Audacity 3.2.0
Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
ControlToolBar Class Referencefinal

A ToolBar that has the main Transport buttons. More...

#include <ControlToolBar.h>

Inheritance diagram for ControlToolBar:
[legend]
Collaboration diagram for ControlToolBar:
[legend]

Public Types

enum class  PlayAppearance {
  Straight , Looped , CutPreview , Scrub ,
  Seek
}
 
- Public Types inherited from ToolBar
enum  DockID { TopDockID = 1 , BotDockID = 2 }
 Identifies one of the docking areas for toolbars. More...
 
using Holder = wxWindowPtr< ToolBar >
 

Public Member Functions

 ControlToolBar (AudacityProject &project)
 
virtual ~ControlToolBar ()
 
void Create (wxWindow *parent) override
 
void UpdatePrefs () override
 
void OnKeyEvent (wxKeyEvent &event)
 
void OnRewind (wxCommandEvent &evt)
 
void OnPlay (wxCommandEvent &evt)
 
void OnStop (wxCommandEvent &evt)
 
void OnRecord (wxCommandEvent &evt)
 
void OnFF (wxCommandEvent &evt)
 
void OnPause (wxCommandEvent &evt)
 
void OnLoop (wxCommandEvent &evt)
 
void OnIdle (wxIdleEvent &event)
 
void SetPlay (bool down, PlayAppearance appearance=PlayAppearance::Straight)
 
void SetStop ()
 
void PlayDefault ()
 
void Populate () override
 
void Repaint (wxDC *dc) override
 
void EnableDisableButtons () override
 
void ReCreateButtons () override
 
void RegenerateTooltips () override
 
void StartScrollingIfPreferred ()
 
void StartScrolling ()
 
void StopScrolling ()
 
- 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 ControlToolBarFind (AudacityProject &project)
 
static ControlToolBarGet (AudacityProject &project)
 
static const ControlToolBarGet (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 Types

enum  {
  ID_PAUSE_BUTTON = 11000 , ID_PLAY_BUTTON , ID_STOP_BUTTON , ID_FF_BUTTON ,
  ID_REW_BUTTON , ID_RECORD_BUTTON , ID_LOOP_BUTTON , BUTTON_COUNT
}
 

Private Member Functions

void UpdateStatusBar ()
 
void ArrangeButtons ()
 
TranslatableString StateForStatusBar ()
 

Static Private Member Functions

static void MakeAlternateImages (AButton &button, int idx, teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled)
 

Private Attributes

AButtonmRewind
 
AButtonmPlay
 
AButtonmRecord
 
AButtonmPause
 
AButtonmStop
 
AButtonmFF
 
AButtonmLoop
 
wxString mStrLocale
 
wxBoxSizer * mSizer
 

Additional Inherited Members

- 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

A ToolBar that has the main Transport buttons.

In the GUI, this is referred to as "Transport Toolbar", as it corresponds to commands in the Transport menu. "Control Toolbar" is historic. This class, which is a child of Toolbar, creates the window containing the Transport (rewind/play/stop/record/ff) buttons. The window can be embedded within a normal project window, or within a ToolBarFrame.

All of the controls in this window were custom-written for Audacity - they are not native controls on any platform - however, it is intended that the images could be easily replaced to allow "skinning" or just customization to match the look and feel of each platform.

Definition at line 32 of file ControlToolBar.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
ID_PAUSE_BUTTON 
ID_PLAY_BUTTON 
ID_STOP_BUTTON 
ID_FF_BUTTON 
ID_REW_BUTTON 
ID_RECORD_BUTTON 
ID_LOOP_BUTTON 
BUTTON_COUNT 

Definition at line 97 of file ControlToolBar.h.

◆ PlayAppearance

enum class ControlToolBar::PlayAppearance
strong
Enumerator
Straight 
Looped 
CutPreview 
Scrub 
Seek 

Definition at line 61 of file ControlToolBar.h.

61 {
62 Straight, Looped, CutPreview, Scrub, Seek
63 };

Constructor & Destructor Documentation

◆ ControlToolBar()

ControlToolBar::ControlToolBar ( AudacityProject project)

Definition at line 116 of file ControlToolBar.cpp.

117: ToolBar(project, XO("Transport"), ID())
118{
119 mStrLocale = gPrefs->Read(wxT("/Locale/Language"), wxT(""));
120
121 mSizer = NULL;
122}
wxT("CloseDown"))
XO("Cut/Copy/Paste")
FileConfig * gPrefs
Definition: Prefs.cpp:70
wxString mStrLocale
static Identifier ID()
wxBoxSizer * mSizer
ToolBar(AudacityProject &project, const TranslatableString &label, const Identifier &section, bool resizable=false)
Definition: ToolBar.cpp:328

References gPrefs, mSizer, mStrLocale, and wxT().

Here is the call graph for this function:

◆ ~ControlToolBar()

ControlToolBar::~ControlToolBar ( )
virtual

Definition at line 124 of file ControlToolBar.cpp.

125{
126}

Member Function Documentation

