Skip to main content

AppShell

Struct AppShell 

Source
pub struct AppShell<R>
where R: Renderer,
{ /* private fields */ }

Implementations§

Source§

impl<R> AppShell<R>
where R: Renderer, R::Error: Debug,

Source

pub fn new(renderer: R, root_key: Key, content: impl FnMut() + 'static) -> Self

Source

pub fn set_dev_options(&mut self, options: DevOptions)

Set development options for debugging and performance monitoring.

The FPS counter and other overlays are rendered directly by the renderer (not via composition) to avoid affecting performance measurements.

Source

pub fn dev_options(&self) -> &DevOptions

Get a reference to the current dev options.

Source

pub fn set_viewport(&mut self, width: f32, height: f32)

Source

pub fn set_buffer_size(&mut self, width: u32, height: u32)

Source

pub fn buffer_size(&self) -> (u32, u32)

Source

pub fn scene(&self) -> &R::Scene

Source

pub fn renderer(&mut self) -> &mut R

Source

pub fn set_frame_waker(&mut self, waker: impl Fn() + Send + Sync + 'static)

Source

pub fn clear_frame_waker(&mut self)

Source

pub fn should_render(&self) -> bool

Source

pub fn needs_redraw(&self) -> bool

Returns true if the shell needs to redraw (dirty flag, layout dirty, active animations). Note: Cursor blink is now timer-based and uses WaitUntil scheduling, not continuous redraw.

Source

pub fn mark_dirty(&mut self)

Marks the shell as dirty, indicating a redraw is needed.

Source

pub fn has_active_animations(&self) -> bool

Returns true if there are active animations or pending recompositions.

Source

pub fn next_event_time(&self) -> Option<Instant>

Returns the next scheduled event time for cursor blink. Use this for ControlFlow::WaitUntil scheduling.

Source

pub fn update(&mut self)

Source

pub fn set_cursor(&mut self, x: f32, y: f32) -> bool

Source

pub fn pointer_pressed(&mut self) -> bool

Source

pub fn pointer_released(&mut self) -> bool

Source

pub fn cancel_gesture(&mut self)

Cancels any active gesture, dispatching Cancel events to cached targets. Call this when:

  • Window loses focus
  • Mouse leaves window while button pressed
  • Any other gesture abort scenario
Source

pub fn on_key_event(&mut self, event: &KeyEvent) -> bool

Routes a keyboard event to the focused text field, if any.

Returns true if the event was consumed by a text field.

On desktop, Ctrl+C/X/V are handled here with system clipboard (arboard). On web, these keys are NOT handled here - they bubble to browser for native copy/paste events.

Source

pub fn on_paste(&mut self, text: &str) -> bool

Handles paste event from platform clipboard. Returns true if the paste was consumed by a focused text field. O(1) operation using stored handler.

Source

pub fn on_copy(&mut self) -> Option<String>

Handles copy request from platform. Returns the selected text from focused text field, or None. O(1) operation using stored handler.

Source

pub fn on_cut(&mut self) -> Option<String>

Handles cut request from platform. Returns the cut text from focused text field, or None. O(1) operation using stored handler.

Source

pub fn set_primary_selection(&mut self, text: &str)

Sets the Linux primary selection (for middle-click paste). This is called when text is selected in a text field. On non-Linux platforms, this is a no-op.

Source

pub fn get_primary_selection(&mut self) -> Option<String>

Gets text from the Linux primary selection (for middle-click paste). On non-Linux platforms, returns None.

Source

pub fn sync_selection_to_primary(&mut self)

Syncs the current text field selection to PRIMARY (Linux X11). Call this when selection changes in a text field.

Source

pub fn on_ime_preedit( &mut self, text: &str, cursor: Option<(usize, usize)>, ) -> bool

Handles IME preedit (composition) events. Called when the input method is composing text (e.g., typing CJK characters).

  • text: The current preedit text (empty to clear composition state)
  • cursor: Optional cursor position within the preedit text (start, end)

Returns true if a text field consumed the event.

Source

pub fn on_ime_delete_surrounding( &mut self, before_bytes: usize, after_bytes: usize, ) -> bool

Handles IME delete-surrounding events. Returns true if a text field consumed the event.

Source

pub fn log_debug_info(&mut self)

Source

pub fn layout_tree(&self) -> Option<&LayoutTree>

Get the current layout tree (for robot/testing)

Source

pub fn semantics_tree(&self) -> Option<&SemanticsTree>

Get the current semantics tree (for robot/testing)

Trait Implementations§

Source§

impl<R> Drop for AppShell<R>
where R: Renderer,

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<R> Freeze for AppShell<R>
where R: Freeze,

§

impl<R> !RefUnwindSafe for AppShell<R>

§

impl<R> !Send for AppShell<R>

§

impl<R> !Sync for AppShell<R>

§

impl<R> Unpin for AppShell<R>
where R: Unpin,

§

impl<R> !UnwindSafe for AppShell<R>

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