Audacity  2.2.2
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
ScrubbingToolBar Class Referencefinal

#include <ScrubbingToolBar.h>

Inheritance diagram for ScrubbingToolBar:
ToolBar wxPanelWrapper wxTabTraversalWrapper< wxPanel >

Public Member Functions

 ScrubbingToolBar ()
 
virtual ~ScrubbingToolBar ()
 
void Create (wxWindow *parent) override
 
void OnButton (wxCommandEvent &event)
 
void Populate () override
 
void Repaint (wxDC *WXUNUSED(dc)) override
 
void EnableDisableButtons () override
 
void UpdatePrefs () override
 
void RegenerateTooltips () override
 
- Public Member Functions inherited from ToolBar
 ToolBar (int type, const wxString &label, const wxString &section, bool resizable=false)
 
virtual ~ToolBar ()
 
bool AcceptsFocus () const override
 
virtual void ReCreateButtons ()
 
int GetType ()
 
wxString GetTitle ()
 
wxString GetLabel ()
 
wxString GetSection ()
 
ToolDockGetDock ()
 
void SetLabel (const wxString &label) override
 
void SetDocked (ToolDock *dock, bool pushed)
 
virtual bool Expose (bool show=true)
 
bool IsResizable () const
 
bool IsVisible () const
 
bool IsDocked () const
 
bool IsPositioned ()
 
void SetVisible (bool bVisible)
 
void SetPositioned ()
 
virtual int GetInitialWidth ()
 Resizable toolbars should implement these. More...
 
virtual int GetMinToolbarWidth ()
 
