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

A kind of ToolBar with Tools on it. More...

#include <ToolsToolBar.h>

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

Public Member Functions

 ToolsToolBar (AudacityProject &project)
 
virtual ~ToolsToolBar ()
 
void UpdatePrefs () override
 
void OnTool (wxCommandEvent &evt)
 
void OnToolChanged (ProjectSettingsEvent)
 
void DoToolChanged ()
 
void Populate () override
 
void Repaint (wxDC *WXUNUSED(dc)) override
 
void EnableDisableButtons () 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 ToolsToolBarGet (AudacityProject &project)
 
static const ToolsToolBarGet (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  { numTools = 4 }
 

Private Member Functions

void Create (wxWindow *parent) override
 
void RegenerateTooltips () override
 
wxImageMakeToolImage (wxImage *tool, wxImage *mask, int style)
 

Static Private Member Functions

static AButtonMakeTool (ToolsToolBar *pBar, teBmps eTool, int id, const TranslatableString &label)
 

Private Attributes

Observer::Subscription mSubscription
 
AButtonmTool [numTools]
 
wxGridSizer * mToolSizer
 
int mCurrentTool
 

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 kind of ToolBar with Tools on it.

This class, which is a child of Toolbar, creates the window containing the tool selection (ibeam, envelope, move, zoom). 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.

See also
Themability of Audacity

Definition at line 37 of file ToolsToolBar.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
numTools 

Definition at line 65 of file ToolsToolBar.h.

65{ numTools = 4 };

Constructor & Destructor Documentation

◆ ToolsToolBar()

ToolsToolBar::ToolsToolBar ( AudacityProject project)

Definition at line 78 of file ToolsToolBar.cpp.

79: ToolBar(project, XO("Tools"), ID())
80{
81 using namespace ToolCodes;
82
83 //Read the following wxASSERTs as documentating a design decision
84 wxASSERT( selectTool == selectTool - firstTool );
85 wxASSERT( envelopeTool == envelopeTool - firstTool );
86 wxASSERT( drawTool == drawTool - firstTool );
87 wxASSERT( multiTool == multiTool - firstTool );
88 bool multiToolActive = false;
89 gPrefs->Read(wxT("/GUI/ToolBars/Tools/MultiToolActive"), &multiToolActive);
90
91 if (multiToolActive)
93 else
95
98}
wxT("CloseDown"))
XO("Cut/Copy/Paste")
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
const auto project
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
Definition: Observer.h:199
static ProjectSettings & Get(AudacityProject &project)
ToolBar(AudacityProject &project, const TranslatableString &label, const Identifier &section, bool resizable=false)
Definition: ToolBar.cpp:328
static Identifier ID()
void OnToolChanged(ProjectSettingsEvent)
Observer::Subscription mSubscription
Definition: ToolsToolBar.h:67
virtual bool Read(const wxString &key, bool *value) const =0

References ToolCodes::drawTool, ToolCodes::envelopeTool, ToolCodes::firstTool, ProjectSettings::Get(), gPrefs, mCurrentTool, mSubscription, ToolCodes::multiTool, OnToolChanged(), project, audacity::BasicSettings::Read(), ToolCodes::selectTool, Observer::Publisher< Message, NotifyAll >::Subscribe(), and wxT().

Here is the call graph for this function:

◆ ~ToolsToolBar()

ToolsToolBar::~ToolsToolBar ( )
virtual

Definition at line 100 of file ToolsToolBar.cpp.

101{
102 static_assert(
104 "mismatch in number of tools" );
105}

References ToolCodes::numTools, and numTools.

Member Function Documentation

◆ Create()

void ToolsToolBar::Create ( wxWindow *  parent)
overrideprivatevirtual

Reimplemented from ToolBar.

Definition at line 249 of file ToolsToolBar.cpp.

250{
251 ToolBar::Create(parent);
252 UpdatePrefs();
253}
virtual void Create(wxWindow *parent)
Definition: ToolBar.cpp:492
void UpdatePrefs() override

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

Here is the call graph for this function:

◆ DoToolChanged()

void ToolsToolBar::DoToolChanged ( )

Definition at line 233 of file ToolsToolBar.cpp.

234{
235 auto &projectSettings = ProjectSettings::Get( mProject );
236 using namespace ToolCodes;
237 mCurrentTool = projectSettings.GetTool() - firstTool;
238 for (int i = 0; i < numTools; i++)
239 if (i == mCurrentTool)
240 mTool[i]->PushDown();
241 else
242 mTool[i]->PopUp();
243
244 gPrefs->Write(wxT("/GUI/ToolBars/Tools/MultiToolActive"),
245 mTool[multiTool]->IsDown());
246 gPrefs->Flush();
247}
void PushDown()
Definition: AButton.cpp:577
void PopUp()
Definition: AButton.cpp:585
AudacityProject & mProject
Definition: ToolBar.h:248
AButton * mTool[numTools]
Definition: ToolsToolBar.h:68
virtual bool Flush() noexcept=0
virtual bool Write(const wxString &key, bool value)=0

