added more control over Gui widget's depth

This commit is contained in:
Anselme 2017-10-19 22:23:24 +02:00
parent fa0d75976f
commit a91efd7354
9 changed files with 45 additions and 17 deletions

View File

@ -50,24 +50,34 @@ void Editor::update()
void Editor::gui() 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()); DeferredPipeline* pipeline = dynamic_cast<DeferredPipeline*>(m_scene->getPipeline());
bool pipeline_gui_status = pipeline->isDebugGuiVisible(); 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(); pipeline->toggleDebugGui();
bool resroucePackEditorStatus = m_editedResourcePack; bool resroucePackEditorStatus = m_editedResourcePack;
if(ImGui::Checkbox("Resource pack editor editor", &resroucePackEditorStatus)) if(ImGui::MenuItem("Resource pack editor editor", NULL, &resroucePackEditorStatus))
toggleResourcePackGui(); toggleResourcePackGui();
bool pickerStatus = m_pickerEnabled; bool pickerStatus = m_pickerEnabled;
if(ImGui::Checkbox("Picker", &pickerStatus)) if(ImGui::MenuItem("Picker", NULL, &pickerStatus))
togglePicker(); togglePicker();
ImGui::EndMenu();
}
ImGui::EndMainMenuBar();
} }
ImGui::End();
} }
void Editor::materialGui() void Editor::materialGui()

View File

@ -9,7 +9,7 @@
#include "SparrowRenderer/mesh.h" #include "SparrowRenderer/mesh.h"
#include "SparrowRenderer/pbrmaterial.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_dimension(dimension),
m_color(color), m_color(color),
m_color_updated(false), m_color_updated(false),
@ -52,6 +52,11 @@ void BackGroundNode::setOpacity(float opacity){
m_opacity_updated = true; m_opacity_updated = true;
} }
void BackGroundNode::setDepth(float depth)
{
m_mesh->setDepth(depth);
}
glm::vec2 BackGroundNode::getDimension(){ glm::vec2 BackGroundNode::getDimension(){
return m_dimension; return m_dimension;
} }

View File

@ -19,7 +19,9 @@ public:
void update(); void update();
void setColor(glm::vec3 color); void setColor(glm::vec3 color);
void setOpacity(float opacity); void setOpacity(float opacity);
void setDepth(float depth);
glm::vec2 getDimension(); glm::vec2 getDimension();
MeshNode* getMeshNode() { return m_mesh; }
}; };

View File

@ -43,6 +43,9 @@ void ButtonNode::update()
if(m_label->wasUpdated()){ if(m_label->wasUpdated()){
m_label->setPosition(m_shape->getDimension()/glm::vec2(2,2) - m_label->getDimension()/glm::vec2(2,2)); 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()) for (auto action : input->getActions())

View File

@ -4,7 +4,7 @@
RectangleButtonShape::RectangleButtonShape(glm::vec2 dimension):ButtonShape(),m_dimension(dimension) 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){ bool RectangleButtonShape::hover(glm::vec2 button_position, glm::vec2 mouse_position){

View File

@ -20,7 +20,7 @@ public:
virtual glm::vec2 getDimension() = 0; virtual glm::vec2 getDimension() = 0;
}; };
class RectangleButtonShape:public ButtonShape class RectangleButtonShape : public ButtonShape
{ {
glm::vec2 m_dimension; glm::vec2 m_dimension;
public: public:

View File

@ -20,6 +20,7 @@ public:
void setColor(glm::vec3 color); void setColor(glm::vec3 color);
glm::vec2 getDimension(); glm::vec2 getDimension();
bool wasUpdated(); bool wasUpdated();
TextNode* getTextNode() { return m_text; }
}; };
#endif // LABELNODE_H #endif // LABELNODE_H

View File

@ -13,7 +13,13 @@ void MeshNode::setSceneTree(SceneTree *tree)
m_scene->registerMeshType(m_geometry.mesh->getFlags()); 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); m_geometry.mesh->setDepth(depth);
} }

View File

@ -30,6 +30,7 @@ public:
virtual void update(); virtual void update();
float getDepth();
void setDepth(float depth); void setDepth(float depth);
virtual GeometryNode* getGeometryNode() { return &m_geometry; } virtual GeometryNode* getGeometryNode() { return &m_geometry; }