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 ()
 
bool ShownByDefault () const override
 Whether the toolbar should be shown by default. Default implementation returns true. More...
 
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, const TranslatableString &label, const Identifier &section, bool resizable=false)
 
virtual ~ToolBar ()
 
virtual bool ShownByDefault () const
 Whether the toolbar should be shown by default. Default implementation returns true. More...
 
virtual bool HideAfterReset () const
 Default implementation returns false. More...
 
virtual DockID DefaultDockID () const
 Which dock the toolbar defaults into. Default implementation chooses the top dock. More...
 
bool AcceptsFocus () const override
 
bool AcceptsFocusFromKeyboard () 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 GetIndex () const
 Get a value used for computing cascading positions of undocked bars. More...
 
void SetIndex (int index)
 Set a value used for computing cascading positions of undocked bars. More...
 
TranslatableString GetTitle ()
 
TranslatableString GetLabel ()
 
Identifier GetSection ()
 
ToolDockGetDock ()
 
void SetPreferredNeighbors (Identifier left, Identifier top={})
 
void SetLabel (const TranslatableString &label)
 
virtual void SetDocked (ToolDock *dock, bool pushed)
 
std::pair< Identifier, IdentifierPreferredNeighbors () const noexcept
 Defaults to (NoBarID, NoBarId) More...
 
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 Identifier ID ()
 
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]
 
wxImageupImage
 
wxImagedownImage
 
wxImagehiliteImage
 
bool mLastScrub { false }
 
bool mLastSeek { false }
 
bool mLastRuler { false }
 

Additional Inherited Members

- Public Types inherited from ToolBar
enum  DockID { TopDockID = 1 , BotDockID = 2 }
 Identifies one of the docking areas for toolbars. More...
 
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
 
Identifier mSection
 
int mIndex {0}
 

Detailed Description

Definition at line 39 of file ScrubbingToolBar.h.

Constructor & Destructor Documentation

◆ ScrubbingToolBar()

ScrubbingToolBar::ScrubbingToolBar ( AudacityProject project)

Definition at line 57 of file ScrubbingToolBar.cpp.

58: ToolBar(project, XO("Scrub"), ID())
59{
60}
XO("Cut/Copy/Paste")
const auto project
static Identifier ID()
ToolBar(AudacityProject &project, const TranslatableString &label, const Identifier &section, bool resizable=false)
Definition: ToolBar.cpp:328

◆ ~ScrubbingToolBar()

ScrubbingToolBar::~ScrubbingToolBar ( )
virtual

Definition at line 62 of file ScrubbingToolBar.cpp.

63{
64}

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 91 of file ScrubbingToolBar.cpp.

97{
98 AButton *&r = pBar->mButtons[id];
99
101 (pBar,
102 bmpRecoloredUpSmall, bmpRecoloredDownSmall, bmpRecoloredUpHiliteSmall, bmpRecoloredHiliteSmall,
103 eEnabledUp, eEnabledDown, eDisabled,
104 wxWindowID(id),
105 wxDefaultPosition,
106 toggle,
107 theTheme.ImageSize( bmpRecoloredUpSmall ));
108
109 r->SetLabel(label);
110 // JKC: Unlike ControlToolBar, does not have a focus rect. Shouldn't it?
111 // r->SetFocusRect( r->GetRect().Deflate( 4, 4 ) );
112
113 pBar->Add( r, 0, wxALIGN_CENTER );
114
115 return r;
116}
TranslatableString label
Definition: TagsEditor.cpp:165
THEME_API Theme theTheme
Definition: Theme.cpp:82
int id
A wxButton with mouse-over behaviour.
Definition: AButton.h:104
void SetLabel(const TranslatableString &label)
Definition: AButton.cpp:189
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:709
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:875

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 82 of file ScrubbingToolBar.cpp.

83{
84 ToolBar::Create(parent);
86}
void UpdatePrefs() override
virtual void Create(wxWindow *parent)
Definition: ToolBar.cpp:492

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

Here is the call graph for this function:

◆ DoRegenerateTooltips()

void ScrubbingToolBar::DoRegenerateTooltips ( bool  force)
private

Definition at line 152 of file ScrubbingToolBar.cpp.

