pub enum Element<Msg: Clone> {
Show 27 variants
Button(Button<Msg>),
Container(Container<Msg>),
TextEdit(TextEdit<Msg>),
Image(Image),
Column(Column<Msg>),
Row(Row<Msg>),
Stack(Stack<Msg>),
Text(Text),
Spacer(Spacer),
Scroll(Scroll<Msg>),
Viewport(Viewport<Msg>),
WrapGrid(WrapGrid<Msg>),
Slider(Slider<Msg>),
VSlider(VSlider<Msg>),
Toggle(Toggle<Msg>),
Separator(Separator),
ProgressBar(ProgressBar),
Checkbox(Checkbox<Msg>),
Radio(Radio<Msg>),
ListItem(ListItem<Msg>),
WindowButton(WindowButton<Msg>),
Pressable(Pressable<Msg>),
Flex(Flex<Msg>),
AnchoredOverlay(AnchoredOverlay<Msg>),
Spinner(Spinner),
External(External),
Carousel(Carousel<Msg>),
}Variants§
Button(Button<Msg>)
Container(Container<Msg>)
TextEdit(TextEdit<Msg>)
Image(Image)
Column(Column<Msg>)
Row(Row<Msg>)
Stack(Stack<Msg>)
Text(Text)
Spacer(Spacer)
Scroll(Scroll<Msg>)
Viewport(Viewport<Msg>)
WrapGrid(WrapGrid<Msg>)
Slider(Slider<Msg>)
VSlider(VSlider<Msg>)
Toggle(Toggle<Msg>)
Separator(Separator)
ProgressBar(ProgressBar)
Checkbox(Checkbox<Msg>)
Radio(Radio<Msg>)
ListItem(ListItem<Msg>)
WindowButton(WindowButton<Msg>)
Pressable(Pressable<Msg>)
Flex(Flex<Msg>)
AnchoredOverlay(AnchoredOverlay<Msg>)
Spinner(Spinner)
External(External)
Carousel(Carousel<Msg>)
Implementations§
Source§impl<Msg: Clone> Element<Msg>
impl<Msg: Clone> Element<Msg>
pub fn preferred_size(&self, max_width: f32, canvas: &Canvas) -> (f32, f32)
pub fn draw( &self, canvas: &mut Canvas, rect: Rect, focused: bool, hovered: bool, pressed: bool, cursor_pos: usize, selection_anchor: usize, )
pub fn hit_test(&self, rect: Rect, pos: Point) -> bool
Sourcepub fn is_interactive(&self) -> bool
pub fn is_interactive(&self) -> bool
Whether the widget should be included in the per-surface
widget_rects list — i.e. whether pointer / touch hit testing must be
able to land on it. This is the predicate that gates the layout pass’s
push to DrawCtx::widget_rects in the draw pass.
Defaults to Self::is_focusable for every widget that takes keyboard
focus (those are interactive by definition). Widgets that are
click/touch-only without taking keyboard focus — currently
Element::WindowButton — opt in here without opting in to the Tab
cycle.
Sourcepub fn is_focusable(&self) -> bool
pub fn is_focusable(&self) -> bool
Whether the widget participates in the Tab / Shift+Tab focus cycle.
Snapshotted onto super::LaidOutWidget::keyboard_focusable at layout time so
next_focusable_index can iterate without the Element tree.
Hit-testable chrome that should not steal keyboard focus from window
content (e.g. Element::WindowButton) returns false here while
still returning true from Self::is_interactive.
pub fn is_text_input(&self) -> bool
Sourcepub fn cursor_shape(&self) -> CursorShape
pub fn cursor_shape(&self) -> CursorShape
Cursor shape to display while the pointer is over this widget. Per-widget defaults match desktop conventions:
- Text inputs →
Text(I-beam) - Clickables (Button, Pressable, Toggle, Checkbox, Radio,
ListItem, WindowButton) →
Pointer(hand) - Anything else →
Default
Widgets that carry a per-instance override (set via the
.cursor( shape ) builder) return the override; otherwise they
return their type-based default. The runtime snapshots this onto
super::LaidOutWidget::cursor at layout time and dispatches the
shape via wp_cursor_shape_v1 on hover transitions.
Source§impl<Msg: Clone + 'static> Element<Msg>
impl<Msg: Clone + 'static> Element<Msg>
Sourcepub fn map<U, F>(self, f: F) -> Element<U>
pub fn map<U, F>(self, f: F) -> Element<U>
Re-tag every message a sub-view emits.
Walks the tree once and rewrites every per-leaf message store —
Button::on_press, Slider::on_change, the children of
Column/Row/Stack/WrapGrid, and so on — so the returned
Element<U> no longer references Msg. The standard Elm /
iced shape: a sub-view defined as fn view( …) -> Element<SubMsg>
can be embedded inside a parent that produces Element<AppMsg>
by calling .map( AppMsg::Sub ).
Cost: O( leaves ) allocations for the closure-wrapping in the
Arc<dyn Fn(...)> callbacks (text_edit, slider, vslider),
and the closure itself runs an extra indirect call per emitted
message — both per-map-layer. Trees built fresh every frame
(the typical case) absorb this in the same allocator pressure
view() already produces, so the overhead is in the noise.
sub_view().map( AppMsg::Sub )Trait Implementations§
Source§impl<Msg: Clone + 'static> From<ColorPicker<Msg>> for Element<Msg>
impl<Msg: Clone + 'static> From<ColorPicker<Msg>> for Element<Msg>
Source§fn from(c: ColorPicker<Msg>) -> Self
fn from(c: ColorPicker<Msg>) -> Self
Source§impl<Msg: Clone + 'static> From<DatePicker<Msg>> for Element<Msg>
impl<Msg: Clone + 'static> From<DatePicker<Msg>> for Element<Msg>
Source§fn from(d: DatePicker<Msg>) -> Self
fn from(d: DatePicker<Msg>) -> Self
Source§impl<Msg: Clone> From<ProgressBar> for Element<Msg>
impl<Msg: Clone> From<ProgressBar> for Element<Msg>
Source§fn from(p: ProgressBar) -> Self
fn from(p: ProgressBar) -> Self
Source§impl<Msg: Clone + 'static> From<TimePicker<Msg>> for Element<Msg>
impl<Msg: Clone + 'static> From<TimePicker<Msg>> for Element<Msg>
Source§fn from(t: TimePicker<Msg>) -> Self
fn from(t: TimePicker<Msg>) -> Self
Source§impl<Msg: Clone + 'static> From<WindowButton<Msg>> for Element<Msg>
impl<Msg: Clone + 'static> From<WindowButton<Msg>> for Element<Msg>
Source§fn from(b: WindowButton<Msg>) -> Self
fn from(b: WindowButton<Msg>) -> Self
Auto Trait Implementations§
impl<Msg> Freeze for Element<Msg>where
Msg: Freeze,
impl<Msg> !RefUnwindSafe for Element<Msg>
impl<Msg> !Send for Element<Msg>
impl<Msg> !Sync for Element<Msg>
impl<Msg> Unpin for Element<Msg>where
Msg: Unpin,
impl<Msg> !UnwindSafe for Element<Msg>
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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.§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.§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.§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.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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