pub struct UiBuilder {
pub id_salt: Option<Id>,
pub global_scope: bool,
pub ui_stack_info: UiStackInfo,
pub layer_id: Option<LayerId>,
pub max_rect: Option<Rect>,
pub layout: Option<Layout>,
pub disabled: bool,
pub invisible: bool,
pub sizing_pass: bool,
pub style: Option<Arc<Style>>,
pub sense: Option<Sense>,
}Expand description
Build a Ui as the child of another Ui.
By default, everything is inherited from the parent,
except for max_rect which by default is set to
the parent Ui::available_rect_before_wrap.
Fields§
§id_salt: Option<Id>§global_scope: bool§ui_stack_info: UiStackInfo§layer_id: Option<LayerId>§max_rect: Option<Rect>§layout: Option<Layout>§disabled: bool§invisible: bool§sizing_pass: bool§style: Option<Arc<Style>>§sense: Option<Sense>Implementations§
Source§impl UiBuilder
impl UiBuilder
pub fn new() -> Self
Sourcepub fn id(self, id: impl Hash) -> Self
pub fn id(self, id: impl Hash) -> Self
Set an id of the new Ui that is independent of the parent Ui.
This way child widgets can be moved in the ui tree without losing state.
You have to ensure that in a frame the child widgets do not get rendered in multiple places.
You should set the same unique id at every place in the ui tree where you want the
child widgets to share state.
If the child widgets are not moved in the ui tree, use UiBuilder::id_salt instead.
This is a shortcut for .id_salt(my_id).global_scope(true).
Sourcepub fn global_scope(self, global_scope: bool) -> Self
pub fn global_scope(self, global_scope: bool) -> Self
Make the new Ui child ids independent of the parent Ui.
This way child widgets can be moved in the ui tree without losing state.
You have to ensure that in a frame the child widgets do not get rendered in multiple places.
You should set the same globally unique id_salt at every place in the ui tree where you want the
child widgets to share state.
Sourcepub fn ui_stack_info(self, ui_stack_info: UiStackInfo) -> Self
pub fn ui_stack_info(self, ui_stack_info: UiStackInfo) -> Self
Provide some information about the new Ui being built.
Sourcepub fn max_rect(self, max_rect: Rect) -> Self
pub fn max_rect(self, max_rect: Rect) -> Self
Set the max rectangle, within which widgets will go.
New widgets will try to fit within this rectangle.
Text labels will wrap to fit within max_rect.
Separator lines will span the max_rect.
If a new widget doesn’t fit within the max_rect then the
Ui will make room for it by expanding both min_rect and
If not set, this will be set to the parent
Ui::available_rect_before_wrap.
Sourcepub fn layout(self, layout: Layout) -> Self
pub fn layout(self, layout: Layout) -> Self
Override the layout.
Will otherwise be inherited from the parent.
Sourcepub fn disabled(self) -> Self
pub fn disabled(self) -> Self
Make the new Ui disabled, i.e. grayed-out and non-interactive.
Note that if the parent Ui is disabled, the child will always be disabled.
Sourcepub fn invisible(self) -> Self
pub fn invisible(self) -> Self
Make the contents invisible.
Will also disable the Ui (see Self::disabled).
If the parent Ui is invisible, the child will always be invisible.
Sourcepub fn sizing_pass(self) -> Self
pub fn sizing_pass(self) -> Self
Set to true in special cases where we do one frame where we size up the contents of the Ui, without actually showing it.
If the sizing_pass flag is set on the parent,
the child will inherit it automatically.
Sourcepub fn style(self, style: impl Into<Arc<Style>>) -> Self
pub fn style(self, style: impl Into<Arc<Style>>) -> Self
Override the style.
Otherwise will inherit the style of the parent.
Sourcepub fn sense(self, sense: Sense) -> Self
pub fn sense(self, sense: Sense) -> Self
Set if you want sense clicks and/or drags. Default is Sense::hover.
The sense will be registered below the Senses of any widgets contained in this Ui, so
if the user clicks a button contained within this Ui, that button will receive the click
instead.
The response can be read early with Ui::response.
Sourcepub fn closable(self) -> Self
pub fn closable(self) -> Self
Make this Ui closable.
Calling Ui::close in a child Ui will mark this Ui for closing.
After Ui::close was called, Ui::should_close and crate::Response::should_close will
return true (for this frame).
This works by adding a ClosableTag to the UiStackInfo.