◆ ArrangeButtons()

void ControlToolBar::ArrangeButtons ( )
private

Definition at line 333 of file ControlToolBar.cpp.

334{
335 int flags = wxALIGN_CENTER | wxRIGHT;
336
337 // (Re)allocate the button sizer
338 if( mSizer )
339 {
340 Detach( mSizer );
341 std::unique_ptr < wxSizer > {mSizer}; // DELETE it
342 }
343
344 Add((mSizer = safenew wxBoxSizer(wxHORIZONTAL)), 1, wxEXPAND);
345
346 // Start with a little extra space
347 mSizer->Add( 5, 55 );
348
349 // Establish correct tab key sequence with mLoop last
350 mPause->MoveBeforeInTabOrder( mLoop );
351 mPlay->MoveBeforeInTabOrder( mLoop );
352 mStop->MoveBeforeInTabOrder( mLoop );
353 mRewind->MoveBeforeInTabOrder( mLoop );
354 mFF->MoveBeforeInTabOrder( mLoop );
355 mRecord->MoveBeforeInTabOrder( mLoop );
356
357 mSizer->Add( mPause, 0, flags, 2 );
358 mSizer->Add( mPlay, 0, flags, 2 );
359 mSizer->Add( mStop, 0, flags, 2 );
360 mSizer->Add( mRewind, 0, flags, 2 );
361 mSizer->Add( mFF, 0, flags, 10 );
362 mSizer->Add( mRecord, 0, flags, 10 );
363 mSizer->Add( mLoop, 0, flags, 5 );
364
365 // Layout the sizer
366 mSizer->Layout();
367
368 // Layout the toolbar
369 Layout();
370
371 // (Re)Establish the minimum size
372 SetMinSize( GetSizer()->GetMinSize() );
373}
#define safenew
Definition: MemoryX.h:10
AButton * mRecord
AButton * mPause
AButton * mRewind
void Add(wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
Definition: ToolBar.cpp:709
wxBoxSizer * GetSizer()
Definition: ToolBar.cpp:701
void Detach(wxWindow *window)
Definition: ToolBar.cpp:775

References ToolBar::Add(), ToolBar::Detach(), ToolBar::GetSizer(), mFF, mLoop, mPause, mPlay, mRecord, mRewind, mSizer, mStop, and safenew.

Referenced by Populate().

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

◆ Create()

void ControlToolBar::Create ( wxWindow *  parent)
overridevirtual

Reimplemented from ToolBar.

Definition at line 148 of file ControlToolBar.cpp.

149{
150 ToolBar::Create(parent);
151 UpdatePrefs();
152}
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:

◆ EnableDisableButtons()

void ControlToolBar::EnableDisableButtons ( )
overridevirtual

Implements ToolBar.

Definition at line 441 of file ControlToolBar.cpp.

442{
444 auto &projectAudioManager = ProjectAudioManager::Get( mProject );
445 bool canStop = projectAudioManager.CanStopAudioStream();
446
447 bool paused = mPause->IsDown();
448 bool playing = mPlay->IsDown();
449 bool recording = mRecord->IsDown();
450 auto gAudioIO = AudioIO::Get();
451 bool busy = gAudioIO->IsBusy();
452
453 // Only interested in audio type tracks
454 bool tracks = p && TrackList::Get( *p ).Any<AudioTrack>(); // PRL: PlayableTrack ?
455
456 mPlay->SetEnabled( canStop && tracks && !recording );
458 canStop &&
459 !(busy && !recording && !paused) &&
460 !(playing && !paused)
461 );
462 mStop->SetEnabled(canStop && (playing || recording));
463 mRewind->SetEnabled(paused || (!playing && !recording));
464 mFF->SetEnabled(tracks && (paused || (!playing && !recording)));
465
466 mPause->SetEnabled(canStop);
467
468 mLoop->SetEnabled( !recording );
469}
bool IsDown()
Definition: AButton.h:208
void SetEnabled(bool state)
Definition: AButton.h:182
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
static AudioIO * Get()
Definition: AudioIO.cpp:147
Track subclass holding data representing sound (as notes, or samples, or ...)
Definition: Track.h:898
static ProjectAudioManager & Get(AudacityProject &project)
AudacityProject & mProject
Definition: ToolBar.h:248
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1440
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:487

References TrackList::Any(), AudioIO::Get(), TrackList::Get(), ProjectAudioManager::Get(), AButton::IsDown(), mFF, mLoop, mPause, mPlay, ToolBar::mProject, mRecord, mRewind, mStop, and AButton::SetEnabled().

Referenced by OnIdle(), ReCreateButtons(), SetPlay(), and SetStop().

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

◆ Find()

ControlToolBar * ControlToolBar::Find ( AudacityProject project)
static

Definition at line 129 of file ControlToolBar.cpp.

130{
131 auto &toolManager = ToolManager::Get( project );
132 return static_cast<ControlToolBar*>(
133 toolManager.GetToolBar(ID()));
134}
A ToolBar that has the main Transport buttons.
static ToolManager & Get(AudacityProject &project)

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

