Theme and ImGui helpers live in the imgui namespace, matching their files

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shweetandClaude Opus 5.5 committed 2026-10-03 18:47:42 -04:00
1 parent 901c11691b
commit c04a685f18
6 files changed
+12 -15

No files matched your search

+1 -1
View File
@@ -237,7 +237,7 @@ namespace anm2ed
logger.info("Initialized Dear ImGui"); logger.info("Initialized Dear ImGui");
imgui::theme_set((theme::Type)settings.theme); imgui::theme_set((imgui::theme::Type)settings.theme);
ImGui_ImplSDL3_InitForOpenGL(window, glContext); ImGui_ImplSDL3_InitForOpenGL(window, glContext);
ImGui_ImplOpenGL3_Init("#version 330"); ImGui_ImplOpenGL3_Init("#version 330");
+1 -1
View File
@@ -52,7 +52,7 @@ namespace anm2ed
X(WINDOW_POSITION, windowPosition, STRING_UNDEFINED, IVEC2, glm::ivec2()) \ X(WINDOW_POSITION, windowPosition, STRING_UNDEFINED, IVEC2, glm::ivec2()) \
X(IS_VSYNC, isVsync, STRING_UNDEFINED, BOOL, true) \ X(IS_VSYNC, isVsync, STRING_UNDEFINED, BOOL, true) \
X(UI_SCALE, uiScale, STRING_UNDEFINED, FLOAT, 1.0f) \ X(UI_SCALE, uiScale, STRING_UNDEFINED, FLOAT, 1.0f) \
X(THEME, theme, STRING_UNDEFINED, INT, types::theme::DARK) \ X(THEME, theme, STRING_UNDEFINED, INT, imgui::theme::DARK) \
X(LANGUAGE, language, STRING_UNDEFINED, INT, ENGLISH) \ X(LANGUAGE, language, STRING_UNDEFINED, INT, ENGLISH) \
\ \
X(FILE_IS_AUTOSAVE, fileIsAutosave, STRING_UNDEFINED, BOOL, true) \ X(FILE_IS_AUTOSAVE, fileIsAutosave, STRING_UNDEFINED, BOOL, true) \
+1 -4
View File
@@ -5,7 +5,7 @@
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <imgui/imgui.h> #include <imgui/imgui.h>
namespace anm2ed::types namespace anm2ed::imgui
{ {
constexpr ImVec2 to_imvec2(const glm::vec2& v) noexcept { return {v.x, v.y}; } constexpr ImVec2 to_imvec2(const glm::vec2& v) noexcept { return {v.x, v.y}; }
constexpr glm::vec2 to_vec2(const ImVec2& v) noexcept { return {v.x, v.y}; } constexpr glm::vec2 to_vec2(const ImVec2& v) noexcept { return {v.x, v.y}; }
@@ -24,10 +24,7 @@ namespace anm2ed::types
static T value{-1}; static T value{-1};
return value; return value;
} }
}
namespace anm2ed::imgui
{
float row_widget_width_get(int, float = ImGui::GetContentRegionAvail().x); float row_widget_width_get(int, float = ImGui::GetContentRegionAvail().x);
ImVec2 widget_size_with_row_get(int, float = ImGui::GetContentRegionAvail().x); ImVec2 widget_size_with_row_get(int, float = ImGui::GetContentRegionAvail().x);
float footer_height_get(int = 1); float footer_height_get(int = 1);
+2 -2
View File
@@ -66,9 +66,9 @@ namespace anm2ed::imgui
switch (position) switch (position)
{ {
case POPUP_CENTER: case POPUP_CENTER:
ImGui::SetNextWindowPos(viewport->GetCenter(), ImGuiCond_None, types::to_imvec2(glm::vec2(0.5f))); ImGui::SetNextWindowPos(viewport->GetCenter(), ImGuiCond_None, to_imvec2(glm::vec2(0.5f)));
if (POPUP_IS_HEIGHT_SET[type]) if (POPUP_IS_HEIGHT_SET[type])
ImGui::SetNextWindowSize(types::to_imvec2(types::to_vec2(viewport->Size) * POPUP_MULTIPLIERS[type])); ImGui::SetNextWindowSize(to_imvec2(to_vec2(viewport->Size) * POPUP_MULTIPLIERS[type]));
else else
ImGui::SetNextWindowSize(ImVec2(viewport->Size.x * POPUP_MULTIPLIERS[type], 0)); ImGui::SetNextWindowSize(ImVec2(viewport->Size.x * POPUP_MULTIPLIERS[type], 0));
break; break;
+5 -5
View File
@@ -19,25 +19,25 @@ namespace anm2ed::imgui
constexpr ImVec4 COLOR_LIGHT_CHECK_MARK{0.0f, 0.0f, 0.0f, 1.0f}; constexpr ImVec4 COLOR_LIGHT_CHECK_MARK{0.0f, 0.0f, 0.0f, 1.0f};
constexpr auto FRAME_BORDER_SIZE = 1.0f; constexpr auto FRAME_BORDER_SIZE = 1.0f;
void theme_set(types::theme::Type theme) void theme_set(theme::Type theme)
{ {
switch (theme) switch (theme)
{ {
case types::theme::LIGHT: case theme::LIGHT:
ImGui::StyleColorsLight(); ImGui::StyleColorsLight();
break; break;
case types::theme::DARK: case theme::DARK:
default: default:
ImGui::StyleColorsDark(); ImGui::StyleColorsDark();
break; break;
case types::theme::CLASSIC: case theme::CLASSIC:
ImGui::StyleColorsClassic(); ImGui::StyleColorsClassic();
break; break;
} }
auto& style = ImGui::GetStyle(); auto& style = ImGui::GetStyle();
style.FrameBorderSize = FRAME_BORDER_SIZE; style.FrameBorderSize = FRAME_BORDER_SIZE;
if (theme == types::theme::LIGHT) if (theme == theme::LIGHT)
{ {
auto& colors = style.Colors; auto& colors = style.Colors;
colors[ImGuiCol_Button] = COLOR_LIGHT_BUTTON; colors[ImGuiCol_Button] = COLOR_LIGHT_BUTTON;
+2 -2
View File
@@ -2,7 +2,7 @@
#include "strings.hpp" #include "strings.hpp"
namespace anm2ed::types::theme namespace anm2ed::imgui::theme
{ {
#define THEMES \ #define THEMES \
X(LIGHT, LABEL_THEME_LIGHT) \ X(LIGHT, LABEL_THEME_LIGHT) \
@@ -28,5 +28,5 @@ namespace anm2ed::types::theme
namespace anm2ed::imgui namespace anm2ed::imgui
{ {
void theme_set(types::theme::Type); void theme_set(theme::Type);
} }