diff --git a/crates/ui-canvas/src/canvas/mod.rs b/crates/ui-canvas/src/canvas/mod.rs index 3ce105967..eab223a6e 100644 --- a/crates/ui-canvas/src/canvas/mod.rs +++ b/crates/ui-canvas/src/canvas/mod.rs @@ -108,7 +108,7 @@ use crate::runtime::focus::KeyUse; use crate::runtime::lock_keys; use crate::runtime::measure; use crate::runtime::motion::{Animate as _, spec}; -use crate::style::{ComponentStyle, StyleCx, SurfaceKind}; +use crate::style::{ComponentStyle, Stateful, StyleCx, SurfaceKind, SurfaceLook}; use craft_behavior::geometry::crop::normalized_angle; use craft_behavior::kurbo::{Point, Rect as DocRect, Size}; use craft_behavior::{ @@ -136,10 +136,14 @@ pub enum ToolPath { Freehand(&'static str), } -/// The style of a canvas: its surface comes from `ContainerProps`. +/// The style of a canvas. #[derive(Clone, Debug, Default, PartialEq, ComponentStyle)] #[non_exhaustive] pub struct CanvasStyle { + /// The canvas surface. It paints in the paint step, before the canvas reserves its picture slot, so the picture + /// lies on the surface and under every canvas control of the body. + #[style(surface)] + surface: Option, #[style(metrics)] metrics: Metrics, /// How far the rulers' strips push the view's rect in from the canvas's top-left corner, while they show. @@ -229,7 +233,7 @@ impl<'a> Canvas<'a> { /// A canvas named `label`. The keyboard path of its tool is the tool's own /// ([`CanvasTool::command_form`]). pub fn new(label: impl Into