mirror of
https://github.com/storytold/designcraft.git
synced 2026-11-03 01:00:13 +00:00
Preferences: the Tools Panel columns go through window.toolsDoubleColumn
The command takes `on` (default: toggle), and Preferences OK runs it with the chosen state instead of setting the flag itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8bc8449eb6
commit
d9e8438cbb
2 files changed
+10
-3
No files matched your search
@@ -3426,7 +3426,7 @@ pub fn confirm(app: &mut DesignApp) -> Result<Value, String> {
|
||||
app.run("window.brightness", json!({"brightness": b}))?;
|
||||
}
|
||||
if d.fields.contains_key("toolsColumns") {
|
||||
app.ui.tools_double_column = d.s("toolsColumns") == "double";
|
||||
app.run("window.toolsDoubleColumn", json!({"on": d.s("toolsColumns") == "double"}))?;
|
||||
}
|
||||
if let Some(v) = d.n("uiScale") {
|
||||
app.run("window.uiScale", json!({"scale": v / 100.0}))?;
|
||||
@@ -7531,6 +7531,10 @@ mod tests {
|
||||
assert!(h.state().ui.dialog.is_none());
|
||||
assert_eq!(h.state().ui.brightness, Brightness::Dark);
|
||||
assert!(h.state().ui.tools_double_column);
|
||||
// The same command the Window menu toggles, with an explicit state for Preferences.
|
||||
assert_eq!(h.state_mut().run("window.toolsDoubleColumn", json!({"on": false})).unwrap(), json!(false));
|
||||
assert_eq!(h.state_mut().run("window.toolsDoubleColumn", json!({"on": false})).unwrap(), json!(false), "set, not toggled");
|
||||
assert_eq!(h.state_mut().run("window.toolsDoubleColumn", json!({})).unwrap(), json!(true), "toggled without `on`");
|
||||
// UI Size has a section of its own.
|
||||
open(h.state_mut());
|
||||
h.state_mut().ui.dialog.as_mut().unwrap().fields.insert("section".into(), json!("uiScaling"));
|
||||
|
||||
@@ -291,7 +291,7 @@ pub const UI_COMMANDS: &[(&str, &str, Option<&str>, &str)] = &[
|
||||
None,
|
||||
"{open?: true, tab?: \"about\"|\"contributors\"|\"models\"} — the About window: splash with community links, contributor and model credits (open: false closes it)",
|
||||
),
|
||||
("window.toolsDoubleColumn", "Tools: Double Column", None, "{}"),
|
||||
("window.toolsDoubleColumn", "Tools: Double Column", None, "{on?: bool (default: toggle)} → whether the Tools panel has two columns"),
|
||||
(
|
||||
"window.workspace",
|
||||
"Workspace",
|
||||
@@ -1829,7 +1829,10 @@ fn run_ui_inner(app: &mut DesignApp, id: &str, p: &Value) -> Option<Result<Value
|
||||
app.ui.pending_urls.push(url.clone());
|
||||
Ok(json!({"url": url}))
|
||||
}
|
||||
"window.toolsDoubleColumn" => flag(&mut app.ui.tools_double_column),
|
||||
"window.toolsDoubleColumn" => {
|
||||
app.ui.tools_double_column = p.get("on").and_then(Value::as_bool).unwrap_or(!app.ui.tools_double_column);
|
||||
Ok(json!(app.ui.tools_double_column))
|
||||
}
|
||||
"window.collapseToIcons" => {
|
||||
app.ui.dock_expanded = false;
|
||||
app.ui.open_panel = None;
|
||||
|
||||
Reference in new issue
Block a user