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

A ToolBar that has the edit buttons on it. More...

#include <EditToolBar.h>

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

Public Member Functions

 EditToolBar (AudacityProject &project)
 
virtual ~EditToolBar ()
 
void Create (wxWindow *parent) override
 
void OnButton (wxCommandEvent &event)
 
void Populate () override
 
void Repaint (wxDC *WXUNUSED(dc)) override
 
void EnableDisableButtons () override
 
void UpdatePrefs () override
 
- Public Member Functions inherited from ToolBar
 ToolBar (AudacityProject &project, const TranslatableString &label, const Identifier &section, bool resizable=false)
 
virtual ~ToolBar ()
 
virtual bool ShownByDefault () const
 Whether the toolbar should be shown by default. Default implementation returns true. More...
 
virtual bool HideAfterReset () const
 Default implementation returns false. More...
 
virtual DockID DefaultDockID () const
 Which dock the toolbar defaults into. Default implementation chooses the top dock. More...
 
bool AcceptsFocus () const override
 
bool AcceptsFocusFromKeyboard () const override
 
virtual void SetToDefaultSize ()
 
virtual void Create (wxWindow *parent)
 
virtual void EnableDisableButtons ()=0
 
virtual void ReCreateButtons ()
 
void UpdatePrefs () override
 
virtual void RegenerateTooltips ()=0
 
int GetIndex () const
 Get a value used for computing cascading positions of undocked bars. More...
 
void SetIndex (int index)
 Set a value used for computing cascading positions of undocked bars. More...
 
TranslatableString GetTitle ()
 
TranslatableString GetLabel ()
 
Identifier GetSection ()
 
ToolDockGetDock ()
 
void SetPreferredNeighbors (Identifier left, Identifier top={})
 
void SetLabel (const TranslatableString &label)
 
virtual void SetDocked (ToolDock *dock, bool pushed)
 
std::pair< Identifier, IdentifierPreferredNeighbors () const noexcept
 Defaults to (NoBarID, NoBarId) More...
 
virtual bool Expose (bool show=true)
 
bool IsResizable () const
 
bool IsVisible () const
 
bool IsDocked () const
 
bool IsPositioned ()
 
void SetVisible (bool bVisible)
 
void SetPositioned ()
 
virtual int GetInitialWidth ()
 Resizable toolbars should implement these. More...
 
virtual int GetMinToolbarWidth ()
 
virtual wxSize GetDockedSize ()
 
wxSize GetSmartDockedSize ()
 
virtual void ResizingDone ()
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
void SetLabel (const TranslatableString &label)
 
void SetName (const TranslatableString &name)
 
void SetToolTip (const TranslatableString &toolTip)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Static Public Member Functions

static Identifier ID ()
 
- Static Public Member Functions inherited from ToolBar
static AButtonMakeButton (wxWindow *parent, teBmps eUp, teBmps eDown, teBmps eHilite, teBmps eDownHi, teBmps eStandardUp, teBmps eStandardDown, teBmps eDisabled, wxWindowID id, wxPoint placement, bool processdownevents, wxSize size)
 
static AButtonMakeButton (ToolBar *parent, teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, int id, bool processdownevents, const TranslatableString &label)
 
static void MakeAlternateImages (AButton &button, int idx, teBmps eUp, teBmps eDown, teBmps eHilite, teBmps eDownHi, teBmps eStandardUp, teBmps eStandardDown, teBmps eDisabled, wxSize size)
 
static void SetButtonToolTip (AudacityProject &project, AButton &button, const ComponentInterfaceSymbol commands[], size_t nCommands)
 
static void MakeButtonBackgroundsSmall ()
 
static void MakeButtonBackgroundsLarge ()
 

Private Member Functions

void AddButton (teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, int id, const TranslatableString &label, bool toggle=false)
 
void AddSeparator ()
 
void RegenerateTooltips () override
 

Private Attributes

ToolBarButtons mButtons
 
wxGridSizer * mToolSizer
 

