forked from 1b-agent/opencadstudio-upstream
Graphic Attributes: faster view, fills on object layer, dock on first show
- The palette view looks fills up through an index of associative fills
that is rebuilt only when the scene's geometry epoch changes, instead
of scanning the drawing twice per frame. The gradient previews are
cached and rebuilt only when the gradient changes.
- New fills go to the layer of the filled object. A checkbox in the
palette menu ("Create fills on the current layer") restores the HATCH
behaviour and is saved in the config. Objects on locked layers are
skipped with a message.
- The palette is no longer part of the default dock layout; it is docked
below Properties the first time it is shown and keeps a place the user
chose. The original dock test is restored.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VgkJN8DEojuPTumAXLHotu
This commit is contained in:
7 files changed
+326
-86
No files matched your search
+13
-12
@@ -123,7 +123,7 @@ pub struct DockState {
|
||||
impl Default for DockState {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
left: vec![PanelId::Properties, PanelId::GraphicAttributes],
|
||||
left: vec![PanelId::Properties],
|
||||
right: vec![PanelId::BlockPalette],
|
||||
panels: BTreeMap::new(),
|
||||
}
|
||||
@@ -159,13 +159,18 @@ impl DockState {
|
||||
] {
|
||||
self.panels.entry(id).or_insert_with(|| DockPanel::for_id(id));
|
||||
}
|
||||
if self.location(PanelId::GraphicAttributes).is_none() {
|
||||
if let Some((side, index)) = self.location(PanelId::Properties) {
|
||||
self.stack_mut(side).insert(index + 1, PanelId::GraphicAttributes);
|
||||
} else {
|
||||
self.left.push(PanelId::GraphicAttributes);
|
||||
}
|
||||
}
|
||||
|
||||
/// Dock `id` directly below Properties (or at the end of the left edge)
|
||||
/// unless it already has a place, which is then kept.
|
||||
pub fn dock_below_properties(&mut self, id: PanelId) {
|
||||
if self.location(id).is_some() {
|
||||
return;
|
||||
}
|
||||
let (side, index) = self
|
||||
.location(PanelId::Properties)
|
||||
.map_or((DockSide::Left, usize::MAX), |(side, index)| (side, index + 1));
|
||||
self.dock(id, side, index);
|
||||
}
|
||||
|
||||
/// Where (if anywhere) a panel is currently docked.
|
||||
@@ -273,10 +278,6 @@ mod tests {
|
||||
fn default_docks_each_known_panel_on_an_edge() {
|
||||
let state = DockState::default();
|
||||
assert_eq!(state.location(PanelId::Properties), Some((DockSide::Left, 0)));
|
||||
assert_eq!(
|
||||
state.location(PanelId::GraphicAttributes),
|
||||
Some((DockSide::Left, 1))
|
||||
);
|
||||
assert_eq!(
|
||||
state.location(PanelId::BlockPalette),
|
||||
Some((DockSide::Right, 0))
|
||||
@@ -302,7 +303,7 @@ mod tests {
|
||||
Some((DockSide::Right, 0))
|
||||
);
|
||||
// It no longer occupies the left edge.
|
||||
assert_eq!(state.left, vec![PanelId::GraphicAttributes]);
|
||||
assert!(state.left.is_empty());
|
||||
assert_eq!(state.right.len(), 2);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user