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

Right click on a ruler pushbutton pops up the appropriate menu, regardless...

... of the button's enabled state.
This commit is contained in:
Paul Licameli 2016-05-02 02:01:02 -04:00
parent 31eda6641b
commit cac54a3b57
2 changed files with 32 additions and 7 deletions

View File

@ -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<size_t>(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()) {

View File

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