@@ -173,7 +173,7 @@ void paintLinearSlider (Graphics& g, const ApplicationTheme& theme, const Slider
173173 {
174174 g.setStrokeColor (Colors::cornflowerblue);
175175 g.setStrokeWidth (2 .0f );
176- g.strokeRoundedRect (sliderBounds. reduced (1 . 0f ), 2 .0f );
176+ g.strokeRoundedRect (slider. getLocalBounds (). reduced (2 ), 2 .0f );
177177 }
178178}
179179
@@ -223,18 +223,13 @@ void paintTwoValueSlider (Graphics& g, const ApplicationTheme& theme, const Slid
223223 {
224224 g.setStrokeColor (Colors::cornflowerblue);
225225 g.setStrokeWidth (2 .0f );
226- g.strokeRoundedRect (sliderBounds. reduced (1 . 0f ), 2 .0f );
226+ g.strokeRoundedRect (slider. getLocalBounds (). reduced (2 ), 2 .0f );
227227 }
228228}
229229
230230void paintSlider (Graphics& g, const ApplicationTheme& theme, const Slider& s)
231231{
232232 auto sliderBounds = s.getSliderBounds ();
233- const Rectangle<float > sliderBoundsFloat (static_cast <float >(sliderBounds.getX ()),
234- static_cast <float >(sliderBounds.getY ()),
235- static_cast <float >(sliderBounds.getWidth ()),
236- static_cast <float >(sliderBounds.getHeight ()));
237-
238233 const auto sliderType = s.getSliderType ();
239234 const bool isMouseOver = s.isMouseOver ();
240235 const bool isMouseDown = false ; // s.isMouseButtonDown();
@@ -248,7 +243,7 @@ void paintSlider (Graphics& g, const ApplicationTheme& theme, const Slider& s)
248243 {
249244 constexpr float rotaryStartAngle = degreesToRadians (135 .0f );
250245 constexpr float rotaryEndAngle = rotaryStartAngle + degreesToRadians (270 .0f );
251- paintRotarySlider (g, theme, s, sliderBoundsFloat , rotaryStartAngle, rotaryEndAngle,
246+ paintRotarySlider (g, theme, s, sliderBounds , rotaryStartAngle, rotaryEndAngle,
252247 static_cast <float >(s.getValueNormalised ()), isMouseOver, isMouseDown);
253248 break ;
254249 }
@@ -264,16 +259,16 @@ void paintSlider (Graphics& g, const ApplicationTheme& theme, const Slider& s)
264259
265260 if (isHorizontal)
266261 {
267- const float thumbX = sliderBoundsFloat .getX () + (sliderValue * sliderBoundsFloat .getWidth ()) - 8 .0f ;
268- thumbBounds = Rectangle<float > (thumbX, sliderBoundsFloat .getCenterY () - 8 .0f , 16 .0f , 16 .0f );
262+ const float thumbX = sliderBounds .getX () + (sliderValue * sliderBounds .getWidth ()) - 8 .0f ;
263+ thumbBounds = Rectangle<float > (thumbX, sliderBounds .getCenterY () - 8 .0f , 16 .0f , 16 .0f );
269264 }
270265 else
271266 {
272- const float thumbY = sliderBoundsFloat .getBottom () - (sliderValue * sliderBoundsFloat .getHeight ()) - 8 .0f ;
273- thumbBounds = Rectangle<float > (sliderBoundsFloat .getCenterX () - 8 .0f , thumbY, 16 .0f , 16 .0f );
267+ const float thumbY = sliderBounds .getBottom () - (sliderValue * sliderBounds .getHeight ()) - 8 .0f ;
268+ thumbBounds = Rectangle<float > (sliderBounds .getCenterX () - 8 .0f , thumbY, 16 .0f , 16 .0f );
274269 }
275270
276- paintLinearSlider (g, theme, s, sliderBoundsFloat , thumbBounds, isHorizontal,
271+ paintLinearSlider (g, theme, s, sliderBounds , thumbBounds, isHorizontal,
277272 sliderValue, isMouseOver, isMouseDown);
278273 break ;
279274 }
@@ -288,17 +283,17 @@ void paintSlider (Graphics& g, const ApplicationTheme& theme, const Slider& s)
288283
289284 if (isHorizontal)
290285 {
291- const float minThumbX = sliderBoundsFloat .getX () + (minNorm * sliderBoundsFloat .getWidth ()) - 8 .0f ;
292- const float maxThumbX = sliderBoundsFloat .getX () + (maxNorm * sliderBoundsFloat .getWidth ()) - 8 .0f ;
293- minThumbBounds = Rectangle<float > (minThumbX, sliderBoundsFloat .getCenterY () - 8 .0f , 16 .0f , 16 .0f );
294- maxThumbBounds = Rectangle<float > (maxThumbX, sliderBoundsFloat .getCenterY () - 8 .0f , 16 .0f , 16 .0f );
286+ const float minThumbX = sliderBounds .getX () + (minNorm * sliderBounds .getWidth ()) - 8 .0f ;
287+ const float maxThumbX = sliderBounds .getX () + (maxNorm * sliderBounds .getWidth ()) - 8 .0f ;
288+ minThumbBounds = Rectangle<float > (minThumbX, sliderBounds .getCenterY () - 8 .0f , 16 .0f , 16 .0f );
289+ maxThumbBounds = Rectangle<float > (maxThumbX, sliderBounds .getCenterY () - 8 .0f , 16 .0f , 16 .0f );
295290 }
296291 else
297292 {
298- const float minThumbY = sliderBoundsFloat .getBottom () - (minNorm * sliderBoundsFloat .getHeight ()) - 8 .0f ;
299- const float maxThumbY = sliderBoundsFloat .getBottom () - (maxNorm * sliderBoundsFloat .getHeight ()) - 8 .0f ;
300- minThumbBounds = Rectangle<float > (sliderBoundsFloat .getCenterX () - 8 .0f , minThumbY, 16 .0f , 16 .0f );
301- maxThumbBounds = Rectangle<float > (sliderBoundsFloat .getCenterX () - 8 .0f , maxThumbY, 16 .0f , 16 .0f );
293+ const float minThumbY = sliderBounds .getBottom () - (minNorm * sliderBounds .getHeight ()) - 8 .0f ;
294+ const float maxThumbY = sliderBounds .getBottom () - (maxNorm * sliderBounds .getHeight ()) - 8 .0f ;
295+ minThumbBounds = Rectangle<float > (sliderBounds .getCenterX () - 8 .0f , minThumbY, 16 .0f , 16 .0f );
296+ maxThumbBounds = Rectangle<float > (sliderBounds .getCenterX () - 8 .0f , maxThumbY, 16 .0f , 16 .0f );
302297 }
303298
304299 // For two-value sliders, check which thumb the mouse is over
@@ -312,7 +307,7 @@ void paintSlider (Graphics& g, const ApplicationTheme& theme, const Slider& s)
312307 isMouseOverMaxThumb = maxThumbBounds.contains (mousePosFloat);
313308 }
314309
315- paintTwoValueSlider (g, theme, s, sliderBoundsFloat , minThumbBounds, maxThumbBounds,
310+ paintTwoValueSlider (g, theme, s, sliderBounds , minThumbBounds, maxThumbBounds,
316311 isHorizontal, minNorm, maxNorm, isMouseOverMinThumb, isMouseOverMaxThumb, isMouseDown);
317312 break ;
318313 }
0 commit comments