Additional Inherited Members

- Public Types inherited from ToolBar
enum  DockID { TopDockID = 1 , BotDockID = 2 }
 Identifies one of the docking areas for toolbars. More...
 
using Holder = wxWindowPtr< ToolBar >
 
- Protected Member Functions inherited from ToolBar
void SetButton (bool down, AButton *button)
 
wxBoxSizer * GetSizer ()
 
void Add (wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
 
void Add (wxSizer *sizer, int proportion=0, int flag=0, int border=0, wxObject *userData=NULL)
 
void Add (int width, int height, int proportion=0, int flag=0, int border=0, wxObject *userData=NULL)
 
void AddSpacer (int size=14)
 
void AddStretchSpacer (int prop=1)
 
void Detach (wxWindow *window)
 
void Detach (wxSizer *sizer)
 
void Updated ()
 
int GetResizeGrabberWidth ()
 Returns the width in pixels of the resizer element. More...
 
virtual void Populate ()=0
 
virtual void Repaint (wxDC *dc)=0
 
void OnErase (wxEraseEvent &event)
 
void OnPaint (wxPaintEvent &event)
 
void OnMouseEvents (wxMouseEvent &event)
 
- Protected Member Functions inherited from PrefsListener
virtual void UpdateSelectedPrefs (int id)
 
 PrefsListener ()
 
virtual ~PrefsListener ()
 
virtual void UpdatePrefs ()=0
 
- Static Protected Member Functions inherited from ToolBar
static void MakeMacRecoloredImage (teBmps eBmpOut, teBmps eBmpIn)
 
static void MakeMacRecoloredImageSize (teBmps eBmpOut, teBmps eBmpIn, const wxSize &size)
 
static void MakeRecoloredImage (teBmps eBmpOut, teBmps eBmpIn)
 
static void MakeRecoloredImageSize (teBmps eBmpOut, teBmps eBmpIn, const wxSize &size)
 
- Static Protected Member Functions inherited from PrefsListener
static void Broadcast (int id=0)
 Call this static function to notify all PrefsListener objects. More...
 
- Protected Attributes inherited from ToolBar
AudacityProjectmProject
 
TranslatableString mLabel
 
Identifier mSection
 
int mIndex {0}
 

Detailed Description

A ToolBar that has the edit buttons on it.

This class, which is a child of Toolbar, creates the window containing interfaces to commonly-used edit functions that are otherwise only available through menus. 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 30 of file EditToolBar.h.

Constructor & Destructor Documentation

◆ EditToolBar()

EditToolBar::EditToolBar ( AudacityProject project)

Definition at line 127 of file EditToolBar.cpp.

128: ToolBar(project, XO("Edit"), ID())
130{
131#ifdef OPTION_SYNC_LOCK_BUTTON
132 auto action = [this]() {
133 bool bSyncLockTracks = SyncLockTracks.Read();
134
135 if (bSyncLockTracks)
136 mButtons.PushDown(ETBSyncLockID);
137 else
138 mButtons.PopUp(ETBSyncLockID);
139 };
140
142#endif
143}
@ ETBNumButtons
Definition: EditToolBar.cpp:81
static const ToolBarButtons::ButtonList EditToolbarButtonList
Definition: EditToolBar.cpp:90
constexpr int first_ETB_ID
Definition: EditToolBar.cpp:88
XO("Cut/Copy/Paste")
BoolSetting SyncLockTracks
Definition: SyncLock.cpp:173
const auto project
ToolBarButtons mButtons
Definition: EditToolBar.h:58
static Identifier ID()
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:207
void SetCustomEnableDisableButtonsAction(std::function< void()> action)
void PopUp(int id)
void PushDown(int id)
ToolBar(AudacityProject &project, const TranslatableString &label, const Identifier &section, bool resizable=false)
Definition: ToolBar.cpp:328

References mButtons, ToolBarButtons::PopUp(), ToolBarButtons::PushDown(), Setting< T >::Read(), ToolBarButtons::SetCustomEnableDisableButtonsAction(), and SyncLockTracks.

Here is the call graph for this function:

◆ ~EditToolBar()

EditToolBar::~EditToolBar ( )
virtual

Definition at line 145 of file EditToolBar.cpp.

146{
147}

Member Function Documentation

◆ AddButton()

void EditToolBar::AddButton ( teBmps  eEnabledUp,
teBmps  eEnabledDown,
teBmps  eDisabled,
int  id,
const TranslatableString label,
bool  toggle = false 
)
private

Definition at line 160 of file EditToolBar.cpp.

163{
164 auto r = mButtons.CreateButton(eEnabledUp, eEnabledDown, eDisabled, id, label, toggle);
165 mToolSizer->Add(r);
166}
TranslatableString label
Definition: TagsEditor.cpp:165
wxGridSizer * mToolSizer
Definition: EditToolBar.h:59
AButton * CreateButton(teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, int id, const TranslatableString &label, bool toggle=false)

References ToolBarButtons::CreateButton(), label, mButtons, and mToolSizer.

Referenced by Populate().

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

◆ AddSeparator()

void EditToolBar::AddSeparator ( )
private

Definition at line 155 of file EditToolBar.cpp.

156{
157 mToolSizer->AddSpacer(0);
158}

References mToolSizer.

Referenced by Populate().

Here is the caller graph for this function:

◆ Create()

void EditToolBar::Create ( wxWindow *  parent)
overridevirtual

Reimplemented from ToolBar.

Definition at line 149 of file EditToolBar.cpp.

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

Implements ToolBar.

Definition at line 242 of file EditToolBar.cpp.

243{
245}
void EnableDisableButtons()

References ToolBarButtons::EnableDisableButtons(), and mButtons.

Here is the call graph for this function:

◆ ID()

static Identifier EditToolBar::ID ( )
static

◆ OnButton()

void EditToolBar::OnButton ( wxCommandEvent &  event)

Definition at line 247 of file EditToolBar.cpp.

248{
249 mButtons.OnButton(event);
250}
void OnButton(wxCommandEvent &event)

References mButtons, and ToolBarButtons::OnButton().

Here is the call graph for this function:

◆ Populate()

void EditToolBar::Populate ( )
overridevirtual

Implements ToolBar.

Definition at line 168 of file EditToolBar.cpp.

169{
170 SetBackgroundColour( theTheme.Colour( clrMedium ) );
172
173 Add(mToolSizer = safenew wxGridSizer(2, 5, 1, 1));
174
175 /* Buttons */
176 // Tooltips match menu entries.
177 // We previously had longer tooltips which were not more clear.
178 AddButton(bmpZoomIn, bmpZoomIn, bmpZoomInDisabled, ETBZoomInID,
179 XO("Zoom In"));
180 AddButton(bmpZoomOut, bmpZoomOut, bmpZoomOutDisabled, ETBZoomOutID,
181 XO("Zoom Out"));
182 AddButton(bmpZoomSel, bmpZoomSel, bmpZoomSelDisabled, ETBZoomSelID,
183 XO("Zoom to Selection"));
184 AddButton(bmpZoomFit, bmpZoomFit, bmpZoomFitDisabled, ETBZoomFitID,
185 XO("Fit to Width"));
186
187#ifdef EXPERIMENTAL_ZOOM_TOGGLE_BUTTON
188 AddButton(bmpZoomToggle, bmpZoomToggle, bmpZoomToggleDisabled, ETBZoomToggleID,
189 XO("Zoom Toggle"));
190#endif
191
192 // Tooltips slightly more verbose than the menu entries are.
193 AddButton(bmpTrim, bmpTrim, bmpTrimDisabled, ETBTrimID,
194 XO("Trim audio outside selection"));
195 AddButton(bmpSilence, bmpSilence, bmpSilenceDisabled, ETBSilenceID,
196 XO("Silence audio selection"));
197
198#ifdef OPTION_SYNC_LOCK_BUTTON
199 AddButton(bmpSyncLockTracksUp, bmpSyncLockTracksDown, bmpSyncLockTracksUp, ETBSyncLockID,
200 XO("Sync-Lock Tracks"), true);
201#else
202 AddSeparator();
203#endif
204
205 AddButton(bmpUndo, bmpUndo, bmpUndoDisabled, ETBUndoID,
206 XO("Undo"));
207 AddButton(bmpRedo, bmpRedo, bmpRedoDisabled, ETBRedoID,
208 XO("Redo"));
209
212#ifdef EXPERIMENTAL_ZOOM_TOGGLE_BUTTON
213 mButtons.SetEnabled(ETBZoomToggleID, false);
214#endif
215
218
219#ifdef OPTION_SYNC_LOCK_BUTTON
220 mButtons.PushDown(ETBSyncLockID);
221#endif
222
224}
@ ETBZoomInID
Definition: EditToolBar.cpp:59
@ ETBRedoID
Definition: EditToolBar.cpp:79
@ ETBZoomSelID
Definition: EditToolBar.cpp:65
@ ETBUndoID
Definition: EditToolBar.cpp:78
@ ETBZoomOutID
Definition: EditToolBar.cpp:60
@ ETBTrimID
Definition: EditToolBar.cpp:68
@ ETBSilenceID
Definition: EditToolBar.cpp:69
@ ETBZoomFitID
Definition: EditToolBar.cpp:66
#define safenew
Definition: MemoryX.h:9
THEME_API Theme theTheme
Definition: Theme.cpp:82
void RegenerateTooltips() override
void AddButton(teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, int id, const TranslatableString &label, bool toggle=false)
void AddSeparator()
wxColour & Colour(int iIndex)
void SetEnabled(int id, bool state)
void Add(wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
Definition: ToolBar.cpp:709
static void MakeButtonBackgroundsSmall()
Definition: ToolBar.cpp:837

References ToolBar::Add(), AddButton(), AddSeparator(), ThemeBase::Colour(), ETBRedoID, ETBSilenceID, ETBTrimID, ETBUndoID, ETBZoomFitID, ETBZoomInID, ETBZoomOutID, ETBZoomSelID, ToolBar::MakeButtonBackgroundsSmall(), mButtons, mToolSizer, ToolBarButtons::PushDown(), RegenerateTooltips(), safenew, ToolBarButtons::SetEnabled(), theTheme, and XO().

Here is the call graph for this function:

◆ RegenerateTooltips()

void EditToolBar::RegenerateTooltips ( )
overrideprivatevirtual

Implements ToolBar.

Definition at line 237 of file EditToolBar.cpp.

238{
240}

References mButtons, and ToolBarButtons::RegenerateTooltips().

Referenced by Populate(), and UpdatePrefs().

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

◆ Repaint()

void EditToolBar::Repaint ( wxDC *  WXUNUSEDdc)
inlineoverride

Definition at line 44 of file EditToolBar.h.

44{};

◆ UpdatePrefs()

void EditToolBar::UpdatePrefs ( )
overridevirtual

Implements PrefsListener.

Definition at line 226 of file EditToolBar.cpp.

227{
229
230 // Set label to pull in language change
231 SetLabel(XO("Edit"));
232
233 // Give base class a chance
235}
void SetLabel(const wxString &label) override
Definition: ToolBar.cpp:408
void UpdatePrefs() override
Definition: ToolBar.cpp:622

References RegenerateTooltips(), ToolBar::SetLabel(), ToolBar::UpdatePrefs(), and XO().

Referenced by Create().

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

Member Data Documentation

◆ mButtons

ToolBarButtons EditToolBar::mButtons
private

◆ mToolSizer

wxGridSizer* EditToolBar::mToolSizer
private

Definition at line 59 of file EditToolBar.h.

Referenced by AddButton(), AddSeparator(), and Populate().


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