virtual wxSize GetDockedSize ()
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const wxString &name=_("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const wxString &name=_("Panel"))
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&...args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Private Member Functions

void MakeButtons ()
 

Static Private Member Functions

static AButtonAddButton (ScrubbingToolBar *pBar, teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, int id, const wxChar *label, bool toggle=false)
 

Private Attributes

AButtonmButtons [STBNumButtons]
 
wxImage * upImage
 
wxImage * downImage
 
wxImage * hiliteImage
 

Additional Inherited Members

- Public Types inherited from ToolBar
using Holder = Destroy_ptr< ToolBar >
 
- Static Public Member Functions inherited from ToolBar
static AButtonMakeButton (wxWindow *parent, teBmps eUp, teBmps eDown, teBmps eHilite, teBmps eDownHi, teBmps eStandardUp, teBmps eStandardDown, teBmps eDisabled, wxWindowID id, wxPoint placement, bool processdownevents, wxSize size)
 
static void MakeAlternateImages (AButton &button, int idx, teBmps eUp, teBmps eDown, teBmps eHilite, teBmps eDownHi, teBmps eStandardUp, teBmps eStandardDown, teBmps eDisabled, wxSize size)
 
static void SetButtonToolTip (AButton &button, const TranslatedInternalString commands[], size_t nCommands)
 
- Protected Member Functions inherited from ToolBar
void SetButton (bool down, AButton *button)
 
void MakeMacRecoloredImage (teBmps eBmpOut, teBmps eBmpIn)
 
void MakeRecoloredImage (teBmps eBmpOut, teBmps eBmpIn)
 
void MakeButtonBackgroundsLarge ()
 
void MakeButtonBackgroundsSmall ()
 
wxBoxSizer * GetSizer ()
 
void Add (wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
 
void Add (wxSizer *sizer, int proportion=0, int flag=0, int border=0, wxObject *userData=NULL)
 
void Add (int width, int height, int proportion=0, int flag=0, int border=0, wxObject *userData=NULL)
 
void AddSpacer (int size=14)
 
void AddStretchSpacer (int prop=1)
 
void Detach (wxWindow *window)
 
void Detach (wxSizer *sizer)
 
void Updated ()
 
int GetResizeGrabberWidth ()
 Returns the width in pixels of the resizer element. More...
 
virtual void Repaint (wxDC *dc)=0
 
void OnErase (wxEraseEvent &event)
 
void OnPaint (wxPaintEvent &event)
 
void OnMouseEvents (wxMouseEvent &event)
 
- Protected Attributes inherited from ToolBar
wxString mLabel
 
wxString mSection
 
int mType
 

Detailed Description

Definition at line 39 of file ScrubbingToolBar.h.

Constructor & Destructor Documentation

ScrubbingToolBar::ScrubbingToolBar ( )
ScrubbingToolBar::~ScrubbingToolBar ( )
virtual

Definition at line 67 of file ScrubbingToolBar.cpp.

68 {
69 }

Member Function Documentation

AButton * ScrubbingToolBar::AddButton ( ScrubbingToolBar pBar,
teBmps  eEnabledUp,
teBmps  eEnabledDown,
teBmps  eDisabled,
int  id,
const wxChar *  label,
bool  toggle = false 
)
staticprivate

This is a convenience function that allows for button creation in MakeButtons() with fewer arguments Very similar to code in ControlToolBar...

Definition at line 80 of file ScrubbingToolBar.cpp.

References ToolBar::Add(), ThemeBase::ImageSize(), ToolBar::MakeButton(), mButtons, and theTheme.

Referenced by Populate().

85 {
86  AButton *&r = pBar->mButtons[id];
87 
89  (pBar,
90  bmpRecoloredUpSmall, bmpRecoloredDownSmall, bmpRecoloredUpHiliteSmall, bmpRecoloredHiliteSmall,
91  eEnabledUp, eEnabledDown, eDisabled,
92  wxWindowID(id),
93  wxDefaultPosition,
94  toggle,
95  theTheme.ImageSize( bmpRecoloredUpSmall ));
96 
97  r->SetLabel(label);
98  // JKC: Unlike ControlToolBar, does not have a focus rect. Shouldn't it?
99  // r->SetFocusRect( r->GetRect().Deflate( 4, 4 ) );
100 
101  pBar->Add( r, 0, wxALIGN_CENTER );
102 
103  return r;
104 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
wxString label
Definition: Tags.cpp:733
AButton * mButtons[STBNumButtons]
wxSize ImageSize(int iIndex)
Definition: Theme.cpp:1257
static AButton * MakeButton(wxWindow *parent, teBmps eUp, teBmps eDown, teBmps eHilite, teBmps eDownHi, teBmps eStandardUp, teBmps eStandardDown, teBmps eDisabled, wxWindowID id, wxPoint placement, bool processdownevents, wxSize size)
Definition: ToolBar.cpp:769
void Add(wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
Definition: ToolBar.cpp:615
A wxButton with mouse-over behaviour.
Definition: AButton.h:28
void ScrubbingToolBar::Create ( wxWindow *  parent)
overridevirtual

Reimplemented from ToolBar.

Definition at line 71 of file ScrubbingToolBar.cpp.

References ToolBar::Create().

72 {
73  ToolBar::Create(parent);
74 }
virtual void Create(wxWindow *parent)
Definition: ToolBar.cpp:442
void ScrubbingToolBar::EnableDisableButtons ( )
overridevirtual

Implements ToolBar.

Definition at line 210 of file ScrubbingToolBar.cpp.

References Scrubber::CanScrub(), AButton::Enable(), GetActiveProject(), AudacityProject::GetRulerPanel(), AudacityProject::GetScrubber(), mButtons, RegenerateTooltips(), AButton::SetEnabled(), AdornedRulerPanel::ShowingScrubRuler(), STBRulerID, STBScrubID, and STBSeekID.

Referenced by OnButton(), and Scrubber::OnScrubOrSeek().

211 {
212  const auto scrubButton = mButtons[STBScrubID];
213  scrubButton->SetEnabled(true);
214  const auto seekButton = mButtons[STBSeekID];
215  seekButton->SetEnabled(true);
216 
218  if (!p) return;
219 
220  auto &scrubber = p->GetScrubber();
221  const auto canScrub = scrubber.CanScrub();
222 
223  if (scrubber.Scrubs()) {
224  scrubButton->PushDown();
225  scrubButton->Enable();
226  }
227  else {
228  scrubButton->PopUp();
229  if (canScrub)
230  scrubButton->Enable();
231  else
232  scrubButton->Disable();
233  }
234 
235  if (scrubber.Seeks()) {
236  seekButton->PushDown();
237  seekButton->Enable();
238  }
239  else {
240  seekButton->PopUp();
241  if (canScrub)
242  seekButton->Enable();
243  else
244  seekButton->Disable();
245  }
246 
247  const auto barButton = mButtons[STBRulerID];
248  barButton->Enable();
249  if (p->GetRulerPanel()->ShowingScrubRuler())
250  barButton->PushDown();
251  else
252  barButton->PopUp();
254  scrubber.CheckMenuItems();
255 }
bool ShowingScrubRuler() const
Definition: Ruler.h:365
Scrubber & GetScrubber()
Definition: Project.h:801
AButton * mButtons[STBNumButtons]
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
AdornedRulerPanel * GetRulerPanel()
Definition: Project.cpp:1439
void SetEnabled(bool state)
Definition: AButton.h:98
void RegenerateTooltips() override
bool CanScrub() const
Definition: Scrubbing.cpp:986
void Enable()
Definition: AButton.cpp:495
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
void ScrubbingToolBar::MakeButtons ( )
private
void ScrubbingToolBar::OnButton ( wxCommandEvent &  event)

Definition at line 185 of file ScrubbingToolBar.cpp.

References EnableDisableButtons(), GetActiveProject(), AudacityProject::GetScrubber(), STBRulerID, STBScrubID, and STBSeekID.

186 {
188  if (!p) return;
189  auto &scrubber = p->GetScrubber();
190 
191  int id = event.GetId();
192 
193  switch (id) {
194  case STBScrubID:
195  scrubber.OnScrub(*p);
196  break;
197  case STBSeekID:
198  scrubber.OnSeek(*p);
199  break;
200  case STBRulerID:
201  scrubber.OnToggleScrubRuler(*p);
202  break;
203  default:
204  wxASSERT(false);
205  }
206 
208 }
Scrubber & GetScrubber()
Definition: Project.h:801
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
void EnableDisableButtons() override
void ScrubbingToolBar::Populate ( )
overridevirtual

Implements ToolBar.

Definition at line 106 of file ScrubbingToolBar.cpp.

References _(), AddButton(), ThemeBase::Colour(), ToolBar::MakeButtonBackgroundsSmall(), RegenerateTooltips(), STBRulerID, STBScrubID, STBSeekID, and theTheme.

107 {
108  SetBackgroundColour( theTheme.Colour( clrMedium ) );
110 
111  /* Buttons */
112  AddButton(this, bmpScrub, bmpScrub, bmpScrubDisabled, STBScrubID,
113  _("Scrub"), true);
114  AddButton(this, bmpSeek, bmpSeek, bmpSeekDisabled, STBSeekID,
115  _("Seek"), true);
116  AddButton(this, bmpToggleScrubRuler, bmpToggleScrubRuler, bmpToggleScrubRuler,
117  STBRulerID,
118  _("Scrub Ruler"), true);
119 
120 
122 }
void MakeButtonBackgroundsSmall()
Definition: ToolBar.cpp:731
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
void RegenerateTooltips() override
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
static AButton * AddButton(ScrubbingToolBar *pBar, teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, int id, const wxChar *label, bool toggle=false)
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1225
void ScrubbingToolBar::RegenerateTooltips ( )
overridevirtual

Implements ToolBar.

Definition at line 135 of file ScrubbingToolBar.cpp.

References _(), GetActiveProject(), label, mButtons, ToolBar::SetButtonToolTip(), STBRulerID, STBScrubID, and STBSeekID.

Referenced by EnableDisableButtons(), Populate(), and UpdatePrefs().

136 {
137 #if wxUSE_TOOLTIPS
138  auto fn = [&]
139  (AButton &button, const wxString &label, const wxString &cmd)
140  {
141  TranslatedInternalString command{ cmd, label };
142  ToolBar::SetButtonToolTip( button, &command, 1u );
143  };
144 
145  auto project = GetActiveProject();
146  if (project) {
147  auto &scrubber = project->GetScrubber();
148 
149  const auto scrubButton = mButtons[STBScrubID];
150  const auto seekButton = mButtons[STBSeekID];
151 
152  wxString label;
153  label = (
154  scrubber.Scrubs()
155  /* i18n-hint: These commands assist the user in finding a sound by ear. ...
156  "Scrubbing" is variable-speed playback, ...
157  "Seeking" is normal speed playback but with skips
158  */
159  ? _("Stop Scrubbing")
160  : _("Start Scrubbing")
161  );
162  fn(*scrubButton, label, wxT("Scrub"));
163 
164  label = (
165  scrubber.Seeks()
166  /* i18n-hint: These commands assist the user in finding a sound by ear. ...
167  "Scrubbing" is variable-speed playback, ...
168  "Seeking" is normal speed playback but with skips
169  */
170  ? _("Stop Seeking")
171  : _("Start Seeking")
172  );
173  fn(*seekButton, label, wxT("Seek"));
174 
175  label = (
176  project->GetRulerPanel()->ShowingScrubRuler()
177  ? _("Hide Scrub Ruler")
178  : _("Show Scrub Ruler")
179  );
180  fn(*mButtons[STBRulerID], label, wxT("ToggleScrubRuler"));
181  }
182 #endif
183 }
wxString label
Definition: Tags.cpp:733
AButton * mButtons[STBNumButtons]
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
static void SetButtonToolTip(AButton &button, const TranslatedInternalString commands[], size_t nCommands)
Definition: ToolBar.cpp:827
A wxButton with mouse-over behaviour.
Definition: AButton.h:28
void ScrubbingToolBar::Repaint ( wxDC *  WXUNUSEDdc)
inlineoverride

Definition at line 51 of file ScrubbingToolBar.h.

51 {};
void ScrubbingToolBar::UpdatePrefs ( )
overridevirtual

Reimplemented from ToolBar.

Definition at line 124 of file ScrubbingToolBar.cpp.

References _(), RegenerateTooltips(), ToolBar::SetLabel(), and ToolBar::UpdatePrefs().

125 {
127 
128  // Set label to pull in language change
129  SetLabel(_("Scrubbing"));
130 
131  // Give base class a chance
133 }
virtual void UpdatePrefs()
Definition: ToolBar.cpp:539
void SetLabel(const wxString &label) override
Definition: ToolBar.cpp:378
void RegenerateTooltips() override
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand

Member Data Documentation

wxImage* ScrubbingToolBar::downImage
private

Definition at line 69 of file ScrubbingToolBar.h.

wxImage* ScrubbingToolBar::hiliteImage
private

Definition at line 70 of file ScrubbingToolBar.h.

AButton* ScrubbingToolBar::mButtons[STBNumButtons]
private

Definition at line 66 of file ScrubbingToolBar.h.

Referenced by AddButton(), EnableDisableButtons(), and RegenerateTooltips().

wxImage* ScrubbingToolBar::upImage
private

Definition at line 68 of file ScrubbingToolBar.h.


The documentation for this class was generated from the following files: