Add slider example
This commit is contained in:
parent
81faa964cc
commit
cd58190d35
1 changed files with 18 additions and 0 deletions
|
@ -1,5 +1,15 @@
|
||||||
use emigui::{label, math::*, types::*, widgets::*, Align, Region, TextStyle};
|
use emigui::{label, math::*, types::*, widgets::*, Align, Region, TextStyle};
|
||||||
|
|
||||||
|
pub fn show_value_gui(value: &mut usize, gui: &mut Region) {
|
||||||
|
gui.add(Slider::usize(value, 1, 1000));
|
||||||
|
if *value < 500 {
|
||||||
|
if gui.add(Button::new("Double it")).clicked {
|
||||||
|
*value *= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gui.add(label!("Value: {}", value));
|
||||||
|
}
|
||||||
|
|
||||||
pub struct App {
|
pub struct App {
|
||||||
checked: bool,
|
checked: bool,
|
||||||
count: usize,
|
count: usize,
|
||||||
|
@ -11,6 +21,8 @@ pub struct App {
|
||||||
num_boxes: usize,
|
num_boxes: usize,
|
||||||
|
|
||||||
num_columns: usize,
|
num_columns: usize,
|
||||||
|
|
||||||
|
slider_value: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for App {
|
impl Default for App {
|
||||||
|
@ -25,6 +37,8 @@ impl Default for App {
|
||||||
num_boxes: 1,
|
num_boxes: 1,
|
||||||
|
|
||||||
num_columns: 2,
|
num_columns: 2,
|
||||||
|
|
||||||
|
slider_value: 100,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,5 +133,9 @@ impl App {
|
||||||
}
|
}
|
||||||
gui.add_graphic(GuiCmd::PaintCommands(cmds));
|
gui.add_graphic(GuiCmd::PaintCommands(cmds));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
gui.foldable("Slider example", |gui| {
|
||||||
|
show_value_gui(&mut self.slider_value, gui);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue