From 03f1d75d3c473784979082d00ac9d05837e2edc8 Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Tue, 12 Mar 2024 19:48:17 +0100 Subject: [PATCH] stuff --- hui/src/element/builtin.rs | 10 ++++++++-- hui/src/element/builtin/slider.rs | 7 +++++++ hui/src/signal.rs | 16 ++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 hui/src/element/builtin/slider.rs diff --git a/hui/src/element/builtin.rs b/hui/src/element/builtin.rs index db0e26b..0962aba 100644 --- a/hui/src/element/builtin.rs +++ b/hui/src/element/builtin.rs @@ -1,4 +1,4 @@ -// "The essentials": +// Layout stuff: #[cfg(feature = "builtin_container")] pub mod container; @@ -12,7 +12,7 @@ pub mod spacer; #[cfg(feature = "builtin_elements")] pub mod br; -// "The basics": +// Basic elements: #[cfg(feature = "builtin_elements")] pub mod text; @@ -20,9 +20,15 @@ pub mod text; #[cfg(feature = "builtin_elements")] pub mod image; +// "Extras": +// (meant to be replaced if needed) + #[cfg(feature = "builtin_elements")] pub mod progress_bar; +#[cfg(feature = "builtin_elements")] +pub mod slider; + // Wrappers: #[cfg(feature = "builtin_elements")] diff --git a/hui/src/element/builtin/slider.rs b/hui/src/element/builtin/slider.rs new file mode 100644 index 0000000..81d6b9f --- /dev/null +++ b/hui/src/element/builtin/slider.rs @@ -0,0 +1,7 @@ +use crate::element::UiElement; + +pub struct Slider { + pub value: f32, +} + +//TODO diff --git a/hui/src/signal.rs b/hui/src/signal.rs index 89b7eb0..62c2416 100644 --- a/hui/src/signal.rs +++ b/hui/src/signal.rs @@ -53,3 +53,19 @@ impl SignalStore { self.sig.clear(); } } + +//TODO this, simplifies handling signals + +pub struct SignalTrigger(pub(crate) Box R>); + +impl SignalTrigger { + pub fn new R + 'static>(f: F) -> Self { + Self(Box::new(f)) + } +} + +impl R + 'static> From for SignalTrigger { + fn from(f: T) -> Self { + Self(Box::new(f)) + } +}