Trait cushy::widget::MakeWidget
source · pub trait MakeWidget: Sized {
Show 58 methods
// Required method
fn make_widget(self) -> WidgetInstance;
// Provided methods
fn into_window(self) -> Window<WidgetInstance> { ... }
fn build_virtual_window(self) -> CushyWindowBuilder { ... }
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_dynamic<C: ComponentDefinition>(
self,
name: &C,
dynamic: impl IntoDynamicComponentValue
) -> Style
where Value<C::ComponentType>: IntoComponentValue { ... }
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 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 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 into_checkbox(self, value: impl IntoDynamic<CheckboxState>) -> Checkbox { ... }
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 widget_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 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<WidgetInstance>
fn into_window(self) -> Window<WidgetInstance>
Returns a new window containing self
as the root widget.
sourcefn build_virtual_window(self) -> CushyWindowBuilder
fn build_virtual_window(self) -> CushyWindowBuilder
Returns a builder for a VirtualWindow
.
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_dynamic<C: ComponentDefinition>(
self,
name: &C,
dynamic: impl IntoDynamicComponentValue
) -> Style
fn with_dynamic<C: ComponentDefinition>( self, name: &C, dynamic: impl IntoDynamicComponentValue ) -> Style
Associates a style component with self
, resolving its value using
dynamic
at runtime.
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_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 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 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.
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 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 widget_ref(self) -> WidgetRef
fn widget_ref(self) -> WidgetRef
Creates a WidgetRef
for use as child widget.
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 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.