fix(section): preserve selected slice depth

This commit is contained in:
Hakan Seven committed 2026-09-10 17:00:16 +03:00
1 parent 0ad31ece6f
commit 035d31e201
2 files changed
+57 -18

No files matched your search

+19 -18
View File
@@ -1443,24 +1443,25 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
} }
} }
// One-shot action — apply immediately. // One-shot action — apply immediately.
let unchanged = self.tabs[i] let unchanged = item.label.starts_with('✓')
.scene || self.tabs[i]
.document .scene
.get_entity(popup.handle) .document
.is_some_and(|entity| match (item.action, entity) { .get_entity(popup.handle)
(GripMenuAction::ShowFit, acadrust::EntityType::Spline(spline)) => { .is_some_and(|entity| match (item.action, entity) {
!spline.cv_frame_visible (GripMenuAction::ShowFit, acadrust::EntityType::Spline(spline)) => {
&& crate::entities::spline::uses_fit_method(spline) !spline.cv_frame_visible
} && crate::entities::spline::uses_fit_method(spline)
( }
GripMenuAction::ShowControlVertices, (
acadrust::EntityType::Spline(spline), GripMenuAction::ShowControlVertices,
) => { acadrust::EntityType::Spline(spline),
spline.cv_frame_visible ) => {
|| !crate::entities::spline::uses_fit_method(spline) spline.cv_frame_visible
} || !crate::entities::spline::uses_fit_method(spline)
_ => false, }
}); _ => false,
});
if unchanged { if unchanged {
return Task::none(); return Task::none();
} }
+38
View File
@@ -2179,6 +2179,12 @@ impl Grippable for ExtendedEntity {
GripMenuAction::SectionVolume => "Volume", GripMenuAction::SectionVolume => "Volume",
_ => return, _ => return,
}; };
let ExtendedEntityData::SectionObject(data) = &self.data else {
return;
};
if section_kind(self, data) == value {
return;
}
apply_section_prop(self, "ext_section_state", value); apply_section_prop(self, "ext_section_state", value);
} }
} }
@@ -2198,3 +2204,35 @@ impl Transformable for ExtendedEntity {
apply_transform(self, transform); apply_transform(self, transform);
} }
} }
#[cfg(test)]
mod tests {
use super::*;
use acadrust::entities::EntityCommon;
use acadrust::types::Color;
#[test]
fn reselecting_slice_keeps_its_depth() {
let mut entity = ExtendedEntity {
common: EntityCommon::new(),
data: ExtendedEntityData::SectionObject(SectionObjectData {
state: 1,
flags: 5,
name: String::new(),
vertical_direction: Vector3::UNIT_Z,
top_height: 1.0,
bottom_height: 1.0,
indicator_alpha: 70,
indicator_color: Color::from_index(9),
back_line_vertices: Vec::new(),
vertices: vec![Vector3::ZERO, Vector3::new(60.0, 0.0, 0.0)],
settings_handle: Handle::NULL,
}),
};
set_section_slice_metadata(&mut entity, true, 0.25);
entity.apply_grip_menu(SECTION_GRIP_STATE, GripMenuAction::SectionSlice);
assert_eq!(section_slice_depth(&entity), Some(0.25));
}
}