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
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, 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 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
 
wxString mSection
 
int mType
 

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 96 of file ControlToolBar.h.

◆ PlayAppearance

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

Definition at line 60 of file ControlToolBar.h.

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

Constructor & Destructor Documentation

◆ ControlToolBar()

ControlToolBar::ControlToolBar ( AudacityProject project)

Definition at line 115 of file ControlToolBar.cpp.

116: ToolBar(project, TransportBarID, XO("Transport"), wxT("Control"))
117{
118 mStrLocale = gPrefs->Read(wxT("/Locale/Language"), wxT(""));
119
120 mSizer = NULL;
121}
#define XO(s)
Definition: Internat.h:31
FileConfig * gPrefs
Definition: Prefs.cpp:71
@ TransportBarID
Definition: ToolBar.h:72
wxString mStrLocale
wxBoxSizer * mSizer
ToolBar(AudacityProject &project, int type, const TranslatableString &label, const wxString &section, bool resizable=false)
Definition: ToolBar.cpp:330

References gPrefs.

◆ ~ControlToolBar()

ControlToolBar::~ControlToolBar ( )
virtual

Definition at line 123 of file ControlToolBar.cpp.

124{
125}

Member Function Documentation

◆ ArrangeButtons()

void ControlToolBar::ArrangeButtons ( )
private

Definition at line 332 of file ControlToolBar.cpp.

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

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

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

◆ EnableDisableButtons()

void ControlToolBar::EnableDisableButtons ( )
overridevirtual

Implements ToolBar.

Definition at line 440 of file ControlToolBar.cpp.

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

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 128 of file ControlToolBar.cpp.

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

References ToolManager::Get(), and TransportBarID.

Here is the call graph for this function:

◆ Get() [1/2]

ControlToolBar & ControlToolBar::Get ( AudacityProject project)
static

Definition at line 135 of file ControlToolBar.cpp.

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

References ToolManager::Get(), and TransportBarID.

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 142 of file ControlToolBar.cpp.

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

References Get().

Here is the call graph for this function:

◆ MakeAlternateImages()

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

Definition at line 154 of file ControlToolBar.cpp.

158{
160 bmpRecoloredUpLarge, bmpRecoloredDownLarge, bmpRecoloredUpHiliteLarge, bmpRecoloredHiliteLarge,
161 eEnabledUp, eEnabledDown, eDisabled,
162 theTheme.ImageSize( bmpRecoloredUpLarge ));
163}
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:922

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 662 of file ControlToolBar.cpp.

663{
664 mFF->PushDown();
665 mFF->PopUp();
666
668
669 {
672 }
673}
void PushDown()
Definition: AButton.cpp:597
void PopUp()
Definition: AButton.cpp:605
bool WasShiftDown()
Definition: AButton.cpp:561
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 583 of file ControlToolBar.cpp.

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

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

574{
575 // Toggle the state of the play region lock
576 auto &region = ViewInfo::Get(mProject).playRegion;
577 if (region.Active())
579 else
581}
PlayRegion playRegion
Definition: ViewInfo.h:217
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 568 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 522 of file ControlToolBar.cpp.

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

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 557 of file ControlToolBar.cpp.

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

651{
652 mRewind->PushDown();
653 mRewind->PopUp();
654
656 {
659 }
660}
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 536 of file ControlToolBar.cpp.

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

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

Here is the call graph for this function:

◆ PlayDefault()

void ControlToolBar::PlayDefault ( )

Definition at line 546 of file ControlToolBar.cpp.

547{
548 // Let control-down have precedence over shift state
549 const bool cutPreview = mPlay->WasControlDown();
550 const bool newDefault = !cutPreview &&
553 .PlayCurrentRegion(newDefault, cutPreview);
554}
bool WasControlDown()
Definition: AButton.cpp:566
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 165 of file ControlToolBar.cpp.

166{
167 SetBackgroundColour( theTheme.Colour( clrMedium ) );
169
170 mPause = MakeButton(this, bmpPause, bmpPause, bmpPauseDisabled,
171 ID_PAUSE_BUTTON, true, XO("Pause"));
172
173 mPlay = MakeButton(this, bmpPlay, bmpPlay, bmpPlayDisabled,
174 ID_PLAY_BUTTON, true, XO("Play"));
175 // 3.1.0 abandoned distinct images for Shift
176 MakeAlternateImages(*mPlay, 1, bmpPlay, bmpPlay, bmpPlayDisabled);
178 bmpCutPreview, bmpCutPreview, bmpCutPreviewDisabled);
180 bmpScrub, bmpScrub, bmpScrubDisabled);
182 bmpSeek, bmpSeek, bmpSeekDisabled);
184
185 mStop = MakeButton(this, bmpStop, bmpStop, bmpStopDisabled ,
186 ID_STOP_BUTTON, false, XO("Stop"));
187
188 mRewind = MakeButton(this, bmpRewind, bmpRewind, bmpRewindDisabled,
189 ID_REW_BUTTON, false, XO("Skip to Start"));
190
191 mFF = MakeButton(this, bmpFFwd, bmpFFwd, bmpFFwdDisabled,
192 ID_FF_BUTTON, false, XO("Skip to End"));
193
194 mRecord = MakeButton(this, bmpRecord, bmpRecord, bmpRecordDisabled,
195 ID_RECORD_BUTTON, false, XO("Record"));
196
197 bool bPreferNewTrack;
198 gPrefs->Read("/GUI/PreferNewTrackRecord",&bPreferNewTrack, false);
199 if( !bPreferNewTrack )
200 MakeAlternateImages(*mRecord, 1, bmpRecordBelow, bmpRecordBelow,
201 bmpRecordBelowDisabled);
202 else
203 MakeAlternateImages(*mRecord, 1, bmpRecordBeside, bmpRecordBeside,
204 bmpRecordBesideDisabled);
205
207
208 mLoop = MakeButton(this, bmpLoop, bmpLoop, bmpLoopDisabled,
210 true, // this makes it a toggle, like the pause button
212
213#if wxUSE_TOOLTIPS
215 wxToolTip::Enable(true);
216 wxToolTip::SetDelay(1000);
217#endif
218
219 // Set default order and mode
221}
const TranslatableString LoopToggleText
Definition: ViewInfo.cpp:227
void FollowModifierKeys()
Definition: AButton.cpp:330
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:852
static void MakeButtonBackgroundsLarge()
Definition: ToolBar.cpp:788
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 374 of file ControlToolBar.cpp.

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

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 223 of file ControlToolBar.cpp.

