From 3e9fcaed7c935b33a474a8902567688a79dc3afd Mon Sep 17 00:00:00 2001 From: ramox81 <184937705+ramox81@users.noreply.github.com> Date: Wed, 26 Aug 2026 09:50:21 +0300 Subject: [PATCH] fix(properties): align single-line text fields --- src/app/properties.rs | 54 +++++++++++++++++++++++++++++++++++ src/scene/cache/properties.rs | 4 ++- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/app/properties.rs b/src/app/properties.rs index bd7daa3c8..43d3d4633 100644 --- a/src/app/properties.rs +++ b/src/app/properties.rs @@ -1799,6 +1799,60 @@ impl OpenCADStudio { } } + // Single-line text height rows depend on both the + // justification and the active annotation scale. Aligned + // text derives its paper height from the two endpoints, + // while annotative text exposes that paper height and a + // separate calculated model height. + if let acadrust::EntityType::Text(text) = entity { + let aligned = matches!( + text.horizontal_alignment, + acadrust::entities::TextHorizontalAlignment::Aligned + ); + let paper_height = if aligned { + crate::entities::text::text_run_placement(text, doc).height as f64 + } else { + text.height + }; + let annotative = crate::scene::annotative::is_annotative(doc, entity); + for section in sections.iter_mut() { + if let Some(row) = + section.props.iter_mut().find(|row| row.field == "height") + { + if annotative { + row.label = t!("Paper text height").into_owned(); + } + if aligned { + row.value = crate::scene::model::object::PropValue::ReadOnly( + crate::entities::common::format_length(paper_height), + ); + } + } + } + if annotative { + let model_factor = annotation_scale_handle + .and_then(|handle| match doc.objects.get(&handle) { + Some(acadrust::objects::ObjectType::Scale(scale)) => Some( + scale.inverse_factor() + / self.tabs[i].scene.annotation_scale_unit_factor(), + ), + _ => None, + }) + .unwrap_or(self.tabs[i].scene.annotation_scale as f64); + insert_row_after( + &mut sections, + "height", + crate::entities::common::ro_prop( + t!("Model text height").as_ref(), + "model_text_height", + crate::entities::common::format_length( + paper_height * model_factor, + ), + ), + ); + } + } + if !group_names.is_empty() { let label = group_names.join(", "); if let Some(general) = sections.first_mut() { diff --git a/src/scene/cache/properties.rs b/src/scene/cache/properties.rs index fe199e881..67078b2c6 100644 --- a/src/scene/cache/properties.rs +++ b/src/scene/cache/properties.rs @@ -94,7 +94,9 @@ pub fn general_section(entity: &EntityType) -> PropSection { ], }; - if matches!(entity, EntityType::LwPolyline(polyline) if crate::entities::lwpolyline::is_rectangle(polyline)) { + if matches!(entity, EntityType::Text(_)) + || matches!(entity, EntityType::LwPolyline(polyline) if crate::entities::lwpolyline::is_rectangle(polyline)) + { section.props.retain(|prop| prop.field != "handle"); }