Struct ModalHost

Source
pub struct ModalHost<T, W> { /* private fields */ }

Implementations§

Source§

impl ModalHost<(), ()>

Source§

impl<T> ModalHost<T, ()>

Source§

impl<T, W: Widget<T>> ModalHost<T, W>

Source

pub fn new(inner: W) -> ModalHost<T, W>

Examples found in repository?
examples/gallery.rs (lines 86-93)
35fn build_root() -> impl Widget<State> {
36    let button = ToggleButton::<State>::from_icon(
37        &TURTLE,
38        4.0,
39        "Turtle",
40        |x| x.chosen == Animal::Turtle,
41        |_, state, _| {
42            state.chosen = Animal::Turtle;
43            println!("toggle");
44        },
45        |_, state, _| {
46            state.chosen = Animal::Snail;
47            println!("untoggle");
48        },
49    )
50    .tooltip("Turtle")
51    .fix_width(32.0)
52    .padding(10.0)
53    .background(Color::WHITE)
54    .border(Color::BLACK, 3.0);
55
56    let group = RadioGroup::icon_row(
57        vec![
58            (&SNAIL, Animal::Snail, "Snail".into()),
59            (&TURTLE, Animal::Turtle, "Turtle".into()),
60            (&RABBIT, Animal::Rabbit, "Rabbit".into()),
61        ],
62        4.0,
63    )
64    .fix_height(32.0)
65    .lens(State::chosen)
66    .padding(10.0)
67    .background(Color::WHITE)
68    .border(Color::BLACK, 3.0);
69
70    let sep = Separator::new().height(50.0).color(Color::rgb8(80, 70, 60));
71
72    let vgroup = RadioGroup::icon_column(
73        vec![
74            (&SNAIL, Animal::Snail, "Snail".into()),
75            (&TURTLE, Animal::Turtle, "Turtle".into()),
76            (&RABBIT, Animal::Rabbit, "Rabbit".into()),
77        ],
78        4.0,
79    )
80    .fix_width(32.0)
81    .lens(State::chosen)
82    .padding(10.0)
83    .background(Color::WHITE)
84    .border(Color::BLACK, 3.0);
85
86    ModalHost::new(
87        Flex::column()
88            .with_child(button)
89            .with_child(group)
90            .with_child(sep)
91            .with_child(vgroup)
92            .with_flex_spacer(1.0),
93    )
94}

Trait Implementations§

Source§

impl<T: Data, W: Widget<T>> Widget<T> for ModalHost<T, W>

Source§

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

Handle an event. Read more
Source§

fn lifecycle( &mut self, ctx: &mut LifeCycleCtx<'_, '_>, ev: &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

Auto Trait Implementations§

§

impl<T, W> Freeze for ModalHost<T, W>
where W: Freeze, T: Freeze,

§

impl<T, W> !RefUnwindSafe for ModalHost<T, W>

§

impl<T, W> !Send for ModalHost<T, W>

§

impl<T, W> !Sync for ModalHost<T, W>

§

impl<T, W> Unpin for ModalHost<T, W>
where W: Unpin, T: Unpin,

§

impl<T, W> !UnwindSafe for ModalHost<T, W>

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

Source§

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

Source§

fn round_into(self) -> U

Source§

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

Source§

fn tooltip<LT>(self, text: LT) -> TooltipHost<T, W>
where LT: Into<LabelText<T>>,

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<Insets>) -> Padding<T>

Wrap this widget in a Padding widget with the given Insets.
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: f64) -> SizedBox<T>

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

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

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

fn fix_size(self, width: f64, height: 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. 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>(self, controller: C) -> ControllerHost<Self, C>
where C: Controller<T, Self>,

Wrap this widget with the provided Controller.
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, L>(self, lens: L) -> LensWrap<S, T, L, Self>
where S: Data, L: Lens<S, T>,

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

fn parse(self) -> Parse<Self>
where Self: Widget<String>,

👎Deprecated since 0.7.0: Use TextBox::with_formatter instead
Parse a Widget<String>’s contents
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.