mirror of
https://github.com/penpot/penpot.git
synced 2025-05-21 22:26:12 +02:00
♻️ Refactor current_shape in rust_wasm
This commit is contained in:
parent
8ed508012e
commit
e45e8158b0
3 changed files with 41 additions and 47 deletions
|
@ -30,4 +30,18 @@ impl<'a> State<'a> {
|
|||
pub fn set_surface(&mut self, surface: skia::Surface) {
|
||||
self.render_state.surface = surface;
|
||||
}
|
||||
|
||||
pub fn use_shape(&'a mut self, id: Uuid) {
|
||||
if !self.shapes.contains_key(&id) {
|
||||
let new_shape = Shape::new(id);
|
||||
self.shapes.insert(id, new_shape);
|
||||
}
|
||||
|
||||
self.current_id = Some(id);
|
||||
self.current_shape = self.shapes.get_mut(&id);
|
||||
}
|
||||
|
||||
pub fn current_shape(&'a mut self) -> Option<&'a mut Shape> {
|
||||
self.current_shape.as_deref_mut()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue