pub struct Tileview<'a, C: PixelColor, M: Clone> { /* private fields */ }Expand description
Full-area paged tile container. Snaps one tile per swipe.
Implementations§
Source§impl<'a, C: PixelColor + 'a, M: Clone + 'a> Tileview<'a, C, M>
impl<'a, C: PixelColor + 'a, M: Clone + 'a> Tileview<'a, C, M>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create an empty tileview paging horizontally. Add tiles via
Tileview::push and supply the host state via
Tileview::scroll_state. Position and size are assigned by the
parent container via arrange.
Sourcepub fn direction(self, dir: ScrollDirection) -> Self
pub fn direction(self, dir: ScrollDirection) -> Self
Paging direction. Only ScrollDirection::Horizontal and
ScrollDirection::Vertical are meaningful; any other value is
treated as horizontal.
Sourcepub fn push<W>(self, tile: W) -> Selfwhere
W: Widget<C, M> + 'a,
pub fn push<W>(self, tile: W) -> Selfwhere
W: Widget<C, M> + 'a,
Push a tile. Tiles are paged in insertion order.
Sourcepub fn scroll_state(self, state: &ScrollState) -> Self
pub fn scroll_state(self, state: &ScrollState) -> Self
Supply the host-owned ScrollState read this frame.
Sourcepub fn width(self, width: impl Into<Length>) -> Self
pub fn width(self, width: impl Into<Length>) -> Self
Width sizing intent (the tileview normally fills its parent).
Sourcepub fn height(self, height: impl Into<Length>) -> Self
pub fn height(self, height: impl Into<Length>) -> Self
Height sizing intent (the tileview normally fills its parent).
Sourcepub fn on_scroll<F>(self, f: F) -> Self
pub fn on_scroll<F>(self, f: F) -> Self
Callback mapping a ScrollMsg to the host message. Apply the
message to the owned ScrollState in update().
Sourcepub fn on_change<F>(self, f: F) -> Self
pub fn on_change<F>(self, f: F) -> Self
Callback fired with the active tile index when it changes.
Drive it from update() via Tileview::change_msg /
Tileview::current_for.
Sourcepub fn current_for(
state: &ScrollState,
viewport: Size,
dir: ScrollDirection,
count: usize,
) -> usize
pub fn current_for( state: &ScrollState, viewport: Size, dir: ScrollDirection, count: usize, ) -> usize
The active tile index for a host ScrollState, the viewport size,
the paging dir, and tile count. The host calls this in update()
after applying a ScrollMsg/tick to learn which tile is showing,
without rebuilding the widget tree.
Trait Implementations§
Source§impl<'a, C: PixelColor + 'a, M: Clone + 'a> Widget<C, M> for Tileview<'a, C, M>
impl<'a, C: PixelColor + 'a, M: Clone + 'a> Widget<C, M> for Tileview<'a, C, M>
Source§fn measure(&mut self, constraints: Constraints) -> Size
fn measure(&mut self, constraints: Constraints) -> Size
constraints.Source§fn preferred_size(&self) -> (Length, Length)
fn preferred_size(&self) -> (Length, Length)
.width(...) / .height(...).
Containers consult this during layout to allocate fixed slots,
query intrinsic sizes, and split residual space among
Fill / FillPortion children. Default is Length::Fill on
both axes.Source§fn arrange(&mut self, rect: Rectangle)
fn arrange(&mut self, rect: Rectangle)
Source§fn handle_touch(&mut self, point: Point, phase: TouchPhase) -> Option<M>
fn handle_touch(&mut self, point: Point, phase: TouchPhase) -> Option<M>
Source§fn mark_pressed(&mut self, point: Point)
fn mark_pressed(&mut self, point: Point)
point hits. No message emit.
Containers forward to children. Default no-op.Source§fn draw<'t>(
&self,
renderer: &mut dyn Renderer<C>,
theme: &Theme<'t, C>,
) -> Result<(), RenderError>
fn draw<'t>( &self, renderer: &mut dyn Renderer<C>, theme: &Theme<'t, C>, ) -> Result<(), RenderError>
renderer at rect.Source§fn widget_id(&self) -> Option<WidgetId>
fn widget_id(&self) -> Option<WidgetId>
Source§fn is_focusable(&self) -> bool
fn is_focusable(&self) -> bool
Source§fn collect_focusable(&self, out: &mut Vec<WidgetId>)
fn collect_focusable(&self, out: &mut Vec<WidgetId>)
Source§fn sync_focus(&mut self, focused: Option<WidgetId>)
fn sync_focus(&mut self, focused: Option<WidgetId>)
Source§fn handle_action(&mut self, action: UiAction) -> Option<M>
fn handle_action(&mut self, action: UiAction) -> Option<M>
Source§fn route_action(&mut self, target: WidgetId, action: UiAction) -> Option<M>
fn route_action(&mut self, target: WidgetId, action: UiAction) -> Option<M>
target.target for directional actions.Auto Trait Implementations§
impl<'a, C, M> Freeze for Tileview<'a, C, M>
impl<'a, C, M> !RefUnwindSafe for Tileview<'a, C, M>
impl<'a, C, M> !Send for Tileview<'a, C, M>
impl<'a, C, M> !Sync for Tileview<'a, C, M>
impl<'a, C, M> Unpin for Tileview<'a, C, M>where
C: Unpin,
impl<'a, C, M> UnsafeUnpin for Tileview<'a, C, M>
impl<'a, C, M> !UnwindSafe for Tileview<'a, C, M>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<'a, C, M, W> IntoElement<'a, C, M> for W
impl<'a, C, M, W> IntoElement<'a, C, M> for W
Source§fn into_element(self) -> Element<'a, C, M>
fn into_element(self) -> Element<'a, C, M>
self.