Audacity 3.2.0
Public Member Functions | Private Member Functions | Static 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, int type, const TranslatableString &label, const wxString &section, bool resizable=false)
 
virtual ~ToolBar ()
 
bool AcceptsFocus () const override
 
virtual void SetToDefaultSize ()
 
virtual void Create (wxWindow *parent)
 
virtual void EnableDisableButtons ()=0
 
virtual void ReCreateButtons ()
 
void UpdatePrefs () override
 
virtual void RegenerateTooltips ()=0
 
int GetType ()
 
TranslatableString GetTitle ()
 
TranslatableString GetLabel ()
 
wxString GetSection ()
 
ToolDockGetDock ()
 
void SetLabel (const TranslatableString &label)
 
virtual void SetDocked (ToolDock *dock, bool pushed)
 
virtual bool Expose (bool show=true)
 
bool IsResizable () const
 
bool IsVisible () const
 
bool IsDocked () const
 
bool IsPositioned ()
 
void SetVisible (bool bVisible)
 
void SetPositioned ()
 
virtual int GetInitialWidth ()
 Resizable toolbars should implement these. More...
 
virtual int GetMinToolbarWidth ()
 
virtual wxSize GetDockedSize ()
 
wxSize GetSmartDockedSize ()
 
virtual void ResizingDone ()
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
void SetLabel (const TranslatableString &label)
 
void SetName (const TranslatableString &name)
 
void SetToolTip (const TranslatableString &toolTip)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Private Member Functions

void AddSeparator ()
 
void MakeButtons ()
 
void RegenerateTooltips () override
 
void ForAllButtons (int Action)
 

Static Private Member Functions

static AButtonAddButton (EditToolBar *pBar, teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, int id, const TranslatableString &label, bool toggle=false)
 

Private Attributes

AButtonmButtons [ETBNumButtons]
 
wxGridSizer * mToolSizer
 
wxImage * upImage
 
wxImage * downImage
 
wxImage * hiliteImage
 

Additional Inherited Members

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

Detailed Description

A ToolBar that has the 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 65 of file EditToolBar.h.

Constructor & Destructor Documentation

◆ EditToolBar()

EditToolBar::EditToolBar ( AudacityProject project)

◆ ~EditToolBar()

EditToolBar::~EditToolBar ( )
virtual

Definition at line 81 of file EditToolBar.cpp.

82{
83}

Member Function Documentation

◆ AddButton()

AButton * EditToolBar::AddButton ( EditToolBar pBar,
teBmps  eEnabledUp,
teBmps  eEnabledDown,
teBmps  eDisabled,
int  id,
const TranslatableString label,
bool  toggle = false 
)
staticprivate

This is a convenience function that allows for button creation in MakeButtons() with fewer arguments Very similar to code in ControlToolBar...

Definition at line 99 of file EditToolBar.cpp.

105{
106 AButton *&r = pBar->mButtons[id];
107
108 r = ToolBar::MakeButton(pBar,
109 bmpRecoloredUpSmall, bmpRecoloredDownSmall, bmpRecoloredUpHiliteSmall, bmpRecoloredHiliteSmall,
110 eEnabledUp, eEnabledDown, eDisabled,
111 wxWindowID(id+first_ETB_ID),
112 wxDefaultPosition,
113 toggle,
114 theTheme.ImageSize( bmpRecoloredUpSmall ));
115
116 r->SetLabel(label);
117 pBar->mToolSizer->Add(r);
118
119 return r;
120}
const int first_ETB_ID
Definition: EditToolBar.h:57
TranslatableString label
Definition: TagsEditor.cpp:163
THEME_API Theme theTheme
Definition: Theme.cpp:82
int id
A wxButton with mouse-over behaviour.
Definition: AButton.h:25
void SetLabel(const TranslatableString &label)
Definition: AButton.cpp:274
wxGridSizer * mToolSizer
Definition: EditToolBar.h:97
AButton * mButtons[ETBNumButtons]
Definition: EditToolBar.h:95
wxSize ImageSize(int iIndex)
static AButton * MakeButton(wxWindow *parent, teBmps eUp, teBmps eDown, teBmps eHilite, teBmps eDownHi, teBmps eStandardUp, teBmps eStandardDown, teBmps eDisabled, wxWindowID id, wxPoint placement, bool processdownevents, wxSize size)
Definition: ToolBar.cpp:852

References first_ETB_ID, id, ThemeBase::ImageSize(), label, ToolBar::MakeButton(), mButtons, mToolSizer, AButton::SetLabel(), and theTheme.

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

92{
93 mToolSizer->AddSpacer(0);
94}

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 85 of file EditToolBar.cpp.

86{
87 ToolBar::Create(parent);
89}
void UpdatePrefs() override
virtual void Create(wxWindow *parent)
Definition: ToolBar.cpp:475

References ToolBar::Create(), and UpdatePrefs().

Here is the call graph for this function:

◆ EnableDisableButtons()

