feat(ui): compatible right-click context menu driven by command options

The viewport context menu is now built from a pure model
(ui::popup::context_menu) rendered by the overlay: while a command runs it
offers Enter / Cancel / every keyword of the command's options() with the
keyword shown as a hint, a Recent Input submenu and M2P; when idle it offers
Repeat, Recent Input, Clipboard, Undo/Redo with history labels, the edit
block (Erase/Move/Copy/Scale/Rotate/Mirror/Draw Order), Isolate, Pan/Zoom,
selection tools, Properties and Options. The default row is anchored under
the pointer and the menu is keyboard-navigable (arrows, Enter, mnemonic
letters; any other key closes it and types into the command line).

Right-click behaviour is a user preference (Options → User Preferences,
SHORTCUTMENU / SHORTCUTMENUDURATION): shortcut menu (commercial solutions default),
time-sensitive, or the previous Enter-first cycle.

LINE gains options() (Close/Undo/eXit).

Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
PanosandClaude Opus 5 committed 2026-09-17 12:05:14 +03:00
1 parent 65c0fe5494
commit e623c053ab
19 files changed
+2019 -199

No files matched your search

+18
View File
@@ -71,6 +71,21 @@ impl CadCommand for LineCommand {
}
}
fn options(&self) -> Vec<crate::command::CmdOption> {
use crate::command::CmdOption;
// Mirrors AutoCAD's LINE prompt: Undo once a point is placed, Close
// once a closing segment is possible, eXit always.
match self.points.len() {
0 => Vec::new(),
1 => vec![CmdOption::new("Undo", "U"), CmdOption::new("eXit", "X")],
_ => vec![
CmdOption::new("Close", "C"),
CmdOption::new("Undo", "U"),
CmdOption::new("eXit", "X"),
],
}
}
fn on_point(&mut self, pt: DVec3) -> CmdResult {
if let Some(&last) = self.points.last() {
let line = Self::line_between(last, pt);
@@ -185,6 +200,9 @@ impl CadCommand for LineCommand {
Some(CmdResult::NeedPoint)
}
}
// eXit: end the command keeping every segment drawn so far
// (AutoCAD LINE's third keyword).
"X" | "EXIT" => Some(CmdResult::Cancel),
"U" | "UNDO" => {
if self.points.len() >= 2 {
// Drop the last vertex and revert its committed segment.