diff --git a/crates/draw/src/ui/artboard/stories.rs b/crates/draw/src/ui/artboard/stories.rs index 6cac751e1..9525e29ac 100644 --- a/crates/draw/src/ui/artboard/stories.rs +++ b/crates/draw/src/ui/artboard/stories.rs @@ -127,8 +127,8 @@ impl Boards { let page = |(index, item): (usize, &ArtboardItem)| { let page = PageFrame::new(item.rect.abs()).name(item.name.clone()).active(self.selected.contains(&index)); match item.background { - ArtboardBackground::White => page.fill(DataColor(Color32::WHITE)), - ArtboardBackground::Black => page.fill(DataColor(Color32::BLACK)), + ArtboardBackground::White => page.fill(DataColor(Color32::WHITE)), // design: allow[raw-colour/const](the artboard background is document data) + ArtboardBackground::Black => page.fill(DataColor(Color32::BLACK)), // design: allow[raw-colour/const](the artboard background is document data) ArtboardBackground::Custom(color) => page.fill(DataColor(Color32::from(color))), _ => page, } diff --git a/crates/draw/src/ui/brush_presets/picker.rs b/crates/draw/src/ui/brush_presets/picker.rs index d1e1e2ca5..dbd6fe5b3 100644 --- a/crates/draw/src/ui/brush_presets/picker.rs +++ b/crates/draw/src/ui/brush_presets/picker.rs @@ -324,7 +324,7 @@ impl<'a, K: Value + Eq + Hash> BrushPresetPicker<'a, K> { let next_search = Cell::new(before.search); let tool_picks: RefCell>> = RefCell::new(Vec::new()); let (mut diameter, mut hardness, mut tip) = (EditEvents::new(), EditEvents::new(), EditEvents::new()); - let browser_id = ui.make_persistent_id("browser"); + let browser_id = ui.scope_id().with("browser"); let has_app_rows = gear_rows.is_some(); let head = |ui: &mut Ui, _: &mut BodyCx<'_>| { Row::new().show(ui, |ui, _| { diff --git a/crates/imaging/src/ui/select/stories.rs b/crates/imaging/src/ui/select/stories.rs index 638f14668..79fd5e7c2 100644 --- a/crates/imaging/src/ui/select/stories.rs +++ b/crates/imaging/src/ui/select/stories.rs @@ -256,7 +256,7 @@ impl PictureEdges { fn normal(&self, p: Point) -> Vec2 { let d = |dx: f64, dy: f64| self.image.subject_distance(p.x + dx, p.y + dy); let g = Vec2::new(d(1.0, 0.0) - d(-1.0, 0.0), d(0.0, 1.0) - d(0.0, -1.0)); - if g.hypot() > 0.0 { g / g.hypot() } else { Vec2::new(0.0, -1.0) } + if g.hypot() > 0.0 { g / g.hypot() } else { Vec2::from((0.0, -1.0)) } } /// The point of the outline nearest `p`; `None` beyond the search's width or where the edge is weaker than its diff --git a/crates/layers/src/ui/filter/mod.rs b/crates/layers/src/ui/filter/mod.rs index c2abf9e28..09566dff0 100644 --- a/crates/layers/src/ui/filter/mod.rs +++ b/crates/layers/src/ui/filter/mod.rs @@ -669,7 +669,7 @@ impl<'a> LayerFilterBar<'a> { pub fn show(self, ui: &mut Ui) -> LayerFilterOutput { let Self { mut filter, blend_modes, focus_name, types: offered } = self; if offered.is_empty() { - return LayerFilterOutput { response: ui.allocate_response(egui::Vec2::ZERO, egui::Sense::hover()), changed: false, edit: None }; + return LayerFilterOutput { response: Row::new().show(ui, |_, _| {}).output, changed: false, edit: None }; } let words = Env::of(ui).words::(); let mut edit = None; diff --git a/crates/layers/src/ui/panel/drag.rs b/crates/layers/src/ui/panel/drag.rs index 694c4c247..4b41cfc73 100644 --- a/crates/layers/src/ui/panel/drag.rs +++ b/crates/layers/src/ui/panel/drag.rs @@ -208,11 +208,11 @@ pub(super) fn clip_cursor(tree: &T, above: &LayerRowKey, be return None; } let icon = if tree.info(upper).clipped { "clip_release" } else { "clip_below" }; - Some(Cursor::Painted(PaintedCursor::tool(IconId::new(icon), CLIP_HOTSPOT, None))) + Some(Cursor::Painted(PaintedCursor::tool(IconId::new(icon), egui::Vec2::from(CLIP_HOTSPOT), None))) } /// The tip of the clip cursors' arrow in their 24-unit icon box. -const CLIP_HOTSPOT: egui::Vec2 = egui::Vec2::new(15.0, 16.0); +const CLIP_HOTSPOT: [f32; 2] = [15.0, 16.0]; /// The reorder event of the list as the panel reports it: one `Set` per drop. pub(super) fn drop_event( diff --git a/crates/layers/src/ui/panel/mod.rs b/crates/layers/src/ui/panel/mod.rs index 2e51583a9..0d3826523 100644 --- a/crates/layers/src/ui/panel/mod.rs +++ b/crates/layers/src/ui/panel/mod.rs @@ -179,6 +179,7 @@ pub struct LayersPanel<'a, T: LayerTree> { /// What a reveal ([`LayersPanel::reveal`]) does with the closed groups that hold the layer. #[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[non_exhaustive] pub enum Groups { /// They open ([`LayersEvent::Open`]) and the layer's own row scrolls into view. Open, diff --git a/crates/menu/src/shortcuts/view/table.rs b/crates/menu/src/shortcuts/view/table.rs index 3c0c87c1f..0f29e53bb 100644 --- a/crates/menu/src/shortcuts/view/table.rs +++ b/crates/menu/src/shortcuts/view/table.rs @@ -726,6 +726,7 @@ impl ChordChip { ChordChip { common: Common::new(), chord, pressed: false } } + #[cfg(feature = "screen-testing")] fn sample() -> Self { ChordChip::new("Ctrl+S".to_owned()).label("Save, Ctrl+S") } diff --git a/crates/review/src/ui/comments/row.rs b/crates/review/src/ui/comments/row.rs index 8ad9d88d5..bc8bcbc8f 100644 --- a/crates/review/src/ui/comments/row.rs +++ b/crates/review/src/ui/comments/row.rs @@ -127,7 +127,7 @@ trait Sink { pub(super) const MORE: PartKey = PartKey::new("more"); /// A card or a heading of the card collection. -#[derive(craft_ui::contract::Component)] +#[derive(craft_ui::contract::Component, craft_ui::contract::Props)] pub(crate) struct CommentRow<'r> { #[common] common: Common, @@ -138,7 +138,8 @@ pub(crate) struct CommentRow<'r> { now: i64, editing: Option<(usize, &'r str)>, reply: &'r str, - /// The activation key reached the card this pass: the reply box takes the focus. + /// The activation key reached the card this pass: its reply box takes the focus, when it shows one. + #[prop] focus_reply: bool, words: Option>, /// The heights the editor field and the reply field measured, for the paint of the same pass. @@ -190,12 +191,6 @@ impl<'r> CommentRow<'r> { self } - /// The activation key reached the card this pass: its reply box takes the focus, when it shows one. - pub(crate) fn focus_reply(mut self, on: bool) -> Self { - self.focus_reply = on; - self - } - /// The message being edited and its draft, and the reply draft. pub(crate) fn drafts(mut self, editing: Option<(usize, &'r str)>, reply: &'r str) -> Self { self.editing = editing; diff --git a/crates/timeline/src/ui/preview.rs b/crates/timeline/src/ui/preview.rs index f5c858f33..1cdf4c617 100644 --- a/crates/timeline/src/ui/preview.rs +++ b/crates/timeline/src/ui/preview.rs @@ -117,7 +117,7 @@ impl Component for FramePreview { let strip = line.map_or(0.0, |line| line.y); let area = Rect::from_min_max(rect.min, pos2(rect.max.x, (rect.max.y - strip).max(rect.min.y))); // The bars belong to the picture, as in a video player, so they are black in every theme. - ui.draw().data_fill(&PaintShape::Rect(area, CornerRadius::ZERO), DataColor::new(Color32::BLACK)); + ui.draw().data_fill(&PaintShape::Rect(area, CornerRadius::ZERO), DataColor::new(Color32::BLACK)); // design: allow[raw-colour/const](the picture's bars are black in every theme) let (target, uv) = frame_rect(area, size, self.fit); ui.content_painter(cx).picture(texture, target, uv, 0.0); if let (Some(run), Some(line)) = (run, line) { diff --git a/crates/timeline/src/ui/transport.rs b/crates/timeline/src/ui/transport.rs index 7710931ca..b8c8a457d 100644 --- a/crates/timeline/src/ui/transport.rs +++ b/crates/timeline/src/ui/transport.rs @@ -378,7 +378,7 @@ impl MediaControls { let mut slider = Slider::new(Bind::given(position), range).step(NUDGE).sizing(Sizing::FillWidth).enabled(playable).label(words.seek.clone()); if let Some((start, end)) = trim.filter(|_| playable) { - slider = slider.trim(start, end); + slider = slider.trim(start..=end); } let edit = slider.show(ui); seek = edit.events; diff --git a/crates/ui-canvas/src/canvas/mod.rs b/crates/ui-canvas/src/canvas/mod.rs index 994795ec9..b25bbb60c 100644 --- a/crates/ui-canvas/src/canvas/mod.rs +++ b/crates/ui-canvas/src/canvas/mod.rs @@ -187,7 +187,11 @@ pub struct Canvas<'a> { context_key: bool, /// The ease the app asked for from the view it drew ([`ease_from`](Self::ease_from)). ease: Option, - /// The app's tool moves the view with the pointer this pass ([`view_follows_pointer`](Self::view_follows_pointer)). + /// The app's tool moves the view with the pointer this pass (an image-moving crop slides the view by fractional + /// pointer distances under a frame that stays put): the shown view stays as given, not [`pixel_aligned`], so the + /// picture and the frame do not jitter by part of a pixel as the pointer moves. P-15: the tool host passes the + /// framework `CropTool`'s image mode. + #[prop(name = "view_follows_pointer")] follows_pointer: bool, } @@ -272,16 +276,6 @@ impl<'a> Canvas<'a> { self } - /// The app's tool moves the view with the pointer this pass (an image-moving crop slides the view by fractional - /// pointer distances under a frame that stays put): the shown view stays as given, not [`pixel_aligned`], so the - /// picture and the frame do not jitter by part of a pixel as the pointer moves. P-15: the tool host passes the - /// framework `CropTool`'s image mode. - #[must_use] - pub fn view_follows_pointer(mut self, follows: bool) -> Self { - self.follows_pointer = follows; - self - } - /// Leaves the view commands to the instance around the canvas that owns its view (a full-window dialog's): the /// canvas is no instance of them, so the chords reach that instance while the canvas has the focus. #[must_use] diff --git a/crates/ui-canvas/src/canvas/tools.rs b/crates/ui-canvas/src/canvas/tools.rs index 2f02c3010..26a30df5a 100644 --- a/crates/ui-canvas/src/canvas/tools.rs +++ b/crates/ui-canvas/src/canvas/tools.rs @@ -23,10 +23,10 @@ const ROTATE_STEP_DEG: f64 = 15.0; /// The room Fit Artboard on Screen leaves around the board, in points: at the sides, and above and below (the board's /// name sits above it). -const ARTBOARD_MARGIN: Vec2 = Vec2::new(30.0, 40.0); +const ARTBOARD_MARGIN: Vec2 = Vec2::new(30.0, 40.0); // design: allow[literal-size/vec2](view-fit room in screen points, not a look) /// The room Fit Layers on Screen leaves around the layers' bounds, in points. -const LAYERS_MARGIN: Vec2 = Vec2::new(20.0, 20.0); +const LAYERS_MARGIN: Vec2 = Vec2::new(20.0, 20.0); // design: allow[literal-size/vec2](view-fit room in screen points, not a look) /// Photoshop's default Screen Resolution (Preferences, Units & Rulers), in pixels per inch. const SCREEN_PPI: f64 = 72.0; diff --git a/crates/ui-canvas/src/canvas_controls/brush/stories.rs b/crates/ui-canvas/src/canvas_controls/brush/stories.rs index 2ebba918e..39bfb2ec9 100644 --- a/crates/ui-canvas/src/canvas_controls/brush/stories.rs +++ b/crates/ui-canvas/src/canvas_controls/brush/stories.rs @@ -124,7 +124,7 @@ fn tip_of(tip: StoryTip, dimensions: BrushDimensions, pointer: Option) -> let normal = (edge.core() + edge.reach()) / 2.0; match tip { StoryTip::Round => (BrushTip::round(dimensions.diameter, normal), TipPose::upright()), - StoryTip::ThinEllipse => (BrushTip::round(dimensions.diameter, normal), TipPose::new(Vec2::new(1.0, 0.0), Vec2::new(0.0, THIN))), + StoryTip::ThinEllipse => (BrushTip::round(dimensions.diameter, normal), TipPose::new(Vec2::from((1.0, 0.0)), Vec2::from((0.0, THIN)))), StoryTip::Star => { let share = (normal / full.max(f64::EPSILON)) as f32; let scaled = diff --git a/crates/ui-contract/src/contract/body/hooks.rs b/crates/ui-contract/src/contract/body/hooks.rs index d550ce2e1..9107da3c0 100644 --- a/crates/ui-contract/src/contract/body/hooks.rs +++ b/crates/ui-contract/src/contract/body/hooks.rs @@ -833,7 +833,7 @@ impl ShapeHooks for BodyHooks<'_> { let body_env = line_env.derive_local(|scoped| { let label_width = label_extra.x; self.scope_body(scoped, &props, id, BodyScope { room, real, sizing, content_column, scroll, label_width, beside: regions.beside }); - scoped.inside_label = inside; + scoped.inside_label = inside.map(|inside| inside as crate::runtime::env::Held); scoped.cell_fills = cell_fills; // A scrolling body shows its first child wherever the view is: the container has no first line there. scoped.first_line = (!real && scroll.is_none()).then_some(first_body); diff --git a/crates/ui-contract/src/contract/collection/columns.rs b/crates/ui-contract/src/contract/collection/columns.rs index 4293265d6..722974b55 100644 --- a/crates/ui-contract/src/contract/collection/columns.rs +++ b/crates/ui-contract/src/contract/collection/columns.rs @@ -1,5 +1,6 @@ //! A collection's columns: kinds, specs, alignment, toggle columns and the sort. +pub use crate::runtime::env::ColumnAlign; use crate::runtime::env::Label; use craft_behavior::{ColumnKey, ColumnWidth}; use craft_keymap::Chord; @@ -84,16 +85,6 @@ pub struct ColumnSpec { pub hideable: bool, } -/// Where a column's content sits. -#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] -pub enum ColumnAlign { - /// At the start edge. - #[default] - Start, - /// At the end edge. - End, -} - impl ColumnSpec { /// A content column with a header and a width; the other settings off. pub fn new(key: ColumnKey, header: impl Into