void EditToolBar::EnableDisableButtons ( )
overridevirtual

Implements ToolBar.

Definition at line 196 of file EditToolBar.cpp.

197{
199}
@ ETBActEnableDisable
Definition: EditToolBar.h:62
void ForAllButtons(int Action)

References ETBActEnableDisable, and ForAllButtons().

Here is the call graph for this function:

◆ ForAllButtons()

void EditToolBar::ForAllButtons ( int  Action)
private

Definition at line 225 of file EditToolBar.cpp.

226{
228 CommandManager* cm = nullptr;
229
231 p = &mProject;
232 cm = &CommandManager::Get( *p );
233#ifdef OPTION_SYNC_LOCK_BUTTON
234 bool bSyncLockTracks;
235 gPrefs->Read(wxT("/GUI/SyncLockTracks"), &bSyncLockTracks, false);
236
237 if (bSyncLockTracks)
238 mButtons[ETBSyncLockID]->PushDown();
239 else
240 mButtons[ETBSyncLockID]->PopUp();
241#endif
242 }
243
244
245 for (const auto &entry : EditToolbarButtonList) {
246#if wxUSE_TOOLTIPS
247 if( Action & ETBActTooltips ){
249 entry.commandName, entry.untranslatedLabel };
251 *mButtons[entry.tool], &command, 1u );
252 }
253#endif
254 if (cm) {
255 mButtons[entry.tool]->SetEnabled(cm->GetEnabled(entry.commandName));
256 }
257 }
258}
static const struct Entry EditToolbarButtonList[]
@ ETBActTooltips
Definition: EditToolBar.h:61
FileConfig * gPrefs
Definition: Prefs.cpp:71
static ProjectFileIORegistry::AttributeWriterEntry entry
void PushDown()
Definition: AButton.cpp:597
void PopUp()
Definition: AButton.cpp:605
void SetEnabled(bool state)
Definition: AButton.h:88
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
CommandManager implements a system for organizing all user-callable commands.
static CommandManager & Get(AudacityProject &project)
bool GetEnabled(const CommandID &name)
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
AudacityProject & mProject
Definition: ToolBar.h:247
static void SetButtonToolTip(AudacityProject &project, AButton &button, const ComponentInterfaceSymbol commands[], size_t nCommands)
Definition: ToolBar.cpp:947
std::function< void()> Action
Definition: BasicUI.h:24

References EditToolbarButtonList, entry, ETBActEnableDisable, ETBActTooltips, CommandManager::Get(), CommandManager::GetEnabled(), gPrefs, mButtons, ToolBar::mProject, AButton::PopUp(), AButton::PushDown(), ToolBar::SetButtonToolTip(), and AButton::SetEnabled().

Referenced by EnableDisableButtons(), and RegenerateTooltips().

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

◆ MakeButtons()

void EditToolBar::MakeButtons ( )
private

◆ OnButton()

void EditToolBar::OnButton ( wxCommandEvent &  event)

Definition at line 260 of file EditToolBar.cpp.

261{
262 int id = event.GetId()-first_ETB_ID;
263 // Be sure the pop-up happens even if there are exceptions, except for buttons which toggle.
264 auto cleanup = finally( [&] { mButtons[id]->InteractionOver();});
265
267 auto &cm = CommandManager::Get( *p );
268
269 auto flags = MenuManager::Get(*p).GetUpdateFlags();
270 const CommandContext context( *p );
272 EditToolbarButtonList[id].commandName, context, flags, false);
273
274#if defined(__WXMAC__)
275 // Bug 2402
276 // LLL: It seems that on the Mac the IDLE events are processed
277 // differently than on Windows/GTK and the AdornedRulerPanel's
278 // OnPaint() method gets called sooner that expected. This is
279 // evident when zooming from this toolbar only. When zooming from
280 // the Menu or from keyboard ommand, the zooming works correctly.
281 wxTheApp->ProcessIdle();
282#endif
283}
bool HandleTextualCommand(CommandManager &commandManager, const CommandID &Str, const CommandContext &context, CommandFlag flags, bool alwaysEnabled)
void InteractionOver()
Definition: AButton.h:122
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
static MenuManager & Get(AudacityProject &project)
Definition: Menus.cpp:71
CommandFlag GetUpdateFlags(bool checkActive=false) const
Definition: Menus.cpp:553

References EditToolbarButtonList, first_ETB_ID, CommandManager::Get(), MenuManager::Get(), MenuManager::GetUpdateFlags(), HandleTextualCommand(), id, AButton::InteractionOver(), mButtons, and ToolBar::mProject.

Here is the call graph for this function:

◆ Populate()

void EditToolBar::Populate ( )
overridevirtual

Implements ToolBar.

Definition at line 122 of file EditToolBar.cpp.

