Struct UiComposition

Source
pub struct UiComposition<'a> { /* private fields */ }
Expand description

Restricted drawing/widget submission inside Ui::compose.

Methods use the existing command budgets and styles. The first submission error is sticky: later submissions return it without modifying the UI, and the group fails even if the callback ignores that error. No mutable Ui, input delivery, focus changes, painting, lifecycle or configuration is exposed. Callback/formatting side effects outside the UI cannot be rolled back.

Clips must be balanced within each group; popping an inherited clip or leaving a new clip open rejects the group with UiError::InvalidLayout. Nested groups have independent rollback and may be replaced by a fallback; propagate their error with ? to reject the containing group. At most 16 groups may be active, including the outermost group. Checkpoints use fixed stack storage; no command/text arena is cloned or widget undo journal kept.

See Ui::compose for a complete result-card/fallback recipe. Input and lifecycle operations are intentionally unavailable:

ⓘ
use ferravex_render::ui::{Ui, Viewport};
let mut ui = Ui::new();
ui.begin(Viewport::responsive([320., 240.], [0.; 4]).unwrap());
ui.compose(|group| {
    group.finish(true); // Input delivery cannot be rolled back.
    Ok(())
}).unwrap();

Implementations§

Source§

impl UiComposition<'_>

Source

pub fn compose<R>( &mut self, build: impl FnOnce(&mut UiComposition<'_>) -> Result<R, UiError>, ) -> Result<R, UiError>

Independently atomic subgroup. A handled error does not poison this group; use ? to propagate it. Depth 17 rejects before calling build.

Source

pub fn push_clip(&mut self, rect: Rect) -> Result<(), UiError>

Same logical geometry and validation as Ui::push_clip.

Source

pub fn pop_clip(&mut self) -> Result<(), UiError>

Pop only a clip pushed in this group; inherited clips remain protected.

Source

pub fn modal(&mut self, blocker: u64) -> Result<(), UiError>

Same modal scope change as Ui::modal, restored if this group fails. Repeated modal calls reuse widget storage; no destructive-operation log.

Source

pub fn panel(&mut self, rect: Rect, color: Color) -> Result<(), UiError>

Submit using Ui::panel.

Source

pub fn gradient( &mut self, rect: Rect, left: Color, right: Color, ) -> Result<(), UiError>

Submit using Ui::gradient.

Source

pub fn text_fmt( &mut self, rect: Rect, style: TextStyle, args: Arguments<'_>, ) -> Result<(), UiError>

Submit using Ui::text_fmt; formatting runs only until the first error.

Source

pub fn text( &mut self, rect: Rect, text: &str, style: TextStyle, ) -> Result<(), UiError>

Submit using Ui::text.

Source

pub fn wrapped_text( &mut self, rect: Rect, text: &str, style: TextStyle, limit: LineLimit, ) -> Result<TextBlockMetrics, UiError>

Submit using Ui::wrapped_text, returning its measured block metrics.

Source

pub fn label( &mut self, rect: Rect, text: &str, style: TextStyle, ) -> Result<(), UiError>

Submit using Ui::label, including full inspection copy when opted in.

Source

pub fn button( &mut self, id: u64, rect: Rect, text: &str, enabled: bool, style: ButtonStyle, ) -> Result<(), UiError>

Submit using Ui::button.

Source

pub fn hud_button( &mut self, id: u64, rect: Rect, text: &str, enabled: bool, style: ButtonStyle, ) -> Result<(), UiError>

Submit using Ui::hud_button.

Source

pub fn button_with_options( &mut self, id: u64, rect: Rect, text: &str, options: ButtonOptions, style: ButtonStyle, ) -> Result<(), UiError>

Source

pub fn hud_button_with_options( &mut self, id: u64, rect: Rect, text: &str, options: ButtonOptions, style: ButtonStyle, ) -> Result<(), UiError>

Source§

impl UiComposition<'_>

Source

pub fn stat_rows( &mut self, bounds: Rect, rows: &[StatRow<'_>], style: StatRowsStyle, ) -> Result<StatRowsReport, UiError>

Measure and submit one nested atomic list. A handled error allows a local fallback; propagate ? when the enclosing card requires this section.

Trait Implementations§

Source§

impl Drop for UiComposition<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for UiComposition<'a>

§

impl<'a> RefUnwindSafe for UiComposition<'a>

§

impl<'a> Send for UiComposition<'a>

§

impl<'a> Sync for UiComposition<'a>

§

impl<'a> Unpin for UiComposition<'a>

§

impl<'a> !UnwindSafe for UiComposition<'a>

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.