From b5a1146966659aa2bf09fd3d7464af79f683ddb4 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Fri, 7 Aug 2026 14:15:59 +0300 Subject: [PATCH] feat(view): one list of visual styles behind every way of choosing one The ribbon offered four styles and dispatched each one's id as a command. Two of those ids were not visual-style commands: "Shaded" carried SOLID, which draws a 2D filled polygon, so choosing it started a draw command; "Hidden" carried HIDDEN, which matched nothing at all, so it did nothing. The intent had been for the button to fire its tool's event, but the dropdown never reads one -- it dispatches the id. Behind that sat two generations of the same feature. The render-mode picker offered the seven styles a viewport can actually be drawn in; everything else -- the ribbon, VSCURRENT, SHADEMODE, VISUALSTYLES and a handful of bare verbs -- went through a binary wireframe-or-shaded flag that could only approximate them, reporting "Hidden (shown shaded)" and "X-Ray (shown as wireframe)" when asked for something it had no way to draw. Four descriptions of one choice, each drifting on its own. There is one list now. Each style names itself once -- mode, label, icon, and the command that applies it -- and the ribbon, the picker, the VISUALSTYLES verb and the interactive prompt all read from it, down to the line that lists the choices, so what is offered cannot disagree with what works. Keywords are the render modes' own names, since there is one set of styles left to name. The binary path is gone rather than kept alongside: its message, its module event, the tool definitions that produced it, the ribbon's special-cased highlight arms, the bare style verbs and the older keyword spellings. X-Ray goes with it -- no render mode draws one, and it was already coming out as a plain wireframe. Three files that had been left holding a single icon constant each fold into the list. Note: ModuleEvent::SetWireframe leaves the plugin API with it. Closes #621 Co-Authored-By: Claude Opus 5 --- assets/ocad.pgp | 1 - crates/ocs_plugin_api/src/ribbon.rs | 2 - src/app/commands/fileops.rs | 58 ++++--------- src/app/commands/mod.rs | 7 -- src/app/commands/view.rs | 32 +++---- src/app/mod.rs | 7 +- src/app/update/dialog.rs | 15 ---- src/app/update/mod.rs | 12 --- src/app/view/controls.rs | 16 ++-- src/app/view/mod.rs | 11 +-- src/modules/view/hidden.rs | 10 --- src/modules/view/mod.rs | 19 ++--- src/modules/view/solid.rs | 13 --- src/modules/view/visual_style.rs | 126 ++++++++++++++++++++++++++++ src/modules/view/wireframe.rs | 13 --- src/modules/view/xray.rs | 10 --- src/ui/ribbon/mod.rs | 1 - src/ui/ribbon/widgets.rs | 4 - 18 files changed, 170 insertions(+), 187 deletions(-) delete mode 100644 src/modules/view/hidden.rs delete mode 100644 src/modules/view/solid.rs create mode 100644 src/modules/view/visual_style.rs delete mode 100644 src/modules/view/wireframe.rs delete mode 100644 src/modules/view/xray.rs diff --git a/assets/ocad.pgp b/assets/ocad.pgp index 104ae72e..b9b54bcd 100644 --- a/assets/ocad.pgp +++ b/assets/ocad.pgp @@ -127,7 +127,6 @@ MO, *PROPERTIES UN, *UNITS TP, *TOOLPALETTES SSM, *SHEETSET -VW, *WIREFRAME HI, *HIDE 3O, *3DORBIT ORBIT, *3DORBIT diff --git a/crates/ocs_plugin_api/src/ribbon.rs b/crates/ocs_plugin_api/src/ribbon.rs index afe33251..28201289 100644 --- a/crates/ocs_plugin_api/src/ribbon.rs +++ b/crates/ocs_plugin_api/src/ribbon.rs @@ -17,8 +17,6 @@ pub enum ModuleEvent { /// Remove all loaded models from the scene. #[allow(dead_code)] ClearModels, - /// Toggle wireframe rendering. - SetWireframe(bool), /// Toggle the layer manager panel. ToggleLayers, /// Ask the host to open a native file picker. On selection the host diff --git a/src/app/commands/fileops.rs b/src/app/commands/fileops.rs index 7ce2b713..3a3d8a5d 100644 --- a/src/app/commands/fileops.rs +++ b/src/app/commands/fileops.rs @@ -103,66 +103,40 @@ impl OpenCADStudio { } } "CLEAR" | "CLR" => return Some(Task::done(Message::ClearScene)), - "WIREFRAME" => return Some(Task::done(Message::SetWireframe(true))), // Visual-style commands. OCS renders either a wireframe or a shaded // view; the named styles map onto the closest of the two and the // chosen style is reported so the mapping is explicit. (`SOLID` is // intentionally NOT a visual-style verb — it is the 2D filled-polygon // draw command; the shaded ribbon button drives `SetWireframe`.) - "VS" | "VSCURRENT" | "SHADEMODE" => { + // One interactive picker behind every verb that asks for a style, + // offering exactly what the render-mode widget offers. (#621) + "VS" | "VSCURRENT" | "SHADEMODE" | "VISUALSTYLES" => { use crate::command::KeywordCommand; + use crate::modules::view::visual_style; let c = KeywordCommand::new( "VSCURRENT", - "VSCURRENT visual style [Shaded / Wireframe / Hidden / Realistic / Conceptual / X-ray]:", - vec![ - ("Shaded", "SHADED", None), - ("Wireframe", "WIREFRAME", None), - ("Hidden", "HIDDEN", None), - ("Realistic", "REALISTIC", None), - ("Conceptual", "CONCEPTUAL", None), - ("X-Ray", "XRAY", None), - ], + visual_style::keyword_prompt(), + visual_style::keyword_choices(), ); self.command_line.push_info(&c.prompt()); self.tabs[i].active_cmd = Some(Box::new(c)); } - // The named visual-style shortcuts still switch directly, and the - // `