mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-23 05:38:11 +08:00
Blend modes (#252)
* Add backend for selecting layer blend mode * Change dropdown input to support callback on change * Add debug messages * Fix canvas update for blend-modes * Finish up and polish blend modes implementations * Add changes from code review Co-authored-by: Keavon Chambers <keavon@keavon.com> Co-authored-by: Dennis Kobert <dennis@kobert.dev>
This commit is contained in:
co-authored by
Keavon Chambers
Dennis Kobert
parent
63e3b5c604
commit
8f9168bfe5
@@ -221,7 +221,9 @@ impl Document {
|
||||
/// Deletes the layer specified by `path`.
|
||||
pub fn delete(&mut self, path: &[LayerId]) -> Result<(), DocumentError> {
|
||||
let (path, id) = split_path(path)?;
|
||||
let _ = self.layer_mut(path).map(|x| x.cache_dirty = true);
|
||||
if let Ok(layer) = self.layer_mut(path) {
|
||||
layer.cache_dirty = true;
|
||||
}
|
||||
self.document_folder_mut(path)?.as_folder_mut()?.remove_layer(id)?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -393,13 +395,21 @@ impl Document {
|
||||
Some(responses)
|
||||
}
|
||||
Operation::ToggleVisibility { path } => {
|
||||
let _ = self.layer_mut(&path).map(|layer| {
|
||||
if let Ok(layer) = self.layer_mut(&path) {
|
||||
layer.visible = !layer.visible;
|
||||
layer.cache_dirty = true;
|
||||
});
|
||||
}
|
||||
let path = path.as_slice()[..path.len() - 1].to_vec();
|
||||
Some(vec![DocumentResponse::DocumentChanged, DocumentResponse::FolderChanged { path }])
|
||||
}
|
||||
Operation::SetLayerBlendMode { path, blend_mode } => {
|
||||
self.mark_as_dirty(path)?;
|
||||
self.layer_mut(&path).unwrap().blend_mode = *blend_mode;
|
||||
|
||||
let path = path.as_slice()[..path.len() - 1].to_vec();
|
||||
|
||||
Some(vec![DocumentResponse::DocumentChanged, DocumentResponse::FolderChanged { path: path.clone() }])
|
||||
}
|
||||
Operation::FillLayer { path, color } => {
|
||||
let layer = self.layer_mut(path).unwrap();
|
||||
layer.style.set_fill(layers::style::Fill::new(*color));
|
||||
|
||||
Reference in New Issue
Block a user