Here is the call graph for this function:

◆ Get() [1/2]

ControlToolBar & ControlToolBar::Get ( AudacityProject project)
static

Definition at line 136 of file ControlToolBar.cpp.

137{
138 auto &toolManager = ToolManager::Get( project );
139 return *static_cast<ControlToolBar*>(
140 toolManager.GetToolBar(ID()));
141}

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

Referenced by TransportUtilities::DoStopPlaying(), Get(), anonymous_namespace{TransportMenus.cpp}::MakeReadyToPlay(), SelectActions::Handler::OnSkipEnd(), and SelectActions::Handler::OnSkipStart().

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

◆ Get() [2/2]

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

Definition at line 143 of file ControlToolBar.cpp.

144{
145 return Get( const_cast<AudacityProject&>( project )) ;
146}
static ControlToolBar & Get(AudacityProject &project)

References Get().

Here is the call graph for this function:

◆ ID()

Identifier ControlToolBar::ID ( )
static

Definition at line 106 of file ControlToolBar.cpp.

107{
108 return wxT("Control");
109}

References wxT().

Referenced by Find(), and Get().

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

◆ MakeAlternateImages()

void ControlToolBar::MakeAlternateImages ( AButton button,
int  idx,
teBmps  eEnabledUp,
teBmps  eEnabledDown,
teBmps  eDisabled 
)
staticprivate

Definition at line 155 of file ControlToolBar.cpp.

159{
161 bmpRecoloredUpLarge, bmpRecoloredDownLarge, bmpRecoloredUpHiliteLarge, bmpRecoloredHiliteLarge,
162 eEnabledUp, eEnabledDown, eDisabled,
163 theTheme.ImageSize( bmpRecoloredUpLarge ));
164}
THEME_API Theme theTheme
Definition: Theme.cpp:82
wxSize ImageSize(int iIndex)
static void MakeAlternateImages(AButton &button, int idx, teBmps eUp, teBmps eDown, teBmps eHilite, teBmps eDownHi, teBmps eStandardUp, teBmps eStandardDown, teBmps eDisabled, wxSize size)
Definition: ToolBar.cpp:945

References ThemeBase::ImageSize(), ToolBar::MakeAlternateImages(), and theTheme.

Referenced by Populate().

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

◆ OnFF()

void ControlToolBar::OnFF ( wxCommandEvent &  evt)

Definition at line 663 of file ControlToolBar.cpp.

664{
665 mFF->PushDown();
666 mFF->PopUp();
667
669
670 {
673 }
674}
void PushDown()
Definition: AButton.cpp:577
void PopUp()
Definition: AButton.cpp:585
bool WasShiftDown()
Definition: AButton.cpp:541
static ProjectWindow & Get(AudacityProject &project)
void SkipEnd(bool shift)

References ProjectAudioManager::Get(), ProjectWindow::Get(), mFF, ToolBar::mProject, AButton::PopUp(), AButton::PushDown(), ProjectWindow::SkipEnd(), ProjectAudioManager::StopIfPaused(), and AButton::WasShiftDown().

Here is the call graph for this function:

◆ OnIdle()

void ControlToolBar::OnIdle ( wxIdleEvent &  event)

Definition at line 584 of file ControlToolBar.cpp.

585{
586 event.Skip();
587
588 if (!wxTheApp->IsActive())
589 return;
590
591 auto &projectAudioManager = ProjectAudioManager::Get( mProject );
592 if ( projectAudioManager.Paused() )
593 mPause->PushDown();
594 else
595 mPause->PopUp();
596
597 bool recording = projectAudioManager.Recording();
598 if (!recording) {
599 mRecord->PopUp();
600 mRecord->SetAlternateIdx( wxGetKeyState(WXK_SHIFT) ? 1 : 0 );
601 }
602 else {
603 mRecord->PushDown();
604 mRecord->SetAlternateIdx( projectAudioManager.Appending() ? 0 : 1 );
605 }
606
607 bool playing = projectAudioManager.Playing();
608 if ( !(playing || Scrubber::Get(mProject).HasMark()) ) {
609 mPlay->PopUp();
611 wxGetKeyState(WXK_CONTROL)
612 ? 2
613 : wxGetKeyState(WXK_SHIFT)
614 ? 1
615 : 0
616 );
617 }
618 else {
619 mPlay->PushDown();
620 // Choose among alternative appearances of the play button, although
621 // options 0 and 1 became non-distinct in 3.1.0
623 projectAudioManager.Cutting()
624 ? 2
625 // : projectAudioManager.Looping()
626 // ? 1
627 : 0
628 );
629 }
630
631 if ( recording || playing )
633 else
635
636 if ( projectAudioManager.Stopping() )
637 mStop->PushDown();
638 else
639 // push-downs of the stop button are only momentary and always pop up now
640 mStop->PopUp();
641
642 if (ViewInfo::Get(mProject).playRegion.Active())
643 mLoop->PushDown();
644 else
645 mLoop->PopUp();
646
649}
void SetAlternateIdx(unsigned idx)
Definition: AButton.cpp:232
void EnableDisableButtons() override
void StartScrollingIfPreferred()
static Scrubber & Get(AudacityProject &project)
Definition: Scrubbing.cpp:187
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235

