pub trait MakeWidget: Sized {
Show 68 methods
// Required method
fn make_widget(self) -> WidgetInstance;
// Provided methods
fn into_window(self) -> Window { ... }
fn build_standalone_window(self) -> StandaloneWindowBuilder { ... }
fn build_recorder(self) -> VirtualRecorderBuilder<Rgb8> { ... }
fn with_styles(self, styles: impl IntoValue<Styles>) -> Style
where Self: Sized { ... }
fn with<C: ComponentDefinition>(
self,
name: &C,
component: impl IntoValue<C::ComponentType>,
) -> Style
where Value<C::ComponentType>: IntoComponentValue { ... }
fn with_local<C: ComponentDefinition>(
self,
name: &C,
component: impl IntoValue<C::ComponentType>,
) -> Style
where Value<C::ComponentType>: IntoComponentValue { ... }
fn with_dynamic<C: ComponentDefinition>(
self,
name: &C,
dynamic: impl IntoDynamicComponentValue,
) -> Style
where C::ComponentType: IntoComponentValue { ... }
fn with_local_dynamic<C: ComponentDefinition>(
self,
name: &C,
dynamic: impl IntoDynamicComponentValue,
) -> Style
where C::ComponentType: IntoComponentValue { ... }
fn with_shortcut<F>(
self,
key: impl Into<ShortcutKey>,
modifiers: ModifiersState,
callback: F,
) -> Shortcuts
where F: FnMut(KeyEvent) -> EventHandling + Send + 'static { ... }
fn with_repeating_shortcut<F>(
self,
key: impl Into<ShortcutKey>,
modifiers: ModifiersState,
callback: F,
) -> Shortcuts
where F: FnMut(KeyEvent) -> EventHandling + Send + 'static { ... }
fn h1(self) -> Style { ... }
fn h2(self) -> Style { ... }
fn h3(self) -> Style { ... }
fn h4(self) -> Style { ... }
fn h5(self) -> Style { ... }
fn h6(self) -> Style { ... }
fn xxxx_large(self) -> Style { ... }
fn xxx_large(self) -> Style { ... }
fn xx_large(self) -> Style { ... }
fn x_large(self) -> Style { ... }
fn large(self) -> Style { ... }
fn default_size(self) -> Style { ... }
fn small(self) -> Style { ... }
fn x_small(self) -> Style { ... }
fn hint(self) -> Style { ... }
fn with_hint(self, hint: impl MakeWidget) -> Stack { ... }
fn with_next_focus(
self,
next_focus: impl IntoValue<Option<WidgetId>>,
) -> WidgetInstance { ... }
fn with_enabled(self, enabled: impl IntoValue<bool>) -> WidgetInstance { ... }
fn into_default(self) -> WidgetInstance { ... }
fn into_escape(self) -> WidgetInstance { ... }
fn and(self, other: impl MakeWidget) -> WidgetList { ... }
fn chain<W: MakeWidget>(
self,
others: impl IntoIterator<Item = W>,
) -> WidgetList { ... }
fn expand(self) -> Expand { ... }
fn expand_weighted(self, weight: u8) -> Expand { ... }
fn expand_horizontally(self) -> Expand { ... }
fn expand_vertically(self) -> Expand { ... }
fn size<T>(self, size: Size<T>) -> Resize
where T: Into<DimensionRange> { ... }
fn width(self, width: impl Into<DimensionRange>) -> Resize { ... }
fn height(self, height: impl Into<DimensionRange>) -> Resize { ... }
fn into_button(self) -> Button { ... }
fn to_button(&self) -> Button
where Self: Clone { ... }
fn into_checkbox(self, value: impl IntoDynamic<CheckboxState>) -> Checkbox { ... }
fn to_checkbox(&self, value: impl IntoDynamic<CheckboxState>) -> Checkbox
where Self: Clone { ... }
fn centered(self) -> Align { ... }
fn align_left(self) -> Align { ... }
fn align_right(self) -> Align { ... }
fn align_top(self) -> Align { ... }
fn align_bottom(self) -> Align { ... }
fn fit_horizontally(self) -> Align { ... }
fn fit_vertically(self) -> Align { ... }
fn scroll(self) -> Scroll { ... }
fn vertical_scroll(self) -> Scroll { ... }
fn horizontal_scroll(self) -> Scroll { ... }
fn into_ref(self) -> WidgetRef { ... }
fn contain(self) -> Container { ... }
fn contain_level(self, level: impl IntoValue<ContainerLevel>) -> Container { ... }
fn background_color(self, color: impl IntoValue<Color>) -> Container { ... }
fn pad(self) -> Container { ... }
fn pad_by(self, padding: impl IntoValue<Edges<Dimension>>) -> Container { ... }
fn themed(self, theme: impl IntoValue<ThemePair>) -> Themed { ... }
fn localized_in(
self,
locale: impl IntoValue<LanguageIdentifier>,
) -> Localized { ... }
fn themed_mode(self, mode: impl IntoValue<ThemeMode>) -> ThemedMode { ... }
fn collapse_horizontally(
self,
collapse_when: impl IntoDynamic<bool>,
) -> Collapse { ... }
fn collapse_vertically(
self,
collapse_when: impl IntoDynamic<bool>,
) -> Collapse { ... }
fn disclose(self) -> Disclose { ... }
fn validation(self, validation: impl IntoDynamic<Validation>) -> Validated { ... }
fn tooltip(self, layer: &OverlayLayer, tip: impl MakeWidget) -> Tooltipped { ... }
}
Expand description
A type that can create a WidgetInstance
.
Required Methods§
sourcefn make_widget(self) -> WidgetInstance
fn make_widget(self) -> WidgetInstance
Returns a new widget.
Provided Methods§
sourcefn into_window(self) -> Window
fn into_window(self) -> Window
Returns a new window containing self
as the root widget.
sourcefn build_standalone_window(self) -> StandaloneWindowBuilder
fn build_standalone_window(self) -> StandaloneWindowBuilder
Returns a builder for a standalone window.
A standalone window can be either a
VirtualWindow
or a
CushyWindow
.
sourcefn build_recorder(self) -> VirtualRecorderBuilder<Rgb8>
fn build_recorder(self) -> VirtualRecorderBuilder<Rgb8>
Returns a builder for a VirtualRecorder
sourcefn with_styles(self, styles: impl IntoValue<Styles>) -> Stylewhere
Self: Sized,
fn with_styles(self, styles: impl IntoValue<Styles>) -> Stylewhere
Self: Sized,
Associates styles
with this widget.
This is equivalent to Style::new(styles, self)
.
sourcefn with<C: ComponentDefinition>(
self,
name: &C,
component: impl IntoValue<C::ComponentType>,
) -> Style
fn with<C: ComponentDefinition>( self, name: &C, component: impl IntoValue<C::ComponentType>, ) -> Style
Associates a style component with self
.
sourcefn with_local<C: ComponentDefinition>(
self,
name: &C,
component: impl IntoValue<C::ComponentType>,
) -> Style
fn with_local<C: ComponentDefinition>( self, name: &C, component: impl IntoValue<C::ComponentType>, ) -> Style
Associates a style component with self
, ensuring that no child widgets
inherit this component.
sourcefn with_dynamic<C: ComponentDefinition>(
self,
name: &C,
dynamic: impl IntoDynamicComponentValue,
) -> Stylewhere
C::ComponentType: IntoComponentValue,
fn with_dynamic<C: ComponentDefinition>(
self,
name: &C,
dynamic: impl IntoDynamicComponentValue,
) -> Stylewhere
C::ComponentType: IntoComponentValue,
Associates a style component with self
, resolving its value using
dynamic
at runtime.
sourcefn with_local_dynamic<C: ComponentDefinition>(
self,
name: &C,
dynamic: impl IntoDynamicComponentValue,
) -> Stylewhere
C::ComponentType: IntoComponentValue,
fn with_local_dynamic<C: ComponentDefinition>(
self,
name: &C,
dynamic: impl IntoDynamicComponentValue,
) -> Stylewhere
C::ComponentType: IntoComponentValue,
Associates a style component with self
, resolving its value using
dynamic
at runtime. This component will not be inherited to child
widgets.
sourcefn with_shortcut<F>(
self,
key: impl Into<ShortcutKey>,
modifiers: ModifiersState,
callback: F,
) -> Shortcuts
fn with_shortcut<F>( self, key: impl Into<ShortcutKey>, modifiers: ModifiersState, callback: F, ) -> Shortcuts
Invokes callback
when key
is pressed while modifiers
are pressed.
This shortcut will only be invoked if focus is within self
or a child
of self
, or if the returned widget becomes the root widget of a
window.
sourcefn with_repeating_shortcut<F>(
self,
key: impl Into<ShortcutKey>,
modifiers: ModifiersState,
callback: F,
) -> Shortcuts
fn with_repeating_shortcut<F>( self, key: impl Into<ShortcutKey>, modifiers: ModifiersState, callback: F, ) -> Shortcuts
Invokes callback
when key
is pressed while modifiers
are pressed.
If the shortcut is held, the callback will be invoked on repeat events.
This shortcut will only be invoked if focus is within self
or a child
of self
, or if the returned widget becomes the root widget of a
window.
sourcefn xxxx_large(self) -> Style
fn xxxx_large(self) -> Style
Styles self
with the largest text size.
sourcefn default_size(self) -> Style
fn default_size(self) -> Style
Styles self
with the third smallest text size.
sourcefn with_hint(self, hint: impl MakeWidget) -> Stack
fn with_hint(self, hint: impl MakeWidget) -> Stack
Attaches hint
as an informational hint message below self
.
The spacing between self
and hint
is half of IntrinsicPadding
.
sourcefn with_next_focus(
self,
next_focus: impl IntoValue<Option<WidgetId>>,
) -> WidgetInstance
fn with_next_focus( self, next_focus: impl IntoValue<Option<WidgetId>>, ) -> WidgetInstance
Sets the widget that should be focused next.
Cushy automatically determines reverse tab order by using this same relationship.
sourcefn with_enabled(self, enabled: impl IntoValue<bool>) -> WidgetInstance
fn with_enabled(self, enabled: impl IntoValue<bool>) -> WidgetInstance
Sets this widget to be enabled/disabled based on enabled
and returns
self.
If this widget is disabled, all children widgets will also be disabled.
§Panics
This function can only be called when one instance of the widget exists. If any clones exist, a panic will occur.
sourcefn into_default(self) -> WidgetInstance
fn into_default(self) -> WidgetInstance
Sets this widget as a “default” widget.
Default widgets are automatically activated when the user signals they are ready for the default action to occur.
Example widgets this is used for are:
- Submit buttons on forms
- Ok buttons
sourcefn into_escape(self) -> WidgetInstance
fn into_escape(self) -> WidgetInstance
Sets this widget as an “escape” widget.
Escape widgets are automatically activated when the user signals they are ready to escape their current situation.
Example widgets this is used for are:
- Close buttons
- Cancel buttons
sourcefn and(self, other: impl MakeWidget) -> WidgetList
fn and(self, other: impl MakeWidget) -> WidgetList
Returns a collection of widgets using self
and other
.
sourcefn chain<W: MakeWidget>(self, others: impl IntoIterator<Item = W>) -> WidgetList
fn chain<W: MakeWidget>(self, others: impl IntoIterator<Item = W>) -> WidgetList
Chains self
and others
into a WidgetList
.
sourcefn expand_weighted(self, weight: u8) -> Expand
fn expand_weighted(self, weight: u8) -> Expand
Expands self
to grow to fill its parent proportionally with other
weighted siblings.
sourcefn expand_horizontally(self) -> Expand
fn expand_horizontally(self) -> Expand
Expands self
to grow to fill its parent horizontally.
sourcefn expand_vertically(self) -> Expand
fn expand_vertically(self) -> Expand
Expands self
to grow to fill its parent vertically.
sourcefn size<T>(self, size: Size<T>) -> Resizewhere
T: Into<DimensionRange>,
fn size<T>(self, size: Size<T>) -> Resizewhere
T: Into<DimensionRange>,
Resizes self
to size
.
sourcefn width(self, width: impl Into<DimensionRange>) -> Resize
fn width(self, width: impl Into<DimensionRange>) -> Resize
sourcefn height(self, height: impl Into<DimensionRange>) -> Resize
fn height(self, height: impl Into<DimensionRange>) -> Resize
Returns this widget as the contents of a clickable button.
Returns this widget as the contents of a clickable button.
sourcefn into_checkbox(self, value: impl IntoDynamic<CheckboxState>) -> Checkbox
fn into_checkbox(self, value: impl IntoDynamic<CheckboxState>) -> Checkbox
Returns this widget as the label of a Checkbox.
sourcefn to_checkbox(&self, value: impl IntoDynamic<CheckboxState>) -> Checkboxwhere
Self: Clone,
fn to_checkbox(&self, value: impl IntoDynamic<CheckboxState>) -> Checkboxwhere
Self: Clone,
Returns this widget as the label of a Checkbox.
sourcefn align_left(self) -> Align
fn align_left(self) -> Align
Aligns self
to the left.
sourcefn align_right(self) -> Align
fn align_right(self) -> Align
Aligns self
to the right.
sourcefn align_bottom(self) -> Align
fn align_bottom(self) -> Align
Aligns self
to the bottom.
sourcefn fit_horizontally(self) -> Align
fn fit_horizontally(self) -> Align
Fits self
horizontally within its parent.
sourcefn fit_vertically(self) -> Align
fn fit_vertically(self) -> Align
Fits self
vertically within its parent.
sourcefn vertical_scroll(self) -> Scroll
fn vertical_scroll(self) -> Scroll
Allows scrolling self
vertically.
sourcefn horizontal_scroll(self) -> Scroll
fn horizontal_scroll(self) -> Scroll
Allows scrolling self
horizontally.
sourcefn contain_level(self, level: impl IntoValue<ContainerLevel>) -> Container
fn contain_level(self, level: impl IntoValue<ContainerLevel>) -> Container
Wraps self
in a Container
with the specified level.
sourcefn background_color(self, color: impl IntoValue<Color>) -> Container
fn background_color(self, color: impl IntoValue<Color>) -> Container
Returns a new widget that renders color
behind self
.
sourcefn pad_by(self, padding: impl IntoValue<Edges<Dimension>>) -> Container
fn pad_by(self, padding: impl IntoValue<Edges<Dimension>>) -> Container
Wraps self
with the specified padding.
sourcefn themed(self, theme: impl IntoValue<ThemePair>) -> Themed
fn themed(self, theme: impl IntoValue<ThemePair>) -> Themed
Applies theme
to self
and its children.
sourcefn localized_in(self, locale: impl IntoValue<LanguageIdentifier>) -> Localized
fn localized_in(self, locale: impl IntoValue<LanguageIdentifier>) -> Localized
Applies theme
to self
and its children.
sourcefn themed_mode(self, mode: impl IntoValue<ThemeMode>) -> ThemedMode
fn themed_mode(self, mode: impl IntoValue<ThemeMode>) -> ThemedMode
Applies mode
to self
and its children.
sourcefn collapse_horizontally(
self,
collapse_when: impl IntoDynamic<bool>,
) -> Collapse
fn collapse_horizontally( self, collapse_when: impl IntoDynamic<bool>, ) -> Collapse
Returns a widget that collapses self
horizontally based on the dynamic boolean value.
This widget will be collapsed when the dynamic contains true
, and
revealed when the dynamic contains false
.
sourcefn collapse_vertically(self, collapse_when: impl IntoDynamic<bool>) -> Collapse
fn collapse_vertically(self, collapse_when: impl IntoDynamic<bool>) -> Collapse
Returns a widget that collapses self
vertically based on the dynamic
boolean value.
This widget will be collapsed when the dynamic contains true
, and
revealed when the dynamic contains false
.
sourcefn validation(self, validation: impl IntoDynamic<Validation>) -> Validated
fn validation(self, validation: impl IntoDynamic<Validation>) -> Validated
Returns a widget that shows validation errors and/or hints.
sourcefn tooltip(self, layer: &OverlayLayer, tip: impl MakeWidget) -> Tooltipped
fn tooltip(self, layer: &OverlayLayer, tip: impl MakeWidget) -> Tooltipped
Returns a widget that shows tip
on layer
when self
is hovered.