forked from 1b-agent/opencadstudio-upstream
feat(statusbar): selection cycling shows a pick list, adds to selection
Replace the repeat-click cycling with a list box: when a click lands on two or more overlapping objects (cycling on), a small list of the candidates opens at the cursor. Picking a row adds that object to the current selection (accumulate); clicking outside dismisses it. A single object under the cursor falls through to the normal click. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
ac042c5dbf
commit
bcbda65746
5 files changed
+137
-28
No files matched your search
+9
-5
@@ -183,11 +183,11 @@ pub(super) struct OpenCADStudio {
|
||||
clean_screen: bool,
|
||||
/// Quick Properties: show a compact floating property panel on selection.
|
||||
quick_properties: bool,
|
||||
/// Selection cycling: repeated clicks at one spot step through the
|
||||
/// overlapping objects there instead of accumulating the selection.
|
||||
/// Selection cycling: clicking where objects overlap opens a list box
|
||||
/// to pick which one; the pick is added to the current selection.
|
||||
selection_cycling: bool,
|
||||
/// Cycling cursor: (screen point, ordered candidates, current index).
|
||||
cycle_state: Option<(iced::Point, Vec<acadrust::Handle>, usize)>,
|
||||
/// When set, the cycling list box is open: (canvas point, candidates).
|
||||
cycle_candidates: Option<(iced::Point, Vec<acadrust::Handle>)>,
|
||||
/// Which status-bar pills the user has chosen to show (persisted).
|
||||
statusbar_config: crate::ui::statusbar_config::StatusBarConfig,
|
||||
/// Whether Tangent snap was enabled before a tangent-pick command started.
|
||||
@@ -765,6 +765,10 @@ pub enum Message {
|
||||
ToggleQuickProperties,
|
||||
/// Toggle selection cycling for overlapping objects.
|
||||
ToggleSelectionCycling,
|
||||
/// Add an object from the selection-cycling list box to the selection.
|
||||
CycleSelect(acadrust::Handle),
|
||||
/// Dismiss the selection-cycling list box without picking.
|
||||
CycleCancel,
|
||||
/// Toggle the selection-filter type picker open/closed.
|
||||
ToggleSelectionFilterPopup,
|
||||
/// Close the selection-filter type picker.
|
||||
@@ -1245,7 +1249,7 @@ impl OpenCADStudio {
|
||||
clean_screen: false,
|
||||
quick_properties: false,
|
||||
selection_cycling: false,
|
||||
cycle_state: None,
|
||||
cycle_candidates: None,
|
||||
pre_cmd_tangent: None,
|
||||
ortho_mode: false,
|
||||
polar_mode: false,
|
||||
|
||||
+22
-23
@@ -2910,9 +2910,11 @@ impl OpenCADStudio {
|
||||
let all_wires = self.tabs[i].scene.hit_test_wires();
|
||||
let vp_mat = self.tabs[i].scene.camera.borrow().view_proj(bounds);
|
||||
|
||||
// Selection cycling: step through overlapping objects
|
||||
// under the cursor on repeated clicks at the same spot.
|
||||
// Gated behind the toggle, so default picking is unchanged.
|
||||
// Selection cycling: where two or more objects
|
||||
// overlap, open a list box to pick which one; a
|
||||
// single object falls through to the normal click.
|
||||
// Gated behind the toggle, so default picking is
|
||||
// unchanged when off.
|
||||
let mut handled_by_cycling = false;
|
||||
if self.selection_cycling {
|
||||
let cands: Vec<Handle> = scene::hit_test::click_hits_all(
|
||||
@@ -2925,25 +2927,9 @@ impl OpenCADStudio {
|
||||
.filter_map(|s| Scene::handle_from_wire_name(s))
|
||||
.filter(|&h| self.tabs[i].scene.passes_selection_filter(h))
|
||||
.collect();
|
||||
if !cands.is_empty() {
|
||||
let same =
|
||||
self.cycle_state.as_ref().map_or(false, |(pt, list, _)| {
|
||||
(pt.x - p.x).abs() < 3.0
|
||||
&& (pt.y - p.y).abs() < 3.0
|
||||
&& *list == cands
|
||||
});
|
||||
let idx = if same {
|
||||
(self.cycle_state.as_ref().unwrap().2 + 1) % cands.len()
|
||||
} else {
|
||||
0
|
||||
};
|
||||
let handle = cands[idx];
|
||||
self.cycle_state = Some((p, cands, idx));
|
||||
self.tabs[i].scene.deselect_all();
|
||||
self.tabs[i].scene.select_entity(handle, false);
|
||||
self.tabs[i].scene.expand_selection_for_groups(&[handle]);
|
||||
self.refresh_properties();
|
||||
selection_just_completed = true;
|
||||
if cands.len() >= 2 {
|
||||
// Overlap: open the list box at the cursor.
|
||||
self.cycle_candidates = Some((p_full, cands));
|
||||
handled_by_cycling = true;
|
||||
}
|
||||
}
|
||||
@@ -3644,7 +3630,20 @@ impl OpenCADStudio {
|
||||
}
|
||||
Message::ToggleSelectionCycling => {
|
||||
self.selection_cycling ^= true;
|
||||
self.cycle_state = None;
|
||||
self.cycle_candidates = None;
|
||||
Task::none()
|
||||
}
|
||||
Message::CycleSelect(handle) => {
|
||||
// Add the picked object to the current selection (accumulate).
|
||||
self.cycle_candidates = None;
|
||||
let i = self.active_tab;
|
||||
self.tabs[i].scene.select_entity(handle, false);
|
||||
self.tabs[i].scene.expand_selection_for_groups(&[handle]);
|
||||
self.refresh_properties();
|
||||
Task::none()
|
||||
}
|
||||
Message::CycleCancel => {
|
||||
self.cycle_candidates = None;
|
||||
Task::none()
|
||||
}
|
||||
Message::ToggleSelectionFilterPopup => {
|
||||
|
||||
@@ -1014,6 +1014,24 @@ impl OpenCADStudio {
|
||||
}
|
||||
}
|
||||
|
||||
// Selection-cycling list box: pick among overlapping objects.
|
||||
if let Some((pt, cands)) = &self.cycle_candidates {
|
||||
if !tab.is_start {
|
||||
let items: Vec<(acadrust::Handle, String)> = cands
|
||||
.iter()
|
||||
.filter_map(|&h| {
|
||||
tab.scene.document.get_entity(h).map(|e| {
|
||||
(h, crate::entities::traits::entity_type_name(e).to_string())
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
if !items.is_empty() {
|
||||
viewport_stack = viewport_stack
|
||||
.push(crate::ui::cycle_popup::cycle_popup_overlay(*pt, items));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Right-click context menu. Lives inside the viewport stack so
|
||||
// the cursor position (canvas-relative) anchors the menu under
|
||||
// the cursor instead of drifting into window-relative space.
|
||||
|
||||
Reference in new issue
Block a user