3#include "absl/strings/str_format.h"
7#include "imgui/imgui.h"
8#include "imgui/imgui_internal.h"
18 return ImGui::GetStyle().Colors[idx];
49 return ImVec4(1.0f, 0.9f, 0.0f, 0.85f);
54 return ImVec4(0.9f, 1.0f, 1.0f, 0.85f);
59 return ImVec4(1.0f, 0.2f, 0.2f, 0.85f);
64 return ImVec4(1.0f, 0.3f, 1.0f, 0.85f);
73 return ImVec4(1.0f, 0.5f, 0.0f, 1.0f);
96 if (label_width > 0.0f) {
97 ImGui::Text(
"%s:", label);
98 ImGui::SameLine(label_width);
100 ImGui::TextUnformatted(label);
103 ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x * 0.6f);
107 ImGui::PopItemWidth();
112 ImGuiTableFlags flags = ImGuiTableFlags_Borders |
113 ImGuiTableFlags_SizingFixedFit |
115 if (ImGui::BeginTable(
id, columns, flags)) {
116 ImGui::TableSetupColumn(
"Property", ImGuiTableColumnFlags_WidthFixed, 150);
117 ImGui::TableSetupColumn(
"Value", ImGuiTableColumnFlags_WidthStretch);
128 ImGui::TableNextColumn();
129 ImGui::Text(
"%s", label);
130 ImGui::TableNextColumn();
131 ImGui::TextWrapped(
"%s", value);
135 ImGui::TableNextColumn();
136 ImGui::Text(
"%s", label);
137 ImGui::TableNextColumn();
138 ImGui::Text(
"%d", value);
142 ImGui::TableNextColumn();
143 ImGui::Text(
"%s", label);
144 ImGui::TableNextColumn();
145 ImGui::Text(
"0x%02X", value);
149 ImGui::TableNextColumn();
150 ImGui::Text(
"%s", label);
151 ImGui::TableNextColumn();
152 ImGui::Text(
"0x%04X", value);
155void SectionHeader(
const char* icon,
const char* label,
const ImVec4& color) {
156 ImGui::TextColored(color,
"%s %s", icon, label);
164bool IconButton(
const char* icon,
const char* label,
const ImVec2& size) {
165 std::string button_text = std::string(icon) +
" " + std::string(label);
166 return ImGui::Button(button_text.c_str(), size);
179 ImGui::PushStyleColor(ImGuiCol_Button, color);
180 ImGui::PushStyleColor(ImGuiCol_ButtonHovered,
181 ImVec4(color.x * 1.2f, color.y * 1.2f, color.z * 1.2f, color.w));
182 ImGui::PushStyleColor(ImGuiCol_ButtonActive,
183 ImVec4(color.x * 0.8f, color.y * 0.8f, color.z * 0.8f, color.w));
185 bool result = ImGui::Button(label, size);
187 ImGui::PopStyleColor(3);
192 bool* state,
const char* tooltip) {
193 const char* icon = *state ? icon_on : icon_off;
196 ImGui::PushStyleColor(ImGuiCol_Button, color);
197 bool result = ImGui::SmallButton(icon);
198 ImGui::PopStyleColor();
200 if (result) *state = !*state;
202 if (tooltip && ImGui::IsItemHovered()) {
203 ImGui::SetTooltip(
"%s", tooltip);
211 if (ImGui::IsItemHovered()) {
212 ImGui::BeginTooltip();
213 ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
214 ImGui::TextUnformatted(desc);
215 ImGui::PopTextWrapPos();
221 ImGui::SeparatorText(label);
234 ImGui::PushStyleColor(ImGuiCol_Button, color);
235 ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 10.0f);
236 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(8, 3));
237 ImGui::SmallButton(text);
238 ImGui::PopStyleVar(2);
239 ImGui::PopStyleColor();
247 ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(2, 2));
248 ImGui::BeginTable(
id, 32, ImGuiTableFlags_SizingFixedFit);
253 ImGui::PopStyleVar();
257 std::function<
void()> on_click) {
258 ImGui::TableNextColumn();
264 if (ImGui::Button(icon)) {
265 if (on_click) on_click();
269 ImGui::PopStyleColor();
272 if (tooltip && ImGui::IsItemHovered()) {
273 ImGui::SetTooltip(
"%s", tooltip);
278 ImGuiWindowFlags flags = scrollable ?
279 ImGuiWindowFlags_AlwaysVerticalScrollbar :
280 ImGuiWindowFlags_None;
281 ImGui::BeginChild(
id, ImVec2(0, 0),
true, flags);
290 snprintf(tab_label,
sizeof(tab_label),
"%s %s", icon, label);
291 return ImGui::BeginTabItem(tab_label, p_open);
295 const char* confirm_text,
const char* cancel_text) {
296 bool confirmed =
false;
298 if (ImGui::BeginPopupModal(
id,
nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
299 ImGui::Text(
"%s", title);
301 ImGui::TextWrapped(
"%s", message);
306 ImGui::CloseCurrentPopup();
310 if (ImGui::Button(cancel_text, ImVec2(120, 0))) {
311 ImGui::CloseCurrentPopup();
327 ImDrawList* draw_list = ImGui::GetWindowDrawList();
328 ImVec2 pos = ImGui::GetCursorScreenPos();
332 pos.y += ImGui::GetTextLineHeight() * 0.5f;
334 draw_list->AddCircleFilled(pos, radius, ImGui::GetColorU32(color));
336 ImGui::SetCursorPosX(ImGui::GetCursorPosX() + radius * 2 + 8);
337 ImGui::Text(
"%s", label);
339 if (tooltip && ImGui::IsItemHovered()) {
340 ImGui::SetTooltip(
"%s", tooltip);
348 ImGui::PushStyleColor(ImGuiCol_Text, color);
349 ImGui::Text(
"%s %s", icon, version);
350 ImGui::PopStyleColor();
366 ImGui::Dummy(ImVec2(0, pixels));
370 ImGui::Dummy(ImVec2(pixels, 0));
375 float text_width = ImGui::CalcTextSize(text).x;
376 ImGui::SetCursorPosX((ImGui::GetContentRegionAvail().x - text_width) * 0.5f);
377 ImGui::Text(
"%s", text);
381 ImGui::SetCursorPosX(ImGui::GetCursorPosX() +
382 ImGui::GetContentRegionAvail().x - width);
390 return 0.5f + 0.5f * sinf(
static_cast<float>(ImGui::GetTime()) * speed * 2.0f);
394 static double start_time = 0.0;
395 double current_time = ImGui::GetTime();
397 if (start_time == 0.0) {
398 start_time = current_time;
401 float elapsed =
static_cast<float>(current_time - start_time);
402 float alpha = ImClamp(elapsed / duration, 0.0f, 1.0f);
413 ImGui::PushStyleVar(ImGuiStyleVar_Alpha,
418 ImGui::PopStyleVar();
422 ImDrawList* draw_list = ImGui::GetWindowDrawList();
423 ImVec2 pos = ImGui::GetCursorScreenPos();
427 const float rotation =
static_cast<float>(ImGui::GetTime()) * 3.0f;
428 const int segments = 16;
429 const float thickness = 3.0f;
431 const float start_angle = rotation;
432 const float end_angle = rotation +
IM_PI * 1.5f;
434 draw_list->PathArcTo(pos, radius, start_angle, end_angle, segments);
435 draw_list->PathStroke(ImGui::GetColorU32(
GetAccentColor()), 0, thickness);
438 ImGui::SetCursorPosX(ImGui::GetCursorPosX() + radius * 2 + 8);
439 ImGui::Text(
"%s", label);
441 ImGui::Dummy(ImVec2(radius * 2 + 8, radius * 2 + 8));
450 float available = ImGui::GetContentRegionAvail().x;
451 float target = available * ratio;
453 if (target < min_width)
return min_width;
454 if (target > max_width)
return max_width;
459 float available = ImGui::GetContentRegionAvail().x;
460 float col_width = available / count;
462 if (col_width < min_col_width) {
463 col_width = min_col_width;
466 for (
int i = 0; i < count; ++i) {
467 ImGui::TableSetupColumn(
"##col", ImGuiTableColumnFlags_WidthFixed, col_width);
471static int g_two_col_table_active = 0;
474 ImGuiTableFlags flags = ImGuiTableFlags_Resizable |
475 ImGuiTableFlags_BordersInnerV |
476 ImGuiTableFlags_SizingStretchProp;
478 if (ImGui::BeginTable(
id, 2, flags)) {
479 float available = ImGui::GetContentRegionAvail().x;
480 ImGui::TableSetupColumn(
"##left", ImGuiTableColumnFlags_None,
481 available * split_ratio);
482 ImGui::TableSetupColumn(
"##right", ImGuiTableColumnFlags_None,
483 available * (1.0f - split_ratio));
484 ImGui::TableNextRow();
485 ImGui::TableNextColumn();
486 g_two_col_table_active++;
491 ImGui::TableNextColumn();
496 g_two_col_table_active--;
505 ImGui::PushItemWidth(60);
506 bool changed = ImGui::InputScalar(
"##hex", ImGuiDataType_U8, value,
nullptr,
508 ImGuiInputTextFlags_CharsHexadecimal);
509 ImGui::PopItemWidth();
516 ImGui::PushItemWidth(80);
517 bool changed = ImGui::InputScalar(
"##hex", ImGuiDataType_U16, value,
nullptr,
519 ImGuiInputTextFlags_CharsHexadecimal);
520 ImGui::PopItemWidth();
525bool IconCombo(
const char* icon,
const char* label,
int* current,
526 const char*
const items[],
int count) {
527 ImGui::Text(
"%s", icon);
529 return ImGui::Combo(label, current, items, count);
static ThemeManager & Get()
const EnhancedTheme & GetCurrentTheme() const
#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)
ImVec4 GetVanillaRomColor()
void PropertyRow(const char *label, const char *value)
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)
float GetResponsiveWidth(float min_width, float max_width, float ratio)
void SetupResponsiveColumns(int count, float min_col_width)
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)
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()
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 StatusBadge(const char *text, ButtonType type)
void HorizontalSpacing(float pixels)
ImVec4 GetCustomRomColor()
Main namespace for the application.