From 8a3c9118f734d9b1781df9d0987f8e16d84bccf5 Mon Sep 17 00:00:00 2001 From: Angad Kambli Date: Wed, 28 Aug 2024 00:29:52 +0530 Subject: [PATCH] minor style tweaks --- ProcSDF/GUI/GUI.cpp | 22 +++++----------------- ProcSDF/GUI/GUI.h | 12 ++++++++++++ ProcSDF/GUI/Inspector.cpp | 16 +++++++++++++--- ProcSDF/GUI/NodeEditor.cpp | 10 ++++++++-- ProcSDF/Rendering/Materials/Material.cpp | 2 ++ ProcSDF/imgui.ini | 2 +- 6 files changed, 41 insertions(+), 23 deletions(-) diff --git a/ProcSDF/GUI/GUI.cpp b/ProcSDF/GUI/GUI.cpp index b3ab6fd..4b40404 100644 --- a/ProcSDF/GUI/GUI.cpp +++ b/ProcSDF/GUI/GUI.cpp @@ -161,6 +161,7 @@ GLFWwindow* GUI::setupImguiGlfw() io.ConfigDragClickToInputText = true; setupStyle(); + defaultFont = io.Fonts->AddFontDefault(); robotoMediumFont = io.Fonts->AddFontFromMemoryCompressedTTF(Roboto_compressed_data, Roboto_compressed_size, 16.0f); robotoRegularFont = io.Fonts->AddFontFromMemoryCompressedTTF(RobotoRegular_compressed_data, RobotoRegular_compressed_size, 16.0f); @@ -174,21 +175,13 @@ void GUI::setupStyle() { ImVec4* colors = ImGui::GetStyle().Colors; -#define HI(v) ImVec4(0.502f, 0.075f, 0.256f, v) -#define MED(v) ImVec4(0.455f, 0.198f, 0.301f, v) -//#define MED(v) ImVec4(0.255f, 0.098f, 0.101f, v) -#define LOW(v) ImVec4(0.232f, 0.201f, 0.271f, v) - // backgrounds (@todo: complete with BG_MED, BG_LOW) -#define BG(v) ImVec4(0.05f, 0.07f, 0.120f, v) -// text -//#define TEXT(v) ImVec4(0.860f, 0.930f, 0.890f, v) -#define TEXT(v) ImVec4(0.860f, 0.930f, 0.890f, v) + auto& style = ImGui::GetStyle(); style.Colors[ImGuiCol_Text] = TEXT(0.78f); style.Colors[ImGuiCol_TextDisabled] = TEXT(0.28f); style.Colors[ImGuiCol_WindowBg] = ImVec4(0.13f, 0.14f, 0.17f, 1.00f); - style.Colors[ImGuiCol_ChildBg] = BG(0.58f); + style.Colors[ImGuiCol_ChildBg] = BG(0.9f); style.Colors[ImGuiCol_PopupBg] = BG(0.9f); style.Colors[ImGuiCol_Border] = ImVec4(0.0f, 0.0f, 0.00f, 0.00f); style.Colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); @@ -206,16 +199,12 @@ void GUI::setupStyle() style.Colors[ImGuiCol_CheckMark] = ImVec4(0.71f, 0.22f, 0.27f, 1.00f); style.Colors[ImGuiCol_SliderGrab] = ImVec4(0.47f, 0.77f, 0.83f, 0.14f); style.Colors[ImGuiCol_SliderGrabActive] = ImVec4(0.71f, 0.22f, 0.27f, 1.00f); - style.Colors[ImGuiCol_Button] = ImVec4(0.47f, 0.77f, 0.83f, 0.14f); - //style.Colors[ImGuiCol_Button] = ImVec4(0.25f, 0.27f, 0.320f, 0.5); - style.Colors[ImGuiCol_ButtonHovered] = MED(0.86f); + style.Colors[ImGuiCol_Button] = ImVec4(0.47f, 0.77f, 0.83f, 0.05f); + style.Colors[ImGuiCol_ButtonHovered] = HI(1.0f); style.Colors[ImGuiCol_ButtonActive] = MED(1.00f); style.Colors[ImGuiCol_Header] = MED(0.76f); style.Colors[ImGuiCol_HeaderHovered] = MED(0.86f); style.Colors[ImGuiCol_HeaderActive] = HI(1.00f); - //style.Colors[ImGuiCol_Column] = ImVec4(0.14f, 0.16f, 0.19f, 1.00f); - //style.Colors[ImGuiCol_ColumnHovered] = MED(0.78f); - //style.Colors[ImGuiCol_ColumnActive] = MED(1.00f); style.Colors[ImGuiCol_ResizeGrip] = ImVec4(0.47f, 0.77f, 0.83f, 0.04f); style.Colors[ImGuiCol_ResizeGripHovered] = MED(0.78f); style.Colors[ImGuiCol_ResizeGripActive] = MED(1.00f); @@ -224,7 +213,6 @@ void GUI::setupStyle() style.Colors[ImGuiCol_PlotHistogram] = TEXT(0.63f); style.Colors[ImGuiCol_PlotHistogramHovered] = MED(1.00f); style.Colors[ImGuiCol_TextSelectedBg] = MED(0.43f); - // [...] style.Colors[ImGuiCol_ModalWindowDimBg] = BG(0.73f); style.WindowPadding = ImVec2(6, 4); diff --git a/ProcSDF/GUI/GUI.h b/ProcSDF/GUI/GUI.h index 74eeef5..6dbc13d 100644 --- a/ProcSDF/GUI/GUI.h +++ b/ProcSDF/GUI/GUI.h @@ -10,6 +10,13 @@ #include "GUI/Inspector.h" #include "GUI/NodeEditor.h" #include "Rendering/Renderer.h" + +#define HI(v) ImVec4(0.502f, 0.075f, 0.256f, v) +#define MED(v) ImVec4(0.455f, 0.198f, 0.301f, v) +#define LOW(v) ImVec4(0.232f, 0.201f, 0.271f, v) +#define BG(v) ImVec4(0.05f, 0.07f, 0.120f, v) +#define TEXT(v) ImVec4(0.860f, 0.930f, 0.890f, v) + class GUI { private: @@ -26,6 +33,7 @@ class GUI ImVec2 m_renderSceneSize; + ImFont* defaultFont; ImFont* robotoMediumFont; ImFont* robotoRegularFont; @@ -46,6 +54,10 @@ class GUI { ImGui::PushFont(robotoMediumFont); } + void pushDefaultFont() + { + ImGui::PushFont(defaultFont); + } GLFWwindow* getWindow() { diff --git a/ProcSDF/GUI/Inspector.cpp b/ProcSDF/GUI/Inspector.cpp index 65b68d8..abe6b1c 100644 --- a/ProcSDF/GUI/Inspector.cpp +++ b/ProcSDF/GUI/Inspector.cpp @@ -28,7 +28,7 @@ void Inspector::draw() { Tab l_oldTab = m_openedTab; - ImVec2 l_buttonSize = ImVec2((ImGui::GetContentRegionAvail().x - 12.0) / 4, 20.0f); + ImVec2 l_buttonSize = ImVec2((ImGui::GetContentRegionAvail().x - 16.0) / 4, 20.0f); ImGui::Dummy(ImVec2(0.0f, 0.0f)); if (l_oldTab == Tab::WORLD_SETTINGS) @@ -93,7 +93,6 @@ void Inspector::draw() ImGui::EndDisabled(); ImGui::PopFont(); } - ImGui::Dummy(ImVec2(0.0f, 0.0f)); switch (m_openedTab) @@ -240,6 +239,7 @@ void Inspector::drawMaterialSettings() if (ImGui::TreeNode("Add Custom Materials")) { ImGui::Indent(); + GUI::getSingleton()->pushMediumFont(); std::vector l_customMaterialNames = NodeGraph::getSingleton()->getCustomMaterialNames(); for (int i = 0; i < l_customMaterialNames.size(); i++) { @@ -256,6 +256,7 @@ void Inspector::drawMaterialSettings() } } } + ImGui::PopFont(); ImGui::Unindent(); ImGui::TreePop(); } @@ -282,6 +283,7 @@ void Inspector::drawNodeGraphSettings() if (ImGui::TreeNode("Primitives")) { ImGui::Indent(); + GUI::getSingleton()->pushMediumFont(); ImGui::PushStyleColor(ImGuiCol_Button, imgui_colors::PRIMITIVE); if (ImGui::Button("Sphere")) { @@ -322,7 +324,7 @@ void Inspector::drawNodeGraphSettings() { addNode(); } - + ImGui::PopFont(); ImGui::PopStyleColor(); ImGui::Unindent(); ImGui::TreePop(); @@ -331,6 +333,7 @@ void Inspector::drawNodeGraphSettings() if (ImGui::TreeNode("Operations")) { ImGui::Indent(); + GUI::getSingleton()->pushMediumFont(); ImGui::PushStyleColor(ImGuiCol_Button, imgui_colors::OPERATION); if (ImGui::Button("Intersection")) { @@ -356,6 +359,7 @@ void Inspector::drawNodeGraphSettings() { addNode(); } + ImGui::PopFont(); ImGui::PopStyleColor(); ImGui::Unindent(); ImGui::TreePop(); @@ -364,6 +368,7 @@ void Inspector::drawNodeGraphSettings() if (ImGui::TreeNode("Object")) { ImGui::Indent(); + GUI::getSingleton()->pushMediumFont(); ImGui::PushStyleColor(ImGuiCol_Button, imgui_colors::OBJECT); if (ImGui::Button("Object")) { @@ -373,6 +378,7 @@ void Inspector::drawNodeGraphSettings() NodeGraph::getSingleton()->addLink(object_node->m_outputIDs[0], NodeGraph::getSingleton()->m_finalNode->m_inputIDs[0]); } + ImGui::PopFont(); ImGui::PopStyleColor(); ImGui::Unindent(); ImGui::TreePop(); @@ -381,6 +387,7 @@ void Inspector::drawNodeGraphSettings() if (ImGui::TreeNode("Transform")) { ImGui::Indent(); + GUI::getSingleton()->pushMediumFont(); ImGui::PushStyleColor(ImGuiCol_Button, imgui_colors::TRANFSFORM); if (ImGui::Button("Translation")) { @@ -406,6 +413,7 @@ void Inspector::drawNodeGraphSettings() { addNode(); } + ImGui::PopFont(); ImGui::PopStyleColor(); ImGui::Unindent(); ImGui::TreePop(); @@ -413,6 +421,7 @@ void Inspector::drawNodeGraphSettings() if (ImGui::TreeNode("Custom Nodes")) { ImGui::Indent(); + GUI::getSingleton()->pushMediumFont(); ImGui::PushStyleColor(ImGuiCol_Button, imgui_colors::CUSTOM_NODE); std::vector l_customNodeNames = NodeGraph::getSingleton()->getCustomNodeNames(); for (int i = 0; i < l_customNodeNames.size(); i++) @@ -434,6 +443,7 @@ void Inspector::drawNodeGraphSettings() GUI_Utilities::appendToSameLineIfApplicable(l_approximateButtonSize); } } + ImGui::PopFont(); ImGui::PopStyleColor(); ImGui::Unindent(); ImGui::TreePop(); diff --git a/ProcSDF/GUI/NodeEditor.cpp b/ProcSDF/GUI/NodeEditor.cpp index 3b5e956..7542d60 100644 --- a/ProcSDF/GUI/NodeEditor.cpp +++ b/ProcSDF/GUI/NodeEditor.cpp @@ -32,10 +32,18 @@ void NodeEditor::draw() ImGui::SameLine(); + if ((!NodeGraph::getSingleton()->checkCompilationError()) && NodeGraph::getSingleton()->isDirty()) + { + ImGui::PushStyleColor(ImGuiCol_Button, HI(1.0)); + } if (ImGui::Button("Recompile")) { NodeGraph::getSingleton()->recompileNodeGraph(); } + if ((!NodeGraph::getSingleton()->checkCompilationError()) && NodeGraph::getSingleton()->isDirty()) + { + ImGui::PopStyleColor(); + } ImGui::SameLine(); @@ -92,13 +100,11 @@ void NodeEditor::draw() float widthNeeded = ImGui::CalcTextSize("Yes").x + style.FramePadding.x * 2.f + ImGui::CalcTextSize("No").x + 5.0f; ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::CalcTextSize(confString).x - widthNeeded); - ImGui::PushStyleColor(ImGuiCol_Button, imgui_colors::RED); if (ImGui::Button("Yes")) { glfwSetWindowShouldClose(GUI::getSingleton()->getWindow(), GL_TRUE); } - ImGui::PopStyleColor(); ImGui::SameLine(); ImGui::Dummy(ImVec2(5.0f, 5.0f)); ImGui::SameLine(); diff --git a/ProcSDF/Rendering/Materials/Material.cpp b/ProcSDF/Rendering/Materials/Material.cpp index bb79a8c..c6d756d 100644 --- a/ProcSDF/Rendering/Materials/Material.cpp +++ b/ProcSDF/Rendering/Materials/Material.cpp @@ -70,6 +70,7 @@ void Material::draw(bool &p_del) { // std::string l_edit_mat_str = "Edit " + m_name; ImGui::PushStyleColor(ImGuiCol_Button, IM_COL32(m_color[0] * 255, m_color[1] * 255, m_color[2] * 255, 255)); + GUI::getSingleton()->pushMediumFont(); if (!GUI_Utilities::isWhiteContrasting(m_color)) { ImGui::PushStyleColor(ImGuiCol_Text, imgui_colors::BLACK); @@ -82,6 +83,7 @@ void Material::draw(bool &p_del) { ImGui::PopStyleColor(); } + ImGui::PopFont(); ImGui::PopStyleColor(); } } diff --git a/ProcSDF/imgui.ini b/ProcSDF/imgui.ini index 9c2d0fd..5252cc4 100644 --- a/ProcSDF/imgui.ini +++ b/ProcSDF/imgui.ini @@ -54,7 +54,7 @@ Size=1920,1080 Collapsed=0 [Window][Confirmation] -Pos=744,511 +Pos=743,513 Size=411,77 Collapsed=0