1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-08 08:01:19 +02:00

Mousing over the menu button of device meters (combined or separate) highlights

This commit is contained in:
Paul Licameli 2016-05-04 10:59:18 -04:00
parent 343f9d82e7
commit 0a0cbbba20
2 changed files with 27 additions and 1 deletions

View File

@ -467,6 +467,15 @@ void Meter::OnPaint(wxPaintEvent & WXUNUSED(event))
// MixerTrackCluster style has no icon or L/R labels // MixerTrackCluster style has no icon or L/R labels
if (mStyle != MixerTrackCluster) if (mStyle != MixerTrackCluster)
{ {
bool highlight = InIcon();
if (highlight) {
auto rect = mIconRect;
rect.Inflate(gap, gap);
wxColour colour(247, 247, 247);
dc.SetBrush(colour);
dc.SetPen(colour );
dc.DrawRectangle(rect);
}
dc.DrawBitmap(*mIcon, mIconRect.GetPosition(), true); dc.DrawBitmap(*mIcon, mIconRect.GetPosition(), true);
dc.SetFont(GetFont()); dc.SetFont(GetFont());
dc.DrawText(mLeftText, mLeftTextPos.x, mLeftTextPos.y); dc.DrawText(mLeftText, mLeftTextPos.x, mLeftTextPos.y);
@ -668,8 +677,22 @@ void Meter::OnSize(wxSizeEvent & WXUNUSED(event))
mLayoutValid = false; mLayoutValid = false;
} }
bool Meter::InIcon(wxMouseEvent *pEvent) const
{
auto point = pEvent ? pEvent->GetPosition() : ScreenToClient(::wxGetMousePosition());
return mIconRect.Contains(point);
}
void Meter::OnMouse(wxMouseEvent &evt) void Meter::OnMouse(wxMouseEvent &evt)
{ {
bool shouldHighlight = InIcon(&evt);
if ((evt.GetEventType() == wxEVT_MOTION || evt.Entering() || evt.Leaving()) &&
(mHighlighted != shouldHighlight)) {
mHighlighted = shouldHighlight;
mLayoutValid = false;
Refresh();
}
if (mStyle == MixerTrackCluster) // MixerTrackCluster style has no menu. if (mStyle == MixerTrackCluster) // MixerTrackCluster style has no menu.
return; return;
@ -688,7 +711,7 @@ void Meter::OnMouse(wxMouseEvent &evt)
#endif #endif
if (evt.RightDown() || if (evt.RightDown() ||
(evt.ButtonDown() && mIconRect.Contains(evt.m_x, evt.m_y))) (evt.ButtonDown() && InIcon(&evt)))
{ {
wxMenu menu; wxMenu menu;
// Note: these should be kept in the same order as the enum // Note: these should be kept in the same order as the enum

View File

@ -186,6 +186,7 @@ class Meter final : public wxPanel
void OnErase(wxEraseEvent &evt); void OnErase(wxEraseEvent &evt);
void OnPaint(wxPaintEvent &evt); void OnPaint(wxPaintEvent &evt);
void OnSize(wxSizeEvent &evt); void OnSize(wxSizeEvent &evt);
bool InIcon(wxMouseEvent *pEvent = nullptr) const;
void OnMouse(wxMouseEvent &evt); void OnMouse(wxMouseEvent &evt);
void OnKeyDown(wxKeyEvent &evt); void OnKeyDown(wxKeyEvent &evt);
void OnKeyUp(wxKeyEvent &evt); void OnKeyUp(wxKeyEvent &evt);
@ -280,6 +281,8 @@ class Meter final : public wxPanel
friend class MeterAx; friend class MeterAx;
bool mHighlighted {};
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };