pub struct Gui {
pub input: Input,
/* private fields */
}
Expand description
Acts as an intermediary between ggez
and egui
use ggegui::{egui, Gui};
struct State {
gui: Gui,
}
impl State {
pub fn new(ctx: &mut Context) -> Self {
Self {
gui: Gui::new(ctx),
}
}
}
impl EventHandler for State {
fn update(&mut self, ctx: &mut Context) -> GameResult {
let gui_ctx = self.gui.ctx();
egui::Window::new("Title").show(&gui_ctx, |ui| {
ui.label("label");
if ui.button("button").clicked() {
println!("button clicked");
}
});
self.gui.update(ctx);
Ok(())
}
fn draw(&mut self, ctx: &mut Context) -> GameResult {
let mut canvas = graphics::Canvas::from_frame(ctx, Color::BLACK);
canvas.draw(
&self.egui_backend,
DrawParam::default().dest(glam::Vec2::ZERO),
);
canvas.finish(ctx)
}
}
Fields§
§input: Input
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Gui
impl !RefUnwindSafe for Gui
impl Send for Gui
impl Sync for Gui
impl Unpin for Gui
impl !UnwindSafe for Gui
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
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> HasMut<T> for T
impl<T> HasMut<T> for T
Source§fn retrieve_mut(&mut self) -> &mut T
fn retrieve_mut(&mut self) -> &mut T
Method to retrieve the context type as mutable.
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more