Add forced whole-pixel snapping
Gitea/canvas-pilot/pipeline/head This commit looks good
Details
Gitea/canvas-pilot/pipeline/head This commit looks good
Details
This commit is contained in:
parent
a15bf92d7f
commit
cfbcfb0883
|
|
@ -602,7 +602,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "canvas-pilot"
|
||||
version = "0.10.8"
|
||||
version = "0.10.9"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"craft-dwg",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ default-members = ["crates/canvas-pilot"]
|
|||
resolver = "3"
|
||||
|
||||
[workspace.package]
|
||||
version = "0.10.8"
|
||||
version = "0.10.9"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
repository = "https://proxy.dandaedre.com/gitea/idle-org/canvas-pilot"
|
||||
|
|
|
|||
|
|
@ -50,7 +50,9 @@
|
|||
"ui.rows": "Rows",
|
||||
"ui.equal-divisions-of-the-output-visibility-and-snapping-are-independent": "Equal divisions of the output. Visibility and snapping are independent.",
|
||||
"ui.includes-contact-between-mirrored-opposite-resizing-layers": "Includes contact between mirrored/opposite resizing layers.",
|
||||
"ui.alt-invert-snapping-shift-10-px-ctrl-shift-100-px": "Alt: invert snapping · Shift: 10 px · Ctrl+Shift: 100 px",
|
||||
"ui.snapping-modifiers-help": "Alt: invert snapping · Shift: 10 px · Ctrl+Shift: 100 px · Shift+Space: force whole pixels",
|
||||
"ui.force-snapping-to-whole-pixels": "Force snapping to whole pixels",
|
||||
"ui.force-whole-pixels-help": "Always snap moved positions and resized edges to integer pixels. Ratio-locked resizing may slightly approximate the ratio.",
|
||||
"ui.snapping": "Snapping",
|
||||
"ui.example-backdrop-title-saved-in-project": "Example backdrop title (saved in project)",
|
||||
"ui.updates-immediately-leave-blank-to-hide-the-title": "Updates immediately. Leave blank to hide the title.",
|
||||
|
|
|
|||
|
|
@ -50,7 +50,9 @@
|
|||
"ui.rows": "Vicoj",
|
||||
"ui.equal-divisions-of-the-output-visibility-and-snapping-are-independent": "Egalaj dividoj de la eligo. Videbleco kaj algluiĝo estas sendependaj.",
|
||||
"ui.includes-contact-between-mirrored-opposite-resizing-layers": "Inkluzivas kontakton inter spegule aŭ kontraŭe regrandigataj tavoloj.",
|
||||
"ui.alt-invert-snapping-shift-10-px-ctrl-shift-100-px": "Alt: inversigi algluiĝon · Shift: 10 px · Ctrl+Shift: 100 px",
|
||||
"ui.snapping-modifiers-help": "Alt: invert snapping · Shift: 10 px · Ctrl+Shift: 100 px · Shift+Space: force whole pixels",
|
||||
"ui.force-snapping-to-whole-pixels": "Force snapping to whole pixels",
|
||||
"ui.force-whole-pixels-help": "Always snap moved positions and resized edges to integer pixels. Ratio-locked resizing may slightly approximate the ratio.",
|
||||
"ui.snapping": "Algluiĝo",
|
||||
"ui.example-backdrop-title-saved-in-project": "Titolo de ekzempla fono (konservita en projekto)",
|
||||
"ui.updates-immediately-leave-blank-to-hide-the-title": "Ĝisdatigas tuj. Lasu malplena por kaŝi la titolon.",
|
||||
|
|
|
|||
|
|
@ -50,7 +50,9 @@
|
|||
"ui.rows": "Filas",
|
||||
"ui.equal-divisions-of-the-output-visibility-and-snapping-are-independent": "Divisiones iguales de la salida. Visibilidad y ajuste son independientes.",
|
||||
"ui.includes-contact-between-mirrored-opposite-resizing-layers": "Incluye el contacto entre capas redimensionadas en espejo o en sentido opuesto.",
|
||||
"ui.alt-invert-snapping-shift-10-px-ctrl-shift-100-px": "Alt: invertir ajuste · Mayús: 10 px · Ctrl+Mayús: 100 px",
|
||||
"ui.snapping-modifiers-help": "Alt: invert snapping · Shift: 10 px · Ctrl+Shift: 100 px · Shift+Space: force whole pixels",
|
||||
"ui.force-snapping-to-whole-pixels": "Force snapping to whole pixels",
|
||||
"ui.force-whole-pixels-help": "Always snap moved positions and resized edges to integer pixels. Ratio-locked resizing may slightly approximate the ratio.",
|
||||
"ui.snapping": "Ajuste magnético",
|
||||
"ui.example-backdrop-title-saved-in-project": "Título del fondo de ejemplo (guardado en el proyecto)",
|
||||
"ui.updates-immediately-leave-blank-to-hide-the-title": "Se actualiza al instante. Déjelo vacío para ocultar el título.",
|
||||
|
|
|
|||
|
|
@ -50,7 +50,9 @@
|
|||
"ui.rows": "Lignes",
|
||||
"ui.equal-divisions-of-the-output-visibility-and-snapping-are-independent": "Divisions égales de la sortie. Visibilité et aimantation sont indépendantes.",
|
||||
"ui.includes-contact-between-mirrored-opposite-resizing-layers": "Inclut le contact entre les calques redimensionnés en miroir ou en opposition.",
|
||||
"ui.alt-invert-snapping-shift-10-px-ctrl-shift-100-px": "Alt : inverser l’aimantation · Maj : 10 px · Ctrl+Maj : 100 px",
|
||||
"ui.snapping-modifiers-help": "Alt: invert snapping · Shift: 10 px · Ctrl+Shift: 100 px · Shift+Space: force whole pixels",
|
||||
"ui.force-snapping-to-whole-pixels": "Force snapping to whole pixels",
|
||||
"ui.force-whole-pixels-help": "Always snap moved positions and resized edges to integer pixels. Ratio-locked resizing may slightly approximate the ratio.",
|
||||
"ui.snapping": "Aimantation",
|
||||
"ui.example-backdrop-title-saved-in-project": "Titre du fond d’exemple (enregistré dans le projet)",
|
||||
"ui.updates-immediately-leave-blank-to-hide-the-title": "Mise à jour immédiate. Laissez vide pour masquer le titre.",
|
||||
|
|
|
|||
|
|
@ -50,7 +50,9 @@
|
|||
"ui.rows": "Στίχοι",
|
||||
"ui.equal-divisions-of-the-output-visibility-and-snapping-are-independent": "Ἴσαι διαιρέσεις τῆς ἐξόδου. Ὁρατότης καὶ πρόσφυσις χωρισταί εἰσιν.",
|
||||
"ui.includes-contact-between-mirrored-opposite-resizing-layers": "Περιέχει καὶ τὴν ἐπαφὴν στρωμάτων κατοπτρικῶς ἢ ἐναντίως μεταβαλλομένων.",
|
||||
"ui.alt-invert-snapping-shift-10-px-ctrl-shift-100-px": "Alt: ἀντιστροφὴ προσφύσεως · Shift: 10 px · Ctrl+Shift: 100 px",
|
||||
"ui.snapping-modifiers-help": "Alt: invert snapping · Shift: 10 px · Ctrl+Shift: 100 px · Shift+Space: force whole pixels",
|
||||
"ui.force-snapping-to-whole-pixels": "Force snapping to whole pixels",
|
||||
"ui.force-whole-pixels-help": "Always snap moved positions and resized edges to integer pixels. Ratio-locked resizing may slightly approximate the ratio.",
|
||||
"ui.snapping": "Πρόσφυσις",
|
||||
"ui.example-backdrop-title-saved-in-project": "Τίτλος ὑποδείγματος βάθους (ἐν τῷ σχεδίῳ σῴζεται)",
|
||||
"ui.updates-immediately-leave-blank-to-hide-the-title": "Εὐθὺς μεταβάλλεται. Κενὸν ἔα ἵνα ὁ τίτλος κρύπτηται.",
|
||||
|
|
|
|||
|
|
@ -50,7 +50,9 @@
|
|||
"ui.rows": "पंक्तियाँ",
|
||||
"ui.equal-divisions-of-the-output-visibility-and-snapping-are-independent": "आउटपुट के बराबर भाग। दृश्यता और स्नैपिंग स्वतंत्र हैं।",
|
||||
"ui.includes-contact-between-mirrored-opposite-resizing-layers": "Includes contact between mirrored/opposite resizing layers.",
|
||||
"ui.alt-invert-snapping-shift-10-px-ctrl-shift-100-px": "Alt: invert snapping · Shift: 10 px · Ctrl+Shift: 100 px",
|
||||
"ui.snapping-modifiers-help": "Alt: invert snapping · Shift: 10 px · Ctrl+Shift: 100 px · Shift+Space: force whole pixels",
|
||||
"ui.force-snapping-to-whole-pixels": "Force snapping to whole pixels",
|
||||
"ui.force-whole-pixels-help": "Always snap moved positions and resized edges to integer pixels. Ratio-locked resizing may slightly approximate the ratio.",
|
||||
"ui.snapping": "स्नैपिंग",
|
||||
"ui.example-backdrop-title-saved-in-project": "उदाहरण पृष्ठभूमि शीर्षक (परियोजना में सहेजा जाता है)",
|
||||
"ui.updates-immediately-leave-blank-to-hide-the-title": "तुरंत अपडेट होता है। शीर्षक छिपाने के लिए खाली छोड़ें।",
|
||||
|
|
|
|||
|
|
@ -50,7 +50,9 @@
|
|||
"ui.rows": "行",
|
||||
"ui.equal-divisions-of-the-output-visibility-and-snapping-are-independent": "出力を等分します。表示とスナップは独立しています。",
|
||||
"ui.includes-contact-between-mirrored-opposite-resizing-layers": "対称・逆方向にサイズ変更するレイヤー同士の接触も含みます。",
|
||||
"ui.alt-invert-snapping-shift-10-px-ctrl-shift-100-px": "Alt:スナップ反転 · Shift:10 px · Ctrl+Shift:100 px",
|
||||
"ui.snapping-modifiers-help": "Alt: invert snapping · Shift: 10 px · Ctrl+Shift: 100 px · Shift+Space: force whole pixels",
|
||||
"ui.force-snapping-to-whole-pixels": "Force snapping to whole pixels",
|
||||
"ui.force-whole-pixels-help": "Always snap moved positions and resized edges to integer pixels. Ratio-locked resizing may slightly approximate the ratio.",
|
||||
"ui.snapping": "スナップ",
|
||||
"ui.example-backdrop-title-saved-in-project": "背景サンプルのタイトル(プロジェクトに保存)",
|
||||
"ui.updates-immediately-leave-blank-to-hide-the-title": "すぐに反映されます。空欄でタイトルを非表示にします。",
|
||||
|
|
|
|||
|
|
@ -50,7 +50,9 @@
|
|||
"ui.rows": "पङ्क्तिहरू",
|
||||
"ui.equal-divisions-of-the-output-visibility-and-snapping-are-independent": "आउटपुटका बराबर भागहरू। दृश्यता र स्न्यापिङ स्वतन्त्र छन्।",
|
||||
"ui.includes-contact-between-mirrored-opposite-resizing-layers": "Includes contact between mirrored/opposite resizing layers.",
|
||||
"ui.alt-invert-snapping-shift-10-px-ctrl-shift-100-px": "Alt: invert snapping · Shift: 10 px · Ctrl+Shift: 100 px",
|
||||
"ui.snapping-modifiers-help": "Alt: invert snapping · Shift: 10 px · Ctrl+Shift: 100 px · Shift+Space: force whole pixels",
|
||||
"ui.force-snapping-to-whole-pixels": "Force snapping to whole pixels",
|
||||
"ui.force-whole-pixels-help": "Always snap moved positions and resized edges to integer pixels. Ratio-locked resizing may slightly approximate the ratio.",
|
||||
"ui.snapping": "स्न्यापिङ",
|
||||
"ui.example-backdrop-title-saved-in-project": "उदाहरण पृष्ठभूमिको शीर्षक (परियोजनामा सेभ हुन्छ)",
|
||||
"ui.updates-immediately-leave-blank-to-hide-the-title": "तुरुन्त अद्यावधिक हुन्छ। शीर्षक लुकाउन खाली छोड्नुहोस्।",
|
||||
|
|
|
|||
|
|
@ -50,7 +50,9 @@
|
|||
"ui.rows": "Linhas",
|
||||
"ui.equal-divisions-of-the-output-visibility-and-snapping-are-independent": "Divisões iguais da saída. Visibilidade e encaixe são independentes.",
|
||||
"ui.includes-contact-between-mirrored-opposite-resizing-layers": "Includes contact between mirrored/opposite resizing layers.",
|
||||
"ui.alt-invert-snapping-shift-10-px-ctrl-shift-100-px": "Alt: invert snapping · Shift: 10 px · Ctrl+Shift: 100 px",
|
||||
"ui.snapping-modifiers-help": "Alt: invert snapping · Shift: 10 px · Ctrl+Shift: 100 px · Shift+Space: force whole pixels",
|
||||
"ui.force-snapping-to-whole-pixels": "Force snapping to whole pixels",
|
||||
"ui.force-whole-pixels-help": "Always snap moved positions and resized edges to integer pixels. Ratio-locked resizing may slightly approximate the ratio.",
|
||||
"ui.snapping": "Encaixe",
|
||||
"ui.example-backdrop-title-saved-in-project": "Título do fundo de exemplo (guardado no projeto)",
|
||||
"ui.updates-immediately-leave-blank-to-hide-the-title": "Atualiza de imediato. Deixe vazio para ocultar o título.",
|
||||
|
|
|
|||
|
|
@ -50,7 +50,9 @@
|
|||
"ui.rows": "แถว",
|
||||
"ui.equal-divisions-of-the-output-visibility-and-snapping-are-independent": "แบ่งเอาต์พุตเท่า ๆ กัน การมองเห็นและการดูดตำแหน่งแยกจากกัน",
|
||||
"ui.includes-contact-between-mirrored-opposite-resizing-layers": "Includes contact between mirrored/opposite resizing layers.",
|
||||
"ui.alt-invert-snapping-shift-10-px-ctrl-shift-100-px": "Alt: invert snapping · Shift: 10 px · Ctrl+Shift: 100 px",
|
||||
"ui.snapping-modifiers-help": "Alt: invert snapping · Shift: 10 px · Ctrl+Shift: 100 px · Shift+Space: force whole pixels",
|
||||
"ui.force-snapping-to-whole-pixels": "Force snapping to whole pixels",
|
||||
"ui.force-whole-pixels-help": "Always snap moved positions and resized edges to integer pixels. Ratio-locked resizing may slightly approximate the ratio.",
|
||||
"ui.snapping": "การดูดเข้าตำแหน่ง",
|
||||
"ui.example-backdrop-title-saved-in-project": "ชื่อพื้นหลังตัวอย่าง (บันทึกในโครงการ)",
|
||||
"ui.updates-immediately-leave-blank-to-hide-the-title": "อัปเดตทันที เว้นว่างเพื่อซ่อนชื่อ",
|
||||
|
|
|
|||
|
|
@ -50,7 +50,9 @@
|
|||
"ui.rows": "kulupu supa",
|
||||
"ui.equal-divisions-of-the-output-visibility-and-snapping-are-independent": "kipisi sama pi sitelen tawa. lukin en awen lon linja li wan ala.",
|
||||
"ui.includes-contact-between-mirrored-opposite-resizing-layers": "Includes contact between mirrored/opposite resizing layers.",
|
||||
"ui.alt-invert-snapping-shift-10-px-ctrl-shift-100-px": "Alt: invert snapping · Shift: 10 px · Ctrl+Shift: 100 px",
|
||||
"ui.snapping-modifiers-help": "Alt: invert snapping · Shift: 10 px · Ctrl+Shift: 100 px · Shift+Space: force whole pixels",
|
||||
"ui.force-snapping-to-whole-pixels": "Force snapping to whole pixels",
|
||||
"ui.force-whole-pixels-help": "Always snap moved positions and resized edges to integer pixels. Ratio-locked resizing may slightly approximate the ratio.",
|
||||
"ui.snapping": "awen lon linja",
|
||||
"ui.example-backdrop-title-saved-in-project": "nimi pi sitelen monsi (awen lon pali)",
|
||||
"ui.updates-immediately-leave-blank-to-hide-the-title": "ona li sin lon tenpo ni. nimi ala la nimi li len.",
|
||||
|
|
|
|||
|
|
@ -50,7 +50,9 @@
|
|||
"ui.rows": "行",
|
||||
"ui.equal-divisions-of-the-output-visibility-and-snapping-are-independent": "等分输出区域。显示与吸附互不影响。",
|
||||
"ui.includes-contact-between-mirrored-opposite-resizing-layers": "也包括镜像或反向缩放图层之间的接触。",
|
||||
"ui.alt-invert-snapping-shift-10-px-ctrl-shift-100-px": "Alt:反转吸附 · Shift:10 px · Ctrl+Shift:100 px",
|
||||
"ui.snapping-modifiers-help": "Alt: invert snapping · Shift: 10 px · Ctrl+Shift: 100 px · Shift+Space: force whole pixels",
|
||||
"ui.force-snapping-to-whole-pixels": "Force snapping to whole pixels",
|
||||
"ui.force-whole-pixels-help": "Always snap moved positions and resized edges to integer pixels. Ratio-locked resizing may slightly approximate the ratio.",
|
||||
"ui.snapping": "吸附",
|
||||
"ui.example-backdrop-title-saved-in-project": "示例背景标题(保存在项目中)",
|
||||
"ui.updates-immediately-leave-blank-to-hide-the-title": "立即更新。留空可隐藏标题。",
|
||||
|
|
|
|||
|
|
@ -2849,9 +2849,13 @@ impl Editor {
|
|||
point: [f64; 2],
|
||||
modifiers: egui::Modifiers,
|
||||
scale: f32,
|
||||
force_pixels: bool,
|
||||
) {
|
||||
let mut options = self.snapping;
|
||||
if modifiers.alt {
|
||||
if force_pixels {
|
||||
options.enabled = true;
|
||||
options.force_pixels = true;
|
||||
} else if modifiers.alt {
|
||||
options.enabled = !options.enabled;
|
||||
}
|
||||
let (target, guides) = self.layout.snap_pivot(
|
||||
|
|
@ -2939,10 +2943,17 @@ impl Editor {
|
|||
point: [f64; 2],
|
||||
modifiers: egui::Modifiers,
|
||||
scale: f32,
|
||||
force_pixels: bool,
|
||||
) -> [Option<f64>; 2] {
|
||||
self.layout
|
||||
.use_resize_pivot(self.effective_pivot(modifiers));
|
||||
if let Some(spacing) = self.effective_grid(modifiers) {
|
||||
if force_pixels {
|
||||
let mut snapping = self.snapping;
|
||||
snapping.enabled = true;
|
||||
snapping.force_pixels = true;
|
||||
self.layout
|
||||
.drag_to_snapped(point, snapping, 6.0 / scale as f64)
|
||||
} else if let Some(spacing) = self.effective_grid(modifiers) {
|
||||
self.layout.drag_to_grid(point, spacing as f64)
|
||||
} else {
|
||||
let mut snapping = self.snapping;
|
||||
|
|
@ -3390,8 +3401,11 @@ impl Editor {
|
|||
let mut origin = area.center() - Vec2::new(sw / 2.0, sh / 2.0) * scale + self.pan * scale;
|
||||
let response = ui.interact(area, egui::Id::new("canvas"), egui::Sense::click_and_drag());
|
||||
let pointer = ui.input(|i| i.pointer.interact_pos());
|
||||
let force_pixels =
|
||||
ui.input(|i| i.key_down(egui::Key::Space) && i.modifiers.shift && !i.modifiers.alt);
|
||||
let temporary_pan = ui.input(|i| {
|
||||
i.key_down(egui::Key::Space) || i.pointer.button_down(egui::PointerButton::Middle)
|
||||
(i.key_down(egui::Key::Space) && !i.modifiers.shift)
|
||||
|| i.pointer.button_down(egui::PointerButton::Middle)
|
||||
});
|
||||
let edit_pointer = self.navigation_tool == NavigationTool::Select && !temporary_pan;
|
||||
let move_pointer = self.navigation_tool == NavigationTool::Move && !temporary_pan;
|
||||
|
|
@ -3606,12 +3620,13 @@ impl Editor {
|
|||
let p = (p - origin) / scale;
|
||||
let point = [p.x as f64, p.y as f64];
|
||||
if let Some(i) = self.pivot_drag.as_ref().map(|(i, _)| *i) {
|
||||
self.move_pivot_snapped(i, point, modifiers, scale);
|
||||
self.move_pivot_snapped(i, point, modifiers, scale, force_pixels);
|
||||
} else if let Some(m) = self.marquee.as_mut() {
|
||||
m.end = point;
|
||||
self.layout.select_region(m.start, point, &m.base);
|
||||
} else {
|
||||
self.snap_guides = self.drag_with_modifiers(point, modifiers, scale);
|
||||
self.snap_guides =
|
||||
self.drag_with_modifiers(point, modifiers, scale, force_pixels);
|
||||
}
|
||||
self.sync();
|
||||
}
|
||||
|
|
@ -3623,12 +3638,13 @@ impl Editor {
|
|||
let p = (p - origin) / scale;
|
||||
let point = [p.x as f64, p.y as f64];
|
||||
if let Some(i) = self.pivot_drag.as_ref().map(|(i, _)| *i) {
|
||||
self.move_pivot_snapped(i, point, modifiers, scale);
|
||||
self.move_pivot_snapped(i, point, modifiers, scale, force_pixels);
|
||||
} else if let Some(m) = self.marquee.as_mut() {
|
||||
m.end = point;
|
||||
self.layout.select_region(m.start, point, &m.base);
|
||||
} else {
|
||||
self.snap_guides = self.drag_with_modifiers(point, modifiers, scale);
|
||||
self.snap_guides =
|
||||
self.drag_with_modifiers(point, modifiers, scale, force_pixels);
|
||||
}
|
||||
self.sync();
|
||||
}
|
||||
|
|
@ -5381,11 +5397,11 @@ mod tests {
|
|||
app.layout.set_selection([true; 2]);
|
||||
app.sync();
|
||||
let before = app.layout.layers().clone();
|
||||
app.move_pivot_snapped(0, [122.0, 361.0], egui::Modifiers::NONE, 1.0);
|
||||
app.move_pivot_snapped(0, [122.0, 361.0], egui::Modifiers::NONE, 1.0, false);
|
||||
assert_eq!(app.pivot_for(0), [0.0, 0.5]);
|
||||
assert_eq!(app.pivot_for(1), [1.0, 0.5]);
|
||||
assert_eq!(app.snap_guides, [Some(120.0), Some(360.0)]);
|
||||
app.move_pivot_snapped(0, [833.0, 653.0], egui::Modifiers::NONE, 1.0);
|
||||
app.move_pivot_snapped(0, [833.0, 653.0], egui::Modifiers::NONE, 1.0, false);
|
||||
assert_eq!(app.snap_guides, [Some(800.0), Some(700.0)]);
|
||||
app.move_pivot_snapped(
|
||||
0,
|
||||
|
|
@ -5396,6 +5412,7 @@ mod tests {
|
|||
..Default::default()
|
||||
},
|
||||
1.0,
|
||||
false,
|
||||
);
|
||||
assert_eq!(app.snap_guides, [None; 2]);
|
||||
app.snapping.enabled = true;
|
||||
|
|
@ -5407,6 +5424,7 @@ mod tests {
|
|||
..Default::default()
|
||||
},
|
||||
1.0,
|
||||
false,
|
||||
);
|
||||
assert_eq!(app.snap_guides, [None; 2]);
|
||||
assert_ne!(app.pivot_for(0), [0.0, 0.5]);
|
||||
|
|
@ -6112,7 +6130,8 @@ mod tests {
|
|||
original.x + original.width * 0.25,
|
||||
original.y + original.height * 0.75,
|
||||
];
|
||||
let guides = app.drag_with_modifiers([1837.0, 360.0], egui::Modifiers::NONE, 1.0);
|
||||
let guides =
|
||||
app.drag_with_modifiers([1837.0, 360.0], egui::Modifiers::NONE, 1.0, false);
|
||||
let target = (1837.0 / spacing as f64).round() * spacing as f64;
|
||||
assert_eq!(guides[0], Some(target));
|
||||
let g = app.layout.layers()[1];
|
||||
|
|
@ -6126,9 +6145,9 @@ mod tests {
|
|||
ctrl: spacing == 100,
|
||||
..Default::default()
|
||||
};
|
||||
app.drag_with_modifiers([1173.0, 217.0], modifiers, 1.0);
|
||||
app.drag_with_modifiers([1173.0, 217.0], modifiers, 1.0, false);
|
||||
assert_eq!(app.layout.layers()[1].x, 1173.0);
|
||||
app.drag_with_modifiers([1173.0, 217.0], egui::Modifiers::NONE, 1.0);
|
||||
app.drag_with_modifiers([1173.0, 217.0], egui::Modifiers::NONE, 1.0, false);
|
||||
assert_eq!(
|
||||
app.layout.layers()[1].x,
|
||||
(1173.0 / spacing as f64).round() * spacing as f64
|
||||
|
|
@ -6282,13 +6301,15 @@ mod tests {
|
|||
..Default::default()
|
||||
},
|
||||
0.75,
|
||||
false,
|
||||
);
|
||||
assert_eq!(guides[0], if enabled { None } else { Some(1920.0) });
|
||||
let g = app.layout.layers()[1];
|
||||
assert_eq!(g.x + g.width, if enabled { 1918.0 } else { 1920.0 });
|
||||
assert_eq!(app.snapping, saved);
|
||||
// Releasing Alt restores the stored setting without a pointer move.
|
||||
let guides = app.drag_with_modifiers(point, egui::Modifiers::NONE, 0.75);
|
||||
let guides =
|
||||
app.drag_with_modifiers(point, egui::Modifiers::NONE, 0.75, false);
|
||||
assert_eq!(guides[0], if enabled { Some(1920.0) } else { None });
|
||||
let g = app.layout.layers()[1];
|
||||
assert_eq!(g.x + g.width, if enabled { 1920.0 } else { 1918.0 });
|
||||
|
|
@ -6302,6 +6323,27 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shift_space_forces_pixels_instead_of_the_shift_grid() {
|
||||
let mut app = Editor::default();
|
||||
let saved = app.snapping;
|
||||
app.layout.start_drag([1160.0, 180.0]);
|
||||
app.drag_with_modifiers(
|
||||
[1163.6, 184.4],
|
||||
egui::Modifiers {
|
||||
shift: true,
|
||||
..Default::default()
|
||||
},
|
||||
1.0,
|
||||
true,
|
||||
);
|
||||
assert_eq!(
|
||||
[app.layout.layers()[1].x, app.layout.layers()[1].y],
|
||||
[1164.0, 184.0]
|
||||
);
|
||||
assert_eq!(app.snapping, saved);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn quick_and_context_snapping_menus_save_the_same_options_without_editing_layers() {
|
||||
for context in [false, true] {
|
||||
|
|
|
|||
|
|
@ -104,6 +104,14 @@ impl Editor {
|
|||
);
|
||||
ui.add_enabled_ui(self.snapping.enabled, |ui| {
|
||||
ui.checkbox(&mut self.snapping.pixels, tr(ui.ctx(), "ui.pixel-edges"));
|
||||
ui.checkbox(
|
||||
&mut self.snapping.force_pixels,
|
||||
tr(ui.ctx(), "ui.force-snapping-to-whole-pixels"),
|
||||
)
|
||||
.on_hover_text(tr(
|
||||
ui.ctx(),
|
||||
"ui.force-whole-pixels-help",
|
||||
));
|
||||
ui.checkbox(
|
||||
&mut self.snapping.screen_edges,
|
||||
tr(ui.ctx(), "ui.screen-edges-center-quarters"),
|
||||
|
|
@ -115,10 +123,7 @@ impl Editor {
|
|||
.on_hover_text("Snap moving outer borders and use other layers’ borders as targets. Independent of masks. Also controls mirrored/opposite resize contact; center and direct resize-handle snapping remain available.");
|
||||
ui.checkbox(&mut self.snapping.mask_edges, tr(ui.ctx(), "ui.mask-edges"));
|
||||
});
|
||||
ui.weak(tr(
|
||||
ui.ctx(),
|
||||
"ui.alt-invert-snapping-shift-10-px-ctrl-shift-100-px",
|
||||
));
|
||||
ui.weak(tr(ui.ctx(), "ui.snapping-modifiers-help"));
|
||||
}
|
||||
pub(super) fn snapping_menu(&mut self, ui: &mut egui::Ui) {
|
||||
ui.menu_button(tr(ui.ctx(), "ui.snapping"), |ui| {
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ impl Project {
|
|||
folders: layout.folders.clone(),
|
||||
workspace: Workspace::default(),
|
||||
format: FORMAT.into(),
|
||||
version: 21,
|
||||
version: 22,
|
||||
next_layer_id: layout.next_id,
|
||||
output_resolution: layout.formats.output.into(),
|
||||
inputs: (0..layout.formats.sources.len())
|
||||
|
|
@ -231,9 +231,9 @@ impl Project {
|
|||
}
|
||||
/// Build a fresh document only after validating the entire file. No history is restored.
|
||||
pub fn layout(&self) -> Result<Layout, String> {
|
||||
if self.format != FORMAT || self.version != 21 {
|
||||
if self.format != FORMAT || self.version != 22 {
|
||||
return Err(
|
||||
"Unsupported project format/version; expected beffroi.midra-layout version 21."
|
||||
"Unsupported project format/version; expected beffroi.midra-layout version 22."
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
|
|
@ -429,8 +429,8 @@ impl Project {
|
|||
}
|
||||
let header: Header =
|
||||
serde_json::from_str(text).map_err(|e| format!("Invalid project JSON: {e}"))?;
|
||||
if !(1..=21).contains(&header.version) {
|
||||
return Err("Unsupported project version; expected versions 1–21.".into());
|
||||
if !(1..=22).contains(&header.version) {
|
||||
return Err("Unsupported project version; expected versions 1–22.".into());
|
||||
}
|
||||
let mut migrated: serde_json::Value = if header.version == 1 || header.version == 2 {
|
||||
let mut value: serde_json::Value =
|
||||
|
|
@ -746,6 +746,16 @@ impl Project {
|
|||
}
|
||||
migrated["version"] = 21.into();
|
||||
}
|
||||
if header.version <= 21 {
|
||||
let snapping = migrated["workspace"]["snapping"]
|
||||
.as_object_mut()
|
||||
.ok_or("Missing snapping")?;
|
||||
if header.version >= 11 && snapping.contains_key("force_pixels") {
|
||||
return Err("Unexpected force_pixels in old project.".into());
|
||||
}
|
||||
snapping.insert("force_pixels".into(), false.into());
|
||||
migrated["version"] = 22.into();
|
||||
}
|
||||
let p: Self =
|
||||
serde_json::from_value(migrated).map_err(|e| format!("Invalid project JSON: {e}"))?;
|
||||
p.layout()?;
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ pub fn from_json(text: &str) -> Result<LoadedProject, String> {
|
|||
}
|
||||
let version = raw["version"]
|
||||
.as_u64()
|
||||
.filter(|v| (1..=21).contains(v))
|
||||
.ok_or("Unsupported project version; expected versions 1–21.")?;
|
||||
.filter(|v| (1..=22).contains(v))
|
||||
.ok_or("Unsupported project version; expected versions 1–22.")?;
|
||||
let mut warnings = Vec::new();
|
||||
if let Some(proposals) = raw.as_object_mut().unwrap().remove("input_proposals") {
|
||||
if proposals != serde_json::json!([]) {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ pub struct Settings {
|
|||
impl Default for Settings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
version: 15,
|
||||
version: 16,
|
||||
ui_scale: 1.0,
|
||||
text_scale: None,
|
||||
language: Default::default(),
|
||||
|
|
@ -74,7 +74,13 @@ impl Settings {
|
|||
}
|
||||
value["snapping"] = serde_json::to_value(canvas_pilot::snapping::Snapping::default())
|
||||
.map_err(|e| e.to_string())?;
|
||||
for field in ["grid", "show_grid", "grid_divisions", "mask_edges"] {
|
||||
for field in [
|
||||
"grid",
|
||||
"show_grid",
|
||||
"grid_divisions",
|
||||
"mask_edges",
|
||||
"force_pixels",
|
||||
] {
|
||||
value["snapping"].as_object_mut().unwrap().remove(field);
|
||||
}
|
||||
value["version"] = 3.into();
|
||||
|
|
@ -181,18 +187,28 @@ impl Settings {
|
|||
snapping.insert("mask_edges".into(), false.into());
|
||||
value["version"] = 14.into();
|
||||
}
|
||||
if matches!(value["version"].as_u64(), Some(14 | 15)) && value.get("text_scale").is_none() {
|
||||
if matches!(value["version"].as_u64(), Some(14..=16)) && value.get("text_scale").is_none() {
|
||||
return Err("Missing text_scale in current settings".into());
|
||||
}
|
||||
if value["version"] == 14 {
|
||||
value["version"] = 15.into();
|
||||
}
|
||||
if value["version"] == 15 {
|
||||
let snapping = value["snapping"]
|
||||
.as_object_mut()
|
||||
.ok_or("Missing snapping")?;
|
||||
if snapping.contains_key("force_pixels") {
|
||||
return Err("Unexpected force_pixels in old settings".into());
|
||||
}
|
||||
snapping.insert("force_pixels".into(), false.into());
|
||||
value["version"] = 16.into();
|
||||
}
|
||||
let settings: Self = serde_json::from_value(value).map_err(|e| e.to_string())?;
|
||||
settings.validate()?;
|
||||
Ok(settings)
|
||||
}
|
||||
fn validate(&self) -> Result<(), String> {
|
||||
if self.version != 15 {
|
||||
if self.version != 16 {
|
||||
return Err(format!("unsupported settings version {}", self.version));
|
||||
}
|
||||
for theme in std::iter::once(&self.theme).chain(&self.recent_themes) {
|
||||
|
|
@ -346,7 +362,7 @@ mod tests {
|
|||
let legacy =
|
||||
include_str!("../../../docs/interfaces/canvas-pilot-settings-v14.example.json");
|
||||
let current =
|
||||
include_str!("../../../docs/interfaces/canvas-pilot-settings-v15.example.json");
|
||||
include_str!("../../../docs/interfaces/canvas-pilot-settings-v16.example.json");
|
||||
assert_eq!(
|
||||
Settings::parse(legacy).unwrap(),
|
||||
Settings::parse(current).unwrap()
|
||||
|
|
@ -359,7 +375,7 @@ mod tests {
|
|||
assert_eq!(serde_json::to_value(saved).unwrap(), value);
|
||||
value["version"] = 14.into();
|
||||
assert!(Settings::parse(&value.to_string()).is_err());
|
||||
value["version"] = 15.into();
|
||||
value["version"] = 16.into();
|
||||
for id in ["", "no-slash", "../theme", "pack/a/b", "pack/Upper"] {
|
||||
value["theme"] = serde_json::json!({"pack":id});
|
||||
value["recent_themes"][0] = value["theme"].clone();
|
||||
|
|
@ -372,7 +388,7 @@ mod tests {
|
|||
let legacy =
|
||||
include_str!("../../../docs/interfaces/canvas-pilot-settings-v13.example.json");
|
||||
let current =
|
||||
include_str!("../../../docs/interfaces/canvas-pilot-settings-v15.example.json");
|
||||
include_str!("../../../docs/interfaces/canvas-pilot-settings-v16.example.json");
|
||||
assert_eq!(
|
||||
Settings::parse(legacy).unwrap(),
|
||||
Settings::parse(current).unwrap()
|
||||
|
|
@ -392,6 +408,28 @@ mod tests {
|
|||
assert!(Settings::parse(&value.to_string()).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn forced_pixel_snapping_migrates_disabled_and_round_trips() {
|
||||
let legacy =
|
||||
include_str!("../../../docs/interfaces/canvas-pilot-settings-v15.example.json");
|
||||
let current =
|
||||
include_str!("../../../docs/interfaces/canvas-pilot-settings-v16.example.json");
|
||||
assert_eq!(
|
||||
Settings::parse(legacy).unwrap(),
|
||||
Settings::parse(current).unwrap()
|
||||
);
|
||||
let mut value: serde_json::Value = serde_json::from_str(current).unwrap();
|
||||
value["snapping"]["force_pixels"] = true.into();
|
||||
assert!(
|
||||
Settings::parse(&value.to_string())
|
||||
.unwrap()
|
||||
.snapping
|
||||
.force_pixels
|
||||
);
|
||||
value["version"] = 15.into();
|
||||
assert!(Settings::parse(&value.to_string()).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn scaling_migrates_and_round_trips_with_strict_limits() {
|
||||
let old = include_str!("../../../docs/interfaces/canvas-pilot-settings-v10.example.json");
|
||||
|
|
@ -461,7 +499,7 @@ mod tests {
|
|||
let old = include_str!("../../../docs/interfaces/canvas-pilot-settings-v8.example.json");
|
||||
let migrated = Settings::parse(old).unwrap();
|
||||
assert_eq!(migrated.language, Language::System);
|
||||
assert_eq!(migrated.version, 15);
|
||||
assert_eq!(migrated.version, 16);
|
||||
let current =
|
||||
include_str!("../../../docs/interfaces/canvas-pilot-settings-v10.example.json");
|
||||
assert_eq!(Settings::parse(current).unwrap(), migrated);
|
||||
|
|
@ -470,13 +508,14 @@ mod tests {
|
|||
let mut old: serde_json::Value = serde_json::from_str(v9).unwrap();
|
||||
old["language"] = old_language.into();
|
||||
let upgraded = Settings::parse(&old.to_string()).unwrap();
|
||||
assert_eq!(upgraded.version, 15);
|
||||
assert_eq!(upgraded.version, 16);
|
||||
assert_eq!(
|
||||
serde_json::to_value(&upgraded.language).unwrap(),
|
||||
old["language"]
|
||||
);
|
||||
old["version"] = 15.into();
|
||||
old["version"] = 16.into();
|
||||
old["snapping"]["mask_edges"] = false.into();
|
||||
old["snapping"]["force_pixels"] = false.into();
|
||||
old["ui_scale"] = serde_json::json!(1.0);
|
||||
old["text_scale"] = serde_json::Value::Null;
|
||||
assert_eq!(serde_json::to_value(upgraded).unwrap(), old);
|
||||
|
|
@ -518,8 +557,9 @@ mod tests {
|
|||
assert!(Settings::parse(&value.to_string()).is_err());
|
||||
value["version"] = 13.into();
|
||||
let saved = Settings::parse(&value.to_string()).unwrap();
|
||||
value["version"] = 15.into();
|
||||
value["version"] = 16.into();
|
||||
value["snapping"]["mask_edges"] = false.into();
|
||||
value["snapping"]["force_pixels"] = false.into();
|
||||
assert_eq!(serde_json::to_value(saved).unwrap(), value);
|
||||
for id in ["", "../uk", "uk_UA"] {
|
||||
value["language"] = serde_json::json!({"pack":id});
|
||||
|
|
@ -554,8 +594,9 @@ mod tests {
|
|||
value["ui_scale"] = 1.5.into();
|
||||
value["text_scale"] = 1.25.into();
|
||||
let saved = Settings::parse(&value.to_string()).unwrap();
|
||||
value["version"] = 15.into();
|
||||
value["version"] = 16.into();
|
||||
value["snapping"]["mask_edges"] = false.into();
|
||||
value["snapping"]["force_pixels"] = false.into();
|
||||
assert_eq!(serde_json::to_value(saved).unwrap(), value);
|
||||
}
|
||||
}
|
||||
|
|
@ -628,7 +669,7 @@ mod tests {
|
|||
for text in [
|
||||
"broken".to_string(),
|
||||
serde_json::to_string(&Settings {
|
||||
version: 16,
|
||||
version: 17,
|
||||
..Default::default()
|
||||
})
|
||||
.unwrap(),
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ fn pixel_magnet(value: f64) -> Option<f64> {
|
|||
pub struct Snapping {
|
||||
pub enabled: bool,
|
||||
pub pixels: bool,
|
||||
pub force_pixels: bool,
|
||||
pub screen_edges: bool,
|
||||
pub layer_edges: bool,
|
||||
pub mask_edges: bool,
|
||||
|
|
@ -27,6 +28,7 @@ impl Default for Snapping {
|
|||
Self {
|
||||
enabled: false,
|
||||
pixels: true,
|
||||
force_pixels: false,
|
||||
screen_edges: true,
|
||||
layer_edges: true,
|
||||
mask_edges: false,
|
||||
|
|
@ -151,6 +153,9 @@ impl Layout {
|
|||
if !options.enabled {
|
||||
return (point, [None; 2]);
|
||||
}
|
||||
if options.force_pixels {
|
||||
return (point.map(f64::round), [None; 2]);
|
||||
}
|
||||
let mut target = point;
|
||||
let mut guides = [None; 2];
|
||||
for axis in 0..2 {
|
||||
|
|
@ -216,6 +221,13 @@ impl Layout {
|
|||
}
|
||||
};
|
||||
for axis in 0..2 {
|
||||
if options.force_pixels {
|
||||
if let Some(i) = selected.iter().position(|v| *v) {
|
||||
let coordinate = edge(before.layers[i], axis)[0] + delta[axis];
|
||||
delta[axis] += coordinate.round() - coordinate;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let mut targets = Vec::new();
|
||||
if options.screen_edges {
|
||||
targets.extend(screen_guides(self.formats.output[axis]));
|
||||
|
|
@ -417,18 +429,22 @@ impl Layout {
|
|||
}
|
||||
}
|
||||
}
|
||||
if let Some(target) = targets
|
||||
.into_iter()
|
||||
.filter(|t| (*t - current[axis]).abs() <= tolerance)
|
||||
.min_by(|a, b| {
|
||||
(a - current[axis])
|
||||
.abs()
|
||||
.total_cmp(&(b - current[axis]).abs())
|
||||
})
|
||||
if !options.force_pixels
|
||||
&& let Some(target) = targets
|
||||
.into_iter()
|
||||
.filter(|t| (*t - current[axis]).abs() <= tolerance)
|
||||
.min_by(|a, b| {
|
||||
(a - current[axis])
|
||||
.abs()
|
||||
.total_cmp(&(b - current[axis]).abs())
|
||||
})
|
||||
{
|
||||
candidates.push((1, (target - current[axis]).abs(), axis, target, None));
|
||||
}
|
||||
if options.layer_edges && matches!(r.mode, ResizeMode::Mirror | ResizeMode::Opposite) {
|
||||
if !options.force_pixels
|
||||
&& options.layer_edges
|
||||
&& matches!(r.mode, ResizeMode::Mirror | ResizeMode::Opposite)
|
||||
{
|
||||
let original = r.before.layers[r.index];
|
||||
let moving = handle_point(original)[axis];
|
||||
let anchor = r.anchor(r.index)[axis];
|
||||
|
|
@ -464,11 +480,12 @@ impl Layout {
|
|||
}
|
||||
}
|
||||
}
|
||||
if options.pixels {
|
||||
if options.pixels || options.force_pixels {
|
||||
let spacing = grid.unwrap_or(1.0);
|
||||
let target = (current[axis] / spacing).round() * spacing;
|
||||
if grid.is_some() || pixel_magnet(current[axis]).is_some() {
|
||||
candidates.push((2, (target - current[axis]).abs(), axis, target, None));
|
||||
if grid.is_some() || options.force_pixels || pixel_magnet(current[axis]).is_some() {
|
||||
let priority = if options.force_pixels { 0 } else { 2 };
|
||||
candidates.push((priority, (target - current[axis]).abs(), axis, target, None));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -517,6 +534,26 @@ impl Layout {
|
|||
&& touching
|
||||
&& (handle_point(self.layers[r.index])[axis] - target).abs() < 1e-6
|
||||
{
|
||||
if options.force_pixels {
|
||||
let mut rounded = self.layers.clone();
|
||||
for (i, geometry) in rounded.iter_mut().enumerate() {
|
||||
if !r.targets[i] {
|
||||
continue;
|
||||
}
|
||||
let right = (geometry.x + geometry.width).round();
|
||||
let bottom = (geometry.y + geometry.height).round();
|
||||
geometry.x = geometry.x.round();
|
||||
geometry.y = geometry.y.round();
|
||||
geometry.width = right - geometry.x;
|
||||
geometry.height = bottom - geometry.y;
|
||||
}
|
||||
if rounded.iter().all(|geometry| geometry.validate().is_ok()) {
|
||||
self.layers = rounded;
|
||||
} else {
|
||||
self.restore(base.clone());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
let mut guides = [None; 2];
|
||||
if priority < 2 || grid.is_some() {
|
||||
guides[axis] = Some(target);
|
||||
|
|
@ -556,4 +593,47 @@ mod tests {
|
|||
layout.drag_to_snapped([1800.4, 360.0], pixels_only(), 6.0);
|
||||
assert!((layout.layers()[1].x + layout.layers()[1].width - 1800.4).abs() < 1e-9);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn forced_pixels_round_moves_and_resize_handles_outside_the_soft_magnet() {
|
||||
let options = Snapping {
|
||||
enabled: true,
|
||||
force_pixels: true,
|
||||
screen_edges: false,
|
||||
layer_edges: false,
|
||||
..Default::default()
|
||||
};
|
||||
let mut layout = Layout::default();
|
||||
layout.start_drag([1160.0, 180.0]);
|
||||
layout.drag_to_snapped([1163.6, 184.4], options, 6.0);
|
||||
assert_eq!(
|
||||
[layout.layers()[1].x, layout.layers()[1].y],
|
||||
[1164.0, 184.0]
|
||||
);
|
||||
layout.finish_drag();
|
||||
|
||||
layout.start_handle_resize(1, ResizeHandle::Right, [1804.0, 364.0], false);
|
||||
layout.drag_to_snapped([1804.6, 364.0], options, 6.0);
|
||||
assert_eq!(layout.layers()[1].x + layout.layers()[1].width, 1805.0);
|
||||
|
||||
let mut ratio_layout = Layout::default();
|
||||
let original_ratio = ratio_layout.layers()[1].width / ratio_layout.layers()[1].height;
|
||||
ratio_layout.start_handle_resize(
|
||||
1,
|
||||
ResizeHandle::Corner(crate::Corner::BottomRight),
|
||||
[1800.0, 540.0],
|
||||
true,
|
||||
);
|
||||
ratio_layout.drag_to_snapped([1801.4, 540.8], options, 6.0);
|
||||
let resized = ratio_layout.layers()[1];
|
||||
for edge in [
|
||||
resized.x,
|
||||
resized.y,
|
||||
resized.x + resized.width,
|
||||
resized.y + resized.height,
|
||||
] {
|
||||
assert_eq!(edge.fract(), 0.0);
|
||||
}
|
||||
assert!((resized.width / resized.height - original_ratio).abs() > 1e-9);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ fn family_links_save_migrate_recover_and_validate() {
|
|||
let mut old: Value = serde_json::from_str(old).unwrap();
|
||||
old["layers"][0]["midra_link"] = json!({"screen":"001","layer":"02"});
|
||||
let p = Project::from_json(&old.to_string()).unwrap();
|
||||
assert_eq!(p.version, 21);
|
||||
assert_eq!(p.version, 22);
|
||||
assert_eq!(
|
||||
p.layers[0].load_mapping.as_ref().unwrap().family,
|
||||
Family::Midra4k
|
||||
|
|
@ -300,7 +300,7 @@ fn documented_v13_example_contains_native_aquilon_link() {
|
|||
"../../../docs/interfaces/canvas-pilot-v13.example.json"
|
||||
))
|
||||
.unwrap();
|
||||
assert_eq!(p.version, 21);
|
||||
assert_eq!(p.version, 22);
|
||||
let link = p.layers[0].load_mapping.as_ref().unwrap();
|
||||
assert_eq!(link.family, Family::Aquilon);
|
||||
assert_eq!(link.screen, "S1");
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ fn v18_migration_synchronizes_links_and_v19_requires_both_directions() {
|
|||
let project = canvas_pilot::project_recovery::from_json(old)
|
||||
.unwrap()
|
||||
.project;
|
||||
assert_eq!(project.version, 21);
|
||||
assert_eq!(project.version, 22);
|
||||
for layer in &project.layers {
|
||||
assert_eq!(
|
||||
layer.send_mapping,
|
||||
|
|
@ -64,7 +64,7 @@ fn v18_migration_synchronizes_links_and_v19_requires_both_directions() {
|
|||
assert_eq!(
|
||||
project,
|
||||
Project::from_json(include_str!(
|
||||
"../../../docs/interfaces/canvas-pilot-v21.example.json"
|
||||
"../../../docs/interfaces/canvas-pilot-v22.example.json"
|
||||
))
|
||||
.unwrap()
|
||||
);
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ fn explicit_empty_folders_survive_history_save_rename_and_membership_changes() {
|
|||
fn version_12_explicit_folder_validation_and_v11_migration() {
|
||||
let old = include_str!("../../../docs/interfaces/canvas-pilot-v11.example.json");
|
||||
let p = Project::from_json(old).unwrap();
|
||||
assert_eq!(p.version, 21);
|
||||
assert_eq!(p.version, 22);
|
||||
assert!(p.folders.is_empty());
|
||||
let example = include_str!("../../../docs/interfaces/canvas-pilot-v12.example.json");
|
||||
assert_eq!(
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ fn explicit_fit_survives_resize_undo_reordering_and_project_roundtrip() {
|
|||
layout.apply(0, box_geometry()).unwrap();
|
||||
assert_eq!(layout.formats().advanced[0], crop);
|
||||
let before = Project::from_layout(&layout);
|
||||
assert_eq!(before.version, 21);
|
||||
assert_eq!(before.version, 22);
|
||||
let loaded = Project::from_json(&before.to_json().unwrap()).unwrap();
|
||||
assert_eq!(loaded, before);
|
||||
assert_eq!(
|
||||
|
|
@ -107,7 +107,7 @@ fn explicit_fit_survives_resize_undo_reordering_and_project_roundtrip() {
|
|||
fn v13_migration_defaults_to_normal_crop_and_v14_requires_valid_fit() {
|
||||
let text = include_str!("../../../docs/interfaces/canvas-pilot-v13.example.json");
|
||||
let migrated = Project::from_json(text).unwrap();
|
||||
assert_eq!(migrated.version, 21);
|
||||
assert_eq!(migrated.version, 22);
|
||||
assert!(migrated.layers.iter().all(|l| l.layer_fit.is_none()));
|
||||
let mut json = serde_json::to_value(&migrated).unwrap();
|
||||
json["layers"][0]
|
||||
|
|
@ -125,7 +125,7 @@ fn current_documented_example_is_valid() {
|
|||
"../../../docs/interfaces/canvas-pilot-v14.example.json"
|
||||
))
|
||||
.unwrap();
|
||||
assert_eq!(p.version, 21);
|
||||
assert_eq!(p.version, 22);
|
||||
p.layout().unwrap();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ fn mask_schema_migration_validation_reorder_resize_and_atomic_import() {
|
|||
let migrated = canvas_pilot::project_recovery::from_json(old)
|
||||
.unwrap()
|
||||
.project;
|
||||
assert_eq!(migrated.version, 21);
|
||||
assert_eq!(migrated.version, 22);
|
||||
assert!(migrated.layers.iter().all(|l| l.mask == Mask::default()));
|
||||
let mut json = serde_json::to_value(&p).unwrap();
|
||||
json["layers"][0].as_object_mut().unwrap().remove("mask");
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ fn persistent_device_links_roundtrip_migrate_and_undo() {
|
|||
include_str!("../../../docs/interfaces/canvas-pilot-v5.example.json"),
|
||||
] {
|
||||
let p = Project::from_json(text).unwrap();
|
||||
assert_eq!(p.version, 21);
|
||||
assert_eq!(p.version, 22);
|
||||
assert!(p.layers.iter().all(|l| l.load_mapping.is_none()));
|
||||
}
|
||||
let mut value = serde_json::to_value(&project).unwrap();
|
||||
|
|
@ -304,7 +304,7 @@ fn position_point_schema_migrates_corners_and_rejects_mislabeled_files() {
|
|||
.unwrap();
|
||||
old["editor"]["position_corner"] = name.into();
|
||||
let loaded = Project::from_json(&old.to_string()).unwrap();
|
||||
assert_eq!(loaded.version, 21);
|
||||
assert_eq!(loaded.version, 22);
|
||||
assert_eq!(loaded.editor.position_point, expected);
|
||||
old["editor"]["position_corner"] = "center".into();
|
||||
assert!(Project::from_json(&old.to_string()).is_err());
|
||||
|
|
@ -313,7 +313,7 @@ fn position_point_schema_migrates_corners_and_rejects_mislabeled_files() {
|
|||
assert!(Project::from_json(&old.to_string()).is_err());
|
||||
}
|
||||
let value: serde_json::Value = serde_json::from_str(¤t.to_json().unwrap()).unwrap();
|
||||
for version in [0, 22] {
|
||||
for version in [0, 23] {
|
||||
let mut invalid = value.clone();
|
||||
invalid["version"] = version.into();
|
||||
assert!(
|
||||
|
|
@ -354,7 +354,7 @@ fn backdrop_title_roundtrips_and_older_projects_gain_the_default() {
|
|||
}
|
||||
let old = include_str!("../../../docs/interfaces/canvas-pilot-v6.example.json");
|
||||
let migrated = Project::from_json(old).unwrap();
|
||||
assert_eq!(migrated.version, 21);
|
||||
assert_eq!(migrated.version, 22);
|
||||
assert_eq!(migrated.editor.backdrop_title, DEFAULT_BACKDROP_TITLE);
|
||||
let mut invalid: serde_json::Value = serde_json::from_str(old).unwrap();
|
||||
invalid["editor"]["backdrop_title"] = "Unexpected".into();
|
||||
|
|
@ -425,7 +425,7 @@ fn saved_pivots_roundtrip_and_old_projects_default_to_center() {
|
|||
assert_eq!(loaded.layer_info(0).pivot, custom);
|
||||
assert_eq!(loaded.layer_info(1).pivot, [0.5; 2]);
|
||||
let example = include_str!("../../../docs/interfaces/canvas-pilot-v9.example.json");
|
||||
assert_eq!(Project::from_json(example).unwrap().version, 21);
|
||||
assert_eq!(Project::from_json(example).unwrap().version, 22);
|
||||
let old = include_str!("../../../docs/interfaces/canvas-pilot-v8.example.json");
|
||||
let migrated = Project::from_json(old).unwrap();
|
||||
assert!(migrated.layers.iter().all(|l| l.pivot == [0.5; 2]));
|
||||
|
|
@ -463,11 +463,11 @@ fn aspect_ratio_lock_is_per_layer_undoable_and_migrates_from_v20() {
|
|||
assert!(project.layers[1].keep_aspect_ratio);
|
||||
assert_eq!(
|
||||
Project::from_json(include_str!(
|
||||
"../../../docs/interfaces/canvas-pilot-v21.example.json"
|
||||
"../../../docs/interfaces/canvas-pilot-v22.example.json"
|
||||
))
|
||||
.unwrap()
|
||||
.version,
|
||||
21
|
||||
22
|
||||
);
|
||||
|
||||
let mut old: serde_json::Value = serde_json::from_str(include_str!(
|
||||
|
|
@ -486,6 +486,26 @@ fn aspect_ratio_lock_is_per_layer_undoable_and_migrates_from_v20() {
|
|||
assert!(Project::from_json(&missing.to_string()).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn forced_pixel_snapping_migrates_from_v21_and_is_strict() {
|
||||
let old = include_str!("../../../docs/interfaces/canvas-pilot-v21.example.json");
|
||||
let current = include_str!("../../../docs/interfaces/canvas-pilot-v22.example.json");
|
||||
assert_eq!(
|
||||
Project::from_json(old).unwrap(),
|
||||
Project::from_json(current).unwrap()
|
||||
);
|
||||
|
||||
let mut project = Project::from_json(current).unwrap();
|
||||
project.workspace.snapping.force_pixels = true;
|
||||
assert_eq!(
|
||||
Project::from_json(&project.to_json().unwrap()).unwrap(),
|
||||
project
|
||||
);
|
||||
let mut mislabeled = serde_json::to_value(project).unwrap();
|
||||
mislabeled["version"] = 21.into();
|
||||
assert!(Project::from_json(&mislabeled.to_string()).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reference_collection_migrates_single_images_and_rejects_mislabeled_or_oversized_collections() {
|
||||
use base64::{Engine, engine::general_purpose::STANDARD};
|
||||
|
|
@ -496,7 +516,7 @@ fn reference_collection_migrates_single_images_and_rejects_mislabeled_or_oversiz
|
|||
let reference = serde_json::json!({"name":"guide.png","image_base64":STANDARD.encode(b"image bytes"),"visible":false,"opacity":0.4,"preserve_ratio":true,"native_size":false,"offset":[0.0,0.0]});
|
||||
old["reference"] = reference.clone();
|
||||
let migrated = Project::from_json(&old.to_string()).unwrap();
|
||||
assert_eq!(migrated.version, 21);
|
||||
assert_eq!(migrated.version, 22);
|
||||
assert_eq!(migrated.references.len(), 1);
|
||||
assert!(!migrated.references[0].visible);
|
||||
assert_eq!(migrated.references[0].opacity, 0.4);
|
||||
|
|
@ -516,7 +536,7 @@ fn reference_collection_migrates_single_images_and_rejects_mislabeled_or_oversiz
|
|||
gallery.references = vec![migrated.references[0].clone(); 33];
|
||||
assert!(gallery.to_json().unwrap_err().contains("32 reference"));
|
||||
let example = include_str!("../../../docs/interfaces/canvas-pilot-v10.example.json");
|
||||
assert_eq!(Project::from_json(example).unwrap().version, 21);
|
||||
assert_eq!(Project::from_json(example).unwrap().version, 22);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ fn valid_project_round_trip_is_exact_without_warnings_or_retired_fields() {
|
|||
let loaded = from_json(&text).unwrap();
|
||||
assert!(loaded.warnings.is_empty());
|
||||
assert_eq!(loaded.project, project);
|
||||
assert_eq!(loaded.project.version, 21);
|
||||
assert_eq!(loaded.project.version, 22);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -143,6 +143,7 @@ fn resize_can_bypass_snapping_and_cancel() {
|
|||
let options = Snapping {
|
||||
enabled: true,
|
||||
pixels: false,
|
||||
force_pixels: false,
|
||||
screen_edges: true,
|
||||
layer_edges: false,
|
||||
..Default::default()
|
||||
|
|
@ -649,6 +650,7 @@ fn overlay_grid_snaps_moves_resizes_and_pivots_with_fractional_divisions() {
|
|||
let options = Snapping {
|
||||
enabled: true,
|
||||
pixels: false,
|
||||
force_pixels: false,
|
||||
screen_edges: false,
|
||||
layer_edges: true,
|
||||
grid: true,
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@
|
|||
|
||||
## Unreleased
|
||||
|
||||
### v0.10.9
|
||||
|
||||
- Add optional forced whole-pixel snapping for moves, resizes and pivots, with a
|
||||
temporary Shift+Space modifier. The existing soft pixel magnet remains the default.
|
||||
|
||||
### v0.10.8
|
||||
|
||||
- Remove inspector Copy/Paste buttons, including the multi-selection Copy button,
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ not a named project export. Headless/default editors never access this path.
|
|||
| Field | Meaning |
|
||||
| --- | --- |
|
||||
| `version` | Integer `1`; other versions rejected |
|
||||
| `project` | Complete [project v21](canvas-pilot.md), including embedded reference bytes; its units, precision and validation apply without display rounding |
|
||||
| `project` | Complete [project v22](canvas-pilot.md), including embedded reference bytes; its units, precision and validation apply without display rounding |
|
||||
| `project_path` | Last opened/successfully saved named JSON path, or null; geometry exports do not change it |
|
||||
| `manual_saved_at` | Unix UTC seconds of the last successful explicit project save, or null when unknown; recovery and measurement-point autosaves do not update it |
|
||||
|
||||
|
|
@ -34,7 +34,7 @@ last successful writer wins.
|
|||
Recovery retains applied values only: no undo history, pending text/format/import
|
||||
drafts, transient tools, or credentials. A normal exit cancels unfinished canvas
|
||||
gestures before the final checkpoint. The schema does not replace named project
|
||||
JSON: Save continues to emit a bare project v21 document. Opening/New replaces the
|
||||
JSON: Save continues to emit a bare project v22 document. Opening/New replaces the
|
||||
single recovery slot; New warns with the manual-save age and Save/Discard/Cancel.
|
||||
A failed or cancelled manual save never completes Save-and-create-new.
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"version": 16,
|
||||
"theme": "midra",
|
||||
"recent_themes": [
|
||||
"midra"
|
||||
],
|
||||
"show_toolbar_icon_names": false,
|
||||
"keep_aspect_ratio": true,
|
||||
"show_source_pattern": false,
|
||||
"snapping": {
|
||||
"enabled": false,
|
||||
"pixels": true,
|
||||
"force_pixels": false,
|
||||
"screen_edges": true,
|
||||
"layer_edges": true,
|
||||
"grid": false,
|
||||
"show_grid": true,
|
||||
"grid_divisions": [
|
||||
8,
|
||||
6
|
||||
],
|
||||
"mask_edges": false
|
||||
},
|
||||
"midra_host": "",
|
||||
"allow_sending_to_program": false,
|
||||
"autoconnect_at_startup": false,
|
||||
"recent_midra_hosts": [],
|
||||
"language": "system",
|
||||
"ui_scale": 1.0,
|
||||
"text_scale": null
|
||||
}
|
||||
|
|
@ -1,15 +1,15 @@
|
|||
# Canvas Pilot application settings, version 15
|
||||
# Canvas Pilot application settings, version 16
|
||||
|
||||
Canvas Pilot was formerly named Midra Layout. The rename preserves existing wire-format identifiers, `.midra.json` projects, settings/recovery locations and `MIDRA_VECTORCRAFT_CLI` configuration. No schema version changes are needed. New exports use Canvas Pilot in human-readable titles; legacy files remain readable.
|
||||
|
||||
Implementation: `crates/canvas-pilot/src/settings.rs`. This per-user JSON file is
|
||||
independent of the [project JSON and SVG contracts](canvas-pilot.md).
|
||||
[Complete default example](canvas-pilot-settings-v15.example.json).
|
||||
[Complete default example](canvas-pilot-settings-v16.example.json).
|
||||
Version 1 files migrate automatically: the saved theme becomes the only entry in
|
||||
`recent_themes`, with all other preferences preserved. The [version 1 example](canvas-pilot-settings-v1.example.json)
|
||||
remains a migration fixture. Version 2 files then migrate by adding disabled
|
||||
snapping with all target types enabled. The [version 2 example](canvas-pilot-settings-v2.example.json)
|
||||
remains a migration fixture too. Version 3 files migrate by adding an empty `midra_host`; the [version 3 example](canvas-pilot-settings-v3.example.json) remains a migration fixture. Version 4 files migrate by adding `allow_sending_to_program: false`; the [version 4 example](canvas-pilot-settings-v4.example.json) remains a migration fixture. Version 5 files migrate with `autoconnect_at_startup: false`; the [version 5 example](canvas-pilot-settings-v5.example.json) remains a migration fixture. Version 6 files migrate with the overlay grid visible, snapping to it disabled, and `grid_divisions: [8, 6]`; the [version 6 example](canvas-pilot-settings-v6.example.json) remains a migration fixture. Version 7 migrates with an empty `recent_midra_hosts` list; the [version 7 example](canvas-pilot-settings-v7.example.json) remains a migration fixture. Version 8 migrates with `language: "system"`; the [version 8 example](canvas-pilot-settings-v8.example.json) remains a migration fixture. Version 9 migrates without changing any preferences; its `system`, `en` and `fr` values remain valid. The [version 9 example](canvas-pilot-settings-v9.example.json) remains a migration fixture. Version 10 adds language choices. Version 11 adds `ui_scale` and `text_scale`; v1–v10 settings migrate to 100% interface scale with separate text scaling disabled, preserving all existing preferences. The [version 10 example](canvas-pilot-settings-v10.example.json) remains a migration fixture. Version 12 adds `pt-PT`, `ne`, `th`, `hi` and `tok`; v1–v11 settings migrate without changing existing preferences. Values outside each old version’s language set are rejected before migration. The [version 11 example](canvas-pilot-settings-v11.example.json) remains a migration fixture. Version 13 adds installed language choices; v12 preferences migrate unchanged. The [version 12 example](canvas-pilot-settings-v12.example.json) remains a fixture. Version 14 adds required `snapping.mask_edges` (false). Versions 1–13 migrate with mask snapping disabled; supplying the field under an older version is rejected. The [version 13 example](canvas-pilot-settings-v13.example.json) remains a migration fixture. Version 15 adds installed theme choices and migrates v1–v14 without changing other preferences. The [version 14 example](canvas-pilot-settings-v14.example.json) remains a migration fixture. Saving writes version 15, which older applications reject.
|
||||
remains a migration fixture too. Version 3 files migrate by adding an empty `midra_host`; the [version 3 example](canvas-pilot-settings-v3.example.json) remains a migration fixture. Version 4 files migrate by adding `allow_sending_to_program: false`; the [version 4 example](canvas-pilot-settings-v4.example.json) remains a migration fixture. Version 5 files migrate with `autoconnect_at_startup: false`; the [version 5 example](canvas-pilot-settings-v5.example.json) remains a migration fixture. Version 6 files migrate with the overlay grid visible, snapping to it disabled, and `grid_divisions: [8, 6]`; the [version 6 example](canvas-pilot-settings-v6.example.json) remains a migration fixture. Version 7 migrates with an empty `recent_midra_hosts` list; the [version 7 example](canvas-pilot-settings-v7.example.json) remains a migration fixture. Version 8 migrates with `language: "system"`; the [version 8 example](canvas-pilot-settings-v8.example.json) remains a migration fixture. Version 9 migrates without changing any preferences; its `system`, `en` and `fr` values remain valid. The [version 9 example](canvas-pilot-settings-v9.example.json) remains a migration fixture. Version 10 adds language choices. Version 11 adds `ui_scale` and `text_scale`; v1–v10 settings migrate to 100% interface scale with separate text scaling disabled, preserving all existing preferences. The [version 10 example](canvas-pilot-settings-v10.example.json) remains a migration fixture. Version 12 adds `pt-PT`, `ne`, `th`, `hi` and `tok`; v1–v11 settings migrate without changing existing preferences. Values outside each old version’s language set are rejected before migration. The [version 11 example](canvas-pilot-settings-v11.example.json) remains a migration fixture. Version 13 adds installed language choices; v12 preferences migrate unchanged. The [version 12 example](canvas-pilot-settings-v12.example.json) remains a fixture. Version 14 adds required `snapping.mask_edges` (false). Versions 1–13 migrate with mask snapping disabled; supplying the field under an older version is rejected. The [version 13 example](canvas-pilot-settings-v13.example.json) remains a migration fixture. Version 15 adds installed theme choices and migrates v1–v14 without changing other preferences. The [version 14 example](canvas-pilot-settings-v14.example.json) remains a migration fixture. Version 16 adds required `snapping.force_pixels` (false). Versions 1–15 migrate with forced whole-pixel snapping disabled; supplying the field under an older version is rejected. The [version 15 example](canvas-pilot-settings-v15.example.json) remains a migration fixture. Saving writes version 16, which older applications reject.
|
||||
|
||||
The `directories` 6 crate resolves `ProjectDirs::from("org", "beffroi", "midra-layout")`.
|
||||
The filename is `settings.json` beneath `config_dir()`:
|
||||
|
|
@ -26,7 +26,7 @@ unknown theme names are rejected. There are no numeric coordinates or units.
|
|||
|
||||
| Field | Values / default |
|
||||
| --- | --- |
|
||||
| `version` | Integer `15` |
|
||||
| `version` | Integer `16` |
|
||||
| `ui_scale` | Finite number, 0.5–4.0 inclusive; default 1.0. egui interface zoom relative to the OS display scale. |
|
||||
| `text_scale` | `null` (default, disabled) or finite number 0.5–2.0 inclusive. Additional standard-widget text multiplier. |
|
||||
| `language` | `"system"` (default), `"en"`, `"fr"`, `"ja"`, `"zh-CN"`, `"es"`, `"grc"`, `"eo"`, `"pt-PT"`, `"ne"`, `"th"`, `"hi"`, `"tok"`, or `{"pack":"uk"}` for an installed language. Pack identifiers use 1–63 lowercase ASCII letters, digits and hyphens, without a leading/trailing hyphen. Unknown built-in string values are rejected. |
|
||||
|
|
@ -38,7 +38,7 @@ unknown theme names are rejected. There are no numeric coordinates or units.
|
|||
| `show_toolbar_icon_names` | Boolean; default false |
|
||||
| `keep_aspect_ratio` | Legacy compatibility value; current projects store the required resize lock on each layer and new layers default to true |
|
||||
| `show_source_pattern` | Boolean; default false. Shows source patterns on other layers only during crop editing; normal editing always hides patterns. |
|
||||
| `snapping` | Object with required boolean fields `enabled` (false), `pixels` (true), `screen_edges` (true; screen edges plus 25%, 50% and 75% guides on both axes), `layer_edges` (true), `mask_edges` (false), `grid` (false), `show_grid` (true), and `grid_divisions` ([8, 6]); unknown fields rejected |
|
||||
| `snapping` | Object with required boolean fields `enabled` (false), `pixels` (true), `force_pixels` (false), `screen_edges` (true; screen edges plus 25%, 50% and 75% guides on both axes), `layer_edges` (true), `mask_edges` (false), `grid` (false), `show_grid` (true), and `grid_divisions` ([8, 6]); unknown fields rejected |
|
||||
|
||||
Scale preferences apply on startup. Slider drafts apply and save on pointer
|
||||
release; typed values wait until text entry ends. UI controls
|
||||
|
|
@ -156,6 +156,8 @@ mask centers. This extends the existing `mask_edges` flag without changing its
|
|||
serialized name, default or schema version. Mirrored
|
||||
contact uses outer edges. The option defaults to false.
|
||||
|
||||
`force_pixels` makes integer pixel coordinates take priority over other snap targets for moves, resize handles and pivots. It defaults to false because rounding every resized edge can slightly approximate a locked aspect ratio. Shift+Space temporarily enables this mode during a gesture, even when regular snapping is disabled; it takes precedence over Shift’s 10 px grid. Space without Shift retains temporary canvas panning.
|
||||
|
||||
The session-only toolbar grid tools select 10 or 100 screen pixels (mutually exclusive). Shift temporarily selects the 10 px grid; Ctrl+Shift selects 100 px. If that same grid tool is selected, the matching shortcut temporarily disables it instead. Alt overrides both grids and temporarily inverts the saved snapping-enabled value (off becomes on; on becomes off), including on release. The chosen pixel/screen/layer-edge targets still apply. These modifiers do not change the saved options or settings version.
|
||||
|
||||
**Settings → Midra integration → Allow sending to Program** saves immediately. Restore default settings disables it. Projects do not override this application preference; the Preview/Program destination itself remains session-only.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,158 @@
|
|||
{
|
||||
"format": "beffroi.midra-layout",
|
||||
"version": 22,
|
||||
"output_resolution": {
|
||||
"width": 1920,
|
||||
"height": 1080
|
||||
},
|
||||
"inputs": [
|
||||
{
|
||||
"id": 1,
|
||||
"source_format": "sixteen_nine",
|
||||
"native_resolution": {
|
||||
"width": 1920,
|
||||
"height": 1080
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"source_format": "sixteen_nine",
|
||||
"native_resolution": {
|
||||
"width": 1920,
|
||||
"height": 1080
|
||||
}
|
||||
}
|
||||
],
|
||||
"layers": [
|
||||
{
|
||||
"id": 2,
|
||||
"source_id": 1,
|
||||
"bounds": {
|
||||
"x": 120.0,
|
||||
"y": 180.0,
|
||||
"width": 640.0,
|
||||
"height": 360.0
|
||||
},
|
||||
"advanced_crop": {
|
||||
"left": 0.0,
|
||||
"right": 0.0,
|
||||
"top": 0.0,
|
||||
"bottom": 0.0
|
||||
},
|
||||
"visible": true,
|
||||
"locked": false,
|
||||
"name": "Slides",
|
||||
"folder": "",
|
||||
"pivot": [
|
||||
0.5,
|
||||
0.5
|
||||
],
|
||||
"layer_fit": null,
|
||||
"mask": {
|
||||
"left": 0.0,
|
||||
"right": 0.0,
|
||||
"top": 0.0,
|
||||
"bottom": 0.0,
|
||||
"origin": "source"
|
||||
},
|
||||
"load_mapping": {
|
||||
"family": "midra4k",
|
||||
"screen": "1",
|
||||
"layer": "1"
|
||||
},
|
||||
"send_mapping": {
|
||||
"destinations": [
|
||||
{
|
||||
"connection": "current",
|
||||
"layer": {
|
||||
"family": "midra4k",
|
||||
"screen": "1",
|
||||
"layer": "1"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"keep_aspect_ratio": true
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"source_id": 2,
|
||||
"bounds": {
|
||||
"x": 1160.0,
|
||||
"y": 180.0,
|
||||
"width": 640.0,
|
||||
"height": 360.0
|
||||
},
|
||||
"advanced_crop": {
|
||||
"left": 0.0,
|
||||
"right": 0.0,
|
||||
"top": 0.0,
|
||||
"bottom": 0.0
|
||||
},
|
||||
"visible": true,
|
||||
"locked": false,
|
||||
"name": "Presenter",
|
||||
"folder": "",
|
||||
"pivot": [
|
||||
0.5,
|
||||
0.5
|
||||
],
|
||||
"layer_fit": "fullscreen",
|
||||
"mask": {
|
||||
"left": 0.1,
|
||||
"right": 0.0,
|
||||
"top": 0.0,
|
||||
"bottom": 0.0,
|
||||
"origin": "layer"
|
||||
},
|
||||
"load_mapping": null,
|
||||
"send_mapping": {
|
||||
"destinations": []
|
||||
},
|
||||
"keep_aspect_ratio": true
|
||||
}
|
||||
],
|
||||
"editor": {
|
||||
"backdrop_title": "Example Conference Name",
|
||||
"selected_layer_ids": [
|
||||
1
|
||||
],
|
||||
"position_point": "top_left",
|
||||
"viewport_zoom": 1.0,
|
||||
"viewport_pan": [
|
||||
0.0,
|
||||
0.0
|
||||
],
|
||||
"show_source_pattern": false,
|
||||
"show_toolbar_icon_names": false,
|
||||
"outline_layers": false,
|
||||
"position_layer_point": null
|
||||
},
|
||||
"next_layer_id": 3,
|
||||
"references": [],
|
||||
"workspace": {
|
||||
"snapping": {
|
||||
"enabled": false,
|
||||
"pixels": true,
|
||||
"force_pixels": false,
|
||||
"screen_edges": true,
|
||||
"layer_edges": true,
|
||||
"grid": false,
|
||||
"show_grid": true,
|
||||
"grid_divisions": [
|
||||
8,
|
||||
6
|
||||
],
|
||||
"mask_edges": false
|
||||
},
|
||||
"resize_mode": "individual",
|
||||
"grid_spacing": null,
|
||||
"collapsed_folders": [],
|
||||
"capture_interval_seconds": 10,
|
||||
"show_empty_inputs": false,
|
||||
"previews": []
|
||||
},
|
||||
"folders": [
|
||||
"Memory A"
|
||||
]
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ These are offline editor formats, not Analog Way REST payloads. Implementation:
|
|||
[`project.rs`](../../crates/canvas-pilot/tests/project.rs). Update this contract,
|
||||
examples and tests in the same change as any save/export schema change.
|
||||
|
||||
## Project JSON, version 21
|
||||
## Project JSON, version 22
|
||||
|
||||
Suggested filename: `layout.pilot.json`. **Open project** accepts any `.json`
|
||||
filename, including legacy `.midra.json` projects, and validates the project
|
||||
|
|
@ -35,13 +35,13 @@ session-only and are not project data. Strict migration accepts older projects o
|
|||
when the retired proposal list is empty and all retired input crop edges are zero;
|
||||
otherwise it directs the caller to explicit best-effort Open project.
|
||||
|
||||
Version 21 moves `editor.keep_aspect_ratio` to required `layers[].keep_aspect_ratio`. Versions 1–20 copy the former project-wide value to every layer, preserving their resize behavior. Saving now writes version 21; older applications reject it.
|
||||
Version 21 moves `editor.keep_aspect_ratio` to required `layers[].keep_aspect_ratio`. Versions 1–20 copy the former project-wide value to every layer, preserving their resize behavior. Version 22 adds required `workspace.snapping.force_pixels` (false). Versions 1–21 migrate with forced whole-pixel snapping disabled and reject the field under an older version. Saving now writes version 22; older applications reject it.
|
||||
|
||||
### Best-effort Open project
|
||||
|
||||
The native-project opening path uses `project_recovery::from_json`. It first tries
|
||||
known migrations and strict validation, then recovers supported fields independently.
|
||||
Only valid UTF-8 JSON with the Canvas Pilot format and a known version (1–21) is
|
||||
Only valid UTF-8 JSON with the Canvas Pilot format and a known version (1–22) is
|
||||
accepted, within the 96 MiB limit. Invalid JSON and unknown future versions are errors.
|
||||
Retired proposals and local input crops are discarded with a report; old appearance
|
||||
is not guaranteed. Reload affected layers from the device after input preprocessing.
|
||||
|
|
@ -57,7 +57,7 @@ projects open as unsaved copies, with no automatic overwrite target. Loading nev
|
|||
writes to the source or sends device commands. Strict exchange imports and automatic
|
||||
recovery envelopes retain their separate validation rules.
|
||||
|
||||
[Complete example](canvas-pilot-v21.example.json) is a valid project with an empty `Memory A` folder and a Midra link,
|
||||
[Complete example](canvas-pilot-v22.example.json) is a valid project with an empty `Memory A` folder and a Midra link,
|
||||
with an unlinked Fullscreen example layer and no reference image. New projects label the lower layer `02 / Slides` and
|
||||
the upper layer `01 / Presenter`; existing projects retain their saved IDs/names.
|
||||
It is loaded by the regression tests.
|
||||
|
|
@ -65,7 +65,7 @@ It is loaded by the regression tests.
|
|||
| Root field | Representation / meaning |
|
||||
| --- | --- |
|
||||
| `format` | Exactly `"beffroi.midra-layout"` |
|
||||
| `version` | Integer `21` |
|
||||
| `version` | Integer `22` |
|
||||
| `folders` | Required array of 0–256 unique explicit folder names, each trimmed and 1–128 characters. Explicit folders remain even with no members; layer folder labels also form implicit groups. |
|
||||
| `next_layer_id` | Positive integer strictly greater than every layer ID; not rewound by undo |
|
||||
| `output_resolution` | `{ "width": integer, "height": integer }`, screen pixels |
|
||||
|
|
@ -262,7 +262,7 @@ and `viewBox="0 0 W H"` equal to the output screen. The root carries
|
|||
|
||||
## Compatibility changes
|
||||
|
||||
Project version 21 and the versioned geometry exchanges are strict contracts. A breaking project field/meaning change must bump
|
||||
Project version 22 and the versioned geometry exchanges are strict contracts. A breaking project field/meaning change must bump
|
||||
`version` and either implement a tested migration or clearly reject older/newer
|
||||
files. Changing rectangle/marker semantics requires a corresponding documented
|
||||
exchange-interface revision and importer tests. Update this document and its example
|
||||
|
|
@ -280,7 +280,7 @@ retarget existing links; choosing a destination there explicitly replaces that
|
|||
layer's saved link. Direct send/load actions use each layer's saved screen,
|
||||
independently of the screen currently displayed in the configuration window.
|
||||
|
||||
Automatic session recovery wraps this project representation in a separate [recovery file](canvas-pilot-recovery.md); named project JSON is version 21.
|
||||
Automatic session recovery wraps this project representation in a separate [recovery file](canvas-pilot-recovery.md); named project JSON is version 22.
|
||||
|
||||
## Folder-scoped Midra transfers
|
||||
|
||||
|
|
@ -306,7 +306,7 @@ device preprocessing to refresh the source dimensions used for layer geometry.
|
|||
|
||||
| Field | Representation / validation / migration default |
|
||||
| --- | --- |
|
||||
| `snapping` | Required booleans `enabled` (false), `pixels` (true), `screen_edges` (true), `layer_edges` (true), `mask_edges` (false), `grid` (false), `show_grid` (true), and `grid_divisions` (two integers 1–64, default `[8,6]`). These override application defaults for the opened project. |
|
||||
| `snapping` | Required booleans `enabled` (false), `pixels` (true), `force_pixels` (false), `screen_edges` (true), `layer_edges` (true), `mask_edges` (false), `grid` (false), `show_grid` (true), and `grid_divisions` (two integers 1–64, default `[8,6]`). These override application defaults for the opened project. |
|
||||
| `resize_mode` | `individual` (default), `same`, `mirror`, or `opposite` |
|
||||
| `grid_spacing` | null (default), 10 or 100, in output pixels |
|
||||
| `collapsed_folders` | Unique existing nonempty folder names (including empty explicit folders); default `[]`. Deleted/renamed stale entries are omitted when saving. |
|
||||
|
|
@ -351,7 +351,7 @@ background export behavior.
|
|||
For the complete persistence audit and the reasons for keeping other controls
|
||||
out of project files, see [Project persistence audit](canvas-pilot-persistence-audit.md).
|
||||
|
||||
Device links distinguish family, screen/auxiliary and layer. A link from another family cannot be used on the current device without explicit remapping. Multiple editor layers may share one destination; a send scope containing duplicates is rejected with the conflicting layer names. Device state and physical bank roles are never saved in the project. Geometry-only exports omit these links; embedded editor snapshots retain version 21 and use the same migration on import.
|
||||
Device links distinguish family, screen/auxiliary and layer. A link from another family cannot be used on the current device without explicit remapping. Multiple editor layers may share one destination; a send scope containing duplicates is rejected with the conflicting layer names. Device state and physical bank roles are never saved in the project. Geometry-only exports omit these links; embedded editor snapshots retain version 22 and use the same migration on import.
|
||||
|
||||
### Explicit layer fit (v14)
|
||||
|
||||
|
|
|
|||
|
|
@ -78,11 +78,11 @@ changes to installed files take effect after restart.
|
|||
|
||||
## Settings, missing packs and round trips
|
||||
|
||||
[Settings version 15](canvas-pilot-settings.md) stores a packed theme as
|
||||
[Settings version 16](canvas-pilot-settings.md) stores a packed theme as
|
||||
`{"pack":"tokyo-night/night"}` in `theme` and `recent_themes`; built-in string IDs
|
||||
are unchanged. Versions 1–14 migrate preserving preferences and history, but pack
|
||||
choices under a legacy version are rejected. Older applications reject version 15.
|
||||
The [default fixture](canvas-pilot-settings-v15.example.json) is the migration target.
|
||||
choices under a legacy version are rejected. Older applications reject version 16.
|
||||
The [default fixture](canvas-pilot-settings-v16.example.json) is the current target.
|
||||
|
||||
Missing/invalid packs preserve the saved theme choice and show an unavailable
|
||||
label, rendering with Midra Dark until the pack is installed again or the user
|
||||
|
|
|
|||
Loading…
Reference in New Issue