From 5f6c4029e95c1000dd5845754786f4a94621f114 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Sun, 14 Jun 2026 09:59:12 +0300 Subject: [PATCH] fix(mleader): new multileader inherits the current MLeader style (#94) A new multileader was built from defaults and ignored the current MLeaderStyle, so the style editor's settings had no effect on it (the renderer reads the entity's own fields, not the style). commit_entity_handle now copies the style's content/path type, text attachment/alignment/angle, colours, sizes, scale and landing into the new entity (enum types round-trip through i16 since the entity and style enums are distinct). Text styles already render correctly and tables already resolve their style live via table_style_handle, so no change was needed there. Co-Authored-By: Claude Opus 4.8 --- src/app/properties.rs | 57 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 9 deletions(-) diff --git a/src/app/properties.rs b/src/app/properties.rs index e08d94a7..c2c204d2 100644 --- a/src/app/properties.rs +++ b/src/app/properties.rs @@ -571,17 +571,56 @@ impl OpenCADStudio { .current_mleader_style_name .clone(); if !name.is_empty() { - ml.style_handle = - self.tabs[i].scene.document.objects.iter().find_map(|(h, o)| { - match o { - acadrust::objects::ObjectType::MultiLeaderStyle(s) - if s.name.eq_ignore_ascii_case(&name) => - { - Some(*h) - } - _ => None, + let found = + self.tabs[i].scene.document.objects.iter().find_map(|(h, o)| match o { + acadrust::objects::ObjectType::MultiLeaderStyle(s) + if s.name.eq_ignore_ascii_case(&name) => + { + Some((*h, s.clone())) } + _ => None, }); + if let Some((h, s)) = found { + ml.style_handle = Some(h); + // Inherit the style's settings so a new multileader + // reflects the current MLeaderStyle (the renderer reads + // these entity fields). See #94. + // The entity and style enums are distinct types with + // matching discriminants — round-trip through i16. + ml.content_type = (s.content_type as i16).into(); + ml.path_type = (s.path_type as i16).into(); + ml.line_color = s.line_color; + ml.line_type_handle = s.line_type_handle; + ml.line_weight = s.line_weight; + ml.enable_landing = s.enable_landing; + ml.enable_dogleg = s.enable_dogleg; + ml.dogleg_length = s.landing_distance; + ml.arrowhead_handle = s.arrowhead_handle; + ml.arrowhead_size = s.arrowhead_size; + ml.text_style_handle = s.text_style_handle; + ml.text_color = s.text_color; + ml.text_frame = s.text_frame; + ml.text_height = s.text_height; + ml.context.text_height = s.text_height; + ml.text_left_attachment = (s.text_left_attachment as i16).into(); + ml.text_right_attachment = (s.text_right_attachment as i16).into(); + ml.text_top_attachment = (s.text_top_attachment as i16).into(); + ml.text_bottom_attachment = (s.text_bottom_attachment as i16).into(); + ml.text_attachment_direction = + (s.text_attachment_direction as i16).into(); + ml.text_alignment = (s.text_alignment as i16).into(); + ml.text_angle_type = (s.text_angle_type as i16).into(); + ml.block_content_handle = s.block_content_handle; + ml.block_content_color = s.block_content_color; + ml.block_connection_type = (s.block_content_connection as i16).into(); + ml.block_rotation = s.block_content_rotation; + ml.block_scale = acadrust::types::Vector3::new( + s.block_content_scale_x, + s.block_content_scale_y, + s.block_content_scale_z, + ); + ml.scale_factor = s.scale_factor; + } } } acadrust::EntityType::Table(t) if t.table_style_handle.is_none() => {