#670: each pane of a 2- or 4-view layout chooses its own view
Problem: the extra panes of View > Switch View Layout were fixed to Top, Front and Right, and the 3D View menu only changed the main view.
Fix: every extra pane has a view selector (Active Camera, Default, Front, Left, Top, Back, Right, Bottom, Custom View 1-3). The choice is kept per comp in Views3D::panes (serde default, so older editor states load with Top/Front/Right) and set by the new command view.setPaneView {pane 0-3, view}. The Active Camera pane renders through the comp camera.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
f19f3a8a39
commit
fa7ffb6d09
@@ -3,6 +3,7 @@
|
||||
//! --test ui_3d -- --ignored`); the other test only runs the UI logic.
|
||||
|
||||
use effectcraft_engine::Session;
|
||||
use effectcraft_engine::render::three_d::View3D;
|
||||
use effectcraft_ui_egui::EffectcraftApp;
|
||||
use egui_kittest::Harness;
|
||||
use serde_json::json;
|
||||
@@ -223,3 +224,44 @@ fn layout_views_draw_the_camera_and_follow_its_position() {
|
||||
assert!(after.0 - before.0 > 10.0, "the camera moves right in the Top view: {before:?} -> {after:?}");
|
||||
assert!((after.1 - before.1).abs() < 1.0, "{before:?} -> {after:?}");
|
||||
}
|
||||
|
||||
/// A 4-view layout over a comp with a 3D solid and a camera.
|
||||
fn four_views() -> Harness<'static, EffectcraftApp> {
|
||||
let mut s = Session::default();
|
||||
s.execute("comp.new", json!({"name": "C", "width": 640, "height": 360, "duration": 2})).unwrap();
|
||||
let solid = s.execute("layer.newSolid", json!({"color": "#ff0000", "width": 200, "height": 200})).unwrap()["layer"].as_u64().unwrap();
|
||||
s.execute("layer.setSwitch", json!({"layer": solid, "switch": "threeD", "value": true})).unwrap();
|
||||
s.execute("layer.newCamera", json!({"position": [320, 180, -300], "poi": [320, 180, 0]})).unwrap();
|
||||
s.execute("view.layout", json!({"views": 4})).unwrap();
|
||||
let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1000.0)).build_eframe(|_| EffectcraftApp::new(s));
|
||||
settle(&mut h);
|
||||
h
|
||||
}
|
||||
|
||||
/// #670: every pane of a multi-view layout has its own view selector; choosing a view changes
|
||||
/// that pane (its camera and its wireframes) and no other, and it is remembered for the comp.
|
||||
#[test]
|
||||
fn each_layout_pane_chooses_its_own_view() {
|
||||
let mut h = four_views();
|
||||
let present = |h: &Harness<'_, EffectcraftApp>, view: &str| h.state().auto.find(&format!("viewer.view.{view}")).is_some();
|
||||
let has_camera = |h: &Harness<'_, EffectcraftApp>, view: &str| h.state().auto.query(&format!("viewer.view.{view}.camera.")).len() == 1;
|
||||
for p in 1..=3 {
|
||||
assert!(h.state().auto.find(&format!("viewer.view.{p}.type")).is_some(), "pane {p} has a selector");
|
||||
}
|
||||
assert!(present(&h, "front") && has_camera(&h, "front"));
|
||||
// Pane 2 (the Front view) becomes the Left view.
|
||||
let left = View3D::ALL.iter().position(|v| *v == View3D::Left).unwrap();
|
||||
click_id(&mut h, "viewer.view.2.type");
|
||||
click_id(&mut h, &format!("viewer.view.2.typeItem.{left}"));
|
||||
settle(&mut h);
|
||||
assert_eq!(h.state().auto.find("viewer.view.2.type").unwrap().label, "View of pane");
|
||||
assert!(present(&h, "left") && has_camera(&h, "left"), "pane 2 shows the Left view with its wireframe");
|
||||
assert!(!present(&h, "front"), "pane 2 no longer shows Front");
|
||||
assert!(present(&h, "top") && present(&h, "right"), "the other panes keep their views");
|
||||
let cid = h.state().session.active_comp_id().unwrap();
|
||||
assert_eq!(h.state().session.state.views3d[&cid].pane(1), View3D::Left);
|
||||
// The Active Camera view of a pane does not draw the camera it looks through.
|
||||
h.state_mut().session.execute("view.setPaneView", json!({"pane": 1, "view": "activeCamera"})).unwrap();
|
||||
settle(&mut h);
|
||||
assert!(present(&h, "activeCamera") && !has_camera(&h, "activeCamera"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user