From dbc6bf993be865e0f2ed2568e107e80695e1e73a Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Wed, 9 Feb 2022 11:19:49 +0100 Subject: [PATCH] Don't fill the slider if it's empty --- nih_plug_egui/src/widgets/param_slider.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/nih_plug_egui/src/widgets/param_slider.rs b/nih_plug_egui/src/widgets/param_slider.rs index a173b84f..16c9a346 100644 --- a/nih_plug_egui/src/widgets/param_slider.rs +++ b/nih_plug_egui/src/widgets/param_slider.rs @@ -91,15 +91,17 @@ impl Widget for ParamSlider<'_, P> { .rect_filled(response.rect, 0.0, ui.visuals().widgets.inactive.bg_fill); let filled_proportion = self.normalized_value(); - let mut filled_rect = response.rect; - filled_rect.set_width(response.rect.width() * filled_proportion); - let filled_bg = if response.dragged() { - // TODO: Use something that works with a light theme - Color32::DARK_GRAY - } else { - ui.visuals().selection.bg_fill - }; - ui.painter().rect_filled(filled_rect, 0.0, filled_bg); + if filled_proportion > 0.0 { + let mut filled_rect = response.rect; + filled_rect.set_width(response.rect.width() * filled_proportion); + let filled_bg = if response.dragged() { + // TODO: Use something that works with a light theme + Color32::DARK_GRAY + } else { + ui.visuals().selection.bg_fill + }; + ui.painter().rect_filled(filled_rect, 0.0, filled_bg); + } ui.painter().rect_stroke( response.rect,