From 69f4d33fa20a3e42d8e4bf85ebe1d307cc433b3f Mon Sep 17 00:00:00 2001 From: aiongg Date: Mon, 16 Nov 2026 22:58:25 +0000 Subject: [PATCH] Canvas: its surface paints in the paint step, under the picture slot The canvas surface came from ContainerProps, which the body paints into a slot reserved when its content starts, after the canvas reserved its picture slot in the paint step: the surface covered every picture shown with RasterDisplay::picture. The surface is the canvas style's own, painted before the slot, so the picture lies on the surface, under the canvas veil and every canvas control of the body; the body's children see the same surface. --- crates/ui-canvas/src/canvas/mod.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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