forked from 1b-agent/opencadstudio-upstream
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:
1 parent
019422d220
commit
494a872e8d
7 files changed
+565
-237
No files matched your search
+26
-3
@@ -59,7 +59,16 @@ impl PanelId {
|
||||
match self {
|
||||
PanelId::Properties => 250.0,
|
||||
PanelId::BlockPalette => 260.0,
|
||||
PanelId::ExternalReferences => 300.0,
|
||||
PanelId::ExternalReferences => 360.0,
|
||||
}
|
||||
}
|
||||
|
||||
/// Widest a panel may be dragged or sized to. The references table is
|
||||
/// column-rich, so it allows double the shared maximum.
|
||||
fn max_width(self) -> f32 {
|
||||
match self {
|
||||
PanelId::ExternalReferences => DOCK_MAX_W * 2.0,
|
||||
_ => DOCK_MAX_W,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -160,7 +169,7 @@ impl DockState {
|
||||
pub fn width(&self, id: PanelId, win_w: f32) -> f32 {
|
||||
self.settings(id)
|
||||
.width
|
||||
.clamp(DOCK_MIN_W, DOCK_MAX_W.min(win_w * 0.45).max(DOCK_MIN_W))
|
||||
.clamp(DOCK_MIN_W, id.max_width().min(win_w * 0.45).max(DOCK_MIN_W))
|
||||
}
|
||||
|
||||
pub fn auto_collapse(&self, id: PanelId) -> bool {
|
||||
@@ -170,7 +179,7 @@ impl DockState {
|
||||
/// Set the persisted width, clamped.
|
||||
pub fn set_width(&mut self, id: PanelId, width: f32) {
|
||||
let entry = self.panels.entry(id).or_insert_with(|| DockPanel::for_id(id));
|
||||
entry.width = width.clamp(DOCK_MIN_W, DOCK_MAX_W);
|
||||
entry.width = width.clamp(DOCK_MIN_W, id.max_width());
|
||||
}
|
||||
|
||||
/// Reset width to the panel's default.
|
||||
@@ -226,6 +235,20 @@ pub const DOCK_MAX_W: f32 = 600.0;
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn external_references_allows_double_max_width() {
|
||||
let mut state = DockState::default();
|
||||
state.ensure_settings();
|
||||
// Slightly wider default than the 300-era panels, double the maximum.
|
||||
// (The 45%-of-window rule still dominates on narrow windows.)
|
||||
assert_eq!(state.width(PanelId::ExternalReferences, 3000.0), 360.0);
|
||||
state.set_width(PanelId::ExternalReferences, 5000.0);
|
||||
assert_eq!(state.width(PanelId::ExternalReferences, 3000.0), DOCK_MAX_W * 2.0);
|
||||
// Other panels keep the shared maximum.
|
||||
state.set_width(PanelId::BlockPalette, 5000.0);
|
||||
assert_eq!(state.width(PanelId::BlockPalette, 3000.0), DOCK_MAX_W);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn default_docks_each_known_panel_on_an_edge() {
|
||||
let state = DockState::default();
|
||||
|
||||
Reference in new issue
Block a user