Audacity 3.2.0
Public Member Functions | Static 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:
[legend]
Collaboration diagram for ScrubbingToolBar:
[legend]

Public Member Functions

 ScrubbingToolBar (AudacityProject &project)
 
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 (AudacityProject &project, int type, const TranslatableString &label, const wxString &section, bool resizable=false)
 
virtual ~ToolBar ()
 
bool AcceptsFocus () const override
 
virtual void SetToDefaultSize ()
 
virtual void Create (wxWindow *parent)
 
virtual void EnableDisableButtons ()=0
 
virtual void ReCreateButtons ()
 
void UpdatePrefs () override
 
virtual void RegenerateTooltips ()=0
 
int GetType ()
 
TranslatableString GetTitle ()
 
TranslatableString GetLabel ()
 
wxString GetSection ()
 
ToolDockGetDock ()
 
void SetLabel (const TranslatableString &label)
 
virtual 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 ()
 
wxSize GetSmartDockedSize ()
 
virtual void ResizingDone ()
 
- 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 TranslatableString &name=XO("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
void SetLabel (const TranslatableString &label)
 
void SetName (const TranslatableString &name)
 
void SetToolTip (const TranslatableString &toolTip)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Static Public Member Functions

static ScrubbingToolBarGet (AudacityProject &project)
 
static const ScrubbingToolBarGet (const AudacityProject &project)
 
- 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 AButtonMakeButton (ToolBar *parent, teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, int id, bool processdownevents, const TranslatableString &label)
 
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 (AudacityProject &project, AButton &button, const ComponentInterfaceSymbol commands[], size_t nCommands)
 
static void MakeButtonBackgroundsSmall ()
 
static void MakeButtonBackgroundsLarge ()
 

Private Member Functions

void MakeButtons ()
 
void OnIdle (wxIdleEvent &evt)
 
void DoRegenerateTooltips (bool force)
 

Static Private Member Functions

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

Private Attributes

AButtonmButtons [STBNumButtons]
 
wxImage * upImage
 
wxImage * downImage
 
wxImage * hiliteImage
 
bool mLastScrub { false }
 
bool mLastSeek { false }
 
bool mLastRuler { false }
 

Additional Inherited Members

- Public Types inherited from ToolBar
using Holder = wxWindowPtr< ToolBar >
 
- Protected Member Functions inherited from ToolBar
void SetButton (bool down, AButton *button)
 
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 Populate ()=0
 
virtual void Repaint (wxDC *dc)=0
 
void OnErase (wxEraseEvent &event)
 
void OnPaint (wxPaintEvent &event)
 
void OnMouseEvents (wxMouseEvent &event)
 
- Protected Member Functions inherited from PrefsListener
virtual void UpdateSelectedPrefs (int id)
 
 PrefsListener ()
 
virtual ~PrefsListener ()
 
virtual void UpdatePrefs ()=0
 
- Static Protected Member Functions inherited from ToolBar
static void MakeMacRecoloredImage (teBmps eBmpOut, teBmps eBmpIn)
 
static void MakeMacRecoloredImageSize (teBmps eBmpOut, teBmps eBmpIn, const wxSize &size)
 
static void MakeRecoloredImage (teBmps eBmpOut, teBmps eBmpIn)
 
static void MakeRecoloredImageSize (teBmps eBmpOut, teBmps eBmpIn, const wxSize &size)
 
- Static Protected Member Functions inherited from PrefsListener
static void Broadcast (int id=0)
 Call this static function to notify all PrefsListener objects. More...
 
- Protected Attributes inherited from ToolBar
AudacityProjectmProject
 
TranslatableString mLabel
 
wxString mSection
 
int mType
 

Detailed Description

Definition at line 39 of file ScrubbingToolBar.h.

Constructor & Destructor Documentation

◆ ScrubbingToolBar()

ScrubbingToolBar::ScrubbingToolBar ( AudacityProject project)

◆ ~ScrubbingToolBar()

ScrubbingToolBar::~ScrubbingToolBar ( )
virtual

Definition at line 61 of file ScrubbingToolBar.cpp.

62{
63}

Member Function Documentation

◆ AddButton()

AButton * ScrubbingToolBar::AddButton ( ScrubbingToolBar pBar,
teBmps  eEnabledUp,
teBmps  eEnabledDown,
teBmps  eDisabled,
int  id,
const TranslatableString 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 85 of file ScrubbingToolBar.cpp.

91{
92 AButton *&r = pBar->mButtons[id];
93
95 (pBar,
96 bmpRecoloredUpSmall, bmpRecoloredDownSmall, bmpRecoloredUpHiliteSmall, bmpRecoloredHiliteSmall,
97 eEnabledUp, eEnabledDown, eDisabled,
98 wxWindowID(id),
99 wxDefaultPosition,
100 toggle,
101 theTheme.ImageSize( bmpRecoloredUpSmall ));
102
103 r->SetLabel(label);
104 // JKC: Unlike ControlToolBar, does not have a focus rect. Shouldn't it?
105 // r->SetFocusRect( r->GetRect().Deflate( 4, 4 ) );
106
107 pBar->Add( r, 0, wxALIGN_CENTER );
108
109 return r;
110}
TranslatableString label
Definition: TagsEditor.cpp:163
THEME_API Theme theTheme
Definition: Theme.cpp:82
int id
A wxButton with mouse-over behaviour.
Definition: AButton.h:25
void SetLabel(const TranslatableString &label)
Definition: AButton.cpp:274
AButton * mButtons[STBNumButtons]
wxSize ImageSize(int iIndex)
void Add(wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
Definition: ToolBar.cpp:686
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:852

References ToolBar::Add(), id, ThemeBase::ImageSize(), label, ToolBar::MakeButton(), mButtons, AButton::SetLabel(), and theTheme.

Referenced by Populate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Create()

void ScrubbingToolBar::Create ( wxWindow *  parent)
overridevirtual

Reimplemented from ToolBar.

Definition at line 76 of file ScrubbingToolBar.cpp.

77{
78 ToolBar::Create(parent);
80}
void UpdatePrefs() override
virtual void Create(wxWindow *parent)
Definition: ToolBar.cpp:475

References ToolBar::Create(), and UpdatePrefs().

Here is the call graph for this function:

◆ DoRegenerateTooltips()

void ScrubbingToolBar::DoRegenerateTooltips ( bool  force)
private

Definition at line 146 of file ScrubbingToolBar.cpp.

147{
148#if wxUSE_TOOLTIPS
149 auto fn = [&](
150 AButton &button, const TranslatableString &label, const CommandID &cmd)
151 {
152 ComponentInterfaceSymbol command{ cmd, label };
153 ToolBar::SetButtonToolTip( mProject, button, &command, 1u );
154 };
155
156 auto project = &mProject;
157 if (project) {
158 auto &scrubber = Scrubber::Get( *project );
159
160 const auto scrubButton = mButtons[STBScrubID];
161 const auto seekButton = mButtons[STBSeekID];
162
164 bool scrubs = scrubber.Scrubs();
165 if (force || mLastScrub != scrubs) {
166 label = (
167 scrubs
168 /* i18n-hint: These commands assist the user in finding a sound by ear. ...
169 "Scrubbing" is variable-speed playback, ...
170 "Seeking" is normal speed playback but with skips
171 */
172 ? XO("Stop Scrubbing")
173 /* i18n-hint: These commands assist the user in finding a sound by ear. ...
174 "Scrubbing" is variable-speed playback, ...
175 "Seeking" is normal speed playback but with skips
176 */
177 : XO("Start Scrubbing")
178 );
179 fn(*scrubButton, label, wxT("Scrub"));
180 }
181 mLastScrub = scrubs;
182
183 bool seeks = scrubber.Seeks();
184 if (force || mLastSeek != seeks) {
185 label = (
186 seeks
187 /* i18n-hint: These commands assist the user in finding a sound by ear. ...
188 "Scrubbing" is variable-speed playback, ...
189 "Seeking" is normal speed playback but with skips
190 */
191 ? XO("Stop Seeking")
192 /* i18n-hint: These commands assist the user in finding a sound by ear. ...
193 "Scrubbing" is variable-speed playback, ...
194 "Seeking" is normal speed playback but with skips
195 */
196 : XO("Start Seeking")
197 );
198 fn(*seekButton, label, wxT("Seek"));
199 }
200 mLastSeek = seeks;
201
202 bool showingRuler = AdornedRulerPanel::Get( *project ).ShowingScrubRuler();
203 if (force || mLastRuler != showingRuler) {
204 label = (
205 showingRuler
206 ? XO("Hide Scrub Ruler")
207 : XO("Show Scrub Ruler")
208 );
209 fn(*mButtons[STBRulerID], label, wxT("ToggleScrubRuler"));
210 }
211 mLastRuler = showingRuler;
212 }
213#endif
214}
#define XO(s)
Definition: Internat.h:31
@ STBRulerID
@ STBSeekID
@ STBScrubID
static const auto fn
bool ShowingScrubRuler() const
static AdornedRulerPanel & Get(AudacityProject &project)
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
static Scrubber & Get(AudacityProject &project)
Definition: Scrubbing.cpp:187
AudacityProject & mProject
Definition: ToolBar.h:247
static void SetButtonToolTip(AudacityProject &project, AButton &button, const ComponentInterfaceSymbol commands[], size_t nCommands)
Definition: ToolBar.cpp:947
Holds a msgid for the translation catalog; may also bind format arguments.

References fn, AdornedRulerPanel::Get(), Scrubber::Get(), label, mButtons, mLastRuler, mLastScrub, mLastSeek, ToolBar::mProject, ToolBar::SetButtonToolTip(), AdornedRulerPanel::ShowingScrubRuler(), STBRulerID, STBScrubID, STBSeekID, and XO.

Referenced by EnableDisableButtons(), and RegenerateTooltips().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EnableDisableButtons()

void ScrubbingToolBar::EnableDisableButtons ( )
overridevirtual

Implements ToolBar.

Definition at line 241 of file ScrubbingToolBar.cpp.

242{
243 const auto scrubButton = mButtons[STBScrubID];
244 const auto seekButton = mButtons[STBSeekID];
245
247
248 auto &scrubber = Scrubber::Get( *p );
249 const auto canScrub = scrubber.CanScrub();
250
251 if (scrubber.Scrubs()) {
252 scrubButton->PushDown();
253 scrubButton->Enable();
254 }
255 else {
256 scrubButton->PopUp();
257 if (canScrub)
258 scrubButton->Enable();
259 else
260 scrubButton->Disable();
261 }
262
263 if (scrubber.Seeks()) {
264 seekButton->PushDown();
265 seekButton->Enable();
266 }
267 else {
268 seekButton->PopUp();
269 if (canScrub)
270 seekButton->Enable();
271 else
272 seekButton->Disable();
273 }
274
275 const auto barButton = mButtons[STBRulerID];
276 barButton->Enable();
278 barButton->PushDown();
279 else
280 barButton->PopUp();
281 DoRegenerateTooltips( false );
282 scrubber.CheckMenuItems();
283}
void Enable()
Definition: AButton.cpp:571
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
void DoRegenerateTooltips(bool force)

References DoRegenerateTooltips(), AButton::Enable(), AdornedRulerPanel::Get(), Scrubber::Get(), mButtons, ToolBar::mProject, AdornedRulerPanel::ShowingScrubRuler(), STBRulerID, STBScrubID, and STBSeekID.

Referenced by OnButton(), and OnIdle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Get() [1/2]

ScrubbingToolBar & ScrubbingToolBar::Get ( AudacityProject project)
static

Definition at line 65 of file ScrubbingToolBar.cpp.

66{
67 auto &toolManager = ToolManager::Get( project );
68 return *static_cast<ScrubbingToolBar*>( toolManager.GetToolBar(ScrubbingBarID) );
69}
@ ScrubbingBarID
Definition: ToolBar.h:79
static ToolManager & Get(AudacityProject &project)

References ToolManager::Get(), and ScrubbingBarID.

Referenced by Get().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Get() [2/2]

const ScrubbingToolBar & ScrubbingToolBar::Get ( const AudacityProject project)
static

Definition at line 71 of file ScrubbingToolBar.cpp.

72{
73 return Get( const_cast<AudacityProject&>( project )) ;
74}
static ScrubbingToolBar & Get(AudacityProject &project)

References Get().

Here is the call graph for this function:

◆ MakeButtons()

void ScrubbingToolBar::MakeButtons ( )
private

◆ OnButton()

void ScrubbingToolBar::OnButton ( wxCommandEvent &  event)

Definition at line 216 of file ScrubbingToolBar.cpp.

217{
219 if (!p) return;
220 auto &scrubber = Scrubber::Get( *p );
221
222 int id = event.GetId();
223
224 switch (id) {
225 case STBScrubID:
226 scrubber.OnScrub(*p);
227 break;
228 case STBSeekID:
229 scrubber.OnSeek(*p);
230 break;
231 case STBRulerID:
232 scrubber.OnToggleScrubRuler(*p);
233 break;
234 default:
235 wxASSERT(false);
236 }
237
239}
void EnableDisableButtons() override

References EnableDisableButtons(), Scrubber::Get(), ToolBar::mProject, STBRulerID, STBScrubID, and STBSeekID.

Here is the call graph for this function:

◆ OnIdle()

void ScrubbingToolBar::OnIdle ( wxIdleEvent &  evt)
private

Definition at line 285 of file ScrubbingToolBar.cpp.

286{
287 evt.Skip();
289}

References EnableDisableButtons().

Here is the call graph for this function:

◆ Populate()

void ScrubbingToolBar::Populate ( )
overridevirtual

Implements ToolBar.

Definition at line 112 of file ScrubbingToolBar.cpp.

113{
114 SetBackgroundColour( theTheme.Colour( clrMedium ) );
116
117 /* Buttons */
118 AddButton(this, bmpScrub, bmpScrub, bmpScrubDisabled, STBScrubID,
119 XO("Scrub"), true);
120 AddButton(this, bmpSeek, bmpSeek, bmpSeekDisabled, STBSeekID,
121 XO("Seek"), true);
122 AddButton(this, bmpToggleScrubRuler, bmpToggleScrubRuler, bmpToggleScrubRuler,
124 XO("Scrub Ruler"), true);
125
126
128}
static AButton * AddButton(ScrubbingToolBar *pBar, teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, int id, const TranslatableString &label, bool toggle=false)
void RegenerateTooltips() override
wxColour & Colour(int iIndex)
static void MakeButtonBackgroundsSmall()
Definition: ToolBar.cpp:814

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

Here is the call graph for this function:

◆ RegenerateTooltips()

void ScrubbingToolBar::RegenerateTooltips ( )
overridevirtual

Implements ToolBar.

Definition at line 141 of file ScrubbingToolBar.cpp.

142{
143 DoRegenerateTooltips( true );
144}

References DoRegenerateTooltips().

Referenced by Populate(), and UpdatePrefs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Repaint()

void ScrubbingToolBar::Repaint ( wxDC *  WXUNUSEDdc)
inlineoverride

Definition at line 54 of file ScrubbingToolBar.h.

54{};

◆ UpdatePrefs()

void ScrubbingToolBar::UpdatePrefs ( )
overridevirtual

Implements PrefsListener.

Definition at line 130 of file ScrubbingToolBar.cpp.

131{
133
134 // Set label to pull in language change
135 SetLabel(XO("Scrubbing"));
136
137 // Give base class a chance
139}
void SetLabel(const wxString &label) override
Definition: ToolBar.cpp:398
void UpdatePrefs() override
Definition: ToolBar.cpp:605

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

Referenced by Create().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ downImage

wxImage* ScrubbingToolBar::downImage
private

Definition at line 72 of file ScrubbingToolBar.h.

◆ hiliteImage

wxImage* ScrubbingToolBar::hiliteImage
private

Definition at line 73 of file ScrubbingToolBar.h.

◆ mButtons

AButton* ScrubbingToolBar::mButtons[STBNumButtons]
private

Definition at line 69 of file ScrubbingToolBar.h.

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

◆ mLastRuler

bool ScrubbingToolBar::mLastRuler { false }
private

Definition at line 87 of file ScrubbingToolBar.h.

Referenced by DoRegenerateTooltips().

◆ mLastScrub

bool ScrubbingToolBar::mLastScrub { false }
private

Definition at line 85 of file ScrubbingToolBar.h.

Referenced by DoRegenerateTooltips().

◆ mLastSeek

bool ScrubbingToolBar::mLastSeek { false }
private

Definition at line 86 of file ScrubbingToolBar.h.

Referenced by DoRegenerateTooltips().

◆ upImage

wxImage* ScrubbingToolBar::upImage
private

Definition at line 71 of file ScrubbingToolBar.h.


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