pub struct PaneOverlay { /* private fields */ }Expand description
A Pane UI instance that renders into an existing wgpu surface.
You retain full control of the window, event loop, and wgpu device. Pane composites its output on top of whatever you have already rendered that frame.
Create with overlay, then call handle_event
from your winit event loop and draw each frame.
Implementations§
Source§impl PaneOverlay
impl PaneOverlay
Sourcepub fn handle_event(&mut self, event: &WindowEvent, pw: f32, ph: f32)
pub fn handle_event(&mut self, event: &WindowEvent, pw: f32, ph: f32)
Forward a winit WindowEvent to Pane’s input handler.
Sourcepub fn handle_gamepad_event(&mut self, event: Event)
pub fn handle_gamepad_event(&mut self, event: Event)
Forward a gilrs gamepad event manually.
Use this if you own the gilrs instance yourself — pass None for gilrs in
overlay first to prevent Pane from also polling it internally.
Sourcepub fn disable_auto_gamepad(&mut self)
pub fn disable_auto_gamepad(&mut self)
Stop Pane from polling gilrs internally.
Sourcepub fn draw(
&mut self,
encoder: &mut CommandEncoder,
view: &TextureView,
pw: f32,
ph: f32,
) -> Vec<PaneAction>
pub fn draw( &mut self, encoder: &mut CommandEncoder, view: &TextureView, pw: f32, ph: f32, ) -> Vec<PaneAction>
Tick and render the UI into an existing render pass.
Call once per frame, after your own render commands and before presenting.
Returns all PaneActions emitted since the last call.
encoder— your active command encoder for the current frame.view— the texture view to render into (typically your swap chain image).pw/ph— window dimensions in logical pixels.
Sourcepub fn read(&self, id: &str) -> Option<(&UiItem, WidgetState)>
pub fn read(&self, id: &str) -> Option<(&UiItem, WidgetState)>
Returns the item data and its current visual state for any widget by id.
Pattern-match on UiItem to access widget-specific fields:
if let Some((UiItem::Button(b), vis)) = ui.read("my_button") {
println!("disabled={} hovered={}", b.disabled, vis.hovered);
}
if let Some((UiItem::Slider(s), vis)) = ui.read("volume") {
println!("value={} grabbed={}", s.value, vis.grabbed);
}Sourcepub fn write(&mut self, id: &str, value: &WriteValue)
pub fn write(&mut self, id: &str, value: &WriteValue)
Set a widget’s value programmatically.
See WriteValue for the supported widget types and their matching variants.
Mismatched types and unknown ids are logged and ignored.
Sourcepub fn create(&mut self, root: &str, builder: impl WidgetBuilder) -> bool
pub fn create(&mut self, root: &str, builder: impl WidgetBuilder) -> bool
Add a code-built widget to a named root. Returns false if the id is already
in use or the root doesn’t exist.
Sourcepub fn destroy(&mut self, id: &str) -> bool
pub fn destroy(&mut self, id: &str) -> bool
Remove a widget by id from any root. Returns true if a widget was removed.
Sourcepub fn create_root(&mut self, name: impl Into<String>)
pub fn create_root(&mut self, name: impl Into<String>)
Create an empty root that can be populated with Self::create.
Sourcepub fn style_id(&self, name: &str) -> Option<StyleId>
pub fn style_id(&self, name: &str) -> Option<StyleId>
Resolve a style name to its StyleId for use with builders.
Sourcepub fn default_style(&self) -> Option<&str>
pub fn default_style(&self) -> Option<&str>
Returns the name of the current default style, if one is set.
Sourcepub fn set_default_style(&mut self, name: &str) -> bool
pub fn set_default_style(&mut self, name: &str) -> bool
Switch the default style by name. Returns false if the name is not registered.
Sourcepub const fn set_debug(&mut self, on: bool)
pub const fn set_debug(&mut self, on: bool)
Enable or disable debug message logging. When on, every internal UiMsg is printed to stdout.
Sourcepub fn push_toast(
&mut self,
message: impl Into<String>,
duration: f32,
x: f32,
y: f32,
width: f32,
height: f32,
)
pub fn push_toast( &mut self, message: impl Into<String>, duration: f32, x: f32, y: f32, width: f32, height: f32, )
Spawn a transient toast notification at the given position.
Sourcepub fn actor_move_to(&mut self, id: &str, x: f32, y: f32, speed: f32)
pub fn actor_move_to(&mut self, id: &str, x: f32, y: f32, speed: f32)
Programmatically send an actor to a fixed position, overriding its RON behaviours.
Sourcepub fn actor_follow_cursor(&mut self, id: &str, speed: f32, trail: f32)
pub fn actor_follow_cursor(&mut self, id: &str, speed: f32, trail: f32)
Programmatically make an actor follow the cursor, overriding its RON behaviours.
Sourcepub fn actor_reset(&mut self, id: &str)
pub fn actor_reset(&mut self, id: &str)
Clear any programmatic override on an actor, returning it to its RON behaviours.
Sourcepub fn actor_set_pos(&mut self, id: &str, x: f32, y: f32)
pub fn actor_set_pos(&mut self, id: &str, x: f32, y: f32)
Teleport an actor to a position instantly, without lerping.
Auto Trait Implementations§
impl !Freeze for PaneOverlay
impl !RefUnwindSafe for PaneOverlay
impl Send for PaneOverlay
impl !Sync for PaneOverlay
impl Unpin for PaneOverlay
impl UnsafeUnpin for PaneOverlay
impl !UnwindSafe for PaneOverlay
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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