From 22b66705e509b8dd3e03d0196beb324f352a8324 Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Thu, 29 Aug 2024 07:27:33 -0400 Subject: [PATCH] HSliderFilled can have skinny paint zone and broad hit zone verticalReduction is a settable member so you can distinguish active zone from paint zone, making up for the lack of a handle hit zone while still keeping a gutter-only look --- include/sst/jucegui/components/HSliderFilled.h | 2 ++ src/sst/jucegui/components/HSliderFilled.cpp | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/sst/jucegui/components/HSliderFilled.h b/include/sst/jucegui/components/HSliderFilled.h index 5bccc7a..cf954a1 100644 --- a/include/sst/jucegui/components/HSliderFilled.h +++ b/include/sst/jucegui/components/HSliderFilled.h @@ -27,6 +27,8 @@ struct HSliderFilled : public HSlider HSliderFilled(); void paint(juce::Graphics &g) override; + int verticalReduction{0}; // if you want the paint zone smaller than the hit zone set this + // to pixels to reduce vertically (both sids, so '1' takes 1 off top and bottom) JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(HSliderFilled); }; diff --git a/src/sst/jucegui/components/HSliderFilled.cpp b/src/sst/jucegui/components/HSliderFilled.cpp index 32a40a9..026a5fa 100644 --- a/src/sst/jucegui/components/HSliderFilled.cpp +++ b/src/sst/jucegui/components/HSliderFilled.cpp @@ -39,10 +39,10 @@ void HSliderFilled::paint(juce::Graphics &g) return; // Gutter - auto b = getLocalBounds(); + auto b = getLocalBounds().reduced(0, verticalReduction); auto o = b.getHeight() - gutterheight; - auto r = getLocalBounds().toFloat(); + auto r = getLocalBounds().reduced(0, verticalReduction).toFloat(); auto rectRad = 5; if (isHovered)