fj_core/operations/
presentation.rs

1//! Operations to control the presentation of objects
2
3use fj_interop::Color;
4
5use crate::{objects::Region, storage::Handle, Core};
6
7/// Get the color of an object
8pub trait GetColor {
9    /// Get the color of the object
10    fn get_color(&self, core: &mut Core) -> Option<Color>;
11}
12
13impl GetColor for Handle<Region> {
14    fn get_color(&self, core: &mut Core) -> Option<Color> {
15        core.layers.presentation.color.get(self).copied()
16    }
17}
18
19/// Set the color of an object
20pub trait SetColor {
21    /// Set the color of the object
22    fn set_color(&self, color: impl Into<Color>, core: &mut Core);
23}
24
25impl SetColor for Handle<Region> {
26    fn set_color(&self, color: impl Into<Color>, core: &mut Core) {
27        core.layers
28            .presentation
29            .set_color(self.clone(), color.into());
30    }
31}