Skip to main content

damascene_core/tree/
defaults.rs

1//! Default values for [`El`].
2//!
3//! Keeping this separate from the field list makes it easier to review
4//! default-policy changes without scanning the whole node surface.
5
6use crate::image::ImageFit;
7use crate::math::MathDisplay;
8use crate::style::StyleProfile;
9
10use super::geometry::{Corners, Sides};
11use super::layout_types::{Align, Axis, Justify, Size};
12use super::node::El;
13use super::semantics::{Kind, Source, SurfaceRole};
14use super::text_types::{FontFamily, FontWeight, TextAlign, TextOverflow, TextRole, TextWrap};
15
16impl Default for El {
17    fn default() -> Self {
18        Self {
19            kind: Kind::Group,
20            style_profile: StyleProfile::TextOnly,
21            key: None,
22            block_pointer: false,
23            hit_overflow: Sides::zero(),
24            focusable: false,
25            focus_ring_placement: Default::default(),
26            always_show_focus_ring: false,
27            selectable: false,
28            consumes_touch_drag: false,
29            selection_source: None,
30            capture_keys: false,
31            alpha_follows_focused_ancestor: false,
32            blink_when_focused: false,
33            state_follows_interactive_ancestor: false,
34            hover_alpha: None,
35            source: Source::default(),
36            allow_lint: Vec::new(),
37            axis: Axis::Overlay,
38            gap: 0.0,
39            padding: Sides::zero(),
40            align: Align::Stretch,
41            justify: Justify::Start,
42            width: Size::Hug,
43            height: Size::Hug,
44            min_width: None,
45            max_width: None,
46            min_height: None,
47            max_height: None,
48            component_size: None,
49            metrics_role: None,
50            explicit_width: false,
51            explicit_height: false,
52            explicit_padding: false,
53            explicit_gap: false,
54            explicit_radius: false,
55            explicit_font_family: false,
56            explicit_mono_font_family: false,
57            explicit_mono: false,
58            fill: None,
59            dim_fill: None,
60            stroke: None,
61            stroke_width: 0.0,
62            radius: Corners::ZERO,
63            shadow: 0.0,
64            surface_role: SurfaceRole::None,
65            paint_overflow: Sides::zero(),
66            clip: false,
67            scrollable: false,
68            pin_policy: crate::tree::PinPolicy::None,
69            arrow_nav_siblings: false,
70            tooltip: None,
71            cursor: None,
72            cursor_pressed: None,
73            shader_override: None,
74            layout_override: None,
75            virtual_items: None,
76            scrollbar: false,
77            text: None,
78            text_color: None,
79            text_align: TextAlign::Start,
80            text_wrap: TextWrap::NoWrap,
81            text_overflow: TextOverflow::Clip,
82            text_role: TextRole::Body,
83            text_max_lines: None,
84            font_size: crate::tokens::TEXT_SM.size,
85            line_height: crate::tokens::TEXT_SM.line_height,
86            font_family: FontFamily::default(),
87            mono_font_family: FontFamily::JetBrainsMono,
88            font_weight: FontWeight::Regular,
89            font_mono: false,
90            text_italic: false,
91            text_bg: None,
92            text_underline: false,
93            text_strikethrough: false,
94            text_link: None,
95            math: None,
96            math_display: MathDisplay::Inline,
97            icon: None,
98            icon_stroke_width: 2.0,
99            image: None,
100            image_tint: None,
101            image_fit: ImageFit::Contain,
102            surface_source: None,
103            surface_alpha: crate::surface::SurfaceAlpha::Premultiplied,
104            surface_fit: ImageFit::Fill,
105            surface_transform: crate::affine::Affine2::IDENTITY,
106            scene_source: None,
107            vector_source: None,
108            vector_render_mode: crate::vector::VectorRenderMode::Painted,
109            children: Vec::new(),
110            opacity: 1.0,
111            translate: (0.0, 0.0),
112            scale: 1.0,
113            animate: None,
114            redraw_within: None,
115            computed_id: String::new(),
116        }
117    }
118}