153{
154#if wxUSE_TOOLTIPS
155 auto fn = [&](
156 AButton &button, const TranslatableString &label, const CommandID &cmd)
157 {
158 ComponentInterfaceSymbol command{ cmd, label };
159 ToolBar::SetButtonToolTip( mProject, button, &command, 1u );
160 };
161
162 auto project = &mProject;
163 if (project) {
164 auto &scrubber = Scrubber::Get( *project );
165
166 const auto scrubButton = mButtons[STBScrubID];
167 const auto seekButton = mButtons[STBSeekID];
168
170 bool scrubs = scrubber.Scrubs();
171 if (force || mLastScrub != scrubs) {
172 label = (
173 scrubs
174 /* i18n-hint: These commands assist the user in finding a sound by ear. ...
175 "Scrubbing" is variable-speed playback, ...
176 "Seeking" is normal speed playback but with skips
177 */
178 ? XO("Stop Scrubbing")
179 /* i18n-hint: These commands assist the user in finding a sound by ear. ...
180 "Scrubbing" is variable-speed playback, ...
181 "Seeking" is normal speed playback but with skips
182 */
183 : XO("Start Scrubbing")
184 );
185 fn(*scrubButton, label, wxT("Scrub"));
186 }
187 mLastScrub = scrubs;
188
189 bool seeks = scrubber.Seeks();
190 if (force || mLastSeek != seeks) {
191 label = (
192 seeks
193 /* i18n-hint: These commands assist the user in finding a sound by ear. ...
194 "Scrubbing" is variable-speed playback, ...
195 "Seeking" is normal speed playback but with skips
196 */
197 ? XO("Stop Seeking")
198 /* i18n-hint: These commands assist the user in finding a sound by ear. ...
199 "Scrubbing" is variable-speed playback, ...
200 "Seeking" is normal speed playback but with skips
201 */
202 : XO("Start Seeking")
203 );
204 fn(*seekButton, label, wxT("Seek"));
205 }
206 mLastSeek = seeks;
207
208 bool showingRuler = AdornedRulerPanel::Get( *project ).ShowingScrubRuler();
209 if (force || mLastRuler != showingRuler) {
210 label = (
211 showingRuler
212 ? XO("Hide Scrub Ruler")
213 : XO("Show Scrub Ruler")
214 );
215 fn(*mButtons[STBRulerID], label, wxT("ToggleScrubRuler"));
216 }
217 mLastRuler = showingRuler;
218 }
219#endif
220}
wxT("CloseDown"))
@ 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:188
AudacityProject & mProject
Definition: ToolBar.h:248
static void SetButtonToolTip(AudacityProject &project, AButton &button, const ComponentInterfaceSymbol commands[], size_t nCommands)
Definition: ToolBar.cpp:970
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, project, ToolBar::SetButtonToolTip(), AdornedRulerPanel::ShowingScrubRuler(), STBRulerID, STBScrubID, STBSeekID, wxT(), 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 247 of file ScrubbingToolBar.cpp.

248{
249 const auto scrubButton = mButtons[STBScrubID];
250 const auto seekButton = mButtons[STBSeekID];
251
253
254 auto &scrubber = Scrubber::Get( *p );
255 const auto canScrub = scrubber.CanScrub();
256
257 if (scrubber.Scrubs()) {
258 scrubButton->PushDown();
259 scrubButton->Enable();
260 }
261 else {
262 scrubButton->PopUp();
263 if (canScrub)
264 scrubButton->Enable();
265 else
266 scrubButton->Disable();
267 }
268
269 if (scrubber.Seeks()) {
270 seekButton->PushDown();
271 seekButton->Enable();
272 }
273 else {
274 seekButton->PopUp();
275 if (canScrub)
276 seekButton->Enable();
277 else
278 seekButton->Disable();
279 }
280
281 const auto barButton = mButtons[STBRulerID];
282 barButton->Enable();
284 barButton->PushDown();
285 else
286 barButton->PopUp();
287 DoRegenerateTooltips( false );
288 scrubber.CheckMenuItems();
289}
void Enable()
Definition: AButton.cpp:551
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
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 71 of file ScrubbingToolBar.cpp.

72{
73 auto &toolManager = ToolManager::Get( project );
74 return *static_cast<ScrubbingToolBar*>(toolManager.GetToolBar(ID()));
75}
static ToolManager & Get(AudacityProject &project)

