forked from 1b-agent/opencadstudio-upstream
fix(text): respect object annotative state
This commit is contained in:
1 parent
0c5d6af1d0
commit
6aaf1ff123
3 files changed
+68
-9
No files matched your search
+37
-1
@@ -1108,6 +1108,14 @@ impl super::OpenCADStudio {
|
||||
let Some(ed) = self.mtext_editor.take() else { return false };
|
||||
let body_empty = ed.content.text().trim().is_empty();
|
||||
let mut mt = ed.build_mtext();
|
||||
let annotative = ed.editing.is_none()
|
||||
&& crate::scene::annotative::text_style_is_annotative(
|
||||
&self.tabs[i].scene.document,
|
||||
&mt.style,
|
||||
);
|
||||
if annotative {
|
||||
mt.is_annotative = true;
|
||||
}
|
||||
if body_empty {
|
||||
// Empty content: drop a new entity; leave an edited one untouched.
|
||||
self.refresh_properties();
|
||||
@@ -1141,7 +1149,17 @@ impl super::OpenCADStudio {
|
||||
// Align new MText to the active UCS (text runs along the UCS X axis).
|
||||
mt.rotation = self.tabs[i].ucs_rotation_angle();
|
||||
self.push_undo_snapshot(i, "MTEXT");
|
||||
self.commit_entity(EntityType::MText(mt));
|
||||
let handle = self.commit_entity_handle(EntityType::MText(mt));
|
||||
if annotative {
|
||||
let scale = self.tabs[i].scene.current_annotation_scale_handle();
|
||||
if let (Some(handle), Some(scale)) = (handle, scale) {
|
||||
crate::scene::annotative::create_annotation_context(
|
||||
&mut self.tabs[i].scene.document,
|
||||
handle,
|
||||
scale,
|
||||
);
|
||||
}
|
||||
}
|
||||
self.tabs[i].dirty = true;
|
||||
}
|
||||
self.refresh_properties();
|
||||
@@ -1163,6 +1181,14 @@ impl super::OpenCADStudio {
|
||||
),
|
||||
None => return,
|
||||
};
|
||||
let annotative = editing.is_none()
|
||||
&& crate::scene::annotative::text_style_is_annotative(
|
||||
&self.tabs[i].scene.document,
|
||||
&mt.style,
|
||||
);
|
||||
if annotative {
|
||||
mt.is_annotative = true;
|
||||
}
|
||||
if body_empty {
|
||||
return;
|
||||
}
|
||||
@@ -1195,6 +1221,16 @@ impl super::OpenCADStudio {
|
||||
self.push_undo_snapshot(i, "MTEXT");
|
||||
let handle = self.commit_entity_handle(EntityType::MText(mt));
|
||||
self.tabs[i].dirty = true;
|
||||
if annotative {
|
||||
let scale = self.tabs[i].scene.current_annotation_scale_handle();
|
||||
if let (Some(handle), Some(scale)) = (handle, scale) {
|
||||
crate::scene::annotative::create_annotation_context(
|
||||
&mut self.tabs[i].scene.document,
|
||||
handle,
|
||||
scale,
|
||||
);
|
||||
}
|
||||
}
|
||||
// Bind the editor to the fresh entity so the next Apply updates it.
|
||||
if let (Some(h), Some(ed)) = (handle, self.mtext_editor.as_mut()) {
|
||||
ed.editing = Some(h);
|
||||
|
||||
+15
-1
@@ -227,10 +227,24 @@ impl super::OpenCADStudio {
|
||||
if !cur_style.is_empty() {
|
||||
t.style = cur_style;
|
||||
}
|
||||
let annotative = crate::scene::annotative::text_style_is_annotative(
|
||||
&self.tabs[i].scene.document,
|
||||
&t.style,
|
||||
);
|
||||
// Align new text to the active UCS (baseline along the UCS X axis).
|
||||
t.rotation = self.tabs[i].ucs_rotation_angle();
|
||||
self.push_undo_snapshot(i, "TEXT");
|
||||
self.commit_entity(EntityType::Text(t));
|
||||
let handle = self.commit_entity_handle(EntityType::Text(t));
|
||||
if annotative {
|
||||
let scale = self.tabs[i].scene.current_annotation_scale_handle();
|
||||
if let (Some(handle), Some(scale)) = (handle, scale) {
|
||||
crate::scene::annotative::create_annotation_context(
|
||||
&mut self.tabs[i].scene.document,
|
||||
handle,
|
||||
scale,
|
||||
);
|
||||
}
|
||||
}
|
||||
self.tabs[i].dirty = true;
|
||||
}
|
||||
self.refresh_properties();
|
||||
|
||||
Reference in new issue
Block a user