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:


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

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

33 : mParent(parent)
34 , mProject(project)
35 , mFirstButtonId(firstButtonId)
36 , mButtons(size)
37 , mButtonList(std::move(buttonList))
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 67 of file ToolBarButtons.cpp.

69 AButton *&r = mButtons[thisButtonId];
72 bmpRecoloredUpSmall, bmpRecoloredDownSmall, bmpRecoloredUpHiliteSmall, bmpRecoloredHiliteSmall,
73 eEnabledUp, eEnabledDown, eDisabled,
74 wxWindowID(thisButtonId + mFirstButtonId),
75 wxDefaultPosition,
76 toggle,
77 theTheme.ImageSize( bmpRecoloredUpSmall ));
79 r->SetLabel(label);
81 return r;
TranslatableString label
Definition: TagsEditor.cpp:164
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 104 of file ToolBarButtons.cpp.

@ 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)

Definition at line 114 of file ToolBarButtons.cpp.

116 CommandManager* cm = nullptr;
123 }
125 for (const auto &entry : mButtonList) {
127 if ( Action & TBActTooltips ) {
129 entry.commandName, entry.untranslatedLabel };
131 *mButtons[entry.tool], &command, 1u );
132 }
134 if (cm) {
135 SetEnabled(entry.tool, cm->GetEnabled(entry.commandName));
136 }
137 }
static ProjectFileIORegistry::AttributeWriterEntry entry
@ TBActTooltips
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,...
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 41 of file ToolBarButtons.cpp.

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

References CommandManager::Get(), MenuManager::Get(), MenuManager::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.

96 mButtons[id]->PopUp();

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.

101 mButtons[id]->PushDown();

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.


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.

91 mCustomEnableDisableButtonsAction = std::move(action);

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.

86 mButtons[id]->SetEnabled(state);

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

Definition at line 60 of file ToolBarButtons.h.

Referenced by ForAllButtons(), and OnButton().

◆ mButtons

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

Definition at line 59 of file ToolBarButtons.h.

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

◆ mCustomEnableDisableButtonsAction

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

Definition at line 62 of file ToolBarButtons.h.

Referenced by ForAllButtons(), and SetCustomEnableDisableButtonsAction().

◆ mFirstButtonId

int ToolBarButtons::mFirstButtonId

Definition at line 57 of file ToolBarButtons.h.

Referenced by CreateButton(), and OnButton().

◆ mParent

ToolBar* ToolBarButtons::mParent

Definition at line 55 of file ToolBarButtons.h.

Referenced by CreateButton().

◆ mProject

AudacityProject& ToolBarButtons::mProject

Definition at line 56 of file ToolBarButtons.h.

Referenced by ForAllButtons(), and OnButton().

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