forked from 1b-agent/opencadstudio-upstream
fix(layers): protect locked entities
Keep locked-layer objects selectable for inspection while suppressing grips, property edits, command mutations, and stale editor writes.
This commit is contained in:
1 parent
ca331fff48
commit
0be9c41773
25 files changed
+524
-118
No files matched your search
@@ -327,6 +327,9 @@ impl Scene {
|
||||
#[cfg_attr(target_arch = "wasm32", allow(dead_code))]
|
||||
pub fn update_entity(&mut self, mut entity: EntityType) -> bool {
|
||||
let handle = entity.common().handle;
|
||||
if self.is_layer_locked(handle) {
|
||||
return false;
|
||||
}
|
||||
let Some(existing) = self.document.get_entity(handle) else {
|
||||
return false;
|
||||
};
|
||||
|
||||
+1
-3
@@ -6412,8 +6412,7 @@ impl Scene {
|
||||
}
|
||||
|
||||
/// True when `handle`'s entity sits on a locked layer. Locked objects stay
|
||||
/// visible and snappable but cannot be selected or modified — callers in
|
||||
/// the pick / modify paths consult this to skip them.
|
||||
/// visible, snappable and selectable, but mutation paths must skip them.
|
||||
pub fn is_layer_locked(&self, handle: Handle) -> bool {
|
||||
self.document
|
||||
.get_entity(handle)
|
||||
@@ -7807,7 +7806,6 @@ impl Scene {
|
||||
));
|
||||
}
|
||||
handles.retain(|&h| self.passes_selection_filter(h));
|
||||
handles.retain(|&h| !self.is_layer_locked(h));
|
||||
handles
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -551,7 +551,7 @@ impl Scene {
|
||||
}
|
||||
|
||||
pub fn copy_entities(&mut self, handles: &[Handle], t: &EntityTransform) -> Vec<Handle> {
|
||||
// Objects on a locked layer can't be copied (they can't be selected).
|
||||
// Objects on a locked layer can be selected but not copied.
|
||||
let clones: Vec<(Handle, EntityType)> = handles
|
||||
.iter()
|
||||
.filter(|&&h| !self.is_layer_locked(h))
|
||||
|
||||
@@ -164,16 +164,6 @@ impl Scene {
|
||||
let Some(e) = self.document.get_entity(h) else {
|
||||
continue;
|
||||
};
|
||||
// Never quick-select objects on a locked layer.
|
||||
if self
|
||||
.document
|
||||
.layers
|
||||
.get(&e.common().layer)
|
||||
.map(|l| l.is_locked())
|
||||
.unwrap_or(false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
let type_ok = type_name.is_none_or(|t| entity_type_name(e) == t);
|
||||
let prop_ok = if !type_ok {
|
||||
true
|
||||
|
||||
Reference in new issue
Block a user