diff --git a/src/command/command.cpp b/src/command/command.cpp index f795f440a5..3b97915ae6 100644 --- a/src/command/command.cpp +++ b/src/command/command.cpp @@ -18,6 +18,9 @@ #include "format.h" #include +#include + +#include "include/aegisub/hotkey.h" #include @@ -32,6 +35,16 @@ static iterator find_command(std::string_view name) { throw CommandNotFound(agi::format(_("'%s' is not a valid command name"), name)); } +wxString Command::GetTooltip(std::string ht_context) const { + wxString ret = StrHelp(); + + std::vector hotkeys = hotkey::get_hotkey_strs(ht_context, name()); + if (!hotkeys.empty()) + ret += to_wx(" (" + agi::Join("/", hotkeys) + ")"); + + return ret; +} + void reg(std::unique_ptr cmd) { auto name = cmd->name(); cmd_map.emplace(name, std::move(cmd)); diff --git a/src/command/command.h b/src/command/command.h index 8e54a65b59..8c26e8d4f1 100644 --- a/src/command/command.h +++ b/src/command/command.h @@ -103,6 +103,9 @@ DEFINE_EXCEPTION(CommandNotFound, CommandError); /// Short help string describing what the command does virtual wxString StrHelp() const=0; + /// Formats the Help text together with the registered hotkey + wxString GetTooltip(std::string ht_context) const; + /// Get this command's type flags /// @return Bitmask of CommandFlags virtual int Type() const { return COMMAND_NORMAL; } diff --git a/src/toolbar.cpp b/src/toolbar.cpp index c88bb0276d..9d1aa33554 100644 --- a/src/toolbar.cpp +++ b/src/toolbar.cpp @@ -143,7 +143,7 @@ namespace { wxITEM_NORMAL; wxBitmap const& bitmap = command->Icon(icon_size, retina_helper.GetScaleFactor(), GetLayoutDirection()); - AddTool(TOOL_ID_BASE + commands.size(), command->StrDisplay(context), BITMAPBUNDLE(bitmap), GetTooltip(command), kind); + AddTool(TOOL_ID_BASE + commands.size(), command->StrDisplay(context), BITMAPBUNDLE(bitmap), command->GetTooltip(ht_context), kind); commands.push_back(command); needs_onidle = needs_onidle || flags != cmd::COMMAND_NORMAL; @@ -157,16 +157,6 @@ namespace { Realize(); } - wxString GetTooltip(cmd::Command *command) { - wxString ret = command->StrHelp(); - - std::vector hotkeys = hotkey::get_hotkey_strs(ht_context, command->name()); - if (!hotkeys.empty()) - ret += to_wx(" (" + agi::Join("/", hotkeys) + ")"); - - return ret; - } - public: Toolbar(wxWindow *parent, std::string name, agi::Context *c, std::string ht_context, bool vertical) : wxToolBar(parent, -1, wxDefaultPosition, wxDefaultSize, wxTB_NODIVIDER | wxTB_FLAT | (vertical ? wxTB_VERTICAL : wxTB_HORIZONTAL)) diff --git a/src/visual_tool_vector_clip.cpp b/src/visual_tool_vector_clip.cpp index 5b4ae1ec89..3ba4d2a4c7 100644 --- a/src/visual_tool_vector_clip.cpp +++ b/src/visual_tool_vector_clip.cpp @@ -39,7 +39,7 @@ VisualToolVectorClip::VisualToolVectorClip(VideoDisplay *parent, agi::Context *c void VisualToolVectorClip::AddTool(std::string command_name, VisualToolVectorClipMode mode) { cmd::Command *command = cmd::get(command_name); int icon_size = OPT_GET("App/Toolbar Icon Size")->GetInt(); - toolBar->AddTool(BUTTON_ID_BASE + mode, command->StrDisplay(c), command->Icon(icon_size), command->StrHelp(), wxITEM_CHECK); + toolBar->AddTool(BUTTON_ID_BASE + mode, command->StrDisplay(c), command->Icon(icon_size), command->GetTooltip("Video"), wxITEM_CHECK); }