yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
empty_state.cc
Go to the documentation of this file.
2
6#include "imgui/imgui.h"
7
8namespace yaze {
9namespace gui {
10
11namespace {
12
13void CenterNextItem(float width) {
14 const float avail = ImGui::GetContentRegionAvail().x;
15 if (avail > width) {
16 ImGui::SetCursorPosX(ImGui::GetCursorPosX() + (avail - width) * 0.5f);
17 }
18}
19
20} // namespace
21
22bool DrawEmptyState(const EmptyStateOptions& options) {
23 if (!options.title && !options.detail && !options.icon) {
24 return false;
25 }
26
27 const float top_pad = options.compact ? 8.0f : 24.0f;
28 const float mid_pad = options.compact ? 6.0f : 12.0f;
29 ImGui::Dummy(ImVec2(0.0f, top_pad));
30
31 if (options.icon && options.icon[0] != '\0') {
32 const ImVec2 icon_size = ImGui::CalcTextSize(options.icon);
33 CenterNextItem(icon_size.x);
35 }
36
37 if (options.title && options.title[0] != '\0') {
38 ImGui::Spacing();
39 const ImVec2 title_size = ImGui::CalcTextSize(options.title);
40 CenterNextItem(title_size.x);
41 ColoredText(options.title,
43 }
44
45 if (options.detail && options.detail[0] != '\0') {
46 ImGui::Dummy(ImVec2(0.0f, mid_pad * 0.5f));
47 const float wrap_width =
48 ImGui::GetContentRegionAvail().x * (options.compact ? 0.95f : 0.85f);
49 const float indent = (ImGui::GetContentRegionAvail().x - wrap_width) * 0.5f;
50 if (indent > 0.0f) {
51 ImGui::SetCursorPosX(ImGui::GetCursorPosX() + indent);
52 }
53 ImGui::PushTextWrapPos(ImGui::GetCursorPosX() + wrap_width);
54 ImGui::TextDisabled("%s", options.detail);
55 ImGui::PopTextWrapPos();
56 }
57
58 bool clicked = false;
59 if (options.action_label && options.action_label[0] != '\0') {
60 ImGui::Dummy(ImVec2(0.0f, mid_pad));
61 const ImVec2 label_size = ImGui::CalcTextSize(options.action_label);
62 const float button_width =
63 label_size.x + ImGui::GetStyle().FramePadding.x * 4.0f;
64 CenterNextItem(button_width);
65 if (PrimaryButton(options.action_label, ImVec2(button_width, 0.0f))) {
66 clicked = true;
67 if (options.on_action) {
68 options.on_action();
69 }
70 }
71 }
72
73 ImGui::Dummy(ImVec2(0.0f, top_pad * 0.5f));
74 return clicked;
75}
76
80 opts.title = "Open a ROM";
81 opts.detail =
82 "Use File > Open ROM / Project, or drop a .sfc / .smc file onto the "
83 "window.";
84 opts.compact = compact;
85 return opts;
86}
87
91 opts.title = "Select something";
92 opts.detail =
93 "Click an object in the active editor to view and edit its properties. "
94 "Dungeon: rooms, objects, sprites. Overworld: maps, tiles, entities. "
95 "Graphics: sheets, palettes.";
96 opts.compact = compact;
97 return opts;
98}
99
102 opts.icon = ICON_MD_MOUSE;
103 opts.title = "Select in the canvas";
104 opts.detail =
105 "Click a room object, door, sprite, or item to inspect it here. "
106 "Shift-click and drag to multi-select. Use placement panels to add new "
107 "entities.";
108 opts.compact = compact;
109 return opts;
110}
111
115 opts.title = "Open a project";
116 opts.detail =
117 "Create or open a .yaze project via File > New Project / Open to manage "
118 "ROM versioning, snapshots, and project settings.";
119 opts.compact = compact;
120 return opts;
121}
122
123EmptyStateOptions EmptyLoading(const char* what, bool compact) {
126 opts.title = "Loading…";
127 opts.detail = what;
128 opts.compact = compact;
129 return opts;
130}
131
132} // namespace gui
133} // namespace yaze
#define ICON_MD_FOLDER_OPEN
Definition icons.h:813
#define ICON_MD_FOLDER_SPECIAL
Definition icons.h:815
#define ICON_MD_TOUCH_APP
Definition icons.h:2000
#define ICON_MD_MOUSE
Definition icons.h:1251
#define ICON_MD_HOURGLASS_EMPTY
Definition icons.h:967
void ColoredText(const char *text, const ImVec4 &color)
bool PrimaryButton(const char *label, const ImVec2 &size, const char *panel_id, const char *anim_id)
Draw a primary action button (accented color).
EmptyStateOptions EmptyLoading(const char *what, bool compact)
EmptyStateOptions EmptyNoProject(bool compact)
ImVec4 GetDisabledColor()
Definition ui_helpers.cc:74
bool DrawEmptyState(const EmptyStateOptions &options)
Draw a centered empty-state block.
EmptyStateOptions EmptyNoSelection(bool compact)
EmptyStateOptions EmptyNoRom(bool compact)
EmptyStateOptions EmptySelectInCanvas(bool compact)
ImVec4 ResolveSemanticColor(SemanticColor color)
Definition ui_helpers.cc:20
Shared empty / disabled panel presentation.
Definition empty_state.h:15
std::function< void()> on_action
Definition empty_state.h:20
bool compact
Tighter vertical rhythm for drawers / inspectors.
Definition empty_state.h:22