References EnableDisableButtons(), ViewInfo::Get(), ProjectAudioManager::Get(), Scrubber::Get(), mLoop, mPause, mPlay, ToolBar::mProject, mRecord, mStop, AButton::PopUp(), AButton::PushDown(), AButton::SetAlternateIdx(), StartScrollingIfPreferred(), StopScrolling(), and UpdateStatusBar().

Here is the call graph for this function:

◆ OnKeyEvent()

void ControlToolBar::OnKeyEvent ( wxKeyEvent &  event)

Definition at line 492 of file ControlToolBar.cpp.

493{
494 // PRL: is this handler really ever reached? Is the ControlToolBar ever
495 // focused? Isn't there a global event filter that interprets the spacebar
496 // key (or other key chosen in preferences) and dispatches to DoPlayStop,
497 // according to CommandManager's table, before we come to this redundant
498 // function?
499
500 if (event.ControlDown() || event.AltDown()) {
501 event.Skip();
502 return;
503 }
504
505 auto gAudioIO = AudioIOBase::Get();
506 auto &projectAudioManager = ProjectAudioManager::Get( mProject );
507
508 // Does not appear to be needed on Linux. Perhaps on some other platform?
509 // If so, "!CanStopAudioStream()" should probably apply.
510 if (event.GetKeyCode() == WXK_SPACE) {
511 if ( projectAudioManager.Playing() || projectAudioManager.Recording() ) {
512 SetStop();
513 projectAudioManager.Stop();
514 }
515 else if (!gAudioIO->IsBusy()) {
516 projectAudioManager.PlayCurrentRegion();
517 }
518 return;
519 }
520 event.Skip();
521}
static AudioIOBase * Get()
Definition: AudioIOBase.cpp:91

References AudioIOBase::Get(), ProjectAudioManager::Get(), ToolBar::mProject, and SetStop().

Here is the call graph for this function:

◆ OnLoop()

void ControlToolBar::OnLoop ( wxCommandEvent &  evt)

Definition at line 574 of file ControlToolBar.cpp.

575{
576 // Toggle the state of the play region lock
577 auto &region = ViewInfo::Get(mProject).playRegion;
578 if (region.Active())
580 else
582}
PlayRegion playRegion
Definition: ViewInfo.h:220
void ActivatePlayRegion(AudacityProject &project)
void InactivatePlayRegion(AudacityProject &project)

References SelectUtilities::ActivatePlayRegion(), ViewInfo::Get(), SelectUtilities::InactivatePlayRegion(), ToolBar::mProject, and ViewInfo::playRegion.

Here is the call graph for this function:

◆ OnPause()

void ControlToolBar::OnPause ( wxCommandEvent &  evt)

Definition at line 569 of file ControlToolBar.cpp.

References ProjectAudioManager::Get(), ToolBar::mProject, and ProjectAudioManager::OnPause().

Here is the call graph for this function:

◆ OnPlay()

void ControlToolBar::OnPlay ( wxCommandEvent &  evt)

Definition at line 523 of file ControlToolBar.cpp.

524{
525 auto p = &mProject;
526 auto &projectAudioManager = ProjectAudioManager::Get( mProject );
527 bool canStop = projectAudioManager.CanStopAudioStream();
528
529 if ( !canStop )
530 return;
531
532 projectAudioManager.Stop();
533
534 PlayDefault();
535}

References ProjectAudioManager::Get(), ToolBar::mProject, and PlayDefault().

Here is the call graph for this function:

◆ OnRecord()

void ControlToolBar::OnRecord ( wxCommandEvent &  evt)
Exception safety guarantee:
Strong – For state of current project's tracks

Definition at line 558 of file ControlToolBar.cpp.

559{
560 // TODO: It would be neater if Menu items and Toolbar buttons used the same code for
561 // enabling/disabling, and all fell into the same action routines.
562 // Here instead we reduplicate some logic (from CommandHandler) because it isn't
563 // normally used for buttons.
564
565 bool altAppearance = mRecord->WasShiftDown();
566 ProjectAudioManager::Get( mProject ).OnRecord( altAppearance );
567}
void OnRecord(bool altAppearance)

References ProjectAudioManager::Get(), ToolBar::mProject, mRecord, ProjectAudioManager::OnRecord(), and AButton::WasShiftDown().

Here is the call graph for this function:

◆ OnRewind()

void ControlToolBar::OnRewind ( wxCommandEvent &  evt)

Definition at line 651 of file ControlToolBar.cpp.

652{
653 mRewind->PushDown();
654 mRewind->PopUp();
655
657 {
660 }
661}
void Rewind(bool shift)

References ProjectAudioManager::Get(), ProjectWindow::Get(), ToolBar::mProject, mRewind, AButton::PopUp(), AButton::PushDown(), ProjectWindow::Rewind(), ProjectAudioManager::StopIfPaused(), and AButton::WasShiftDown().

