1use crate::{bindings::*, color::Color, Declaration, Dimensions, Vector2};
2
3pub struct BorderBuilder<
5 'declaration,
6 'render,
7 ImageElementData: 'render,
8 CustomElementData: 'render,
9> {
10 parent: &'declaration mut Declaration<'render, ImageElementData, CustomElementData>,
11}
12
13impl<'declaration, 'render, ImageElementData: 'render, CustomElementData: 'render>
14 BorderBuilder<'declaration, 'render, ImageElementData, CustomElementData>
15{
16 #[inline]
18 pub fn new(
19 parent: &'declaration mut Declaration<'render, ImageElementData, CustomElementData>,
20 ) -> Self {
21 BorderBuilder { parent }
22 }
23
24 #[inline]
26 pub fn all_directions(&mut self, width: u16) -> &mut Self {
27 self.parent.inner.border.width.left = width;
28 self.parent.inner.border.width.right = width;
29 self.parent.inner.border.width.top = width;
30 self.parent.inner.border.width.bottom = width;
31 self
32 }
33
34 #[inline]
36 pub fn left(&mut self, width: u16) -> &mut Self {
37 self.parent.inner.border.width.left = width;
38 self
39 }
40
41 #[inline]
43 pub fn right(&mut self, width: u16) -> &mut Self {
44 self.parent.inner.border.width.right = width;
45 self
46 }
47
48 #[inline]
50 pub fn top(&mut self, width: u16) -> &mut Self {
51 self.parent.inner.border.width.top = width;
52 self
53 }
54
55 #[inline]
57 pub fn bottom(&mut self, width: u16) -> &mut Self {
58 self.parent.inner.border.width.bottom = width;
59 self
60 }
61
62 #[inline]
64 pub fn between_children(&mut self, width: u16) -> &mut Self {
65 self.parent.inner.border.width.betweenChildren = width;
66 self
67 }
68
69 #[inline]
71 pub fn color(&mut self, color: Color) -> &mut Self {
72 self.parent.inner.border.color = color.into();
73 self
74 }
75
76 #[inline]
78 pub fn end(&mut self) -> &mut Declaration<'render, ImageElementData, CustomElementData> {
79 self.parent
80 }
81}
82
83pub struct ImageBuilder<
85 'declaration,
86 'render,
87 ImageElementData: 'render,
88 CustomElementData: 'render,
89> {
90 parent: &'declaration mut Declaration<'render, ImageElementData, CustomElementData>,
91}
92
93impl<'declaration, 'render, ImageElementData: 'render, CustomElementData: 'render>
94 ImageBuilder<'declaration, 'render, ImageElementData, CustomElementData>
95{
96 #[inline]
98 pub fn new(
99 parent: &'declaration mut Declaration<'render, ImageElementData, CustomElementData>,
100 ) -> Self {
101 ImageBuilder { parent }
102 }
103
104 #[inline]
107 pub fn data(&mut self, data: &'render ImageElementData) -> &mut Self {
108 self.parent.inner.image.imageData = data as *const ImageElementData as _;
109 self
110 }
111 #[inline]
113 pub fn end(&mut self) -> &mut Declaration<'render, ImageElementData, CustomElementData> {
114 self.parent
115 }
116}
117
118#[derive(Debug, Clone, Copy)]
120#[repr(u8)]
121pub enum FloatingAttachPointType {
122 LeftTop = Clay_FloatingAttachPointType_CLAY_ATTACH_POINT_LEFT_TOP,
124 LeftCenter = Clay_FloatingAttachPointType_CLAY_ATTACH_POINT_LEFT_CENTER,
126 LeftBottom = Clay_FloatingAttachPointType_CLAY_ATTACH_POINT_LEFT_BOTTOM,
128 CenterTop = Clay_FloatingAttachPointType_CLAY_ATTACH_POINT_CENTER_TOP,
130 CenterCenter = Clay_FloatingAttachPointType_CLAY_ATTACH_POINT_CENTER_CENTER,
132 CenterBottom = Clay_FloatingAttachPointType_CLAY_ATTACH_POINT_CENTER_BOTTOM,
134 RightTop = Clay_FloatingAttachPointType_CLAY_ATTACH_POINT_RIGHT_TOP,
136 RightCenter = Clay_FloatingAttachPointType_CLAY_ATTACH_POINT_RIGHT_CENTER,
138 RightBottom = Clay_FloatingAttachPointType_CLAY_ATTACH_POINT_RIGHT_BOTTOM,
140}
141
142#[derive(Debug, Clone, Copy)]
144#[repr(u8)]
145pub enum PointerCaptureMode {
146 Capture = Clay_PointerCaptureMode_CLAY_POINTER_CAPTURE_MODE_CAPTURE,
148 Passthrough = Clay_PointerCaptureMode_CLAY_POINTER_CAPTURE_MODE_PASSTHROUGH,
150}
151
152#[derive(Debug, Clone)]
154#[repr(u8)]
155pub enum FloatingAttachToElement {
156 None = Clay_FloatingAttachToElement_CLAY_ATTACH_TO_NONE,
158 Parent = Clay_FloatingAttachToElement_CLAY_ATTACH_TO_PARENT,
160 ElementWithId = Clay_FloatingAttachToElement_CLAY_ATTACH_TO_ELEMENT_WITH_ID,
162 Root = Clay_FloatingAttachToElement_CLAY_ATTACH_TO_ROOT,
164}
165
166pub struct FloatingBuilder<
168 'declaration,
169 'render,
170 ImageElementData: 'render,
171 CustomElementData: 'render,
172> {
173 parent: &'declaration mut Declaration<'render, ImageElementData, CustomElementData>,
174}
175
176impl<'declaration, 'render, ImageElementData: 'render, CustomElementData: 'render>
177 FloatingBuilder<'declaration, 'render, ImageElementData, CustomElementData>
178{
179 #[inline]
181 pub fn new(
182 parent: &'declaration mut Declaration<'render, ImageElementData, CustomElementData>,
183 ) -> Self {
184 FloatingBuilder { parent }
185 }
186
187 #[inline]
189 pub fn offset(&mut self, offset: Vector2) -> &mut Self {
190 self.parent.inner.floating.offset = offset.into();
191 self
192 }
193
194 #[inline]
196 pub fn dimensions(&mut self, dimensions: Dimensions) -> &mut Self {
197 self.parent.inner.floating.expand = dimensions.into();
198 self
199 }
200
201 #[inline]
203 pub fn z_index(&mut self, z_index: i16) -> &mut Self {
204 self.parent.inner.floating.zIndex = z_index;
205 self
206 }
207
208 #[inline]
210 pub fn parent_id(&mut self, id: u32) -> &mut Self {
211 self.parent.inner.floating.parentId = id;
212 self
213 }
214
215 #[inline]
217 pub fn attach_points(
218 &mut self,
219 element: FloatingAttachPointType,
220 parent: FloatingAttachPointType,
221 ) -> &mut Self {
222 self.parent.inner.floating.attachPoints.element = element as _;
223 self.parent.inner.floating.attachPoints.parent = parent as _;
224 self
225 }
226
227 #[inline]
234 pub fn attach_to(&mut self, attach: FloatingAttachToElement) -> &mut Self {
235 self.parent.inner.floating.attachTo = attach as _;
236 self
237 }
238
239 #[inline]
241 pub fn pointer_capture_mode(&mut self, mode: PointerCaptureMode) -> &mut Self {
242 self.parent.inner.floating.pointerCaptureMode = mode as _;
243 self
244 }
245
246 #[inline]
248 pub fn end(&mut self) -> &mut Declaration<'render, ImageElementData, CustomElementData> {
249 self.parent
250 }
251}
252
253pub struct CornerRadiusBuilder<
255 'declaration,
256 'render,
257 ImageElementData: 'render,
258 CustomElementData: 'render,
259> {
260 parent: &'declaration mut Declaration<'render, ImageElementData, CustomElementData>,
261}
262
263impl<'declaration, 'render, ImageElementData: 'render, CustomElementData: 'render>
264 CornerRadiusBuilder<'declaration, 'render, ImageElementData, CustomElementData>
265{
266 #[inline]
268 pub fn new(
269 parent: &'declaration mut Declaration<'render, ImageElementData, CustomElementData>,
270 ) -> Self {
271 CornerRadiusBuilder { parent }
272 }
273
274 #[inline]
276 pub fn top_left(&mut self, radius: f32) -> &mut Self {
277 self.parent.inner.cornerRadius.topLeft = radius;
278 self
279 }
280
281 #[inline]
283 pub fn top_right(&mut self, radius: f32) -> &mut Self {
284 self.parent.inner.cornerRadius.topRight = radius;
285 self
286 }
287
288 #[inline]
290 pub fn bottom_left(&mut self, radius: f32) -> &mut Self {
291 self.parent.inner.cornerRadius.bottomLeft = radius;
292 self
293 }
294
295 #[inline]
297 pub fn bottom_right(&mut self, radius: f32) -> &mut Self {
298 self.parent.inner.cornerRadius.bottomRight = radius;
299 self
300 }
301
302 #[inline]
304 pub fn all(&mut self, radius: f32) -> &mut Self {
305 self.parent.inner.cornerRadius.topLeft = radius;
306 self.parent.inner.cornerRadius.topRight = radius;
307 self.parent.inner.cornerRadius.bottomLeft = radius;
308 self.parent.inner.cornerRadius.bottomRight = radius;
309 self
310 }
311
312 #[inline]
314 pub fn end(&mut self) -> &mut Declaration<'render, ImageElementData, CustomElementData> {
315 self.parent
316 }
317}