mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 02:09:00 +00:00
ui-contract: port types meet upstream's memo and replay bounds (ShownFact, ScrubDrags, ZoomScheme); one public keymap
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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<CommandRef> {
|
||||
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<Arc<craft_keymap::Keymap>> {
|
||||
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 });
|
||||
|
||||
+1
-1
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user