forked from 1b-agent/opencadstudio-upstream
feat(cursor): add point cursor for active commands
This commit is contained in:
1 parent
b5eabae712
commit
5bca05d913
2 files changed
+18
-3
No files matched your search
@@ -802,6 +802,9 @@ bg={bg_ms:.1}ms n={view_count}"
|
||||
.hover_highlight
|
||||
.map(|h| tab.scene.is_layer_locked(h))
|
||||
.unwrap_or(false);
|
||||
let point_cursor = tab.active_cmd.as_ref().is_some_and(|cmd| {
|
||||
!cmd.needs_entity_pick() && !cmd.is_selection_gathering()
|
||||
});
|
||||
crate::ui::overlay::selection_overlay(
|
||||
std::sync::Arc::clone(&tab.scene.selection),
|
||||
snap_info,
|
||||
@@ -827,6 +830,7 @@ bg={bg_ms:.1}ms n={view_count}"
|
||||
size_percent: self.cursor_size,
|
||||
pick_box: self.pick_box,
|
||||
cursor_type: self.cursor_type,
|
||||
point_mode: point_cursor,
|
||||
color: self.crosshair_color,
|
||||
isometric: self.isometric_drafting,
|
||||
iso_plane: self.iso_plane,
|
||||
|
||||
+14
-3
@@ -69,6 +69,7 @@ pub struct CrosshairOptions {
|
||||
pub isometric: bool,
|
||||
pub iso_plane: IsoPlane,
|
||||
pub snap_angle_deg: f32,
|
||||
pub point_mode: bool,
|
||||
}
|
||||
|
||||
/// Rendering style for the viewport grid.
|
||||
@@ -1469,7 +1470,12 @@ impl canvas::Program<Message> for SelectionCanvas {
|
||||
style: canvas::Style::Solid(color),
|
||||
..Default::default()
|
||||
};
|
||||
let sq = pick_box_half_px(self.crosshair.pick_box);
|
||||
let point_mode = self.crosshair.point_mode;
|
||||
let sq = if point_mode {
|
||||
0.0
|
||||
} else {
|
||||
pick_box_half_px(self.crosshair.pick_box)
|
||||
};
|
||||
let arm = crosshair_arm_px(bounds, self.crosshair.size_percent);
|
||||
let base_angles: [f64; 2] = if self.crosshair.isometric {
|
||||
self.crosshair.iso_plane.angles()
|
||||
@@ -1479,7 +1485,9 @@ impl canvas::Program<Message> for SelectionCanvas {
|
||||
for angle in base_angles {
|
||||
let rad = (angle + self.crosshair.snap_angle_deg as f64).to_radians();
|
||||
let dir = Point::new(rad.cos() as f32, -rad.sin() as f32);
|
||||
let gap = if sq > 0.0 {
|
||||
let gap = if point_mode {
|
||||
9.0
|
||||
} else if sq > 0.0 {
|
||||
sq / dir.x.abs().max(dir.y.abs()).max(1e-6)
|
||||
} else {
|
||||
0.0
|
||||
@@ -1492,7 +1500,10 @@ impl canvas::Program<Message> for SelectionCanvas {
|
||||
});
|
||||
frame.stroke(&arms, stroke.clone());
|
||||
}
|
||||
if sq > 0.0 {
|
||||
if point_mode {
|
||||
let dot = canvas::Path::circle(cp, 1.75);
|
||||
frame.fill(&dot, color);
|
||||
} else if sq > 0.0 {
|
||||
let square = canvas::Path::rectangle(
|
||||
Point::new(cp.x - sq, cp.y - sq),
|
||||
Size::new(sq * 2.0, sq * 2.0),
|
||||
|
||||
Reference in new issue
Block a user