6#include "imgui/imgui.h"
7#include "imgui/imgui_internal.h"
17 return ImGui::GetStyle().Colors[idx];
48 return ImVec4(1.0f, 0.9f, 0.0f, 0.85f);
53 return ImVec4(0.9f, 1.0f, 1.0f, 0.85f);
58 return ImVec4(1.0f, 0.2f, 0.2f, 0.85f);
63 return ImVec4(1.0f, 0.3f, 1.0f, 0.85f);
72 return ImVec4(1.0f, 0.5f, 0.0f, 1.0f);
95 if (label_width > 0.0f) {
96 ImGui::Text(
"%s:", label);
97 ImGui::SameLine(label_width);
99 ImGui::TextUnformatted(label);
102 ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x * 0.6f);
106 ImGui::PopItemWidth();
111 ImGuiTableFlags flags = ImGuiTableFlags_Borders |
112 ImGuiTableFlags_SizingFixedFit |
114 if (ImGui::BeginTable(
id, columns, flags)) {
115 ImGui::TableSetupColumn(
"Property", ImGuiTableColumnFlags_WidthFixed, 150);
116 ImGui::TableSetupColumn(
"Value", ImGuiTableColumnFlags_WidthStretch);
127 ImGui::TableNextColumn();
128 ImGui::Text(
"%s", label);
129 ImGui::TableNextColumn();
130 ImGui::TextWrapped(
"%s", value);
134 ImGui::TableNextColumn();
135 ImGui::Text(
"%s", label);
136 ImGui::TableNextColumn();
137 ImGui::Text(
"%d", value);
141 ImGui::TableNextColumn();
142 ImGui::Text(
"%s", label);
143 ImGui::TableNextColumn();
144 ImGui::Text(
"0x%02X", value);
148 ImGui::TableNextColumn();
149 ImGui::Text(
"%s", label);
150 ImGui::TableNextColumn();
151 ImGui::Text(
"0x%04X", value);
154void SectionHeader(
const char* icon,
const char* label,
const ImVec4& color) {
155 ImGui::TextColored(color,
"%s %s", icon, label);
163bool IconButton(
const char* icon,
const char* label,
const ImVec2& size) {
164 std::string button_text = std::string(icon) +
" " + std::string(label);
165 return ImGui::Button(button_text.c_str(), size);
178 ImGui::PushStyleColor(ImGuiCol_Button, color);
179 ImGui::PushStyleColor(ImGuiCol_ButtonHovered,
180 ImVec4(color.x * 1.2f, color.y * 1.2f, color.z * 1.2f, color.w));
181 ImGui::PushStyleColor(ImGuiCol_ButtonActive,
182 ImVec4(color.x * 0.8f, color.y * 0.8f, color.z * 0.8f, color.w));
184 bool result = ImGui::Button(label, size);
186 ImGui::PopStyleColor(3);
191 bool* state,
const char* tooltip) {
192 const char* icon = *state ? icon_on : icon_off;
195 ImGui::PushStyleColor(ImGuiCol_Button, color);
196 bool result = ImGui::SmallButton(icon);
197 ImGui::PopStyleColor();
199 if (result) *state = !*state;
201 if (tooltip && ImGui::IsItemHovered()) {
202 ImGui::SetTooltip(
"%s", tooltip);
210 if (ImGui::IsItemHovered()) {
211 ImGui::BeginTooltip();
212 ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
213 ImGui::TextUnformatted(desc);
214 ImGui::PopTextWrapPos();
220 ImGui::SeparatorText(label);
233 ImGui::PushStyleColor(ImGuiCol_Button, color);
234 ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 10.0f);
235 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(8, 3));
236 ImGui::SmallButton(text);
237 ImGui::PopStyleVar(2);
238 ImGui::PopStyleColor();
246 ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(2, 2));
247 ImGui::BeginTable(
id, 32, ImGuiTableFlags_SizingFixedFit);
252 ImGui::PopStyleVar();
256 std::function<
void()> on_click) {
257 ImGui::TableNextColumn();
263 if (ImGui::Button(icon)) {
264 if (on_click) on_click();
268 ImGui::PopStyleColor();
271 if (tooltip && ImGui::IsItemHovered()) {
272 ImGui::SetTooltip(
"%s", tooltip);
277 ImGuiWindowFlags flags = scrollable ?
278 ImGuiWindowFlags_AlwaysVerticalScrollbar :
279 ImGuiWindowFlags_None;
280 ImGui::BeginChild(
id, ImVec2(0, 0),
true, flags);
289 snprintf(tab_label,
sizeof(tab_label),
"%s %s", icon, label);
290 return ImGui::BeginTabItem(tab_label, p_open);
294 const char* confirm_text,
const char* cancel_text) {
295 bool confirmed =
false;
297 if (ImGui::BeginPopupModal(
id,
nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
298 ImGui::Text(
"%s", title);
300 ImGui::TextWrapped(
"%s", message);
305 ImGui::CloseCurrentPopup();
309 if (ImGui::Button(cancel_text, ImVec2(120, 0))) {
310 ImGui::CloseCurrentPopup();
326 ImDrawList* draw_list = ImGui::GetWindowDrawList();
327 ImVec2 pos = ImGui::GetCursorScreenPos();
331 pos.y += ImGui::GetTextLineHeight() * 0.5f;
333 draw_list->AddCircleFilled(pos, radius, ImGui::GetColorU32(color));
335 ImGui::SetCursorPosX(ImGui::GetCursorPosX() + radius * 2 + 8);
336 ImGui::Text(
"%s", label);
338 if (tooltip && ImGui::IsItemHovered()) {
339 ImGui::SetTooltip(
"%s", tooltip);
347 ImGui::PushStyleColor(ImGuiCol_Text, color);
348 ImGui::Text(
"%s %s", icon, version);
349 ImGui::PopStyleColor();
365 ImGui::Dummy(ImVec2(0, pixels));
369 ImGui::Dummy(ImVec2(pixels, 0));
374 float text_width = ImGui::CalcTextSize(text).x;
375 ImGui::SetCursorPosX((ImGui::GetContentRegionAvail().x - text_width) * 0.5f);
376 ImGui::Text(
"%s", text);
380 ImGui::SetCursorPosX(ImGui::GetCursorPosX() +
381 ImGui::GetContentRegionAvail().x - width);
389 return 0.5f + 0.5f * sinf(
static_cast<float>(ImGui::GetTime()) * speed * 2.0f);
393 static double start_time = 0.0;
394 double current_time = ImGui::GetTime();
396 if (start_time == 0.0) {
397 start_time = current_time;
400 float elapsed =
static_cast<float>(current_time - start_time);
401 float alpha = ImClamp(elapsed / duration, 0.0f, 1.0f);
412 ImGui::PushStyleVar(ImGuiStyleVar_Alpha,
417 ImGui::PopStyleVar();
421 ImDrawList* draw_list = ImGui::GetWindowDrawList();
422 ImVec2 pos = ImGui::GetCursorScreenPos();
426 const float rotation =
static_cast<float>(ImGui::GetTime()) * 3.0f;
427 const int segments = 16;
428 const float thickness = 3.0f;
430 const float start_angle = rotation;
431 const float end_angle = rotation +
IM_PI * 1.5f;
433 draw_list->PathArcTo(pos, radius, start_angle, end_angle, segments);
434 draw_list->PathStroke(ImGui::GetColorU32(
GetAccentColor()), 0, thickness);
437 ImGui::SetCursorPosX(ImGui::GetCursorPosX() + radius * 2 + 8);
438 ImGui::Text(
"%s", label);
440 ImGui::Dummy(ImVec2(radius * 2 + 8, radius * 2 + 8));
449 float available = ImGui::GetContentRegionAvail().x;
450 float target = available * ratio;
452 if (target < min_width)
return min_width;
453 if (target > max_width)
return max_width;
458 float available = ImGui::GetContentRegionAvail().x;
459 float col_width = available / count;
461 if (col_width < min_col_width) {
462 col_width = min_col_width;
465 for (
int i = 0; i < count; ++i) {
466 ImGui::TableSetupColumn(
"##col", ImGuiTableColumnFlags_WidthFixed, col_width);
470static int g_two_col_table_active = 0;
473 ImGuiTableFlags flags = ImGuiTableFlags_Resizable |
474 ImGuiTableFlags_BordersInnerV |
475 ImGuiTableFlags_SizingStretchProp;
477 if (ImGui::BeginTable(
id, 2, flags)) {
478 float available = ImGui::GetContentRegionAvail().x;
479 ImGui::TableSetupColumn(
"##left", ImGuiTableColumnFlags_None,
480 available * split_ratio);
481 ImGui::TableSetupColumn(
"##right", ImGuiTableColumnFlags_None,
482 available * (1.0f - split_ratio));
483 ImGui::TableNextRow();
484 ImGui::TableNextColumn();
485 g_two_col_table_active++;
490 ImGui::TableNextColumn();
495 g_two_col_table_active--;
504 ImGui::PushItemWidth(60);
505 bool changed = ImGui::InputScalar(
"##hex", ImGuiDataType_U8, value,
nullptr,
507 ImGuiInputTextFlags_CharsHexadecimal);
508 ImGui::PopItemWidth();
515 ImGui::PushItemWidth(80);
516 bool changed = ImGui::InputScalar(
"##hex", ImGuiDataType_U16, value,
nullptr,
518 ImGuiInputTextFlags_CharsHexadecimal);
519 ImGui::PopItemWidth();
524bool IconCombo(
const char* icon,
const char* label,
int* current,
525 const char*
const items[],
int count) {
526 ImGui::Text(
"%s", icon);
528 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)
ImVec4 GetThemeColor(ImGuiCol idx)
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)
void StatusBadge(const char *text, ButtonType type)
void HorizontalSpacing(float pixels)
ImVec4 GetCustomRomColor()
Main namespace for the application.