Layer opacity (#312)

Closes #187

* Add layer opacity input

* Improve Rust code cleanliness
This commit is contained in:
Keavon Chambers
2021-07-27 23:15:23 -07:00
committed by GitHub
parent 8c1532b0eb
commit edfbc27534
9 changed files with 86 additions and 18 deletions

View File

@@ -412,15 +412,22 @@ impl Document {
}
Operation::SetLayerBlendMode { path, blend_mode } => {
self.mark_as_dirty(path)?;
self.layer_mut(&path).unwrap().blend_mode = *blend_mode;
self.layer_mut(path)?.blend_mode = *blend_mode;
let path = path.as_slice()[..path.len() - 1].to_vec();
Some(vec![DocumentResponse::DocumentChanged, DocumentResponse::FolderChanged { path }])
}
Operation::SetLayerOpacity { path, opacity } => {
self.mark_as_dirty(path)?;
self.layer_mut(path)?.opacity = *opacity;
let path = path.as_slice()[..path.len() - 1].to_vec();
Some(vec![DocumentResponse::DocumentChanged, DocumentResponse::FolderChanged { path }])
}
Operation::FillLayer { path, color } => {
let layer = self.layer_mut(path).unwrap();
layer.style.set_fill(layers::style::Fill::new(*color));
self.layer_mut(path)?.style.set_fill(layers::style::Fill::new(*color));
self.mark_as_dirty(path)?;
Some(vec![DocumentResponse::DocumentChanged])
}