References ToolCodes::firstTool, audacity::BasicSettings::Flush(), ProjectSettings::Get(), gPrefs, mCurrentTool, ToolBar::mProject, mTool, ToolCodes::multiTool, numTools, AButton::PopUp(), AButton::PushDown(), audacity::BasicSettings::Write(), and wxT().

Referenced by OnToolChanged(), and Populate().

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

◆ EnableDisableButtons()

void ToolsToolBar::EnableDisableButtons ( )
inlineoverridevirtual

Implements ToolBar.

Definition at line 56 of file ToolsToolBar.h.

56{};

◆ Get() [1/2]

ToolsToolBar & ToolsToolBar::Get ( AudacityProject project)
static

Definition at line 107 of file ToolsToolBar.cpp.

108{
109 auto &toolManager = ToolManager::Get( project );
110 return *static_cast<ToolsToolBar*>(toolManager.GetToolBar(ID()));
111}
static ToolManager & Get(AudacityProject &project)
A kind of ToolBar with Tools on it.
Definition: ToolsToolBar.h:37

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

Referenced by Get(), and anonymous_namespace{ToolsToolBar.cpp}::SetTool().

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

◆ Get() [2/2]

const ToolsToolBar & ToolsToolBar::Get ( const AudacityProject project)
static

Definition at line 113 of file ToolsToolBar.cpp.

114{
115 return Get( const_cast<AudacityProject&>( project )) ;
116}
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 ToolsToolBar & Get(AudacityProject &project)

References Get(), and project.

Here is the call graph for this function:

◆ ID()

static Identifier ToolsToolBar::ID ( )
static

Referenced by Get().

Here is the caller graph for this function:

◆ MakeTool()

AButton * ToolsToolBar::MakeTool ( ToolsToolBar pBar,
teBmps  eTool,
int  id,
const TranslatableString label 
)
staticprivate

Definition at line 175 of file ToolsToolBar.cpp.

178{
179 AButton *button = ToolBar::MakeButton(pBar,
180 bmpRecoloredUpSmall,
181 bmpRecoloredDownSmall,
182 bmpRecoloredUpHiliteSmall,
183 bmpRecoloredDownSmall, // Not bmpRecoloredHiliteSmall as down is inactive.
184 eTool, eTool, eTool,
185 wxWindowID(id + FirstToolID),
186 wxDefaultPosition, true,
187 theTheme.ImageSize( bmpRecoloredUpSmall ));
188 button->SetLabel( label );
189 pBar->mToolSizer->Add( button );
190 return button;
191}
TranslatableString label
Definition: TagsEditor.cpp:165
THEME_API Theme theTheme
Definition: Theme.cpp:82
const int FirstToolID
Definition: ToolsToolBar.h:35
A wxButton with mouse-over behaviour.
Definition: AButton.h:104
void SetLabel(const TranslatableString &label)
Definition: AButton.cpp:189
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:875
wxGridSizer * mToolSizer
Definition: ToolsToolBar.h:69

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

Referenced by Populate().

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

◆ MakeToolImage()

wxImage * ToolsToolBar::MakeToolImage ( wxImage tool,
wxImage mask,
int  style 
)
private

◆ OnTool()

void ToolsToolBar::OnTool ( wxCommandEvent &  evt)

Definition at line 213 of file ToolsToolBar.cpp.

214{
215 // This will cause callback to OnToolChanged
216 auto iTool = evt.GetId() - ToolCodes::firstTool - FirstToolID;
217 auto pButton = mTool[iTool];
218 if (pButton->IsDown())
220 else
221 // Don't stay up
222 pButton->PushDown();
223}
void SetTool(int tool)

References ToolCodes::firstTool, FirstToolID, ProjectSettings::Get(), ToolBar::mProject, mTool, and ProjectSettings::SetTool().

Here is the call graph for this function:

◆ OnToolChanged()

void ToolsToolBar::OnToolChanged ( ProjectSettingsEvent  evt)

Definition at line 225 of file ToolsToolBar.cpp.

226{
228 return;
231}
void DoToolChanged()
void Redraw()
Definition: Viewport.cpp:748
static Viewport & Get(AudacityProject &project)
Definition: Viewport.cpp:32
enum ProjectSettingsEvent::Type type

References ProjectSettingsEvent::ChangedTool, DoToolChanged(), Viewport::Get(), ToolBar::mProject, Viewport::Redraw(), and ProjectSettingsEvent::type.

Referenced by ToolsToolBar().

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

◆ Populate()

void ToolsToolBar::Populate ( )
overridevirtual

Implements ToolBar.

Definition at line 194 of file ToolsToolBar.cpp.

