1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-13 07:07:46 +02:00

Fix drawing of focus rectangles in buttons, meters, sliders on Mac

This commit is contained in:
Paul Licameli 2016-06-24 23:48:03 -04:00
parent 6a4d6ceeda
commit fe509ed412
4 changed files with 17 additions and 5 deletions

View File

@ -174,11 +174,20 @@ void AColor::DrawFocus(wxDC & dc, wxRect & rect)
x2 = rect.GetRight(), x2 = rect.GetRight(),
y2 = rect.GetBottom(); y2 = rect.GetBottom();
#ifdef __WXMAC__
// Why must this be different?
// Otherwise nothing is visible if you do as for the
// other platforms.
dc.SetPen(wxPen(wxT("MEDIUM GREY"), 1, wxSOLID));
dc.SetLogicalFunction(wxCOPY);
#else
dc.SetPen(wxPen(wxT("MEDIUM GREY"), 0, wxSOLID)); dc.SetPen(wxPen(wxT("MEDIUM GREY"), 0, wxSOLID));
// this seems to be closer than what Windows does than wxINVERT although // this seems to be closer than what Windows does than wxINVERT although
// I'm still not sure if it's correct // I'm still not sure if it's correct
dc.SetLogicalFunction(wxAND_REVERSE); dc.SetLogicalFunction(wxAND_REVERSE);
#endif
wxCoord z; wxCoord z;
for ( z = x1 + 1; z < x2; z += 2 ) for ( z = x1 + 1; z < x2; z += 2 )

View File

@ -138,7 +138,14 @@ AButton *ControlToolBar::MakeButton(teBmps eEnabledUp, teBmps eEnabledDown, teBm
wxDefaultPosition, processdownevents, wxDefaultPosition, processdownevents,
theTheme.ImageSize( bmpRecoloredUpLarge )); theTheme.ImageSize( bmpRecoloredUpLarge ));
r->SetLabel(label); r->SetLabel(label);
r->SetFocusRect( r->GetRect().Deflate( 12, 12 ) ); enum { deflation =
#ifdef __WXMAC__
3
#else
12
#endif
};
r->SetFocusRect( r->GetClientRect().Deflate( deflation, deflation ) );
return r; return r;
} }

View File

@ -343,12 +343,10 @@ void AButton::OnPaint(wxPaintEvent & WXUNUSED(event))
mImages[mAlternateIdx].mArr[buttonState].Draw(dc, GetClientRect()); mImages[mAlternateIdx].mArr[buttonState].Draw(dc, GetClientRect());
#if defined(__WXMSW__) || defined(__WXGTK__)
if( mButtonIsFocused ) if( mButtonIsFocused )
{ {
AColor::DrawFocus( dc, mFocusRect ); AColor::DrawFocus( dc, mFocusRect );
} }
#endif
} }
void AButton::OnErase(wxEraseEvent & WXUNUSED(event)) void AButton::OnErase(wxEraseEvent & WXUNUSED(event))

View File

@ -659,13 +659,11 @@ void Meter::OnPaint(wxPaintEvent & WXUNUSED(event))
} }
} }
#if defined(__WXMSW__) || defined(__WXGTK__)
if (mIsFocused) if (mIsFocused)
{ {
wxRect r = mIconRect; wxRect r = mIconRect;
AColor::DrawFocus(destDC, r.Inflate(1, 1)); AColor::DrawFocus(destDC, r.Inflate(1, 1));
} }
#endif
delete paintDC; delete paintDC;
} }