mirror of
https://github.com/griffi-gh/hUI.git
synced 2024-11-25 08:28:42 -06:00
Compare commits
3 commits
f514746ecc
...
03f1d75d3c
Author | SHA1 | Date | |
---|---|---|---|
griffi-gh | 03f1d75d3c | ||
griffi-gh | 3f99151d93 | ||
griffi-gh | ad89088557 |
|
@ -34,12 +34,17 @@ ui_main!(
|
|||
run: |ui, size, (ref mut counter, image)| {
|
||||
Container::default()
|
||||
.with_size(size!(100%))
|
||||
.with_align(Alignment::Center)
|
||||
.with_padding(10.)
|
||||
.with_align((Alignment::Center, Alignment::Begin))
|
||||
.with_direction(Direction::Horizontal)
|
||||
.with_gap(5.)
|
||||
.with_background((0.1, 0.1, 0.1))
|
||||
.with_wrap(true)
|
||||
.with_children(|ui| {
|
||||
Text::new("Number of images:")
|
||||
.with_text_size(24)
|
||||
.add_child(ui);
|
||||
Br.add_child(ui);
|
||||
Container::default()
|
||||
.with_padding(10.)
|
||||
.with_background(color::ORANGE)
|
||||
|
@ -78,11 +83,9 @@ ui_main!(
|
|||
})
|
||||
.add_root(ui, size);
|
||||
|
||||
ui.process_signals(|sig| {
|
||||
match sig {
|
||||
CounterSignal::Increment => *counter += 1,
|
||||
CounterSignal::Decrement => *counter -= 1,
|
||||
}
|
||||
ui.process_signals(|sig| match sig {
|
||||
CounterSignal::Increment => *counter += 1,
|
||||
CounterSignal::Decrement => *counter -= 1,
|
||||
});
|
||||
}
|
||||
);
|
||||
|
|
|
@ -22,12 +22,9 @@ glam = "0.25"
|
|||
fontdue = "0.8"
|
||||
rect_packer = "0.2"
|
||||
log = "0.4"
|
||||
nz = "0.3"
|
||||
document-features = "0.2"
|
||||
derive_setters = "0.1"
|
||||
#smallvec = "1.13"
|
||||
tinyset = "0.4"
|
||||
#mopa = "0.2"
|
||||
|
||||
[features]
|
||||
default = ["builtin_elements", "builtin_font", "pixel_perfect_text"]
|
||||
|
|
|
@ -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")]
|
||||
|
|
7
hui/src/element/builtin/slider.rs
Normal file
7
hui/src/element/builtin/slider.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
use crate::element::UiElement;
|
||||
|
||||
pub struct Slider {
|
||||
pub value: f32,
|
||||
}
|
||||
|
||||
//TODO
|
|
@ -53,3 +53,19 @@ impl SignalStore {
|
|||
self.sig.clear();
|
||||
}
|
||||
}
|
||||
|
||||
//TODO this, simplifies handling signals
|
||||
|
||||
pub struct SignalTrigger<R: UiSignal + 'static, A = ()>(pub(crate) Box<dyn Fn(A) -> R>);
|
||||
|
||||
impl<R: UiSignal + 'static, A> SignalTrigger<R, A> {
|
||||
pub fn new<F: Fn(A) -> R + 'static>(f: F) -> Self {
|
||||
Self(Box::new(f))
|
||||
}
|
||||
}
|
||||
|
||||
impl<R: UiSignal + 'static, A, T: Fn(A) -> R + 'static> From<T> for SignalTrigger<R, A> {
|
||||
fn from(f: T) -> Self {
|
||||
Self(Box::new(f))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue