1use zng_wgt::prelude::*;
4
5#[widget($crate::vr::Vr)]
7pub struct Vr(super::RuleLine);
8impl Vr {
9 fn widget_intrinsic(&mut self) {
10 widget_set! {
11 self;
12 orientation = LineOrientation::Vertical;
13 color = COLOR_VAR;
14 stroke_thickness = STROKE_THICKNESS_VAR;
15 line_style = LINE_STYLE_VAR;
16 margin = MARGIN_VAR;
17 length = HEIGHT_VAR;
18 }
19 }
20}
21
22context_var! {
23 pub static COLOR_VAR: Rgba = zng_wgt_text::FONT_COLOR_VAR.map(|c| c.with_alpha(30.pct()));
27
28 pub static STROKE_THICKNESS_VAR: Length = 1.dip();
30
31 pub static LINE_STYLE_VAR: LineStyle = LineStyle::Solid;
33
34 pub static MARGIN_VAR: SideOffsets = (0, 4);
38
39 pub static HEIGHT_VAR: Length = Length::Default;
43}
44
45#[property(CONTEXT, default(COLOR_VAR))]
51pub fn color(child: impl IntoUiNode, color: impl IntoVar<Rgba>) -> UiNode {
52 with_context_var(child, COLOR_VAR, color)
53}
54
55#[property(CONTEXT, default(STROKE_THICKNESS_VAR))]
61pub fn stroke_thickness(child: impl IntoUiNode, thickness: impl IntoVar<Length>) -> UiNode {
62 with_context_var(child, STROKE_THICKNESS_VAR, thickness)
63}
64
65#[property(CONTEXT, default(LINE_STYLE_VAR))]
71pub fn line_style(child: impl IntoUiNode, style: impl IntoVar<LineStyle>) -> UiNode {
72 with_context_var(child, LINE_STYLE_VAR, style)
73}
74
75#[property(CONTEXT, default(MARGIN_VAR))]
81pub fn margin(child: impl IntoUiNode, margin: impl IntoVar<SideOffsets>) -> UiNode {
82 with_context_var(child, MARGIN_VAR, margin)
83}
84
85#[property(CONTEXT, default(HEIGHT_VAR))]
91pub fn height(child: impl IntoUiNode, height: impl IntoVar<Length>) -> UiNode {
92 with_context_var(child, HEIGHT_VAR, height)
93}