mln_style/layers/
fill_layer.rs1use crate::layer::{LayerStyle, LayerTypeInfo, SourceKind, StyleLayerType};
2use crate::layers::fill_layer_properties::{self, FillLayoutProperties, FillPaintProperties};
3use crate::property::table::{PropertyTable, PropertyVisitor};
4use crate::property::value::PropertyValue;
5use crate::types::LayerBlendType;
6
7pub struct Fill;
9
10impl StyleLayerType for Fill {
11 const INFO: LayerTypeInfo = LayerTypeInfo { name: "fill", source: SourceKind::Geometry, from_json: true };
12 const PROPERTIES: &'static PropertyTable = &fill_layer_properties::PROPERTIES;
13
14 type LayoutProperties = FillLayoutProperties::Unevaluated;
15 type PaintProperties = FillPaintProperties::Transitionable;
16 type Extra = ();
17
18 fn visit_property<V: PropertyVisitor<LayerStyle<Self>>>(slot: usize, visitor: V) -> Option<V::Output> {
19 fill_layer_properties::visit(slot, visitor)
20 }
21
22 fn paint_lays_out(before: &LayerStyle<Self>, after: &LayerStyle<Self>) -> bool {
27 !rounds_corners(before) && rounds_corners(after)
28 }
29
30 fn layer_blend(paint: &FillPaintProperties::PossiblyEvaluated) -> LayerBlendType {
31 *paint.fill_layer_blend.uniform()
32 }
33}
34
35#[must_use]
38pub fn rounds_corners(style: &LayerStyle<Fill>) -> bool {
39 match &style.paint.fill_rounded_corner_distance.value {
40 PropertyValue::Undefined => false,
41 PropertyValue::Constant(distance) => *distance > 0.0,
42 PropertyValue::Expression(_) => true,
43 }
44}