Audacity 3.2.0
Public Types | Public Member Functions | Static Public Member Functions | Private Types | 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 ()
 

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

140: ToolBar(project, XO("Transport"), ID())
141{
142 mStrLocale = gPrefs->Read(wxT("/Locale/Language"), wxT(""));
143
144 mSizer = NULL;
145}
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 147 of file ControlToolBar.cpp.

148{
149}

Member Function Documentation

◆ ArrangeButtons()

void ControlToolBar::ArrangeButtons ( )
private

Definition at line 388 of file ControlToolBar.cpp.

389{
390 // (Re)allocate the button sizer
391 if( mSizer )
392 {
393 Detach( mSizer );
394 std::unique_ptr < wxSizer > {mSizer}; // DELETE it
395 }
396
397 Add((mSizer = safenew wxBoxSizer(wxHORIZONTAL)), 1, wxEXPAND | wxALL, 5);
398
399 // Establish correct tab key sequence with mLoop last
400 mPause->MoveBeforeInTabOrder( mLoop );
401 mPlay->MoveBeforeInTabOrder( mLoop );
402 mStop->MoveBeforeInTabOrder( mLoop );
403 mRewind->MoveBeforeInTabOrder( mLoop );
404 mFF->MoveBeforeInTabOrder( mLoop );
405 mRecord->MoveBeforeInTabOrder( mLoop );
406
407 mSizer->Add( mPause, 0, wxRIGHT, 4 );
408 mSizer->Add( mPlay, 0, wxRIGHT, 4 );
409 mSizer->Add( mStop, 0, wxRIGHT, 4 );
410 mSizer->Add( mRewind, 0, wxRIGHT, 4 );
411 mSizer->Add( mFF, 0, wxRIGHT, 8 );
412 mSizer->Add( mRecord, 0, wxRIGHT, 8 );
413 mSizer->Add( mLoop );
414
415 // Layout the sizer
416 mSizer->Layout();
417
418 // Layout the toolbar
419 Layout();
420
421 // (Re)Establish the minimum size
422 SetMinSize( GetSizer()->GetMinSize() );
423}
#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 171 of file ControlToolBar.cpp.

172{
173 ToolBar::Create(parent);
174 UpdatePrefs();
175}
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 485 of file ControlToolBar.cpp.

486{
488 auto &projectAudioManager = ProjectAudioManager::Get( mProject );
489 bool canStop = projectAudioManager.CanStopAudioStream();
490
491 bool paused = mPause->IsDown();
492 bool playing = mPlay->IsDown();
493 bool recording = mRecord->IsDown();
494 auto gAudioIO = AudioIO::Get();
495 bool busy = gAudioIO->IsBusy();
496
497 // Only interested in audio type tracks
498 bool tracks = p && TrackList::Get(*p).Any<AudioTrack>(); // PRL: PlayableTrack ?
499
500 mPlay->SetEnabled( canStop && tracks && !recording );
502 canStop &&
503 !(busy && !recording && !paused) &&
504 !(playing && !paused)
505 );
506 mStop->SetEnabled(canStop && (playing || recording));
507 mRewind->SetEnabled(paused || (!playing && !recording));
508 mFF->SetEnabled(tracks && (paused || (!playing && !recording)));
509
510 mPause->SetEnabled(canStop);
511
512 mLoop->SetEnabled( !recording );
513}
const auto tracks
bool IsDown()
Definition: AButton.h:226
void SetEnabled(bool state)
Definition: AButton.h:200
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:247
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:950
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:314

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

153{
154 auto &toolManager = ToolManager::Get( project );
155 return static_cast<ControlToolBar*>(
156 toolManager.GetToolBar(ID()));
157}
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 159 of file ControlToolBar.cpp.

160{
161 auto &toolManager = ToolManager::Get( project );
162 return *static_cast<ControlToolBar*>(
163 toolManager.GetToolBar(ID()));
164}

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

167{
168 return Get( const_cast<AudacityProject&>( project )) ;
169}
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 129 of file ControlToolBar.cpp.

130{
131 return wxT("Control");
132}

References wxT().

Referenced by Find(), and Get().

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

708{
709 mFF->PushDown();
710 mFF->PopUp();
711
713
714 {
717 }
718}
void PushDown()
Definition: AButton.cpp:644
void PopUp()
Definition: AButton.cpp:652
bool WasShiftDown()
Definition: AButton.cpp:608
void ScrollToEnd(bool extend)
Definition: Viewport.cpp:541
static Viewport & Get(AudacityProject &project)
Definition: Viewport.cpp:33

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

