Audacity 3.2.0
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
ToolBarButtons Class Referencefinal

#include <ToolBarButtons.h>

Collaboration diagram for ToolBarButtons:
[legend]

Classes

struct  Entry
 

Public Types

using ButtonList = std::vector< Entry >
 

Public Member Functions

 ToolBarButtons (ToolBar *const parent, AudacityProject &project, ButtonList buttonList, int size, int firstButtonId)
 
void OnButton (wxCommandEvent &event)
 
AButtonCreateButton (teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, int id, const TranslatableString &label, bool toggle=false)
 
void SetEnabled (int id, bool state)
 
void SetCustomEnableDisableButtonsAction (std::function< void()> action)
 
void PopUp (int id)
 
void PushDown (int id)
 
void EnableDisableButtons ()
 
void RegenerateTooltips ()
 

Private Member Functions

void ForAllButtons (int Action)
 

Private Attributes

ToolBarmParent
 
AudacityProjectmProject
 
int mFirstButtonId
 
std::vector< AButton * > mButtons
 
ButtonList mButtonList
 
std::function< void()> mCustomEnableDisableButtonsAction
 

Detailed Description

Definition at line 24 of file ToolBarButtons.h.

Member Typedef Documentation

◆ ButtonList

using ToolBarButtons::ButtonList = std::vector<Entry>

Definition at line 32 of file ToolBarButtons.h.

Constructor & Destructor Documentation

◆ ToolBarButtons()

ToolBarButtons::ToolBarButtons ( ToolBar *const  parent,
AudacityProject project,
ButtonList  buttonList,
int  size,
int  firstButtonId 
)

Definition at line 31 of file ToolBarButtons.cpp.

32 : mParent(parent)
34 , mFirstButtonId(firstButtonId)
35 , mButtons(size)
36 , mButtonList(std::move(buttonList))
37{
38}
const auto project
AudacityProject & mProject
std::vector< AButton * > mButtons
ButtonList mButtonList
ToolBar * mParent

Member Function Documentation

◆ CreateButton()

AButton * ToolBarButtons::CreateButton ( teBmps  eEnabledUp,
teBmps  eEnabledDown,
teBmps  eDisabled,
int  id,
const TranslatableString label,
bool  toggle = false 
)

Definition at line 64 of file ToolBarButtons.cpp.

65{
66 AButton *&r = mButtons[thisButtonId];
67
69 bmpRecoloredUpSmall, bmpRecoloredDownSmall, bmpRecoloredUpHiliteSmall, bmpRecoloredHiliteSmall,
70 eEnabledUp, eEnabledDown, eDisabled,
71 wxWindowID(thisButtonId + mFirstButtonId),
72 wxDefaultPosition,
73 toggle,
74 theTheme.ImageSize( bmpRecoloredUpSmall ));
75
76 r->SetLabel(label);
77
78 return r;
79}
TranslatableString label
Definition: TagsEditor.cpp:165
THEME_API Theme theTheme
Definition: Theme.cpp:82
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

References ThemeBase::ImageSize(), label, ToolBar::MakeButton(), mButtons, mFirstButtonId, mParent, AButton::SetLabel(), and theTheme.

Referenced by CutCopyPasteToolBar::AddButton(), and EditToolBar::AddButton().

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

◆ EnableDisableButtons()

void ToolBarButtons::EnableDisableButtons ( )

Definition at line 101 of file ToolBarButtons.cpp.

102{
104}
@ TBActEnableDisable
void ForAllButtons(int Action)

References ForAllButtons(), and TBActEnableDisable.

Referenced by CutCopyPasteToolBar::EnableDisableButtons(), and EditToolBar::EnableDisableButtons().

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

◆ ForAllButtons()

void ToolBarButtons::ForAllButtons ( int  Action)
private

Definition at line 111 of file ToolBarButtons.cpp.

112{
113 CommandManager* cm = nullptr;
114
117
120 }
121
122 for (const auto &entry : mButtonList) {
123#if wxUSE_TOOLTIPS
124 if ( Action & TBActTooltips ) {
126 entry.commandName, entry.untranslatedLabel };
128 *mButtons[entry.tool], &command, 1u );
129 }
130#endif
131 if (cm) {
132 SetEnabled(entry.tool, cm->GetEnabled(entry.commandName));
133 }
134 }
135}
static ProjectFileIORegistry::AttributeWriterEntry entry
@ TBActTooltips
CommandManager implements a system for organizing all user-callable commands.
bool GetEnabled(const CommandID &name) const
static CommandManager & Get(AudacityProject &project)
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
std::function< void()> mCustomEnableDisableButtonsAction
void SetEnabled(int id, bool state)
static void SetButtonToolTip(AudacityProject &project, AButton &button, const ComponentInterfaceSymbol commands[], size_t nCommands)
Definition: ToolBar.cpp:970
std::function< void()> Action
Definition: BasicUI.h:24

References entry, CommandManager::Get(), CommandManager::GetEnabled(), mButtonList, mButtons, mCustomEnableDisableButtonsAction, mProject, ToolBar::SetButtonToolTip(), SetEnabled(), TBActEnableDisable, and TBActTooltips.

Referenced by EnableDisableButtons(), and RegenerateTooltips().

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

◆ OnButton()

void ToolBarButtons::OnButton ( wxCommandEvent &  event)

Definition at line 40 of file ToolBarButtons.cpp.

41{
42 int id = event.GetId() - mFirstButtonId;
43
44 // Be sure the pop-up happens even if there are exceptions, except for buttons which toggle.
45 auto cleanup = finally( [&] { mButtons[id]->InteractionOver(); });
46
48 const CommandContext context( mProject );
49
51 mButtonList[id].commandName, context, flags, false );
52
53#if defined(__WXMAC__)
54 // Bug 2402
55 // LLL: It seems that on the Mac the IDLE events are processed
56 // differently than on Windows/GTK and the AdornedRulerPanel's
57 // OnPaint() method gets called sooner that expected. This is
58 // evident when zooming from this toolbar only. When zooming from
59 // the Menu or from keyboard ommand, the zooming works correctly.
60 wxTheApp->ProcessIdle();
61#endif
62}
int id
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
CommandFlag GetUpdateFlags(bool quick=false) const
AUDACITY_DLL_API bool HandleTextualCommand(const CommandID &Str, const CommandContext &context, CommandFlag flags, bool alwaysEnabled)

References CommandManager::Get(), CommandManager::GetUpdateFlags(), CommandDispatch::HandleTextualCommand(), id, mButtonList, mButtons, mFirstButtonId, and mProject.

Referenced by CutCopyPasteToolBar::OnButton(), and EditToolBar::OnButton().

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

◆ PopUp()

void ToolBarButtons::PopUp ( int  id)

Definition at line 91 of file ToolBarButtons.cpp.

92{
93 mButtons[id]->PopUp();
94}

References id, and mButtons.

Referenced by EditToolBar::EditToolBar().

Here is the caller graph for this function:

◆ PushDown()

void ToolBarButtons::PushDown ( int  id)

Definition at line 96 of file ToolBarButtons.cpp.

97{
98 mButtons[id]->PushDown();
99}

References id, and mButtons.

Referenced by EditToolBar::EditToolBar(), and EditToolBar::Populate().

Here is the caller graph for this function:

◆ RegenerateTooltips()

void ToolBarButtons::RegenerateTooltips ( )

Definition at line 106 of file ToolBarButtons.cpp.

107{
109}

References ForAllButtons(), and TBActTooltips.

Referenced by CutCopyPasteToolBar::RegenerateTooltips(), and EditToolBar::RegenerateTooltips().

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

◆ SetCustomEnableDisableButtonsAction()

void ToolBarButtons::SetCustomEnableDisableButtonsAction ( std::function< void()>  action)

Definition at line 86 of file ToolBarButtons.cpp.

87{
88 mCustomEnableDisableButtonsAction = std::move(action);
89}

References mCustomEnableDisableButtonsAction.

Referenced by EditToolBar::EditToolBar().

Here is the caller graph for this function:

◆ SetEnabled()

void ToolBarButtons::SetEnabled ( int  id,
bool  state 
)

Definition at line 81 of file ToolBarButtons.cpp.

82{
83 mButtons[id]->SetEnabled(state);
84}

References id, and mButtons.

Referenced by ForAllButtons(), CutCopyPasteToolBar::Populate(), and EditToolBar::Populate().

Here is the caller graph for this function:

Member Data Documentation

◆ mButtonList

ButtonList ToolBarButtons::mButtonList
private

Definition at line 60 of file ToolBarButtons.h.

Referenced by ForAllButtons(), and OnButton().

◆ mButtons

std::vector<AButton*> ToolBarButtons::mButtons
private

Definition at line 59 of file ToolBarButtons.h.

Referenced by CreateButton(), ForAllButtons(), OnButton(), PopUp(), PushDown(), and SetEnabled().

◆ mCustomEnableDisableButtonsAction

std::function<void()> ToolBarButtons::mCustomEnableDisableButtonsAction
private

Definition at line 62 of file ToolBarButtons.h.

Referenced by ForAllButtons(), and SetCustomEnableDisableButtonsAction().

◆ mFirstButtonId

int ToolBarButtons::mFirstButtonId
private

Definition at line 57 of file ToolBarButtons.h.

Referenced by CreateButton(), and OnButton().

◆ mParent

ToolBar* ToolBarButtons::mParent
private

Definition at line 55 of file ToolBarButtons.h.

Referenced by CreateButton().

◆ mProject

AudacityProject& ToolBarButtons::mProject
private

Definition at line 56 of file ToolBarButtons.h.

Referenced by ForAllButtons(), and OnButton().


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