Implement backend part of the layer selection (#172)

* Implement backend part of the layer selection
This commit is contained in:
TrueDoctor
2021-06-09 12:20:50 +02:00
committed by Keavon Chambers
parent 13dd51dbf8
commit 0e8cbad003
11 changed files with 163 additions and 125 deletions
+4 -3
View File
@@ -104,11 +104,12 @@ pub fn export_document() -> Result<(), JsValue> {
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_message(DocumentMessage::ExportDocument)).map_err(convert_error)
}
/// Select a layer from the layer list
/// Update the list of selected layers. The layer paths have to be stored in one array and are separated by LayerId::MAX
#[wasm_bindgen]
pub fn select_layer(path: Vec<LayerId>) -> Result<(), JsValue> {
pub fn select_layers(paths: Vec<LayerId>) -> Result<(), JsValue> {
let paths = paths.split(|id| *id == LayerId::MAX).map(|path| path.to_vec()).collect();
EDITOR_STATE
.with(|editor| editor.borrow_mut().handle_message(DocumentMessage::SelectLayer(path)))
.with(|editor| editor.borrow_mut().handle_message(DocumentMessage::SelectLayers(paths)))
.map_err(convert_error)
}