Struct SizedBox

Source
pub struct SizedBox<T> { /* private fields */ }
Expand description

A widget with predefined size.

If given a child, this widget forces its child to have a specific width and/or height (assuming values are permitted by this widget’s parent). If either the width or height is not set, this widget will size itself to match the child’s size in that dimension.

If not given a child, SizedBox will try to size itself as close to the specified height and width as possible given the parent’s constraints. If height or width is not set, it will be treated as zero.

Implementations§

Source§

impl<T> SizedBox<T>

Source

pub fn new(child: impl Widget<T> + 'static) -> Self

Construct container with child, and both width and height not set.

Examples found in repository?
examples/flex.rs (line 287)
241fn build_widget(state: &Params) -> Box<dyn Widget<AppState>> {
242    let mut flex = match state.axis {
243        FlexType::Column => Flex::column(),
244        FlexType::Row => Flex::row(),
245    }
246    .cross_axis_alignment(state.cross_alignment)
247    .main_axis_alignment(state.main_alignment)
248    .must_fill_main_axis(state.fill_major_axis);
249
250    flex.add_child(
251        TextBox::new()
252            .with_placeholder("Sample text")
253            .lens(DemoState::input_text),
254    );
255    space_if_needed(&mut flex, state);
256
257    flex.add_child(
258        Button::new("Clear").on_click(|_ctx, data: &mut DemoState, _env| {
259            data.input_text.clear();
260            data.enabled = false;
261            data.volume = 0.0;
262        }),
263    );
264
265    space_if_needed(&mut flex, state);
266
267    flex.add_child(
268        Label::new(|data: &DemoState, _: &Env| data.input_text.clone()).with_text_size(32.0),
269    );
270    space_if_needed(&mut flex, state);
271    flex.add_child(Checkbox::new("Demo").lens(DemoState::enabled));
272    space_if_needed(&mut flex, state);
273    flex.add_child(Switch::new().lens(DemoState::enabled));
274    space_if_needed(&mut flex, state);
275    flex.add_child(Slider::new().lens(DemoState::volume));
276    space_if_needed(&mut flex, state);
277    flex.add_child(ProgressBar::new().lens(DemoState::volume));
278    space_if_needed(&mut flex, state);
279    flex.add_child(
280        Stepper::new()
281            .with_range(0.0, 1.0)
282            .with_step(0.1)
283            .with_wraparound(true)
284            .lens(DemoState::volume),
285    );
286
287    let mut flex = SizedBox::new(flex);
288    if state.fix_minor_axis {
289        match state.axis {
290            FlexType::Row => flex = flex.height(200.),
291            FlexType::Column => flex = flex.width(200.),
292        }
293    }
294    if state.fix_major_axis {
295        match state.axis {
296            FlexType::Row => flex = flex.width(600.),
297            FlexType::Column => flex = flex.height(300.),
298        }
299    }
300
301    let flex = flex
302        .padding(8.0)
303        .border(Color::grey(0.6), 2.0)
304        .rounded(5.0)
305        .lens(AppState::demo_state);
306
307    if state.debug_layout {
308        flex.debug_paint_layout().boxed()
309    } else {
310        flex.boxed()
311    }
312}
Source

pub fn empty() -> Self

Construct container without child, and both width and height not set.

If the widget is unchanged, it will do nothing, which can be useful if you want to draw a widget some of the time (for example, it is used to implement Maybe).

Examples found in repository?
examples/flex.rs (line 104)
102    fn new() -> Rebuilder {
103        Rebuilder {
104            inner: SizedBox::empty().boxed(),
105        }
106    }
More examples
Hide additional examples
examples/scroll_colors.rs (line 36)
23fn build_app() -> impl Widget<u32> {
24    let mut col = Flex::column();
25    let rows = 30;
26    let cols = 30;
27
28    for i in 0..cols {
29        let mut row = Flex::row();
30        let col_progress = i as f64 / cols as f64;
31
32        for j in 0..rows {
33            let row_progress = j as f64 / rows as f64;
34
35            row.add_child(
36                Container::new(SizedBox::empty().width(200.0).height(200.0))
37                    .background(Color::rgb(1.0 * col_progress, 1.0 * row_progress, 1.0)),
38            );
39        }
40
41        col.add_child(row);
42    }
43
44    Scroll::new(col)
45}
examples/event_viewer.rs (line 240)
231fn interactive_area() -> impl Widget<AppState> {
232    let text_box = TextBox::multiline()
233        .with_text_color(Color::rgb8(0xf0, 0xf0, 0xea))
234        .fix_size(INTERACTIVE_AREA_DIM, INTERACTIVE_AREA_DIM)
235        .lens(AppState::text_input)
236        .controller(EventLogger {
237            filter: |event| matches!(event, Event::KeyDown(_) | Event::KeyUp(_)),
238        });
239
240    let mouse_box = SizedBox::empty()
241        .fix_size(INTERACTIVE_AREA_DIM, INTERACTIVE_AREA_DIM)
242        .background(CURSOR_BACKGROUND_COLOR)
243        .rounded(5.0)
244        .border(INTERACTIVE_AREA_BORDER, 1.0)
245        .controller(EventLogger {
246            filter: |event| {
247                matches!(
248                    event,
249                    Event::MouseDown(_) | Event::MouseUp(_) | Event::Wheel(_)
250                )
251            },
252        });
253
254    Flex::row()
255        .with_flex_spacer(1.0)
256        .with_child(text_box)
257        .with_flex_spacer(1.0)
258        .with_child(mouse_box)
259        .with_flex_spacer(1.0)
260        .padding(10.0)
261}
Source

pub fn width(self, width: impl Into<KeyOrValue<f64>>) -> Self

Set container’s width.

Examples found in repository?
examples/scroll_colors.rs (line 36)
23fn build_app() -> impl Widget<u32> {
24    let mut col = Flex::column();
25    let rows = 30;
26    let cols = 30;
27
28    for i in 0..cols {
29        let mut row = Flex::row();
30        let col_progress = i as f64 / cols as f64;
31
32        for j in 0..rows {
33            let row_progress = j as f64 / rows as f64;
34
35            row.add_child(
36                Container::new(SizedBox::empty().width(200.0).height(200.0))
37                    .background(Color::rgb(1.0 * col_progress, 1.0 * row_progress, 1.0)),
38            );
39        }
40
41        col.add_child(row);
42    }
43
44    Scroll::new(col)
45}
More examples
Hide additional examples
examples/flex.rs (line 291)
241fn build_widget(state: &Params) -> Box<dyn Widget<AppState>> {
242    let mut flex = match state.axis {
243        FlexType::Column => Flex::column(),
244        FlexType::Row => Flex::row(),
245    }
246    .cross_axis_alignment(state.cross_alignment)
247    .main_axis_alignment(state.main_alignment)
248    .must_fill_main_axis(state.fill_major_axis);
249
250    flex.add_child(
251        TextBox::new()
252            .with_placeholder("Sample text")
253            .lens(DemoState::input_text),
254    );
255    space_if_needed(&mut flex, state);
256
257    flex.add_child(
258        Button::new("Clear").on_click(|_ctx, data: &mut DemoState, _env| {
259            data.input_text.clear();
260            data.enabled = false;
261            data.volume = 0.0;
262        }),
263    );
264
265    space_if_needed(&mut flex, state);
266
267    flex.add_child(
268        Label::new(|data: &DemoState, _: &Env| data.input_text.clone()).with_text_size(32.0),
269    );
270    space_if_needed(&mut flex, state);
271    flex.add_child(Checkbox::new("Demo").lens(DemoState::enabled));
272    space_if_needed(&mut flex, state);
273    flex.add_child(Switch::new().lens(DemoState::enabled));
274    space_if_needed(&mut flex, state);
275    flex.add_child(Slider::new().lens(DemoState::volume));
276    space_if_needed(&mut flex, state);
277    flex.add_child(ProgressBar::new().lens(DemoState::volume));
278    space_if_needed(&mut flex, state);
279    flex.add_child(
280        Stepper::new()
281            .with_range(0.0, 1.0)
282            .with_step(0.1)
283            .with_wraparound(true)
284            .lens(DemoState::volume),
285    );
286
287    let mut flex = SizedBox::new(flex);
288    if state.fix_minor_axis {
289        match state.axis {
290            FlexType::Row => flex = flex.height(200.),
291            FlexType::Column => flex = flex.width(200.),
292        }
293    }
294    if state.fix_major_axis {
295        match state.axis {
296            FlexType::Row => flex = flex.width(600.),
297            FlexType::Column => flex = flex.height(300.),
298        }
299    }
300
301    let flex = flex
302        .padding(8.0)
303        .border(Color::grey(0.6), 2.0)
304        .rounded(5.0)
305        .lens(AppState::demo_state);
306
307    if state.debug_layout {
308        flex.debug_paint_layout().boxed()
309    } else {
310        flex.boxed()
311    }
312}
Source

pub fn height(self, height: impl Into<KeyOrValue<f64>>) -> Self

Set container’s height.

Examples found in repository?
examples/scroll_colors.rs (line 36)
23fn build_app() -> impl Widget<u32> {
24    let mut col = Flex::column();
25    let rows = 30;
26    let cols = 30;
27
28    for i in 0..cols {
29        let mut row = Flex::row();
30        let col_progress = i as f64 / cols as f64;
31
32        for j in 0..rows {
33            let row_progress = j as f64 / rows as f64;
34
35            row.add_child(
36                Container::new(SizedBox::empty().width(200.0).height(200.0))
37                    .background(Color::rgb(1.0 * col_progress, 1.0 * row_progress, 1.0)),
38            );
39        }
40
41        col.add_child(row);
42    }
43
44    Scroll::new(col)
45}
More examples
Hide additional examples
examples/flex.rs (line 290)
241fn build_widget(state: &Params) -> Box<dyn Widget<AppState>> {
242    let mut flex = match state.axis {
243        FlexType::Column => Flex::column(),
244        FlexType::Row => Flex::row(),
245    }
246    .cross_axis_alignment(state.cross_alignment)
247    .main_axis_alignment(state.main_alignment)
248    .must_fill_main_axis(state.fill_major_axis);
249
250    flex.add_child(
251        TextBox::new()
252            .with_placeholder("Sample text")
253            .lens(DemoState::input_text),
254    );
255    space_if_needed(&mut flex, state);
256
257    flex.add_child(
258        Button::new("Clear").on_click(|_ctx, data: &mut DemoState, _env| {
259            data.input_text.clear();
260            data.enabled = false;
261            data.volume = 0.0;
262        }),
263    );
264
265    space_if_needed(&mut flex, state);
266
267    flex.add_child(
268        Label::new(|data: &DemoState, _: &Env| data.input_text.clone()).with_text_size(32.0),
269    );
270    space_if_needed(&mut flex, state);
271    flex.add_child(Checkbox::new("Demo").lens(DemoState::enabled));
272    space_if_needed(&mut flex, state);
273    flex.add_child(Switch::new().lens(DemoState::enabled));
274    space_if_needed(&mut flex, state);
275    flex.add_child(Slider::new().lens(DemoState::volume));
276    space_if_needed(&mut flex, state);
277    flex.add_child(ProgressBar::new().lens(DemoState::volume));
278    space_if_needed(&mut flex, state);
279    flex.add_child(
280        Stepper::new()
281            .with_range(0.0, 1.0)
282            .with_step(0.1)
283            .with_wraparound(true)
284            .lens(DemoState::volume),
285    );
286
287    let mut flex = SizedBox::new(flex);
288    if state.fix_minor_axis {
289        match state.axis {
290            FlexType::Row => flex = flex.height(200.),
291            FlexType::Column => flex = flex.width(200.),
292        }
293    }
294    if state.fix_major_axis {
295        match state.axis {
296            FlexType::Row => flex = flex.width(600.),
297            FlexType::Column => flex = flex.height(300.),
298        }
299    }
300
301    let flex = flex
302        .padding(8.0)
303        .border(Color::grey(0.6), 2.0)
304        .rounded(5.0)
305        .lens(AppState::demo_state);
306
307    if state.debug_layout {
308        flex.debug_paint_layout().boxed()
309    } else {
310        flex.boxed()
311    }
312}
examples/list.rs (line 81)
53fn ui_builder() -> impl Widget<AppData> {
54    let mut root = Flex::column();
55
56    // Build a button to add children to both lists
57    root.add_child(
58        Button::new("Add")
59            .on_click(|_, data: &mut AppData, _| {
60                // Add child to left list
61                data.l_index += 1;
62                data.left.push_back(data.l_index as u32);
63
64                // Add child to right list
65                data.r_index += 1;
66                data.right.push_back(data.r_index as u32);
67            })
68            .fix_height(30.0)
69            .expand_width(),
70    );
71
72    let mut lists = Flex::row().cross_axis_alignment(CrossAxisAlignment::Start);
73
74    // Build a simple list
75    lists.add_flex_child(
76        Scroll::new(List::new(|| {
77            Label::new(|item: &u32, _env: &_| format!("List item #{item}"))
78                .align_vertical(UnitPoint::LEFT)
79                .padding(10.0)
80                .expand()
81                .height(50.0)
82                .background(Color::rgb(0.5, 0.5, 0.5))
83        }))
84        .vertical()
85        .lens(AppData::left),
86        1.0,
87    );
88
89    // Build a list with shared data
90    lists.add_flex_child(
91        Scroll::new(
92            List::new(|| {
93                Flex::row()
94                    .with_child(
95                        Label::new(|(_, item): &(Vector<u32>, u32), _env: &_| {
96                            format!("List item #{item}")
97                        })
98                        .align_vertical(UnitPoint::LEFT),
99                    )
100                    .with_flex_spacer(1.0)
101                    .with_child(
102                        Button::new("Delete")
103                            .on_click(|_ctx, (shared, item): &mut (Vector<u32>, u32), _env| {
104                                // We have access to both child's data and shared data.
105                                // Remove element from right list.
106                                shared.retain(|v| v != item);
107                            })
108                            .fix_size(80.0, 20.0)
109                            .align_vertical(UnitPoint::CENTER),
110                    )
111                    .padding(10.0)
112                    .background(Color::rgb(0.5, 0.0, 0.5))
113                    .fix_height(50.0)
114            })
115            .with_spacing(10.),
116        )
117        .vertical()
118        .lens(lens::Identity.map(
119            // Expose shared data with children data
120            |d: &AppData| (d.right.clone(), d.right.clone()),
121            |d: &mut AppData, x: (Vector<u32>, Vector<u32>)| {
122                // If shared data was changed reflect the changes in our AppData
123                d.right = x.0
124            },
125        )),
126        1.0,
127    );
128
129    root.add_flex_child(lists, 1.0);
130
131    root.with_child(Label::new("horizontal list"))
132        .with_child(
133            Scroll::new(
134                List::new(|| {
135                    Label::new(|item: &u32, _env: &_| format!("List item #{item}"))
136                        .padding(10.0)
137                        .background(Color::rgb(0.5, 0.5, 0.0))
138                        .fix_height(50.0)
139                })
140                .horizontal()
141                .with_spacing(10.)
142                .lens(AppData::left),
143            )
144            .horizontal(),
145        )
146        .debug_paint_layout()
147}
Source

pub fn expand(self) -> Self

Expand container to fit the parent.

Only call this method if you want your widget to occupy all available space. If you only care about expanding in one of width or height, use expand_width or expand_height instead.

Source

pub fn expand_width(self) -> Self

Expand the container on the x-axis.

This will force the child to have maximum width.

Examples found in repository?
examples/list.rs (line 69)
53fn ui_builder() -> impl Widget<AppData> {
54    let mut root = Flex::column();
55
56    // Build a button to add children to both lists
57    root.add_child(
58        Button::new("Add")
59            .on_click(|_, data: &mut AppData, _| {
60                // Add child to left list
61                data.l_index += 1;
62                data.left.push_back(data.l_index as u32);
63
64                // Add child to right list
65                data.r_index += 1;
66                data.right.push_back(data.r_index as u32);
67            })
68            .fix_height(30.0)
69            .expand_width(),
70    );
71
72    let mut lists = Flex::row().cross_axis_alignment(CrossAxisAlignment::Start);
73
74    // Build a simple list
75    lists.add_flex_child(
76        Scroll::new(List::new(|| {
77            Label::new(|item: &u32, _env: &_| format!("List item #{item}"))
78                .align_vertical(UnitPoint::LEFT)
79                .padding(10.0)
80                .expand()
81                .height(50.0)
82                .background(Color::rgb(0.5, 0.5, 0.5))
83        }))
84        .vertical()
85        .lens(AppData::left),
86        1.0,
87    );
88
89    // Build a list with shared data
90    lists.add_flex_child(
91        Scroll::new(
92            List::new(|| {
93                Flex::row()
94                    .with_child(
95                        Label::new(|(_, item): &(Vector<u32>, u32), _env: &_| {
96                            format!("List item #{item}")
97                        })
98                        .align_vertical(UnitPoint::LEFT),
99                    )
100                    .with_flex_spacer(1.0)
101                    .with_child(
102                        Button::new("Delete")
103                            .on_click(|_ctx, (shared, item): &mut (Vector<u32>, u32), _env| {
104                                // We have access to both child's data and shared data.
105                                // Remove element from right list.
106                                shared.retain(|v| v != item);
107                            })
108                            .fix_size(80.0, 20.0)
109                            .align_vertical(UnitPoint::CENTER),
110                    )
111                    .padding(10.0)
112                    .background(Color::rgb(0.5, 0.0, 0.5))
113                    .fix_height(50.0)
114            })
115            .with_spacing(10.),
116        )
117        .vertical()
118        .lens(lens::Identity.map(
119            // Expose shared data with children data
120            |d: &AppData| (d.right.clone(), d.right.clone()),
121            |d: &mut AppData, x: (Vector<u32>, Vector<u32>)| {
122                // If shared data was changed reflect the changes in our AppData
123                d.right = x.0
124            },
125        )),
126        1.0,
127    );
128
129    root.add_flex_child(lists, 1.0);
130
131    root.with_child(Label::new("horizontal list"))
132        .with_child(
133            Scroll::new(
134                List::new(|| {
135                    Label::new(|item: &u32, _env: &_| format!("List item #{item}"))
136                        .padding(10.0)
137                        .background(Color::rgb(0.5, 0.5, 0.0))
138                        .fix_height(50.0)
139                })
140                .horizontal()
141                .with_spacing(10.)
142                .lens(AppData::left),
143            )
144            .horizontal(),
145        )
146        .debug_paint_layout()
147}
Source

pub fn expand_height(self) -> Self

Expand the container on the y-axis.

This will force the child to have maximum height.

Trait Implementations§

Source§

impl<T: Data> Widget<T> for SizedBox<T>

Source§

fn event( &mut self, ctx: &mut EventCtx<'_, '_>, event: &Event, data: &mut T, env: &Env, )

Handle an event. Read more
Source§

fn lifecycle( &mut self, ctx: &mut LifeCycleCtx<'_, '_>, event: &LifeCycle, data: &T, env: &Env, )

Handle a life cycle notification. Read more
Source§

fn update( &mut self, ctx: &mut UpdateCtx<'_, '_>, old_data: &T, data: &T, env: &Env, )

Update the widget’s appearance in response to a change in the app’s Data or Env. Read more
Source§

fn layout( &mut self, ctx: &mut LayoutCtx<'_, '_>, bc: &BoxConstraints, data: &T, env: &Env, ) -> Size

Compute layout. Read more
Source§

fn paint(&mut self, ctx: &mut PaintCtx<'_, '_, '_>, data: &T, env: &Env)

Paint the widget appearance. Read more
Source§

fn compute_max_intrinsic( &mut self, axis: Axis, ctx: &mut LayoutCtx<'_, '_>, bc: &BoxConstraints, data: &T, env: &Env, ) -> f64

Computes max intrinsic/preferred dimension of a widget on the provided axis. Read more

Auto Trait Implementations§

§

impl<T> Freeze for SizedBox<T>

§

impl<T> !RefUnwindSafe for SizedBox<T>

§

impl<T> !Send for SizedBox<T>

§

impl<T> !Sync for SizedBox<T>

§

impl<T> Unpin for SizedBox<T>

§

impl<T> !UnwindSafe for SizedBox<T>

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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> RoundFrom<T> for T

Source§

fn round_from(x: T) -> T

Performs the conversion.
Source§

impl<T, U> RoundInto<U> for T
where U: RoundFrom<T>,

Source§

fn round_into(self) -> U

Performs the conversion.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, W> TestWidgetExt<T> for W
where T: Data, W: Widget<T> + 'static,

Source§

fn record(self, recording: &Recording) -> Recorder<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.
Source§

impl<T, W> WidgetExt<T> for W
where T: Data, W: Widget<T> + 'static,

Source§

fn padding(self, insets: impl Into<KeyOrValue<Insets>>) -> Padding<T, Self>

Wrap this widget in a Padding widget with the given Insets. Read more
Source§

fn center(self) -> Align<T>

Wrap this widget in an Align widget, configured to center it.
Source§

fn align_left(self) -> Align<T>

Wrap this widget in an Align widget, configured to align left.
Source§

fn align_right(self) -> Align<T>

Wrap this widget in an Align widget, configured to align right.
Source§

fn align_vertical(self, align: UnitPoint) -> Align<T>

Wrap this widget in an Align widget, configured to align vertically.
Source§

fn align_horizontal(self, align: UnitPoint) -> Align<T>

Wrap this widget in an Align widget, configured to align horizontally.
Source§

fn fix_width(self, width: impl Into<KeyOrValue<f64>>) -> SizedBox<T>

Wrap this widget in a SizedBox with an explicit width.
Source§

fn fix_height(self, height: impl Into<KeyOrValue<f64>>) -> SizedBox<T>

Wrap this widget in a SizedBox with an explicit height.
Source§

fn fix_size( self, width: impl Into<KeyOrValue<f64>>, height: impl Into<KeyOrValue<f64>>, ) -> SizedBox<T>

Wrap this widget in an SizedBox with an explicit width and height
Source§

fn expand(self) -> SizedBox<T>

Wrap this widget in a SizedBox with an infinite width and height. Read more
Source§

fn expand_width(self) -> SizedBox<T>

Wrap this widget in a SizedBox with an infinite width. Read more
Source§

fn expand_height(self) -> SizedBox<T>

Wrap this widget in a SizedBox with an infinite width. Read more
Source§

fn background(self, brush: impl Into<BackgroundBrush<T>>) -> Container<T>

Wrap this widget in a Container with the provided background brush. Read more
Source§

fn foreground(self, brush: impl Into<BackgroundBrush<T>>) -> Container<T>

Wrap this widget in a Container with the provided foreground brush. Read more
Source§

fn border( self, color: impl Into<KeyOrValue<Color>>, width: impl Into<KeyOrValue<f64>>, ) -> Container<T>

Wrap this widget in a Container with the given border. Read more
Source§

fn env_scope(self, f: impl Fn(&mut Env, &T) + 'static) -> EnvScope<T, Self>

Wrap this widget in a EnvScope widget, modifying the parent Env with the provided closure.
Source§

fn controller<C: Controller<T, Self>>( self, controller: C, ) -> ControllerHost<Self, C>

Wrap this widget with the provided Controller.
Source§

fn on_added( self, f: impl Fn(&mut Self, &mut LifeCycleCtx<'_, '_>, &T, &Env) + 'static, ) -> ControllerHost<Self, Added<T, Self>>

Provide a closure that will be called when this widget is added to the widget tree. Read more
Source§

fn on_click( self, f: impl Fn(&mut EventCtx<'_, '_>, &mut T, &Env) + 'static, ) -> ControllerHost<Self, Click<T>>

Control the events of this widget with a Click widget. The closure provided will be called when the widget is clicked with the left mouse button. Read more
Source§

fn debug_paint_layout(self) -> EnvScope<T, Self>

Draw the layout Rects of this widget and its children.
Source§

fn debug_widget_id(self) -> EnvScope<T, Self>

Display the WidgetIds for this widget and its children, when hot. Read more
Source§

fn debug_invalidation(self) -> DebugInvalidation<T, Self>

Draw a color-changing rectangle over this widget, allowing you to see the invalidation regions.
Source§

fn debug_widget(self) -> EnvScope<T, Self>

Set the DEBUG_WIDGET env variable for this widget (and its descendants). Read more
Source§

fn lens<S: Data, L: Lens<S, T>>(self, lens: L) -> LensWrap<S, T, L, Self>

Wrap this widget in a LensWrap widget for the provided Lens.
Source§

fn with_id(self, id: WidgetId) -> IdentityWrapper<Self>

Assign the widget a specific WidgetId. Read more
Source§

fn boxed(self) -> Box<dyn Widget<T>>

Wrap this widget in a Box.
Source§

fn scroll(self) -> Scroll<T, Self>

Wrap this widget in a Scroll widget.
Source§

fn disabled_if( self, disabled_if: impl Fn(&T, &Env) -> bool + 'static, ) -> DisabledIf<T, Self>

Wrap this widget in a DisabledIf widget. Read more
Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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