629{
630 event.Skip();
631
632 if (!wxTheApp->IsActive())
633 return;
634
635 auto &projectAudioManager = ProjectAudioManager::Get( mProject );
636 if ( projectAudioManager.Paused() )
637 mPause->PushDown();
638 else
639 mPause->PopUp();
640
641 bool recording = projectAudioManager.Recording();
642 if (!recording) {
643 mRecord->PopUp();
644 mRecord->SetAlternateIdx( wxGetKeyState(WXK_SHIFT) ? 1 : 0 );
645 }
646 else {
647 mRecord->PushDown();
648 mRecord->SetAlternateIdx( projectAudioManager.Appending() ? 0 : 1 );
649 }
650
651 bool playing = projectAudioManager.Playing();
652 if ( !(playing || Scrubber::Get(mProject).HasMark()) ) {
653 mPlay->PopUp();
655 wxGetKeyState(WXK_CONTROL)
656 ? 2
657 : wxGetKeyState(WXK_SHIFT)
658 ? 1
659 : 0
660 );
661 }
662 else {
663 mPlay->PushDown();
664 // Choose among alternative appearances of the play button, although
665 // options 0 and 1 became non-distinct in 3.1.0
667 projectAudioManager.Cutting()
668 ? 2
669 // : projectAudioManager.Looping()
670 // ? 1
671 : 0
672 );
673 }
674
675 if ( recording || playing )
677 else
679
680 if ( projectAudioManager.Stopping() )
681 mStop->PushDown();
682 else
683 // push-downs of the stop button are only momentary and always pop up now
684 mStop->PopUp();
685
686 if (ViewInfo::Get(mProject).playRegion.Active())
687 mLoop->PushDown();
688 else
689 mLoop->PopUp();
690
693}
void SetAlternateIdx(unsigned idx)
Definition: AButton.cpp:287
void EnableDisableButtons() override
void StartScrollingIfPreferred()
static Scrubber & Get(AudacityProject &project)
Definition: Scrubbing.cpp:186
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 536 of file ControlToolBar.cpp.

537{
538 // PRL: is this handler really ever reached? Is the ControlToolBar ever
539 // focused? Isn't there a global event filter that interprets the spacebar
540 // key (or other key chosen in preferences) and dispatches to DoPlayStop,
541 // according to CommandManager's table, before we come to this redundant
542 // function?
543
544 if (event.ControlDown() || event.AltDown()) {
545 event.Skip();
546 return;
547 }
548
549 auto gAudioIO = AudioIOBase::Get();
550 auto &projectAudioManager = ProjectAudioManager::Get( mProject );
551
552 // Does not appear to be needed on Linux. Perhaps on some other platform?
553 // If so, "!CanStopAudioStream()" should probably apply.
554 if (event.GetKeyCode() == WXK_SPACE) {
555 if ( projectAudioManager.Playing() || projectAudioManager.Recording() ) {
556 SetStop();
557 projectAudioManager.Stop();
558 }
559 else if (!gAudioIO->IsBusy()) {
560 projectAudioManager.PlayCurrentRegion();
561 }
562 return;
563 }
564 event.Skip();
565}
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 618 of file ControlToolBar.cpp.

619{
620 // Toggle the state of the play region lock
621 auto &region = ViewInfo::Get(mProject).playRegion;
622 if (region.Active())
624 else
626}
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 613 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 567 of file ControlToolBar.cpp.

568{
569 auto p = &mProject;
570 auto &projectAudioManager = ProjectAudioManager::Get( mProject );
571 bool canStop = projectAudioManager.CanStopAudioStream();
572
573 if ( !canStop )
574 return;
575
576 projectAudioManager.Stop();
577
578 PlayDefault();
579}

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

603{
604 // TODO: It would be neater if Menu items and Toolbar buttons used the same code for
605 // enabling/disabling, and all fell into the same action routines.
606 // Here instead we reduplicate some logic (from CommandHandler) because it isn't
607 // normally used for buttons.
608
609 bool altAppearance = mRecord->WasShiftDown();
610 ProjectAudioManager::Get( mProject ).OnRecord( altAppearance );
611}
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 695 of file ControlToolBar.cpp.

696{
697 mRewind->PushDown();
698 mRewind->PopUp();
699
701 {
704 }
705}
void ScrollToStart(bool extend)
Definition: Viewport.cpp:523

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

