forked from 1b-agent/opencadstudio-upstream
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 <noreply@anthropic.com>
This commit is contained in:
1 parent
65c0fe5494
commit
e623c053ab
19 files changed
+2019
-199
No files matched your search
+30
-3
@@ -89,6 +89,17 @@ pub const HOVER_DWELL_MS: u128 = 500;
|
||||
/// threshold gates that extra redraw-avoidance behavior.
|
||||
pub const HOVER_DWELL_DENSE_WIRES: usize = 50_000;
|
||||
|
||||
/// Keyboard navigation inside the open right-click context menu.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum ContextMenuNav {
|
||||
Up,
|
||||
Down,
|
||||
/// Pick the highlighted row (or the default row when none is highlighted).
|
||||
Enter,
|
||||
/// Pick the next row whose mnemonic letter matches.
|
||||
Mnemonic(char),
|
||||
}
|
||||
|
||||
/// Open multi-functional-grip popup state.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct GripPopup {
|
||||
@@ -518,6 +529,10 @@ pub(super) struct OpenCADStudio {
|
||||
double_click_block_refedit: bool,
|
||||
/// Open ATTEDIT when double-clicking a block with attributes.
|
||||
double_click_block_attedit: bool,
|
||||
/// What a right-click in the drawing area does (SHORTCUTMENU).
|
||||
right_click_mode: settings::RightClickMode,
|
||||
/// Time-sensitive right-click hold threshold, ms (SHORTCUTMENUDURATION).
|
||||
right_click_hold_ms: i32,
|
||||
/// Selected-object count past which grips stop being generated
|
||||
/// (GRIPOBJLIMIT, 0..=32767; 0 = no limit).
|
||||
grip_object_limit: i32,
|
||||
@@ -2149,6 +2164,10 @@ pub enum Message {
|
||||
ZoomWheelReversedChanged(bool),
|
||||
/// Change how far one wheel notch zooms (ZOOMFACTOR, 3..=100).
|
||||
ZoomFactorChanged(i32),
|
||||
/// Options → User Preferences: right-click behaviour (SHORTCUTMENU).
|
||||
RightClickModeChanged(settings::RightClickMode),
|
||||
/// Options → User Preferences: time-sensitive hold threshold, ms.
|
||||
RightClickHoldMsChanged(i32),
|
||||
/// Toggle TEXTEDIT ending after one object (TEXTEDITMODE).
|
||||
TextEditModeChanged(bool),
|
||||
/// Toggle continued dimensions inheriting the base style (DIMCONTINUEMODE).
|
||||
@@ -3277,9 +3296,15 @@ pub enum Message {
|
||||
TextInlineInput(String),
|
||||
/// Commit the editor: create or update the TEXT entity.
|
||||
TextInlineOk,
|
||||
// ── Draw Order context menu ─────────────────────────────────────────
|
||||
/// Toggle the Draw Order sub-items in the viewport context menu.
|
||||
DrawOrderSubmenuToggle,
|
||||
// ── Viewport right-click context menu ───────────────────────────────
|
||||
/// A context-menu row was picked (mouse or keyboard). Closes the menu and
|
||||
/// runs the row's action through the same message the equivalent typed
|
||||
/// input / shortcut would have produced.
|
||||
ContextMenuPick(crate::ui::popup::context_menu::MenuAction),
|
||||
/// Expand / collapse an accordion submenu of the open context menu.
|
||||
ContextMenuSubmenuToggle(crate::ui::popup::context_menu::SubmenuId),
|
||||
/// Keyboard navigation inside the open context menu.
|
||||
ContextMenuNavigate(ContextMenuNav),
|
||||
/// Begin an interactive reference-object pick to move the current
|
||||
/// selection above (`true`) or below (`false`) the picked object.
|
||||
DrawOrderPickRef(bool),
|
||||
@@ -3794,6 +3819,8 @@ impl OpenCADStudio {
|
||||
pick_box: 3,
|
||||
double_click_block_refedit: false,
|
||||
double_click_block_attedit: true,
|
||||
right_click_mode: settings::RightClickMode::ShortcutMenu,
|
||||
right_click_hold_ms: 250,
|
||||
grip_object_limit: settings::DEFAULT_GRIP_OBJECT_LIMIT,
|
||||
ncopy_bind: false,
|
||||
cursor_type: settings::CursorType::Crosshair,
|
||||
|
||||
Reference in new issue
Block a user