mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-20 22:30:05 +02:00
Gale suggested showing current key shortcuts for toolbar controls tooltips. This implements it for ControlToolBar (aka Transport toolbar).
One tricky aspect was that until GetActiveProject() is ready to return non-NULL, ControlToolBar::RegenerateToolsTooltips() cannot get the project's CommandManager, so cannot get the shortcuts. Changed ControlToolBar::RegenerateToolsTooltips() to be public and now call it late in wAudacityProject(). When called before the project is completely instantiated, in the rewritten ControlToolBar::RegenerateToolsTooltips(), it just sets the tooltips to the names without the keys, pretty much as now -- but I don't think users will ever see that because of the subsequent call. Anyway, did it in a more programmatic way than the previous code, which reduces string literals duplication. Btw, I changed the start value for the ID_PLAY_BUTTON because the former value of 0 causes FindWindow() to return the toolbar rather than the button -- wxWidgets bug. Also got rid of some cruft and applied a few WXUNUSED.
This commit is contained in:
parent
019ec26ddf
commit
b8128af0c5
@ -497,6 +497,10 @@ AudacityProject *CreateNewAudacityProject()
|
|||||||
//Set the new project as active:
|
//Set the new project as active:
|
||||||
SetActiveProject(p);
|
SetActiveProject(p);
|
||||||
|
|
||||||
|
// Okay, GetActiveProject() is ready. Now we can get its CommandManager,
|
||||||
|
// and add the shortcut keys to the tooltips.
|
||||||
|
p->GetControlToolBar()->RegenerateToolsTooltips();
|
||||||
|
|
||||||
ModuleManager::Dispatch(ProjectInitialized);
|
ModuleManager::Dispatch(ProjectInitialized);
|
||||||
|
|
||||||
p->Show(true);
|
p->Show(true);
|
||||||
|
@ -1239,7 +1239,7 @@ void CommandManager::HandleXMLEndTag(const wxChar *tag)
|
|||||||
if (!wxStrcmp(tag, wxT("audacitykeyboard"))) {
|
if (!wxStrcmp(tag, wxT("audacitykeyboard"))) {
|
||||||
wxMessageBox(wxString::Format(_("Loaded %d keyboard shortcuts\n"),
|
wxMessageBox(wxString::Format(_("Loaded %d keyboard shortcuts\n"),
|
||||||
mXMLKeysRead),
|
mXMLKeysRead),
|
||||||
_("Loading keyboard shortcuts"),
|
_("Loading Keyboard Shortcuts"),
|
||||||
wxOK | wxCENTRE);
|
wxOK | wxCENTRE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,10 +183,10 @@ void ControlToolBar::Populate()
|
|||||||
ID_STOP_BUTTON, false, _("Stop"));
|
ID_STOP_BUTTON, false, _("Stop"));
|
||||||
|
|
||||||
mRewind = MakeButton(bmpRewind, bmpRewind, bmpRewindDisabled,
|
mRewind = MakeButton(bmpRewind, bmpRewind, bmpRewindDisabled,
|
||||||
ID_REW_BUTTON, false, _("Start"));
|
ID_REW_BUTTON, false, _("Skip to Start"));
|
||||||
|
|
||||||
mFF = MakeButton(bmpFFwd, bmpFFwd, bmpFFwdDisabled,
|
mFF = MakeButton(bmpFFwd, bmpFFwd, bmpFFwdDisabled,
|
||||||
ID_FF_BUTTON, false, _("End"));
|
ID_FF_BUTTON, false, _("Skip to End"));
|
||||||
|
|
||||||
mRecord = MakeButton(bmpRecord, bmpRecord, bmpRecordDisabled,
|
mRecord = MakeButton(bmpRecord, bmpRecord, bmpRecordDisabled,
|
||||||
ID_RECORD_BUTTON, true, _("Record"));
|
ID_RECORD_BUTTON, true, _("Record"));
|
||||||
@ -204,12 +204,42 @@ void ControlToolBar::Populate()
|
|||||||
void ControlToolBar::RegenerateToolsTooltips()
|
void ControlToolBar::RegenerateToolsTooltips()
|
||||||
{
|
{
|
||||||
#if wxUSE_TOOLTIPS
|
#if wxUSE_TOOLTIPS
|
||||||
mPause->SetToolTip(_("Pause"));
|
// ID_BATCH_BUTTON is not an actual button, so use it as loop bound.
|
||||||
mPlay->SetToolTip(_("Play (Shift for Loop Play)"));
|
for (long iWinID = ID_PLAY_BUTTON; iWinID < ID_BATCH_BUTTON; iWinID++)
|
||||||
mStop->SetToolTip(_("Stop"));
|
{
|
||||||
mRewind->SetToolTip(_("Skip to Start"));
|
wxWindow* pCtrl = this->FindWindow(iWinID);
|
||||||
mFF->SetToolTip(_("Skip to End"));
|
wxString strToolTip = pCtrl->GetLabel();
|
||||||
mRecord->SetToolTip(_("Record (Shift for Append Record)"));
|
AudacityProject* pProj = GetActiveProject();
|
||||||
|
CommandManager* pCmdMgr = (pProj) ? pProj->GetCommandManager() : NULL;
|
||||||
|
if (pCmdMgr)
|
||||||
|
{
|
||||||
|
wxString strKey(wxT(" ("));
|
||||||
|
switch (iWinID)
|
||||||
|
{
|
||||||
|
case ID_PLAY_BUTTON:
|
||||||
|
strKey += pCmdMgr->GetKeyFromName(strToolTip);
|
||||||
|
strKey += _(") / Loop Play (");
|
||||||
|
strKey += pCmdMgr->GetKeyFromName(wxT("PlayLooped"));
|
||||||
|
break;
|
||||||
|
case ID_RECORD_BUTTON:
|
||||||
|
strKey += pCmdMgr->GetKeyFromName(strToolTip);
|
||||||
|
strKey += _(") / Append Record (");
|
||||||
|
strKey += pCmdMgr->GetKeyFromName(wxT("RecordAppend"));
|
||||||
|
break;
|
||||||
|
case ID_FF_BUTTON:
|
||||||
|
strKey += pCmdMgr->GetKeyFromName(wxT("SkipEnd"));
|
||||||
|
break;
|
||||||
|
case ID_REW_BUTTON:
|
||||||
|
strKey += pCmdMgr->GetKeyFromName(wxT("SkipStart"));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
strKey += pCmdMgr->GetKeyFromName(strToolTip);
|
||||||
|
}
|
||||||
|
strKey += wxT(")");
|
||||||
|
strToolTip += strKey;
|
||||||
|
}
|
||||||
|
pCtrl->SetToolTip(strToolTip);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,7 +360,6 @@ void ControlToolBar::EnableDisableButtons()
|
|||||||
{
|
{
|
||||||
//TIDY-ME: Button logic could be neater.
|
//TIDY-ME: Button logic could be neater.
|
||||||
AudacityProject *p = GetActiveProject();
|
AudacityProject *p = GetActiveProject();
|
||||||
size_t numProjects = gAudacityProjects.Count();
|
|
||||||
bool tracks = false;
|
bool tracks = false;
|
||||||
bool playing = mPlay->IsDown();
|
bool playing = mPlay->IsDown();
|
||||||
bool recording = mRecord->IsDown();
|
bool recording = mRecord->IsDown();
|
||||||
@ -654,7 +683,7 @@ void ControlToolBar::OnKeyUp(wxKeyEvent & event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlToolBar::OnPlay(wxCommandEvent &evt)
|
void ControlToolBar::OnPlay(wxCommandEvent & WXUNUSED(evt))
|
||||||
{
|
{
|
||||||
StopPlaying();
|
StopPlaying();
|
||||||
|
|
||||||
@ -664,7 +693,7 @@ void ControlToolBar::OnPlay(wxCommandEvent &evt)
|
|||||||
PlayDefault();
|
PlayDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlToolBar::OnStop(wxCommandEvent &evt)
|
void ControlToolBar::OnStop(wxCommandEvent & WXUNUSED(evt))
|
||||||
{
|
{
|
||||||
StopPlaying();
|
StopPlaying();
|
||||||
}
|
}
|
||||||
@ -713,7 +742,7 @@ void ControlToolBar::StopPlaying(bool stopStream /* = true*/)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlToolBar::OnBatch(wxCommandEvent &evt)
|
void ControlToolBar::OnBatch(wxCommandEvent & WXUNUSED(evt))
|
||||||
{
|
{
|
||||||
AudacityProject *proj = GetActiveProject();
|
AudacityProject *proj = GetActiveProject();
|
||||||
if (proj)
|
if (proj)
|
||||||
@ -902,7 +931,7 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ControlToolBar::OnPause(wxCommandEvent &evt)
|
void ControlToolBar::OnPause(wxCommandEvent & WXUNUSED(evt))
|
||||||
{
|
{
|
||||||
if(mPaused)
|
if(mPaused)
|
||||||
{
|
{
|
||||||
@ -918,7 +947,7 @@ void ControlToolBar::OnPause(wxCommandEvent &evt)
|
|||||||
gAudioIO->SetPaused(mPaused);
|
gAudioIO->SetPaused(mPaused);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlToolBar::OnRewind(wxCommandEvent &evt)
|
void ControlToolBar::OnRewind(wxCommandEvent & WXUNUSED(evt))
|
||||||
{
|
{
|
||||||
mRewind->PushDown();
|
mRewind->PushDown();
|
||||||
mRewind->PopUp();
|
mRewind->PopUp();
|
||||||
@ -929,7 +958,7 @@ void ControlToolBar::OnRewind(wxCommandEvent &evt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlToolBar::OnFF(wxCommandEvent &evt)
|
void ControlToolBar::OnFF(wxCommandEvent & WXUNUSED(evt))
|
||||||
{
|
{
|
||||||
mFF->PushDown();
|
mFF->PushDown();
|
||||||
mFF->PopUp();
|
mFF->PopUp();
|
||||||
@ -941,8 +970,8 @@ void ControlToolBar::OnFF(wxCommandEvent &evt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlToolBar::SetupCutPreviewTracks(double playStart, double cutStart,
|
void ControlToolBar::SetupCutPreviewTracks(double WXUNUSED(playStart), double cutStart,
|
||||||
double cutEnd, double playEnd)
|
double cutEnd, double WXUNUSED(playEnd))
|
||||||
{
|
{
|
||||||
ClearCutPreviewTracks();
|
ClearCutPreviewTracks();
|
||||||
AudacityProject *p = GetActiveProject();
|
AudacityProject *p = GetActiveProject();
|
||||||
@ -989,13 +1018,3 @@ void ControlToolBar::ClearCutPreviewTracks()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Indentation settings for Vim and Emacs and unique identifier for Arch, a
|
|
||||||
// version control system. Please do not modify past this point.
|
|
||||||
//
|
|
||||||
// Local Variables:
|
|
||||||
// c-basic-offset: 3
|
|
||||||
// indent-tabs-mode: nil
|
|
||||||
// End:
|
|
||||||
//
|
|
||||||
// vim: et sts=3 sw=3
|
|
||||||
// arch-tag: ebfdc42a-6a03-4826-afa2-937a48c0565b
|
|
||||||
|
@ -81,6 +81,7 @@ class ControlToolBar:public ToolBar {
|
|||||||
void SetVUMeters(AudacityProject *p);
|
void SetVUMeters(AudacityProject *p);
|
||||||
|
|
||||||
virtual void ReCreateButtons();
|
virtual void ReCreateButtons();
|
||||||
|
void RegenerateToolsTooltips();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -90,22 +91,21 @@ class ControlToolBar:public ToolBar {
|
|||||||
const wxChar *label);
|
const wxChar *label);
|
||||||
void MakeLoopImage();
|
void MakeLoopImage();
|
||||||
void ArrangeButtons();
|
void ArrangeButtons();
|
||||||
void RegenerateToolsTooltips();
|
|
||||||
void SetupCutPreviewTracks(double playStart, double cutStart,
|
void SetupCutPreviewTracks(double playStart, double cutStart,
|
||||||
double cutEnd, double playEnd);
|
double cutEnd, double playEnd);
|
||||||
void ClearCutPreviewTracks();
|
void ClearCutPreviewTracks();
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
ID_PLAY_BUTTON,
|
ID_PLAY_BUTTON = 11000,
|
||||||
ID_RECORD_BUTTON,
|
ID_RECORD_BUTTON,
|
||||||
ID_PAUSE_BUTTON,
|
ID_PAUSE_BUTTON,
|
||||||
ID_STOP_BUTTON,
|
ID_STOP_BUTTON,
|
||||||
ID_FF_BUTTON,
|
ID_FF_BUTTON,
|
||||||
ID_REW_BUTTON,
|
ID_REW_BUTTON,
|
||||||
ID_BATCH_BUTTON,
|
|
||||||
|
|
||||||
BUTTON_COUNT
|
// ID_BATCH_BUTTON is not an actual button.
|
||||||
|
ID_BATCH_BUTTON,
|
||||||
};
|
};
|
||||||
|
|
||||||
AButton *mRewind;
|
AButton *mRewind;
|
||||||
@ -136,14 +136,3 @@ class ControlToolBar:public ToolBar {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Indentation settings for Vim and Emacs and unique identifier for Arch, a
|
|
||||||
// version control system. Please do not modify past this point.
|
|
||||||
//
|
|
||||||
// Local Variables:
|
|
||||||
// c-basic-offset: 3
|
|
||||||
// indent-tabs-mode: nil
|
|
||||||
// End:
|
|
||||||
//
|
|
||||||
// vim: et sts=3 sw=3
|
|
||||||
// arch-tag: bb2858b8-2c70-48df-9d72-bcdef94be4e3
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user