mirror of
https://github.com/storytold/photocraft.git
synced 2026-11-02 06:17:22 -06:00
Main moved the engine commands into crates/engine/src/cmd/ and the dialogs and panels into submodules. The PR's placement calls follow them, and main's new insert sites (new_adjustment in adjust_params.rs, Place in file_cmds/open.rs, shapes in vector_cmds/shape.rs) use layer_place::insert_new like the PR's originals. The New Group dialog moves to dialogs/new_group_ui.rs; the Layers panel flyout's New Group… opens it. Main's Session::precheck now also checks layer.new.group's and layer.new.groupFromLayers' new params (name, color, mode, opacity, position), so precheck_agrees_with_execute holds. Main had since added "New Group…" to every catalog: the PR's duplicate rows are dropped. Main's newer tests that made a layer with an open group active now open the group last, as the PR did for the older ones. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
38 lines
1.7 KiB
Rust
38 lines
1.7 KiB
Rust
use photocraft_engine::Session;
|
|
use serde_json::json;
|
|
|
|
fn select(s: &mut Session, id: u64, mode: &str) {
|
|
s.execute("layer.select", json!({"layer": id, "mode": mode})).unwrap();
|
|
}
|
|
|
|
fn selected(s: &Session) -> Vec<u64> {
|
|
let mut ids: Vec<_> = s.active().unwrap().selected_layers.iter().map(|id| id.0).collect();
|
|
ids.sort_unstable();
|
|
ids
|
|
}
|
|
|
|
#[test]
|
|
fn shift_range_follows_visible_rows_on_both_sides_of_an_expanded_group() {
|
|
let mut s = Session::new();
|
|
s.execute("file.new", json!({"width": 8, "height": 8})).unwrap();
|
|
let b = s.execute("layer.new.layer", json!({"name": "B"})).unwrap()["layer"].as_u64().unwrap();
|
|
let c = s.execute("layer.new.layer", json!({"name": "C"})).unwrap()["layer"].as_u64().unwrap();
|
|
select(&mut s, b, "replace");
|
|
select(&mut s, c, "add");
|
|
let group = s.execute("layer.groupLayers", json!({})).unwrap()["layer"].as_u64().unwrap();
|
|
// D goes above the closed group (an open one would take it inside, as in Photoshop).
|
|
let d = s.execute("layer.new.layer", json!({"name": "D"})).unwrap()["layer"].as_u64().unwrap();
|
|
// Group Layers makes a collapsed group, as in Photoshop; open it so B and C are visible rows.
|
|
s.execute("layer.setExpanded", json!({"layer": group, "expanded": true})).unwrap();
|
|
|
|
for (anchor, target, wanted) in
|
|
[(d, group, vec![d, group]), (group, d, vec![d, group]), (group, b, vec![group, c, b]), (b, group, vec![group, c, b]), (c, b, vec![c, b])]
|
|
{
|
|
select(&mut s, anchor, "replace");
|
|
select(&mut s, target, "range");
|
|
let mut expected = wanted;
|
|
expected.sort_unstable();
|
|
assert_eq!(selected(&s), expected, "range from {anchor} to {target}");
|
|
}
|
|
}
|