winio_primitive/
drawing.rs1use euclid::*;
2use rgb::RGBA8;
3
4pub struct LogicalSpace;
6
7pub type Point = Point2D<f64, LogicalSpace>;
9pub type Vector = Vector2D<f64, LogicalSpace>;
11pub type Size = Size2D<f64, LogicalSpace>;
13pub type Rect = euclid::Rect<f64, LogicalSpace>;
15pub type RectBox = Box2D<f64, LogicalSpace>;
17pub type Margin = SideOffsets2D<f64, LogicalSpace>;
19pub type Rotation = Rotation2D<f64, LogicalSpace, LogicalSpace>;
21pub type Transform = Transform2D<f64, LogicalSpace, LogicalSpace>;
23pub type Angle = euclid::Angle<f64>;
25
26pub struct RelativeSpace;
28
29pub type RelativePoint = Point2D<f64, RelativeSpace>;
31pub type RelativeVector = Vector2D<f64, RelativeSpace>;
33pub type RelativeSize = Size2D<f64, RelativeSpace>;
35
36pub type RelativeToLogical = Transform2D<f64, RelativeSpace, LogicalSpace>;
38
39#[derive(Debug, PartialEq, Eq, Clone, Copy)]
41#[non_exhaustive]
42pub enum ColorTheme {
43 Light,
45 Dark,
47}
48
49#[derive(Debug, PartialEq, Eq, Clone, Copy)]
51pub enum Orient {
52 Horizontal,
54 Vertical,
56}
57
58#[derive(Debug, PartialEq, Eq, Clone, Copy)]
60pub enum HAlign {
61 Left,
63 Center,
65 Right,
67 Stretch,
69}
70
71#[derive(Debug, PartialEq, Eq, Clone, Copy)]
73pub enum VAlign {
74 Top,
76 Center,
78 Bottom,
80 Stretch,
82}
83
84pub type Color = RGBA8;
86
87#[derive(Debug, Clone)]
89pub struct DrawingFont {
90 pub family: String,
92 pub size: f64,
94 pub italic: bool,
96 pub bold: bool,
98 pub halign: HAlign,
100 pub valign: VAlign,
102}
103
104impl DrawingFont {
105 pub fn builder() -> DrawingFontBuilder {
107 DrawingFontBuilder::new()
108 }
109}
110
111pub struct DrawingFontBuilder {
113 value: DrawingFont,
114}
115
116impl Default for DrawingFontBuilder {
117 fn default() -> Self {
118 Self {
119 value: DrawingFont {
120 family: String::new(),
121 size: 0.0,
122 italic: false,
123 bold: false,
124 halign: HAlign::Left,
125 valign: VAlign::Top,
126 },
127 }
128 }
129}
130
131impl DrawingFontBuilder {
132 pub fn new() -> Self {
134 Self::default()
135 }
136
137 pub fn family(&mut self, s: impl AsRef<str>) -> &mut Self {
139 self.value.family = s.as_ref().to_string();
140 self
141 }
142
143 pub fn size(&mut self, s: f64) -> &mut Self {
145 self.value.size = s;
146 self
147 }
148
149 pub fn italic(&mut self, v: bool) -> &mut Self {
151 self.value.italic = v;
152 self
153 }
154
155 pub fn bold(&mut self, v: bool) -> &mut Self {
157 self.value.bold = v;
158 self
159 }
160
161 pub fn halign(&mut self, v: HAlign) -> &mut Self {
163 self.value.halign = v;
164 self
165 }
166
167 pub fn valign(&mut self, v: VAlign) -> &mut Self {
169 self.value.valign = v;
170 self
171 }
172
173 pub fn build(&self) -> DrawingFont {
175 self.value.clone()
176 }
177}
178
179#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
181pub enum MouseButton {
182 Left,
184 Right,
186 Middle,
188 Other,
190}
191
192#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
194pub enum TickPosition {
195 None,
197 TopLeft,
199 BottomRight,
201 Both,
203}