yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
shortcut_legend_panel.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_DUNGEON_PANELS_SHORTCUT_LEGEND_PANEL_H
2#define YAZE_APP_EDITOR_DUNGEON_PANELS_SHORTCUT_LEGEND_PANEL_H
3
6#include "imgui/imgui.h"
7
8namespace yaze::editor {
9
10// A simple modal panel listing all keyboard shortcuts for the dungeon editor.
11// Can be triggered via a toolbar "?" button or Ctrl+?.
13 public:
14 static void Draw(bool* p_open) {
15 if (!p_open || !*p_open)
16 return;
17
18 ImGui::SetNextWindowSize(ImVec2(420, 480), ImGuiCond_FirstUseEver);
19 if (!ImGui::Begin(ICON_MD_KEYBOARD " Keyboard Shortcuts", p_open)) {
20 ImGui::End();
21 return;
22 }
23
24 constexpr ImGuiTableFlags kFlags = ImGuiTableFlags_RowBg |
25 ImGuiTableFlags_BordersInnerH |
26 ImGuiTableFlags_PadOuterX;
27
28 // ---- Editing ----
29 ImGui::TextDisabled(ICON_MD_EDIT " Editing");
30 if (ImGui::BeginTable("##ShortcutsEdit", 2, kFlags)) {
31 ImGui::TableSetupColumn("Action", ImGuiTableColumnFlags_WidthStretch);
32 ImGui::TableSetupColumn("Shortcut", ImGuiTableColumnFlags_WidthFixed,
33 140);
34 ShortcutRow("Cut", "Ctrl+X");
35 ShortcutRow("Copy", "Ctrl+C");
36 ShortcutRow("Paste", "Ctrl+V");
37 ShortcutRow("Duplicate", "Ctrl+D");
38 ShortcutRow("Delete", "Del / Backspace");
39 ShortcutRow("Undo", "Ctrl+Z");
40 ShortcutRow("Redo", "Ctrl+Y / Ctrl+Shift+Z");
41 ShortcutRow("Select All", "Ctrl+A");
42 ShortcutRow("Cancel Placement", "Esc");
43 ImGui::EndTable();
44 }
45
46 ImGui::Spacing();
47
48 // ---- Layers ----
49 ImGui::TextDisabled(ICON_MD_LAYERS " Layers");
50 if (ImGui::BeginTable("##ShortcutsLayers", 2, kFlags)) {
51 ImGui::TableSetupColumn("Action", ImGuiTableColumnFlags_WidthStretch);
52 ImGui::TableSetupColumn("Shortcut", ImGuiTableColumnFlags_WidthFixed,
53 140);
54 ShortcutRow("Send to Layer 1", "1");
55 ShortcutRow("Send to Layer 2", "2");
56 ShortcutRow("Send to Layer 3", "3");
57 ShortcutRow("Bring to Front", "Ctrl+Shift+]");
58 ShortcutRow("Send to Back", "Ctrl+Shift+[");
59 ShortcutRow("Bring Forward", "Ctrl+]");
60 ShortcutRow("Send Backward", "Ctrl+[");
61 ImGui::EndTable();
62 }
63
64 ImGui::Spacing();
65
66 // ---- Navigation ----
67 ImGui::TextDisabled(ICON_MD_NAVIGATION " Navigation");
68 if (ImGui::BeginTable("##ShortcutsNav", 2, kFlags)) {
69 ImGui::TableSetupColumn("Action", ImGuiTableColumnFlags_WidthStretch);
70 ImGui::TableSetupColumn("Shortcut", ImGuiTableColumnFlags_WidthFixed,
71 140);
72 ShortcutRow("Cycle Room Tabs", "Ctrl+Tab");
73 ShortcutRow("Adjacent Room (N/S/E/W)", "Ctrl+Arrow Keys");
74 ShortcutRow("Save Room", "Ctrl+Shift+S");
75 ShortcutRow("Re-render Room", "Ctrl+R");
76 ImGui::EndTable();
77 }
78
79 ImGui::Spacing();
80
81 // ---- View ----
82 ImGui::TextDisabled(ICON_MD_VISIBILITY " View");
83 if (ImGui::BeginTable("##ShortcutsView", 2, kFlags)) {
84 ImGui::TableSetupColumn("Action", ImGuiTableColumnFlags_WidthStretch);
85 ImGui::TableSetupColumn("Shortcut", ImGuiTableColumnFlags_WidthFixed,
86 140);
87 ShortcutRow("Toggle Grid", "G");
88 ShortcutRow("Zoom In", "Ctrl+ +");
89 ShortcutRow("Zoom Out", "Ctrl+ -");
90 ShortcutRow("Reset Zoom", "Ctrl+0");
91 ImGui::EndTable();
92 }
93
94 ImGui::End();
95 }
96
97 private:
98 static void ShortcutRow(const char* action, const char* shortcut) {
99 ImGui::TableNextRow();
100 ImGui::TableNextColumn();
101 ImGui::TextUnformatted(action);
102 ImGui::TableNextColumn();
103 ImGui::TextDisabled("%s", shortcut);
104 }
105};
106
107} // namespace yaze::editor
108
109#endif // YAZE_APP_EDITOR_DUNGEON_PANELS_SHORTCUT_LEGEND_PANEL_H
static void ShortcutRow(const char *action, const char *shortcut)
#define ICON_MD_VISIBILITY
Definition icons.h:2101
#define ICON_MD_EDIT
Definition icons.h:645
#define ICON_MD_LAYERS
Definition icons.h:1068
#define ICON_MD_KEYBOARD
Definition icons.h:1028
#define ICON_MD_NAVIGATION
Definition icons.h:1276
Editors are the view controllers for the application.