pub struct Canvas { /* private fields */ }Expand description
A drawing canvas, made by canvas.
Implementations§
Source§impl Canvas
impl Canvas
Sourcepub fn on_drag(self, f: impl Fn(CanvasDrag) + 'static) -> Self
pub fn on_drag(self, f: impl Fn(CanvasDrag) + 'static) -> Self
Drags inside the canvas: moving something it draws (a card on a
diagram). f gets CanvasDrag::Began once the pointer has moved a
few points with the button down, then Moved and Ended. A canvas
with on_drag doesn’t start draggable’s drag out.
Sourcepub fn on_hover(self, f: impl Fn(Option<(f64, f64)>) + 'static) -> Self
pub fn on_hover(self, f: impl Fn(Option<(f64, f64)>) + 'static) -> Self
Called with the pointer’s position as it moves over the canvas, and
None when it leaves (while the app is active).
Sourcepub fn on_click(self, f: impl Fn(f64, f64) + 'static) -> Self
pub fn on_click(self, f: impl Fn(f64, f64) + 'static) -> Self
Called with the position of a click.
Sourcepub fn on_double_click(self, f: impl Fn(f64, f64) + 'static) -> Self
pub fn on_double_click(self, f: impl Fn(f64, f64) + 'static) -> Self
Called with the position of a double click, after
on_click runs for its second click (so a click
can select a tile and a double click open it, as in the Finder).
The interval is the user’s double-click setting.
Sourcepub fn on_scroll(self, f: impl Fn(f64, f64, f64, f64) -> bool + 'static) -> Self
pub fn on_scroll(self, f: impl Fn(f64, f64, f64, f64) -> bool + 'static) -> Self
Called with how far the user scrolls over the canvas (dx, dy in
points, positive to the right and down… as the content would move)
and the pointer’s position; returns whether it used the scroll.
What it doesn’t use scrolls an enclosing scroll view.
Sourcepub fn on_magnify(self, f: impl Fn(f64, f64, f64) -> bool + 'static) -> Self
pub fn on_magnify(self, f: impl Fn(f64, f64, f64) -> bool + 'static) -> Self
Called as the user pinches (or ⌘-scrolls) over the canvas: how much larger (0.1 is 10%; negative is smaller) and the pointer’s position; returns whether it used it.
Sourcepub fn description(self, f: impl Fn() -> String + 'static) -> Self
pub fn description(self, f: impl Fn() -> String + 'static) -> Self
What VoiceOver reads for the canvas (an image to it), kept up to
date as the signals f reads change.
Sourcepub fn draggable(self, f: impl Fn() -> Option<DragItem> + 'static) -> Self
pub fn draggable(self, f: impl Fn() -> Option<DragItem> + 'static) -> Self
Dragging the canvas carries what f returns (nothing if None):
text, an image, a file, or a file written where it’s dropped.
Sourcepub fn exportable(self, name: &str) -> Self
pub fn exportable(self, name: &str) -> Self
The canvas as an image: a right-click menu with Copy Image and Save
Image…, and dragging it out gives name.png (to the Finder, Mail,
a document). Charts use this for exporting.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Canvas
impl !Send for Canvas
impl !Sync for Canvas
impl !UnwindSafe for Canvas
impl Forget for Canvas
impl Freeze for Canvas
impl Move for Canvas
impl Unpin for Canvas
impl UnsafeUnpin for Canvas
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
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<V> ViewExt for Vwhere
V: View,
impl<V> ViewExt for Vwhere
V: View,
Source§fn on_command(
self,
command: Command,
action: impl Fn() + 'static,
) -> Modified<Self>
fn on_command( self, command: Command, action: impl Fn() + 'static, ) -> Modified<Self>
command while the focus is in this view (see
Command).Source§fn on_command_when(
self,
command: Command,
enabled: impl Fn() -> bool + 'static,
action: impl Fn() + 'static,
) -> Modified<Self>
fn on_command_when( self, command: Command, enabled: impl Fn() -> bool + 'static, action: impl Fn() + 'static, ) -> Modified<Self>
command, enabled only while enabled returns true.Source§fn focused_value<T: Clone + 'static>(
self,
name: &'static str,
value: T,
) -> Modified<Self>
fn focused_value<T: Clone + 'static>( self, name: &'static str, value: T, ) -> Modified<Self>
Source§fn padding_xy(self, horizontal: f64, vertical: f64) -> Modified<Self>
fn padding_xy(self, horizontal: f64, vertical: f64) -> Modified<Self>
horizontal points left and right and vertical above and
below: a row’s .padding_xy(10.0, 7.0), as SwiftUI’s
.padding(.horizontal, 10) and .padding(.vertical, 7).Source§fn min_width(self, points: f64) -> Modified<Self>
fn min_width(self, points: f64) -> Modified<Self>
points wide (SwiftUI’s frame(minWidth:)).Source§fn min_height(self, points: f64) -> Modified<Self>
fn min_height(self, points: f64) -> Modified<Self>
points tall (SwiftUI’s frame(minHeight:)).Source§fn fill_width(self) -> Modified<Self>
fn fill_width(self) -> Modified<Self>
Source§fn fill_height(self) -> Modified<Self>
fn fill_height(self) -> Modified<Self>
Source§fn popover<P: View>(
self,
shown: &Signal<bool>,
content: impl Fn() -> P + 'static,
) -> Modified<Self>
fn popover<P: View>( self, shown: &Signal<bool>, content: impl Fn() -> P + 'static, ) -> Modified<Self>
Source§fn popover_on<P: View>(
self,
edge: Edge,
shown: &Signal<bool>,
content: impl Fn() -> P + 'static,
) -> Modified<Self>
fn popover_on<P: View>( self, edge: Edge, shown: &Signal<bool>, content: impl Fn() -> P + 'static, ) -> Modified<Self>
popover on a given side of the view.Source§fn accessibility_label(self, label: impl IntoValue<String>) -> Modified<Self>
fn accessibility_label(self, label: impl IntoValue<String>) -> Modified<Self>
text("Name:"), an icon button). A
closure keeps it current (move || format!("{} unread", n.get())).Source§fn background(self, color: impl IntoValue<Color>) -> Modified<Self>
fn background(self, color: impl IntoValue<Color>) -> Modified<Self>
corner_radius and shadow, a
card. Color::QuaternaryFill is the system’s grouped-card colour.
A closure computes it from signals (a selected row, a status); it
changes smoothly inside animated.Source§fn corner_radius(self, points: f64) -> Modified<Self>
fn corner_radius(self, points: f64) -> Modified<Self>
Source§fn border(self, color: Color, width: f64) -> Modified<Self>
fn border(self, color: Color, width: f64) -> Modified<Self>
width points wide around the view (inside its padding).Source§fn shadow(self, shadow: Shadow) -> Modified<Self>
fn shadow(self, shadow: Shadow) -> Modified<Self>
Source§fn opacity(self, opacity: impl IntoValue<f64>) -> Modified<Self>
fn opacity(self, opacity: impl IntoValue<f64>) -> Modified<Self>
opacity (0 transparent, 1 opaque), all of it, or a
closure computing it from signals; it fades inside
animated.Source§fn font(self, font: Font) -> Modified<Self>
fn font(self, font: Font) -> Modified<Self>
Source§fn color(self, color: impl IntoValue<Color>) -> Modified<Self>
fn color(self, color: impl IntoValue<Color>) -> Modified<Self>
Source§fn accessibility_value(self, value: impl IntoValue<String>) -> Modified<Self>
fn accessibility_value(self, value: impl IntoValue<String>) -> Modified<Self>
Source§fn material(self, material: Material) -> Modified<Self>
fn material(self, material: Material) -> Modified<Self>
corner_radius rounds it.Source§fn glass(self, glass: Glass) -> Modified<Self>
fn glass(self, glass: Glass) -> Modified<Self>
corner_radius
rounds it.Source§fn transition(self, transition: Transition) -> Modified<Self>
fn transition(self, transition: Transition) -> Modified<Self>
Source§fn matched_geometry(self, id: &str) -> Modified<Self>
fn matched_geometry(self, id: &str) -> Modified<Self>
matchedGeometryEffect): when, in one
animated change, a view with this id goes
and another with it comes (a thumbnail replaced by its detail, a
selection marker moving), the new one starts where and as large as
the old one was, and moves to its place.Source§fn on_hover(self, action: impl Fn(bool) + 'static) -> Modified<Self>
fn on_hover(self, action: impl Fn(bool) + 'static) -> Modified<Self>
action with true when the pointer moves over the view and
false when it leaves (while the app is active).Source§fn hover_highlight(self, color: Color) -> Modified<Self>
fn hover_highlight(self, color: Color) -> Modified<Self>
color while the pointer is over the view, fading
in and out: for rows and cards that can be clicked.Source§fn tooltip(self, text: impl IntoValue<String>) -> Modified<Self>
fn tooltip(self, text: impl IntoValue<String>) -> Modified<Self>
text appears in a small box when the pointer rests on
the view (SwiftUI’s help). VoiceOver reads it as the view’s help. A
closure keeps it current.when() is true, following the signals it
reads: its native views stay built (no rebuild, the state inside
kept) but aren’t shown, and it takes no room in its stack, as if it
weren’t there. For a panel shown in one mode only, rather than a
dynamic that rebuilds it each time. VoiceOver and Tab skip it.