Skip to main content

azul_layout/widgets/
drop_down.rs

1use azul_core::{
2    callbacks::{CoreCallback, CoreCallbackData, Update},
3    dom::{
4        Dom, DomVec, EventFilter, FocusEventFilter, IdOrClass, IdOrClass::Class, IdOrClassVec,
5        TabIndex,
6    },
7    menu::{Menu, MenuItem, MenuItemVec, MenuPopupPosition, StringMenuItem},
8    refany::RefAny,
9};
10use azul_css::{
11    dynamic_selector::{CssPropertyWithConditions, CssPropertyWithConditionsVec},
12    props::{
13        basic::*,
14        layout::*,
15        property::{CssProperty, *},
16        style::*,
17    },
18    *,
19};
20
21use crate::callbacks::{Callback, CallbackInfo};
22
23const STRING_16146701490593874959: AzString = AzString::from_const_str("sans-serif");
24const STYLE_BACKGROUND_CONTENT_4857374953508308215_ITEMS: &[StyleBackgroundContent] =
25    &[StyleBackgroundContent::LinearGradient(LinearGradient {
26        direction: Direction::FromTo(DirectionCorners {
27            dir_from: DirectionCorner::Top,
28            dir_to: DirectionCorner::Bottom,
29        }),
30        extend_mode: ExtendMode::Clamp,
31        stops: NormalizedLinearColorStopVec::from_const_slice(
32            LINEAR_COLOR_STOP_8909964754681718371_ITEMS,
33        ),
34    })];
35const STYLE_BACKGROUND_CONTENT_8560341490937422656_ITEMS: &[StyleBackgroundContent] =
36    &[StyleBackgroundContent::LinearGradient(LinearGradient {
37        direction: Direction::FromTo(DirectionCorners {
38            dir_from: DirectionCorner::Top,
39            dir_to: DirectionCorner::Bottom,
40        }),
41        extend_mode: ExtendMode::Clamp,
42        stops: NormalizedLinearColorStopVec::from_const_slice(
43            LINEAR_COLOR_STOP_1400070954008106244_ITEMS,
44        ),
45    })];
46const STYLE_BACKGROUND_CONTENT_16125239329823337131_ITEMS: &[StyleBackgroundContent] =
47    &[StyleBackgroundContent::LinearGradient(LinearGradient {
48        direction: Direction::FromTo(DirectionCorners {
49            dir_from: DirectionCorner::Top,
50            dir_to: DirectionCorner::Bottom,
51        }),
52        extend_mode: ExtendMode::Clamp,
53        stops: NormalizedLinearColorStopVec::from_const_slice(
54            LINEAR_COLOR_STOP_8010235203234495977_ITEMS,
55        ),
56    })];
57const STYLE_BACKGROUND_CONTENT_16746671892555275291_ITEMS: &[StyleBackgroundContent] =
58    &[StyleBackgroundContent::Color(ColorU {
59        r: 255,
60        g: 255,
61        b: 255,
62        a: 255,
63    })];
64const STYLE_TRANSFORM_9499236770162623295_ITEMS: &[StyleTransform] = &[
65    StyleTransform::Rotate(AngleValue::const_deg(315)),
66    StyleTransform::Translate(StyleTransformTranslate2D {
67        x: PixelValue::const_px(0),
68        y: PixelValue::const_px(-2),
69    }),
70];
71const STYLE_FONT_FAMILY_18001933966972968559_ITEMS: &[StyleFontFamily] =
72    &[StyleFontFamily::System(STRING_16146701490593874959)];
73const LINEAR_COLOR_STOP_1400070954008106244_ITEMS: &[NormalizedLinearColorStop] = &[
74    NormalizedLinearColorStop {
75        offset: PercentageValue::const_new(0),
76        color: ColorU {
77            r: 240,
78            g: 240,
79            b: 240,
80            a: 255,
81        },
82    },
83    NormalizedLinearColorStop {
84        offset: PercentageValue::const_new(100),
85        color: ColorU {
86            r: 229,
87            g: 229,
88            b: 229,
89            a: 255,
90        },
91    },
92];
93const LINEAR_COLOR_STOP_8010235203234495977_ITEMS: &[NormalizedLinearColorStop] = &[
94    NormalizedLinearColorStop {
95        offset: PercentageValue::const_new(0),
96        color: ColorU {
97            r: 218,
98            g: 236,
99            b: 252,
100            a: 255,
101        },
102    },
103    NormalizedLinearColorStop {
104        offset: PercentageValue::const_new(100),
105        color: ColorU {
106            r: 196,
107            g: 224,
108            b: 252,
109            a: 255,
110        },
111    },
112];
113const LINEAR_COLOR_STOP_8909964754681718371_ITEMS: &[NormalizedLinearColorStop] = &[
114    NormalizedLinearColorStop {
115        offset: PercentageValue::const_new(0),
116        color: ColorU {
117            r: 235,
118            g: 244,
119            b: 252,
120            a: 255,
121        },
122    },
123    NormalizedLinearColorStop {
124        offset: PercentageValue::const_new(100),
125        color: ColorU {
126            r: 220,
127            g: 236,
128            b: 252,
129            a: 255,
130        },
131    },
132];
133
134const CSS_MATCH_10188117026223137249_PROPERTIES: &[CssPropertyWithConditions] = &[
135    // .__azul-native-dropdown-wrapper:focus
136    CssPropertyWithConditions::on_focus(CssProperty::BorderBottomWidth(
137        LayoutBorderBottomWidthValue::Exact(LayoutBorderBottomWidth {
138            inner: PixelValue::const_px(1),
139        }),
140    )),
141    CssPropertyWithConditions::on_focus(CssProperty::BorderLeftWidth(
142        LayoutBorderLeftWidthValue::Exact(LayoutBorderLeftWidth {
143            inner: PixelValue::const_px(1),
144        }),
145    )),
146    CssPropertyWithConditions::on_focus(CssProperty::BorderRightWidth(
147        LayoutBorderRightWidthValue::Exact(LayoutBorderRightWidth {
148            inner: PixelValue::const_px(1),
149        }),
150    )),
151    CssPropertyWithConditions::on_focus(CssProperty::BorderTopWidth(
152        LayoutBorderTopWidthValue::Exact(LayoutBorderTopWidth {
153            inner: PixelValue::const_px(1),
154        }),
155    )),
156    CssPropertyWithConditions::on_focus(CssProperty::BorderBottomStyle(
157        StyleBorderBottomStyleValue::Exact(StyleBorderBottomStyle {
158            inner: BorderStyle::Solid,
159        }),
160    )),
161    CssPropertyWithConditions::on_focus(CssProperty::BorderLeftStyle(
162        StyleBorderLeftStyleValue::Exact(StyleBorderLeftStyle {
163            inner: BorderStyle::Solid,
164        }),
165    )),
166    CssPropertyWithConditions::on_focus(CssProperty::BorderRightStyle(
167        StyleBorderRightStyleValue::Exact(StyleBorderRightStyle {
168            inner: BorderStyle::Solid,
169        }),
170    )),
171    CssPropertyWithConditions::on_focus(CssProperty::BorderTopStyle(
172        StyleBorderTopStyleValue::Exact(StyleBorderTopStyle {
173            inner: BorderStyle::Solid,
174        }),
175    )),
176    CssPropertyWithConditions::on_focus(CssProperty::BorderBottomColor(
177        StyleBorderBottomColorValue::Exact(StyleBorderBottomColor {
178            inner: ColorU {
179                r: 86,
180                g: 157,
181                b: 229,
182                a: 255,
183            },
184        }),
185    )),
186    CssPropertyWithConditions::on_focus(CssProperty::BorderLeftColor(
187        StyleBorderLeftColorValue::Exact(StyleBorderLeftColor {
188            inner: ColorU {
189                r: 86,
190                g: 157,
191                b: 229,
192                a: 255,
193            },
194        }),
195    )),
196    CssPropertyWithConditions::on_focus(CssProperty::BorderRightColor(
197        StyleBorderRightColorValue::Exact(StyleBorderRightColor {
198            inner: ColorU {
199                r: 86,
200                g: 157,
201                b: 229,
202                a: 255,
203            },
204        }),
205    )),
206    CssPropertyWithConditions::on_focus(CssProperty::BorderTopColor(
207        StyleBorderTopColorValue::Exact(StyleBorderTopColor {
208            inner: ColorU {
209                r: 86,
210                g: 157,
211                b: 229,
212                a: 255,
213            },
214        }),
215    )),
216    CssPropertyWithConditions::on_focus(CssProperty::BackgroundContent(
217        StyleBackgroundContentVecValue::Exact(StyleBackgroundContentVec::from_const_slice(
218            STYLE_BACKGROUND_CONTENT_16125239329823337131_ITEMS,
219        )),
220    )),
221    // .__azul-native-dropdown-wrapper:active
222    CssPropertyWithConditions::on_active(CssProperty::BorderBottomWidth(
223        LayoutBorderBottomWidthValue::Exact(LayoutBorderBottomWidth {
224            inner: PixelValue::const_px(1),
225        }),
226    )),
227    CssPropertyWithConditions::on_active(CssProperty::BorderLeftWidth(
228        LayoutBorderLeftWidthValue::Exact(LayoutBorderLeftWidth {
229            inner: PixelValue::const_px(1),
230        }),
231    )),
232    CssPropertyWithConditions::on_active(CssProperty::BorderRightWidth(
233        LayoutBorderRightWidthValue::Exact(LayoutBorderRightWidth {
234            inner: PixelValue::const_px(1),
235        }),
236    )),
237    CssPropertyWithConditions::on_active(CssProperty::BorderTopWidth(
238        LayoutBorderTopWidthValue::Exact(LayoutBorderTopWidth {
239            inner: PixelValue::const_px(1),
240        }),
241    )),
242    CssPropertyWithConditions::on_active(CssProperty::BorderBottomStyle(
243        StyleBorderBottomStyleValue::Exact(StyleBorderBottomStyle {
244            inner: BorderStyle::Solid,
245        }),
246    )),
247    CssPropertyWithConditions::on_active(CssProperty::BorderLeftStyle(
248        StyleBorderLeftStyleValue::Exact(StyleBorderLeftStyle {
249            inner: BorderStyle::Solid,
250        }),
251    )),
252    CssPropertyWithConditions::on_active(CssProperty::BorderRightStyle(
253        StyleBorderRightStyleValue::Exact(StyleBorderRightStyle {
254            inner: BorderStyle::Solid,
255        }),
256    )),
257    CssPropertyWithConditions::on_active(CssProperty::BorderTopStyle(
258        StyleBorderTopStyleValue::Exact(StyleBorderTopStyle {
259            inner: BorderStyle::Solid,
260        }),
261    )),
262    CssPropertyWithConditions::on_active(CssProperty::BorderBottomColor(
263        StyleBorderBottomColorValue::Exact(StyleBorderBottomColor {
264            inner: ColorU {
265                r: 86,
266                g: 157,
267                b: 229,
268                a: 255,
269            },
270        }),
271    )),
272    CssPropertyWithConditions::on_active(CssProperty::BorderLeftColor(
273        StyleBorderLeftColorValue::Exact(StyleBorderLeftColor {
274            inner: ColorU {
275                r: 86,
276                g: 157,
277                b: 229,
278                a: 255,
279            },
280        }),
281    )),
282    CssPropertyWithConditions::on_active(CssProperty::BorderRightColor(
283        StyleBorderRightColorValue::Exact(StyleBorderRightColor {
284            inner: ColorU {
285                r: 86,
286                g: 157,
287                b: 229,
288                a: 255,
289            },
290        }),
291    )),
292    CssPropertyWithConditions::on_active(CssProperty::BorderTopColor(
293        StyleBorderTopColorValue::Exact(StyleBorderTopColor {
294            inner: ColorU {
295                r: 86,
296                g: 157,
297                b: 229,
298                a: 255,
299            },
300        }),
301    )),
302    CssPropertyWithConditions::on_active(CssProperty::BackgroundContent(
303        StyleBackgroundContentVecValue::Exact(StyleBackgroundContentVec::from_const_slice(
304            STYLE_BACKGROUND_CONTENT_16125239329823337131_ITEMS,
305        )),
306    )),
307    // .__azul-native-dropdown-wrapper:hover
308    CssPropertyWithConditions::on_hover(CssProperty::BorderBottomWidth(
309        LayoutBorderBottomWidthValue::Exact(LayoutBorderBottomWidth {
310            inner: PixelValue::const_px(1),
311        }),
312    )),
313    CssPropertyWithConditions::on_hover(CssProperty::BorderLeftWidth(
314        LayoutBorderLeftWidthValue::Exact(LayoutBorderLeftWidth {
315            inner: PixelValue::const_px(1),
316        }),
317    )),
318    CssPropertyWithConditions::on_hover(CssProperty::BorderRightWidth(
319        LayoutBorderRightWidthValue::Exact(LayoutBorderRightWidth {
320            inner: PixelValue::const_px(1),
321        }),
322    )),
323    CssPropertyWithConditions::on_hover(CssProperty::BorderTopWidth(
324        LayoutBorderTopWidthValue::Exact(LayoutBorderTopWidth {
325            inner: PixelValue::const_px(1),
326        }),
327    )),
328    CssPropertyWithConditions::on_hover(CssProperty::BorderBottomStyle(
329        StyleBorderBottomStyleValue::Exact(StyleBorderBottomStyle {
330            inner: BorderStyle::Solid,
331        }),
332    )),
333    CssPropertyWithConditions::on_hover(CssProperty::BorderLeftStyle(
334        StyleBorderLeftStyleValue::Exact(StyleBorderLeftStyle {
335            inner: BorderStyle::Solid,
336        }),
337    )),
338    CssPropertyWithConditions::on_hover(CssProperty::BorderRightStyle(
339        StyleBorderRightStyleValue::Exact(StyleBorderRightStyle {
340            inner: BorderStyle::Solid,
341        }),
342    )),
343    CssPropertyWithConditions::on_hover(CssProperty::BorderTopStyle(
344        StyleBorderTopStyleValue::Exact(StyleBorderTopStyle {
345            inner: BorderStyle::Solid,
346        }),
347    )),
348    CssPropertyWithConditions::on_hover(CssProperty::BorderBottomColor(
349        StyleBorderBottomColorValue::Exact(StyleBorderBottomColor {
350            inner: ColorU {
351                r: 126,
352                g: 180,
353                b: 234,
354                a: 255,
355            },
356        }),
357    )),
358    CssPropertyWithConditions::on_hover(CssProperty::BorderLeftColor(
359        StyleBorderLeftColorValue::Exact(StyleBorderLeftColor {
360            inner: ColorU {
361                r: 126,
362                g: 180,
363                b: 234,
364                a: 255,
365            },
366        }),
367    )),
368    CssPropertyWithConditions::on_hover(CssProperty::BorderRightColor(
369        StyleBorderRightColorValue::Exact(StyleBorderRightColor {
370            inner: ColorU {
371                r: 126,
372                g: 180,
373                b: 234,
374                a: 255,
375            },
376        }),
377    )),
378    CssPropertyWithConditions::on_hover(CssProperty::BorderTopColor(
379        StyleBorderTopColorValue::Exact(StyleBorderTopColor {
380            inner: ColorU {
381                r: 126,
382                g: 180,
383                b: 234,
384                a: 255,
385            },
386        }),
387    )),
388    CssPropertyWithConditions::on_hover(CssProperty::BackgroundContent(
389        StyleBackgroundContentVecValue::Exact(StyleBackgroundContentVec::from_const_slice(
390            STYLE_BACKGROUND_CONTENT_4857374953508308215_ITEMS,
391        )),
392    )),
393    // .__azul-native-dropdown-wrapper
394    CssPropertyWithConditions::simple(CssProperty::PaddingRight(LayoutPaddingRightValue::Exact(
395        LayoutPaddingRight {
396            inner: PixelValue::const_px(2),
397        },
398    ))),
399    CssPropertyWithConditions::simple(CssProperty::PaddingLeft(LayoutPaddingLeftValue::Exact(
400        LayoutPaddingLeft {
401            inner: PixelValue::const_px(2),
402        },
403    ))),
404    CssPropertyWithConditions::simple(CssProperty::PaddingBottom(LayoutPaddingBottomValue::Exact(
405        LayoutPaddingBottom {
406            inner: PixelValue::const_px(2),
407        },
408    ))),
409    CssPropertyWithConditions::simple(CssProperty::PaddingTop(LayoutPaddingTopValue::Exact(
410        LayoutPaddingTop {
411            inner: PixelValue::const_px(2),
412        },
413    ))),
414    CssPropertyWithConditions::simple(CssProperty::MinWidth(LayoutMinWidthValue::Exact(
415        LayoutMinWidth {
416            inner: PixelValue::const_px(120),
417        },
418    ))),
419    CssPropertyWithConditions::simple(CssProperty::FontSize(StyleFontSizeValue::Exact(
420        StyleFontSize {
421            inner: PixelValue::const_px(11),
422        },
423    ))),
424    CssPropertyWithConditions::simple(CssProperty::FontFamily(StyleFontFamilyVecValue::Exact(
425        StyleFontFamilyVec::from_const_slice(STYLE_FONT_FAMILY_18001933966972968559_ITEMS),
426    ))),
427    CssPropertyWithConditions::simple(CssProperty::FlexGrow(LayoutFlexGrowValue::Exact(
428        LayoutFlexGrow {
429            inner: FloatValue::const_new(0),
430        },
431    ))),
432    CssPropertyWithConditions::simple(CssProperty::FlexDirection(LayoutFlexDirectionValue::Exact(
433        LayoutFlexDirection::Row,
434    ))),
435    CssPropertyWithConditions::simple(CssProperty::Display(LayoutDisplayValue::Exact(
436        LayoutDisplay::Block,
437    ))),
438    CssPropertyWithConditions::simple(CssProperty::BorderBottomWidth(
439        LayoutBorderBottomWidthValue::Exact(LayoutBorderBottomWidth {
440            inner: PixelValue::const_px(1),
441        }),
442    )),
443    CssPropertyWithConditions::simple(CssProperty::BorderLeftWidth(
444        LayoutBorderLeftWidthValue::Exact(LayoutBorderLeftWidth {
445            inner: PixelValue::const_px(1),
446        }),
447    )),
448    CssPropertyWithConditions::simple(CssProperty::BorderRightWidth(
449        LayoutBorderRightWidthValue::Exact(LayoutBorderRightWidth {
450            inner: PixelValue::const_px(1),
451        }),
452    )),
453    CssPropertyWithConditions::simple(CssProperty::BorderTopWidth(
454        LayoutBorderTopWidthValue::Exact(LayoutBorderTopWidth {
455            inner: PixelValue::const_px(1),
456        }),
457    )),
458    CssPropertyWithConditions::simple(CssProperty::BorderBottomStyle(
459        StyleBorderBottomStyleValue::Exact(StyleBorderBottomStyle {
460            inner: BorderStyle::Solid,
461        }),
462    )),
463    CssPropertyWithConditions::simple(CssProperty::BorderLeftStyle(
464        StyleBorderLeftStyleValue::Exact(StyleBorderLeftStyle {
465            inner: BorderStyle::Solid,
466        }),
467    )),
468    CssPropertyWithConditions::simple(CssProperty::BorderRightStyle(
469        StyleBorderRightStyleValue::Exact(StyleBorderRightStyle {
470            inner: BorderStyle::Solid,
471        }),
472    )),
473    CssPropertyWithConditions::simple(CssProperty::BorderTopStyle(
474        StyleBorderTopStyleValue::Exact(StyleBorderTopStyle {
475            inner: BorderStyle::Solid,
476        }),
477    )),
478    CssPropertyWithConditions::simple(CssProperty::BorderBottomColor(
479        StyleBorderBottomColorValue::Exact(StyleBorderBottomColor {
480            inner: ColorU {
481                r: 172,
482                g: 172,
483                b: 172,
484                a: 255,
485            },
486        }),
487    )),
488    CssPropertyWithConditions::simple(CssProperty::BorderLeftColor(
489        StyleBorderLeftColorValue::Exact(StyleBorderLeftColor {
490            inner: ColorU {
491                r: 172,
492                g: 172,
493                b: 172,
494                a: 255,
495            },
496        }),
497    )),
498    CssPropertyWithConditions::simple(CssProperty::BorderRightColor(
499        StyleBorderRightColorValue::Exact(StyleBorderRightColor {
500            inner: ColorU {
501                r: 172,
502                g: 172,
503                b: 172,
504                a: 255,
505            },
506        }),
507    )),
508    CssPropertyWithConditions::simple(CssProperty::BorderTopColor(
509        StyleBorderTopColorValue::Exact(StyleBorderTopColor {
510            inner: ColorU {
511                r: 172,
512                g: 172,
513                b: 172,
514                a: 255,
515            },
516        }),
517    )),
518    CssPropertyWithConditions::simple(CssProperty::BackgroundContent(
519        StyleBackgroundContentVecValue::Exact(StyleBackgroundContentVec::from_const_slice(
520            STYLE_BACKGROUND_CONTENT_8560341490937422656_ITEMS,
521        )),
522    )),
523];
524const CSS_MATCH_10188117026223137249: CssPropertyWithConditionsVec =
525    CssPropertyWithConditionsVec::from_const_slice(CSS_MATCH_10188117026223137249_PROPERTIES);
526
527const CSS_MATCH_16432538576103237591_PROPERTIES: &[CssPropertyWithConditions] = &[
528    // .__azul-native-dropdown-wrapper p
529    CssPropertyWithConditions::simple(CssProperty::PaddingRight(LayoutPaddingRightValue::Exact(
530        LayoutPaddingRight {
531            inner: PixelValue::const_px(8),
532        },
533    ))),
534    CssPropertyWithConditions::simple(CssProperty::Display(LayoutDisplayValue::Exact(
535        LayoutDisplay::Block,
536    ))),
537];
538const CSS_MATCH_16432538576103237591: CssPropertyWithConditionsVec =
539    CssPropertyWithConditionsVec::from_const_slice(CSS_MATCH_16432538576103237591_PROPERTIES);
540
541const CSS_MATCH_2883986488332352590_PROPERTIES: &[CssPropertyWithConditions] = &[
542    // body
543    CssPropertyWithConditions::simple(CssProperty::BackgroundContent(
544        StyleBackgroundContentVecValue::Exact(StyleBackgroundContentVec::from_const_slice(
545            STYLE_BACKGROUND_CONTENT_16746671892555275291_ITEMS,
546        )),
547    )),
548];
549const CSS_MATCH_2883986488332352590: CssPropertyWithConditionsVec =
550    CssPropertyWithConditionsVec::from_const_slice(CSS_MATCH_2883986488332352590_PROPERTIES);
551
552const CSS_MATCH_4428877324022630014_PROPERTIES: &[CssPropertyWithConditions] = &[
553    // .__azul-native-dropdown
554    CssPropertyWithConditions::simple(CssProperty::FlexGrow(LayoutFlexGrowValue::Exact(
555        LayoutFlexGrow {
556            inner: FloatValue::const_new(0),
557        },
558    ))),
559    CssPropertyWithConditions::simple(CssProperty::FlexDirection(LayoutFlexDirectionValue::Exact(
560        LayoutFlexDirection::Row,
561    ))),
562];
563const CSS_MATCH_4428877324022630014: CssPropertyWithConditionsVec =
564    CssPropertyWithConditionsVec::from_const_slice(CSS_MATCH_4428877324022630014_PROPERTIES);
565
566const CSS_MATCH_4687758758634879229_PROPERTIES: &[CssPropertyWithConditions] = &[
567    // .__azul-native-dropdown-arrow-wrapper
568    CssPropertyWithConditions::simple(CssProperty::PaddingRight(LayoutPaddingRightValue::Exact(
569        LayoutPaddingRight {
570            inner: PixelValue::const_px(5),
571        },
572    ))),
573    CssPropertyWithConditions::simple(CssProperty::PaddingLeft(LayoutPaddingLeftValue::Exact(
574        LayoutPaddingLeft {
575            inner: PixelValue::const_px(5),
576        },
577    ))),
578    CssPropertyWithConditions::simple(CssProperty::PaddingBottom(LayoutPaddingBottomValue::Exact(
579        LayoutPaddingBottom {
580            inner: PixelValue::const_px(0),
581        },
582    ))),
583    CssPropertyWithConditions::simple(CssProperty::PaddingTop(LayoutPaddingTopValue::Exact(
584        LayoutPaddingTop {
585            inner: PixelValue::const_px(0),
586        },
587    ))),
588    CssPropertyWithConditions::simple(CssProperty::JustifyContent(
589        LayoutJustifyContentValue::Exact(LayoutJustifyContent::End),
590    )),
591    CssPropertyWithConditions::simple(CssProperty::FlexDirection(LayoutFlexDirectionValue::Exact(
592        LayoutFlexDirection::Row,
593    ))),
594];
595const CSS_MATCH_4687758758634879229: CssPropertyWithConditionsVec =
596    CssPropertyWithConditionsVec::from_const_slice(CSS_MATCH_4687758758634879229_PROPERTIES);
597
598const CSS_MATCH_5369484915686807864_PROPERTIES: &[CssPropertyWithConditions] = &[
599    // .__azul-native-dropdown-arrow-content
600    CssPropertyWithConditions::simple(CssProperty::Width(LayoutWidthValue::Exact(
601        LayoutWidth::Px(PixelValue::const_px(6)),
602    ))),
603    CssPropertyWithConditions::simple(CssProperty::Transform(StyleTransformVecValue::Exact(
604        StyleTransformVec::from_const_slice(STYLE_TRANSFORM_9499236770162623295_ITEMS),
605    ))),
606    CssPropertyWithConditions::simple(CssProperty::Height(LayoutHeightValue::Exact(
607        LayoutHeight::Px(PixelValue::const_px(6)),
608    ))),
609    CssPropertyWithConditions::simple(CssProperty::BorderLeftWidth(
610        LayoutBorderLeftWidthValue::Exact(LayoutBorderLeftWidth {
611            inner: PixelValue::const_px(2),
612        }),
613    )),
614    CssPropertyWithConditions::simple(CssProperty::BorderLeftStyle(
615        StyleBorderLeftStyleValue::Exact(StyleBorderLeftStyle {
616            inner: BorderStyle::Solid,
617        }),
618    )),
619    CssPropertyWithConditions::simple(CssProperty::BorderLeftColor(
620        StyleBorderLeftColorValue::Exact(StyleBorderLeftColor {
621            inner: ColorU {
622                r: 96,
623                g: 96,
624                b: 96,
625                a: 255,
626            },
627        }),
628    )),
629    CssPropertyWithConditions::simple(CssProperty::BorderBottomWidth(
630        LayoutBorderBottomWidthValue::Exact(LayoutBorderBottomWidth {
631            inner: PixelValue::const_px(2),
632        }),
633    )),
634    CssPropertyWithConditions::simple(CssProperty::BorderBottomStyle(
635        StyleBorderBottomStyleValue::Exact(StyleBorderBottomStyle {
636            inner: BorderStyle::Solid,
637        }),
638    )),
639    CssPropertyWithConditions::simple(CssProperty::BorderBottomColor(
640        StyleBorderBottomColorValue::Exact(StyleBorderBottomColor {
641            inner: ColorU {
642                r: 96,
643                g: 96,
644                b: 96,
645                a: 255,
646            },
647        }),
648    )),
649];
650const CSS_MATCH_5369484915686807864: CssPropertyWithConditionsVec =
651    CssPropertyWithConditionsVec::from_const_slice(CSS_MATCH_5369484915686807864_PROPERTIES);
652
653const CSS_MATCH_6763840958685503000_PROPERTIES: &[CssPropertyWithConditions] = &[
654    // .__azul-native-dropdown-arrow
655    CssPropertyWithConditions::simple(CssProperty::MinWidth(LayoutMinWidthValue::Exact(
656        LayoutMinWidth {
657            inner: PixelValue::const_px(20),
658        },
659    ))),
660    CssPropertyWithConditions::simple(CssProperty::JustifyContent(
661        LayoutJustifyContentValue::Exact(LayoutJustifyContent::Center),
662    )),
663    CssPropertyWithConditions::simple(CssProperty::FlexGrow(LayoutFlexGrowValue::Exact(
664        LayoutFlexGrow {
665            inner: FloatValue::const_new(0),
666        },
667    ))),
668    CssPropertyWithConditions::simple(CssProperty::FlexDirection(LayoutFlexDirectionValue::Exact(
669        LayoutFlexDirection::Column,
670    ))),
671];
672const CSS_MATCH_6763840958685503000: CssPropertyWithConditionsVec =
673    CssPropertyWithConditionsVec::from_const_slice(CSS_MATCH_6763840958685503000_PROPERTIES);
674
675const CSS_MATCH_7938442083662451131_PROPERTIES: &[CssPropertyWithConditions] = &[
676    // .__azul-native-dropdown-focused-text:hover
677    CssPropertyWithConditions::on_hover(CssProperty::BorderBottomWidth(
678        LayoutBorderBottomWidthValue::Exact(LayoutBorderBottomWidth {
679            inner: PixelValue::const_px(1),
680        }),
681    )),
682    CssPropertyWithConditions::on_hover(CssProperty::BorderLeftWidth(
683        LayoutBorderLeftWidthValue::Exact(LayoutBorderLeftWidth {
684            inner: PixelValue::const_px(1),
685        }),
686    )),
687    CssPropertyWithConditions::on_hover(CssProperty::BorderRightWidth(
688        LayoutBorderRightWidthValue::Exact(LayoutBorderRightWidth {
689            inner: PixelValue::const_px(1),
690        }),
691    )),
692    CssPropertyWithConditions::on_hover(CssProperty::BorderTopWidth(
693        LayoutBorderTopWidthValue::Exact(LayoutBorderTopWidth {
694            inner: PixelValue::const_px(1),
695        }),
696    )),
697    CssPropertyWithConditions::on_hover(CssProperty::BorderBottomStyle(
698        StyleBorderBottomStyleValue::Exact(StyleBorderBottomStyle {
699            inner: BorderStyle::Dotted,
700        }),
701    )),
702    CssPropertyWithConditions::on_hover(CssProperty::BorderLeftStyle(
703        StyleBorderLeftStyleValue::Exact(StyleBorderLeftStyle {
704            inner: BorderStyle::Dotted,
705        }),
706    )),
707    CssPropertyWithConditions::on_hover(CssProperty::BorderRightStyle(
708        StyleBorderRightStyleValue::Exact(StyleBorderRightStyle {
709            inner: BorderStyle::Dotted,
710        }),
711    )),
712    CssPropertyWithConditions::on_hover(CssProperty::BorderTopStyle(
713        StyleBorderTopStyleValue::Exact(StyleBorderTopStyle {
714            inner: BorderStyle::Dotted,
715        }),
716    )),
717    CssPropertyWithConditions::on_hover(CssProperty::BorderBottomColor(
718        StyleBorderBottomColorValue::Exact(StyleBorderBottomColor {
719            inner: ColorU {
720                r: 0,
721                g: 0,
722                b: 0,
723                a: 255,
724            },
725        }),
726    )),
727    CssPropertyWithConditions::on_hover(CssProperty::BorderLeftColor(
728        StyleBorderLeftColorValue::Exact(StyleBorderLeftColor {
729            inner: ColorU {
730                r: 0,
731                g: 0,
732                b: 0,
733                a: 255,
734            },
735        }),
736    )),
737    CssPropertyWithConditions::on_hover(CssProperty::BorderRightColor(
738        StyleBorderRightColorValue::Exact(StyleBorderRightColor {
739            inner: ColorU {
740                r: 0,
741                g: 0,
742                b: 0,
743                a: 255,
744            },
745        }),
746    )),
747    CssPropertyWithConditions::on_hover(CssProperty::BorderTopColor(
748        StyleBorderTopColorValue::Exact(StyleBorderTopColor {
749            inner: ColorU {
750                r: 0,
751                g: 0,
752                b: 0,
753                a: 255,
754            },
755        }),
756    )),
757    // .__azul-native-dropdown-focused-text
758    CssPropertyWithConditions::simple(CssProperty::PaddingRight(LayoutPaddingRightValue::Exact(
759        LayoutPaddingRight {
760            inner: PixelValue::const_px(15),
761        },
762    ))),
763    CssPropertyWithConditions::simple(CssProperty::FlexGrow(LayoutFlexGrowValue::Exact(
764        LayoutFlexGrow {
765            inner: FloatValue::const_new(1),
766        },
767    ))),
768    CssPropertyWithConditions::simple(CssProperty::BorderBottomRightRadius(
769        StyleBorderBottomRightRadiusValue::Exact(StyleBorderBottomRightRadius {
770            inner: PixelValue::const_px(2),
771        }),
772    )),
773    CssPropertyWithConditions::simple(CssProperty::BorderBottomLeftRadius(
774        StyleBorderBottomLeftRadiusValue::Exact(StyleBorderBottomLeftRadius {
775            inner: PixelValue::const_px(2),
776        }),
777    )),
778    CssPropertyWithConditions::simple(CssProperty::BorderTopRightRadius(
779        StyleBorderTopRightRadiusValue::Exact(StyleBorderTopRightRadius {
780            inner: PixelValue::const_px(2),
781        }),
782    )),
783    CssPropertyWithConditions::simple(CssProperty::BorderTopLeftRadius(
784        StyleBorderTopLeftRadiusValue::Exact(StyleBorderTopLeftRadius {
785            inner: PixelValue::const_px(2),
786        }),
787    )),
788    CssPropertyWithConditions::simple(CssProperty::BorderBottomWidth(
789        LayoutBorderBottomWidthValue::Exact(LayoutBorderBottomWidth {
790            inner: PixelValue::const_px(1),
791        }),
792    )),
793    CssPropertyWithConditions::simple(CssProperty::BorderLeftWidth(
794        LayoutBorderLeftWidthValue::Exact(LayoutBorderLeftWidth {
795            inner: PixelValue::const_px(1),
796        }),
797    )),
798    CssPropertyWithConditions::simple(CssProperty::BorderRightWidth(
799        LayoutBorderRightWidthValue::Exact(LayoutBorderRightWidth {
800            inner: PixelValue::const_px(1),
801        }),
802    )),
803    CssPropertyWithConditions::simple(CssProperty::BorderTopWidth(
804        LayoutBorderTopWidthValue::Exact(LayoutBorderTopWidth {
805            inner: PixelValue::const_px(1),
806        }),
807    )),
808    CssPropertyWithConditions::simple(CssProperty::BorderBottomStyle(
809        StyleBorderBottomStyleValue::Exact(StyleBorderBottomStyle {
810            inner: BorderStyle::Solid,
811        }),
812    )),
813    CssPropertyWithConditions::simple(CssProperty::BorderLeftStyle(
814        StyleBorderLeftStyleValue::Exact(StyleBorderLeftStyle {
815            inner: BorderStyle::Solid,
816        }),
817    )),
818    CssPropertyWithConditions::simple(CssProperty::BorderRightStyle(
819        StyleBorderRightStyleValue::Exact(StyleBorderRightStyle {
820            inner: BorderStyle::Solid,
821        }),
822    )),
823    CssPropertyWithConditions::simple(CssProperty::BorderTopStyle(
824        StyleBorderTopStyleValue::Exact(StyleBorderTopStyle {
825            inner: BorderStyle::Solid,
826        }),
827    )),
828    CssPropertyWithConditions::simple(CssProperty::BorderBottomColor(
829        StyleBorderBottomColorValue::Exact(StyleBorderBottomColor {
830            inner: ColorU {
831                r: 255,
832                g: 255,
833                b: 255,
834                a: 0,
835            },
836        }),
837    )),
838    CssPropertyWithConditions::simple(CssProperty::BorderLeftColor(
839        StyleBorderLeftColorValue::Exact(StyleBorderLeftColor {
840            inner: ColorU {
841                r: 255,
842                g: 255,
843                b: 255,
844                a: 0,
845            },
846        }),
847    )),
848    CssPropertyWithConditions::simple(CssProperty::BorderRightColor(
849        StyleBorderRightColorValue::Exact(StyleBorderRightColor {
850            inner: ColorU {
851                r: 255,
852                g: 255,
853                b: 255,
854                a: 0,
855            },
856        }),
857    )),
858    CssPropertyWithConditions::simple(CssProperty::BorderTopColor(
859        StyleBorderTopColorValue::Exact(StyleBorderTopColor {
860            inner: ColorU {
861                r: 255,
862                g: 255,
863                b: 255,
864                a: 0,
865            },
866        }),
867    )),
868    CssPropertyWithConditions::simple(CssProperty::AlignItems(LayoutAlignItemsValue::Exact(
869        LayoutAlignItems::Center,
870    ))),
871];
872const CSS_MATCH_7938442083662451131: CssPropertyWithConditionsVec =
873    CssPropertyWithConditionsVec::from_const_slice(CSS_MATCH_7938442083662451131_PROPERTIES);
874
875pub type DropDownOnChoiceChangeCallbackType = extern "C" fn(RefAny, CallbackInfo, usize) -> Update;
876impl_widget_callback!(
877    DropDownOnChoiceChange,
878    OptionDropDownOnChoiceChange,
879    DropDownOnChoiceChangeCallback,
880    DropDownOnChoiceChangeCallbackType
881);
882
883#[repr(C)]
884pub struct DropDown {
885    pub choices: StringVec,
886    pub selected: usize,
887    pub on_choice_change: OptionDropDownOnChoiceChange,
888}
889
890impl Default for DropDown {
891    fn default() -> Self {
892        Self {
893            choices: StringVec::from_const_slice(&[]),
894            selected: 0,
895            on_choice_change: None.into(),
896        }
897    }
898}
899
900impl DropDown {
901    pub fn new(choices: StringVec) -> Self {
902        Self {
903            choices,
904            selected: 0,
905            on_choice_change: None.into(),
906        }
907    }
908
909    pub fn swap_with_default(&mut self) -> Self {
910        let mut m = DropDown::default();
911        core::mem::swap(&mut m, self);
912        m
913    }
914
915    pub fn dom(self) -> Dom {
916        let refany = RefAny::new(self);
917
918        Dom::create_div()
919            .with_css_props(CSS_MATCH_4428877324022630014)
920            .with_ids_and_classes({
921                const IDS_AND_CLASSES_9466018534284317754: &[IdOrClass] =
922                    &[Class(AzString::from_const_str("__azul-native-dropdown"))];
923                IdOrClassVec::from_const_slice(IDS_AND_CLASSES_9466018534284317754)
924            })
925            .with_children(DomVec::from_vec(vec![Dom::create_div()
926                .with_css_props(CSS_MATCH_10188117026223137249)
927                .with_ids_and_classes({
928                    const IDS_AND_CLASSES_6395608618544226348: &[IdOrClass] = &[Class(
929                        AzString::from_const_str("__azul-native-dropdown-wrapper"),
930                    )];
931                    IdOrClassVec::from_const_slice(IDS_AND_CLASSES_6395608618544226348)
932                })
933                .with_tab_index(TabIndex::Auto)
934                .with_callbacks(
935                    vec![CoreCallbackData {
936                        event: EventFilter::Focus(FocusEventFilter::FocusReceived),
937                        refany: refany.clone(),
938                        callback: CoreCallback {
939                            cb: on_dropdown_click as usize,
940                            ctx: azul_core::refany::OptionRefAny::None,
941                        },
942                    }]
943                    .into(),
944                )
945                .with_children(DomVec::from_vec(vec![
946                    Dom::create_div()
947                        .with_css_props(CSS_MATCH_7938442083662451131)
948                        .with_ids_and_classes({
949                            const IDS_AND_CLASSES_11862789041977911489: &[IdOrClass] = &[Class(
950                                AzString::from_const_str("__azul-native-dropdown-focused-text"),
951                            )];
952                            IdOrClassVec::from_const_slice(IDS_AND_CLASSES_11862789041977911489)
953                        })
954                        .with_children(DomVec::from_vec(vec![Dom::create_text(
955                            AzString::from_const_str("Checkbox"),
956                        )
957                        .with_css_props(CSS_MATCH_16432538576103237591)])),
958                    Dom::create_div()
959                        .with_css_props(CSS_MATCH_6763840958685503000)
960                        .with_ids_and_classes({
961                            const IDS_AND_CLASSES_17649077225810153180: &[IdOrClass] = &[Class(
962                                AzString::from_const_str("__azul-native-dropdown-arrow"),
963                            )];
964                            IdOrClassVec::from_const_slice(IDS_AND_CLASSES_17649077225810153180)
965                        })
966                        .with_children(DomVec::from_vec(vec![Dom::create_div()
967                            .with_css_props(CSS_MATCH_4687758758634879229)
968                            .with_ids_and_classes({
969                                const IDS_AND_CLASSES_17777388057004109464: &[IdOrClass] =
970                                    &[Class(AzString::from_const_str(
971                                        "__azul-native-dropdown-arrow-wrapper",
972                                    ))];
973                                IdOrClassVec::from_const_slice(IDS_AND_CLASSES_17777388057004109464)
974                            })
975                            .with_children(DomVec::from_vec(vec![Dom::create_div()
976                                .with_css_props(CSS_MATCH_5369484915686807864)
977                                .with_ids_and_classes({
978                                    const IDS_AND_CLASSES_12603885741328163120: &[IdOrClass] =
979                                        &[Class(AzString::from_const_str(
980                                            "__azul-native-dropdown-arrow-content",
981                                        ))];
982                                    IdOrClassVec::from_const_slice(
983                                        IDS_AND_CLASSES_12603885741328163120,
984                                    )
985                                })]))])),
986                ]))]))
987    }
988}
989
990// dataset holding the choices
991struct DropDownLocalDataset {
992    choices: StringVec,
993    selected: usize,
994    on_choice_change: OptionDropDownOnChoiceChange,
995}
996
997// dataset for individual menu item callback
998struct ChoiceCallbackData {
999    choice_id: usize,
1000    on_choice_change: OptionDropDownOnChoiceChange,
1001}
1002
1003extern "C" fn on_dropdown_click(mut refany: RefAny, mut info: CallbackInfo) -> Update {
1004    let refany = match refany.downcast_ref::<DropDown>() {
1005        Some(s) => s,
1006        None => return Update::DoNothing,
1007    };
1008
1009    // Build menu items from choices
1010    let menu_items: Vec<MenuItem> = refany
1011        .choices
1012        .iter()
1013        .enumerate()
1014        .map(|(idx, choice)| {
1015            MenuItem::String(StringMenuItem::create(choice.clone()).with_callback(
1016                RefAny::new(ChoiceCallbackData {
1017                    choice_id: idx,
1018                    on_choice_change: refany.on_choice_change.clone(),
1019                }),
1020                on_choice_selected as usize,
1021            ))
1022        })
1023        .collect();
1024
1025    let menu = Menu {
1026        items: menu_items.into(),
1027        position: MenuPopupPosition::BottomOfHitRect,
1028        ..Default::default()
1029    };
1030
1031    // Open native menu positioned below the dropdown
1032    info.open_menu_for_hit_node(menu);
1033
1034    Update::DoNothing
1035}
1036
1037extern "C" fn on_choice_selected(mut refany: RefAny, info: CallbackInfo) -> Update {
1038    let mut refany = match refany.downcast_mut::<ChoiceCallbackData>() {
1039        Some(s) => s,
1040        None => return Update::DoNothing,
1041    };
1042
1043    let choice_id = refany.choice_id;
1044
1045    match refany.on_choice_change.as_mut() {
1046        Some(DropDownOnChoiceChange { refany, callback }) => {
1047            (callback.cb)(refany.clone(), info.clone(), choice_id)
1048        }
1049        None => Update::DoNothing,
1050    }
1051}
1052
1053impl From<DropDown> for Dom {
1054    fn from(b: DropDown) -> Dom {
1055        b.dom()
1056    }
1057}