2018-12-26 16:32:58 +00:00
|
|
|
use crate::{gui::Gui, math::*, types::*};
|
2018-12-26 09:46:23 +00:00
|
|
|
|
|
|
|
pub struct App {
|
2018-12-26 21:17:33 +00:00
|
|
|
checked: bool,
|
2018-12-26 09:46:23 +00:00
|
|
|
count: i32,
|
2018-12-26 16:32:58 +00:00
|
|
|
|
|
|
|
width: f32,
|
|
|
|
height: f32,
|
|
|
|
corner_radius: f32,
|
|
|
|
stroke_width: f32,
|
2018-12-26 09:46:23 +00:00
|
|
|
}
|
|
|
|
|
2018-12-26 21:17:33 +00:00
|
|
|
impl Default for App {
|
|
|
|
fn default() -> App {
|
2018-12-26 16:32:58 +00:00
|
|
|
App {
|
2018-12-26 21:17:33 +00:00
|
|
|
checked: false,
|
2018-12-26 16:32:58 +00:00
|
|
|
count: 0,
|
|
|
|
width: 100.0,
|
|
|
|
height: 50.0,
|
|
|
|
corner_radius: 5.0,
|
|
|
|
stroke_width: 2.0,
|
|
|
|
}
|
|
|
|
}
|
2018-12-26 21:17:33 +00:00
|
|
|
}
|
2018-12-26 16:32:58 +00:00
|
|
|
|
2018-12-26 21:17:33 +00:00
|
|
|
impl App {
|
2018-12-26 09:46:23 +00:00
|
|
|
pub fn show_gui(&mut self, gui: &mut Gui) {
|
2018-12-26 21:17:33 +00:00
|
|
|
gui.checkbox("checkbox", &mut self.checked);
|
|
|
|
|
2018-12-26 09:46:23 +00:00
|
|
|
if gui.button("Click me").clicked {
|
|
|
|
self.count += 1;
|
|
|
|
}
|
|
|
|
|
2018-12-26 16:01:46 +00:00
|
|
|
gui.label(format!("The button have been clicked {} times", self.count));
|
|
|
|
|
2018-12-26 21:17:33 +00:00
|
|
|
gui.slider_f32("width", &mut self.width, 0.0, 500.0);
|
|
|
|
gui.slider_f32("height", &mut self.height, 0.0, 500.0);
|
|
|
|
gui.slider_f32("corner_radius", &mut self.corner_radius, 0.0, 50.0);
|
|
|
|
gui.slider_f32("stroke_width", &mut self.stroke_width, 0.0, 10.0);
|
2018-12-26 16:32:58 +00:00
|
|
|
|
|
|
|
gui.commands
|
|
|
|
.push(GuiCmd::PaintCommands(vec![PaintCmd::Rect {
|
|
|
|
corner_radius: self.corner_radius,
|
|
|
|
fill_style: Some("#888888ff".into()),
|
|
|
|
pos: vec2(300.0, 100.0),
|
|
|
|
size: vec2(self.width, self.height),
|
|
|
|
outline: Some(Outline {
|
|
|
|
width: self.stroke_width,
|
|
|
|
style: "#ffffffff".into(),
|
|
|
|
}),
|
|
|
|
}]));
|
2018-12-26 09:46:23 +00:00
|
|
|
|
2018-12-26 14:28:38 +00:00
|
|
|
let commands_json = format!("{:#?}", gui.gui_commands());
|
|
|
|
gui.label(format!("All gui commands: {}", commands_json));
|
2018-12-26 09:46:23 +00:00
|
|
|
}
|
|
|
|
}
|