diff --git a/client/web/wasm/src/document.rs b/client/web/wasm/src/document.rs index 11c6f222..7e3ef259 100644 --- a/client/web/wasm/src/document.rs +++ b/client/web/wasm/src/document.rs @@ -233,7 +233,7 @@ pub fn set_blend_mode_for_selected_layers(blend_mode_svg_style_name: String) -> "saturation" => BlendMode::Saturation, "color" => BlendMode::Color, "luminosity" => BlendMode::Luminosity, - _ => return Err(convert_error(EditorError::Misc("UnknownBlendMode".to_string())).into()), + _ => return Err(convert_error(EditorError::Misc("UnknownBlendMode".to_string()))), }; EDITOR_STATE.with(|editor| editor.borrow_mut().handle_message(DocumentMessage::SetBlendModeForSelectedLayers(blend_mode)).map_err(convert_error)) diff --git a/core/document/src/response.rs b/core/document/src/response.rs index 419085b9..71dcad76 100644 --- a/core/document/src/response.rs +++ b/core/document/src/response.rs @@ -16,7 +16,7 @@ impl fmt::Display for DocumentResponse { let name = match self { DocumentResponse::DocumentChanged { .. } => "DocumentChanged", DocumentResponse::FolderChanged { .. } => "FolderChanged", - DocumentResponse::CreatedLayer { .. } => "SelectLayer", + DocumentResponse::CreatedLayer { .. } => "CreatedLayer", DocumentResponse::DeletedLayer { .. } => "DeleteLayer", }; diff --git a/core/editor/src/document/document_file.rs b/core/editor/src/document/document_file.rs index b47b35de..0d4f7251 100644 --- a/core/editor/src/document/document_file.rs +++ b/core/editor/src/document/document_file.rs @@ -39,7 +39,7 @@ fn layer_data<'a>(layer_data: &'a mut HashMap, LayerData>, path: &[ } pub fn layer_panel_entry(layer_data: &mut LayerData, layer: &mut Layer, path: Vec) -> LayerPanelEntry { - let blend_mode = layer.blend_mode.clone(); + let blend_mode = layer.blend_mode; let layer_type: LayerType = (&layer.data).into(); let name = layer.name.clone().unwrap_or_else(|| format!("Unnamed {}", layer_type)); let arr = layer.current_bounding_box().unwrap_or([DVec2::ZERO, DVec2::ZERO]); diff --git a/core/editor/src/document/document_message_handler.rs b/core/editor/src/document/document_message_handler.rs index 63b32efa..b14d705c 100644 --- a/core/editor/src/document/document_message_handler.rs +++ b/core/editor/src/document/document_message_handler.rs @@ -118,17 +118,6 @@ impl DocumentMessageHandler { fn layerdata_mut(&mut self, path: &[LayerId]) -> &mut LayerData { self.active_document_mut().layer_data.entry(path.to_vec()).or_insert_with(|| LayerData::new(true)) } - #[allow(dead_code)] - fn create_transform_from_layerdata(&self, path: Vec, responses: &mut VecDeque) { - let layerdata = self.layerdata(&path); - responses.push_back( - DocumentOperation::SetLayerTransform { - path, - transform: layerdata.calculate_transform().to_cols_array(), - } - .into(), - ); - } fn create_document_transform_from_layerdata(&self, viewport_size: &ViewportPosition, responses: &mut VecDeque) { let half_viewport = viewport_size.as_dvec2() / 2.; let layerdata = self.layerdata(&[]); @@ -142,10 +131,10 @@ impl DocumentMessageHandler { ); } - /// Returns the paths to all layers in order, optionally including only selected layers + /// Returns the paths to all layers in order, optionally including only selected or non + /// selected layers. fn layers_sorted(&self, selected: Option) -> Vec> { // Compute the indices for each layer to be able to sort them - // TODO: Replace with drain_filter https://github.com/rust-lang/rust/issues/59618 let mut layers_with_indices: Vec<(Vec, Vec)> = self .active_document() .layer_data @@ -153,7 +142,7 @@ impl DocumentMessageHandler { // 'path.len() > 0' filters out root layer since it has no indices .filter_map(|(path, data)| (!path.is_empty() && (data.selected == selected.unwrap_or(data.selected))).then(|| path.clone())) .filter_map(|path| { - // Currently it is possible that layer_data contains layers that are don't actually exist + // Currently it is possible that layer_data contains layers that are don't actually exist (has been partially fixed in #281) // and thus indices_for_path can return an error. We currently skip these layers and log a warning. // Once this problem is solved this code can be simplified match self.active_document().document.indices_for_path(&path) { @@ -180,7 +169,8 @@ impl DocumentMessageHandler { self.layers_sorted(Some(true)) } - /// Returns the paths to all selected layers in order + /// Returns the paths to all non_selected layers in order + #[allow(dead_code)] // used for test cases pub fn non_selected_layers_sorted(&self) -> Vec> { self.layers_sorted(Some(false)) }