mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-10 00:51:13 +02:00
Mouse-over highlighting of slider thumbs in toolbar & mixer board
This commit is contained in:
parent
adf4c61052
commit
34da6e6ad3
@ -1976,7 +1976,7 @@ void TrackInfo::SliderDrawFunction
|
||||
wxRect sliderRect = rect;
|
||||
TrackInfo::GetSliderHorizontalBounds( rect.GetTopLeft(), sliderRect );
|
||||
auto wt = static_cast<const TrackClass*>( pTrack );
|
||||
Selector( sliderRect, wt, captured, nullptr )->OnPaint(*dc);
|
||||
Selector( sliderRect, wt, captured, nullptr )->OnPaint(*dc, false);
|
||||
}
|
||||
|
||||
void TrackInfo::PanSliderDrawFunction
|
||||
|
@ -455,8 +455,9 @@ void LWSlider::Init(wxWindow * parent,
|
||||
mCurrentValue = 0.0f;
|
||||
mDefaultValue = 0.0f;
|
||||
mDefaultShortcut = false;
|
||||
mBitmap = NULL;
|
||||
mThumbBitmap = NULL;
|
||||
mBitmap = nullptr;
|
||||
mThumbBitmap = nullptr;
|
||||
mThumbBitmapHilited = nullptr;
|
||||
mScrollLine = 1.0f;
|
||||
mScrollPage = 5.0f;
|
||||
mTipPanel = NULL;
|
||||
@ -545,9 +546,9 @@ void LWSlider::AdjustSize(const wxSize & sz)
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void LWSlider::OnPaint(wxDC &dc)
|
||||
void LWSlider::OnPaint(wxDC &dc, bool highlight)
|
||||
{
|
||||
if (!mBitmap || !mThumbBitmap)
|
||||
if (!mBitmap || !mThumbBitmap || !mThumbBitmapHilited)
|
||||
{
|
||||
Draw(dc);
|
||||
}
|
||||
@ -568,14 +569,16 @@ void LWSlider::OnPaint(wxDC &dc)
|
||||
#endif
|
||||
|
||||
dc.DrawBitmap(*mBitmap, mLeft, mTop, true);
|
||||
const auto &thumbBitmap =
|
||||
highlight ? *mThumbBitmapHilited : *mThumbBitmap;
|
||||
if (mOrientation == wxHORIZONTAL)
|
||||
{
|
||||
dc.DrawBitmap(*mThumbBitmap, mLeft+thumbPos, mTop+thumbOrtho, true);
|
||||
dc.DrawBitmap(thumbBitmap, mLeft+thumbPos, mTop+thumbOrtho, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: Don't use pixel-count hack in positioning.
|
||||
dc.DrawBitmap(*mThumbBitmap, mLeft+thumbOrtho-5, mTop+thumbPos, true);
|
||||
dc.DrawBitmap(thumbBitmap, mLeft+thumbOrtho-5, mTop+thumbPos, true);
|
||||
}
|
||||
|
||||
if (mTipPanel)
|
||||
@ -605,9 +608,12 @@ void LWSlider::Draw(wxDC & paintDC)
|
||||
// wxImage img2 = img.Rotate90(false);
|
||||
// mThumbBitmap = std::make_unique<wxBitmap>(wxBitmap( img2));
|
||||
mThumbBitmap = std::make_unique<wxBitmap>(wxBitmap( theTheme.Bitmap( bmpSliderThumbRotated )));
|
||||
mThumbBitmapHilited = std::make_unique<wxBitmap>(wxBitmap( theTheme.Bitmap( bmpSliderThumbRotatedHilited )));
|
||||
}
|
||||
else
|
||||
else {
|
||||
mThumbBitmap = std::make_unique<wxBitmap>(wxBitmap( theTheme.Bitmap( bmpSliderThumb )));
|
||||
mThumbBitmapHilited = std::make_unique<wxBitmap>(wxBitmap( theTheme.Bitmap( bmpSliderThumbHilited )));
|
||||
}
|
||||
|
||||
|
||||
// This code draws the (old) slider thumb.
|
||||
@ -1500,6 +1506,7 @@ void LWSlider::SetEnabled(bool enabled)
|
||||
mEnabled = enabled;
|
||||
|
||||
mThumbBitmap.reset();
|
||||
mThumbBitmapHilited.reset();
|
||||
|
||||
Refresh();
|
||||
}
|
||||
@ -1596,7 +1603,11 @@ void ASlider::OnPaint(wxPaintEvent & WXUNUSED(event))
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
|
||||
mLWSlider->OnPaint(dc);
|
||||
bool highlighted =
|
||||
GetClientRect().Contains(
|
||||
ScreenToClient(
|
||||
::wxGetMousePosition() ) );
|
||||
mLWSlider->OnPaint(dc, highlighted);
|
||||
|
||||
if ( mSliderIsFocused )
|
||||
{
|
||||
|
@ -142,7 +142,7 @@ class LWSlider
|
||||
|
||||
void AdjustSize(const wxSize & sz);
|
||||
|
||||
void OnPaint(wxDC &dc);
|
||||
void OnPaint(wxDC &dc, bool highlighted);
|
||||
void OnSize(wxSizeEvent & event);
|
||||
void OnMouseEvent(wxMouseEvent & event);
|
||||
void OnKeyEvent(wxKeyEvent & event);
|
||||
@ -232,12 +232,7 @@ class LWSlider
|
||||
|
||||
bool mIsDragging;
|
||||
|
||||
std::unique_ptr<wxBitmap> mBitmap, mThumbBitmap;
|
||||
|
||||
// AD: True if this object owns *mThumbBitmap (sometimes mThumbBitmap points
|
||||
// to an object we shouldn't DELETE) -- once we get theming totally right
|
||||
// this should go away
|
||||
bool mThumbBitmapAllocated;
|
||||
std::unique_ptr<wxBitmap> mBitmap, mThumbBitmap, mThumbBitmapHilited;
|
||||
|
||||
wxString mName;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user