AdaptWidget

Trait AdaptWidget 

Source
pub trait AdaptWidget: Widget + Sized {
Show 14 methods // Provided methods fn align(self, hints: AlignHints) -> Align<Self> { ... } fn pack(self, hints: AlignHints) -> Pack<Self> { ... } fn margins(self, dirs: Directions, style: MarginStyle) -> Margins<Self> { ... } fn map<A, F>(self, f: F) -> Map<A, Self, F> where F: for<'a> Fn(&'a A) -> &'a Self::Data { ... } fn on_configure<F>(self, f: F) -> AdaptEvents<Self> where F: Fn(&mut AdaptConfigCx<'_, '_>, &mut Self) + 'static { ... } fn on_update<F>(self, f: F) -> AdaptEvents<Self> where F: Fn(&mut AdaptConfigCx<'_, '_>, &mut Self, &Self::Data) + 'static { ... } fn on_message<M, H>(self, handler: H) -> AdaptEvents<Self> where M: Debug + 'static, H: Fn(&mut AdaptEventCx<'_, '_>, &mut Self, M) + 'static { ... } fn map_message<M, N, H>(self, handler: H) -> AdaptEvents<Self> where M: Debug + 'static, N: Debug + 'static, H: Fn(usize, M) -> N + 'static { ... } fn on_messages<H>(self, handler: H) -> AdaptEvents<Self> where H: Fn(&mut AdaptEventCx<'_, '_>, &mut Self, &Self::Data) + 'static { ... } fn with_min_size_px(self, w: i32, h: i32) -> Reserve<Self> { ... } fn with_min_size_em(self, w: f32, h: f32) -> Reserve<Self> { ... } fn with_label<D, T>(self, direction: D, label: T) -> WithLabel<Self, D> where D: Directional, T: Into<AccessString> { ... } fn with_hidden_label<T: ToString>(self, label: T) -> WithHiddenLabel<Self> { ... } fn with_state<A>(self, state: Self::Data) -> Adapt<A, Self> { ... }
}
Expand description

Provides some convenience methods on widgets

Provided Methods§

Source

fn align(self, hints: AlignHints) -> Align<Self>

Apply an alignment hint

The inner widget chooses how to apply (or ignore) this hint.

Returns a wrapper around the input widget.

Source

fn pack(self, hints: AlignHints) -> Pack<Self>

Apply an alignment hint, squash and align the result

The inner widget chooses how to apply (or ignore) this hint. The widget is then prevented from stretching beyond its ideal size, aligning within the available rect.

Returns a wrapper around the input widget.

Source

fn margins(self, dirs: Directions, style: MarginStyle) -> Margins<Self>

Specify margins

This replaces a widget’s margins.

Returns a wrapper around the input widget.

Source

fn map<A, F>(self, f: F) -> Map<A, Self, F>
where F: for<'a> Fn(&'a A) -> &'a Self::Data,

Map data type via a function

Returns a wrapper around the input widget.

Source

fn on_configure<F>(self, f: F) -> AdaptEvents<Self>
where F: Fn(&mut AdaptConfigCx<'_, '_>, &mut Self) + 'static,

Call the given closure on Events::configure

Returns a wrapper around the input widget.

Source

fn on_update<F>(self, f: F) -> AdaptEvents<Self>
where F: Fn(&mut AdaptConfigCx<'_, '_>, &mut Self, &Self::Data) + 'static,

Call the given closure on Events::update

Returns a wrapper around the input widget.

Source

fn on_message<M, H>(self, handler: H) -> AdaptEvents<Self>
where M: Debug + 'static, H: Fn(&mut AdaptEventCx<'_, '_>, &mut Self, M) + 'static,

Add a handler on message of type M

Where access to input data is required, use Self::on_messages instead.

Returns a wrapper around the input widget.

Source

fn map_message<M, N, H>(self, handler: H) -> AdaptEvents<Self>
where M: Debug + 'static, N: Debug + 'static, H: Fn(usize, M) -> N + 'static,

Add a child handler to map messages of type M to N

§Example
use kas::messages::Select;
use kas_widgets::{AdaptWidget, Row, Tab};

#[derive(Clone, Debug)]
struct MsgSelectIndex(usize);

let tabs = Row::new([Tab::new("A")])
    .map_message(|index, Select| MsgSelectIndex(index));
Source

fn on_messages<H>(self, handler: H) -> AdaptEvents<Self>
where H: Fn(&mut AdaptEventCx<'_, '_>, &mut Self, &Self::Data) + 'static,

Add a generic message handler

Returns a wrapper around the input widget.

Source

fn with_min_size_px(self, w: i32, h: i32) -> Reserve<Self>

Construct a wrapper, setting minimum size in pixels

The input size is scaled by the scale factor.

Returns a wrapper around the input widget.

Source

fn with_min_size_em(self, w: f32, h: f32) -> Reserve<Self>

Construct a wrapper, setting minimum size in Em

This depends on the font size, though not the exact font in use.

Returns a wrapper around the input widget.

Source

fn with_label<D, T>(self, direction: D, label: T) -> WithLabel<Self, D>

Construct a wrapper widget adding a label

Returns a wrapper around the input widget.

Source

fn with_hidden_label<T: ToString>(self, label: T) -> WithHiddenLabel<Self>

Construct a wrapper widget adding a hidden label

This label is not normally visible but may be read by accessibility tools and tooltips.

Returns a wrapper around the input widget.

Source

fn with_state<A>(self, state: Self::Data) -> Adapt<A, Self>

Construct an Adapt widget over input

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§