MCPcopy Create free account
hub / github.com/audacity/audacity / AddSelectionSetupButton

Method AddSelectionSetupButton

src/toolbars/SelectionBar.cpp:239–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

237}
238
239void SelectionBar::AddSelectionSetupButton(wxSizer* pSizer)
240{
241 auto setupBtn = MakeSetupButton();
242
243 auto showMenu = [this, setupBtn]()
244 {
245 static const wxString choices[4] = {
246 _("Start and End of Selection"),
247 _("Start and Length of Selection"),
248 _("Length and End of Selection"),
249 _("Length and Center of Selection"),
250 };
251
252 wxMenu menu;
253 int selectionMode {};
254 for (auto& choice : choices)
255 {
256 auto subMenu = menu.AppendRadioItem(wxID_ANY, choice);
257
258 if (static_cast<SelectionMode>(selectionMode) == mSelectionMode)
259 subMenu->Check();
260
261 menu.Bind(
262 wxEVT_MENU,
263 [this, selectionMode](auto& evt)
264 {
265 SetSelectionMode(static_cast<SelectionMode>(selectionMode));
266 SelectionModeUpdated();
267 },
268 subMenu->GetId());
269
270 ++selectionMode;
271 }
272
273 menu.Bind(wxEVT_MENU_CLOSE, [setupBtn](auto&) { setupBtn->PopUp(); });
274
275 BasicMenu::Handle { &menu }.Popup(wxWidgetsWindowPlacement { setupBtn });
276 };
277
278 setupBtn->Bind(wxEVT_BUTTON, [this, showMenu](auto&) { showMenu(); });
279 pSizer->Add(setupBtn, 0, wxALIGN_RIGHT | wxBOTTOM | wxRIGHT, 5);
280
281 mSetupButton = setupBtn;
282}
283
284void SelectionBar::Populate()
285{

Callers

nothing calls this directly

Calls 6

BindMethod · 0.80
GetIdMethod · 0.80
CheckMethod · 0.45
PopUpMethod · 0.45
PopupMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected