Skip to content

Commit

Permalink
Added help/keyboard shortcuts menu
Browse files Browse the repository at this point in the history
  • Loading branch information
ypujante committed May 15, 2023
1 parent 671f322 commit e1ea999
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.24)

set(re-edit_VERSION_MAJOR 1)
set(re-edit_VERSION_MINOR 4)
set(re-edit_VERSION_PATCH 1)
set(re-edit_VERSION_PATCH 2)
set(re-edit_VERSION "${re-edit_VERSION_MAJOR}.${re-edit_VERSION_MINOR}.${re-edit_VERSION_PATCH}")

execute_process(COMMAND git describe --long --dirty --abbrev=10 --tags
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ pongasoft produces a variety of high quality and free/open source software. If y
Release Notes
-------------

* #### 1.4.2 - 2023/05/15

- Added Help menu: displays the keyboard shortcuts
- Uses re-mock 1.4.3 which means re-edit can be built without depending on the RE SDK

* #### 1.4.1 - 2023/05/07

- Added ability to load a project by simply dragging it from the Finder (resp. File Explorer) onto the main window
Expand Down
70 changes: 70 additions & 0 deletions src/cpp/re/edit/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,10 @@ void Application::renderApplicationMenuItems()
{
newAboutDialog();
}
if(ImGui::MenuItem("Help"))
{
newHelpDialog();
}
if(ImGui::BeginMenu("Style"))
{
std::optional<config::Style> newStyle{};
Expand Down Expand Up @@ -1504,5 +1508,71 @@ void Application::about() const
}
}

//------------------------------------------------------------------------
// Application::newHelpDialog
//------------------------------------------------------------------------
void Application::newHelpDialog()
{
newDialog("Help")
.lambda([this]() { help(); })
.buttonOk();
}

//------------------------------------------------------------------------
// Application::help
//------------------------------------------------------------------------
void Application::help() const
{
static const std::vector<std::tuple<char const *, char const *, std::vector<char const *>>> kShortcuts = {
{"CMD =", "Ctrl + =", {"Increment zoom (+10%)"} },
{"CMD -", "Ctrl + -", {"Decrement zoom (+10%)"} },
{"CMD 0", "Ctrl + 0", {"Zoom to fit"} },
{"CMD Z", "Ctrl + Z", {"Undo"} },
{"CMD Shift Z", "Ctrl + Shift + Z", {"Redo"} },
{"CMD S", "Ctrl + S", {"Save"} },
{"CMD Q", "Ctrl + Q", {"Quit"} },
{"Alt", "Alt", {"Disable the grid temporarily while being held", "Display alternate menu entries (ex: \"Select All\" includes hidden widgets)", "Add the dragged widget to the visibility group"} },
{"Arrows", "Arrows", {"Move the panel"} },
{"Space Bar + LMB", "Space Bar + LMB", {"Move the panel (when mouse is over the panel)"} },
{"Mouse Wheel", "Mouse Wheel", {"Zoom in/out (when mouse is over the Panel)"} },
{"A", "A", {"Toggle Select All/Select None"} },
{"B", "B", {"Toggle Widget Borders"} },
{"C", "C", {"Center the panel"} },
{"F", "F", {"Zoom to fit (one hand shortcut)"} },
{"Q", "Q", {"Quick View (while being held)"} },
{"R", "R", {"Toggle Rails (also toggle Panel X-Ray to see the rails)"} },
{"X", "X", {"Toggle Widget X-Ray"} },
};

#if WIN32
static constexpr int kShortcutIndex = 1;
#else
static constexpr int kShortcutIndex = 0;
#endif

ImGui::SeparatorText("Keyboard Shortcuts");
if(ImGui::BeginTable("keyboard_shortcuts", 2, ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersInnerV))
{
ImGui::TableSetupColumn("Shortcut");
ImGui::TableSetupColumn("Description");
ImGui::TableHeadersRow();

for(auto &shortcut: kShortcuts)
{
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
ImGui::TextUnformatted(std::get<kShortcutIndex>(shortcut));
ImGui::TableSetColumnIndex(1);
auto const &description = std::get<2>(shortcut);
for(auto const &item: std::get<2>(shortcut))
{
ImGui::TextUnformatted(item);
}
}

ImGui::EndTable();
}

}

}
2 changes: 2 additions & 0 deletions src/cpp/re/edit/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ class Application
void renderApplicationMenuItems();
void newAboutDialog();
void about() const;
void newHelpDialog();
void help() const;
inline bool hasDialog() const { return fCurrentDialog != nullptr || !fDialogs.empty(); }
template<typename F>
void executeAndAbortOnException(F&& f) noexcept;
Expand Down

0 comments on commit e1ea999

Please sign in to comment.