Trait cushy::widget::WrapperWidget
source · pub trait WrapperWidget:
Debug
+ Send
+ 'static {
Show 27 methods
// Required method
fn child_mut(&mut self) -> &mut WidgetRef;
// Provided methods
fn summarize(&self, f: &mut Formatter<'_>) -> Result { ... }
fn root_behavior(
&mut self,
context: &mut EventContext<'_>,
) -> Option<RootBehavior> { ... }
fn redraw_background(
&mut self,
context: &mut GraphicsContext<'_, '_, '_, '_>,
) { ... }
fn redraw_foreground(
&mut self,
context: &mut GraphicsContext<'_, '_, '_, '_>,
) { ... }
fn layout_child(
&mut self,
available_space: Size<ConstraintLimit>,
context: &mut LayoutContext<'_, '_, '_, '_>,
) -> WrappedLayout { ... }
fn adjust_child_constraints(
&mut self,
available_space: Size<ConstraintLimit>,
context: &mut LayoutContext<'_, '_, '_, '_>,
) -> Size<ConstraintLimit> { ... }
fn position_child(
&mut self,
size: Size<Px>,
available_space: Size<ConstraintLimit>,
context: &mut LayoutContext<'_, '_, '_, '_>,
) -> WrappedLayout { ... }
fn background_color(&mut self, context: &WidgetContext<'_>) -> Option<Color> { ... }
fn mounted(&mut self, context: &mut EventContext<'_>) { ... }
fn unmounted(&mut self, context: &mut EventContext<'_>) { ... }
fn hit_test(
&mut self,
location: Point<Px>,
context: &mut EventContext<'_>,
) -> bool { ... }
fn hover(
&mut self,
location: Point<Px>,
context: &mut EventContext<'_>,
) -> Option<CursorIcon> { ... }
fn unhover(&mut self, context: &mut EventContext<'_>) { ... }
fn accept_focus(&mut self, context: &mut EventContext<'_>) -> bool { ... }
fn advance_focus(
&mut self,
direction: VisualOrder,
context: &mut EventContext<'_>,
) -> EventHandling { ... }
fn focus(&mut self, context: &mut EventContext<'_>) { ... }
fn allow_blur(&mut self, context: &mut EventContext<'_>) -> bool { ... }
fn blur(&mut self, context: &mut EventContext<'_>) { ... }
fn activate(&mut self, context: &mut EventContext<'_>) { ... }
fn deactivate(&mut self, context: &mut EventContext<'_>) { ... }
fn mouse_down(
&mut self,
location: Point<Px>,
device_id: DeviceId,
button: MouseButton,
context: &mut EventContext<'_>,
) -> EventHandling { ... }
fn mouse_drag(
&mut self,
location: Point<Px>,
device_id: DeviceId,
button: MouseButton,
context: &mut EventContext<'_>,
) { ... }
fn mouse_up(
&mut self,
location: Option<Point<Px>>,
device_id: DeviceId,
button: MouseButton,
context: &mut EventContext<'_>,
) { ... }
fn keyboard_input(
&mut self,
device_id: DeviceId,
input: KeyEvent,
is_synthetic: bool,
context: &mut EventContext<'_>,
) -> EventHandling { ... }
fn ime(&mut self, ime: Ime, context: &mut EventContext<'_>) -> EventHandling { ... }
fn mouse_wheel(
&mut self,
device_id: DeviceId,
delta: MouseScrollDelta,
phase: TouchPhase,
context: &mut EventContext<'_>,
) -> EventHandling { ... }
}
Expand description
A Widget
that contains a single child.
Required Methods§
Provided Methods§
sourcefn summarize(&self, f: &mut Formatter<'_>) -> Result
fn summarize(&self, f: &mut Formatter<'_>) -> Result
Writes a summary of this widget into fmt
.
The default implementation calls Debug::fmt
. This function allows
widget authors to print only publicly relevant information that will
appear when debug formatting a WidgetInstance
.
sourcefn root_behavior(
&mut self,
context: &mut EventContext<'_>,
) -> Option<RootBehavior>
fn root_behavior( &mut self, context: &mut EventContext<'_>, ) -> Option<RootBehavior>
Returns the behavior this widget should apply when positioned at the root of the window.
The provided implementation for WrapperWidget
returns
RootBehavior::PassThrough
. This is different from the provided
implementation for Widget
.
sourcefn redraw_background(&mut self, context: &mut GraphicsContext<'_, '_, '_, '_>)
fn redraw_background(&mut self, context: &mut GraphicsContext<'_, '_, '_, '_>)
Draws the background of the widget.
This is invoked before the wrapped widget is drawn.
sourcefn redraw_foreground(&mut self, context: &mut GraphicsContext<'_, '_, '_, '_>)
fn redraw_foreground(&mut self, context: &mut GraphicsContext<'_, '_, '_, '_>)
Draws the foreground of the widget.
This is invoked after the wrapped widget is drawn.
sourcefn layout_child(
&mut self,
available_space: Size<ConstraintLimit>,
context: &mut LayoutContext<'_, '_, '_, '_>,
) -> WrappedLayout
fn layout_child( &mut self, available_space: Size<ConstraintLimit>, context: &mut LayoutContext<'_, '_, '_, '_>, ) -> WrappedLayout
Returns the rectangle that the child widget should occupy given
available_space
.
sourcefn adjust_child_constraints(
&mut self,
available_space: Size<ConstraintLimit>,
context: &mut LayoutContext<'_, '_, '_, '_>,
) -> Size<ConstraintLimit>
fn adjust_child_constraints( &mut self, available_space: Size<ConstraintLimit>, context: &mut LayoutContext<'_, '_, '_, '_>, ) -> Size<ConstraintLimit>
Returns the adjusted contraints to use when laying out the child.
sourcefn position_child(
&mut self,
size: Size<Px>,
available_space: Size<ConstraintLimit>,
context: &mut LayoutContext<'_, '_, '_, '_>,
) -> WrappedLayout
fn position_child( &mut self, size: Size<Px>, available_space: Size<ConstraintLimit>, context: &mut LayoutContext<'_, '_, '_, '_>, ) -> WrappedLayout
Returns the layout after positioning the child that occupies size
.
sourcefn background_color(&mut self, context: &WidgetContext<'_>) -> Option<Color>
fn background_color(&mut self, context: &WidgetContext<'_>) -> Option<Color>
Returns the background color to render behind the wrapped widget.
sourcefn mounted(&mut self, context: &mut EventContext<'_>)
fn mounted(&mut self, context: &mut EventContext<'_>)
The widget has been mounted into a parent widget.
sourcefn unmounted(&mut self, context: &mut EventContext<'_>)
fn unmounted(&mut self, context: &mut EventContext<'_>)
The widget has been removed from its parent widget.
sourcefn hit_test(
&mut self,
location: Point<Px>,
context: &mut EventContext<'_>,
) -> bool
fn hit_test( &mut self, location: Point<Px>, context: &mut EventContext<'_>, ) -> bool
Returns true if this widget should respond to mouse input at location
.
sourcefn hover(
&mut self,
location: Point<Px>,
context: &mut EventContext<'_>,
) -> Option<CursorIcon>
fn hover( &mut self, location: Point<Px>, context: &mut EventContext<'_>, ) -> Option<CursorIcon>
The widget is currently has a cursor hovering it at location
.
sourcefn unhover(&mut self, context: &mut EventContext<'_>)
fn unhover(&mut self, context: &mut EventContext<'_>)
The widget is no longer being hovered.
sourcefn accept_focus(&mut self, context: &mut EventContext<'_>) -> bool
fn accept_focus(&mut self, context: &mut EventContext<'_>) -> bool
This widget has been targeted to be focused. If this function returns true, the widget will be focused. If false, Cushy will continue searching for another focus target.
sourcefn advance_focus(
&mut self,
direction: VisualOrder,
context: &mut EventContext<'_>,
) -> EventHandling
fn advance_focus( &mut self, direction: VisualOrder, context: &mut EventContext<'_>, ) -> EventHandling
The widget should switch to the next focusable area within this widget,
honoring direction
in a consistent manner. Returning HANDLED
will
cause the search for the next focus widget stop.
sourcefn focus(&mut self, context: &mut EventContext<'_>)
fn focus(&mut self, context: &mut EventContext<'_>)
The widget has received focus for user input.
sourcefn allow_blur(&mut self, context: &mut EventContext<'_>) -> bool
fn allow_blur(&mut self, context: &mut EventContext<'_>) -> bool
The widget is about to lose focus. Returning true allows the focus to switch away from this widget.
sourcefn blur(&mut self, context: &mut EventContext<'_>)
fn blur(&mut self, context: &mut EventContext<'_>)
The widget is no longer focused for user input.
sourcefn activate(&mut self, context: &mut EventContext<'_>)
fn activate(&mut self, context: &mut EventContext<'_>)
The widget has become the active widget.
sourcefn deactivate(&mut self, context: &mut EventContext<'_>)
fn deactivate(&mut self, context: &mut EventContext<'_>)
The widget is no longer active.
sourcefn mouse_down(
&mut self,
location: Point<Px>,
device_id: DeviceId,
button: MouseButton,
context: &mut EventContext<'_>,
) -> EventHandling
fn mouse_down( &mut self, location: Point<Px>, device_id: DeviceId, button: MouseButton, context: &mut EventContext<'_>, ) -> EventHandling
A mouse button event has occurred at location
. Returns whether the
event has been handled or not.
If an event is handled, the widget will receive callbacks for
mouse_drag
and mouse_up
.
sourcefn mouse_drag(
&mut self,
location: Point<Px>,
device_id: DeviceId,
button: MouseButton,
context: &mut EventContext<'_>,
)
fn mouse_drag( &mut self, location: Point<Px>, device_id: DeviceId, button: MouseButton, context: &mut EventContext<'_>, )
A mouse button is being held down as the cursor is moved across the widget.
sourcefn mouse_up(
&mut self,
location: Option<Point<Px>>,
device_id: DeviceId,
button: MouseButton,
context: &mut EventContext<'_>,
)
fn mouse_up( &mut self, location: Option<Point<Px>>, device_id: DeviceId, button: MouseButton, context: &mut EventContext<'_>, )
A mouse button is no longer being pressed.
sourcefn keyboard_input(
&mut self,
device_id: DeviceId,
input: KeyEvent,
is_synthetic: bool,
context: &mut EventContext<'_>,
) -> EventHandling
fn keyboard_input( &mut self, device_id: DeviceId, input: KeyEvent, is_synthetic: bool, context: &mut EventContext<'_>, ) -> EventHandling
A keyboard event has been sent to this widget. Returns whether the event has been handled or not.
sourcefn ime(&mut self, ime: Ime, context: &mut EventContext<'_>) -> EventHandling
fn ime(&mut self, ime: Ime, context: &mut EventContext<'_>) -> EventHandling
An input manager event has been sent to this widget. Returns whether the event has been handled or not.
sourcefn mouse_wheel(
&mut self,
device_id: DeviceId,
delta: MouseScrollDelta,
phase: TouchPhase,
context: &mut EventContext<'_>,
) -> EventHandling
fn mouse_wheel( &mut self, device_id: DeviceId, delta: MouseScrollDelta, phase: TouchPhase, context: &mut EventContext<'_>, ) -> EventHandling
A mouse wheel event has been sent to this widget. Returns whether the event has been handled or not.