pub struct ImguiElement<Data, F: Fn(&Ui<'_>, &Engine, &mut Data)> { /* private fields */ }
Expand description
Builds and renders an imgui::Ui
constructed from a user-defined function.
Implementations§
Source§impl<Data, F: Fn(&Ui<'_>, &Engine, &mut Data)> ImguiElement<Data, F>
impl<Data, F: Fn(&Ui<'_>, &Engine, &mut Data)> ImguiElement<Data, F>
Sourcepub fn new(func: F, engine: &Engine) -> Self
pub fn new(func: F, engine: &Engine) -> Self
Construct a new ImguiElement
from a function, which will take in a Ui
struct and modify it
as needed before drawing.
Examples found in repository?
examples/basic_imgui.rs (lines 18-29)
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
fn main() {
let engine = EngineBuilder::new(|wb| wb.with_maximized(true))
.bg_color(acidalia::wgpu::Color {
r: 0.1,
g: 0.2,
b: 0.3,
a: 1.0,
})
.build();
let ui_el = ImguiElement::new(
|ui, _engine, d: &mut Data| {
imgui::Window::new("Main").build(ui, || {
if ui.small_button("Increment count") {
d.count += 1;
}
ui.text(format!("Count: {}", d.count));
});
},
&engine,
);
let data = Data::default();
engine.run(screen!(ui_el), data);
}
Trait Implementations§
Source§impl<Data, F: Fn(&Ui<'_>, &Engine, &mut Data)> Element<Data> for ImguiElement<Data, F>
impl<Data, F: Fn(&Ui<'_>, &Engine, &mut Data)> Element<Data> for ImguiElement<Data, F>
Source§fn update(
&mut self,
engine: &mut Engine,
_data: &mut Data,
event: &Event<'_, ()>,
)
fn update( &mut self, engine: &mut Engine, _data: &mut Data, event: &Event<'_, ()>, )
Process
winit
events.Source§fn render<'a: 'rp, 'rp>(
&'a mut self,
engine: &mut Engine,
data: &mut Data,
_frame: &SurfaceTexture,
render_pass: &mut RenderPass<'rp>,
)
fn render<'a: 'rp, 'rp>( &'a mut self, engine: &mut Engine, data: &mut Data, _frame: &SurfaceTexture, render_pass: &mut RenderPass<'rp>, )
Draw to the screen. Note: it is expected that trait implementers will use
the supplied render pass, however, to explain the lifetime annotations,
the render pass is provided to all elements in the screen, so they all
must live as long as the render pass.
Auto Trait Implementations§
impl<Data, F> !Freeze for ImguiElement<Data, F>
impl<Data, F> !RefUnwindSafe for ImguiElement<Data, F>
impl<Data, F> !Send for ImguiElement<Data, F>
impl<Data, F> !Sync for ImguiElement<Data, F>
impl<Data, F> Unpin for ImguiElement<Data, F>
impl<Data, F> !UnwindSafe for ImguiElement<Data, F>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more