yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
agent_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.agent
13 t.user_message_color = gui::ConvertColorToImVec4(theme.agent.user_message);
14 t.agent_message_color = gui::ConvertColorToImVec4(theme.agent.agent_message);
16 gui::ConvertColorToImVec4(theme.agent.system_message);
17
19 gui::ConvertColorToImVec4(theme.agent.text_secondary);
20
21 // Content colors - derived from theme.agent
22 t.json_text_color = gui::ConvertColorToImVec4(theme.agent.json_text);
23 t.command_text_color = gui::ConvertColorToImVec4(theme.agent.command_text);
24 t.code_bg_color = gui::ConvertColorToImVec4(theme.agent.code_background);
25
26 // UI element colors - derived from theme.agent
27 t.panel_bg_color = gui::ConvertColorToImVec4(theme.agent.panel_bg);
28 t.panel_bg_darker = gui::ConvertColorToImVec4(theme.agent.panel_bg_darker);
29 t.panel_border_color = gui::ConvertColorToImVec4(theme.agent.panel_border);
30 t.accent_color = gui::ConvertColorToImVec4(theme.agent.accent);
31
32 // Status colors - derived from theme.agent
33 t.status_active = gui::ConvertColorToImVec4(theme.agent.status_active);
34 t.status_inactive = gui::ConvertColorToImVec4(theme.agent.status_inactive);
35 t.status_success = gui::ConvertColorToImVec4(theme.agent.status_success);
36 t.status_warning = gui::ConvertColorToImVec4(theme.agent.status_warning);
37 t.status_error = gui::ConvertColorToImVec4(theme.agent.status_error);
38
39 // Provider colors - derived from theme.agent
40 t.provider_ollama = gui::ConvertColorToImVec4(theme.agent.provider_ollama);
41 t.provider_gemini = gui::ConvertColorToImVec4(theme.agent.provider_gemini);
42 t.provider_mock = gui::ConvertColorToImVec4(theme.agent.provider_mock);
43 t.provider_openai = gui::ConvertColorToImVec4(theme.agent.provider_openai);
44
45 // Collaboration colors
47 gui::ConvertColorToImVec4(theme.agent.collaboration_active);
49 gui::ConvertColorToImVec4(theme.agent.collaboration_inactive);
50
51 // Proposal colors - derived from theme.agent
53 gui::ConvertColorToImVec4(theme.agent.proposal_panel_bg);
54 t.proposal_accent = gui::ConvertColorToImVec4(theme.agent.proposal_accent);
55
56 // Button colors - derived from theme.agent
57 t.button_copy = gui::ConvertColorToImVec4(theme.agent.button_copy);
59 gui::ConvertColorToImVec4(theme.agent.button_copy_hover);
60
61 // Gradient colors - derived from theme.agent
62 t.gradient_top = gui::ConvertColorToImVec4(theme.agent.gradient_top);
63 t.gradient_bottom = gui::ConvertColorToImVec4(theme.agent.gradient_bottom);
64
65 // Unified editor colors
66 t.editor_background = gui::ConvertColorToImVec4(theme.editor_background);
67 t.editor_grid = gui::ConvertColorToImVec4(theme.editor_grid);
68 t.editor_cursor = gui::ConvertColorToImVec4(theme.editor_cursor);
69 t.editor_selection = gui::ConvertColorToImVec4(theme.editor_selection);
70
71 // Interaction colors
72 t.selection_primary = gui::ConvertColorToImVec4(theme.selection_primary);
73 t.selection_secondary = gui::ConvertColorToImVec4(theme.selection_secondary);
74 t.selection_hover = gui::ConvertColorToImVec4(theme.selection_hover);
75 t.selection_pulsing = gui::ConvertColorToImVec4(theme.selection_pulsing);
76 t.selection_handle = gui::ConvertColorToImVec4(theme.selection_handle);
77 t.drag_preview = gui::ConvertColorToImVec4(theme.drag_preview);
79 gui::ConvertColorToImVec4(theme.drag_preview_outline);
80
81 // Entity colors
82 t.entrance_color = gui::ConvertColorToImVec4(theme.entrance_color);
83 t.hole_color = gui::ConvertColorToImVec4(theme.hole_color);
84 t.exit_color = gui::ConvertColorToImVec4(theme.exit_color);
85 t.item_color = gui::ConvertColorToImVec4(theme.item_color);
86 t.sprite_color = gui::ConvertColorToImVec4(theme.sprite_color);
87 t.transport_color = gui::ConvertColorToImVec4(theme.transport_color);
88 t.music_zone_color = gui::ConvertColorToImVec4(theme.music_zone_color);
89
90 // Dungeon editor colors - derived from theme.dungeon
92 gui::ConvertColorToImVec4(theme.dungeon.selection_primary);
94 gui::ConvertColorToImVec4(theme.dungeon.selection_secondary);
96 gui::ConvertColorToImVec4(theme.dungeon.selection_pulsing);
98 gui::ConvertColorToImVec4(theme.dungeon.selection_handle);
100 gui::ConvertColorToImVec4(theme.dungeon.drag_preview);
102 gui::ConvertColorToImVec4(theme.dungeon.drag_preview_outline);
103 t.dungeon_object_wall = gui::ConvertColorToImVec4(theme.dungeon.object_wall);
105 gui::ConvertColorToImVec4(theme.dungeon.object_floor);
107 gui::ConvertColorToImVec4(theme.dungeon.object_chest);
108 t.dungeon_object_door = gui::ConvertColorToImVec4(theme.dungeon.object_door);
109 t.dungeon_object_pot = gui::ConvertColorToImVec4(theme.dungeon.object_pot);
111 gui::ConvertColorToImVec4(theme.dungeon.object_stairs);
113 gui::ConvertColorToImVec4(theme.dungeon.object_decoration);
115 gui::ConvertColorToImVec4(theme.dungeon.object_default);
117 gui::ConvertColorToImVec4(theme.dungeon.grid_cell_highlight);
119 gui::ConvertColorToImVec4(theme.dungeon.grid_cell_selected);
121 gui::ConvertColorToImVec4(theme.dungeon.grid_cell_border);
122 t.dungeon_grid_text = gui::ConvertColorToImVec4(theme.dungeon.grid_text);
123 t.dungeon_room_border = gui::ConvertColorToImVec4(theme.dungeon.room_border);
125 gui::ConvertColorToImVec4(theme.dungeon.room_border_dark);
127 gui::ConvertColorToImVec4(theme.dungeon.sprite_layer0);
129 gui::ConvertColorToImVec4(theme.dungeon.sprite_layer1);
131 gui::ConvertColorToImVec4(theme.dungeon.sprite_layer2);
133 gui::ConvertColorToImVec4(theme.dungeon.outline_layer0);
135 gui::ConvertColorToImVec4(theme.dungeon.outline_layer1);
137 gui::ConvertColorToImVec4(theme.dungeon.outline_layer2);
138
139 // Text colors - derived from base theme
140 t.text_primary = gui::ConvertColorToImVec4(theme.text_primary);
141 t.text_secondary_gray = gui::ConvertColorToImVec4(theme.text_secondary);
142 t.text_info = gui::ConvertColorToImVec4(theme.primary);
146
147 // Box colors - derived from base theme
148 t.box_bg_dark = gui::ConvertColorToImVec4(theme.window_bg);
149 t.box_border = gui::ConvertColorToImVec4(theme.border);
150 t.box_text = gui::ConvertColorToImVec4(theme.text_primary);
151
152 return t;
153}
154
155// Global theme instance
156static AgentUITheme g_current_theme;
157static bool g_theme_initialized = false;
158
159namespace AgentUI {
160
162 if (!g_theme_initialized) {
163 g_current_theme = AgentUITheme::FromCurrentTheme();
164 g_theme_initialized = true;
165 }
166 return g_current_theme;
167}
168
170 g_current_theme = AgentUITheme::FromCurrentTheme();
171 g_theme_initialized = true;
172}
173
175 const auto& theme = GetTheme();
176 ImGui::PushStyleColor(ImGuiCol_ChildBg, theme.panel_bg_color);
177 ImGui::PushStyleColor(ImGuiCol_Border, theme.panel_border_color);
178 ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 4.0f);
179 ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, 1.0f);
180}
181
183 ImGui::PopStyleVar(2);
184 ImGui::PopStyleColor(2);
185}
186
187void RenderSectionHeader(const char* icon, const char* label,
188 const ImVec4& color) {
189 ImGui::PushStyleColor(ImGuiCol_Text, color);
190 ImGui::Text("%s %s", icon, label);
191 ImGui::PopStyleColor();
192 ImGui::Separator();
193}
194
195void RenderStatusIndicator(const char* label, bool active) {
196 const auto& theme = GetTheme();
197 ImVec4 color = active ? theme.status_active : theme.status_inactive;
198 ImGui::PushStyleColor(ImGuiCol_Text, color);
199 ImGui::Bullet();
200 ImGui::SameLine();
201 ImGui::Text("%s", label);
202 ImGui::PopStyleColor();
203}
204
205void RenderProviderBadge(const char* provider) {
206 const auto& theme = GetTheme();
207 ImVec4 color = theme.provider_mock;
208
209 if (strcmp(provider, "ollama") == 0) {
210 color = theme.provider_ollama;
211 } else if (strcmp(provider, "gemini") == 0) {
212 color = theme.provider_gemini;
213 } else if (strcmp(provider, "anthropic") == 0) {
214 color = theme.provider_openai;
215 } else if (strcmp(provider, "openai") == 0) {
216 color = theme.provider_openai;
217 }
218
219 ImGui::PushStyleColor(ImGuiCol_Text, color);
220 ImGui::Text("[%s]", provider);
221 ImGui::PopStyleColor();
222}
223
224void StatusBadge(const char* text, ButtonColor color) {
225 const auto& theme = GetTheme();
226 ImVec4 bg_color;
227
228 switch (color) {
230 bg_color = theme.status_success;
231 break;
233 bg_color = theme.status_warning;
234 break;
236 bg_color = theme.status_error;
237 break;
239 bg_color = theme.accent_color;
240 break;
242 default:
243 bg_color = theme.panel_bg_darker;
244 break;
245 }
246
247 ImGui::PushStyleColor(ImGuiCol_Button, bg_color);
248 ImGui::PushStyleColor(ImGuiCol_ButtonHovered, bg_color);
249 ImGui::PushStyleColor(ImGuiCol_ButtonActive, bg_color);
250 ImGui::SmallButton(text);
251 ImGui::PopStyleColor(3);
252}
253
254void VerticalSpacing(float amount) {
255 ImGui::Dummy(ImVec2(0.0f, amount));
256}
257
258void HorizontalSpacing(float amount) {
259 ImGui::SameLine();
260 ImGui::Dummy(ImVec2(amount, 0.0f));
261 ImGui::SameLine();
262}
263
264bool StyledButton(const char* label, const ImVec4& color, const ImVec2& size) {
265 ImGui::PushStyleColor(ImGuiCol_Button, color);
266 ImGui::PushStyleColor(
267 ImGuiCol_ButtonHovered,
268 ImVec4(color.x * 1.2f, color.y * 1.2f, color.z * 1.2f, color.w));
269 ImGui::PushStyleColor(
270 ImGuiCol_ButtonActive,
271 ImVec4(color.x * 0.8f, color.y * 0.8f, color.z * 0.8f, color.w));
272 bool clicked = ImGui::Button(label, size);
273 ImGui::PopStyleColor(3);
274 return clicked;
275}
276
277bool IconButton(const char* icon, const char* tooltip) {
278 ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0));
279 bool clicked = ImGui::Button(icon);
280 ImGui::PopStyleColor();
281
282 if (tooltip && ImGui::IsItemHovered()) {
283 ImGui::SetTooltip("%s", tooltip);
284 }
285 return clicked;
286}
287
288} // namespace AgentUI
289
290} // namespace editor
291} // 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:134
Centralized theme colors for Agent UI components.
Definition agent_theme.h:19
static AgentUITheme FromCurrentTheme()
Definition agent_theme.cc:8