pub struct UiBuilder {Show 14 fields
pub id_source: Option<IdSource>,
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>,
pub accessibility_parent: Option<Id>,
pub accessibility_label: Option<String>,
pub accessibility_role: Option<Role>,
pub classes: Classes,
}egui only.Expand description
The properties specified when creating a top-level or child 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.
See also Ui::new and Ui::new_child for uses.
Fields§
§id_source: Option<IdSource>§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>§accessibility_parent: Option<Id>§accessibility_label: Option<String>§accessibility_role: Option<Role>§classes: ClassesImplementations§
Source§impl UiBuilder
impl UiBuilder
pub fn new() -> UiBuilder
Sourcepub fn id_salt(self, id_salt: impl AsIdSalt) -> UiBuilder
pub fn id_salt(self, id_salt: impl AsIdSalt) -> UiBuilder
Seed the child Ui with this id_salt, which will be mixed
with the Ui::scope_id of the parent.
You should give each Ui an id_salt that is unique
within the parent, or give it none at all.
Sourcepub fn scope_id(self, scope_id: Id) -> UiBuilder
pub fn scope_id(self, scope_id: Id) -> UiBuilder
Set the Ui::scope_id of the new Ui to something 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 scope_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.
The scope_id is also used as the Ui::unique_id of the new Ui, so it must be globally unique.
Sourcepub fn id(self, id: Id) -> UiBuilder
👎Deprecated: Renamed to UiBuilder::scope_id
pub fn id(self, id: Id) -> UiBuilder
Renamed to UiBuilder::scope_id
Renamed to Self::scope_id.
Sourcepub fn ui_stack_info(self, ui_stack_info: UiStackInfo) -> UiBuilder
pub fn ui_stack_info(self, ui_stack_info: UiStackInfo) -> UiBuilder
Provide some information about the new Ui being built.
Sourcepub fn max_rect(self, max_rect: Rect) -> UiBuilder
pub fn max_rect(self, max_rect: Rect) -> UiBuilder
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) -> UiBuilder
pub fn layout(self, layout: Layout) -> UiBuilder
Override the layout.
Will otherwise be inherited from the parent.
Sourcepub fn disabled(self) -> UiBuilder
pub fn disabled(self) -> UiBuilder
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.
See also crate::Ui::add_enabled, crate::Ui::add_enabled_ui and crate::Ui::is_enabled.
Sourcepub fn invisible(self) -> UiBuilder
pub fn invisible(self) -> UiBuilder
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) -> UiBuilder
pub fn sizing_pass(self) -> UiBuilder
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>>) -> UiBuilder
pub fn style(self, style: impl Into<Arc<Style>>) -> UiBuilder
Override the style.
Otherwise will inherit the style of the parent.
Sourcepub fn sense(self, sense: Sense) -> UiBuilder
pub fn sense(self, sense: Sense) -> UiBuilder
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) -> UiBuilder
pub fn closable(self) -> UiBuilder
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.
Sourcepub fn accessibility_parent(self, parent_id: Id) -> UiBuilder
pub fn accessibility_parent(self, parent_id: Id) -> UiBuilder
Set the accessibility parent for this Ui.
Pass Ui::unique_id or Response::id, not Ui::scope_id.
This will override the automatic parent assignment for accessibility purposes.
If not set, the parent Ui’s ID will be used as the accessibility parent.
Sourcepub fn accessibility_label(self, label: impl Into<String>) -> UiBuilder
pub fn accessibility_label(self, label: impl Into<String>) -> UiBuilder
Sourcepub fn accessibility_role(self, role: Role) -> UiBuilder
pub fn accessibility_role(self, role: Role) -> UiBuilder
Give this Ui’s node a role other than the one its UiKind implies,
e.g. Role::Alert for a toast.
Trait Implementations§
Source§impl HasClasses for UiBuilder
impl HasClasses for UiBuilder
fn classes(&self) -> &Classes
fn classes_mut(&mut self) -> &mut Classes
Source§fn add_class(&mut self, class: impl Into<ClassName>) -> &mut Selfwhere
Self: Sized,
fn add_class(&mut self, class: impl Into<ClassName>) -> &mut Selfwhere
Self: Sized,
Source§fn set_class(&mut self, class: impl Into<ClassName>, present: bool) -> &mut Selfwhere
Self: Sized,
fn set_class(&mut self, class: impl Into<ClassName>, present: bool) -> &mut Selfwhere
Self: Sized,
present, remove it otherwise. Read moreSource§fn remove_class(&mut self, class: impl Into<ClassName>) -> &mut Selfwhere
Self: Sized,
fn remove_class(&mut self, class: impl Into<ClassName>) -> &mut Selfwhere
Self: Sized,
Source§fn with_class(self, class: impl Into<ClassName>) -> Selfwhere
Self: Sized,
fn with_class(self, class: impl Into<ClassName>) -> Selfwhere
Self: Sized,
self.Source§fn add_classes(&mut self, classes: Classes) -> &mut Self
fn add_classes(&mut self, classes: Classes) -> &mut Self
Source§fn with_classes(self, classes: Classes) -> Selfwhere
Self: Sized,
fn with_classes(self, classes: Classes) -> Selfwhere
Self: Sized,
self.Source§fn add_class_if(
&mut self,
class: impl Into<ClassName>,
condition: bool,
) -> &mut Selfwhere
Self: Sized,
fn add_class_if(
&mut self,
class: impl Into<ClassName>,
condition: bool,
) -> &mut Selfwhere
Self: Sized,
Source§fn with_class_if(self, class: impl Into<ClassName>, condition: bool) -> Selfwhere
Self: Sized,
fn with_class_if(self, class: impl Into<ClassName>, condition: bool) -> Selfwhere
Self: Sized,
self if the condition is true. Read moreSource§fn iter_classes(&self) -> Iter<'_, ClassName> ⓘ
fn iter_classes(&self) -> Iter<'_, ClassName> ⓘ
Source§fn classes_as_slice(&self) -> &[ClassName]
fn classes_as_slice(&self) -> &[ClassName]
Auto Trait Implementations§
impl !RefUnwindSafe for UiBuilder
impl !UnwindSafe for UiBuilder
impl Forget for UiBuilder
impl Freeze for UiBuilderwhere
NonZero<u64>: Freeze,
*const u8 is !null: Freeze,
PhantomData<(String, Option<Arc<dyn Any + Sync + Send>>)>: Freeze,
*const ArcInner<Style> is !null: Freeze,
PhantomData<ArcInner<Style>>: Freeze,
PhantomData<u8>: Freeze,
&'static str: Freeze,
*const ArcInner<str> is !null: Freeze,
PhantomData<ArcInner<str>>: Freeze,
*const ClassName is !null: Freeze,
PhantomData<ClassName>: Freeze,
impl Move for UiBuilder
impl Send for UiBuilder
impl Sync for UiBuilder
impl Unpin for UiBuilder
impl UnsafeUnpin for UiBuilderwhere
NonZeroU64Inner: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<(String, Option<Arc<dyn Any + Sync + Send>>)>: UnsafeUnpin,
*const ArcInner<Style> is !null: UnsafeUnpin,
PhantomData<ArcInner<Style>>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
&'static str: UnsafeUnpin,
*const ArcInner<str> is !null: UnsafeUnpin,
PhantomData<ArcInner<str>>: UnsafeUnpin,
*const ClassName is !null: UnsafeUnpin,
PhantomData<ClassName>: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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