Here is the call graph for this function:

◆ OnStop()

void ControlToolBar::OnStop ( wxCommandEvent &  evt)

Definition at line 537 of file ControlToolBar.cpp.

538{
539 auto &projectAudioManager = ProjectAudioManager::Get( mProject );
540 bool canStop = projectAudioManager.CanStopAudioStream();
541
542 if ( canStop ) {
543 projectAudioManager.Stop();
544 }
545}

References ProjectAudioManager::Get(), and ToolBar::mProject.

Here is the call graph for this function:

◆ PlayDefault()

void ControlToolBar::PlayDefault ( )

Definition at line 547 of file ControlToolBar.cpp.

548{
549 // Let control-down have precedence over shift state
550 const bool cutPreview = mPlay->WasControlDown();
551 const bool newDefault = !cutPreview &&
554 .PlayCurrentRegion(newDefault, cutPreview);
555}
bool WasControlDown()
Definition: AButton.cpp:546
void PlayCurrentRegion(bool newDefault=false, bool cutpreview=false)

References ProjectAudioManager::Get(), mPlay, ToolBar::mProject, ProjectAudioManager::PlayCurrentRegion(), AButton::WasControlDown(), and AButton::WasShiftDown().

Referenced by OnPlay().

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

◆ Populate()

void ControlToolBar::Populate ( )
overridevirtual

Implements ToolBar.

Definition at line 166 of file ControlToolBar.cpp.

167{
168 SetBackgroundColour( theTheme.Colour( clrMedium ) );
170
171 mPause = MakeButton(this, bmpPause, bmpPause, bmpPauseDisabled,
172 ID_PAUSE_BUTTON, true, XO("Pause"));
173
174 mPlay = MakeButton(this, bmpPlay, bmpPlay, bmpPlayDisabled,
175 ID_PLAY_BUTTON, true, XO("Play"));
176 // 3.1.0 abandoned distinct images for Shift
177 MakeAlternateImages(*mPlay, 1, bmpPlay, bmpPlay, bmpPlayDisabled);
179 bmpCutPreview, bmpCutPreview, bmpCutPreviewDisabled);
181 bmpScrub, bmpScrub, bmpScrubDisabled);
183 bmpSeek, bmpSeek, bmpSeekDisabled);
185
186 mStop = MakeButton(this, bmpStop, bmpStop, bmpStopDisabled ,
187 ID_STOP_BUTTON, false, XO("Stop"));
188
189 mRewind = MakeButton(this, bmpRewind, bmpRewind, bmpRewindDisabled,
190 ID_REW_BUTTON, false, XO("Skip to Start"));
191
192 mFF = MakeButton(this, bmpFFwd, bmpFFwd, bmpFFwdDisabled,
193 ID_FF_BUTTON, false, XO("Skip to End"));
194
195 mRecord = MakeButton(this, bmpRecord, bmpRecord, bmpRecordDisabled,
196 ID_RECORD_BUTTON, false, XO("Record"));
197
198 bool bPreferNewTrack;
199 gPrefs->Read("/GUI/PreferNewTrackRecord",&bPreferNewTrack, false);
200 if( !bPreferNewTrack )
201 MakeAlternateImages(*mRecord, 1, bmpRecordBelow, bmpRecordBelow,
202 bmpRecordBelowDisabled);
203 else
204 MakeAlternateImages(*mRecord, 1, bmpRecordBeside, bmpRecordBeside,
205 bmpRecordBesideDisabled);
206
208
209 mLoop = MakeButton(this, bmpLoop, bmpLoop, bmpLoopDisabled,
211 true, // this makes it a toggle, like the pause button
213
214#if wxUSE_TOOLTIPS
216 wxToolTip::Enable(true);
217 wxToolTip::SetDelay(1000);
218#endif
219
220 // Set default order and mode
222}
const TranslatableString LoopToggleText
Definition: ViewInfo.cpp:227
void FollowModifierKeys()
Definition: AButton.cpp:243
static void MakeAlternateImages(AButton &button, int idx, teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled)
void RegenerateTooltips() override
wxColour & Colour(int iIndex)
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
static void MakeButtonBackgroundsLarge()
Definition: ToolBar.cpp:811
TranslatableString Stripped(unsigned options=MenuCodes) const
non-mutating, constructs another TranslatableString object

References ArrangeButtons(), ThemeBase::Colour(), AButton::FollowModifierKeys(), gPrefs, ID_FF_BUTTON, ID_LOOP_BUTTON, ID_PAUSE_BUTTON, ID_PLAY_BUTTON, ID_RECORD_BUTTON, ID_REW_BUTTON, ID_STOP_BUTTON, LoopToggleText, MakeAlternateImages(), ToolBar::MakeButton(), ToolBar::MakeButtonBackgroundsLarge(), mFF, mLoop, mPause, mPlay, mRecord, mRewind, mStop, RegenerateTooltips(), TranslatableString::Stripped(), theTheme, and XO().

Here is the call graph for this function:

