pub struct CanvasView<State: 'static> { /* private fields */ }Expand description
A declarative custom-painting canvas. See the module docs.
Implementations§
Source§impl<State: 'static> CanvasView<State>
impl<State: 'static> CanvasView<State>
Sourcepub fn size(self, size: Size) -> Self
pub fn size(self, size: Size) -> Self
Force an explicit size, clamped into whatever constraints this
widget’s parent hands it. Overrides CanvasView::expand when called
after it (last builder call wins, matching the crate’s other
size-mode builders — e.g. crate::platform_view).
Sourcepub fn expand(self) -> Self
pub fn expand(self) -> Self
Fill the incoming constraints’ maximum — the default (see the module docs), provided as an explicit builder call for readability at call sites that want to make the choice visible.
Sourcepub fn on_hit<F: Fn(Point, Size) -> bool + 'static>(self, hit: F) -> Self
pub fn on_hit<F: Fn(Point, Size) -> bool + 'static>(self, hit: F) -> Self
Narrow pointer hit-testing to hit(local_point, size) -> bool,
consulted before CanvasView::on_tap/CanvasView::on_pointer
dispatch (see the module docs). Unset, hit-testing falls back
to the ordinary “inside the rectangular bounds” test every other
baseline leaf uses.
Sourcepub fn on_tap<F: Fn(&mut State) + 'static>(self, on_tap: F) -> Self
pub fn on_tap<F: Fn(&mut State) + 'static>(self, on_tap: F) -> Self
Fire on_tap(state) on an up-inside release (gated by
CanvasView::on_hit, see the module docs).
Sourcepub fn on_pointer<F: Fn(&mut State, PointerEvent) + 'static>(
self,
on_pointer: F,
) -> Self
pub fn on_pointer<F: Fn(&mut State, PointerEvent) + 'static>( self, on_pointer: F, ) -> Self
Fire on_pointer(state, event) with the raw PointerEvent on every
phase the hit-test admits (gated by CanvasView::on_hit, see the
module docs) — the escape hatch for a caller that wants the
full gesture (drag included) rather than just the tap summary.
Sourcepub fn repaint_key(self, key: impl Hash) -> Self
pub fn repaint_key(self, key: impl Hash) -> Self
Opt into paint-only dirtying driven by a dependency outside the
ordinary View diff: hash any Hash fingerprint of the data the
paint closure reads, and a changed hash across a rebuild requests
ChangeFlags::PAINT even when nothing else about the view changed.
See the module docs.
Trait Implementations§
Source§impl<State: 'static> View<State> for CanvasView<State>
impl<State: 'static> View<State> for CanvasView<State>
Source§type Element = CanvasWidget
type Element = CanvasWidget
Source§fn build(&self, _ctx: &mut BuildCtx<'_>) -> CanvasWidget
fn build(&self, _ctx: &mut BuildCtx<'_>) -> CanvasWidget
Source§fn rebuild(
&self,
prev: &Self,
element: &mut CanvasWidget,
_ctx: &mut BuildCtx<'_>,
) -> ChangeFlags
fn rebuild( &self, prev: &Self, element: &mut CanvasWidget, _ctx: &mut BuildCtx<'_>, ) -> ChangeFlags
prev (the previous view of the same type) against the live
element, mutating it in place and reporting what changed.