yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
theme.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Theme definitions for yaze UI components.
3// Centralized color palette and style constants to ensure visual consistency.
4
5#ifndef YAZE_SRC_APP_GUI_STYLE_THEME_H_
6#define YAZE_SRC_APP_GUI_STYLE_THEME_H_
7
8#include "imgui.h"
9
11
12struct Theme {
13 // Primary brand color (used for titles, highlights)
14 ImVec4 primary = ImVec4(0.196f, 0.6f, 0.8f, 1.0f); // teal-ish
15 // Secondary accent (buttons, active states)
16 ImVec4 secondary = ImVec4(0.133f, 0.545f, 0.133f, 1.0f); // forest green
17 // Warning / error color
18 ImVec4 warning = ImVec4(0.8f, 0.2f, 0.2f, 1.0f);
19 // Success color
20 ImVec4 success = ImVec4(0.2f, 0.8f, 0.2f, 1.0f);
21 // Background for panels
22 ImVec4 panel_bg = ImVec4(0.07f, 0.07f, 0.07f, 0.95f);
23 // Text color (default)
24 ImVec4 text = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
25 // Rounded corner radius for windows and child panels
26 float rounding = 6.0f;
27};
28
29// Returns the default theme used throughout the application.
30inline const Theme& DefaultTheme() {
31 static Theme theme;
32 return theme;
33}
34
35// Apply the theme to ImGui style (call once per frame before drawing UI).
36inline void ApplyTheme(const Theme& theme) {
37 ImGuiStyle& style = ImGui::GetStyle();
38 style.WindowRounding = theme.rounding;
39 style.ChildRounding = theme.rounding;
40 style.FrameRounding = theme.rounding;
41 style.GrabRounding = theme.rounding;
42 style.PopupRounding = theme.rounding;
43 style.ScrollbarRounding = theme.rounding;
44
45 // Colors – we keep most defaults, but override key ones.
46 style.Colors[ImGuiCol_TitleBgActive] = theme.primary;
47 style.Colors[ImGuiCol_Button] = theme.secondary;
48 style.Colors[ImGuiCol_ButtonHovered] = ImVec4(theme.secondary.x * 1.2f,
49 theme.secondary.y * 1.2f,
50 theme.secondary.z * 1.2f, 1.0f);
51 style.Colors[ImGuiCol_Text] = theme.text;
52 style.Colors[ImGuiCol_ChildBg] = theme.panel_bg;
53}
54
55} // namespace yaze::gui::style
56
57#endif // YAZE_SRC_APP_GUI_STYLE_THEME_H_
const Theme & DefaultTheme()
Definition theme.h:30
void ApplyTheme(const Theme &theme)
Definition theme.h:36