582{
583 auto &projectAudioManager = ProjectAudioManager::Get( mProject );
584 bool canStop = projectAudioManager.CanStopAudioStream();
585
586 if ( canStop ) {
587 projectAudioManager.Stop();
588 }
589}

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

Here is the call graph for this function:

◆ PlayDefault()

void ControlToolBar::PlayDefault ( )

Definition at line 591 of file ControlToolBar.cpp.

592{
593 // Let control-down have precedence over shift state
594 const bool cutPreview = mPlay->WasControlDown();
595 const bool newDefault = !cutPreview &&
598 .PlayCurrentRegion(newDefault, cutPreview);
599}
bool WasControlDown()
Definition: AButton.cpp:613
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 177 of file ControlToolBar.cpp.

178{
179 SetBackgroundColour( theTheme.Colour( clrMedium ) );
181
183 this,
185 XO("Pause"),
186 theTheme.Image(bmpPause),
187 wxNullImage,
188 theTheme.Image(bmpPauseDisabled));
190
192 this,
194 XO("Play"),
195 theTheme.Image(bmpPlay),
196 wxNullImage,
197 theTheme.Image(bmpPlayDisabled));
198 mPlay->SetButtonToggles(true);
200 // 3.1.0 abandoned distinct images for Shift
202 theTheme.Image(bmpCutPreview),
203 wxNullImage,
204 theTheme.Image(bmpCutPreviewDisabled));
206 theTheme.Image(bmpScrub),
207 wxNullImage,
208 theTheme.Image(bmpScrubDisabled));
210 theTheme.Image(bmpSeek),
211 wxNullImage,
212 theTheme.Image(bmpSeekDisabled));
213
214
217 XO("Stop"),
218 theTheme.Image(bmpStop),
219 wxNullImage,
220 theTheme.Image(bmpStopDisabled));
221
224 XO("Skip to Start"),
225 theTheme.Image(bmpRewind),
226 wxNullImage,
227 theTheme.Image(bmpRewindDisabled));
228
231 XO("Skip to End"),
232 theTheme.Image(bmpFFwd),
233 wxNullImage,
234 theTheme.Image(bmpFFwdDisabled));
235
238 XO("Record"),
239 theTheme.Image(bmpRecord),
240 wxNullImage,
241 theTheme.Image(bmpRecordDisabled));
243
244 bool bPreferNewTrack;
245 gPrefs->Read("/GUI/PreferNewTrackRecord",&bPreferNewTrack, false);
246 if( !bPreferNewTrack )
247 {
249 theTheme.Image(bmpRecordBelow),
250 wxNullImage,
251 theTheme.Image(bmpRecordBelowDisabled));
252 }
253 else
254 {
256 theTheme.Image(bmpRecordBeside),
257 wxNullImage,
258 theTheme.Image(bmpRecordBesideDisabled));
259 }
260
264 theTheme.Image(bmpLoop),
265 wxNullImage,
266 theTheme.Image(bmpLoopDisabled));
267 mLoop->SetButtonToggles(true);// this makes it a toggle, like the pause button
268
269#if wxUSE_TOOLTIPS
271 wxToolTip::Enable(true);
272 wxToolTip::SetDelay(1000);
273#endif
274
275 // Set default order and mode
277}
THEME_API Theme theTheme
Definition: Theme.cpp:82
const TranslatableString LoopToggleText
Definition: ViewInfo.cpp:227
void SetButtonToggles(bool toggler)
Definition: AButton.h:232
void SetAlternateIcons(unsigned idx, const wxImage &up, const wxImage &down, const wxImage &disabled)
Definition: AButton.cpp:275
void FollowModifierKeys()
Definition: AButton.cpp:298
void RegenerateTooltips() override
wxColour & Colour(int iIndex)
wxImage & Image(int iIndex)
static void MakeButtonBackgroundsLarge()
Definition: ToolBar.cpp:811
TranslatableString Stripped(unsigned options=MenuCodes) const
non-mutating, constructs another TranslatableString object
AButton * MakeControlToolBarButton(wxWindow *parent, wxWindowID id, const TranslatableString &label, const wxImage &iconUp, const wxImage &iconDown, const wxImage &iconDisabled)

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, ThemeBase::Image(), LoopToggleText, ToolBar::MakeButtonBackgroundsLarge(), anonymous_namespace{ControlToolBar.cpp}::MakeControlToolBarButton(), mFF, mLoop, mPause, mPlay, mRecord, mRewind, mStop, audacity::BasicSettings::Read(), RegenerateTooltips(), AButton::SetAlternateIcons(), AButton::SetButtonToggles(), TranslatableString::Stripped(), theTheme, and XO().

