forked from 1b-agent/opencadstudio-upstream
feat(layers): draggable Name-column width in the Layer Manager (#359)
A thin divider after the Name header resizes the column by drag (60-640 px, session-persistent), riding the shared modal drag flow. The name elide budget follows the column width, so widening the column reveals long layer names; the hover tooltip stays for overflow. Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
261b699dee
commit
87f40e7544
4 files changed
+58
-22
No files matched your search
@@ -461,6 +461,11 @@ pub(super) struct OpenCADStudio {
|
||||
modal_drag_last: Option<Point>,
|
||||
/// True while the modal title bar is held (a drag is in progress).
|
||||
modal_dragging: bool,
|
||||
/// Layer Manager: dragging the Name-column divider (width follows the
|
||||
/// shared ModalDragMove flow).
|
||||
layer_col_dragging: bool,
|
||||
/// Layer Manager Name column width in px, adjusted by the divider drag.
|
||||
layer_name_col_w: f32,
|
||||
/// How far the user has dragged the modal's corner resize grip from the
|
||||
/// dialog's natural size (added to each modal's default width/height). Reset
|
||||
/// with `modal_offset` so every dialog opens at its own size.
|
||||
@@ -1364,6 +1369,8 @@ pub enum Message {
|
||||
CommandHistoryNext,
|
||||
/// Toggle the dropdown listing the full command-line history.
|
||||
CommandHistoryToggle,
|
||||
/// Start dragging the Layer Manager's Name-column divider.
|
||||
LayerNameColGrab,
|
||||
/// Toggle the persistent literal-space mode (the `>` button): while on,
|
||||
/// every command line behaves as if it started with `>` — Space stays in
|
||||
/// the input instead of submitting. Saved in the user config.
|
||||
@@ -2286,6 +2293,8 @@ impl OpenCADStudio {
|
||||
modal_offset: iced::Vector::ZERO,
|
||||
modal_drag_last: None,
|
||||
modal_dragging: false,
|
||||
layer_col_dragging: false,
|
||||
layer_name_col_w: 130.0,
|
||||
modal_resize: iced::Vector::ZERO,
|
||||
modal_resizing: false,
|
||||
attr_editor_handle: None,
|
||||
|
||||
+11
-2
@@ -3246,10 +3246,18 @@ impl OpenCADStudio {
|
||||
self.modal_drag_last = None;
|
||||
Task::none()
|
||||
}
|
||||
Message::LayerNameColGrab => {
|
||||
// Start a Name-column divider drag; rides ModalDragMove.
|
||||
self.layer_col_dragging = true;
|
||||
self.modal_drag_last = None;
|
||||
Task::none()
|
||||
}
|
||||
Message::ModalDragMove(p) => {
|
||||
if let Some(last) = self.modal_drag_last {
|
||||
let (dx, dy) = (p.x - last.x, p.y - last.y);
|
||||
if self.modal_resizing {
|
||||
if self.layer_col_dragging {
|
||||
self.layer_name_col_w = (self.layer_name_col_w + dx).clamp(60.0, 640.0);
|
||||
} else if self.modal_resizing {
|
||||
// The grip sits bottom-right, so dragging out grows the
|
||||
// box. The delta is added to each dialog's natural size,
|
||||
// so clamp it at zero — dragging in past the natural size
|
||||
@@ -3280,7 +3288,7 @@ impl OpenCADStudio {
|
||||
}
|
||||
}
|
||||
}
|
||||
if self.modal_dragging || self.modal_resizing {
|
||||
if self.modal_dragging || self.modal_resizing || self.layer_col_dragging {
|
||||
self.modal_drag_last = Some(p);
|
||||
}
|
||||
Task::none()
|
||||
@@ -3288,6 +3296,7 @@ impl OpenCADStudio {
|
||||
Message::ModalDragRelease => {
|
||||
self.modal_dragging = false;
|
||||
self.modal_resizing = false;
|
||||
self.layer_col_dragging = false;
|
||||
self.modal_drag_last = None;
|
||||
Task::none()
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ impl OpenCADStudio {
|
||||
}
|
||||
super::super::ModalKind::Layers => {
|
||||
let tab = &self.tabs[self.active_tab];
|
||||
sized(tab.layers.view_window(), 900, 360)
|
||||
sized(tab.layers.view_window(self.layer_name_col_w), 900, 360)
|
||||
}
|
||||
super::super::ModalKind::Plot => {
|
||||
sized(crate::ui::window::plot::view_window(&self.plot_dialog), 760, 540)
|
||||
|
||||
Reference in new issue
Block a user