forked from 1b-agent/opencadstudio-upstream
feat(props): editable block Name row + collapsible XYZ groups
- Block reference Name (Misc) is editable: the dropdown re-points the insert to another definition; typing a new name renames the definition everywhere (record re-key, Block marker, every INSERT reference). Anonymous (*) and xref blocks stay read-only, with the same guards added to Scene::rename_block. - Custom single-control dropdown (text field + caret) built on the shared floating_below overlay so the list always opens downward, unlike iced's space-based menu placement. - Consecutive "<Base> X/Y/Z" rows (Position, Scale, Start, Center, ...) collapse into one expandable summary row across all entities; the expand state persists across rebuilds and selection changes. - The BEDIT block tab no longer offers the layout Rename/Delete context menu. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
47f3409588
commit
b5dbef5776
10 files changed
+583
-51
No files matched your search
@@ -20,6 +20,9 @@ impl OpenCADStudio {
|
||||
// closes, matching the deselect / reselect / click-away expectation.
|
||||
let color_palette_open = self.tabs[i].properties.color_palette_open;
|
||||
let edit_buf = std::mem::take(&mut self.tabs[i].properties.edit_buf);
|
||||
// Expanded coordinate groups persist across rebuilds AND selection
|
||||
// changes — it's a per-user view preference, not per-entity state.
|
||||
let expanded_groups = std::mem::take(&mut self.tabs[i].properties.expanded_groups);
|
||||
// Which entities the previous panel was built for — an uncommitted
|
||||
// edit buffer only survives a rebuild for the *same* selection.
|
||||
let prev_handles = std::mem::take(&mut self.tabs[i].properties.source_handles);
|
||||
@@ -497,6 +500,41 @@ impl OpenCADStudio {
|
||||
let src_mm = if src == 0 { 1.0 } else { insunits_to_mm(src) };
|
||||
let factor = if host_mm.abs() > 1e-12 { src_mm / host_mm } else { 1.0 };
|
||||
set_row(&mut sections, "unit_factor", format!("{factor:.4}"));
|
||||
|
||||
// Name row: editable for regular blocks — pick an
|
||||
// existing definition to re-point this reference, or
|
||||
// type a new name to rename the definition (every
|
||||
// insert of it follows). Anonymous (*) and
|
||||
// xref(-dependent) blocks keep the read-only row.
|
||||
let regular = |br: &acadrust::tables::BlockRecord| {
|
||||
!br.is_anonymous()
|
||||
&& !br.flags.is_xref
|
||||
&& !br.name.contains('|')
|
||||
};
|
||||
let editable = doc
|
||||
.block_records
|
||||
.get(&ins.block_name)
|
||||
.map(®ular)
|
||||
.unwrap_or(false);
|
||||
if editable {
|
||||
let mut options: Vec<String> = doc
|
||||
.block_records
|
||||
.iter()
|
||||
.filter(|br| regular(br))
|
||||
.map(|br| br.name.clone())
|
||||
.collect();
|
||||
options.sort_by(|a, b| {
|
||||
a.to_lowercase().cmp(&b.to_lowercase())
|
||||
});
|
||||
set_row_value(
|
||||
&mut sections,
|
||||
"block",
|
||||
crate::scene::model::object::PropValue::EditChoice {
|
||||
value: ins.block_name.clone(),
|
||||
options,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
// Underlay: name + path from the referenced definition.
|
||||
acadrust::EntityType::Underlay(ul) => {
|
||||
@@ -919,6 +957,7 @@ impl OpenCADStudio {
|
||||
} else {
|
||||
Default::default()
|
||||
};
|
||||
panel.expanded_groups = expanded_groups;
|
||||
panel.source_handles = new_handles;
|
||||
panel.prop_vertex = prop_vertex;
|
||||
panel
|
||||
@@ -1455,6 +1494,16 @@ fn merge_prop_value(
|
||||
selected: VARIES_LABEL.into(),
|
||||
options: options.clone(),
|
||||
},
|
||||
(
|
||||
PropValue::EditChoice { options, .. },
|
||||
PropValue::EditChoice {
|
||||
options: other_options,
|
||||
..
|
||||
},
|
||||
) if options == other_options => PropValue::EditChoice {
|
||||
value: VARIES_LABEL.into(),
|
||||
options: options.clone(),
|
||||
},
|
||||
(PropValue::EditText(_), PropValue::EditText(_)) => {
|
||||
PropValue::EditText(VARIES_LABEL.into())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user