1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-05 14:18:53 +02:00

Cleaner code to pop non toggle buttons up.

This commit is contained in:
James Crook 2017-04-09 19:07:28 +01:00
parent ffdba2eb2b
commit 6e440056f9
2 changed files with 5 additions and 9 deletions

View File

@ -246,15 +246,8 @@ void EditToolBar::OnButton(wxCommandEvent &event)
// due to bugs elsewhere (see: AudacityProject::UpdateMenus() )
// Be sure the pop-up happens even if there are exceptions
// Except, Sync Lock button is a toggle...
auto cleanup = finally( [&] {
bool bIsToggle = false;
#ifdef OPTION_SYNC_LOCK_BUTTON
bIsToggle = bIsToggle || ( id == ETBSyncLockID );
#endif
if( !bIsToggle )
SetButton(false, mButtons[id]);
}
// except for buttons which toggle.
auto cleanup = finally( [&] { mButtons[id]->InteractionOver();}
);
switch (id) {

View File

@ -122,6 +122,9 @@ class AButton final : public wxWindow {
void ClearDoubleClicked() { mIsDoubleClicked = false; }
void SetButtonToggles( bool toggler ){ mToggle = toggler;}
// When click is over and mouse has moved away, a normal button
// should pop up.
void InteractionOver(){ if( !mToggle ) PopUp();}
void Toggle(){ mButtonIsDown ? PopUp() : PushDown();}
void Click();
void SetShift(bool shift);