acidalia_imgui

Struct ImguiElement

Source
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>

Source

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>

Source§

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>, )

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>
where F: Unpin, Data: Unpin,

§

impl<Data, F> !UnwindSafe for ImguiElement<Data, F>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToVec<T> for T

Source§

fn to_vec(self) -> Vec<T>

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>