pub struct Flex { /* private fields */ }
Expand description
A container with either horizontal or vertical layout.
This widget is the foundation of most layouts, and is highly configurable.
Implementations§
source§impl Flex
impl Flex
sourcepub fn row() -> Self
pub fn row() -> Self
Create a new horizontal stack.
The child widgets are laid out horizontally, from left to right.
sourcepub fn column() -> Self
pub fn column() -> Self
Create a new vertical stack.
The child widgets are laid out vertically, from top to bottom.
sourcepub fn cross_axis_alignment(self, alignment: CrossAxisAlignment) -> Self
pub fn cross_axis_alignment(self, alignment: CrossAxisAlignment) -> Self
Builder-style method for specifying the childrens’ CrossAxisAlignment
.
sourcepub fn main_axis_alignment(self, alignment: MainAxisAlignment) -> Self
pub fn main_axis_alignment(self, alignment: MainAxisAlignment) -> Self
Builder-style method for specifying the childrens’ MainAxisAlignment
.
sourcepub fn must_fill_main_axis(self, fill: bool) -> Self
pub fn must_fill_main_axis(self, fill: bool) -> Self
Builder-style method for setting whether the container must expand to fill the available space on its main axis.
sourcepub fn with_child(self, child: impl Widget) -> Self
pub fn with_child(self, child: impl Widget) -> Self
Builder-style variant of add_child
.
Convenient for assembling a group of widgets in a single expression.
sourcepub fn with_child_id(self, child: impl Widget, id: WidgetId) -> Self
pub fn with_child_id(self, child: impl Widget, id: WidgetId) -> Self
Builder-style variant of add_child
, that takes the id that the child will have.
Useful for unit tests.
pub fn with_child_pod(self, widget: WidgetPod<Box<dyn Widget>>) -> Self
sourcepub fn with_flex_child(
self,
child: impl Widget,
params: impl Into<FlexParams>
) -> Self
pub fn with_flex_child( self, child: impl Widget, params: impl Into<FlexParams> ) -> Self
Builder-style method to add a flexible child to the container.
sourcepub fn with_default_spacer(self) -> Self
pub fn with_default_spacer(self) -> Self
Builder-style method to add a spacer widget with a standard size.
The actual value of this spacer depends on whether this container is a row or column, as well as theme settings.
sourcepub fn with_spacer(self, len: f64) -> Self
pub fn with_spacer(self, len: f64) -> Self
Builder-style method for adding a fixed-size spacer to the container.
If you are laying out standard controls in this container, you should
generally prefer to use add_default_spacer
.
sourcepub fn with_flex_spacer(self, flex: f64) -> Self
pub fn with_flex_spacer(self, flex: f64) -> Self
Builder-style method for adding a flex
spacer to the container.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Trait Implementations§
source§impl Widget for Flex
impl Widget for Flex
source§fn on_pointer_event(&mut self, ctx: &mut EventCtx<'_>, event: &PointerEvent)
fn on_pointer_event(&mut self, ctx: &mut EventCtx<'_>, event: &PointerEvent)
fn on_text_event(&mut self, ctx: &mut EventCtx<'_>, event: &TextEvent)
source§fn on_access_event(&mut self, ctx: &mut EventCtx<'_>, event: &AccessEvent)
fn on_access_event(&mut self, ctx: &mut EventCtx<'_>, event: &AccessEvent)
fn on_status_change( &mut self, _ctx: &mut LifeCycleCtx<'_>, _event: &StatusChange )
source§fn lifecycle(&mut self, ctx: &mut LifeCycleCtx<'_>, event: &LifeCycle)
fn lifecycle(&mut self, ctx: &mut LifeCycleCtx<'_>, event: &LifeCycle)
source§fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
source§fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut Scene)
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut Scene)
fn accessibility_role(&self) -> Role
fn accessibility(&mut self, ctx: &mut AccessCtx<'_>)
source§fn children(&self) -> SmallVec<[WidgetRef<'_, dyn Widget>; 16]>
fn children(&self) -> SmallVec<[WidgetRef<'_, dyn Widget>; 16]>
source§fn make_trace_span(&self) -> Span
fn make_trace_span(&self) -> Span
Auto Trait Implementations§
impl Freeze for Flex
impl !RefUnwindSafe for Flex
impl !Send for Flex
impl !Sync for Flex
impl Unpin for Flex
impl !UnwindSafe for Flex
Blanket Implementations§
source§impl<T> AsAny for Twhere
T: Any,
impl<T> AsAny for Twhere
T: Any,
source§fn as_dyn_any(&self) -> &(dyn Any + 'static)
fn as_dyn_any(&self) -> &(dyn Any + 'static)
source§fn as_mut_dyn_any(&mut self) -> &mut (dyn Any + 'static)
fn as_mut_dyn_any(&mut self) -> &mut (dyn Any + 'static)
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
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.