◆ ReCreateButtons()

void ControlToolBar::ReCreateButtons ( )
overridevirtual

Reimplemented from ToolBar.

Definition at line 375 of file ControlToolBar.cpp.

376{
377 bool playDown = false;
378 bool playShift = false;
379 bool pauseDown = false;
380 bool recordDown = false;
381 bool recordShift = false;
382 bool loopDown = false;
383
384 // ToolBar::ReCreateButtons() will get rid of its sizer and
385 // since we've attached our sizer to it, ours will get deleted too
386 // so clean ours up first.
387 if( mSizer )
388 {
389 playDown = mPlay->IsDown();
390 playShift = mPlay->WasShiftDown();
391 pauseDown = mPause->IsDown();
392 recordDown = mRecord->IsDown();
393 recordShift = mRecord->WasShiftDown();
394 loopDown = mLoop->IsDown();
395 Detach( mSizer );
396
397 std::unique_ptr < wxSizer > {mSizer}; // DELETE it
398 mSizer = NULL;
399 }
400
402
403 if (playDown)
404 {
408 SetPlay(playDown, appearance);
409 }
410
411 if (pauseDown)
412 {
413 mPause->PushDown();
414 }
415
416 if (recordDown)
417 {
418 mRecord->SetAlternateIdx(recordShift ? 1 : 0);
419 mRecord->PushDown();
420 }
421
422 if (loopDown)
423 mLoop->PushDown();
424
426
428}
void SetPlay(bool down, PlayAppearance appearance=PlayAppearance::Straight)
virtual void ReCreateButtons()
Definition: ToolBar.cpp:533

References ToolBar::Detach(), EnableDisableButtons(), AButton::IsDown(), Looped, mLoop, mPause, mPlay, mRecord, mSizer, AButton::PushDown(), ToolBar::ReCreateButtons(), RegenerateTooltips(), AButton::SetAlternateIdx(), SetPlay(), Straight, and AButton::WasShiftDown().

Referenced by UpdatePrefs().

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

◆ RegenerateTooltips()

void ControlToolBar::RegenerateTooltips ( )
overridevirtual

Implements ToolBar.

Definition at line 224 of file ControlToolBar.cpp.

225{
226#if wxUSE_TOOLTIPS
227 for (long iWinID = ID_PAUSE_BUTTON; iWinID < BUTTON_COUNT; iWinID++)
228 {
229 auto pCtrl = static_cast<AButton*>(this->FindWindow(iWinID));
231 switch (iWinID)
232 {
233 case ID_PLAY_BUTTON:
234 // Without shift
235 name = wxT("DefaultPlayStop");
236 break;
237 case ID_RECORD_BUTTON:
238 // Without shift
239 //name = wxT("Record");
240 name = wxT("Record1stChoice");
241 break;
242 case ID_PAUSE_BUTTON:
243 name = wxT("Pause");
244 break;
245 case ID_STOP_BUTTON:
246 name = wxT("Stop");
247 break;
248 case ID_FF_BUTTON:
249 name = wxT("CursProjectEnd");
250 break;
251 case ID_REW_BUTTON:
252 name = wxT("CursProjectStart");
253 break;
254 case ID_LOOP_BUTTON:
255 name = wxT("TogglePlayRegion");
256 break;
257 }
258 std::vector<ComponentInterfaceSymbol> commands(
259 1u, { name, Verbatim( pCtrl->GetLabel() ) } );
260
261 // Some have a second
262 switch (iWinID)
263 {
264 case ID_PLAY_BUTTON:
265 // With shift
266 commands.push_back( { wxT("OncePlayStop"), XO("Play Once") } );
267 break;
268 case ID_RECORD_BUTTON:
269 // With shift
270 { bool bPreferNewTrack;
271 gPrefs->Read("/GUI/PreferNewTrackRecord",&bPreferNewTrack, false);
272 // For the shortcut tooltip.
273 commands.push_back( {
274 wxT("Record2ndChoice"),
275 !bPreferNewTrack
276 ? XO("Record New Track")
277 : XO("Append Record")
278 } );
279 }
280 break;
281 case ID_PAUSE_BUTTON:
282 break;
283 case ID_STOP_BUTTON:
284 break;
285 case ID_FF_BUTTON:
286 // With shift
287 commands.push_back( {
288 wxT("SelEnd"), XO("Select to End") } );
289 break;
290 case ID_REW_BUTTON:
291 // With shift
292 commands.push_back( {
293 wxT("SelStart"), XO("Select to Start") } );
294 break;
295 }
297 mProject, *pCtrl, commands.data(), commands.size());
298 }
299#endif
300}
const TranslatableString name
Definition: Distortion.cpp:76
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
A wxButton with mouse-over behaviour.
Definition: AButton.h:104
size_t size() const
How many attachment pointers are in the Site.
Definition: ClientData.h:251
static void SetButtonToolTip(AudacityProject &project, AButton &button, const ComponentInterfaceSymbol commands[], size_t nCommands)
Definition: ToolBar.cpp:970

