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 Angle = euclid::Angle<f64>;
23
24pub struct RelativeSpace;
26
27pub type RelativePoint = Point2D<f64, RelativeSpace>;
29pub type RelativeVector = Vector2D<f64, RelativeSpace>;
31pub type RelativeSize = Size2D<f64, RelativeSpace>;
33
34pub type RelativeToLogical = Transform2D<f64, RelativeSpace, LogicalSpace>;
36
37#[derive(Debug, PartialEq, Eq, Clone, Copy)]
39#[non_exhaustive]
40pub enum ColorTheme {
41 Light,
43 Dark,
45}
46
47#[derive(Debug, PartialEq, Eq, Clone, Copy)]
49pub enum Orient {
50 Horizontal,
52 Vertical,
54}
55
56#[derive(Debug, PartialEq, Eq, Clone, Copy)]
58pub enum HAlign {
59 Left,
61 Center,
63 Right,
65 Stretch,
67}
68
69#[derive(Debug, PartialEq, Eq, Clone, Copy)]
71pub enum VAlign {
72 Top,
74 Center,
76 Bottom,
78 Stretch,
80}
81
82pub type Color = RGBA8;
84
85#[derive(Debug, Clone)]
87pub struct DrawingFont {
88 pub family: String,
90 pub size: f64,
92 pub italic: bool,
94 pub bold: bool,
96 pub halign: HAlign,
98 pub valign: VAlign,
100}
101
102impl DrawingFont {
103 pub fn builder() -> DrawingFontBuilder {
105 DrawingFontBuilder::new()
106 }
107}
108
109pub struct DrawingFontBuilder {
111 value: DrawingFont,
112}
113
114impl Default for DrawingFontBuilder {
115 fn default() -> Self {
116 Self {
117 value: DrawingFont {
118 family: String::new(),
119 size: 0.0,
120 italic: false,
121 bold: false,
122 halign: HAlign::Left,
123 valign: VAlign::Top,
124 },
125 }
126 }
127}
128
129impl DrawingFontBuilder {
130 pub fn new() -> Self {
132 Self::default()
133 }
134
135 pub fn family(&mut self, s: impl AsRef<str>) -> &mut Self {
137 self.value.family = s.as_ref().to_string();
138 self
139 }
140
141 pub fn size(&mut self, s: f64) -> &mut Self {
143 self.value.size = s;
144 self
145 }
146
147 pub fn italic(&mut self, v: bool) -> &mut Self {
149 self.value.italic = v;
150 self
151 }
152
153 pub fn bold(&mut self, v: bool) -> &mut Self {
155 self.value.bold = v;
156 self
157 }
158
159 pub fn halign(&mut self, v: HAlign) -> &mut Self {
161 self.value.halign = v;
162 self
163 }
164
165 pub fn valign(&mut self, v: VAlign) -> &mut Self {
167 self.value.valign = v;
168 self
169 }
170
171 pub fn build(&self) -> DrawingFont {
173 self.value.clone()
174 }
175}
176
177#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
179pub enum MouseButton {
180 Left,
182 Right,
184 Middle,
186 Other,
188}