5#include "absl/strings/str_format.h"
9#include "imgui/imgui.h"
10#include "imgui/imgui_internal.h"
45 return ImGui::GetStyle().Colors[idx];
80 return ImVec4(1.0f, 0.9f, 0.0f, 0.85f);
85 return ImVec4(0.9f, 1.0f, 1.0f, 0.85f);
90 return ImVec4(1.0f, 0.2f, 0.2f, 0.85f);
95 return ImVec4(1.0f, 0.3f, 1.0f, 0.85f);
104 return ImVec4(1.0f, 0.5f, 0.0f, 1.0f);
126 ImGui::PushStyleColor(ImGuiCol_Text, color);
127 ImGui::TextUnformatted(text);
128 ImGui::PopStyleColor();
132 ImGui::PushStyleColor(ImGuiCol_Text, color);
135 ImGui::TextV(fmt, args);
137 ImGui::PopStyleColor();
148 ImGui::TextV(fmt, args);
150 ImGui::PopStyleColor();
162 ImVec4(base.x * 1.2f, base.y * 1.2f, base.z * 1.2f, base.w),
163 ImVec4(base.x * 0.8f, base.y * 0.8f, base.z * 0.8f, base.w),
172 ImVec4(base.x * 1.2f, base.y * 1.2f, base.z * 1.2f, base.w),
173 ImVec4(base.x * 0.8f, base.y * 0.8f, base.z * 0.8f, base.w),
182 ImVec4(base.x * 1.2f, base.y * 1.2f, base.z * 1.2f, base.w),
183 ImVec4(base.x * 0.8f, base.y * 0.8f, base.z * 0.8f, base.w),
192 ImVec4(base.x * 1.2f, base.y * 1.2f, base.z * 1.2f, base.w),
193 ImVec4(base.x * 0.8f, base.y * 0.8f, base.z * 0.8f, base.w),
205 ImGui::PopStyleColor();
214 if (label_width > 0.0f) {
215 ImGui::Text(
"%s:", label);
216 ImGui::SameLine(label_width);
218 ImGui::TextUnformatted(label);
221 ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x * 0.6f);
225 ImGui::PopItemWidth();
230 ImGuiTableFlags extra_flags) {
231 ImGuiTableFlags flags =
232 ImGuiTableFlags_Borders | ImGuiTableFlags_SizingFixedFit | extra_flags;
233 if (ImGui::BeginTable(
id, columns, flags)) {
234 ImGui::TableSetupColumn(
"Property", ImGuiTableColumnFlags_WidthFixed, 150);
235 ImGui::TableSetupColumn(
"Value", ImGuiTableColumnFlags_WidthStretch);
246 ImGui::TableNextColumn();
247 ImGui::Text(
"%s", label);
248 ImGui::TableNextColumn();
249 ImGui::TextWrapped(
"%s", value);
253 ImGui::TableNextColumn();
254 ImGui::Text(
"%s", label);
255 ImGui::TableNextColumn();
256 ImGui::Text(
"%d", value);
260 ImGui::TableNextColumn();
261 ImGui::Text(
"%s", label);
262 ImGui::TableNextColumn();
263 ImGui::Text(
"0x%02X", value);
267 ImGui::TableNextColumn();
268 ImGui::Text(
"%s", label);
269 ImGui::TableNextColumn();
270 ImGui::Text(
"0x%04X", value);
273void SectionHeader(
const char* icon,
const char* label,
const ImVec4& color) {
274 ImGui::TextColored(color,
"%s %s", icon, label);
282bool IconButton(
const char* icon,
const char* label,
const ImVec2& size) {
283 std::string button_text = std::string(icon) +
" " + std::string(label);
284 return ImGui::Button(button_text.c_str(), size);
288 ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0));
289 bool clicked = ImGui::Button(icon);
290 ImGui::PopStyleColor();
292 if (tooltip && ImGui::IsItemHovered()) {
293 ImGui::SetTooltip(
"%s", tooltip);
318 ImGui::PushStyleColor(ImGuiCol_Button, color);
319 ImGui::PushStyleColor(
320 ImGuiCol_ButtonHovered,
321 ImVec4(color.x * 1.2f, color.y * 1.2f, color.z * 1.2f, color.w));
322 ImGui::PushStyleColor(
323 ImGuiCol_ButtonActive,
324 ImVec4(color.x * 0.8f, color.y * 0.8f, color.z * 0.8f, color.w));
326 bool result = ImGui::Button(label, size);
328 ImGui::PopStyleColor(3);
332bool StyledButton(
const char* label,
const ImVec4& color,
const ImVec2& size) {
333 ImGui::PushStyleColor(ImGuiCol_Button, color);
334 ImGui::PushStyleColor(
335 ImGuiCol_ButtonHovered,
336 ImVec4(color.x * 1.2f, color.y * 1.2f, color.z * 1.2f, color.w));
337 ImGui::PushStyleColor(
338 ImGuiCol_ButtonActive,
339 ImVec4(color.x * 0.8f, color.y * 0.8f, color.z * 0.8f, color.w));
341 bool result = ImGui::Button(label, size);
343 ImGui::PopStyleColor(3);
348 const char* tooltip) {
349 const char* icon = *state ? icon_on : icon_off;
352 ImGui::PushStyleColor(ImGuiCol_Button, color);
353 bool result = ImGui::SmallButton(icon);
354 ImGui::PopStyleColor();
359 if (tooltip && ImGui::IsItemHovered()) {
360 ImGui::SetTooltip(
"%s", tooltip);
373 bool result = ImGui::Button(label, size);
376 ImGui::PopStyleColor(3);
384 if (ImGui::IsItemHovered()) {
385 ImGui::BeginTooltip();
386 ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
387 ImGui::TextUnformatted(desc);
388 ImGui::PopTextWrapPos();
394 ImGui::SeparatorText(label);
417 ImGui::PushStyleColor(ImGuiCol_Button, color);
418 ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 10.0f);
419 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(8, 3));
420 ImGui::SmallButton(text);
421 ImGui::PopStyleVar(2);
422 ImGui::PopStyleColor();
430 ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(2, 2));
431 ImGui::BeginTable(
id, 32, ImGuiTableFlags_SizingFixedFit);
436 ImGui::PopStyleVar();
440 std::function<
void()> on_click) {
441 ImGui::TableNextColumn();
447 if (ImGui::Button(icon)) {
453 ImGui::PopStyleColor();
456 if (tooltip && ImGui::IsItemHovered()) {
457 ImGui::SetTooltip(
"%s", tooltip);
462 ImGuiWindowFlags flags = scrollable ? ImGuiWindowFlags_AlwaysVerticalScrollbar
463 : ImGuiWindowFlags_None;
464 ImGui::BeginChild(
id, ImVec2(0, 0),
true, flags);
473 snprintf(tab_label,
sizeof(tab_label),
"%s %s", icon, label);
474 return ImGui::BeginTabItem(tab_label, p_open);
478 const char* confirm_text,
const char* cancel_text) {
479 bool confirmed =
false;
481 if (ImGui::BeginPopupModal(
id,
nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
482 ImGui::Text(
"%s", title);
484 ImGui::TextWrapped(
"%s", message);
489 ImGui::CloseCurrentPopup();
493 if (ImGui::Button(cancel_text, ImVec2(120, 0))) {
494 ImGui::CloseCurrentPopup();
511 ImDrawList* draw_list = ImGui::GetWindowDrawList();
512 ImVec2 pos = ImGui::GetCursorScreenPos();
516 pos.y += ImGui::GetTextLineHeight() * 0.5f;
518 draw_list->AddCircleFilled(pos, radius, ImGui::GetColorU32(color));
520 ImGui::SetCursorPosX(ImGui::GetCursorPosX() + radius * 2 + 8);
521 ImGui::Text(
"%s", label);
523 if (tooltip && ImGui::IsItemHovered()) {
524 ImGui::SetTooltip(
"%s", tooltip);
532 if (strcmp(provider,
"ollama") == 0) {
534 }
else if (strcmp(provider,
"gemini") == 0) {
536 }
else if (strcmp(provider,
"anthropic") == 0) {
538 }
else if (strcmp(provider,
"openai") == 0) {
542 ImGui::PushStyleColor(ImGuiCol_Text, color);
543 ImGui::Text(
"[%s]", provider);
544 ImGui::PopStyleColor();
551 ImGui::PushStyleColor(ImGuiCol_Text, color);
552 ImGui::Text(
"%s %s", icon, version);
553 ImGui::PopStyleColor();
569 ImGui::Dummy(ImVec2(0, pixels));
573 ImGui::Dummy(ImVec2(pixels, 0));
578 float text_width = ImGui::CalcTextSize(text).x;
579 ImGui::SetCursorPosX((ImGui::GetContentRegionAvail().x - text_width) * 0.5f);
580 ImGui::Text(
"%s", text);
584 ImGui::SetCursorPosX(ImGui::GetCursorPosX() +
585 ImGui::GetContentRegionAvail().x - width);
594 0.5f * sinf(
static_cast<float>(ImGui::GetTime()) * speed * 2.0f);
598 static double start_time = 0.0;
599 double current_time = ImGui::GetTime();
601 if (start_time == 0.0) {
602 start_time = current_time;
605 float elapsed =
static_cast<float>(current_time - start_time);
606 float alpha = ImClamp(elapsed / duration, 0.0f, 1.0f);
617 ImGui::PushStyleVar(ImGuiStyleVar_Alpha,
622 ImGui::PopStyleVar();
626 ImDrawList* draw_list = ImGui::GetWindowDrawList();
627 ImVec2 pos = ImGui::GetCursorScreenPos();
631 const float rotation =
static_cast<float>(ImGui::GetTime()) * 3.0f;
632 const int segments = 16;
633 const float thickness = 3.0f;
635 const float start_angle = rotation;
636 const float end_angle = rotation +
IM_PI * 1.5f;
638 draw_list->PathArcTo(pos, radius, start_angle, end_angle, segments);
639 draw_list->PathStroke(ImGui::GetColorU32(
GetAccentColor()), 0, thickness);
642 ImGui::SetCursorPosX(ImGui::GetCursorPosX() + radius * 2 + 8);
643 ImGui::Text(
"%s", label);
645 ImGui::Dummy(ImVec2(radius * 2 + 8, radius * 2 + 8));
654 float available = ImGui::GetContentRegionAvail().x;
655 float target = available * ratio;
657 if (target < min_width)
659 if (target > max_width)
665 float available = ImGui::GetContentRegionAvail().x;
666 float col_width = available / count;
668 if (col_width < min_col_width) {
669 col_width = min_col_width;
672 for (
int i = 0; i < count; ++i) {
673 ImGui::TableSetupColumn(
"##col", ImGuiTableColumnFlags_WidthFixed,
678static int g_two_col_table_active = 0;
681 ImGuiTableFlags flags = ImGuiTableFlags_Resizable |
682 ImGuiTableFlags_BordersInnerV |
683 ImGuiTableFlags_SizingStretchProp;
685 if (ImGui::BeginTable(
id, 2, flags)) {
686 float available = ImGui::GetContentRegionAvail().x;
687 ImGui::TableSetupColumn(
"##left", ImGuiTableColumnFlags_None,
688 available * split_ratio);
689 ImGui::TableSetupColumn(
"##right", ImGuiTableColumnFlags_None,
690 available * (1.0f - split_ratio));
691 ImGui::TableNextRow();
692 ImGui::TableNextColumn();
693 g_two_col_table_active++;
698 ImGui::TableNextColumn();
703 g_two_col_table_active--;
712 ImGui::PushItemWidth(60);
714 ImGui::InputScalar(
"##hex", ImGuiDataType_U8, value,
nullptr,
nullptr,
715 "%02X", ImGuiInputTextFlags_CharsHexadecimal);
716 ImGui::PopItemWidth();
723 ImGui::PushItemWidth(80);
725 ImGui::InputScalar(
"##hex", ImGuiDataType_U16, value,
nullptr,
nullptr,
726 "%04X", ImGuiInputTextFlags_CharsHexadecimal);
727 ImGui::PopItemWidth();
732bool IconCombo(
const char* icon,
const char* label,
int* current,
733 const char*
const items[],
int count) {
734 ImGui::Text(
"%s", icon);
736 return ImGui::Combo(label, current, items, count);
const Theme & GetCurrentTheme() const
static ThemeManager & Get()
#define ICON_MD_LOCK_OPEN
#define ICON_MD_CHECK_CIRCLE
#define ICON_MD_HELP_OUTLINE
void RightAlign(float width)
void VerticalSpacing(float pixels)
void EndCanvasContainer()
void BeginToolset(const char *id)
ImVec4 ConvertColorToImVec4(const Color &color)
std::string MakePanelTitle(const std::string &title)
ImVec4 GetVanillaRomColor()
void PropertyRow(const char *label, const char *value)
void ColoredText(const char *text, const ImVec4 &color)
ButtonColorSet GetWarningButtonColors()
ButtonColorSet GetDangerButtonColors()
bool ToggleIconButton(const char *icon_on, const char *icon_off, bool *state, const char *tooltip)
void BeginField(const char *label, float label_width)
void SeparatorText(const char *label)
void StatusIndicator(const char *label, bool active, const char *tooltip)
ImVec4 GetSelectedColor()
void BeginTwoColumns(const char *id, float split_ratio)
void RomVersionBadge(const char *version, bool is_vanilla)
bool EditorTabItem(const char *icon, const char *label, bool *p_open)
ImVec4 GetEntranceColor()
void CenterText(const char *text)
bool LabeledInputHex(const char *label, uint8_t *value)
void SectionHeader(const char *icon, const char *label, const ImVec4 &color)
void LockIndicator(bool locked, const char *label)
bool IconButton(const char *icon, const char *label, const ImVec2 &size)
void PropertyRowHex(const char *label, uint8_t value)
bool ToggleButton(const char *label, bool active, const ImVec2 &size)
float GetResponsiveWidth(float min_width, float max_width, float ratio)
void SetupResponsiveColumns(int count, float min_col_width)
ButtonColorSet GetSuccessButtonColors()
bool ColoredButton(const char *label, ButtonType type, const ImVec2 &size)
bool BeginPropertyTable(const char *id, int columns, ImGuiTableFlags extra_flags)
void BeginCanvasContainer(const char *id, bool scrollable)
bool IconCombo(const char *icon, const char *label, int *current, const char *const items[], int count)
void LoadingSpinner(const char *label, float radius)
ImVec4 GetDisabledColor()
void ColoredTextF(const ImVec4 &color, const char *fmt,...)
void ToolsetButton(const char *icon, bool selected, const char *tooltip, std::function< void()> on_click)
bool ConfirmationDialog(const char *id, const char *title, const char *message, const char *confirm_text, const char *cancel_text)
ImVec4 GetModifiedColor()
bool StyledButton(const char *label, const ImVec4 &color, const ImVec2 &size)
float GetFadeIn(float duration)
float GetPulseAlpha(float speed)
void PushPulseEffect(float speed)
void HelpMarker(const char *desc)
Color GetThemeColor(const std::string &color_name)
void RenderProviderBadge(const char *provider)
void StatusBadge(const char *text, ButtonType type)
void ThemedText(const char *text, SemanticColor color)
void HorizontalSpacing(float pixels)
void ThemedTextF(SemanticColor color, const char *fmt,...)
ImVec4 GetCustomRomColor()
ButtonColorSet GetPrimaryButtonColors()
ImVec4 ResolveSemanticColor(SemanticColor color)