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

114: ToolBar(project, XO("Transport"), ID())
115{
116 mStrLocale = gPrefs->Read(wxT("/Locale/Language"), wxT(""));
117
118 mSizer = NULL;
119}
wxT("CloseDown"))
XO("Cut/Copy/Paste")
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
const auto project
wxString mStrLocale
static Identifier ID()
wxBoxSizer * mSizer
ToolBar(AudacityProject &project, const TranslatableString &label, const Identifier &section, bool resizable=false)
Definition: ToolBar.cpp:328
virtual bool Read(const wxString &key, bool *value) const =0

References gPrefs, mSizer, mStrLocale, audacity::BasicSettings::Read(), and wxT().

Here is the call graph for this function:

◆ ~ControlToolBar()

ControlToolBar::~ControlToolBar ( )
virtual

Definition at line 121 of file ControlToolBar.cpp.

122{
123}

Member Function Documentation

◆ ArrangeButtons()

void ControlToolBar::ArrangeButtons ( )
private

Definition at line 330 of file ControlToolBar.cpp.

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

146{
147 ToolBar::Create(parent);
148 UpdatePrefs();
149}
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 438 of file ControlToolBar.cpp.

439{
441 auto &projectAudioManager = ProjectAudioManager::Get( mProject );
442 bool canStop = projectAudioManager.CanStopAudioStream();
443
444 bool paused = mPause->IsDown();
445 bool playing = mPlay->IsDown();
446 bool recording = mRecord->IsDown();
447 auto gAudioIO = AudioIO::Get();
448 bool busy = gAudioIO->IsBusy();
449
450 // Only interested in audio type tracks
451 bool tracks = p && TrackList::Get(*p).Any<AudioTrack>(); // PRL: PlayableTrack ?
452
453 mPlay->SetEnabled( canStop && tracks && !recording );
455 canStop &&
456 !(busy && !recording && !paused) &&
457 !(playing && !paused)
458 );
459 mStop->SetEnabled(canStop && (playing || recording));
460 mRewind->SetEnabled(paused || (!playing && !recording));
461 mFF->SetEnabled(tracks && (paused || (!playing && !recording)));
462
463 mPause->SetEnabled(canStop);
464
465 mLoop->SetEnabled( !recording );
466}
const auto tracks
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:126
Track subclass holding data representing sound (as notes, or samples, or ...)
Definition: PlayableTrack.h:21
static ProjectAudioManager & Get(AudacityProject &project)
AudacityProject & mProject
Definition: ToolBar.h:248
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1097
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:347

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

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

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

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

Here is the call graph for this function:

◆ Get() [1/2]

ControlToolBar & ControlToolBar::Get ( AudacityProject project)
static

Definition at line 133 of file ControlToolBar.cpp.

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

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

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

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

References Get(), and project.

Here is the call graph for this function:

◆ ID()

Identifier ControlToolBar::ID ( )
static

Definition at line 103 of file ControlToolBar.cpp.

104{
105 return wxT("Control");
106}

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

156{
158 bmpRecoloredUpLarge, bmpRecoloredDownLarge, bmpRecoloredUpHiliteLarge, bmpRecoloredHiliteLarge,
159 eEnabledUp, eEnabledDown, eDisabled,
160 theTheme.ImageSize( bmpRecoloredUpLarge ));
161}
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 660 of file ControlToolBar.cpp.

661{
662 mFF->PushDown();
663 mFF->PopUp();
664
666
667 {
670 }
671}
void PushDown()
Definition: AButton.cpp:577
void PopUp()
Definition: AButton.cpp:585
bool WasShiftDown()
Definition: AButton.cpp:541
void ScrollToEnd(bool extend)
Definition: Viewport.cpp:536
static Viewport & Get(AudacityProject &project)
Definition: Viewport.cpp:32

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

Here is the call graph for this function:

◆ OnIdle()

void ControlToolBar::OnIdle ( wxIdleEvent &  event)

Definition at line 581 of file ControlToolBar.cpp.

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

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

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

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

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

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

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

649{
650 mRewind->PushDown();
651 mRewind->PopUp();
652
654 {
657 }
658}
void ScrollToStart(bool extend)
Definition: Viewport.cpp:518

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

Here is the call graph for this function:

◆ OnStop()

void ControlToolBar::OnStop ( wxCommandEvent &  evt)

Definition at line 534 of file ControlToolBar.cpp.

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

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

Here is the call graph for this function:

◆ PlayDefault()

void ControlToolBar::PlayDefault ( )

Definition at line 544 of file ControlToolBar.cpp.

545{
546 // Let control-down have precedence over shift state
547 const bool cutPreview = mPlay->WasControlDown();
548 const bool newDefault = !cutPreview &&
551 .PlayCurrentRegion(newDefault, cutPreview);
552}
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 163 of file ControlToolBar.cpp.

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

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

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

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

469{
470 if (down) {
471 mPlay->SetShift(appearance == PlayAppearance::Looped);
473 mPlay->SetAlternateIdx(static_cast<int>(appearance));
474 mPlay->PushDown();
475 }
476 else {
477 mPlay->PopUp();
479 }
481}
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 483 of file ControlToolBar.cpp.

484{
485 mStop->PushDown();
487}

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

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

References ProjectWindow::PlaybackScroller::Activate(), AudioIO::Get(), ProjectWindow::Get(), ProjectWindow::GetPlaybackScroller(), gPrefs, ToolBar::mProject, project, audacity::BasicSettings::Read(), 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 726 of file ControlToolBar.cpp.

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

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

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

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

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

300{
301 bool updated = false;
302 bool active;
303
304 wxString strLocale = gPrefs->Read(wxT("/Locale/Language"), wxT(""));
305 if (mStrLocale != strLocale)
306 {
307 mStrLocale = strLocale;
308 updated = true;
309 }
310
311 if( updated )
312 {
313 ReCreateButtons(); // side effect: calls RegenerateTooltips()
314 Updated();
315 }
316 else
317 // The other reason to regenerate tooltips is if keyboard shortcuts for
318 // transport buttons changed, but that's too much work to check for, so just
319 // always do it. (Much cheaper than calling ReCreateButtons() in all cases.
321
322
323 // Set label to pull in language change
324 SetLabel(XO("Transport"));
325
326 // Give base class a chance
328}
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, audacity::BasicSettings::Read(), 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 719 of file ControlToolBar.cpp.

720{
723 );
724}
@ 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: