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 auto& button = mButtons[thisButtonId];// ;
67 button = safenew AButton(mParent, thisButtonId + mFirstButtonId);
68 button->SetButtonType(AButton::FrameButton);
69 button->SetButtonToggles(toggle);
70 button->SetImages(
71 theTheme.Image(bmpRecoloredUpSmall),
72 theTheme.Image(bmpRecoloredUpHiliteSmall),
73 theTheme.Image(bmpRecoloredDownSmall),
74 theTheme.Image(bmpRecoloredHiliteSmall),
75 theTheme.Image(bmpRecoloredUpSmall));
76 button->SetIcons(theTheme.Image(eEnabledUp), theTheme.Image(eEnabledDown), theTheme.Image(eDisabled));
77 button->SetFrameMid(3);
78 button->SetLabel(label);
79 button->SetMinSize(wxSize { 25, 25 });
80 button->SetMaxSize(wxSize { 25, 25 });
81 return button;
82}
#define safenew
Definition: MemoryX.h:10
TranslatableString label
Definition: TagsEditor.cpp:165
THEME_API Theme theTheme
Definition: Theme.cpp:82
A wxButton with mouse-over behaviour.
Definition: AButton.h:104
@ FrameButton
Definition: AButton.h:114
wxImage & Image(int iIndex)

References AButton::FrameButton, ThemeBase::Image(), label, mButtons, mFirstButtonId, mParent, safenew, 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 104 of file ToolBarButtons.cpp.

105{
107}
@ 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 114 of file ToolBarButtons.cpp.

115{
116 CommandManager* cm = nullptr;
117
120
123 }
124
125 for (const auto &entry : mButtonList) {
126#if wxUSE_TOOLTIPS
127 if ( Action & TBActTooltips ) {
129 entry.commandName, entry.untranslatedLabel };
131 *mButtons[entry.tool], &command, 1u );
132 }
133#endif
134 if (cm) {
135 SetEnabled(entry.tool, cm->GetEnabled(entry.commandName));
136 }
137 }
138}
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:934
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 94 of file ToolBarButtons.cpp.

95{
96 mButtons[id]->PopUp();
97}

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 99 of file ToolBarButtons.cpp.

100{
101 mButtons[id]->PushDown();
102}

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 109 of file ToolBarButtons.cpp.

110{
112}

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 89 of file ToolBarButtons.cpp.

90{
91 mCustomEnableDisableButtonsAction = std::move(action);
92}

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 84 of file ToolBarButtons.cpp.

85{
86 mButtons[id]->SetEnabled(state);
87}

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: