From 033d0f7e6e450b3f2d62d9a75210d52611cf346d Mon Sep 17 00:00:00 2001 From: Jake Stanger Date: Sun, 23 Apr 2023 12:59:28 +0100 Subject: [PATCH] feat(custom): option to toggle slider label Adds new `show_label` option. Resolves #115 (for real this time). --- docs/modules/Custom.md | 1 + src/modules/custom/slider.rs | 3 +++ 2 files changed, 4 insertions(+) diff --git a/docs/modules/Custom.md b/docs/modules/Custom.md index 6d33749..52588b9 100644 --- a/docs/modules/Custom.md +++ b/docs/modules/Custom.md @@ -87,6 +87,7 @@ If your input program requires an integer, you will need to round it. | `max` | `float` | `100` | Maximum slider value. | | `step` | `float` | - | The increment to change when scrolling with the mouse wheel. If left blank, will use the default determined by the environment. | | `length` | `integer` | `null` | Slider length. GTK will automatically size if left unset. | +| `show_label` | `boolean` | `true` | Whether to show the value label above the slider. | The example slider widget below shows a volume control for MPC, which updates the server when changed, and polls the server for volume changes to keep the slider in sync. diff --git a/src/modules/custom/slider.rs b/src/modules/custom/slider.rs index f777b1c..b6f7fbd 100644 --- a/src/modules/custom/slider.rs +++ b/src/modules/custom/slider.rs @@ -24,6 +24,8 @@ pub struct SliderWidget { max: f64, step: Option, length: Option, + #[serde(default = "crate::config::default_true")] + show_label: bool, } const fn default_min() -> f64 { @@ -51,6 +53,7 @@ impl CustomWidget for SliderWidget { } scale.set_range(self.min, self.max); + scale.set_draw_value(self.show_label); if let Some(on_change) = self.on_change { let min = self.min;