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
4#include "app/gui/color.h"
5#include "imgui/imgui.h"
6
7namespace yaze {
8namespace editor {
9
10// Global theme instance
11static AgentUITheme g_agent_theme;
12static bool g_theme_initialized = false;
13
15 AgentUITheme theme;
16 const auto& current = gui::ThemeManager::Get().GetCurrentTheme();
17
18 // Message colors - derived from theme primary/secondary
19 theme.user_message_color = ImVec4(
20 current.primary.red * 1.1f,
21 current.primary.green * 0.95f,
22 current.primary.blue * 0.6f,
23 1.0f
24 );
25
26 theme.agent_message_color = ImVec4(
27 current.secondary.red * 0.9f,
28 current.secondary.green * 1.3f,
29 current.secondary.blue * 1.0f,
30 1.0f
31 );
32
33 theme.system_message_color = ImVec4(
34 current.info.red,
35 current.info.green,
36 current.info.blue,
37 1.0f
38 );
39
40 // Content colors
41 theme.json_text_color = ConvertColorToImVec4(current.text_secondary);
42 theme.command_text_color = ConvertColorToImVec4(current.accent);
43 theme.code_bg_color = ConvertColorToImVec4(current.code_background);
44
45 theme.text_secondary_color = ConvertColorToImVec4(current.text_secondary);
46
47 // UI element colors
48 theme.panel_bg_color = ImVec4(0.12f, 0.14f, 0.18f, 0.95f);
49 theme.panel_bg_darker = ImVec4(0.08f, 0.10f, 0.14f, 0.95f);
50 theme.panel_border_color = ConvertColorToImVec4(current.border);
51 theme.accent_color = ConvertColorToImVec4(current.accent);
52
53 // Status colors
54 theme.status_active = ConvertColorToImVec4(current.success);
55 theme.status_inactive = ImVec4(0.6f, 0.6f, 0.6f, 1.0f);
56 theme.status_success = ConvertColorToImVec4(current.success);
57 theme.status_warning = ConvertColorToImVec4(current.warning);
58 theme.status_error = ConvertColorToImVec4(current.error);
59
60 // Provider-specific colors
61 theme.provider_ollama = ImVec4(0.2f, 0.8f, 0.4f, 1.0f); // Green
62 theme.provider_gemini = ImVec4(0.196f, 0.6f, 0.8f, 1.0f); // Blue
63 theme.provider_mock = ImVec4(0.6f, 0.6f, 0.6f, 1.0f); // Gray
64
65 // Collaboration colors
66 theme.collaboration_active = ImVec4(0.133f, 0.545f, 0.133f, 1.0f); // Forest green
67 theme.collaboration_inactive = ImVec4(0.6f, 0.6f, 0.6f, 1.0f);
68
69 // Proposal colors
70 theme.proposal_panel_bg = ImVec4(0.20f, 0.35f, 0.20f, 0.35f);
71 theme.proposal_accent = ImVec4(0.8f, 1.0f, 0.8f, 1.0f);
72
73 // Button colors
74 theme.button_copy = ImVec4(0.3f, 0.3f, 0.4f, 0.6f);
75 theme.button_copy_hover = ImVec4(0.4f, 0.4f, 0.5f, 0.8f);
76
77 // Gradient colors
78 theme.gradient_top = ImVec4(0.18f, 0.22f, 0.28f, 1.0f);
79 theme.gradient_bottom = ImVec4(0.12f, 0.16f, 0.22f, 1.0f);
80
81 return theme;
82}
83
84namespace AgentUI {
85
87 if (!g_theme_initialized) {
89 }
90 return g_agent_theme;
91}
92
94 g_agent_theme = AgentUITheme::FromCurrentTheme();
95 g_theme_initialized = true;
96}
97
99 const auto& theme = GetTheme();
100 ImGui::PushStyleColor(ImGuiCol_ChildBg, theme.panel_bg_color);
101 ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 6.0f);
102 ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(12, 12));
103}
104
106 ImGui::PopStyleVar(2);
107 ImGui::PopStyleColor();
108}
109
110void RenderSectionHeader(const char* icon, const char* label, const ImVec4& color) {
111 ImGui::TextColored(color, "%s %s", icon, label);
112 ImGui::Separator();
113}
114
115void RenderStatusIndicator(const char* label, bool active) {
116 const auto& theme = GetTheme();
117 ImVec4 color = active ? theme.status_active : theme.status_inactive;
118
119 ImDrawList* draw_list = ImGui::GetWindowDrawList();
120 ImVec2 pos = ImGui::GetCursorScreenPos();
121 float radius = 4.0f;
122
123 pos.x += radius + 2;
124 pos.y += ImGui::GetTextLineHeight() * 0.5f;
125
126 draw_list->AddCircleFilled(pos, radius, ImGui::GetColorU32(color));
127
128 ImGui::SetCursorPosX(ImGui::GetCursorPosX() + radius * 2 + 8);
129 ImGui::Text("%s", label);
130}
131
132void RenderProviderBadge(const char* provider) {
133 const auto& theme = GetTheme();
134
135 ImVec4 badge_color;
136 if (strcmp(provider, "ollama") == 0) {
137 badge_color = theme.provider_ollama;
138 } else if (strcmp(provider, "gemini") == 0) {
139 badge_color = theme.provider_gemini;
140 } else {
141 badge_color = theme.provider_mock;
142 }
143
144 ImGui::PushStyleColor(ImGuiCol_Button, badge_color);
145 ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 12.0f);
146 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(8, 4));
147 ImGui::SmallButton(provider);
148 ImGui::PopStyleVar(2);
149 ImGui::PopStyleColor();
150}
151
152void StatusBadge(const char* text, ButtonColor color) {
153 const auto& theme = GetTheme();
154
155 ImVec4 badge_color;
156 switch (color) {
157 case ButtonColor::Success: badge_color = theme.status_success; break;
158 case ButtonColor::Warning: badge_color = theme.status_warning; break;
159 case ButtonColor::Error: badge_color = theme.status_error; break;
160 case ButtonColor::Info: badge_color = theme.accent_color; break;
161 default: badge_color = theme.status_inactive; break;
162 }
163
164 ImGui::PushStyleColor(ImGuiCol_Button, badge_color);
165 ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 10.0f);
166 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(6, 2));
167 ImGui::SmallButton(text);
168 ImGui::PopStyleVar(2);
169 ImGui::PopStyleColor();
170}
171
172void VerticalSpacing(float amount) {
173 ImGui::Dummy(ImVec2(0, amount));
174}
175
176void HorizontalSpacing(float amount) {
177 ImGui::Dummy(ImVec2(amount, 0));
178 ImGui::SameLine();
179}
180
181bool StyledButton(const char* label, const ImVec4& color, const ImVec2& size) {
182 ImGui::PushStyleColor(ImGuiCol_Button, color);
183 ImGui::PushStyleColor(ImGuiCol_ButtonHovered,
184 ImVec4(color.x * 1.2f, color.y * 1.2f, color.z * 1.2f, color.w));
185 ImGui::PushStyleColor(ImGuiCol_ButtonActive,
186 ImVec4(color.x * 0.8f, color.y * 0.8f, color.z * 0.8f, color.w));
187 ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
188
189 bool result = ImGui::Button(label, size);
190
191 ImGui::PopStyleVar();
192 ImGui::PopStyleColor(3);
193
194 return result;
195}
196
197bool IconButton(const char* icon, const char* tooltip) {
198 bool result = ImGui::SmallButton(icon);
199
200 if (tooltip && ImGui::IsItemHovered()) {
201 ImGui::SetTooltip("%s", tooltip);
202 }
203
204 return result;
205}
206
207} // namespace AgentUI
208
209} // namespace editor
210} // namespace yaze
static ThemeManager & Get()
const EnhancedTheme & GetCurrentTheme() const
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)
Main namespace for the application.
Centralized theme colors for Agent UI components.
static AgentUITheme FromCurrentTheme()