224{
225#if wxUSE_TOOLTIPS
226 for (long iWinID = ID_PAUSE_BUTTON; iWinID < BUTTON_COUNT; iWinID++)
227 {
228 auto pCtrl = static_cast<AButton*>(this->FindWindow(iWinID));
230 switch (iWinID)
231 {
232 case ID_PLAY_BUTTON:
233 // Without shift
234 name = wxT("DefaultPlayStop");
235 break;
236 case ID_RECORD_BUTTON:
237 // Without shift
238 //name = wxT("Record");
239 name = wxT("Record1stChoice");
240 break;
241 case ID_PAUSE_BUTTON:
242 name = wxT("Pause");
243 break;
244 case ID_STOP_BUTTON:
245 name = wxT("Stop");
246 break;
247 case ID_FF_BUTTON:
248 name = wxT("CursProjectEnd");
249 break;
250 case ID_REW_BUTTON:
251 name = wxT("CursProjectStart");
252 break;
253 case ID_LOOP_BUTTON:
254 name = wxT("TogglePlayRegion");
255 break;
256 }
257 std::vector<ComponentInterfaceSymbol> commands(
258 1u, { name, Verbatim( pCtrl->GetLabel() ) } );
259
260 // Some have a second
261 switch (iWinID)
262 {
263 case ID_PLAY_BUTTON:
264 // With shift
265 commands.push_back( { wxT("OncePlayStop"), XO("Play Once") } );
266 break;
267 case ID_RECORD_BUTTON:
268 // With shift
269 { bool bPreferNewTrack;
270 gPrefs->Read("/GUI/PreferNewTrackRecord",&bPreferNewTrack, false);
271 // For the shortcut tooltip.
272 commands.push_back( {
273 wxT("Record2ndChoice"),
274 !bPreferNewTrack
275 ? XO("Record New Track")
276 : XO("Append Record")
277 } );
278 }
279 break;
280 case ID_PAUSE_BUTTON:
281 break;
282 case ID_STOP_BUTTON:
283 break;
284 case ID_FF_BUTTON:
285 // With shift
286 commands.push_back( {
287 wxT("SelEnd"), XO("Select to End") } );
288 break;
289 case ID_REW_BUTTON:
290 // With shift
291 commands.push_back( {
292 wxT("SelStart"), XO("Select to Start") } );
293 break;
294 }
296 mProject, *pCtrl, commands.data(), commands.size());
297 }
298#endif
299}
const TranslatableString name
Definition: Distortion.cpp:82
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:25
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:947

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(), 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 429 of file ControlToolBar.cpp.

430{
431#ifndef USE_AQUA_THEME
432 wxSize s = mSizer->GetSize();
433 wxPoint p = mSizer->GetPosition();
434
435 wxRect bevelRect( p.x, p.y, s.GetWidth() - 1, s.GetHeight() - 1 );
436 AColor::Bevel( *dc, true, bevelRect );
437#endif
438}
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 470 of file ControlToolBar.cpp.

471{
472 if (down) {
473 mPlay->SetShift(appearance == PlayAppearance::Looped);
475 mPlay->SetAlternateIdx(static_cast<int>(appearance));
476 mPlay->PushDown();
477 }
478 else {
479 mPlay->PopUp();
481 }
483}
void SetShift(bool shift)
Definition: AButton.cpp:626
void SetControl(bool control)
Definition: AButton.cpp:631

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 485 of file ControlToolBar.cpp.

486{
487 mStop->PushDown();
489}

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 746 of file ControlToolBar.cpp.

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

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

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 728 of file ControlToolBar.cpp.

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

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 699 of file ControlToolBar.cpp.

700{
701 TranslatableString state;
702 auto &projectAudioManager = ProjectAudioManager::Get( mProject );
703
704 auto pProject = &mProject;
705 auto scrubState = pProject
708 if (!scrubState.empty())
709 state = scrubState;
710 else if (mPlay->IsDown())
711 state = sStatePlay;
712 else if (projectAudioManager.Recording())
713 state = sStateRecord;
714 else
715 state = sStateStop;
716
717 return ((mPause->IsDown()) ? XO("%s Paused.") : XO("%s."))
718 .Format( state );
719}
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 785 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 301 of file ControlToolBar.cpp.

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

References gPrefs, mStrLocale, ReCreateButtons(), RegenerateTooltips(), ToolBar::SetLabel(), ToolBar::Updated(), ToolBar::UpdatePrefs(), 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 721 of file ControlToolBar.cpp.

722{
725 );
726}
@ 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 113 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 108 of file ControlToolBar.h.

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

◆ mSizer

wxBoxSizer* ControlToolBar::mSizer
private

Definition at line 118 of file ControlToolBar.h.

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

◆ mStop

AButton* ControlToolBar::mStop
private

Definition at line 112 of file ControlToolBar.h.

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

◆ mStrLocale

wxString ControlToolBar::mStrLocale
private

Definition at line 116 of file ControlToolBar.h.

Referenced by UpdatePrefs().


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