diff --git a/src/widgets/Ruler.cpp b/src/widgets/Ruler.cpp index 27b12e87c..7a53857ee 100644 --- a/src/widgets/Ruler.cpp +++ b/src/widgets/Ruler.cpp @@ -2262,13 +2262,8 @@ void AdornedRulerPanel::OnMouseEvents(wxMouseEvent &evt) if (HasCapture() && mCaptureState != StatusChoice::NoButton) HandlePushbuttonEvent(evt); - else if (!HasCapture() && overButtons) { - if (evt.ButtonDown() && button != StatusChoice::NoButton) { - CaptureMouse(); - mCaptureState = button; - Refresh(); - } - } + else if (!HasCapture() && overButtons) + HandlePushbuttonClick(evt); // Handle popup menus else if (!HasCapture() && evt.RightDown() && !(evt.LeftIsDown())) { if(inScrubZone) @@ -2909,6 +2904,18 @@ void AdornedRulerPanel::ToggleButtonState( StatusChoice button ) } } +void AdornedRulerPanel::ShowButtonMenu( StatusChoice button, wxPoint position) +{ + switch (button) { + case StatusChoice::QuickPlayButton: + return ShowMenu(position); + case StatusChoice::ScrubBarButton: + return ShowScrubMenu(position); + default: + return; + } +} + const AdornedRulerPanel::ButtonStrings AdornedRulerPanel::PushbuttonLabels [static_cast(StatusChoice::NumButtons)] { @@ -2946,6 +2953,22 @@ void AdornedRulerPanel::DoDrawPushbutton(wxDC *dc, StatusChoice button, bool dow AColor::BevelTrackInfo(*dc, !down, bev); } +void AdornedRulerPanel::HandlePushbuttonClick(wxMouseEvent &evt) +{ + auto button = FindButton(evt.GetPosition()); + if (IsButton(button)) { + if (evt.LeftDown()) { + CaptureMouse(); + mCaptureState = button; + Refresh(); + } + else if (evt.RightDown()) { + auto rect = GetButtonRect(button); + ShowButtonMenu( button, wxPoint{ rect.GetX() + 1, rect.GetBottom() + 1 } ); + } + } +} + void AdornedRulerPanel::HandlePushbuttonEvent(wxMouseEvent &evt) { if(evt.ButtonUp()) { diff --git a/src/widgets/Ruler.h b/src/widgets/Ruler.h index 52ce8ae2d..7f1d9b8ca 100644 --- a/src/widgets/Ruler.h +++ b/src/widgets/Ruler.h @@ -385,8 +385,10 @@ private: StatusChoice FindButton( wxPoint position ) const; bool GetButtonState( StatusChoice button ) const; void ToggleButtonState( StatusChoice button ); + void ShowButtonMenu( StatusChoice button, wxPoint position); void DoDrawPushbutton(wxDC *dc, StatusChoice button, bool down) const; void DoDrawPushbuttons(wxDC *dc) const; + void HandlePushbuttonClick(wxMouseEvent &evt); void HandlePushbuttonEvent(wxMouseEvent &evt); wxFont &GetButtonFont() const;