Skip to main content

mln_style/layers/
background_layer_properties.rs

1// This file is generated by //tools/style-codegen from the style spec
2// (tools/style-codegen/v8.json). Do not edit.
3
4use crate::layer::LayerStyle;
5use crate::layers::Background;
6use crate::property::table::{PropertyInfo, PropertyTable, PropertyVisitor};
7
8crate::properties!(
9    /// The paint properties of a background layer.
10    #[expect(non_snake_case, reason = "named as a type: the module stands for the layer's set of properties")]
11    pub mod BackgroundPaintProperties: paint {
12        background_color: constant Color = Color::black(),
13        background_opacity: constant f32 = 1.0_f32,
14        background_pattern: cross_faded Image = Image::default(),
15    }
16    use crate::color::Color, crate::expression::Image;
17);
18
19/// The properties, by slot.
20pub(crate) static PROPERTIES: PropertyTable = PropertyTable::new(
21    &[
22        PropertyInfo::paint("background-color"),
23        PropertyInfo::paint("background-opacity"),
24        PropertyInfo::paint("background-pattern"),
25    ],
26    &[0, 1, 2],
27);
28
29/// Calls `visitor` with the field of the property in `slot`.
30pub(crate) fn visit<V: PropertyVisitor<LayerStyle<Background>>>(slot: usize, visitor: V) -> Option<V::Output> {
31    Some(match slot {
32        0 => visitor.paint(|s| &s.paint.background_color, |s| &mut s.paint.background_color),
33        1 => visitor.paint(|s| &s.paint.background_opacity, |s| &mut s.paint.background_opacity),
34        2 => visitor.paint(|s| &s.paint.background_pattern, |s| &mut s.paint.background_pattern),
35        _ => return None,
36    })
37}