pub struct Widget {
pub kind: WidgetKind,
pub id: Option<String>,
pub style: Style,
pub flex_dir: FlexDir,
pub children: Vec<Widget>,
pub on_click: Option<String>,
pub enabled: bool,
pub focused: bool,
}Expand description
A single widget in the UI tree.
Fields§
§kind: WidgetKind§id: Option<String>§style: Style§flex_dir: FlexDir§children: Vec<Widget>§on_click: Option<String>§enabled: bool§focused: boolImplementations§
Source§impl Widget
impl Widget
pub fn id(self, id: impl Into<String>) -> Widget
pub fn on_click(self, ev: impl Into<String>) -> Widget
pub fn child(self, w: Widget) -> Widget
Sourcepub fn w(self, w: impl Into<Units>) -> Widget
pub fn w(self, w: impl Into<Units>) -> Widget
Accepts a plain px value (0.0 = auto) or a Units directly —
e.g. .w(18.0) or .w(Units::Percent(60.0)).
pub fn h(self, h: impl Into<Units>) -> Widget
pub fn min_w(self, v: f32) -> Widget
pub fn min_h(self, v: f32) -> Widget
pub fn flex(self, v: f32) -> Widget
pub fn flex_dir(self, v: FlexDir) -> Widget
pub fn gap(self, v: f32) -> Widget
pub fn bg(self, v: u32) -> Widget
pub fn color(self, v: u32) -> Widget
pub fn align(self, v: Align) -> Widget
pub fn font_scale(self, v: f32) -> Widget
pub fn shadow(self, v: bool) -> Widget
pub fn no_wrap(self) -> Widget
pub fn focus_style(self, v: FocusStyle) -> Widget
pub fn focus_color(self, v: u32) -> Widget
pub fn dock(self, v: Dock) -> Widget
pub fn enabled(self, v: bool) -> Widget
pub fn focused(self, v: bool) -> Widget
Sourcepub fn at(self, x: f32, y: f32) -> Widget
pub fn at(self, x: f32, y: f32) -> Widget
Position absolutely at (x, y) inside the parent’s content box — see Style::pos.
Sourcepub fn ellipsis(self) -> Widget
pub fn ellipsis(self) -> Widget
Single line, cut with ... when too wide — see Style::ellipsis.
Sourcepub fn clip(self, v: bool) -> Widget
pub fn clip(self, v: bool) -> Widget
Clip children to this widget’s rect — see Style::clip.
Sourcepub fn scroll_y(self, v: f32) -> Widget
pub fn scroll_y(self, v: f32) -> Widget
Vertical scroll offset of the children — see Style::scroll_y.
Sourcepub fn scrollbar(self, v: bool) -> Widget
pub fn scrollbar(self, v: bool) -> Widget
Draw a vertical scrollbar on overflow — see Style::scrollbar.
Sourcepub fn children(self, children: impl IntoIterator<Item = Widget>) -> Widget
pub fn children(self, children: impl IntoIterator<Item = Widget>) -> Widget
Adds every widget in children, in order.
Sourcepub fn find_mut(&mut self, id: &str) -> Option<&mut Widget>
pub fn find_mut(&mut self, id: &str) -> Option<&mut Widget>
The first widget in this subtree (depth-first, self included) whose
Widget::id is id — for changing a built tree before laying it
out (dynamic text, enabled state, …).
Sourcepub fn set_text(&mut self, text: impl Into<String>) -> bool
pub fn set_text(&mut self, text: impl Into<String>) -> bool
Replaces the text of a label or button; false for any other kind.
pub fn padding(self, top: f32, right: f32, bottom: f32, left: f32) -> Widget
pub fn margin(self, top: f32, right: f32, bottom: f32, left: f32) -> Widget
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Widget
impl RefUnwindSafe for Widget
impl Send for Widget
impl Sync for Widget
impl Unpin for Widget
impl UnsafeUnpin for Widget
impl UnwindSafe for Widget
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Returns the layout of the type.
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Returns whether the given value has been niched. Read more
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
Writes data to
out indicating that a T is niched.