fix(style): new text/mtext/dimension use the current style (#92)

New annotation entities were created at the entity "Standard" default
instead of the document's current style, so making a style current had
no effect on creation.

- Text / MText: seed the new entity (and the MText editor preview) from
  header.current_text_style_name.
- Dimension: commit_entity_handle fills the new dimension's style_name
  from header.current_dimstyle_name, covering every dimension command
  centrally.

Applied only when the entity is still at its default so an explicitly
styled entity is preserved. MLeader and Table styles need their style
tables modelled first and are left for follow-up.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan Seven 2026-06-14 01:15:52 +03:00
commit 92e32243eb
3 changed files with 41 additions and 1 deletions

View file

@ -190,11 +190,22 @@ impl super::OpenCADStudio {
self.tabs[i].scene.bump_geometry();
self.tabs[i].dirty = true;
} else {
let t = Text::with_value(
let mut t = Text::with_value(
&ed.value,
Vector3::new(ed.pos.x as f64, ed.pos.y as f64, ed.pos.z as f64),
)
.with_height(ed.height);
// New text inherits the document's current text style (STYLE), not
// the entity default. See #92.
let cur_style = self.tabs[i]
.scene
.document
.header
.current_text_style_name
.clone();
if !cur_style.is_empty() {
t.style = cur_style;
}
self.push_undo_snapshot(i, "TEXT");
self.commit_entity(EntityType::Text(t));
self.tabs[i].dirty = true;