[−][src]Trait kas::Layout
Positioning and drawing routines for widgets
This trait contains methods concerned with positioning of contents, other
than those in kas::event::Handler
.
Required methods
fn size_rules(
&mut self,
size_handle: &mut dyn SizeHandle,
axis: AxisInfo
) -> SizeRules
&mut self,
size_handle: &mut dyn SizeHandle,
axis: AxisInfo
) -> SizeRules
Get size rules for the given axis.
This method takes &mut self
to allow local caching of child widget
configuration for future size_rules
and set_rect
calls.
Optionally, this method may set self.rect().size
to the widget's ideal
size for use by Layout::set_rect
when setting alignment.
If operating on one axis and the other is fixed, then the other
parameter is used for the fixed dimension. Additionally, one may assume
that size_rules
has previously been called on the fixed axis with the
current widget configuration.
fn draw(&self, draw_handle: &mut dyn DrawHandle, mgr: &ManagerState)
Draw a widget
This method is called to draw each visible widget (and should not attempt recursion on child widgets).
Provided methods
fn set_rect(
&mut self,
_size_handle: &mut dyn SizeHandle,
rect: Rect,
_align: AlignHints
)
&mut self,
_size_handle: &mut dyn SizeHandle,
rect: Rect,
_align: AlignHints
)
Adjust to the given size.
For widgets with children, this is usually implemented via the derive macro. For non-parent widgets which stretch to fill available space, the default implementation suffices. For non-parent widgets which react to alignment, this is a little more complex to implement, and can be done in one of two ways:
- Shrinking to ideal area and aligning within available space (e.g.
CheckBoxBare
widget) - Filling available space and applying alignment to contents (e.g.
Label
widget)
One may assume that size_rules
has been called for each axis with the
current widget configuration.
fn find_id(&self, _coord: Coord) -> Option<WidgetId>
Find a child widget by coordinate
This is used by the event manager to target the correct widget given an event from a coordinate source (mouse pointer, touch event). Widgets may return their own Id over that of children in order to steal events (e.g. a button using an inner label widget).
This must not be called before Layout::set_rect
.
In the case of an empty grid cell, the parent widget is returned
(same behaviour as with events addressed by coordinate).
The only case None
should be expected is when coord
is outside the
initial widget's region; however this is not guaranteed.
Implementations on Foreign Types
impl<M> Layout for Box<dyn Handler<Msg = M>>
[src]
fn size_rules(
&mut self,
size_handle: &mut dyn SizeHandle,
axis: AxisInfo
) -> SizeRules
[src]
&mut self,
size_handle: &mut dyn SizeHandle,
axis: AxisInfo
) -> SizeRules
fn set_rect(
&mut self,
size_handle: &mut dyn SizeHandle,
rect: Rect,
align: AlignHints
)
[src]
&mut self,
size_handle: &mut dyn SizeHandle,
rect: Rect,
align: AlignHints
)
fn find_id(&self, coord: Coord) -> Option<WidgetId>
[src]
fn draw(&self, draw_handle: &mut dyn DrawHandle, mgr: &ManagerState)
[src]
Implementors
impl Layout for Filler
[src]
fn size_rules(&mut self, _: &mut dyn SizeHandle, _: AxisInfo) -> SizeRules
[src]
fn draw(&self, _: &mut dyn DrawHandle, _: &ManagerState)
[src]
impl Layout for Label
[src]
fn size_rules(
&mut self,
size_handle: &mut dyn SizeHandle,
axis: AxisInfo
) -> SizeRules
[src]
&mut self,
size_handle: &mut dyn SizeHandle,
axis: AxisInfo
) -> SizeRules
fn set_rect(
&mut self,
_size_handle: &mut dyn SizeHandle,
rect: Rect,
align: AlignHints
)
[src]
&mut self,
_size_handle: &mut dyn SizeHandle,
rect: Rect,
align: AlignHints
)
fn draw(&self, draw_handle: &mut dyn DrawHandle, _: &ManagerState)
[src]
impl Layout for MessageBox
[src]
fn size_rules(
&mut self,
size_handle: &mut dyn SizeHandle,
axis: AxisInfo
) -> SizeRules
[src]
&mut self,
size_handle: &mut dyn SizeHandle,
axis: AxisInfo
) -> SizeRules
fn set_rect(
&mut self,
size_handle: &mut dyn SizeHandle,
rect: Rect,
_: AlignHints
)
[src]
&mut self,
size_handle: &mut dyn SizeHandle,
rect: Rect,
_: AlignHints
)
fn find_id(&self, coord: Coord) -> Option<WidgetId>
[src]
fn draw(&self, draw_handle: &mut dyn DrawHandle, mgr: &ManagerState)
[src]
impl<D: Directional> Layout for ScrollBar<D>
[src]
fn size_rules(
&mut self,
size_handle: &mut dyn SizeHandle,
axis: AxisInfo
) -> SizeRules
[src]
&mut self,
size_handle: &mut dyn SizeHandle,
axis: AxisInfo
) -> SizeRules
fn set_rect(
&mut self,
size_handle: &mut dyn SizeHandle,
rect: Rect,
_: AlignHints
)
[src]
&mut self,
size_handle: &mut dyn SizeHandle,
rect: Rect,
_: AlignHints
)
fn draw(&self, draw_handle: &mut dyn DrawHandle, mgr: &ManagerState)
[src]
impl<D: Directional, W: Widget> Layout for List<D, W>
[src]
fn size_rules(
&mut self,
size_handle: &mut dyn SizeHandle,
axis: AxisInfo
) -> SizeRules
[src]
&mut self,
size_handle: &mut dyn SizeHandle,
axis: AxisInfo
) -> SizeRules
fn set_rect(
&mut self,
size_handle: &mut dyn SizeHandle,
rect: Rect,
_: AlignHints
)
[src]
&mut self,
size_handle: &mut dyn SizeHandle,
rect: Rect,
_: AlignHints
)
fn find_id(&self, coord: Coord) -> Option<WidgetId>
[src]
fn draw(&self, draw_handle: &mut dyn DrawHandle, mgr: &ManagerState)
[src]
impl<H: 'static> Layout for EditBox<H>
[src]
fn size_rules(
&mut self,
size_handle: &mut dyn SizeHandle,
axis: AxisInfo
) -> SizeRules
[src]
&mut self,
size_handle: &mut dyn SizeHandle,
axis: AxisInfo
) -> SizeRules
fn set_rect(
&mut self,
size_handle: &mut dyn SizeHandle,
rect: Rect,
align: AlignHints
)
[src]
&mut self,
size_handle: &mut dyn SizeHandle,
rect: Rect,
align: AlignHints
)
fn draw(&self, draw_handle: &mut dyn DrawHandle, mgr: &ManagerState)
[src]
impl<M: Clone + Debug> Layout for TextButton<M>
[src]
fn size_rules(
&mut self,
size_handle: &mut dyn SizeHandle,
axis: AxisInfo
) -> SizeRules
[src]
&mut self,
size_handle: &mut dyn SizeHandle,
axis: AxisInfo
) -> SizeRules
fn set_rect(
&mut self,
size_handle: &mut dyn SizeHandle,
rect: Rect,
align: AlignHints
)
[src]
&mut self,
size_handle: &mut dyn SizeHandle,
rect: Rect,
align: AlignHints
)
fn find_id(&self, coord: Coord) -> Option<WidgetId>
[src]
fn draw(&self, draw_handle: &mut dyn DrawHandle, mgr: &ManagerState)
[src]
impl<OT: 'static> Layout for CheckBox<OT>
[src]
fn size_rules(
&mut self,
size_handle: &mut dyn SizeHandle,
axis: AxisInfo
) -> SizeRules
[src]
&mut self,
size_handle: &mut dyn SizeHandle,
axis: AxisInfo
) -> SizeRules
fn set_rect(
&mut self,
size_handle: &mut dyn SizeHandle,
rect: Rect,
_: AlignHints
)
[src]
&mut self,
size_handle: &mut dyn SizeHandle,
rect: Rect,
_: AlignHints
)
fn find_id(&self, coord: Coord) -> Option<WidgetId>
[src]
fn draw(&self, draw_handle: &mut dyn DrawHandle, mgr: &ManagerState)
[src]
impl<OT: 'static> Layout for CheckBoxBare<OT>
[src]
fn size_rules(
&mut self,
size_handle: &mut dyn SizeHandle,
axis: AxisInfo
) -> SizeRules
[src]
&mut self,
size_handle: &mut dyn SizeHandle,
axis: AxisInfo
) -> SizeRules
fn set_rect(
&mut self,
_size_handle: &mut dyn SizeHandle,
rect: Rect,
align: AlignHints
)
[src]
&mut self,
_size_handle: &mut dyn SizeHandle,
rect: Rect,
align: AlignHints
)
fn draw(&self, draw_handle: &mut dyn DrawHandle, mgr: &ManagerState)
[src]
impl<OT: 'static> Layout for RadioBox<OT>
[src]
fn size_rules(
&mut self,
size_handle: &mut dyn SizeHandle,
axis: AxisInfo
) -> SizeRules
[src]
&mut self,
size_handle: &mut dyn SizeHandle,
axis: AxisInfo
) -> SizeRules
fn set_rect(
&mut self,
size_handle: &mut dyn SizeHandle,
rect: Rect,
_: AlignHints
)
[src]
&mut self,
size_handle: &mut dyn SizeHandle,
rect: Rect,
_: AlignHints
)
fn find_id(&self, coord: Coord) -> Option<WidgetId>
[src]
fn draw(&self, draw_handle: &mut dyn DrawHandle, mgr: &ManagerState)
[src]
impl<OT: 'static> Layout for RadioBoxBare<OT>
[src]
fn size_rules(
&mut self,
size_handle: &mut dyn SizeHandle,
axis: AxisInfo
) -> SizeRules
[src]
&mut self,
size_handle: &mut dyn SizeHandle,
axis: AxisInfo
) -> SizeRules
fn set_rect(
&mut self,
_size_handle: &mut dyn SizeHandle,
rect: Rect,
align: AlignHints
)
[src]
&mut self,
_size_handle: &mut dyn SizeHandle,
rect: Rect,
align: AlignHints
)
fn draw(&self, draw_handle: &mut dyn DrawHandle, mgr: &ManagerState)
[src]
impl<W: Widget + 'static> Layout for Window<W>
[src]
fn size_rules(
&mut self,
size_handle: &mut dyn SizeHandle,
axis: AxisInfo
) -> SizeRules
[src]
&mut self,
size_handle: &mut dyn SizeHandle,
axis: AxisInfo
) -> SizeRules
fn set_rect(
&mut self,
size_handle: &mut dyn SizeHandle,
rect: Rect,
_: AlignHints
)
[src]
&mut self,
size_handle: &mut dyn SizeHandle,
rect: Rect,
_: AlignHints
)
fn find_id(&self, coord: Coord) -> Option<WidgetId>
[src]
fn draw(&self, draw_handle: &mut dyn DrawHandle, mgr: &ManagerState)
[src]
impl<W: Widget> Layout for ScrollRegion<W>
[src]
fn size_rules(
&mut self,
size_handle: &mut dyn SizeHandle,
axis: AxisInfo
) -> SizeRules
[src]
&mut self,
size_handle: &mut dyn SizeHandle,
axis: AxisInfo
) -> SizeRules
fn set_rect(
&mut self,
size_handle: &mut dyn SizeHandle,
rect: Rect,
_: AlignHints
)
[src]
&mut self,
size_handle: &mut dyn SizeHandle,
rect: Rect,
_: AlignHints
)