feat(xref): row selection, resizable columns, tree view, and find-replace

Single, multi, and range row selection, resizable table columns, hierarchical tree presentation, and find-and-replace through the command line.
This commit is contained in:
Karim Jerbi committed 2026-09-15 23:56:31 +01:00
1 parent 019422d220
commit 494a872e8d
7 files changed
+565 -237

No files matched your search

+7 -31
View File
@@ -638,6 +638,11 @@ pub(super) fn on_ribbon_tool_click(&mut self, tool_id: String, event: ModuleEven
iced::Task::none()
}
DockMsg::DragMove(point) => {
// NOTE: xref column drags intentionally do NOT ride this
// path: its points live in workspace space while the header
// tracker reports header-local points, and mixing the two
// produced a one-time jump plus a stuck drag. Column moves
// arrive via Message::XrefColMove only.
if self.dock_dragging.is_some() {
let avail = self.tabs[self.active_tab].scene.selection.borrow().vp_size.1;
let side = if point.x < self.win_size.0 * 0.5 {
@@ -679,6 +684,8 @@ pub(super) fn on_ribbon_tool_click(&mut self, tool_id: String, event: ModuleEven
self.dock_resizing = None;
self.dock_drag_last = None;
self.dock_drag_target = None;
self.xref_col_drag = None;
self.xref_col_last = None;
iced::Task::none()
}
}
@@ -1271,37 +1278,6 @@ pub(super) fn on_ribbon_tool_click(&mut self, tool_id: String, event: ModuleEven
}
self.refresh_xref_manager();
}
/// Apply Find & Replace across all direct references (same engine fn
/// as `XREF Path Find`).
pub(crate) fn xref_manager_find_replace_apply(&mut self) {
if cfg!(target_arch = "wasm32") {
self.command_line.push_error(crate::t!("Reference changes are not available on web — the reference list is read-only.").as_ref());
return;
}
let i = self.active_tab;
let old = self.xref_manager.find_input.clone();
let new = self.xref_manager.replace_input.clone();
if old.is_empty() || new.is_empty() {
self.command_line
.push_error(crate::t!("Usage: XREF Path Find <old> <new>").as_ref());
return;
}
self.push_undo_snapshot(i, "XREF-PATH");
let n = crate::io::xref::replace_path_prefix(
&mut self.tabs[i].scene.document,
&old,
&new,
);
self.command_line.push_output(crate::tf!(
"XREF: updated {} reference(s).",
n
).as_ref());
if n > 0 {
self.post_ref_op(i);
}
self.refresh_xref_manager();
}
}
#[cfg(test)]
+45 -12
View File
@@ -2148,13 +2148,50 @@ impl OpenCADStudio {
Task::none()
}
Message::XrefManagerSelect(index) => {
self.xref_manager.toggle_select(index);
use crate::ui::window::xref_manager::SelectExtend;
// Normal GUI list behavior off the globally tracked
// modifiers (same source as the layer list): plain click
// selects one row, Ctrl/Cmd toggles, Shift extends a range.
let extend = if self.ctrl_down {
SelectExtend::Toggle
} else if self.shift_down {
SelectExtend::Range
} else {
SelectExtend::Single
};
self.xref_manager.click_select(index, extend);
Task::none()
}
Message::XrefRowRightClick(index) => {
self.xref_manager.right_click_select(index);
Task::none()
}
Message::XrefManagerToggleTree => {
self.xref_manager.toggle_tree();
Task::none()
}
Message::XrefColGrab(i) => {
// Start a table-column divider drag; moves arrive via the
// header's mouse_area (XrefColMove), like the Layers
// Name-column divider rides ModalDragMove.
self.xref_col_drag = Some(i);
self.xref_col_last = None;
Task::none()
}
Message::XrefColMove(p) => {
if let Some(i) = self.xref_col_drag {
if let Some(last) = self.xref_col_last {
self.xref_manager.drag_col_by(i, p.x - last.x);
}
self.xref_col_last = Some(p);
}
Task::none()
}
Message::XrefColRelease => {
self.xref_col_drag = None;
self.xref_col_last = None;
Task::none()
}
Message::XrefManagerTogglePreview => {
self.xref_manager.show_preview ^= true;
Task::none()
@@ -2255,17 +2292,13 @@ impl OpenCADStudio {
self.xref_manager_path_apply();
Task::none()
}
Message::XrefManagerFindInput(text) => {
self.xref_manager.find_input = text;
Task::none()
}
Message::XrefManagerReplaceInput(text) => {
self.xref_manager.replace_input = text;
Task::none()
}
Message::XrefManagerFindReplaceApply => {
self.xref_manager_find_replace_apply();
Task::none()
Message::XrefFindReplacePrompt => {
// No fields in the panel: prefill the command line so the
// existing `XREF Path Find <old> <new>` parsing runs it.
self.command_line.input = "XREF Path Find ".to_string();
self.command_line.autocomplete_cursor = None;
self.command_line.cancel_history_navigation();
return self.focus_cmd_input();
}
Message::LayerStateManagerOpen => {