egui/emgui/src/emgui.rs

30 lines
811 B
Rust
Raw Normal View History

2019-01-05 20:23:53 +00:00
use crate::{font::Font, layout, style, types::*};
2018-12-26 22:08:50 +00:00
/// Encapsulates input, layout and painting for ease of use.
2019-01-05 14:28:07 +00:00
#[derive(Clone)]
2018-12-26 22:08:50 +00:00
pub struct Emgui {
pub last_input: RawInput,
pub layout: layout::Layout,
pub style: style::Style,
}
impl Emgui {
2019-01-05 20:23:53 +00:00
pub fn new(font: Font) -> Emgui {
2019-01-05 14:28:07 +00:00
Emgui {
last_input: Default::default(),
2019-01-05 20:23:53 +00:00
layout: layout::Layout::new(font),
2019-01-05 14:28:07 +00:00
style: Default::default(),
}
}
2018-12-26 22:08:50 +00:00
pub fn new_frame(&mut self, new_input: RawInput) {
let gui_input = GuiInput::from_last_and_new(&self.last_input, &new_input);
self.last_input = new_input;
2018-12-28 22:29:24 +00:00
self.layout.new_frame(gui_input);
2018-12-26 22:08:50 +00:00
}
pub fn paint(&mut self) -> Vec<PaintCmd> {
style::into_paint_commands(self.layout.gui_commands(), &self.style)
}
}