Here is the call graph for this function:

◆ ReCreateButtons()

void ControlToolBar::ReCreateButtons ( )
overridevirtual

Reimplemented from ToolBar.

Definition at line 425 of file ControlToolBar.cpp.

426{
427 bool playDown = false;
428 bool playShift = false;
429 bool pauseDown = false;
430 bool recordDown = false;
431 bool recordShift = false;
432 bool loopDown = false;
433
434 // ToolBar::ReCreateButtons() will get rid of its sizer and
435 // since we've attached our sizer to it, ours will get deleted too
436 // so clean ours up first.
437 if( mSizer )
438 {
439 playDown = mPlay->IsDown();
440 playShift = mPlay->WasShiftDown();
441 pauseDown = mPause->IsDown();
442 recordDown = mRecord->IsDown();
443 recordShift = mRecord->WasShiftDown();
444 loopDown = mLoop->IsDown();
445 Detach( mSizer );
446
447 std::unique_ptr < wxSizer > {mSizer}; // DELETE it
448 mSizer = NULL;
449 }
450
452
453 if (playDown)
454 {
458 SetPlay(playDown, appearance);
459 }
460
461 if (pauseDown)
462 {
463 mPause->PushDown();
464 }
465
466 if (recordDown)
467 {
468 mRecord->SetAlternateIdx(recordShift ? 1 : 0);
469 mRecord->PushDown();
470 }
471
472 if (loopDown)
473 mLoop->PushDown();
474
476
478}
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 279 of file ControlToolBar.cpp.

280{
281#if wxUSE_TOOLTIPS
282 for (long iWinID = ID_PAUSE_BUTTON; iWinID < BUTTON_COUNT; iWinID++)
283 {
284 auto pCtrl = static_cast<AButton*>(this->FindWindow(iWinID));
286 switch (iWinID)
287 {
288 case ID_PLAY_BUTTON:
289 // Without shift
290 name = wxT("DefaultPlayStop");
291 break;
292 case ID_RECORD_BUTTON:
293 // Without shift
294 //name = wxT("Record");
295 name = wxT("Record1stChoice");
296 break;
297 case ID_PAUSE_BUTTON:
298 name = wxT("Pause");
299 break;
300 case ID_STOP_BUTTON:
301 name = wxT("Stop");
302 break;
303 case ID_FF_BUTTON:
304 name = wxT("CursProjectEnd");
305 break;
306 case ID_REW_BUTTON:
307 name = wxT("CursProjectStart");
308 break;
309 case ID_LOOP_BUTTON:
310 name = wxT("TogglePlayRegion");
311 break;
312 }
313 std::vector<ComponentInterfaceSymbol> commands(
314 1u, { name, Verbatim( pCtrl->GetLabel() ) } );
315
316 // Some have a second
317 switch (iWinID)
318 {
319 case ID_PLAY_BUTTON:
320 // With shift
321 commands.push_back( { wxT("OncePlayStop"), XO("Play Once") } );
322 break;
323 case ID_RECORD_BUTTON:
324 // With shift
325 { bool bPreferNewTrack;
326 gPrefs->Read("/GUI/PreferNewTrackRecord",&bPreferNewTrack, false);
327 // For the shortcut tooltip.
328 commands.push_back( {
329 wxT("Record2ndChoice"),
330 !bPreferNewTrack
331 ? XO("Record New Track")
332 : XO("Append Record")
333 } );
334 }
335 break;
336 case ID_PAUSE_BUTTON:
337 break;
338 case ID_STOP_BUTTON:
339 break;
340 case ID_FF_BUTTON:
341 // With shift
342 commands.push_back( {
343 wxT("SelEnd"), XO("Select to End") } );
344 break;
345 case ID_REW_BUTTON:
346 // With shift
347 commands.push_back( {
348 wxT("SelStart"), XO("Select to Start") } );
349 break;
350 }
352 mProject, *pCtrl, commands.data(), commands.size());
353 }
354#endif
355}
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:260
static void SetButtonToolTip(AudacityProject &project, AButton &button, const ComponentInterfaceSymbol commands[], size_t nCommands)
Definition: ToolBar.cpp:934

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

481{
482 // this was used to draw a bevel and can be removed.
483}

◆ SetPlay()

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

Definition at line 515 of file ControlToolBar.cpp.

516{
517 if (down) {
518 mPlay->SetShift(appearance == PlayAppearance::Looped);
520 mPlay->SetAlternateIdx(static_cast<int>(appearance));
521 mPlay->PushDown();
522 }
523 else {
524 mPlay->PopUp();
526 }
528}
void SetShift(bool shift)
Definition: AButton.cpp:673
void SetControl(bool control)
Definition: AButton.cpp:678

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

531{
532 mStop->PushDown();
534}

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

792{
794 const auto project = &mProject;
795 if (project) {
796 auto mode = Mode::Pinned;
797
798#if 0
799 // Enable these lines to pin the playhead right instead of center,
800 // when recording but not overdubbing.
801 auto gAudioIO = AudioIO::Get();
802 if (gAudioIO->GetNumCaptureChannels() > 0) {
803 // recording
804
805 // Display a fixed recording head while scrolling the waves continuously.
806 // If you overdub, you may want to anticipate some context in existing tracks,
807 // so center the head. If not, put it rightmost to display as much wave as we can.
808 bool duplex;
809 gPrefs->Read(wxT("/AudioIO/Duplex"), &duplex, true);
810 if (duplex) {
811 // See if there is really anything being overdubbed
812 if (gAudioIO->GetNumPlaybackChannels() == 0)
813 // No.
814 duplex = false;
815 }
816
817 if (!duplex)
818 mode = Mode::Right;
819 }
820#endif
821
823 }
824}
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 773 of file ControlToolBar.cpp.

774{
775 if ( Scrubber::Get( mProject ).IsTransportingPinned() )
777#ifdef __WXMAC__
778 else if (Scrubber::Get( mProject ).HasMark()) {
779 // PRL: cause many "unnecessary" refreshes. For reasons I don't understand,
780 // doing this causes wheel rotation events (mapped from the double finger vertical
781 // swipe) to be delivered more uniformly to the application, so that speed control
782 // works better.
785 }
786#endif
787 else
789}

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

745{
746 TranslatableString state;
747 auto &projectAudioManager = ProjectAudioManager::Get( mProject );
748
749 auto pProject = &mProject;
750 auto scrubState = pProject
753 if (!scrubState.empty())
754 state = scrubState;
755 else if (mPlay->IsDown())
756 state = sStatePlay;
757 else if (projectAudioManager.Recording())
758 state = sStateRecord;
759 else
760 state = sStateStop;
761
762 return ((mPause->IsDown()) ? XO("%s Paused.") : XO("%s."))
763 .Format( state );
764}
const TranslatableString & GetUntranslatedStateString() const
Definition: Scrubbing.cpp:987
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, anonymous_namespace{ControlToolBar.cpp}::sStatePlay, anonymous_namespace{ControlToolBar.cpp}::sStateRecord, anonymous_namespace{ControlToolBar.cpp}::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 826 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 357 of file ControlToolBar.cpp.

358{
359 bool updated = false;
360 bool active;
361
362 wxString strLocale = gPrefs->Read(wxT("/Locale/Language"), wxT(""));
363 if (mStrLocale != strLocale)
364 {
365 mStrLocale = strLocale;
366 updated = true;
367 }
368
369 if( updated )
370 {
371 ReCreateButtons(); // side effect: calls RegenerateTooltips()
372 Updated();
373 }
374 else
375 // The other reason to regenerate tooltips is if keyboard shortcuts for
376 // transport buttons changed, but that's too much work to check for, so just
377 // always do it. (Much cheaper than calling ReCreateButtons() in all cases.
379
380
381 // Set label to pull in language change
382 SetLabel(XO("Transport"));
383
384 // Give base class a chance
386}
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 766 of file ControlToolBar.cpp.

767{
770 );
771}
StatusBarField StateStatusBarField()
ID of the first field in the status bar. This filed is used to display playback state.
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 108 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 103 of file ControlToolBar.h.

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

◆ mSizer

wxBoxSizer* ControlToolBar::mSizer
private

Definition at line 113 of file ControlToolBar.h.

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

◆ mStop

AButton* ControlToolBar::mStop
private

Definition at line 107 of file ControlToolBar.h.

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

◆ mStrLocale

wxString ControlToolBar::mStrLocale
private

Definition at line 111 of file ControlToolBar.h.

Referenced by ControlToolBar(), and UpdatePrefs().


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