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<'_>
impl UiComposition<'_>
Sourcepub fn compose<R>(
&mut self,
build: impl FnOnce(&mut UiComposition<'_>) -> Result<R, UiError>,
) -> Result<R, UiError>
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.
Sourcepub fn push_clip(&mut self, rect: Rect) -> Result<(), UiError>
pub fn push_clip(&mut self, rect: Rect) -> Result<(), UiError>
Same logical geometry and validation as Ui::push_clip.
Sourcepub fn pop_clip(&mut self) -> Result<(), UiError>
pub fn pop_clip(&mut self) -> Result<(), UiError>
Pop only a clip pushed in this group; inherited clips remain protected.
Sourcepub fn modal(&mut self, blocker: u64) -> Result<(), UiError>
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.
Sourcepub fn panel(&mut self, rect: Rect, color: Color) -> Result<(), UiError>
pub fn panel(&mut self, rect: Rect, color: Color) -> Result<(), UiError>
Submit using Ui::panel.
Sourcepub fn gradient(
&mut self,
rect: Rect,
left: Color,
right: Color,
) -> Result<(), UiError>
pub fn gradient( &mut self, rect: Rect, left: Color, right: Color, ) -> Result<(), UiError>
Submit using Ui::gradient.
Sourcepub fn text_fmt(
&mut self,
rect: Rect,
style: TextStyle,
args: Arguments<'_>,
) -> Result<(), UiError>
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.
Sourcepub fn text(
&mut self,
rect: Rect,
text: &str,
style: TextStyle,
) -> Result<(), UiError>
pub fn text( &mut self, rect: Rect, text: &str, style: TextStyle, ) -> Result<(), UiError>
Submit using Ui::text.
Sourcepub fn wrapped_text(
&mut self,
rect: Rect,
text: &str,
style: TextStyle,
limit: LineLimit,
) -> Result<TextBlockMetrics, UiError>
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.
Sourcepub fn label(
&mut self,
rect: Rect,
text: &str,
style: TextStyle,
) -> Result<(), UiError>
pub fn label( &mut self, rect: Rect, text: &str, style: TextStyle, ) -> Result<(), UiError>
Submit using Ui::label, including full inspection copy when opted in.
Submit using Ui::button.
Submit using Ui::hud_button.
Submit using Ui::button_with_options.
Submit using Ui::hud_button_with_options.
Source§impl UiComposition<'_>
impl UiComposition<'_>
Sourcepub fn stat_rows(
&mut self,
bounds: Rect,
rows: &[StatRow<'_>],
style: StatRowsStyle,
) -> Result<StatRowsReport, UiError>
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.