diff --git a/crates/ui-contract/src/contract/memo.rs b/crates/ui-contract/src/contract/memo.rs index 2f4bd1e89..6343c0099 100644 --- a/crates/ui-contract/src/contract/memo.rs +++ b/crates/ui-contract/src/contract/memo.rs @@ -1006,6 +1006,27 @@ impl MemoProps for craft_behavior::canvas::CanvasView { } } +/// Every field (`#[non_exhaustive]`, so a field added later is listed here by hand): the rungs, the greatest zoom, the +/// least zoom and the device zoom of 100 %. +impl MemoProps for craft_behavior::ZoomScheme { + fn key(&self, key: &mut MemoKey) { + self.rungs.key(key); + self.max.key(key); + match self.floor { + craft_behavior::ZoomFloor::ShorterSide(side) => { + key.write_u32(0); + side.key(key); + } + craft_behavior::ZoomFloor::Fixed(zoom) => { + key.write_u32(1); + zoom.key(key); + } + other => format!("{other:?}").key(key), + } + self.hundred.key(key); + } +} + /// The width and the height. impl MemoProps for craft_behavior::kurbo::Size { fn key(&self, key: &mut MemoKey) { diff --git a/crates/ui-contract/src/runtime/commands/mod.rs b/crates/ui-contract/src/runtime/commands/mod.rs index 978ba4254..2374d4cef 100644 --- a/crates/ui-contract/src/runtime/commands/mod.rs +++ b/crates/ui-contract/src/runtime/commands/mod.rs @@ -43,6 +43,7 @@ use crate::runtime::egui::{areas, pass}; use crate::runtime::env::Label; use crate::runtime::memory::Facts; use crate::runtime::overlay; +use crate::runtime::{RecordShift, Shift}; use craft_behavior::CommandFlags; use craft_behavior::edit_history::Step; use craft_keymap::{Chord, Overrides}; @@ -623,14 +624,8 @@ pub fn holder(ctx: &Context, chord: &Chord) -> Option { board::holder(ctx, chord) } -/// The runtime's keymap: the linked sets and the app catalog on the window's platform, under the overrides, with the -/// system chords reserved. `None` before the first frame. -pub fn keymap(ctx: &Context) -> Option> { - board::keymap(ctx) -} - /// A command shown at `rect` in `layer`, as a pass registered it. -#[derive(Clone)] +#[derive(Clone, Debug, PartialEq)] struct ShownFact { command: CommandRef, layer: egui::LayerId, @@ -639,6 +634,17 @@ struct ShownFact { holder: bool, } +/// A replay moves the rect; the rest stays. +impl Shift for ShownFact { + fn shifted(&self, by: &RecordShift) -> Self { + ShownFact { rect: self.rect.shifted(by), ..self.clone() } + } + + fn snapped(&self, to: &Self, within: f32) -> Self { + ShownFact { rect: self.rect.snapped(&to.rect, within), ..self.clone() } + } +} + /// Registers `command` as shown for the next pass of the running viewport. fn register_shown(ctx: &Context, layer: egui::LayerId, rect: egui::Rect, label: Label, command: &CommandRef, holder: bool) { Facts::register(ctx, ShownFact { command: command.clone(), layer, rect, label, holder }); diff --git a/crates/ui-contract/src/runtime/env/scrub.rs b/crates/ui-contract/src/runtime/env/scrub.rs index aa5914ce1..f64eac2c4 100644 --- a/crates/ui-contract/src/runtime/env/scrub.rs +++ b/crates/ui-contract/src/runtime/env/scrub.rs @@ -3,7 +3,7 @@ use super::EnvValue; /// Which drags scrub a value, an `AppValues` env value. -#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, crate::contract::MemoProps)] #[non_exhaustive] pub enum ScrubDrags { /// The body of a field not in edit and a scrubbing side label scrub.