Ribbon: an option to fold it to its tab row (#10112) (#10214)

* Ribbon: an option to fold it to its tab row (#10112)

Preferences > Layout > "Show only the ribbon's tabs" (off by default), the
Ribbon Tabs Only command (view.ribbon_tabs_only), and its settings-profile key.
Rebuilt on main's redesigned Layout page.

* Ribbon Tabs Only: switching tabs with a panel menu open no longer keeps the overlay open (#10112)

A tab click now forgets the open panel drop-down of the previous tab, so the pointer leaving or Escape still closes the overlay.

* Ribbon Tabs Only: count its settings-profile key in the profile membership test (#10112)
This commit is contained in:
raykholo
2026-11-05 03:42:58 +00:00
committed by GitHub
parent 733f0b2254
commit b916f9bf33
17 changed files with 381 additions and 26 deletions
+32 -1
View File
@@ -6,7 +6,8 @@ use solidcraft_render::{Camera, StandardView};
use super::CommandSpec;
use crate::params::{bad, num, req_vec2, req_vec3, vec3};
use crate::schema::view_navigation::{
CameraReply, NavigatorParams, NormalToParams, RenderBrowser, RenderFocus, RenderSelect, StandardViewParams, TabStep, TabStepParams,
CameraReply, NavigatorParams, NormalToParams, RenderBrowser, RenderFocus, RenderSelect, RibbonTabsOnly, RibbonTabsOnlyParams, StandardViewParams,
TabStep, TabStepParams,
};
use crate::schema::{TypedContract, output_schema_for};
use crate::{Result, Sel, Session};
@@ -17,6 +18,7 @@ const BROWSER_CONTRACT: TypedContract<RenderBrowserRequest> = TypedContract::new
const TAB_STEP_CONTRACT: TypedContract<TabStepParams> = TypedContract::new();
const STANDARD_VIEW_CONTRACT: TypedContract<StandardViewParams> = TypedContract::new();
const NORMAL_TO_CONTRACT: TypedContract<NormalToParams> = TypedContract::new();
const RIBBON_TABS_ONLY_CONTRACT: TypedContract<RibbonTabsOnlyParams> = TypedContract::new();
// Both existing request forms share the Browser command and its published schema.
#[derive(serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
@@ -69,6 +71,9 @@ CommandSpec::new("view.navigator", "Custom View Navigator", crate::checked!("vie
.icon("nav_settings").noundo().doc_only()
.contract(&NAVIGATOR_CONTRACT).output(output_schema_for::<NavigatorParams>)
.params("style?: axes|cube|custom; body?: body name|null; texture?: themed|modeled; arrows?, home?: bool → the navigator as set; the app's view navigator, never saved in the design; never opens a dialog (a toolbar start opens the Custom View Navigator panel)"),
CommandSpec::new("view.ribbon_tabs_only", "Ribbon Tabs Only", crate::checked!("view.ribbon_tabs_only", ribbon_tabs_only))
.icon("chevron").noundo().doc_only().contract(&RIBBON_TABS_ONLY_CONTRACT).output(output_schema_for::<RibbonTabsOnly>)
.params("on?: bool (omitted: switch) → on?; fold the ribbon to its tab row, a tab click shows its panels over the view (window setting)"),
CommandSpec::new("view.render_focus", "Render Focus View", crate::checked!("view.render_focus", render_focus))
.icon("render_scene").noundo().doc_only()
.contract(&FOCUS_CONTRACT).output(output_schema_for::<RenderFocus>)
@@ -320,6 +325,17 @@ fn navigation_bar(_s: &mut Session, p: &Value) -> Result<Value> {
view_toggle(p, "view.navigation_bar", "visible")
}
fn ribbon_tabs_only(_s: &mut Session, p: &Value) -> Result<Value> {
let cmd = "view.ribbon_tabs_only";
let p = match p {
Value::Null => json!({}),
Value::Object(_) => p.clone(),
_ => return Err(bad(cmd, "parameters must be an object")),
};
let request: RibbonTabsOnlyParams = serde_json::from_value(p).map_err(|e| bad(cmd, e.to_string()))?;
serde_json::to_value(RibbonTabsOnly { on: request.on, param_warnings: Vec::new() }).map_err(|e| crate::EngineError::Other(e.to_string()))
}
fn status_items(s: &mut Session, p: &Value) -> Result<Value> {
if !p.is_object() {
return Err(bad("view.status_items", "parameters must be an empty object"));
@@ -645,6 +661,21 @@ mod tests {
assert!(s.camera.is_none());
}
#[test]
fn ribbon_tabs_only_echoes_the_request_without_editing_the_design() {
let mut s = Session::default();
let before = s.doc.to_json();
assert_eq!(s.execute("view.ribbon_tabs_only", &json!({})).unwrap(), json!({}));
for on in [false, true] {
assert_eq!(s.execute("view.ribbon_tabs_only", &json!({"on":on})).unwrap(), json!({"on":on}));
}
for params in [json!({"on":0}), json!({"on":"true"}), json!({"on":[]}), json!({"unexpected":true}), json!(true), json!([])] {
assert!(s.execute("view.ribbon_tabs_only", &params).is_err(), "{params}");
}
assert_eq!(s.doc.to_json(), before);
assert!(s.undo.is_empty());
}
#[test]
fn look_at_planes_uses_the_first_supported_selection_and_flips_on_repeat() {
let original = Camera { yaw: 0.3, pitch: 0.4, roll: 0.7, fov: 0.6, distance: 123.0, ..Default::default() };
@@ -131,6 +131,27 @@ pub struct TabStep {
pub param_warnings: Vec<String>,
}
/// `view.ribbon_tabs_only`: fold the ribbon to its tab row, or show it whole (#10112).
#[derive(Debug, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct RibbonTabsOnlyParams {
/// True folds the ribbon to its tab row, false shows it whole; omitted switches between the two.
#[serde(default)]
pub on: Option<bool>,
}
/// What `view.ribbon_tabs_only` returns: the request echoed. The window applies it to its
/// preference; the design is not changed and nothing is added to undo.
#[derive(Debug, Serialize, JsonSchema)]
pub struct RibbonTabsOnly {
/// The requested state; absent when the call asked to switch.
#[serde(skip_serializing_if = "Option::is_none")]
pub on: Option<bool>,
/// In the warn parameter-check mode: what the call's parameters got wrong.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub param_warnings: Vec<String>,
}
/// Validated request and echoed result of `view.render_select`.
#[derive(Debug, Serialize)]
pub struct RenderSelect {