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:
parent
343f9d82e7
commit
0a0cbbba20
@ -467,6 +467,15 @@ void Meter::OnPaint(wxPaintEvent & WXUNUSED(event))
|
||||
// MixerTrackCluster style has no icon or L/R labels
|
||||
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.SetFont(GetFont());
|
||||
dc.DrawText(mLeftText, mLeftTextPos.x, mLeftTextPos.y);
|
||||
@ -668,8 +677,22 @@ void Meter::OnSize(wxSizeEvent & WXUNUSED(event))
|
||||
mLayoutValid = false;
|
||||
}
|
||||
|
||||
bool Meter::InIcon(wxMouseEvent *pEvent) const
|
||||
{
|
||||
auto point = pEvent ? pEvent->GetPosition() : ScreenToClient(::wxGetMousePosition());
|
||||
return mIconRect.Contains(point);
|
||||
}
|
||||
|
||||
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.
|
||||
return;
|
||||
|
||||
@ -688,7 +711,7 @@ void Meter::OnMouse(wxMouseEvent &evt)
|
||||
#endif
|
||||
|
||||
if (evt.RightDown() ||
|
||||
(evt.ButtonDown() && mIconRect.Contains(evt.m_x, evt.m_y)))
|
||||
(evt.ButtonDown() && InIcon(&evt)))
|
||||
{
|
||||
wxMenu menu;
|
||||
// Note: these should be kept in the same order as the enum
|
||||
|
@ -186,6 +186,7 @@ class Meter final : public wxPanel
|
||||
void OnErase(wxEraseEvent &evt);
|
||||
void OnPaint(wxPaintEvent &evt);
|
||||
void OnSize(wxSizeEvent &evt);
|
||||
bool InIcon(wxMouseEvent *pEvent = nullptr) const;
|
||||
void OnMouse(wxMouseEvent &evt);
|
||||
void OnKeyDown(wxKeyEvent &evt);
|
||||
void OnKeyUp(wxKeyEvent &evt);
|
||||
@ -280,6 +281,8 @@ class Meter final : public wxPanel
|
||||
|
||||
friend class MeterAx;
|
||||
|
||||
bool mHighlighted {};
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user