Render workspace: move the Inspector or Browser dock to either side with view.render_dock and a header menu (#7230)
This commit is contained in:
@@ -29,6 +29,11 @@ CommandSpec::new("view.render_stage", "Render Stage", render_stage)
|
||||
CommandSpec::new("view.shots_strip", "Shots Strip", shots_strip)
|
||||
.at("RENDER CAMERA", "SHOTS").icon("camera").noundo().doc_only()
|
||||
.params("visible: bool → {visible}; Render Shots strip UI preference. Headless echo only, no document edits or undo"),
|
||||
CommandSpec::new("view.render_dock", "Move Render Dock", crate::checked!("view.render_dock", render_dock))
|
||||
.at("RENDER", "SCENE").icon("settings").noundo().doc_only()
|
||||
.contract(&RENDER_DOCK_CONTRACT)
|
||||
.output(crate::schema::output_schema_for::<crate::schema::view_navigation::RenderDock>)
|
||||
.params("panel: inspector|browser; side: left|right → {panel, side}; Render dock UI preference; headless echo only, no document edits or undo"),
|
||||
CommandSpec::new("view.layout", "Workspace layout", layout)
|
||||
.icon("settings").noundo().doc_only().params("mode: floating|compact → validated workspace layout; display only, never opens a dialog"),
|
||||
CommandSpec::new("view.history_layout", "History layout", history_layout)
|
||||
@@ -223,6 +228,14 @@ fn render_stage(_s: &mut Session, p: &Value) -> Result<Value> {
|
||||
Ok(json!({"stage":request.stage}))
|
||||
}
|
||||
|
||||
const RENDER_DOCK_CONTRACT: crate::schema::TypedContract<crate::schema::view_navigation::RenderDock> = crate::schema::TypedContract::new();
|
||||
|
||||
fn render_dock(_s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let request: crate::schema::view_navigation::RenderDock =
|
||||
serde_json::from_value(p.clone()).map_err(|e| bad("view.render_dock", e.to_string()))?;
|
||||
serde_json::to_value(request).map_err(|e| bad("view.render_dock", e.to_string()))
|
||||
}
|
||||
|
||||
fn shots_strip(_s: &mut Session, p: &Value) -> Result<Value> {
|
||||
#[derive(serde::Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
@@ -919,3 +932,36 @@ fn render_workspace_stage_validates_without_document_changes_or_evaluation() {
|
||||
assert!(std::sync::Arc::ptr_eq(&document, &session.doc));
|
||||
assert_eq!(before, (session.undo.len(), session.redo.len(), session.revision, session.evaluations, session.is_dirty()));
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[test]
|
||||
fn render_workspace_dock_validates_without_mutation() {
|
||||
let mut session = Session::default();
|
||||
session.execute("solid.box", &json!({"length":10,"width":10,"height":10})).unwrap();
|
||||
session.execute("edit.undo", &json!({})).unwrap();
|
||||
let document = session.doc.clone();
|
||||
let before = (session.undo.len(), session.redo.len(), session.revision, session.evaluations, session.is_dirty(), session.camera);
|
||||
for panel in ["inspector", "browser"] {
|
||||
for side in ["left", "right"] {
|
||||
let params = json!({"panel":panel,"side":side});
|
||||
assert_eq!(session.execute("view.render_dock", ¶ms).unwrap(), params);
|
||||
}
|
||||
}
|
||||
for params in [
|
||||
Value::Null,
|
||||
json!([]),
|
||||
json!({}),
|
||||
json!({"panel":"inspector"}),
|
||||
json!({"side":"left"}),
|
||||
json!({"panel":true,"side":"left"}),
|
||||
json!({"panel":"inspector","side":null}),
|
||||
json!({"panel":"inspector","side":1e300}),
|
||||
json!({"panel":"other","side":"left"}),
|
||||
json!({"panel":"inspector","side":"top"}),
|
||||
json!({"panel":"browser","side":"left","unknown":true}),
|
||||
] {
|
||||
assert!(session.execute("view.render_dock", ¶ms).is_err(), "{params}");
|
||||
}
|
||||
assert!(std::sync::Arc::ptr_eq(&document, &session.doc));
|
||||
assert_eq!(before, (session.undo.len(), session.redo.len(), session.revision, session.evaluations, session.is_dirty(), session.camera));
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ pub mod edit;
|
||||
pub mod features;
|
||||
pub mod inspect;
|
||||
pub mod sketch_constraints;
|
||||
pub mod view_navigation;
|
||||
|
||||
pub use check::{Contract, Issue, ParamCheck, TypedContract, input_schema_for, output_schema_for, run_checked, run_checked_as};
|
||||
pub use types::*;
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
//! UI-only Render dock request and echo contract.
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct RenderDock {
|
||||
pub panel: RenderPanel,
|
||||
pub side: DockSide,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum RenderPanel {
|
||||
Inspector,
|
||||
Browser,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum DockSide {
|
||||
Left,
|
||||
Right,
|
||||
}
|
||||
@@ -231,6 +231,7 @@ fn send_to_slicer_needs_a_slicer_and_bodies() {
|
||||
}
|
||||
|
||||
/// The chosen-programs list is process-wide: tests that set it take turns.
|
||||
#[cfg(unix)]
|
||||
static CHOSEN_PROGRAMS: std::sync::Mutex<()> = std::sync::Mutex::new(());
|
||||
|
||||
/// `file.save_mesh` with a `slicer` writes where the caller said and hands that file over, by the
|
||||
@@ -437,7 +438,10 @@ fn send_to_slicer_writes_3mf_and_starts_the_program_with_it() {
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let (script, seen) = (dir.join("fake-slicer"), dir.join("seen"));
|
||||
std::fs::write(&script, format!("#!/bin/sh\necho \"$@\" > {}\n", seen.display())).unwrap();
|
||||
// Publish the acknowledgement only after writing it: cleanup must wait for every launch.
|
||||
let writing = dir.join("writing");
|
||||
std::fs::write(&script, format!("#!/bin/sh\nprintf '%s\\n' \"$@\" > '{}'\nmv '{}' '{}'\n", writing.display(), writing.display(), seen.display()))
|
||||
.unwrap();
|
||||
std::fs::set_permissions(&script, std::fs::Permissions::from_mode(0o755)).unwrap();
|
||||
run(&mut s, "select.set", json!({"items":[{"type":"body","name":"Mesh"}]}));
|
||||
// A program nobody chose is refused; once it is among the user's chosen ones it starts.
|
||||
@@ -452,19 +456,26 @@ fn send_to_slicer_writes_3mf_and_starts_the_program_with_it() {
|
||||
assert_eq!(r["format"], "3mf");
|
||||
let file = r["path"].as_str().unwrap().to_string();
|
||||
assert!(std::fs::read(&file).unwrap().starts_with(b"PK"));
|
||||
for _ in 0..100 {
|
||||
if seen.exists() && std::fs::metadata(&seen).unwrap().len() > 0 {
|
||||
break;
|
||||
let await_launch = |expected: &str| {
|
||||
for _ in 0..100 {
|
||||
if seen.exists() {
|
||||
assert_eq!(std::fs::read_to_string(&seen).unwrap().trim(), expected);
|
||||
std::fs::remove_file(&seen).unwrap();
|
||||
return;
|
||||
}
|
||||
std::thread::sleep(std::time::Duration::from_millis(50));
|
||||
}
|
||||
std::thread::sleep(std::time::Duration::from_millis(50));
|
||||
}
|
||||
assert_eq!(std::fs::read_to_string(&seen).unwrap().trim(), file);
|
||||
panic!("fake slicer did not acknowledge {expected}");
|
||||
};
|
||||
await_launch(&file);
|
||||
// Sending the same bodies again replaces the file; the same name in the same private folder.
|
||||
let again = s.execute("file.send_to_slicer", &json!({"slicer": script})).unwrap();
|
||||
assert_eq!((again["path"].as_str(), again["numbered"].as_bool()), (Some(file.as_str()), Some(false)));
|
||||
await_launch(&file);
|
||||
let stl = s.execute("file.send_to_slicer", &json!({"slicer": script, "format": "stl"})).unwrap();
|
||||
assert!(stl["path"].as_str().unwrap().ends_with(".stl"));
|
||||
assert_ne!(stl["path"], r["path"]);
|
||||
await_launch(stl["path"].as_str().unwrap());
|
||||
crate::slicers::set_chosen_programs(&[]);
|
||||
std::fs::remove_dir_all(std::path::Path::new(&file).parent().unwrap()).unwrap();
|
||||
std::fs::remove_dir_all(dir).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user