mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-31 07:59:27 +02:00
Transport button tooltips with shortcuts use Mac special chars
This commit is contained in:
parent
8dfaa4dcf8
commit
5f8fad4a48
@ -200,44 +200,38 @@ void ControlToolBar::Populate()
|
||||
void ControlToolBar::RegenerateToolsTooltips()
|
||||
{
|
||||
#if wxUSE_TOOLTIPS
|
||||
std::vector<wxString> commands;
|
||||
for (long iWinID = ID_PLAY_BUTTON; iWinID < BUTTON_COUNT; iWinID++)
|
||||
{
|
||||
wxWindow* pCtrl = this->FindWindow(iWinID);
|
||||
wxString strToolTip = pCtrl->GetLabel();
|
||||
AudacityProject* pProj = GetActiveProject();
|
||||
CommandManager* pCmdMgr = (pProj) ? pProj->GetCommandManager() : NULL;
|
||||
if (pCmdMgr)
|
||||
commands.clear();
|
||||
auto pCtrl = static_cast<AButton*>(this->FindWindow(iWinID));
|
||||
commands.push_back(pCtrl->GetLabel());
|
||||
switch (iWinID)
|
||||
{
|
||||
wxString strKey(wxT(" ("));
|
||||
switch (iWinID)
|
||||
{
|
||||
case ID_PLAY_BUTTON:
|
||||
strKey += pCmdMgr->GetKeyFromName(wxT("Play"));
|
||||
strKey += _(") / Loop Play (");
|
||||
strKey += pCmdMgr->GetKeyFromName(wxT("PlayLooped"));
|
||||
break;
|
||||
case ID_RECORD_BUTTON:
|
||||
strKey += pCmdMgr->GetKeyFromName(wxT("Record"));
|
||||
strKey += _(") / Append Record (");
|
||||
strKey += pCmdMgr->GetKeyFromName(wxT("RecordAppend"));
|
||||
break;
|
||||
case ID_PAUSE_BUTTON:
|
||||
strKey += pCmdMgr->GetKeyFromName(wxT("Pause"));
|
||||
break;
|
||||
case ID_STOP_BUTTON:
|
||||
strKey += pCmdMgr->GetKeyFromName(wxT("Stop"));
|
||||
break;
|
||||
case ID_FF_BUTTON:
|
||||
strKey += pCmdMgr->GetKeyFromName(wxT("SkipEnd"));
|
||||
break;
|
||||
case ID_REW_BUTTON:
|
||||
strKey += pCmdMgr->GetKeyFromName(wxT("SkipStart"));
|
||||
break;
|
||||
}
|
||||
strKey += wxT(")");
|
||||
strToolTip += strKey;
|
||||
case ID_PLAY_BUTTON:
|
||||
commands.push_back(wxT("Play"));
|
||||
commands.push_back(_("Loop Play"));
|
||||
commands.push_back(wxT("PlayLooped"));
|
||||
break;
|
||||
case ID_RECORD_BUTTON:
|
||||
commands.push_back(wxT("Record"));
|
||||
commands.push_back(_("Append Record"));
|
||||
commands.push_back(wxT("RecordAppend"));
|
||||
break;
|
||||
case ID_PAUSE_BUTTON:
|
||||
commands.push_back(wxT("Pause"));
|
||||
break;
|
||||
case ID_STOP_BUTTON:
|
||||
commands.push_back(wxT("Stop"));
|
||||
break;
|
||||
case ID_FF_BUTTON:
|
||||
commands.push_back(wxT("SkipEnd"));
|
||||
break;
|
||||
case ID_REW_BUTTON:
|
||||
commands.push_back(wxT("SkipStart"));
|
||||
break;
|
||||
}
|
||||
pCtrl->SetToolTip(strToolTip);
|
||||
ToolBar::SetButtonToolTip(*pCtrl, commands);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ in which buttons can be placed.
|
||||
#include "../ImageManipulation.h"
|
||||
#include "../Project.h"
|
||||
#include "../Theme.h"
|
||||
#include "../commands/Keyboard.h"
|
||||
#include "../widgets/AButton.h"
|
||||
#include "../widgets/Grabber.h"
|
||||
|
||||
@ -761,6 +762,33 @@ void ToolBar::MakeAlternateImages(AButton &button, int idx,
|
||||
button.SetAlternateImages(idx, *up, *hilite, *down, *disable);
|
||||
}
|
||||
|
||||
void ToolBar::SetButtonToolTip
|
||||
(AButton &button, const std::vector<wxString> &commands, const wxString &separator)
|
||||
{
|
||||
const auto project = GetActiveProject();
|
||||
const auto commandManager = project ? project->GetCommandManager() : nullptr;
|
||||
wxString result;
|
||||
auto iter = commands.begin(), end = commands.end();
|
||||
while (iter != end) {
|
||||
result += *iter++;
|
||||
if (iter != end) {
|
||||
if (!iter->empty()) {
|
||||
if (commandManager) {
|
||||
auto keyStr = commandManager->GetKeyFromName(*iter);
|
||||
if (keyStr.empty())
|
||||
keyStr = _("no key");
|
||||
result += wxT(" ");
|
||||
result += Internat::Parenthesize(KeyStringDisplay(keyStr, true));
|
||||
}
|
||||
}
|
||||
++iter;
|
||||
}
|
||||
if (iter != end)
|
||||
result += separator;
|
||||
}
|
||||
button.SetToolTip(result);
|
||||
}
|
||||
|
||||
//
|
||||
// This changes the state a button (from up to down or vice versa)
|
||||
//
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include "../Experimental.h"
|
||||
|
||||
#include <vector>
|
||||
#include <wx/defs.h>
|
||||
#include <wx/panel.h>
|
||||
#include <wx/sizer.h>
|
||||
@ -149,7 +150,18 @@ class ToolBar /* not final */ : public wxPanel
|
||||
teBmps eStandardDown,
|
||||
teBmps eDisabled,
|
||||
wxSize size);
|
||||
|
||||
|
||||
static
|
||||
void SetButtonToolTip
|
||||
(AButton &button,
|
||||
// An array, alternating user-visible strings, and
|
||||
// non-user-visible command names. If a shortcut key is defined
|
||||
// for the command, then it is appended, parenthesized, after the
|
||||
// user-visible string.
|
||||
const std::vector<wxString> &commands,
|
||||
// If more than one pair of strings is given, then use this separator.
|
||||
const wxString &separator = wxT(" / "));
|
||||
|
||||
protected:
|
||||
void SetButton(bool down, AButton *button);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user