forked from 1b-agent/opencadstudio-upstream
STRETCH picks its crossing window as two corner points. After the first corner set last_point, Ortho/Polar constrained the opposite corner to an axis through it, collapsing the window to a line and making selection impossible. Add CadCommand::window_corner_pick(); STRETCH returns true for its two window steps, and the viewport skips the ortho/polar (and OTRACK) lock for that point in both the preview and commit paths — the corners are now free. Also render the window like a normal box selection instead of a bare green outline: add SelectionState::preview_box (a hit-test-free marquee), draw it with the shared draw_marquee helper (green crossing fill + stroke), and drive it from the command's new window_first_corner(). Cleared on command end. Co-Authored-By: Claude Opus 4.8 <[email protected]>
54 lines
2.4 KiB
Rust
54 lines
2.4 KiB
Rust
use iced::time::Instant;
|
|
use iced::Point;
|
|
|
|
/// Mouse / selection interaction state for the viewport.
|
|
#[derive(Clone, Default)]
|
|
pub struct SelectionState {
|
|
pub vp_size: (f32, f32),
|
|
pub box_anchor: Option<Point>,
|
|
/// World point under the box-selection anchor, so the anchor can be
|
|
/// re-projected to screen when the camera zooms/pans mid-drag instead of
|
|
/// staying frozen at its original pixel (which selected the wrong area).
|
|
/// (#234)
|
|
pub box_anchor_world: Option<glam::DVec3>,
|
|
pub box_current: Option<Point>,
|
|
pub box_last: Option<(Point, Point)>,
|
|
pub box_crossing: bool,
|
|
pub box_last_crossing: bool,
|
|
/// A preview-only selection marquee `(anchor, current, crossing)` in canvas
|
|
/// pixels, drawn identically to a real box-selection (green crossing fill /
|
|
/// blue window fill) but with NO hit-test behaviour. Commands that pick a
|
|
/// window by point (STRETCH's crossing window) set this so the region reads
|
|
/// like a normal selection instead of a bare outline. (#291)
|
|
pub preview_box: Option<(Point, Point, bool)>,
|
|
pub poly_active: bool,
|
|
pub poly_points: Vec<Point>,
|
|
pub poly_crossing: bool,
|
|
pub poly_last_crossing: bool,
|
|
pub context_menu: Option<Point>,
|
|
/// True while the context menu's Draw Order sub-items are expanded.
|
|
pub draworder_submenu: bool,
|
|
pub last_move_pos: Option<Point>,
|
|
pub left_down: bool,
|
|
pub left_press_pos: Option<Point>,
|
|
pub left_press_time: Option<Instant>,
|
|
pub left_dragging: bool,
|
|
pub right_down: bool,
|
|
pub right_press_pos: Option<Point>,
|
|
pub right_press_time: Option<Instant>,
|
|
pub right_dragging: bool,
|
|
pub right_last_pos: Option<Point>,
|
|
/// World point the current orbit drag revolves around (selection or model
|
|
/// centre), captured when the drag starts so it stays fixed for the whole
|
|
/// gesture. `None` when no orbit is in progress. (#229)
|
|
pub orbit_pivot: Option<glam::DVec3>,
|
|
/// While a command is active, a right-click acts as Enter; the *next*
|
|
/// consecutive right-click opens the context menu instead. This tracks
|
|
/// whether the previous right-click already fired Enter. Reset by any
|
|
/// other interaction (left-click pick, a new command) and on viewport exit.
|
|
pub right_click_entered: bool,
|
|
pub middle_down: bool,
|
|
pub middle_last_pos: Option<Point>,
|
|
pub middle_last_press_time: Option<Instant>,
|
|
}
|