Skip to content

Commit 638e7f2

Browse files
committed
style(userInterface): adapt functions panel colors to themes
1 parent efa63c8 commit 638e7f2

2 files changed

Lines changed: 28 additions & 9 deletions

File tree

‎include/mathplotter/userInterface.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace mathplotter {
2525
int m_selectedThemeIndex{0};
2626
std::vector<FunctionRow> m_functionRows;
2727

28-
void DrawFunctionPanel();
28+
void DrawFunctionPanel(const Theme& theme);
2929
void ConfigureTitle(const Theme& theme);
3030
void SelectTheme(Theme& theme);
3131
ImVec4 ToImGuiColor(const sf::Color& color);

‎src/userInterface.cpp‎

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,31 @@ namespace mathplotter {
126126
ImGui::End();
127127
}
128128

129-
void UserInterface::DrawFunctionPanel() {
129+
void UserInterface::DrawFunctionPanel(const Theme& theme) {
130+
const ImVec4 background{
131+
ToImGuiColor(theme.GetBackgroundColor())
132+
};
133+
134+
const ImVec4 foreground{
135+
ToImGuiColor(theme.GetAxisLabelColor())
136+
};
137+
138+
ImVec4 hovered{foreground};
139+
hovered.w = 0.15f;
140+
141+
ImVec4 active{foreground};
142+
active.w = 0.25f;
143+
144+
ImGui::PushStyleColor(ImGuiCol_WindowBg, background);
145+
ImGui::PushStyleColor(ImGuiCol_PopupBg, background);
146+
ImGui::PushStyleColor(ImGuiCol_Text, foreground);
147+
ImGui::PushStyleColor(ImGuiCol_Border, foreground);
148+
ImGui::PushStyleColor(ImGuiCol_TableBorderStrong, foreground);
149+
ImGui::PushStyleColor(ImGuiCol_TableBorderLight, foreground);
150+
ImGui::PushStyleColor(ImGuiCol_Button, background);
151+
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, hovered);
152+
ImGui::PushStyleColor(ImGuiCol_ButtonActive, active);
153+
130154
constexpr ImGuiWindowFlags windowFlags{
131155
ImGuiWindowFlags_NoMove |
132156
ImGuiWindowFlags_NoResize |
@@ -346,11 +370,6 @@ namespace mathplotter {
346370
1.f
347371
);
348372

349-
ImGui::PushStyleColor(
350-
ImGuiCol_Border,
351-
ImVec4(0.f, 0.f, 0.f, 1.f)
352-
);
353-
354373
if (
355374
ImGui::ColorButton(
356375
"##FunctionColor",
@@ -397,7 +416,6 @@ namespace mathplotter {
397416
ImGui::EndPopup();
398417
}
399418

400-
ImGui::PopStyleColor();
401419
ImGui::PopStyleVar();
402420
}
403421

@@ -457,10 +475,11 @@ namespace mathplotter {
457475
}
458476

459477
ImGui::End();
478+
ImGui::PopStyleColor(9);
460479
}
461480

462481
void UserInterface::Draw([[maybe_unused]]sf::RenderWindow& window, Theme& theme) {
463-
DrawFunctionPanel();
482+
DrawFunctionPanel(theme);
464483
SelectTheme(theme);
465484
//window.draw(m_title);
466485
}

0 commit comments

Comments
 (0)