ltk

Enum Element

Source
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>

Source

pub fn preferred_size(&self, max_width: f32, canvas: &Canvas) -> (f32, f32)

Source

pub fn draw( &self, canvas: &mut Canvas, rect: Rect, focused: bool, hovered: bool, pressed: bool, cursor_pos: usize, selection_anchor: usize, )

Source

pub fn hit_test(&self, rect: Rect, pos: Point) -> bool

Source

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.

Source

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.

Source

pub fn is_text_input(&self) -> bool

Source

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

pub fn tooltip(&self) -> Option<&str>

Add an arm here to opt a widget kind into the auto-tooltip flow.

Source§

impl<Msg: Clone + 'static> Element<Msg>

Source

pub fn map<U, F>(self, f: F) -> Element<U>
where U: Clone + 'static, F: Fn(Msg) -> U + 'static,

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> From<Button<Msg>> for Element<Msg>

Source§

fn from(b: Button<Msg>) -> Self

Converts to this type from the input type.
Source§

impl<Msg: Clone + 'static> From<Carousel<Msg>> for Element<Msg>

Source§

fn from(c: Carousel<Msg>) -> Self

Converts to this type from the input type.
Source§

impl<Msg: Clone + 'static> From<Checkbox<Msg>> for Element<Msg>

Source§

fn from(c: Checkbox<Msg>) -> Self

Converts to this type from the input type.
Source§

impl<Msg: Clone + 'static> From<ColorPicker<Msg>> for Element<Msg>

Source§

fn from(c: ColorPicker<Msg>) -> Self

Converts to this type from the input type.
Source§

impl<Msg: Clone> From<Column<Msg>> for Element<Msg>

Source§

fn from(c: Column<Msg>) -> Self

Converts to this type from the input type.
Source§

impl<Msg: Clone> From<Container<Msg>> for Element<Msg>

Source§

fn from(c: Container<Msg>) -> Self

Converts to this type from the input type.
Source§

impl<Msg: Clone + 'static> From<DatePicker<Msg>> for Element<Msg>

Source§

fn from(d: DatePicker<Msg>) -> Self

Converts to this type from the input type.
Source§

impl<Msg: Clone + 'static> From<Dialog<Msg>> for Element<Msg>

Source§

fn from(d: Dialog<Msg>) -> Element<Msg>

Converts to this type from the input type.
Source§

impl<Msg: Clone> From<External> for Element<Msg>

Source§

fn from(e: External) -> Self

Converts to this type from the input type.
Source§

impl<Msg: Clone + 'static> From<Flex<Msg>> for Element<Msg>

Source§

fn from(f: Flex<Msg>) -> Self

Converts to this type from the input type.
Source§

impl<Msg: Clone> From<Image> for Element<Msg>

Source§

fn from(i: Image) -> Self

Converts to this type from the input type.
Source§

impl<Msg: Clone + 'static> From<ListItem<Msg>> for Element<Msg>

Source§

fn from(l: ListItem<Msg>) -> Self

Converts to this type from the input type.
Source§

impl<Msg: Clone + 'static> From<Notebook<Msg>> for Element<Msg>

Source§

fn from(n: Notebook<Msg>) -> Self

Converts to this type from the input type.
Source§

impl<Msg: Clone + 'static> From<Pressable<Msg>> for Element<Msg>

Source§

fn from(p: Pressable<Msg>) -> Self

Converts to this type from the input type.
Source§

impl<Msg: Clone> From<ProgressBar> for Element<Msg>

Source§

fn from(p: ProgressBar) -> Self

Converts to this type from the input type.
Source§

impl<Msg: Clone + 'static> From<Radio<Msg>> for Element<Msg>

Source§

fn from(r: Radio<Msg>) -> Self

Converts to this type from the input type.
Source§

impl<Msg: Clone> From<Row<Msg>> for Element<Msg>

Source§

fn from(r: Row<Msg>) -> Self

Converts to this type from the input type.
Source§

impl<Msg: Clone> From<Separator> for Element<Msg>

Source§

fn from(s: Separator) -> Self

Converts to this type from the input type.
Source§

impl<Msg: Clone + 'static> From<Slider<Msg>> for Element<Msg>

Source§

fn from(s: Slider<Msg>) -> Self

Converts to this type from the input type.
Source§

impl<Msg: Clone + 'static> From<Spacer> for Element<Msg>

Source§

fn from(s: Spacer) -> Self

Converts to this type from the input type.
Source§

impl<Msg: Clone> From<Spinner> for Element<Msg>

Source§

fn from(s: Spinner) -> Self

Converts to this type from the input type.
Source§

impl<Msg: Clone> From<Stack<Msg>> for Element<Msg>

Source§

fn from(s: Stack<Msg>) -> Self

Converts to this type from the input type.
Source§

impl<Msg: Clone + 'static> From<TabBar<Msg>> for Element<Msg>

Source§

fn from(t: TabBar<Msg>) -> Self

Converts to this type from the input type.
Source§

impl<Msg: Clone + 'static> From<Text> for Element<Msg>

Source§

fn from(t: Text) -> Self

Converts to this type from the input type.
Source§

impl<Msg: Clone> From<TextEdit<Msg>> for Element<Msg>

Source§

fn from(t: TextEdit<Msg>) -> Self

Converts to this type from the input type.
Source§

impl<Msg: Clone + 'static> From<TimePicker<Msg>> for Element<Msg>

Source§

fn from(t: TimePicker<Msg>) -> Self

Converts to this type from the input type.
Source§

impl<Msg: Clone + 'static> From<Toggle<Msg>> for Element<Msg>

Source§

fn from(t: Toggle<Msg>) -> Self

Converts to this type from the input type.
Source§

impl<Msg: Clone + 'static> From<VSlider<Msg>> for Element<Msg>

Source§

fn from(s: VSlider<Msg>) -> Self

Converts to this type from the input type.
Source§

impl<Msg: Clone + 'static> From<Viewport<Msg>> for Element<Msg>

Source§

fn from(v: Viewport<Msg>) -> Self

Converts to this type from the input type.
Source§

impl<Msg: Clone + 'static> From<WindowButton<Msg>> for Element<Msg>

Source§

fn from(b: WindowButton<Msg>) -> Self

Converts to this type from the input type.
Source§

impl<Msg: Clone + 'static> From<WrapGrid<Msg>> for Element<Msg>

Source§

fn from(g: WrapGrid<Msg>) -> Self

Converts to this type from the input type.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more