GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git
feat: per-slider band-style override — cce-bevel adopts it
Slider::with_band forces the band style (thin full-range band swelling
at the value) on or off per widget, where before only the DE-wide
style.control.slider.style config chose it. cce-bevel opts all eight
knobs in.
Co-Authored-By: Claude Fable 5 <[email protected]>
src/bin/cce-bevel.rs | 12 +++++++++---
src/widget/input/slider.rs | 14 +++++++++++++-
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/src/bin/cce-bevel.rs b/src/bin/cce-bevel.rs
index 4e255d4..7b4070a 100644
--- a/src/bin/cce-bevel.rs
+++ b/src/bin/cce-bevel.rs
@@ -60,7 +60,11 @@ impl ProfileKnobs {
fn new(seed: Option<(f32, f32, f32)>) -> Self {
let (s, b, c) = seed.unwrap_or((0.5, 0.5, 0.5));
let knob = |v: f32, label: &str| {
- Slider::new().with_label(label).with_value(v.clamp(0.0, 1.0)).with_scroll(true)
+ Slider::new()
+ .with_label(label)
+ .with_value(v.clamp(0.0, 1.0))
+ .with_scroll(true)
+ .with_band(true)
};
let mut this = Self {
shoulder: knob(s, "Shoulder"),
@@ -408,14 +412,16 @@ impl Application for BevelPopup {
.with_value(((depth - dmin) / (dmax - dmin)).clamp(0.0, 1.0))
.with_readout(true)
.with_decimals(2)
- .with_scroll(true),
+ .with_scroll(true)
+ .with_band(true),
width_slider: Slider::new()
.with_label("Width")
.with_range(wmin, wmax)
.with_value(((width - wmin) / (wmax - wmin)).clamp(0.0, 1.0))
.with_readout(true)
.with_decimals(1)
- .with_scroll(true),
+ .with_scroll(true)
+ .with_band(true),
save_button: Button::new(0.0, 0.0, 0.0, 0.0).with_label("Save"),
reset_button: Button::new(0.0, 0.0, 0.0, 0.0).with_label("Reset"),
status: "Edits apply live; Save writes config.kdl.".to_string(),
diff --git a/src/widget/input/slider.rs b/src/widget/input/slider.rs
index 8fb2250..a7b8319 100644
--- a/src/widget/input/slider.rs
+++ b/src/widget/input/slider.rs
@@ -61,6 +61,9 @@ pub struct Slider {
last_wheel: Option<std::time::Instant>,
/// Readout / edit-buffer display precision (decimal places).
decimals: usize,
+ /// Per-widget band-style override; `None` follows the DE config
+ /// (`style.control.slider.style`).
+ band_override: Option<bool>,
}
impl Slider {
@@ -82,6 +85,7 @@ impl Slider {
scroll_vel: 0.0,
last_wheel: None,
decimals: 2,
+ band_override: None,
})
}
@@ -127,7 +131,7 @@ impl Slider {
/// full-range band that inflates smoothly at the value — no track fill, no
/// thumb ball, no carve.
fn band(&self) -> bool {
- crate::layout::slider_band()
+ self.band_override.unwrap_or_else(crate::layout::slider_band)
}
/// The width the value maps over: the full track under the band style
@@ -397,6 +401,14 @@ impl Adapted<Slider> {
self.decimals = decimals;
self
}
+
+ /// Force the band style (the thin full-range band swelling at the value)
+ /// on or off for this slider, regardless of the DE-wide
+ /// `style.control.slider.style` setting.
+ pub fn with_band(mut self, band: bool) -> Self {
+ self.band_override = Some(band);
+ self
+ }
}
impl Layout for Slider {