References BUTTON_COUNT, gPrefs, ID_FF_BUTTON, ID_LOOP_BUTTON, ID_PAUSE_BUTTON, ID_PLAY_BUTTON, ID_RECORD_BUTTON, ID_REW_BUTTON, ID_STOP_BUTTON, ToolBar::mProject, name, ToolBar::SetButtonToolTip(), ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::size(), Verbatim(), wxT(), and XO().

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

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

◆ Repaint()

void ControlToolBar::Repaint ( wxDC *  dc)
overridevirtual

Implements ToolBar.

Definition at line 430 of file ControlToolBar.cpp.

431{
432#ifndef USE_AQUA_THEME
433 wxSize s = mSizer->GetSize();
434 wxPoint p = mSizer->GetPosition();
435
436 wxRect bevelRect( p.x, p.y, s.GetWidth() - 1, s.GetHeight() - 1 );
437 AColor::Bevel( *dc, true, bevelRect );
438#endif
439}
static void Bevel(wxDC &dc, bool up, const wxRect &r)
Definition: AColor.cpp:266

References AColor::Bevel(), and mSizer.

Here is the call graph for this function:

◆ SetPlay()

void ControlToolBar::SetPlay ( bool  down,
PlayAppearance  appearance = PlayAppearance::Straight 
)

Definition at line 471 of file ControlToolBar.cpp.

472{
473 if (down) {
474 mPlay->SetShift(appearance == PlayAppearance::Looped);
476 mPlay->SetAlternateIdx(static_cast<int>(appearance));
477 mPlay->PushDown();
478 }
479 else {
480 mPlay->PopUp();
482 }
484}
void SetShift(bool shift)
Definition: AButton.cpp:606
void SetControl(bool control)
Definition: AButton.cpp:611

References CutPreview, EnableDisableButtons(), Looped, mPlay, AButton::PopUp(), AButton::PushDown(), AButton::SetAlternateIdx(), AButton::SetControl(), and AButton::SetShift().

Referenced by ReCreateButtons().

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

◆ SetStop()

void ControlToolBar::SetStop ( )

Definition at line 486 of file ControlToolBar.cpp.

487{
488 mStop->PushDown();
490}

References EnableDisableButtons(), mStop, and AButton::PushDown().

Referenced by OnKeyEvent().

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

◆ StartScrolling()

void ControlToolBar::StartScrolling ( )

Definition at line 747 of file ControlToolBar.cpp.

748{
750 const auto project = &mProject;
751 if (project) {
752 auto mode = Mode::Pinned;
753
754#if 0
755 // Enable these lines to pin the playhead right instead of center,
756 // when recording but not overdubbing.
757 auto gAudioIO = AudioIO::Get();
758 if (gAudioIO->GetNumCaptureChannels() > 0) {
759 // recording
760
761 // Display a fixed recording head while scrolling the waves continuously.
762 // If you overdub, you may want to anticipate some context in existing tracks,
763 // so center the head. If not, put it rightmost to display as much wave as we can.
764 bool duplex;
765#ifdef EXPERIMENTAL_DA
766 gPrefs->Read(wxT("/AudioIO/Duplex"), &duplex, false);
767#else
768 gPrefs->Read(wxT("/AudioIO/Duplex"), &duplex, true);
769#endif
770 if (duplex) {
771 // See if there is really anything being overdubbed
772 if (gAudioIO->GetNumPlaybackChannels() == 0)
773 // No.
774 duplex = false;
775 }
776
777 if (!duplex)
778 mode = Mode::Right;
779 }
780#endif
781
783 }
784}
PlaybackScroller & GetPlaybackScroller()

References ProjectWindow::PlaybackScroller::Activate(), AudioIO::Get(), ProjectWindow::Get(), ProjectWindow::GetPlaybackScroller(), gPrefs, ToolBar::mProject, and wxT().

Referenced by StartScrollingIfPreferred().

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

◆ StartScrollingIfPreferred()

void ControlToolBar::StartScrollingIfPreferred ( )

Definition at line 729 of file ControlToolBar.cpp.

730{
731 if ( Scrubber::Get( mProject ).IsTransportingPinned() )
733#ifdef __WXMAC__
734 else if (Scrubber::Get( mProject ).HasMark()) {
735 // PRL: cause many "unnecessary" refreshes. For reasons I don't understand,
736 // doing this causes wheel rotation events (mapped from the double finger vertical
737 // swipe) to be delivered more uniformly to the application, so that speed control
738 // works better.
741 }
742#endif
743 else
745}

References ProjectWindow::PlaybackScroller::Activate(), ProjectWindow::Get(), Scrubber::Get(), ProjectWindow::GetPlaybackScroller(), ToolBar::mProject, ProjectWindow::PlaybackScroller::Refresh, StartScrolling(), and StopScrolling().

Referenced by OnIdle().

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

◆ StateForStatusBar()

TranslatableString ControlToolBar::StateForStatusBar ( )
private

Definition at line 700 of file ControlToolBar.cpp.

