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 extra_flags) {
113 ImGuiTableFlags flags =
114 ImGuiTableFlags_Borders | ImGuiTableFlags_SizingFixedFit | extra_flags;
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);
189 ImGui::PushStyleColor(ImGuiCol_Button, color);
190 ImGui::PushStyleColor(
191 ImGuiCol_ButtonHovered,
192 ImVec4(color.x * 1.2f, color.y * 1.2f, color.z * 1.2f, color.w));
193 ImGui::PushStyleColor(
194 ImGuiCol_ButtonActive,
195 ImVec4(color.x * 0.8f, color.y * 0.8f, color.z * 0.8f, color.w));
197 bool result = ImGui::Button(label, size);
199 ImGui::PopStyleColor(3);
204 const char* tooltip) {
205 const char* icon = *state ? icon_on : icon_off;
208 ImGui::PushStyleColor(ImGuiCol_Button, color);
209 bool result = ImGui::SmallButton(icon);
210 ImGui::PopStyleColor();
215 if (tooltip && ImGui::IsItemHovered()) {
216 ImGui::SetTooltip(
"%s", tooltip);
229 bool result = ImGui::Button(label, size);
232 ImGui::PopStyleColor(3);
240 if (ImGui::IsItemHovered()) {
241 ImGui::BeginTooltip();
242 ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
243 ImGui::TextUnformatted(desc);
244 ImGui::PopTextWrapPos();
250 ImGui::SeparatorText(label);
273 ImGui::PushStyleColor(ImGuiCol_Button, color);
274 ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 10.0f);
275 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(8, 3));
276 ImGui::SmallButton(text);
277 ImGui::PopStyleVar(2);
278 ImGui::PopStyleColor();
286 ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(2, 2));
287 ImGui::BeginTable(
id, 32, ImGuiTableFlags_SizingFixedFit);
292 ImGui::PopStyleVar();
296 std::function<
void()> on_click) {
297 ImGui::TableNextColumn();
303 if (ImGui::Button(icon)) {
309 ImGui::PopStyleColor();
312 if (tooltip && ImGui::IsItemHovered()) {
313 ImGui::SetTooltip(
"%s", tooltip);
318 ImGuiWindowFlags flags = scrollable ? ImGuiWindowFlags_AlwaysVerticalScrollbar
319 : ImGuiWindowFlags_None;
320 ImGui::BeginChild(
id, ImVec2(0, 0),
true, flags);
329 snprintf(tab_label,
sizeof(tab_label),
"%s %s", icon, label);
330 return ImGui::BeginTabItem(tab_label, p_open);
334 const char* confirm_text,
const char* cancel_text) {
335 bool confirmed =
false;
337 if (ImGui::BeginPopupModal(
id,
nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
338 ImGui::Text(
"%s", title);
340 ImGui::TextWrapped(
"%s", message);
345 ImGui::CloseCurrentPopup();
349 if (ImGui::Button(cancel_text, ImVec2(120, 0))) {
350 ImGui::CloseCurrentPopup();
367 ImDrawList* draw_list = ImGui::GetWindowDrawList();
368 ImVec2 pos = ImGui::GetCursorScreenPos();
372 pos.y += ImGui::GetTextLineHeight() * 0.5f;
374 draw_list->AddCircleFilled(pos, radius, ImGui::GetColorU32(color));
376 ImGui::SetCursorPosX(ImGui::GetCursorPosX() + radius * 2 + 8);
377 ImGui::Text(
"%s", label);
379 if (tooltip && ImGui::IsItemHovered()) {
380 ImGui::SetTooltip(
"%s", tooltip);
388 ImGui::PushStyleColor(ImGuiCol_Text, color);
389 ImGui::Text(
"%s %s", icon, version);
390 ImGui::PopStyleColor();
406 ImGui::Dummy(ImVec2(0, pixels));
410 ImGui::Dummy(ImVec2(pixels, 0));
415 float text_width = ImGui::CalcTextSize(text).x;
416 ImGui::SetCursorPosX((ImGui::GetContentRegionAvail().x - text_width) * 0.5f);
417 ImGui::Text(
"%s", text);
421 ImGui::SetCursorPosX(ImGui::GetCursorPosX() +
422 ImGui::GetContentRegionAvail().x - width);
431 0.5f * sinf(
static_cast<float>(ImGui::GetTime()) * speed * 2.0f);
435 static double start_time = 0.0;
436 double current_time = ImGui::GetTime();
438 if (start_time == 0.0) {
439 start_time = current_time;
442 float elapsed =
static_cast<float>(current_time - start_time);
443 float alpha = ImClamp(elapsed / duration, 0.0f, 1.0f);
454 ImGui::PushStyleVar(ImGuiStyleVar_Alpha,
459 ImGui::PopStyleVar();
463 ImDrawList* draw_list = ImGui::GetWindowDrawList();
464 ImVec2 pos = ImGui::GetCursorScreenPos();
468 const float rotation =
static_cast<float>(ImGui::GetTime()) * 3.0f;
469 const int segments = 16;
470 const float thickness = 3.0f;
472 const float start_angle = rotation;
473 const float end_angle = rotation +
IM_PI * 1.5f;
475 draw_list->PathArcTo(pos, radius, start_angle, end_angle, segments);
476 draw_list->PathStroke(ImGui::GetColorU32(
GetAccentColor()), 0, thickness);
479 ImGui::SetCursorPosX(ImGui::GetCursorPosX() + radius * 2 + 8);
480 ImGui::Text(
"%s", label);
482 ImGui::Dummy(ImVec2(radius * 2 + 8, radius * 2 + 8));
491 float available = ImGui::GetContentRegionAvail().x;
492 float target = available * ratio;
494 if (target < min_width)
496 if (target > max_width)
502 float available = ImGui::GetContentRegionAvail().x;
503 float col_width = available / count;
505 if (col_width < min_col_width) {
506 col_width = min_col_width;
509 for (
int i = 0; i < count; ++i) {
510 ImGui::TableSetupColumn(
"##col", ImGuiTableColumnFlags_WidthFixed,
515static int g_two_col_table_active = 0;
518 ImGuiTableFlags flags = ImGuiTableFlags_Resizable |
519 ImGuiTableFlags_BordersInnerV |
520 ImGuiTableFlags_SizingStretchProp;
522 if (ImGui::BeginTable(
id, 2, flags)) {
523 float available = ImGui::GetContentRegionAvail().x;
524 ImGui::TableSetupColumn(
"##left", ImGuiTableColumnFlags_None,
525 available * split_ratio);
526 ImGui::TableSetupColumn(
"##right", ImGuiTableColumnFlags_None,
527 available * (1.0f - split_ratio));
528 ImGui::TableNextRow();
529 ImGui::TableNextColumn();
530 g_two_col_table_active++;
535 ImGui::TableNextColumn();
540 g_two_col_table_active--;
549 ImGui::PushItemWidth(60);
551 ImGui::InputScalar(
"##hex", ImGuiDataType_U8, value,
nullptr,
nullptr,
552 "%02X", ImGuiInputTextFlags_CharsHexadecimal);
553 ImGui::PopItemWidth();
560 ImGui::PushItemWidth(80);
562 ImGui::InputScalar(
"##hex", ImGuiDataType_U16, value,
nullptr,
nullptr,
563 "%04X", ImGuiInputTextFlags_CharsHexadecimal);
564 ImGui::PopItemWidth();
569bool IconCombo(
const char* icon,
const char* label,
int* current,
570 const char*
const items[],
int count) {
571 ImGui::Text(
"%s", icon);
573 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)
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)
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()