feat(insert): add docked block palette
Add a searchable block palette with previews, file import, collision-safe nested definitions, and dependency/table-record import. Keep palette thumbnails current across drawing switches and block-definition edits.
This commit is contained in:
parent
67a767e23b
commit
8f009d0058
13 changed files with 1248 additions and 22 deletions
|
|
@ -3141,34 +3141,38 @@ impl OpenCADStudio {
|
|||
/// this drawing doesn't already have. Each recreated record gets a fresh
|
||||
/// handle from the target document so it can't collide with an existing
|
||||
/// one. No-op for same-document pastes (the records already exist). (#129)
|
||||
pub(super) fn merge_clipboard_deps(&mut self, i: usize) {
|
||||
pub(super) fn merge_dependencies(
|
||||
&mut self,
|
||||
i: usize,
|
||||
deps: &crate::app::ClipboardDeps,
|
||||
) {
|
||||
use acadrust::TableEntry;
|
||||
if self.clipboard_deps.is_empty() {
|
||||
if deps.is_empty() {
|
||||
return;
|
||||
}
|
||||
let doc = &mut self.tabs[i].scene.document;
|
||||
for rec in &self.clipboard_deps.layers {
|
||||
for rec in &deps.layers {
|
||||
if !doc.layers.contains(rec.name()) {
|
||||
let mut r = rec.clone();
|
||||
r.set_handle(doc.allocate_handle());
|
||||
let _ = doc.layers.add(r);
|
||||
}
|
||||
}
|
||||
for rec in &self.clipboard_deps.linetypes {
|
||||
for rec in &deps.linetypes {
|
||||
if !doc.line_types.contains(rec.name()) {
|
||||
let mut r = rec.clone();
|
||||
r.set_handle(doc.allocate_handle());
|
||||
let _ = doc.line_types.add(r);
|
||||
}
|
||||
}
|
||||
for rec in &self.clipboard_deps.text_styles {
|
||||
for rec in &deps.text_styles {
|
||||
if !doc.text_styles.contains(rec.name()) {
|
||||
let mut r = rec.clone();
|
||||
r.set_handle(doc.allocate_handle());
|
||||
let _ = doc.text_styles.add(r);
|
||||
}
|
||||
}
|
||||
for rec in &self.clipboard_deps.dim_styles {
|
||||
for rec in &deps.dim_styles {
|
||||
if !doc.dim_styles.contains(rec.name()) {
|
||||
let mut r = rec.clone();
|
||||
r.set_handle(doc.allocate_handle());
|
||||
|
|
@ -3177,6 +3181,11 @@ impl OpenCADStudio {
|
|||
}
|
||||
}
|
||||
|
||||
pub(super) fn merge_clipboard_deps(&mut self, i: usize) {
|
||||
let deps = self.clipboard_deps.clone();
|
||||
self.merge_dependencies(i, &deps);
|
||||
}
|
||||
|
||||
/// Recreate any block definition the pasted INSERTs reference but tab
|
||||
/// `i`'s document lacks (cross-drawing paste), so the block reference
|
||||
/// renders its geometry instead of nothing. No-op for same-document
|
||||
|
|
|
|||
Loading…
Reference in a new issue