fn layers_sorted(&self, selected: Option<bool>) -> Vec<Vec<LayerId>> {
		// Compute the indices for each layer to be able to sort them
		let mut layers_with_indices: Vec<(Vec<LayerId>, Vec<usize>)> = self
			.active_document()
			.layer_data
			.iter()
			// '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 (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) {
					Err(err) => {
						warn!("layers_sorted: Could not get indices for the layer {:?}: {:?}", path, err);
						None
					}
					Ok(indices) => Some((path, indices)),
				}
			})
			.collect();

		layers_with_indices.sort_by_key(|(_, indices)| indices.clone());
		layers_with_indices.into_iter().map(|(path, _)| path).collect()
	}
/// Returns the paths to all layers in order, optionally including only selected or non
/// selected layers.
Returns the paths to all layers in order, optionally including only selected or non
selected layers.
Returns the paths to all layers in order optionally including only selected or non selected layers .
fn layers_sorted(&self, selected: Option<bool>) -> Vec<Vec<LayerId>> {
		// Compute the indices for each layer to be able to sort them
		let mut layers_with_indices: Vec<(Vec<LayerId>, Vec<usize>)> = self
			.active_document()
			.layer_data
			.iter()
			// '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 (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) {
					Err(err) => {
						warn!("layers_sorted: Could not get indices for the layer {:?}: {:?}", path, err);
						None
					}
					Ok(indices) => Some((path, indices)),
				}
			})
			.collect();
		layers_with_indices.sort_by_key(|(_, indices)| indices.clone());
		layers_with_indices.into_iter().map(|(path, _)| path).collect()
	}
fn layers_sorted ( & self , selected : Option < bool > ) -> Vec < Vec < LayerId > > { // Compute the indices for each layer to be able to sort them let mut layers_with_indices : Vec < ( Vec < LayerId > , Vec < usize > ) > = self . active_document ( ) . layer_data . iter ( ) // '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 (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 ) { Err ( err ) => { warn ! ( " " path err ) ; None } Ok ( indices ) => Some ( ( path , indices ) ) , } } ) . collect ( ) ; layers_with_indices . sort_by_key ( | ( _ , indices ) | indices . clone ( ) ) ; layers_with_indices . into_iter ( ) . map ( | ( path , _ ) | path ) . collect ( ) }
Returns the paths to all layers in order, optionally including only selected or non
selected layers.
Returns the paths to all layers in order optionally including only selected or non selected layers .
&self
selected
Option<bool>
&self
selected
Option<bool>