added more control over Gui widget's depth
This commit is contained in:
parent
fa0d75976f
commit
a91efd7354
@ -50,24 +50,34 @@ void Editor::update()
|
||||
|
||||
void Editor::gui()
|
||||
{
|
||||
ImGui::Begin("SparrowEditor", &m_editorEnabled);
|
||||
if(ImGui::BeginMainMenuBar())
|
||||
{
|
||||
ImGui::Checkbox("Material editor", &m_materialEditorEnabled);
|
||||
if(ImGui::BeginMenu("File"))
|
||||
{
|
||||
ImGui::MenuItem("Load scene");
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if(ImGui::BeginMenu("Tools"))
|
||||
{
|
||||
ImGui::MenuItem("Material editor", NULL, &m_materialEditorEnabled);
|
||||
|
||||
DeferredPipeline* pipeline = dynamic_cast<DeferredPipeline*>(m_scene->getPipeline());
|
||||
bool pipeline_gui_status = pipeline->isDebugGuiVisible();
|
||||
if(ImGui::Checkbox("Rendering pipeline debug gui", &pipeline_gui_status))
|
||||
if(ImGui::MenuItem("Rendering pipeline debug gui", NULL, &pipeline_gui_status))
|
||||
pipeline->toggleDebugGui();
|
||||
|
||||
bool resroucePackEditorStatus = m_editedResourcePack;
|
||||
if(ImGui::Checkbox("Resource pack editor editor", &resroucePackEditorStatus))
|
||||
if(ImGui::MenuItem("Resource pack editor editor", NULL, &resroucePackEditorStatus))
|
||||
toggleResourcePackGui();
|
||||
|
||||
bool pickerStatus = m_pickerEnabled;
|
||||
if(ImGui::Checkbox("Picker", &pickerStatus))
|
||||
if(ImGui::MenuItem("Picker", NULL, &pickerStatus))
|
||||
togglePicker();
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
ImGui::EndMainMenuBar();
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void Editor::materialGui()
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "SparrowRenderer/mesh.h"
|
||||
#include "SparrowRenderer/pbrmaterial.h"
|
||||
|
||||
BackGroundNode::BackGroundNode(glm::vec2 dimension, glm::vec3 color, float opacity,float depth):
|
||||
BackGroundNode::BackGroundNode(glm::vec2 dimension, glm::vec3 color, float opacity, float depth):
|
||||
m_dimension(dimension),
|
||||
m_color(color),
|
||||
m_color_updated(false),
|
||||
@ -52,6 +52,11 @@ void BackGroundNode::setOpacity(float opacity){
|
||||
m_opacity_updated = true;
|
||||
}
|
||||
|
||||
void BackGroundNode::setDepth(float depth)
|
||||
{
|
||||
m_mesh->setDepth(depth);
|
||||
}
|
||||
|
||||
glm::vec2 BackGroundNode::getDimension(){
|
||||
return m_dimension;
|
||||
}
|
||||
|
@ -19,7 +19,9 @@ public:
|
||||
void update();
|
||||
void setColor(glm::vec3 color);
|
||||
void setOpacity(float opacity);
|
||||
void setDepth(float depth);
|
||||
glm::vec2 getDimension();
|
||||
MeshNode* getMeshNode() { return m_mesh; }
|
||||
};
|
||||
|
||||
|
||||
|
@ -43,6 +43,9 @@ void ButtonNode::update()
|
||||
|
||||
if(m_label->wasUpdated()){
|
||||
m_label->setPosition(m_shape->getDimension()/glm::vec2(2,2) - m_label->getDimension()/glm::vec2(2,2));
|
||||
// make sure the label is in front of the button background
|
||||
if(m_label->getTextNode() != nullptr)
|
||||
m_label->getTextNode()->setDepth(m_shape->getBackGround()->getMeshNode()->getDepth() + 0.1f);
|
||||
}
|
||||
|
||||
for (auto action : input->getActions())
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
RectangleButtonShape::RectangleButtonShape(glm::vec2 dimension):ButtonShape(),m_dimension(dimension)
|
||||
{
|
||||
m_background = new BackGroundNode(dimension,glm::vec3(1.,1.,1.),1,0);
|
||||
m_background = new BackGroundNode(dimension, glm::vec3(1.,1.,1.), 1, 5);
|
||||
}
|
||||
|
||||
bool RectangleButtonShape::hover(glm::vec2 button_position, glm::vec2 mouse_position){
|
||||
|
@ -20,7 +20,7 @@ public:
|
||||
virtual glm::vec2 getDimension() = 0;
|
||||
};
|
||||
|
||||
class RectangleButtonShape:public ButtonShape
|
||||
class RectangleButtonShape : public ButtonShape
|
||||
{
|
||||
glm::vec2 m_dimension;
|
||||
public:
|
||||
|
@ -20,6 +20,7 @@ public:
|
||||
void setColor(glm::vec3 color);
|
||||
glm::vec2 getDimension();
|
||||
bool wasUpdated();
|
||||
TextNode* getTextNode() { return m_text; }
|
||||
};
|
||||
|
||||
#endif // LABELNODE_H
|
||||
|
@ -13,7 +13,13 @@ void MeshNode::setSceneTree(SceneTree *tree)
|
||||
m_scene->registerMeshType(m_geometry.mesh->getFlags());
|
||||
}
|
||||
|
||||
void MeshNode::setDepth(float depth){
|
||||
float MeshNode::getDepth()
|
||||
{
|
||||
return m_geometry.mesh->getDepth();
|
||||
}
|
||||
|
||||
void MeshNode::setDepth(float depth)
|
||||
{
|
||||
m_geometry.mesh->setDepth(depth);
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@ public:
|
||||
|
||||
virtual void update();
|
||||
|
||||
float getDepth();
|
||||
void setDepth(float depth);
|
||||
|
||||
virtual GeometryNode* getGeometryNode() { return &m_geometry; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user