From 3f0922b5c03104aab23c5ea58402289579b68a02 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Fri, 4 Nov 2022 15:50:03 +0100 Subject: [PATCH] Add special styling for bypass buttons --- nih_plug_vizia/assets/widgets.css | 9 +++++++++ nih_plug_vizia/src/widgets.rs | 2 +- nih_plug_vizia/src/widgets/param_button.rs | 12 ++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/nih_plug_vizia/assets/widgets.css b/nih_plug_vizia/assets/widgets.css index dd9d39ef..58bc82d1 100644 --- a/nih_plug_vizia/assets/widgets.css +++ b/nih_plug_vizia/assets/widgets.css @@ -43,6 +43,15 @@ param-button:checked { transition: background-color 0.1 0; } +param-button:hover { + background-color: #ffaba51a; + transition: background-color 0.1 0; +} +param-button.bypass:checked { + background-color: #ffaba5; + transition: background-color 0.1 0; +} + param-button label { /* TODO */ } diff --git a/nih_plug_vizia/src/widgets.rs b/nih_plug_vizia/src/widgets.rs index 6e1aecae..f1cd9653 100644 --- a/nih_plug_vizia/src/widgets.rs +++ b/nih_plug_vizia/src/widgets.rs @@ -19,7 +19,7 @@ mod resize_handle; pub mod util; pub use generic_ui::GenericUi; -pub use param_button::ParamButton; +pub use param_button::{ParamButton, ParamButtonExt}; pub use param_slider::{ParamSlider, ParamSliderExt, ParamSliderStyle}; pub use peak_meter::PeakMeter; pub use resize_handle::ResizeHandle; diff --git a/nih_plug_vizia/src/widgets/param_button.rs b/nih_plug_vizia/src/widgets/param_button.rs index 73b8e46a..5ffefc96 100644 --- a/nih_plug_vizia/src/widgets/param_button.rs +++ b/nih_plug_vizia/src/widgets/param_button.rs @@ -85,3 +85,15 @@ impl View for ParamButton { }); } } + +/// Extension methods for [`ParamButton`] handles. +pub trait ParamButtonExt { + /// Change the colors scheme for a bypass button. This simply adds the `bypass` class. + fn for_bypass(self) -> Self; +} + +impl ParamButtonExt for Handle<'_, ParamButton> { + fn for_bypass(self) -> Self { + self.class("bypass") + } +}