use crate::layer::LayerStyle;
use crate::layers::Line;
use crate::property::table::{PropertyInfo, PropertyTable, PropertyVisitor};
crate::properties!(
#[expect(non_snake_case, reason = "named as a type: the module stands for the layer's set of properties")]
pub mod LineLayoutProperties: layout {
line_cap: data_driven LineCapType = LineCapType::Butt,
line_join: data_driven LineJoinType = LineJoinType::Miter,
line_miter_limit: data_driven f32 = 2.0_f32,
line_round_limit: data_driven f32 = 1.05_f32,
line_sort_key: data_driven f32 = 0.0_f32,
}
use crate::types::LineCapType, crate::types::LineJoinType;
);
crate::properties!(
#[expect(non_snake_case, reason = "named as a type: the module stands for the layer's set of properties")]
pub mod LinePaintProperties: paint {
line_blur: data_driven f32 = 0.0_f32,
line_color: data_driven Color = Color::black(),
line_dasharray: cross_faded_or_data_driven Vec<f32> = Vec::new(),
line_gap_width: data_driven f32 = 0.0_f32,
line_gradient: color_ramp Color = Color::default(),
line_layer_blend: constant LayerBlendType = LayerBlendType::Normal,
line_layer_opacity: constant f32 = 1.0_f32,
line_offset: data_driven f32 = 0.0_f32,
line_opacity: data_driven f32 = 1.0_f32,
line_pattern: cross_faded_data_driven Image = Image::default(),
line_translate: constant [f32; 2] = [0.0_f32, 0.0_f32],
line_translate_anchor: constant TranslateAnchorType = TranslateAnchorType::Map,
line_width: data_driven f32 = 1.0_f32,
}
derived {
line_floor_width: integer_zoom f32 = 1.0_f32 => line_width,
}
use crate::color::Color, crate::expression::Image, crate::types::LayerBlendType, crate::types::TranslateAnchorType;
);
pub(crate) static PROPERTIES: PropertyTable = PropertyTable::new(
&[
PropertyInfo::paint("line-blur").data_driven(),
PropertyInfo::paint("line-color").data_driven(),
PropertyInfo::paint("line-dasharray").data_driven().cross_faded(),
PropertyInfo::paint("line-gap-width").data_driven(),
PropertyInfo::paint("line-gradient"),
PropertyInfo::paint("line-layer-blend"),
PropertyInfo::paint("line-layer-opacity"),
PropertyInfo::paint("line-offset").data_driven(),
PropertyInfo::paint("line-opacity").data_driven(),
PropertyInfo::paint("line-pattern").data_driven().cross_faded(),
PropertyInfo::paint("line-translate"),
PropertyInfo::paint("line-translate-anchor"),
PropertyInfo::paint("line-width").data_driven(),
PropertyInfo::layout("line-cap").data_driven(),
PropertyInfo::layout("line-join").data_driven(),
PropertyInfo::layout("line-miter-limit").data_driven(),
PropertyInfo::layout("line-round-limit").data_driven(),
PropertyInfo::layout("line-sort-key").data_driven(),
],
&[0, 13, 1, 2, 3, 4, 14, 5, 6, 15, 7, 8, 9, 16, 17, 10, 11, 12],
);
pub(crate) fn visit<V: PropertyVisitor<LayerStyle<Line>>>(slot: usize, visitor: V) -> Option<V::Output> {
Some(match slot {
0 => visitor.paint(|s| &s.paint.line_blur, |s| &mut s.paint.line_blur),
1 => visitor.paint(|s| &s.paint.line_color, |s| &mut s.paint.line_color),
2 => visitor.paint(|s| &s.paint.line_dasharray, |s| &mut s.paint.line_dasharray),
3 => visitor.paint(|s| &s.paint.line_gap_width, |s| &mut s.paint.line_gap_width),
4 => visitor.paint(|s| &s.paint.line_gradient, |s| &mut s.paint.line_gradient),
5 => visitor.paint(|s| &s.paint.line_layer_blend, |s| &mut s.paint.line_layer_blend),
6 => visitor.paint(|s| &s.paint.line_layer_opacity, |s| &mut s.paint.line_layer_opacity),
7 => visitor.paint(|s| &s.paint.line_offset, |s| &mut s.paint.line_offset),
8 => visitor.paint(|s| &s.paint.line_opacity, |s| &mut s.paint.line_opacity),
9 => visitor.paint(|s| &s.paint.line_pattern, |s| &mut s.paint.line_pattern),
10 => visitor.paint(|s| &s.paint.line_translate, |s| &mut s.paint.line_translate),
11 => visitor.paint(|s| &s.paint.line_translate_anchor, |s| &mut s.paint.line_translate_anchor),
12 => visitor.paint(|s| &s.paint.line_width, |s| &mut s.paint.line_width),
13 => visitor.layout(|s| &s.layout.line_cap, |s| &mut s.layout.line_cap),
14 => visitor.layout(|s| &s.layout.line_join, |s| &mut s.layout.line_join),
15 => visitor.layout(|s| &s.layout.line_miter_limit, |s| &mut s.layout.line_miter_limit),
16 => visitor.layout(|s| &s.layout.line_round_limit, |s| &mut s.layout.line_round_limit),
17 => visitor.layout(|s| &s.layout.line_sort_key, |s| &mut s.layout.line_sort_key),
_ => return None,
})
}