701{
702 TranslatableString state;
703 auto &projectAudioManager = ProjectAudioManager::Get( mProject );
704
705 auto pProject = &mProject;
706 auto scrubState = pProject
709 if (!scrubState.empty())
710 state = scrubState;
711 else if (mPlay->IsDown())
712 state = sStatePlay;
713 else if (projectAudioManager.Recording())
714 state = sStateRecord;
715 else
716 state = sStateStop;
717
718 return ((mPause->IsDown()) ? XO("%s Paused.") : XO("%s."))
719 .Format( state );
720}
static const TranslatableString sStatePlay
Methods for ControlToolBar.
static const TranslatableString sStateRecord
static const TranslatableString sStateStop
const TranslatableString & GetUntranslatedStateString() const
Holds a msgid for the translation catalog; may also bind format arguments.
TranslatableString & Format(Args &&...args) &
Capture variadic format arguments (by copy) when there is no plural.

References TranslatableString::Format(), ProjectAudioManager::Get(), Scrubber::Get(), Scrubber::GetUntranslatedStateString(), AButton::IsDown(), mPause, mPlay, ToolBar::mProject, sStatePlay, sStateRecord, sStateStop, and XO().

Referenced by UpdateStatusBar().

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

◆ StopScrolling()

void ControlToolBar::StopScrolling ( )

Definition at line 786 of file ControlToolBar.cpp.

References ProjectWindow::PlaybackScroller::Activate(), ProjectWindow::Get(), ProjectWindow::GetPlaybackScroller(), ToolBar::mProject, and ProjectWindow::PlaybackScroller::Off.

Referenced by OnIdle(), and StartScrollingIfPreferred().

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

◆ UpdatePrefs()

void ControlToolBar::UpdatePrefs ( )
overridevirtual

Implements PrefsListener.

Definition at line 302 of file ControlToolBar.cpp.

303{
304 bool updated = false;
305 bool active;
306
307 wxString strLocale = gPrefs->Read(wxT("/Locale/Language"), wxT(""));
308 if (mStrLocale != strLocale)
309 {
310 mStrLocale = strLocale;
311 updated = true;
312 }
313
314 if( updated )
315 {
316 ReCreateButtons(); // side effect: calls RegenerateTooltips()
317 Updated();
318 }
319 else
320 // The other reason to regenerate tooltips is if keyboard shortcuts for
321 // transport buttons changed, but that's too much work to check for, so just
322 // always do it. (Much cheaper than calling ReCreateButtons() in all cases.
324
325
326 // Set label to pull in language change
327 SetLabel(XO("Transport"));
328
329 // Give base class a chance
331}
void ReCreateButtons() override
void SetLabel(const wxString &label) override
Definition: ToolBar.cpp:408
void UpdatePrefs() override
Definition: ToolBar.cpp:622
void Updated()
Definition: ToolBar.cpp:684

References gPrefs, mStrLocale, ReCreateButtons(), RegenerateTooltips(), ToolBar::SetLabel(), ToolBar::Updated(), ToolBar::UpdatePrefs(), wxT(), and XO().

Referenced by Create().

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

◆ UpdateStatusBar()

void ControlToolBar::UpdateStatusBar ( )
private

Definition at line 722 of file ControlToolBar.cpp.

723{
726 );
727}
@ stateStatusBarField
Definition: ProjectStatus.h:25
TranslatableString StateForStatusBar()
static ProjectStatus & Get(AudacityProject &project)
void Set(const TranslatableString &msg, StatusBarField field=mainStatusBarField)

References ProjectStatus::Get(), ToolBar::mProject, ProjectStatus::Set(), StateForStatusBar(), and stateStatusBarField.

Referenced by OnIdle().

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

Member Data Documentation

◆ mFF

AButton* ControlToolBar::mFF
private

Definition at line 114 of file ControlToolBar.h.

Referenced by ArrangeButtons(), EnableDisableButtons(), OnFF(), and Populate().

◆ mLoop

AButton* ControlToolBar::mLoop
private

◆ mPause

AButton* ControlToolBar::mPause
private

◆ mPlay

AButton* ControlToolBar::mPlay
private

◆ mRecord

AButton* ControlToolBar::mRecord
private

◆ mRewind

AButton* ControlToolBar::mRewind
private

Definition at line 109 of file ControlToolBar.h.

Referenced by ArrangeButtons(), EnableDisableButtons(), OnRewind(), and Populate().

◆ mSizer

wxBoxSizer* ControlToolBar::mSizer
private

Definition at line 119 of file ControlToolBar.h.

Referenced by ArrangeButtons(), ControlToolBar(), ReCreateButtons(), and Repaint().

◆ mStop

AButton* ControlToolBar::mStop
private

Definition at line 113 of file ControlToolBar.h.

Referenced by ArrangeButtons(), EnableDisableButtons(), OnIdle(), Populate(), and SetStop().

◆ mStrLocale

wxString ControlToolBar::mStrLocale
private

Definition at line 117 of file ControlToolBar.h.

Referenced by ControlToolBar(), and UpdatePrefs().


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