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.
1
#include "
app/editor/agent/agent_ui_theme.h
"
2
3
#include "
app/gui/core/theme_manager.h
"
4
#include "
app/gui/core/color.h
"
5
#include "imgui/imgui.h"
6
7
namespace
yaze
{
8
namespace
editor {
9
10
// Global theme instance
11
static
AgentUITheme g_agent_theme;
12
static
bool
g_theme_initialized =
false
;
13
14
AgentUITheme
AgentUITheme::FromCurrentTheme
() {
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
84
namespace
AgentUI {
85
86
const
AgentUITheme
&
GetTheme
() {
87
if
(!g_theme_initialized) {
88
RefreshTheme
();
89
}
90
return
g_agent_theme;
91
}
92
93
void
RefreshTheme
() {
94
g_agent_theme =
AgentUITheme::FromCurrentTheme
();
95
g_theme_initialized =
true
;
96
}
97
98
void
PushPanelStyle
() {
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
105
void
PopPanelStyle
() {
106
ImGui::PopStyleVar(2);
107
ImGui::PopStyleColor();
108
}
109
110
void
RenderSectionHeader
(
const
char
* icon,
const
char
* label,
const
ImVec4& color) {
111
ImGui::TextColored(color,
"%s %s"
, icon, label);
112
ImGui::Separator();
113
}
114
115
void
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
132
void
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
152
void
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
172
void
VerticalSpacing
(
float
amount) {
173
ImGui::Dummy(ImVec2(0, amount));
174
}
175
176
void
HorizontalSpacing
(
float
amount) {
177
ImGui::Dummy(ImVec2(amount, 0));
178
ImGui::SameLine();
179
}
180
181
bool
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
197
bool
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
agent_ui_theme.h
yaze::gui::ThemeManager::Get
static ThemeManager & Get()
Definition
theme_manager.cc:117
yaze::gui::ThemeManager::GetCurrentTheme
const EnhancedTheme & GetCurrentTheme() const
Definition
theme_manager.h:201
color.h
yaze::editor::AgentUI::RefreshTheme
void RefreshTheme()
Definition
agent_ui_theme.cc:93
yaze::editor::AgentUI::ButtonColor
ButtonColor
Definition
agent_ui_theme.h:87
yaze::editor::AgentUI::ButtonColor::Warning
@ Warning
yaze::editor::AgentUI::ButtonColor::Info
@ Info
yaze::editor::AgentUI::ButtonColor::Success
@ Success
yaze::editor::AgentUI::ButtonColor::Error
@ Error
yaze::editor::AgentUI::PopPanelStyle
void PopPanelStyle()
Definition
agent_ui_theme.cc:105
yaze::editor::AgentUI::RenderStatusIndicator
void RenderStatusIndicator(const char *label, bool active)
Definition
agent_ui_theme.cc:115
yaze::editor::AgentUI::StyledButton
bool StyledButton(const char *label, const ImVec4 &color, const ImVec2 &size)
Definition
agent_ui_theme.cc:181
yaze::editor::AgentUI::HorizontalSpacing
void HorizontalSpacing(float amount)
Definition
agent_ui_theme.cc:176
yaze::editor::AgentUI::GetTheme
const AgentUITheme & GetTheme()
Definition
agent_ui_theme.cc:86
yaze::editor::AgentUI::RenderSectionHeader
void RenderSectionHeader(const char *icon, const char *label, const ImVec4 &color)
Definition
agent_ui_theme.cc:110
yaze::editor::AgentUI::PushPanelStyle
void PushPanelStyle()
Definition
agent_ui_theme.cc:98
yaze::editor::AgentUI::RenderProviderBadge
void RenderProviderBadge(const char *provider)
Definition
agent_ui_theme.cc:132
yaze::editor::AgentUI::VerticalSpacing
void VerticalSpacing(float amount)
Definition
agent_ui_theme.cc:172
yaze::editor::AgentUI::StatusBadge
void StatusBadge(const char *text, ButtonColor color)
Definition
agent_ui_theme.cc:152
yaze::editor::AgentUI::IconButton
bool IconButton(const char *icon, const char *tooltip)
Definition
agent_ui_theme.cc:197
yaze::gui::ConvertColorToImVec4
ImVec4 ConvertColorToImVec4(const Color &color)
Definition
color.h:21
yaze
Main namespace for the application.
Definition
controller.cc:20
yaze::editor::AgentUITheme
Centralized theme colors for Agent UI components.
Definition
agent_ui_theme.h:18
yaze::editor::AgentUITheme::gradient_top
ImVec4 gradient_top
Definition
agent_ui_theme.h:62
yaze::editor::AgentUITheme::button_copy
ImVec4 button_copy
Definition
agent_ui_theme.h:58
yaze::editor::AgentUITheme::collaboration_active
ImVec4 collaboration_active
Definition
agent_ui_theme.h:50
yaze::editor::AgentUITheme::proposal_panel_bg
ImVec4 proposal_panel_bg
Definition
agent_ui_theme.h:54
yaze::editor::AgentUITheme::provider_mock
ImVec4 provider_mock
Definition
agent_ui_theme.h:47
yaze::editor::AgentUITheme::status_warning
ImVec4 status_warning
Definition
agent_ui_theme.h:41
yaze::editor::AgentUITheme::panel_bg_color
ImVec4 panel_bg_color
Definition
agent_ui_theme.h:32
yaze::editor::AgentUITheme::panel_bg_darker
ImVec4 panel_bg_darker
Definition
agent_ui_theme.h:33
yaze::editor::AgentUITheme::json_text_color
ImVec4 json_text_color
Definition
agent_ui_theme.h:27
yaze::editor::AgentUITheme::status_error
ImVec4 status_error
Definition
agent_ui_theme.h:42
yaze::editor::AgentUITheme::accent_color
ImVec4 accent_color
Definition
agent_ui_theme.h:35
yaze::editor::AgentUITheme::system_message_color
ImVec4 system_message_color
Definition
agent_ui_theme.h:22
yaze::editor::AgentUITheme::FromCurrentTheme
static AgentUITheme FromCurrentTheme()
Definition
agent_ui_theme.cc:14
yaze::editor::AgentUITheme::text_secondary_color
ImVec4 text_secondary_color
Definition
agent_ui_theme.h:24
yaze::editor::AgentUITheme::agent_message_color
ImVec4 agent_message_color
Definition
agent_ui_theme.h:21
yaze::editor::AgentUITheme::panel_border_color
ImVec4 panel_border_color
Definition
agent_ui_theme.h:34
yaze::editor::AgentUITheme::user_message_color
ImVec4 user_message_color
Definition
agent_ui_theme.h:20
yaze::editor::AgentUITheme::status_inactive
ImVec4 status_inactive
Definition
agent_ui_theme.h:39
yaze::editor::AgentUITheme::provider_ollama
ImVec4 provider_ollama
Definition
agent_ui_theme.h:45
yaze::editor::AgentUITheme::status_active
ImVec4 status_active
Definition
agent_ui_theme.h:38
yaze::editor::AgentUITheme::collaboration_inactive
ImVec4 collaboration_inactive
Definition
agent_ui_theme.h:51
yaze::editor::AgentUITheme::gradient_bottom
ImVec4 gradient_bottom
Definition
agent_ui_theme.h:63
yaze::editor::AgentUITheme::command_text_color
ImVec4 command_text_color
Definition
agent_ui_theme.h:28
yaze::editor::AgentUITheme::provider_gemini
ImVec4 provider_gemini
Definition
agent_ui_theme.h:46
yaze::editor::AgentUITheme::status_success
ImVec4 status_success
Definition
agent_ui_theme.h:40
yaze::editor::AgentUITheme::proposal_accent
ImVec4 proposal_accent
Definition
agent_ui_theme.h:55
yaze::editor::AgentUITheme::button_copy_hover
ImVec4 button_copy_hover
Definition
agent_ui_theme.h:59
yaze::editor::AgentUITheme::code_bg_color
ImVec4 code_bg_color
Definition
agent_ui_theme.h:29
theme_manager.h
src
app
editor
agent
agent_ui_theme.cc
Generated by
1.9.8