yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
agent_ui_theme.cc
Go to the documentation of this file.
2
3#include <cstring>
4
5namespace yaze {
6namespace editor {
7
10 const auto& theme = yaze::gui::ThemeManager::Get().GetCurrentTheme();
11
12 // Message colors - derived from theme.chat
13 t.user_message_color = gui::ConvertColorToImVec4(theme.chat.user_message);
14 t.agent_message_color = gui::ConvertColorToImVec4(theme.chat.agent_message);
15 t.system_message_color = gui::ConvertColorToImVec4(theme.chat.system_message);
16
17 t.text_secondary_color = gui::ConvertColorToImVec4(theme.text_secondary);
18
19 // Content colors - derived from theme.chat
20 t.json_text_color = gui::ConvertColorToImVec4(theme.chat.json_text);
21 t.command_text_color = gui::ConvertColorToImVec4(theme.chat.command_text);
22 t.code_bg_color = gui::ConvertColorToImVec4(theme.chat.code_background);
23
24 // UI element colors - derived from base theme
25 t.panel_bg_color = gui::ConvertColorToImVec4(theme.window_bg);
26 t.panel_bg_darker = ImVec4(theme.window_bg.red * 0.8f, theme.window_bg.green * 0.8f,
27 theme.window_bg.blue * 0.8f, 1.0f);
29 t.accent_color = gui::ConvertColorToImVec4(theme.primary);
30
31 // Status colors - derived from base theme
33 t.status_inactive = gui::ConvertColorToImVec4(theme.text_disabled);
37
38 // Provider colors - derived from theme.chat
39 t.provider_ollama = gui::ConvertColorToImVec4(theme.chat.provider_ollama);
40 t.provider_gemini = gui::ConvertColorToImVec4(theme.chat.provider_gemini);
41 t.provider_mock = gui::ConvertColorToImVec4(theme.chat.provider_mock);
42 t.provider_openai = gui::ConvertColorToImVec4(theme.chat.provider_openai);
43
44 // Collaboration colors
47
48 // Proposal colors - derived from theme.chat
49 t.proposal_panel_bg = gui::ConvertColorToImVec4(theme.chat.proposal_panel_bg);
50 t.proposal_accent = gui::ConvertColorToImVec4(theme.chat.proposal_accent);
51
52 // Button colors - derived from theme.chat
53 t.button_copy = gui::ConvertColorToImVec4(theme.chat.button_copy);
54 t.button_copy_hover = gui::ConvertColorToImVec4(theme.chat.button_copy_hover);
55
56 // Gradient colors - derived from theme.chat
57 t.gradient_top = gui::ConvertColorToImVec4(theme.chat.gradient_top);
58 t.gradient_bottom = gui::ConvertColorToImVec4(theme.chat.gradient_bottom);
59
60 // Dungeon editor colors - derived from theme.dungeon
61 t.dungeon_selection_primary = gui::ConvertColorToImVec4(theme.dungeon.selection_primary);
62 t.dungeon_selection_secondary = gui::ConvertColorToImVec4(theme.dungeon.selection_secondary);
63 t.dungeon_selection_pulsing = gui::ConvertColorToImVec4(theme.dungeon.selection_pulsing);
64 t.dungeon_selection_handle = gui::ConvertColorToImVec4(theme.dungeon.selection_handle);
65 t.dungeon_drag_preview = gui::ConvertColorToImVec4(theme.dungeon.drag_preview);
66 t.dungeon_drag_preview_outline = gui::ConvertColorToImVec4(theme.dungeon.drag_preview_outline);
67 t.dungeon_object_wall = gui::ConvertColorToImVec4(theme.dungeon.object_wall);
68 t.dungeon_object_floor = gui::ConvertColorToImVec4(theme.dungeon.object_floor);
69 t.dungeon_object_chest = gui::ConvertColorToImVec4(theme.dungeon.object_chest);
70 t.dungeon_object_door = gui::ConvertColorToImVec4(theme.dungeon.object_door);
71 t.dungeon_object_pot = gui::ConvertColorToImVec4(theme.dungeon.object_pot);
72 t.dungeon_object_stairs = gui::ConvertColorToImVec4(theme.dungeon.object_stairs);
73 t.dungeon_object_decoration = gui::ConvertColorToImVec4(theme.dungeon.object_decoration);
74 t.dungeon_object_default = gui::ConvertColorToImVec4(theme.dungeon.object_default);
75 t.dungeon_grid_cell_highlight = gui::ConvertColorToImVec4(theme.dungeon.grid_cell_highlight);
76 t.dungeon_grid_cell_selected = gui::ConvertColorToImVec4(theme.dungeon.grid_cell_selected);
77 t.dungeon_grid_cell_border = gui::ConvertColorToImVec4(theme.dungeon.grid_cell_border);
78 t.dungeon_grid_text = gui::ConvertColorToImVec4(theme.dungeon.grid_text);
79 t.dungeon_room_border = gui::ConvertColorToImVec4(theme.dungeon.room_border);
80 t.dungeon_room_border_dark = gui::ConvertColorToImVec4(theme.dungeon.room_border_dark);
81 t.dungeon_sprite_layer0 = gui::ConvertColorToImVec4(theme.dungeon.sprite_layer0);
82 t.dungeon_sprite_layer1 = gui::ConvertColorToImVec4(theme.dungeon.sprite_layer1);
83 t.dungeon_sprite_layer2 = gui::ConvertColorToImVec4(theme.dungeon.sprite_layer2);
84 t.dungeon_outline_layer0 = gui::ConvertColorToImVec4(theme.dungeon.outline_layer0);
85 t.dungeon_outline_layer1 = gui::ConvertColorToImVec4(theme.dungeon.outline_layer1);
86 t.dungeon_outline_layer2 = gui::ConvertColorToImVec4(theme.dungeon.outline_layer2);
87
88 // Text colors - derived from base theme
89 t.text_primary = gui::ConvertColorToImVec4(theme.text_primary);
90 t.text_secondary_gray = gui::ConvertColorToImVec4(theme.text_secondary);
91 t.text_info = gui::ConvertColorToImVec4(theme.primary);
95
96 // Box colors - derived from base theme
97 t.box_bg_dark = gui::ConvertColorToImVec4(theme.window_bg);
98 t.box_border = gui::ConvertColorToImVec4(theme.border);
99 t.box_text = gui::ConvertColorToImVec4(theme.text_primary);
100
101 return t;
102}
103
104// Global theme instance
105static AgentUITheme g_current_theme;
106
107namespace AgentUI {
108
110 // Initialize if needed (lazy)
111 if (g_current_theme.user_message_color.w == 0.0f) {
112 g_current_theme = AgentUITheme::FromCurrentTheme();
113 }
114 return g_current_theme;
115}
116
118 g_current_theme = AgentUITheme::FromCurrentTheme();
119}
120
122 const auto& theme = GetTheme();
123 ImGui::PushStyleColor(ImGuiCol_ChildBg, theme.panel_bg_color);
124 ImGui::PushStyleColor(ImGuiCol_Border, theme.panel_border_color);
125 ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 4.0f);
126 ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, 1.0f);
127}
128
130 ImGui::PopStyleVar(2);
131 ImGui::PopStyleColor(2);
132}
133
134void RenderSectionHeader(const char* icon, const char* label,
135 const ImVec4& color) {
136 ImGui::PushStyleColor(ImGuiCol_Text, color);
137 ImGui::Text("%s %s", icon, label);
138 ImGui::PopStyleColor();
139 ImGui::Separator();
140}
141
142void RenderStatusIndicator(const char* label, bool active) {
143 const auto& theme = GetTheme();
144 ImVec4 color = active ? theme.status_active : theme.status_inactive;
145 ImGui::PushStyleColor(ImGuiCol_Text, color);
146 ImGui::Bullet();
147 ImGui::SameLine();
148 ImGui::Text("%s", label);
149 ImGui::PopStyleColor();
150}
151
152void RenderProviderBadge(const char* provider) {
153 const auto& theme = GetTheme();
154 ImVec4 color = theme.provider_mock;
155
156 if (strcmp(provider, "ollama") == 0) {
157 color = theme.provider_ollama;
158 } else if (strcmp(provider, "gemini") == 0) {
159 color = theme.provider_gemini;
160 } else if (strcmp(provider, "openai") == 0) {
161 color = theme.provider_openai;
162 }
163
164 ImGui::PushStyleColor(ImGuiCol_Text, color);
165 ImGui::Text("[%s]", provider);
166 ImGui::PopStyleColor();
167}
168
169void StatusBadge(const char* text, ButtonColor color) {
170 const auto& theme = GetTheme();
171 ImVec4 bg_color;
172
173 switch (color) {
175 bg_color = theme.status_success;
176 break;
178 bg_color = theme.status_warning;
179 break;
181 bg_color = theme.status_error;
182 break;
184 bg_color = theme.accent_color;
185 break;
187 default:
188 bg_color = theme.panel_bg_darker;
189 break;
190 }
191
192 ImGui::PushStyleColor(ImGuiCol_Button, bg_color);
193 ImGui::PushStyleColor(ImGuiCol_ButtonHovered, bg_color);
194 ImGui::PushStyleColor(ImGuiCol_ButtonActive, bg_color);
195 ImGui::SmallButton(text);
196 ImGui::PopStyleColor(3);
197}
198
199void VerticalSpacing(float amount) {
200 ImGui::Dummy(ImVec2(0.0f, amount));
201}
202
203void HorizontalSpacing(float amount) {
204 ImGui::SameLine();
205 ImGui::Dummy(ImVec2(amount, 0.0f));
206 ImGui::SameLine();
207}
208
209bool StyledButton(const char* label, const ImVec4& color, const ImVec2& size) {
210 ImGui::PushStyleColor(ImGuiCol_Button, color);
211 ImGui::PushStyleColor(ImGuiCol_ButtonHovered,
212 ImVec4(color.x * 1.2f, color.y * 1.2f, color.z * 1.2f,
213 color.w));
214 ImGui::PushStyleColor(ImGuiCol_ButtonActive,
215 ImVec4(color.x * 0.8f, color.y * 0.8f, color.z * 0.8f,
216 color.w));
217 bool clicked = ImGui::Button(label, size);
218 ImGui::PopStyleColor(3);
219 return clicked;
220}
221
222bool IconButton(const char* icon, const char* tooltip) {
223 ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0));
224 bool clicked = ImGui::Button(icon);
225 ImGui::PopStyleColor();
226
227 if (tooltip && ImGui::IsItemHovered()) {
228 ImGui::SetTooltip("%s", tooltip);
229 }
230 return clicked;
231}
232
233} // namespace AgentUI
234
235} // namespace editor
236} // namespace yaze
const Theme & GetCurrentTheme() const
static ThemeManager & Get()
void RenderStatusIndicator(const char *label, bool active)
bool StyledButton(const char *label, const ImVec4 &color, const ImVec2 &size)
void HorizontalSpacing(float amount)
const AgentUITheme & GetTheme()
void RenderSectionHeader(const char *icon, const char *label, const ImVec4 &color)
void RenderProviderBadge(const char *provider)
void VerticalSpacing(float amount)
void StatusBadge(const char *text, ButtonColor color)
bool IconButton(const char *icon, const char *tooltip)
ImVec4 ConvertColorToImVec4(const Color &color)
Definition color.h:23
Centralized theme colors for Agent UI components.
static AgentUITheme FromCurrentTheme()