195{
196 SetBackgroundColour( theTheme.Colour( clrMedium ) );
198
199 Add(mToolSizer = safenew wxGridSizer(2, 2, 1, 1));
200
201 /* Tools */
202 using namespace ToolCodes;
203 mTool[ selectTool ] = MakeTool( this, bmpIBeam, selectTool, XO("Selection Tool") );
204 mTool[ envelopeTool ] = MakeTool( this, bmpEnvelope, envelopeTool, XO("Envelope Tool") );
205 mTool[ drawTool ] = MakeTool( this, bmpDraw, drawTool, XO("Draw Tool") );
206 mTool[ multiTool ] = MakeTool( this, bmpMulti, multiTool, XO("Multi-Tool") );
207
209
211}
#define safenew
Definition: MemoryX.h:9
wxColour & Colour(int iIndex)
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
static AButton * MakeTool(ToolsToolBar *pBar, teBmps eTool, int id, const TranslatableString &label)
void RegenerateTooltips() override

References ToolBar::Add(), ThemeBase::Colour(), DoToolChanged(), ToolCodes::drawTool, ToolCodes::envelopeTool, ToolBar::MakeButtonBackgroundsSmall(), MakeTool(), mTool, mToolSizer, ToolCodes::multiTool, RegenerateTooltips(), safenew, ToolCodes::selectTool, theTheme, and XO().

Here is the call graph for this function:

◆ RegenerateTooltips()

void ToolsToolBar::RegenerateTooltips ( )
overrideprivatevirtual

Implements ToolBar.

Definition at line 118 of file ToolsToolBar.cpp.

119{
120
121// JKC:
122// Under Win98 Tooltips appear to be buggy, when you have a lot of
123// tooltip messages flying around. I found that just creating a
124// twelfth tooltip caused Audacity to crash when it tried to show
125// any tooltip.
126//
127// Win98 does NOT recover from this crash - for any application which is
128// using tooltips will also crash thereafter... so you must reboot.
129// Rather weird.
130//
131// Getting windows to process more of its stacked up messages seems
132// to workaround the problem. The problem is not fully understood though
133// (as of April 2003).
134
135 // Vaughan, October 2003: Now we're crashing on Win2K if
136 // "Quit when closing last window" is unchecked, when we come back
137 // through here, on either of the wxSafeYield calls.
138 // James confirms that commenting them out does not cause his original problem
139 // to reappear, so they're commented out now.
140 // wxSafeYield(); //Deal with some queued up messages...
141
142 #if wxUSE_TOOLTIPS
143
144 using namespace ToolCodes;
145
146 static const struct Entry {
147 int tool;
148 CommandID commandName;
149 TranslatableString untranslatedLabel;
150 } table[] = {
151 { selectTool, wxT("SelectTool"), XO("Selection Tool") },
152 { envelopeTool, wxT("EnvelopeTool"), XO("Envelope Tool") },
153 { drawTool, wxT("DrawTool"), XO("Draw Tool") },
154 { multiTool, wxT("MultiTool"), XO("Multi-Tool") },
155 };
156
157 for (const auto &entry : table) {
159 entry.commandName, entry.untranslatedLabel };
161 *mTool[entry.tool], &command, 1u );
162 }
163 #endif
164
165 // wxSafeYield();
166 return;
167}
static ProjectFileIORegistry::AttributeWriterEntry entry
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
static void SetButtonToolTip(AudacityProject &project, AButton &button, const ComponentInterfaceSymbol commands[], size_t nCommands)
Definition: ToolBar.cpp:970
Holds a msgid for the translation catalog; may also bind format arguments.

References ToolCodes::drawTool, entry, ToolCodes::envelopeTool, ToolBar::mProject, mTool, ToolCodes::multiTool, ToolCodes::selectTool, ToolBar::SetButtonToolTip(), wxT(), and XO().

Referenced by Populate(), and UpdatePrefs().

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

◆ Repaint()

void ToolsToolBar::Repaint ( wxDC *  WXUNUSEDdc)
inlineoverride

Definition at line 55 of file ToolsToolBar.h.

55{};

◆ UpdatePrefs()

void ToolsToolBar::UpdatePrefs ( )
overridevirtual

Reimplemented from ToolBar.

Definition at line 169 of file ToolsToolBar.cpp.

170{
173}
void UpdatePrefs() override
Definition: ToolBar.cpp:622

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

Referenced by Create().

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

Member Data Documentation

◆ mCurrentTool

int ToolsToolBar::mCurrentTool
private

Definition at line 70 of file ToolsToolBar.h.

Referenced by DoToolChanged(), and ToolsToolBar().

◆ mSubscription

Observer::Subscription ToolsToolBar::mSubscription
private

Definition at line 67 of file ToolsToolBar.h.

Referenced by ToolsToolBar().

◆ mTool

AButton* ToolsToolBar::mTool[numTools]
private

Definition at line 68 of file ToolsToolBar.h.

Referenced by DoToolChanged(), OnTool(), Populate(), and RegenerateTooltips().

◆ mToolSizer

wxGridSizer* ToolsToolBar::mToolSizer
private

Definition at line 69 of file ToolsToolBar.h.

Referenced by MakeTool(), and Populate().


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