References ToolManager::Get(), ID(), and project.

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 77 of file ScrubbingToolBar.cpp.

78{
79 return Get( const_cast<AudacityProject&>( project )) ;
80}
static ScrubbingToolBar & Get(AudacityProject &project)

References Get(), and project.

Here is the call graph for this function:

◆ ID()

static Identifier ScrubbingToolBar::ID ( )
static

Referenced by Get().

Here is the caller graph for this function:

◆ MakeButtons()

void ScrubbingToolBar::MakeButtons ( )
private

◆ OnButton()

void ScrubbingToolBar::OnButton ( wxCommandEvent &  event)

Definition at line 222 of file ScrubbingToolBar.cpp.

223{
225 if (!p) return;
226 auto &scrubber = Scrubber::Get( *p );
227
228 int id = event.GetId();
229
230 switch (id) {
231 case STBScrubID:
232 scrubber.OnScrub(*p);
233 break;
234 case STBSeekID:
235 scrubber.OnSeek(*p);
236 break;
237 case STBRulerID:
238 scrubber.OnToggleScrubRuler(*p);
239 break;
240 default:
241 wxASSERT(false);
242 }
243
245}
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 291 of file ScrubbingToolBar.cpp.

292{
293 evt.Skip();
295}

References EnableDisableButtons().

Here is the call graph for this function:

◆ Populate()

void ScrubbingToolBar::Populate ( )
overridevirtual

Implements ToolBar.

Definition at line 118 of file ScrubbingToolBar.cpp.

119{
120 SetBackgroundColour( theTheme.Colour( clrMedium ) );
122
123 /* Buttons */
124 AddButton(this, bmpScrub, bmpScrub, bmpScrubDisabled, STBScrubID,
125 XO("Scrub"), true);
126 AddButton(this, bmpSeek, bmpSeek, bmpSeekDisabled, STBSeekID,
127 XO("Seek"), true);
128 AddButton(this, bmpToggleScrubRuler, bmpToggleScrubRuler, bmpToggleScrubRuler,
130 XO("Scrub Ruler"), true);
131
132
134}
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:837

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 147 of file ScrubbingToolBar.cpp.

148{
149 DoRegenerateTooltips( true );
150}

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 58 of file ScrubbingToolBar.h.

58{};

◆ ShownByDefault()

bool ScrubbingToolBar::ShownByDefault ( ) const
overridevirtual

Whether the toolbar should be shown by default. Default implementation returns true.

Reimplemented from ToolBar.

Definition at line 66 of file ScrubbingToolBar.cpp.

67{
68 return false;
69}

◆ UpdatePrefs()

void ScrubbingToolBar::UpdatePrefs ( )
overridevirtual

Implements PrefsListener.

Definition at line 136 of file ScrubbingToolBar.cpp.

137{
139
140 // Set label to pull in language change
141 SetLabel(XO("Scrubbing"));
142
143 // Give base class a chance
145}
void SetLabel(const wxString &label) override
Definition: ToolBar.cpp:408
void UpdatePrefs() override
Definition: ToolBar.cpp:622

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 76 of file ScrubbingToolBar.h.

◆ hiliteImage

wxImage* ScrubbingToolBar::hiliteImage
private

Definition at line 77 of file ScrubbingToolBar.h.

◆ mButtons

AButton* ScrubbingToolBar::mButtons[STBNumButtons]
private

Definition at line 73 of file ScrubbingToolBar.h.

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

◆ mLastRuler

bool ScrubbingToolBar::mLastRuler { false }
private

Definition at line 91 of file ScrubbingToolBar.h.

Referenced by DoRegenerateTooltips().

◆ mLastScrub

bool ScrubbingToolBar::mLastScrub { false }
private

Definition at line 89 of file ScrubbingToolBar.h.

Referenced by DoRegenerateTooltips().

◆ mLastSeek

bool ScrubbingToolBar::mLastSeek { false }
private

Definition at line 90 of file ScrubbingToolBar.h.

Referenced by DoRegenerateTooltips().

◆ upImage

wxImage* ScrubbingToolBar::upImage
private

Definition at line 75 of file ScrubbingToolBar.h.


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