wplot/sys/stroke_brush/
changer.rs

1/// Internal namespace.
2pub( crate ) mod private
3{
4  use crate::protected::*;
5
6  /// ChangerInterface of brush stroke.
7  #[ allow( dead_code ) ]
8  #[ derive( Debug, Clone ) ]
9  pub struct StrokeBrushChanger
10  {
11    pub( crate ) id : Id,
12    pub( crate ) context_changer : ContextChanger,
13  }
14
15  impl StrokeBrushChanger
16  {
17
18    /// Constructor.
19    #[ inline ]
20    pub( crate ) fn _new( mut context_changer : ContextChanger ) -> Self
21    {
22      let id = &mut context_changer.stroke;
23      if id.is_none()
24      {
25        *id = Some( Id::new::< StrokeBrush >() );
26        StrokeBrushChangeNew::new( context_changer.stroke.unwrap() ).add_to( &mut context_changer );
27      }
28      let id = context_changer.stroke.unwrap();
29      Self
30      {
31        id,
32        context_changer,
33      }
34    }
35
36    // /// Get back to context.
37    // #[ inline ]
38    // pub fn context( self ) -> ContextChanger
39    // {
40    //   self.context_changer
41    // }
42
43    /// ChangeInterface color.
44    #[ inline ]
45    pub fn color< Color >( mut self, color : Color ) -> Self
46    where
47      Color : RgbaInterface< f32 >,
48    {
49      let id = self.id;
50      let change = StrokeBrushChangeColor::new( id, color.into_rgba() );
51      self.change_add( change );
52      self
53    }
54
55    /// Width.
56    #[ inline ]
57    pub fn width( mut self, val : f32 ) -> Self
58    {
59      let id = self.id;
60      let change = StrokeBrushChangeWidth::new( id, val );
61      self.change_add( change );
62      self
63    }
64
65  }
66
67  impl ChangerInterface for StrokeBrushChanger
68  {
69
70    type Parent = ContextChanger;
71    type Root = ContextChanger;
72
73    fn context( self ) -> Self::Root
74    {
75      self.context_changer
76    }
77
78    fn parent( &mut self ) -> &mut Self::Parent
79    {
80      &mut self.context_changer
81    }
82
83    fn end( self ) -> Self::Parent
84    {
85      self.context_changer
86    }
87
88  }
89
90  impl HasIdInterface for StrokeBrushChanger
91  {
92    #[ inline ]
93    fn id( &self ) -> Id
94    {
95      self.id
96    }
97  }
98
99}
100
101crate::mod_interface!
102{
103  exposed use StrokeBrushChanger;
104}