mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-02 16:49:41 +02:00
New scrubbing toolbar; remove ruler pushbuttons.
This commit is contained in:
commit
64ad076d14
@ -726,6 +726,7 @@ void AudacityProject::CreateMenusAndCommands()
|
||||
c->AddCheck(wxT("ShowTranscriptionTB"), _("Transcri&ption Toolbar"), FN(OnShowTranscriptionToolBar), 0, AlwaysEnabledFlag, AlwaysEnabledFlag);
|
||||
/* i18n-hint: Clicking this menu item shows the toolbar with the big buttons on it (play record etc)*/
|
||||
c->AddCheck(wxT("ShowTransportTB"), _("&Transport Toolbar"), FN(OnShowTransportToolBar), 0, AlwaysEnabledFlag, AlwaysEnabledFlag);
|
||||
c->AddCheck(wxT("ShowScrubbingTB"), _("Scrubbing Toolbar"), FN(OnShowScrubbingToolBar), 0, AlwaysEnabledFlag, AlwaysEnabledFlag);
|
||||
|
||||
c->AddSeparator();
|
||||
|
||||
@ -1807,6 +1808,8 @@ void AudacityProject::ModifyToolbarMenus()
|
||||
return;
|
||||
}
|
||||
|
||||
mCommandManager.Check(wxT("ShowScrubbingTB"),
|
||||
mToolManager->IsVisible(ScrubbingBarID));
|
||||
mCommandManager.Check(wxT("ShowDeviceTB"),
|
||||
mToolManager->IsVisible(DeviceBarID));
|
||||
mCommandManager.Check(wxT("ShowEditTB"),
|
||||
@ -5438,6 +5441,12 @@ void AudacityProject::OnShowMixerToolBar()
|
||||
ModifyToolbarMenus();
|
||||
}
|
||||
|
||||
void AudacityProject::OnShowScrubbingToolBar()
|
||||
{
|
||||
mToolManager->ShowHide( ScrubbingBarID );
|
||||
ModifyToolbarMenus();
|
||||
}
|
||||
|
||||
void AudacityProject::OnShowSelectionToolBar()
|
||||
{
|
||||
mToolManager->ShowHide( SelectionBarID );
|
||||
|
@ -305,6 +305,7 @@ void OnShowSelectionToolBar();
|
||||
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
|
||||
void OnShowSpectralSelectionToolBar();
|
||||
#endif
|
||||
void OnShowScrubbingToolBar();
|
||||
void OnShowToolsToolBar();
|
||||
void OnShowTranscriptionToolBar();
|
||||
void OnResetToolBars();
|
||||
|
@ -452,6 +452,10 @@ bool ScreenshotCommand::Apply(CommandExecutionContext context)
|
||||
{
|
||||
CaptureToolbar(context.GetProject()->GetToolManager(), TranscriptionBarID, fileName);
|
||||
}
|
||||
else if (captureMode.IsSameAs(wxT("scrubbing")))
|
||||
{
|
||||
CaptureToolbar(context.GetProject()->GetToolManager(), ScrubbingBarID, fileName);
|
||||
}
|
||||
else if (captureMode.IsSameAs(wxT("trackpanel")))
|
||||
{
|
||||
TrackPanel *panel = context.GetProject()->GetTrackPanel();
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**********************************************************************
|
||||
/**********************************************************************
|
||||
|
||||
Audacity: A Digital Audio Editor
|
||||
|
||||
@ -330,3 +330,188 @@ void EditToolBar::EnableDisableButtons()
|
||||
mButtons[ETBSyncLockID]->PopUp();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// PRL: to do: move the below to its own file
|
||||
// Much of this is imitative of EditToolBar. Should there be a common base
|
||||
// class?
|
||||
#include "../Audacity.h"
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include <wx/wxprec.h>
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <wx/event.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/intl.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/tooltip.h>
|
||||
#endif
|
||||
|
||||
#include "../AllThemeResources.h"
|
||||
#include "../AudioIO.h"
|
||||
#include "../ImageManipulation.h"
|
||||
#include "../Internat.h"
|
||||
#include "../Prefs.h"
|
||||
#include "../Project.h"
|
||||
#include "../Theme.h"
|
||||
#include "../Track.h"
|
||||
#include "../UndoManager.h"
|
||||
#include "../widgets/AButton.h"
|
||||
#include "../tracks/ui/Scrubbing.h"
|
||||
|
||||
#include "../Experimental.h"
|
||||
|
||||
IMPLEMENT_CLASS(ScrubbingToolBar, ToolBar);
|
||||
|
||||
//const int BUTTON_WIDTH = 27;
|
||||
//const int SEPARATOR_WIDTH = 14;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Methods for ScrubbingToolBar
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
BEGIN_EVENT_TABLE( ScrubbingToolBar, ToolBar )
|
||||
EVT_COMMAND_RANGE( STBStartID,
|
||||
STBStartID + STBNumButtons - 1,
|
||||
wxEVT_COMMAND_BUTTON_CLICKED,
|
||||
ScrubbingToolBar::OnButton )
|
||||
END_EVENT_TABLE()
|
||||
|
||||
//Standard contructor
|
||||
ScrubbingToolBar::ScrubbingToolBar()
|
||||
: ToolBar(ScrubbingBarID, _("Scrub"), wxT("Scrub"))
|
||||
{
|
||||
}
|
||||
|
||||
ScrubbingToolBar::~ScrubbingToolBar()
|
||||
{
|
||||
}
|
||||
|
||||
void ScrubbingToolBar::Create(wxWindow * parent)
|
||||
{
|
||||
ToolBar::Create(parent);
|
||||
}
|
||||
|
||||
/// This is a convenience function that allows for button creation in
|
||||
/// MakeButtons() with fewer arguments
|
||||
/// Very similar to code in ControlToolBar...
|
||||
AButton *ScrubbingToolBar::AddButton
|
||||
(teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled,
|
||||
int id,
|
||||
const wxChar *label,
|
||||
bool toggle)
|
||||
{
|
||||
AButton *&r = mButtons[id];
|
||||
|
||||
r = ToolBar::MakeButton
|
||||
(this,
|
||||
bmpRecoloredUpSmall, bmpRecoloredDownSmall, bmpRecoloredHiliteSmall,
|
||||
eEnabledUp, eEnabledDown, eDisabled,
|
||||
wxWindowID(id),
|
||||
wxDefaultPosition,
|
||||
toggle,
|
||||
theTheme.ImageSize( bmpRecoloredUpSmall ));
|
||||
|
||||
r->SetLabel(label);
|
||||
// JKC: Unlike ControlToolBar, does not have a focus rect. Shouldn't it?
|
||||
// r->SetFocusRect( r->GetRect().Deflate( 4, 4 ) );
|
||||
|
||||
Add( r, 0, wxALIGN_CENTER );
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
void ScrubbingToolBar::Populate()
|
||||
{
|
||||
MakeButtonBackgroundsSmall();
|
||||
|
||||
/* Buttons */
|
||||
AddButton(bmpPlay, bmpPlay, bmpPlayDisabled, STBStartID,
|
||||
_("Start scrubbing"), false);
|
||||
AddButton(bmpScrub, bmpScrub, bmpScrubDisabled, STBScrubID,
|
||||
_("Scrub"), true);
|
||||
AddButton(bmpSeek, bmpSeek, bmpSeekDisabled, STBSeekID,
|
||||
_("Seek"), true);
|
||||
|
||||
|
||||
RegenerateTooltips();
|
||||
}
|
||||
|
||||
void ScrubbingToolBar::UpdatePrefs()
|
||||
{
|
||||
RegenerateTooltips();
|
||||
|
||||
// Set label to pull in language change
|
||||
SetLabel(_("Scrubbing"));
|
||||
|
||||
// Give base class a chance
|
||||
ToolBar::UpdatePrefs();
|
||||
}
|
||||
|
||||
void ScrubbingToolBar::RegenerateTooltips()
|
||||
{
|
||||
#if wxUSE_TOOLTIPS
|
||||
/* i18n-hint: These commands assist the user in finding a sound by ear. ...
|
||||
"Scrubbing" is variable-speed playback, ...
|
||||
"Seeking" is normal speed playback but with skips
|
||||
*/
|
||||
mButtons[STBStartID]->SetToolTip(_("Start scrubbing or seeking"));
|
||||
mButtons[STBScrubID]->SetToolTip(_("Scrub"));
|
||||
mButtons[STBSeekID]->SetToolTip(_("Seek"));
|
||||
#endif
|
||||
}
|
||||
|
||||
void ScrubbingToolBar::OnButton(wxCommandEvent &event)
|
||||
{
|
||||
AudacityProject *p = GetActiveProject();
|
||||
if (!p) return;
|
||||
auto &scrubber = p->GetScrubber();
|
||||
|
||||
int id = event.GetId();
|
||||
|
||||
switch (id) {
|
||||
case STBStartID:
|
||||
mButtons[STBStartID]->PopUp();
|
||||
scrubber.OnStart(event);
|
||||
break;
|
||||
case STBScrubID:
|
||||
scrubber.OnScrub(event);
|
||||
break;
|
||||
case STBSeekID:
|
||||
scrubber.OnSeek(event);
|
||||
break;
|
||||
default:
|
||||
wxASSERT(false);
|
||||
}
|
||||
|
||||
EnableDisableButtons();
|
||||
}
|
||||
|
||||
void ScrubbingToolBar::EnableDisableButtons()
|
||||
{
|
||||
const auto scrubButton = mButtons[STBScrubID];
|
||||
scrubButton->SetEnabled(true);
|
||||
const auto seekButton = mButtons[STBSeekID];
|
||||
seekButton->SetEnabled(true);
|
||||
|
||||
AudacityProject *p = GetActiveProject();
|
||||
if (!p) return;
|
||||
|
||||
auto &scrubber = p->GetScrubber();
|
||||
if (scrubber.Scrubs())
|
||||
scrubButton->PushDown();
|
||||
else
|
||||
scrubButton->PopUp();
|
||||
|
||||
if (scrubber.Seeks())
|
||||
seekButton->PushDown();
|
||||
else
|
||||
seekButton->PopUp();
|
||||
|
||||
const auto startButton = mButtons[STBStartID];
|
||||
if (scrubber.CanScrub())
|
||||
startButton->Enable();
|
||||
else
|
||||
startButton->Disable();
|
||||
}
|
||||
|
@ -97,5 +97,66 @@ class EditToolBar final : public ToolBar {
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
// PRL: to do: move this to its own file
|
||||
|
||||
#include <wx/defs.h>
|
||||
|
||||
#include "ToolBar.h"
|
||||
#include "../Theme.h"
|
||||
#include "../Experimental.h"
|
||||
|
||||
class wxCommandEvent;
|
||||
class wxDC;
|
||||
class wxImage;
|
||||
class wxWindow;
|
||||
|
||||
class AButton;
|
||||
|
||||
enum {
|
||||
STBStartID,
|
||||
STBScrubID,
|
||||
STBSeekID,
|
||||
|
||||
STBNumButtons
|
||||
};
|
||||
|
||||
class ScrubbingToolBar final : public ToolBar {
|
||||
|
||||
public:
|
||||
|
||||
ScrubbingToolBar();
|
||||
virtual ~ScrubbingToolBar();
|
||||
|
||||
void Create(wxWindow *parent);
|
||||
|
||||
void OnButton(wxCommandEvent & event);
|
||||
|
||||
void Populate();
|
||||
void Repaint(wxDC * WXUNUSED(dc)) {};
|
||||
void EnableDisableButtons();
|
||||
void UpdatePrefs();
|
||||
|
||||
private:
|
||||
|
||||
AButton *AddButton(teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled,
|
||||
int id, const wxChar *label, bool toggle = false);
|
||||
|
||||
void MakeButtons();
|
||||
|
||||
void RegenerateTooltips();
|
||||
|
||||
AButton *mButtons[STBNumButtons];
|
||||
|
||||
wxImage *upImage;
|
||||
wxImage *downImage;
|
||||
wxImage *hiliteImage;
|
||||
|
||||
public:
|
||||
|
||||
DECLARE_CLASS(EditToolBar);
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -71,6 +71,7 @@ enum
|
||||
MixerBarID,
|
||||
EditBarID,
|
||||
TranscriptionBarID,
|
||||
ScrubbingBarID,
|
||||
DeviceBarID,
|
||||
SelectionBarID,
|
||||
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
|
||||
|
@ -448,6 +448,7 @@ ToolManager::ToolManager( AudacityProject *parent )
|
||||
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
|
||||
mBars[SpectralSelectionBarID] = new SpectralSelectionBar();
|
||||
#endif
|
||||
mBars[ ScrubbingBarID ] = new ScrubbingToolBar();
|
||||
|
||||
// We own the timer
|
||||
mTimer.SetOwner( this );
|
||||
|
@ -854,18 +854,23 @@ bool Scrubber::CanScrub() const
|
||||
void Scrubber::AddMenuItems()
|
||||
{
|
||||
auto cm = mProject->GetCommandManager();
|
||||
auto flags = cm->GetDefaultFlags() | WaveTracksExistFlag;
|
||||
auto mask = cm->GetDefaultMask() | WaveTracksExistFlag;
|
||||
auto flag = WaveTracksExistFlag;
|
||||
auto flags = cm->GetDefaultFlags() | flag;
|
||||
auto mask = cm->GetDefaultMask() | flag;
|
||||
|
||||
cm->BeginSubMenu(_("Scru&bbing"));
|
||||
for (const auto &item : menuItems) {
|
||||
if (!item.GetStatus().empty())
|
||||
cm->AddCheck(item.name, wxGetTranslation(item.label),
|
||||
FNT(Scrubber, this, item.memFn),
|
||||
false, flags, mask);
|
||||
false,
|
||||
// Less restricted:
|
||||
AlwaysEnabledFlag, AlwaysEnabledFlag);
|
||||
else
|
||||
// The start item
|
||||
cm->AddItem(item.name, wxGetTranslation(item.label),
|
||||
FNT(Scrubber, this, item.memFn),
|
||||
// More restricted:
|
||||
flags, mask);
|
||||
}
|
||||
cm->EndSubMenu();
|
||||
|
@ -1920,8 +1920,6 @@ enum {
|
||||
OnLockPlayRegionID,
|
||||
|
||||
OnTogglePinnedStateID,
|
||||
OnScrubID,
|
||||
OnSeekID,
|
||||
};
|
||||
|
||||
BEGIN_EVENT_TABLE(AdornedRulerPanel, OverlayPanel)
|
||||
@ -1943,12 +1941,6 @@ BEGIN_EVENT_TABLE(AdornedRulerPanel, OverlayPanel)
|
||||
EVT_COMMAND( OnTogglePinnedStateID,
|
||||
wxEVT_COMMAND_BUTTON_CLICKED,
|
||||
AdornedRulerPanel::OnTogglePinnedState )
|
||||
EVT_COMMAND( OnScrubID,
|
||||
wxEVT_COMMAND_BUTTON_CLICKED,
|
||||
AdornedRulerPanel::OnScrub )
|
||||
EVT_COMMAND( OnSeekID,
|
||||
wxEVT_COMMAND_BUTTON_CLICKED,
|
||||
AdornedRulerPanel::OnSeek )
|
||||
|
||||
END_EVENT_TABLE()
|
||||
|
||||
@ -2117,8 +2109,6 @@ void AdornedRulerPanel::ReCreateButtons()
|
||||
bmpRecoloredUpSmall, bmpRecoloredDownSmall, bmpRecoloredHiliteSmall,
|
||||
bmpUnpinnedPlayRecordHead, bmpUnpinnedPlayRecordHead, bmpUnpinnedPlayRecordHead,
|
||||
size);
|
||||
buttonMaker(OnScrubID, bmpScrub, true);
|
||||
buttonMaker(OnSeekID, bmpSeek, true);
|
||||
|
||||
UpdateButtonStates();
|
||||
}
|
||||
@ -2180,7 +2170,10 @@ void AdornedRulerPanel::RegenerateTooltips(StatusChoice choice)
|
||||
}
|
||||
break;
|
||||
case StatusChoice::EnteringScrubZone :
|
||||
this->SetToolTip(ScrubbingMessage(mProject->GetScrubber()));
|
||||
{
|
||||
const auto message = ScrubbingMessage(mProject->GetScrubber());
|
||||
this->SetToolTip(message);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
this->SetToolTip(NULL);
|
||||
@ -2825,30 +2818,6 @@ void AdornedRulerPanel::UpdateButtonStates()
|
||||
|
||||
auto &scrubber = mProject->GetScrubber();
|
||||
|
||||
{
|
||||
const auto scrubButton = static_cast<AButton*>(FindWindow(OnScrubID));
|
||||
/* i18n-hint: These commands assist the user in finding a sound by ear. ...
|
||||
"Scrubbing" is variable-speed playback
|
||||
*/
|
||||
common(scrubButton, wxT("Scrub"), _("Scrub"));
|
||||
if (scrubber.Scrubs())
|
||||
scrubButton->PushDown();
|
||||
else
|
||||
scrubButton->PopUp();
|
||||
}
|
||||
|
||||
{
|
||||
const auto seekButton = static_cast<AButton*>(FindWindow(OnSeekID));
|
||||
/* i18n-hint: These commands assist the user in finding a sound by ear. ...
|
||||
"Seeking" is normal speed playback but with skips
|
||||
*/
|
||||
common(seekButton, wxT("Seek"), _("Seek"));
|
||||
if (scrubber.Seeks())
|
||||
seekButton->PushDown();
|
||||
else
|
||||
seekButton->PopUp();
|
||||
}
|
||||
|
||||
if(mShowScrubbing != (scrubber.Scrubs() || scrubber.Seeks()))
|
||||
OnToggleScrubbing();
|
||||
}
|
||||
@ -2859,16 +2828,6 @@ void AdornedRulerPanel::OnTogglePinnedState(wxCommandEvent & event)
|
||||
UpdateButtonStates();
|
||||
}
|
||||
|
||||
void AdornedRulerPanel::OnSeek(wxCommandEvent & event)
|
||||
{
|
||||
mProject->GetScrubber().OnSeek(event);
|
||||
}
|
||||
|
||||
void AdornedRulerPanel::OnScrub(wxCommandEvent & event)
|
||||
{
|
||||
mProject->GetScrubber().OnScrub(event);
|
||||
}
|
||||
|
||||
void AdornedRulerPanel::OnCaptureLost(wxMouseCaptureLostEvent & WXUNUSED(evt))
|
||||
{
|
||||
HideQuickPlayIndicator();
|
||||
|
@ -414,8 +414,6 @@ private:
|
||||
void OnLockPlayRegion(wxCommandEvent &evt);
|
||||
|
||||
void OnToggleScrubbing(/*wxCommandEvent&*/);
|
||||
void OnScrub(wxCommandEvent&);
|
||||
void OnSeek(wxCommandEvent&);
|
||||
|
||||
void OnContextMenu(wxContextMenuEvent & WXUNUSED(event));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user