fix(properties): align single-line text fields
This commit is contained in:
parent
fff811577b
commit
3e9fcaed7c
2 changed files with 57 additions and 1 deletions
|
|
@ -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() {
|
if !group_names.is_empty() {
|
||||||
let label = group_names.join(", ");
|
let label = group_names.join(", ");
|
||||||
if let Some(general) = sections.first_mut() {
|
if let Some(general) = sections.first_mut() {
|
||||||
|
|
|
||||||
4
src/scene/cache/properties.rs
vendored
4
src/scene/cache/properties.rs
vendored
|
|
@ -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");
|
section.props.retain(|prop| prop.field != "handle");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue