1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-20 22:30:05 +02:00

Play buttons can detect double clicks (but don't do anything special yet)

This commit is contained in:
Paul Licameli 2016-05-03 21:28:39 -04:00
parent 67d3bb89cb
commit 039aaa13a0
4 changed files with 17 additions and 1 deletions

View File

@ -738,6 +738,9 @@ void ControlToolBar::OnKeyEvent(wxKeyEvent & event)
void ControlToolBar::OnPlay(wxCommandEvent & WXUNUSED(evt)) void ControlToolBar::OnPlay(wxCommandEvent & WXUNUSED(evt))
{ {
auto doubleClicked = mPlay->IsDoubleClicked();
mPlay->ClearDoubleClicked();
if (!CanStopAudioStream()) if (!CanStopAudioStream())
return; return;

View File

@ -474,10 +474,15 @@ void TranscriptionToolBar::PlayAtSpeed(bool looped, bool cutPreview)
// Come here from button clicks only // Come here from button clicks only
void TranscriptionToolBar::OnPlaySpeed(wxCommandEvent & WXUNUSED(event)) void TranscriptionToolBar::OnPlaySpeed(wxCommandEvent & WXUNUSED(event))
{ {
auto button = mButtons[TTB_PlaySpeed];
auto doubleClicked = button->IsDoubleClicked();
button->ClearDoubleClicked();
// Let control have precedence over shift // Let control have precedence over shift
const bool cutPreview = mButtons[TTB_PlaySpeed]->WasControlDown(); const bool cutPreview = mButtons[TTB_PlaySpeed]->WasControlDown();
const bool looped = !cutPreview && const bool looped = !cutPreview &&
mButtons[TTB_PlaySpeed]->WasShiftDown(); button->WasShiftDown();
PlayAtSpeed(looped, cutPreview); PlayAtSpeed(looped, cutPreview);
} }

View File

@ -407,6 +407,8 @@ void AButton::OnMouseEvent(wxMouseEvent & event)
if (mEnabled && event.IsButton()) { if (mEnabled && event.IsButton()) {
if (event.ButtonIsDown(wxMOUSE_BTN_ANY)) { if (event.ButtonIsDown(wxMOUSE_BTN_ANY)) {
mIsClicking = true; mIsClicking = true;
if (event.ButtonDClick())
mIsDoubleClicked = true;
if( !HasCapture() ) if( !HasCapture() )
CaptureMouse(); CaptureMouse();
} }

View File

@ -109,6 +109,11 @@ class AButton final : public wxWindow {
bool WasControlDown(); // returns true if control was held down bool WasControlDown(); // returns true if control was held down
// the last time the button was clicked // the last time the button was clicked
bool IsDown(){ return mButtonIsDown;} bool IsDown(){ return mButtonIsDown;}
// Double click is detected, but not automatically cleared.
bool IsDoubleClicked() const { return mIsDoubleClicked; }
void ClearDoubleClicked() { mIsDoubleClicked = false; }
void SetButtonToggles( bool toggler ){ mToggle = toggler;} void SetButtonToggles( bool toggler ){ mToggle = toggler;}
void Toggle(){ mButtonIsDown ? PopUp() : PushDown();} void Toggle(){ mButtonIsDown ? PopUp() : PushDown();}
void Click(); void Click();
@ -157,6 +162,7 @@ class AButton final : public wxWindow {
bool mIsClicking; bool mIsClicking;
bool mEnabled; bool mEnabled;
bool mUseDisabledAsDownHiliteImage; bool mUseDisabledAsDownHiliteImage;
bool mIsDoubleClicked {};
struct ImageArr { ImageRoll mArr[4]; }; struct ImageArr { ImageRoll mArr[4]; };
std::vector<ImageArr> mImages; std::vector<ImageArr> mImages;