1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-12-09 06:06:24 +01:00

New scrubbing toolbar; remove ruler pushbuttons.

This commit is contained in:
Paul Licameli
2016-06-05 01:03:24 -04:00
parent 0e09f2ce04
commit f5c4c85653
10 changed files with 275 additions and 51 deletions

View File

@@ -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();
}

View File

@@ -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

View File

@@ -71,6 +71,7 @@ enum
MixerBarID,
EditBarID,
TranscriptionBarID,
ScrubbingBarID,
DeviceBarID,
SelectionBarID,
#ifdef EXPERIMENTAL_SPECTRAL_EDITING

View File

@@ -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 );