123{
124 SetBackgroundColour( theTheme.Colour( clrMedium ) );
126
127 Add(mToolSizer = safenew wxGridSizer(2, 5, 1, 1));
128
129 /* Buttons */
130 // Tooltips match menu entries.
131 // We previously had longer tooltips which were not more clear.
132 AddButton(this, bmpZoomIn, bmpZoomIn, bmpZoomInDisabled, ETBZoomInID,
133 XO("Zoom In"));
134 AddButton(this, bmpZoomOut, bmpZoomOut, bmpZoomOutDisabled, ETBZoomOutID,
135 XO("Zoom Out"));
136 AddButton(this, bmpZoomSel, bmpZoomSel, bmpZoomSelDisabled, ETBZoomSelID,
137 XO("Zoom to Selection"));
138 AddButton(this, bmpZoomFit, bmpZoomFit, bmpZoomFitDisabled, ETBZoomFitID,
139 XO("Fit to Width"));
140
141#ifdef EXPERIMENTAL_ZOOM_TOGGLE_BUTTON
142 AddButton(this, bmpZoomToggle, bmpZoomToggle, bmpZoomToggleDisabled, ETBZoomToggleID,
143 XO("Zoom Toggle"));
144#endif
145
146 // Tooltips slightly more verbose than the menu entries are.
147 AddButton(this, bmpTrim, bmpTrim, bmpTrimDisabled, ETBTrimID,
148 XO("Trim audio outside selection"));
149 AddButton(this, bmpSilence, bmpSilence, bmpSilenceDisabled, ETBSilenceID,
150 XO("Silence audio selection"));
151
152#ifdef OPTION_SYNC_LOCK_BUTTON
153 AddButton(this, bmpSyncLockTracksUp, bmpSyncLockTracksDown, bmpSyncLockTracksUp, ETBSyncLockID,
154 XO("Sync-Lock Tracks"), true);
155#else
156 AddSeparator();
157#endif
158
159 AddButton(this, bmpUndo, bmpUndo, bmpUndoDisabled, ETBUndoID,
160 XO("Undo"));
161 AddButton(this, bmpRedo, bmpRedo, bmpRedoDisabled, ETBRedoID,
162 XO("Redo"));
163
166#ifdef EXPERIMENTAL_ZOOM_TOGGLE_BUTTON
167 mButtons[ETBZoomToggleID]->SetEnabled(false);
168#endif
169
172
173#ifdef OPTION_SYNC_LOCK_BUTTON
174 mButtons[ETBSyncLockID]->PushDown();
175#endif
176
178}
@ ETBZoomInID
Definition: EditToolBar.h:30
@ ETBRedoID
Definition: EditToolBar.h:52
@ ETBZoomSelID
Definition: EditToolBar.h:36
@ ETBUndoID
Definition: EditToolBar.h:51
@ ETBZoomOutID
Definition: EditToolBar.h:31
@ ETBTrimID
Definition: EditToolBar.h:39
@ ETBSilenceID
Definition: EditToolBar.h:40
@ ETBZoomFitID
Definition: EditToolBar.h:37
#define XO(s)
Definition: Internat.h:31
#define safenew
Definition: MemoryX.h:10
static AButton * AddButton(EditToolBar *pBar, teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, int id, const TranslatableString &label, bool toggle=false)
Definition: EditToolBar.cpp:99
void RegenerateTooltips() override
void AddSeparator()
Definition: EditToolBar.cpp:91
wxColour & Colour(int iIndex)
void Add(wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
Definition: ToolBar.cpp:686
static void MakeButtonBackgroundsSmall()
Definition: ToolBar.cpp:814

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

Here is the call graph for this function:

◆ RegenerateTooltips()

void EditToolBar::RegenerateTooltips ( )
overrideprivatevirtual

Implements ToolBar.

Definition at line 191 of file EditToolBar.cpp.

192{
194}

References ETBActTooltips, and ForAllButtons().

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 77 of file EditToolBar.h.

77{};

◆ UpdatePrefs()

void EditToolBar::UpdatePrefs ( )
overridevirtual

Implements PrefsListener.

Definition at line 180 of file EditToolBar.cpp.

181{
183
184 // Set label to pull in language change
185 SetLabel(XO("Edit"));
186
187 // Give base class a chance
189}
void SetLabel(const wxString &label) override
Definition: ToolBar.cpp:398
void UpdatePrefs() override
Definition: ToolBar.cpp:605

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

◆ downImage

wxImage* EditToolBar::downImage
private

Definition at line 100 of file EditToolBar.h.

◆ hiliteImage

wxImage* EditToolBar::hiliteImage
private

Definition at line 101 of file EditToolBar.h.

◆ mButtons

AButton* EditToolBar::mButtons[ETBNumButtons]
private

Definition at line 95 of file EditToolBar.h.

Referenced by AddButton(), ForAllButtons(), OnButton(), and Populate().

◆ mToolSizer

wxGridSizer* EditToolBar::mToolSizer
private

Definition at line 97 of file EditToolBar.h.

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

◆ upImage

wxImage* EditToolBar::upImage
private

Definition at line 99 of file EditToolBar.h.


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