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
+40 -1

No files matched your search

+2 -1
View File
@@ -1443,7 +1443,8 @@ 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('✓')
|| self.tabs[i]
.scene .scene
.document .document
.get_entity(popup.handle) .get_entity(popup.handle)
+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));
}
}