Skip to main content

azul_layout/widgets/
frame.rs

1use azul_core::{
2    callbacks::{CoreCallbackData, Update},
3    dom::{Dom, DomVec, IdOrClass, IdOrClass::Class, IdOrClassVec},
4    refany::RefAny,
5};
6use azul_css::{
7    dynamic_selector::{CssPropertyWithConditions, CssPropertyWithConditionsVec},
8    props::{
9        basic::*,
10        layout::*,
11        property::{CssProperty, *},
12        style::*,
13    },
14    *,
15};
16
17use crate::callbacks::Callback;
18
19const STRING_16146701490593874959: AzString = AzString::from_const_str("sans-serif");
20const STYLE_BACKGROUND_CONTENT_11062356617965867290_ITEMS: &[StyleBackgroundContent] =
21    &[StyleBackgroundContent::Color(ColorU {
22        r: 240,
23        g: 240,
24        b: 240,
25        a: 255,
26    })];
27const STYLE_FONT_FAMILY_8122988506401935406_ITEMS: &[StyleFontFamily] =
28    &[StyleFontFamily::System(STRING_16146701490593874959)];
29
30const CSS_MATCH_15775557796860201720_PROPERTIES: &[CssPropertyWithConditions] = &[
31    // .__azul-native-frame .__azul-native-frame-header .__azul-native-frame-header-before div
32    CssPropertyWithConditions::simple(CssProperty::Height(LayoutHeightValue::Exact(
33        LayoutHeight::Px(PixelValue::const_px(8)),
34    ))),
35    CssPropertyWithConditions::simple(CssProperty::BorderTopWidth(
36        LayoutBorderTopWidthValue::Exact(LayoutBorderTopWidth {
37            inner: PixelValue::const_px(1),
38        }),
39    )),
40    CssPropertyWithConditions::simple(CssProperty::BorderTopStyle(
41        StyleBorderTopStyleValue::Exact(StyleBorderTopStyle {
42            inner: BorderStyle::Solid,
43        }),
44    )),
45    CssPropertyWithConditions::simple(CssProperty::BorderTopColor(
46        StyleBorderTopColorValue::Exact(StyleBorderTopColor {
47            inner: ColorU {
48                r: 221,
49                g: 221,
50                b: 221,
51                a: 255,
52            },
53        }),
54    )),
55    CssPropertyWithConditions::simple(CssProperty::BorderLeftWidth(
56        LayoutBorderLeftWidthValue::Exact(LayoutBorderLeftWidth {
57            inner: PixelValue::const_px(1),
58        }),
59    )),
60    CssPropertyWithConditions::simple(CssProperty::BorderLeftStyle(
61        StyleBorderLeftStyleValue::Exact(StyleBorderLeftStyle {
62            inner: BorderStyle::Solid,
63        }),
64    )),
65    CssPropertyWithConditions::simple(CssProperty::BorderLeftColor(
66        StyleBorderLeftColorValue::Exact(StyleBorderLeftColor {
67            inner: ColorU {
68                r: 221,
69                g: 221,
70                b: 221,
71                a: 255,
72            },
73        }),
74    )),
75    // .__azul-native-frame .__azul-native-frame-header .__azul-native-frame-header-before
76    CssPropertyWithConditions::simple(CssProperty::Width(LayoutWidthValue::Exact(
77        LayoutWidth::Px(PixelValue::const_px(5)),
78    ))),
79    CssPropertyWithConditions::simple(CssProperty::MarginTop(LayoutMarginTopValue::Exact(
80        LayoutMarginTop {
81            inner: PixelValue::const_px(6),
82        },
83    ))),
84    CssPropertyWithConditions::simple(CssProperty::FlexGrow(LayoutFlexGrowValue::Exact(
85        LayoutFlexGrow {
86            inner: FloatValue::const_new(1),
87        },
88    ))),
89    CssPropertyWithConditions::simple(CssProperty::FlexDirection(LayoutFlexDirectionValue::Exact(
90        LayoutFlexDirection::Column,
91    ))),
92];
93const CSS_MATCH_15775557796860201720: CssPropertyWithConditionsVec =
94    CssPropertyWithConditionsVec::from_const_slice(CSS_MATCH_15775557796860201720_PROPERTIES);
95
96const CSS_MATCH_16739370686243728873_PROPERTIES: &[CssPropertyWithConditions] = &[
97    // .__azul-native-frame .__azul-native-frame-header
98    CssPropertyWithConditions::simple(CssProperty::FontSize(StyleFontSizeValue::Exact(
99        StyleFontSize {
100            inner: PixelValue::const_px(11),
101        },
102    ))),
103    CssPropertyWithConditions::simple(CssProperty::FontFamily(StyleFontFamilyVecValue::Exact(
104        StyleFontFamilyVec::from_const_slice(STYLE_FONT_FAMILY_8122988506401935406_ITEMS),
105    ))),
106    CssPropertyWithConditions::simple(CssProperty::FlexDirection(LayoutFlexDirectionValue::Exact(
107        LayoutFlexDirection::Row,
108    ))),
109    CssPropertyWithConditions::simple(CssProperty::AlignItems(LayoutAlignItemsValue::Exact(
110        LayoutAlignItems::End,
111    ))),
112];
113const CSS_MATCH_16739370686243728873: CssPropertyWithConditionsVec =
114    CssPropertyWithConditionsVec::from_const_slice(CSS_MATCH_16739370686243728873_PROPERTIES);
115
116const CSS_MATCH_4236783900531286611_PROPERTIES: &[CssPropertyWithConditions] = &[
117    // .__azul-native-frame .__azul-native-frame-header p
118    CssPropertyWithConditions::simple(CssProperty::TextAlign(StyleTextAlignValue::Exact(
119        StyleTextAlign::Center,
120    ))),
121    CssPropertyWithConditions::simple(CssProperty::PaddingLeft(LayoutPaddingLeftValue::Exact(
122        LayoutPaddingLeft {
123            inner: PixelValue::const_px(3),
124        },
125    ))),
126    CssPropertyWithConditions::simple(CssProperty::PaddingRight(LayoutPaddingRightValue::Exact(
127        LayoutPaddingRight {
128            inner: PixelValue::const_px(1),
129        },
130    ))),
131    CssPropertyWithConditions::simple(CssProperty::PaddingLeft(LayoutPaddingLeftValue::Exact(
132        LayoutPaddingLeft {
133            inner: PixelValue::const_px(1),
134        },
135    ))),
136    CssPropertyWithConditions::simple(CssProperty::PaddingBottom(LayoutPaddingBottomValue::Exact(
137        LayoutPaddingBottom {
138            inner: PixelValue::const_px(0),
139        },
140    ))),
141    CssPropertyWithConditions::simple(CssProperty::PaddingTop(LayoutPaddingTopValue::Exact(
142        LayoutPaddingTop {
143            inner: PixelValue::const_px(0),
144        },
145    ))),
146];
147const CSS_MATCH_4236783900531286611: CssPropertyWithConditionsVec =
148    CssPropertyWithConditionsVec::from_const_slice(CSS_MATCH_4236783900531286611_PROPERTIES);
149
150const CSS_MATCH_8602559445190067154_PROPERTIES: &[CssPropertyWithConditions] = &[
151    // .__azul-native-frame
152    CssPropertyWithConditions::simple(CssProperty::PaddingRight(LayoutPaddingRightValue::Exact(
153        LayoutPaddingRight {
154            inner: PixelValue::const_px(5),
155        },
156    ))),
157    CssPropertyWithConditions::simple(CssProperty::PaddingLeft(LayoutPaddingLeftValue::Exact(
158        LayoutPaddingLeft {
159            inner: PixelValue::const_px(5),
160        },
161    ))),
162    CssPropertyWithConditions::simple(CssProperty::PaddingBottom(LayoutPaddingBottomValue::Exact(
163        LayoutPaddingBottom {
164            inner: PixelValue::const_px(3),
165        },
166    ))),
167    CssPropertyWithConditions::simple(CssProperty::PaddingTop(LayoutPaddingTopValue::Exact(
168        LayoutPaddingTop {
169            inner: PixelValue::const_px(3),
170        },
171    ))),
172];
173const CSS_MATCH_8602559445190067154: CssPropertyWithConditionsVec =
174    CssPropertyWithConditionsVec::from_const_slice(CSS_MATCH_8602559445190067154_PROPERTIES);
175
176const CSS_MATCH_9156589477016488419_PROPERTIES: &[CssPropertyWithConditions] = &[
177    // .__azul-native-frame .__azul-native-frame-header .__azul-native-frame-header-after div
178    CssPropertyWithConditions::simple(CssProperty::Height(LayoutHeightValue::Exact(
179        LayoutHeight::Px(PixelValue::const_px(8)),
180    ))),
181    CssPropertyWithConditions::simple(CssProperty::BorderTopWidth(
182        LayoutBorderTopWidthValue::Exact(LayoutBorderTopWidth {
183            inner: PixelValue::const_px(1),
184        }),
185    )),
186    CssPropertyWithConditions::simple(CssProperty::BorderTopStyle(
187        StyleBorderTopStyleValue::Exact(StyleBorderTopStyle {
188            inner: BorderStyle::Solid,
189        }),
190    )),
191    CssPropertyWithConditions::simple(CssProperty::BorderTopColor(
192        StyleBorderTopColorValue::Exact(StyleBorderTopColor {
193            inner: ColorU {
194                r: 221,
195                g: 221,
196                b: 221,
197                a: 255,
198            },
199        }),
200    )),
201    CssPropertyWithConditions::simple(CssProperty::BorderRightWidth(
202        LayoutBorderRightWidthValue::Exact(LayoutBorderRightWidth {
203            inner: PixelValue::const_px(1),
204        }),
205    )),
206    CssPropertyWithConditions::simple(CssProperty::BorderRightStyle(
207        StyleBorderRightStyleValue::Exact(StyleBorderRightStyle {
208            inner: BorderStyle::Solid,
209        }),
210    )),
211    CssPropertyWithConditions::simple(CssProperty::BorderRightColor(
212        StyleBorderRightColorValue::Exact(StyleBorderRightColor {
213            inner: ColorU {
214                r: 221,
215                g: 221,
216                b: 221,
217                a: 255,
218            },
219        }),
220    )),
221    // .__azul-native-frame .__azul-native-frame-header .__azul-native-frame-header-after
222    CssPropertyWithConditions::simple(CssProperty::MarginTop(LayoutMarginTopValue::Exact(
223        LayoutMarginTop {
224            inner: PixelValue::const_px(6),
225        },
226    ))),
227    CssPropertyWithConditions::simple(CssProperty::FlexGrow(LayoutFlexGrowValue::Exact(
228        LayoutFlexGrow {
229            inner: FloatValue::const_new(1),
230        },
231    ))),
232    CssPropertyWithConditions::simple(CssProperty::FlexDirection(LayoutFlexDirectionValue::Exact(
233        LayoutFlexDirection::Column,
234    ))),
235];
236const CSS_MATCH_9156589477016488419: CssPropertyWithConditionsVec =
237    CssPropertyWithConditionsVec::from_const_slice(CSS_MATCH_9156589477016488419_PROPERTIES);
238
239#[derive(Debug, Clone)]
240#[repr(C)]
241pub struct Frame {
242    pub title: AzString,
243    pub flex_grow: f32,
244    pub content: Dom,
245}
246
247impl Frame {
248    pub fn create(title: AzString, content: Dom) -> Self {
249        Self {
250            title,
251            content,
252            flex_grow: 0.0,
253        }
254    }
255
256    pub fn swap_with_default(&mut self) -> Self {
257        let mut s = Self::create(AzString::from_const_str(""), Dom::create_div());
258        core::mem::swap(&mut s, self);
259        s
260    }
261
262    pub fn set_flex_grow(&mut self, flex_grow: f32) {
263        self.flex_grow = flex_grow;
264    }
265
266    pub fn with_flex_grow(mut self, flex_grow: f32) -> Self {
267        self.set_flex_grow(flex_grow);
268        self
269    }
270
271    pub fn dom(self) -> Dom {
272        Dom::create_div()
273            .with_css_props(CSS_MATCH_8602559445190067154)
274            .with_ids_and_classes({
275                const IDS_AND_CLASSES_14615537625743340639: &[IdOrClass] =
276                    &[Class(AzString::from_const_str("__azul-native-frame"))];
277                IdOrClassVec::from_const_slice(IDS_AND_CLASSES_14615537625743340639)
278            })
279            .with_children(DomVec::from_vec(vec![
280                Dom::create_div()
281                    .with_css_props(CSS_MATCH_16739370686243728873)
282                    .with_ids_and_classes({
283                        const IDS_AND_CLASSES_17776797146874875377: &[IdOrClass] = &[Class(
284                            AzString::from_const_str("__azul-native-frame-header"),
285                        )];
286                        IdOrClassVec::from_const_slice(IDS_AND_CLASSES_17776797146874875377)
287                    })
288                    .with_children(DomVec::from_vec(vec![
289                        Dom::create_div()
290                            .with_css_props(CSS_MATCH_15775557796860201720)
291                            .with_ids_and_classes({
292                                const IDS_AND_CLASSES_15264202958442287530: &[IdOrClass] =
293                                    &[Class(AzString::from_const_str(
294                                        "__azul-native-frame-header-before",
295                                    ))];
296                                IdOrClassVec::from_const_slice(IDS_AND_CLASSES_15264202958442287530)
297                            })
298                            .with_children(DomVec::from_vec(vec![Dom::create_div()])),
299                        Dom::create_text(self.title).with_css_props(CSS_MATCH_4236783900531286611),
300                        Dom::create_div()
301                            .with_css_props(CSS_MATCH_9156589477016488419)
302                            .with_ids_and_classes({
303                                const IDS_AND_CLASSES_5689091102265932280: &[IdOrClass] = &[Class(
304                                    AzString::from_const_str("__azul-native-frame-header-after"),
305                                )];
306                                IdOrClassVec::from_const_slice(IDS_AND_CLASSES_5689091102265932280)
307                            })
308                            .with_children(DomVec::from_vec(vec![Dom::create_div()])),
309                    ])),
310                Dom::create_div()
311                    .with_css_props(CssPropertyWithConditionsVec::from_vec(vec![
312                        // .__azul-native-frame .__azul-native-frame-content
313                        CssPropertyWithConditions::simple(CssProperty::FlexGrow(
314                            LayoutFlexGrowValue::Exact(LayoutFlexGrow::new(
315                                self.flex_grow as isize,
316                            )),
317                        )),
318                        CssPropertyWithConditions::simple(CssProperty::PaddingRight(
319                            LayoutPaddingRightValue::Exact(LayoutPaddingRight {
320                                inner: PixelValue::const_px(5),
321                            }),
322                        )),
323                        CssPropertyWithConditions::simple(CssProperty::PaddingLeft(
324                            LayoutPaddingLeftValue::Exact(LayoutPaddingLeft {
325                                inner: PixelValue::const_px(5),
326                            }),
327                        )),
328                        CssPropertyWithConditions::simple(CssProperty::PaddingBottom(
329                            LayoutPaddingBottomValue::Exact(LayoutPaddingBottom {
330                                inner: PixelValue::const_px(5),
331                            }),
332                        )),
333                        CssPropertyWithConditions::simple(CssProperty::PaddingTop(
334                            LayoutPaddingTopValue::Exact(LayoutPaddingTop {
335                                inner: PixelValue::const_px(5),
336                            }),
337                        )),
338                        CssPropertyWithConditions::simple(CssProperty::FontSize(
339                            StyleFontSizeValue::Exact(StyleFontSize {
340                                inner: PixelValue::const_px(11),
341                            }),
342                        )),
343                        CssPropertyWithConditions::simple(CssProperty::FontFamily(
344                            StyleFontFamilyVecValue::Exact(StyleFontFamilyVec::from_const_slice(
345                                STYLE_FONT_FAMILY_8122988506401935406_ITEMS,
346                            )),
347                        )),
348                        CssPropertyWithConditions::simple(CssProperty::BorderTopWidth(
349                            LayoutBorderTopWidthValue::None,
350                        )),
351                        CssPropertyWithConditions::simple(CssProperty::BorderTopStyle(
352                            StyleBorderTopStyleValue::None,
353                        )),
354                        CssPropertyWithConditions::simple(CssProperty::BorderTopColor(
355                            StyleBorderTopColorValue::None,
356                        )),
357                        CssPropertyWithConditions::simple(CssProperty::BorderBottomWidth(
358                            LayoutBorderBottomWidthValue::Exact(LayoutBorderBottomWidth {
359                                inner: PixelValue::const_px(1),
360                            }),
361                        )),
362                        CssPropertyWithConditions::simple(CssProperty::BorderLeftWidth(
363                            LayoutBorderLeftWidthValue::Exact(LayoutBorderLeftWidth {
364                                inner: PixelValue::const_px(1),
365                            }),
366                        )),
367                        CssPropertyWithConditions::simple(CssProperty::BorderRightWidth(
368                            LayoutBorderRightWidthValue::Exact(LayoutBorderRightWidth {
369                                inner: PixelValue::const_px(1),
370                            }),
371                        )),
372                        CssPropertyWithConditions::simple(CssProperty::BorderTopWidth(
373                            LayoutBorderTopWidthValue::Exact(LayoutBorderTopWidth {
374                                inner: PixelValue::const_px(1),
375                            }),
376                        )),
377                        CssPropertyWithConditions::simple(CssProperty::BorderBottomStyle(
378                            StyleBorderBottomStyleValue::Exact(StyleBorderBottomStyle {
379                                inner: BorderStyle::Solid,
380                            }),
381                        )),
382                        CssPropertyWithConditions::simple(CssProperty::BorderLeftStyle(
383                            StyleBorderLeftStyleValue::Exact(StyleBorderLeftStyle {
384                                inner: BorderStyle::Solid,
385                            }),
386                        )),
387                        CssPropertyWithConditions::simple(CssProperty::BorderRightStyle(
388                            StyleBorderRightStyleValue::Exact(StyleBorderRightStyle {
389                                inner: BorderStyle::Solid,
390                            }),
391                        )),
392                        CssPropertyWithConditions::simple(CssProperty::BorderTopStyle(
393                            StyleBorderTopStyleValue::Exact(StyleBorderTopStyle {
394                                inner: BorderStyle::Solid,
395                            }),
396                        )),
397                        CssPropertyWithConditions::simple(CssProperty::BorderBottomColor(
398                            StyleBorderBottomColorValue::Exact(StyleBorderBottomColor {
399                                inner: ColorU {
400                                    r: 221,
401                                    g: 221,
402                                    b: 221,
403                                    a: 255,
404                                },
405                            }),
406                        )),
407                        CssPropertyWithConditions::simple(CssProperty::BorderLeftColor(
408                            StyleBorderLeftColorValue::Exact(StyleBorderLeftColor {
409                                inner: ColorU {
410                                    r: 221,
411                                    g: 221,
412                                    b: 221,
413                                    a: 255,
414                                },
415                            }),
416                        )),
417                        CssPropertyWithConditions::simple(CssProperty::BorderRightColor(
418                            StyleBorderRightColorValue::Exact(StyleBorderRightColor {
419                                inner: ColorU {
420                                    r: 221,
421                                    g: 221,
422                                    b: 221,
423                                    a: 255,
424                                },
425                            }),
426                        )),
427                        CssPropertyWithConditions::simple(CssProperty::BorderTopColor(
428                            StyleBorderTopColorValue::Exact(StyleBorderTopColor {
429                                inner: ColorU {
430                                    r: 221,
431                                    g: 221,
432                                    b: 221,
433                                    a: 255,
434                                },
435                            }),
436                        )),
437                    ]))
438                    .with_ids_and_classes({
439                        const IDS_AND_CLASSES_9898887665724137124: &[IdOrClass] = &[Class(
440                            AzString::from_const_str("__azul-native-frame-content"),
441                        )];
442                        IdOrClassVec::from_const_slice(IDS_AND_CLASSES_9898887665724137124)
443                    })
444                    .with_children(vec![self.content].into()),
445            ]))
446    }
447}