Skip to content

Commit

Permalink
minor style tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
angad-k committed Aug 27, 2024
1 parent 6807657 commit 8a3c911
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 23 deletions.
22 changes: 5 additions & 17 deletions ProcSDF/GUI/GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
12 changes: 12 additions & 0 deletions ProcSDF/GUI/GUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -26,6 +33,7 @@ class GUI

ImVec2 m_renderSceneSize;

ImFont* defaultFont;
ImFont* robotoMediumFont;
ImFont* robotoRegularFont;

Expand All @@ -46,6 +54,10 @@ class GUI
{
ImGui::PushFont(robotoMediumFont);
}
void pushDefaultFont()
{
ImGui::PushFont(defaultFont);
}

GLFWwindow* getWindow()
{
Expand Down
16 changes: 13 additions & 3 deletions ProcSDF/GUI/Inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -93,7 +93,6 @@ void Inspector::draw()
ImGui::EndDisabled();
ImGui::PopFont();
}

ImGui::Dummy(ImVec2(0.0f, 0.0f));

switch (m_openedTab)
Expand Down Expand Up @@ -240,6 +239,7 @@ void Inspector::drawMaterialSettings()
if (ImGui::TreeNode("Add Custom Materials"))
{
ImGui::Indent();
GUI::getSingleton()->pushMediumFont();
std::vector <std::string> l_customMaterialNames = NodeGraph::getSingleton()->getCustomMaterialNames();
for (int i = 0; i < l_customMaterialNames.size(); i++)
{
Expand All @@ -256,6 +256,7 @@ void Inspector::drawMaterialSettings()
}
}
}
ImGui::PopFont();
ImGui::Unindent();
ImGui::TreePop();
}
Expand All @@ -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"))
{
Expand Down Expand Up @@ -322,7 +324,7 @@ void Inspector::drawNodeGraphSettings()
{
addNode<CylinderNode>();
}

ImGui::PopFont();
ImGui::PopStyleColor();
ImGui::Unindent();
ImGui::TreePop();
Expand All @@ -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"))
{
Expand All @@ -356,6 +359,7 @@ void Inspector::drawNodeGraphSettings()
{
addNode<OnionNode>();
}
ImGui::PopFont();
ImGui::PopStyleColor();
ImGui::Unindent();
ImGui::TreePop();
Expand All @@ -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"))
{
Expand All @@ -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();
Expand All @@ -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"))
{
Expand All @@ -406,13 +413,15 @@ void Inspector::drawNodeGraphSettings()
{
addNode<Scale>();
}
ImGui::PopFont();
ImGui::PopStyleColor();
ImGui::Unindent();
ImGui::TreePop();
}
if (ImGui::TreeNode("Custom Nodes"))
{
ImGui::Indent();
GUI::getSingleton()->pushMediumFont();
ImGui::PushStyleColor(ImGuiCol_Button, imgui_colors::CUSTOM_NODE);
std::vector <std::string> l_customNodeNames = NodeGraph::getSingleton()->getCustomNodeNames();
for (int i = 0; i < l_customNodeNames.size(); i++)
Expand All @@ -434,6 +443,7 @@ void Inspector::drawNodeGraphSettings()
GUI_Utilities::appendToSameLineIfApplicable(l_approximateButtonSize);
}
}
ImGui::PopFont();
ImGui::PopStyleColor();
ImGui::Unindent();
ImGui::TreePop();
Expand Down
10 changes: 8 additions & 2 deletions ProcSDF/GUI/NodeEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions ProcSDF/Rendering/Materials/Material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -82,6 +83,7 @@ void Material::draw(bool &p_del)
{
ImGui::PopStyleColor();
}
ImGui::PopFont();
ImGui::PopStyleColor();
}
}
Expand Down
2 changes: 1 addition & 1 deletion ProcSDF/imgui.ini
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Size=1920,1080
Collapsed=0

[Window][Confirmation]
Pos=744,511
Pos=743,513
Size=411,77
Collapsed=0

0 comments on commit 8a3c911

Please sign in to comment.