mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-27 14:18:29 +00:00
Layers: a repeated Locate reveals the row it already highlighted
Running Locate Object or Locate Layer again on the row it already highlighted wrote the same highlight, so the Layers panel did not open the layers around the row or scroll to it: a sublayer whose layer was closed since stayed hidden. layer.locate now leaves a one-time request on the document (DocState::locate_reveal) that the panel takes on its next frame, opening the layers around the located row and scrolling to it whether or not the highlight changed. The request is not saved and adds no undo step, and the panel drops it when the row is no longer highlighted.
This commit is contained in:
@@ -132,7 +132,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Locate Object",
|
||||
["Window", "Layers"],
|
||||
None,
|
||||
"{id?, layersOnly?} (default: the last selected object) highlight the object's row; the Layers panel opens the layers around it and scrolls to it → {id, ancestry: [layer…, id]}. layersOnly (default false; the panel sends true while Show Layers Only is on, as Locate Layer) highlights the innermost layer or sublayer holding the object instead, or a layer id itself → {id: layer, objectId, ancestry: [layer…]}",
|
||||
"{id?, layersOnly?} (default: the last selected object) highlight the object's row; the Layers panel opens the layers around it and scrolls to it, also when the row was already highlighted →{id, ancestry: [layer…, id]}. layersOnly (default false; the panel sends true while Show Layers Only is on, as Locate Layer) highlights the innermost layer or sublayer holding the object instead, or a layer id itself → {id: layer, objectId, ancestry: [layer…]}",
|
||||
has_doc,
|
||||
locate
|
||||
),
|
||||
@@ -446,6 +446,7 @@ fn locate(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
}
|
||||
let row = ancestry.last().copied().ok_or(EngineError::NoNode(id))?;
|
||||
st.layer_rows = vec![row];
|
||||
st.locate_reveal = Some(row);
|
||||
st.revision += 1;
|
||||
let ancestry: Vec<u64> = ancestry.iter().map(|i| i.0).collect();
|
||||
Ok(if layers_only { json!({ "id": row.0, "objectId": id.0, "ancestry": ancestry }) } else { json!({ "id": id.0, "ancestry": ancestry }) })
|
||||
|
||||
Reference in New Issue
Block a user