summaryrefslogtreecommitdiff
path: root/src/mbgl/style/layers/layer_properties.hpp.ejs
blob: 11a1db33c70885a41304c4383e785790c8d05be0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<%
  const type = locals.type;
  const layoutProperties = locals.layoutProperties;
  const paintProperties = locals.paintProperties;
-%>
// This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`.

#pragma once

#include <mbgl/style/types.hpp>
#include <mbgl/style/layer_properties.hpp>
#include <mbgl/style/layers/<%- type.replace('-', '_') %>_layer.hpp>
#include <mbgl/style/layout_property.hpp>
#include <mbgl/style/paint_property.hpp>
#include <mbgl/style/properties.hpp>
#include <mbgl/programs/attributes.hpp>
#include <mbgl/programs/uniforms.hpp>

namespace mbgl {
namespace style {

<% for (const property of layoutProperties) { -%>
struct <%- camelize(property.name) %> : <%- layoutPropertyType(property, type) %> {
    static constexpr const char *name() { return "<%- property.name %>"; }
    static <%- evaluatedType(property) %> defaultValue() { return <%- defaultValue(property) %>; }
};

<% } -%>
<% for (const property of paintProperties) { -%>
<%   if (property['property-type'] === 'color-ramp') { -%>
struct <%- camelize(property.name) %> : ColorRampProperty {
};
<%   } else { -%>
struct <%- camelize(property.name) %> : <%- paintPropertyType(property, type) %> {
    static <%- evaluatedType(property) %> defaultValue() { return <%- defaultValue(property) %>; }
<% if (isOverridable(property)) { -%>
    static constexpr const char *name() { return "<%- property.name %>"; }
    static constexpr auto expressionType() { return expression::type::<%- expressionType(property) %>{}; };
    template<typename T> static bool hasOverride(const T& t) { return !!t.<%- camelizeWithLeadingLowercase(property.name) %>; };
<% } -%>
};
<% if (property.name === 'line-width') { -%>

struct LineFloorWidth : DataDrivenPaintProperty<float, attributes::floorwidth, uniforms::floorwidth> {
    using EvaluatorType = DataDrivenPropertyEvaluator<float, true>;
    static float defaultValue() { return 1.0f; }
};
<% } -%>
<%   } -%>

<% } -%>
<% if (layoutProperties.length) { -%>
class <%- camelize(type) %>LayoutProperties : public Properties<
<% for (const property of layoutProperties.slice(0, -1)) { -%>
    <%- camelize(property.name) %>,
<% } -%>
    <%- camelize(layoutProperties.slice(-1)[0].name) %>
> {};

<% } -%>
class <%- camelize(type) %>PaintProperties : public Properties<
<% for (const property of paintProperties.slice(0, -1)) { -%>
    <%- camelize(property.name) %>,
<% if (property.name === 'line-width') { -%>
    LineFloorWidth,
<% } -%>
<% } -%>
    <%- camelize(paintProperties.slice(-1)[0].name) %>
> {};

class <%- camelize(type) %>LayerProperties final : public LayerProperties {
public:
    explicit <%- camelize(type) %>LayerProperties(Immutable<<%- camelize(type) %>Layer::Impl>);
    <%- camelize(type) %>LayerProperties(
        Immutable<<%- camelize(type) %>Layer::Impl>,
<% if (type === 'background' || type === 'fill' || type === 'line' || type === 'fill-extrusion') { -%>
        CrossfadeParameters,
<% } -%>
        <%- camelize(type) %>PaintProperties::PossiblyEvaluated);
    ~<%- camelize(type) %>LayerProperties() override;

    const <%- camelize(type) %>Layer::Impl& layerImpl() const;
    // Data members.
<% if (type === 'background' || type === 'fill' || type === 'line' || type === 'fill-extrusion') { -%>
    CrossfadeParameters crossfade;
<% } -%>
    <%- camelize(type) %>PaintProperties::PossiblyEvaluated evaluated;
};

} // namespace style
} // namespace mbgl