[core] Rationalize style property classes: <type>{Paint,Layout}Properties
This commit is contained in:
@@ -13,8 +13,8 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
struct FillProperties {
|
||||
FillProperties() {}
|
||||
class FillPaintProperties {
|
||||
public:
|
||||
bool antialias = true;
|
||||
float opacity = 1.0f;
|
||||
Color fill_color = {{ 0, 0, 0, 1 }};
|
||||
@@ -28,8 +28,12 @@ struct FillProperties {
|
||||
}
|
||||
};
|
||||
|
||||
struct LineProperties {
|
||||
inline LineProperties() {}
|
||||
class FillLayoutProperties {
|
||||
public:
|
||||
};
|
||||
|
||||
class LinePaintProperties {
|
||||
public:
|
||||
float opacity = 1.0f;
|
||||
Color color = {{ 0, 0, 0, 1 }};
|
||||
std::array<float, 2> translate = {{ 0, 0 }};
|
||||
@@ -46,23 +50,16 @@ struct LineProperties {
|
||||
}
|
||||
};
|
||||
|
||||
struct CircleProperties {
|
||||
inline CircleProperties() {}
|
||||
float radius = 5.0f;
|
||||
Color color = {{ 0, 0, 0, 1 }};
|
||||
float opacity = 1.0f;
|
||||
std::array<float, 2> translate = {{ 0, 0 }};
|
||||
TranslateAnchorType translateAnchor = TranslateAnchorType::Map;
|
||||
float blur = 0;
|
||||
|
||||
inline bool isVisible() const {
|
||||
return radius > 0 && color[3] > 0 && opacity > 0;
|
||||
}
|
||||
class LineLayoutProperties {
|
||||
public:
|
||||
CapType cap = CapType::Butt;
|
||||
JoinType join = JoinType::Miter;
|
||||
float miter_limit = 2.0f;
|
||||
float round_limit = 1.0f;
|
||||
};
|
||||
|
||||
struct SymbolProperties {
|
||||
inline SymbolProperties() {}
|
||||
|
||||
class SymbolPaintProperties {
|
||||
public:
|
||||
struct {
|
||||
float opacity = 1.0f;
|
||||
float size = 1.0f;
|
||||
@@ -91,8 +88,66 @@ struct SymbolProperties {
|
||||
}
|
||||
};
|
||||
|
||||
struct RasterProperties {
|
||||
inline RasterProperties() {}
|
||||
class SymbolLayoutProperties {
|
||||
public:
|
||||
PlacementType placement = PlacementType::Point;
|
||||
float spacing = 250.0f;
|
||||
bool avoid_edges = false;
|
||||
|
||||
struct {
|
||||
bool allow_overlap = false;
|
||||
bool ignore_placement = false;
|
||||
bool optional = false;
|
||||
RotationAlignmentType rotation_alignment = RotationAlignmentType::Viewport;
|
||||
float size = 1.0f;
|
||||
float max_size = 1.0f;
|
||||
std::string image;
|
||||
float rotate = 0.0f;
|
||||
float padding = 2.0f;
|
||||
bool keep_upright = false;
|
||||
std::array<float, 2> offset = {{ 0, 0 }};
|
||||
} icon;
|
||||
|
||||
struct {
|
||||
RotationAlignmentType rotation_alignment = RotationAlignmentType::Viewport;
|
||||
std::string field;
|
||||
std::string font = "Open Sans Regular, Arial Unicode MS Regular";
|
||||
float size = 16.0f;
|
||||
float max_size = 16.0f;
|
||||
float max_width = 15.0f /* em */;
|
||||
float line_height = 1.2f /* em */;
|
||||
float letter_spacing = 0.0f /* em */;
|
||||
TextJustifyType justify = TextJustifyType::Center;
|
||||
TextAnchorType anchor = TextAnchorType::Center;
|
||||
float max_angle = 45.0f /* degrees */;
|
||||
float rotate = 0.0f;
|
||||
float padding = 2.0f;
|
||||
bool keep_upright = true;
|
||||
TextTransformType transform = TextTransformType::None;
|
||||
std::array<float, 2> offset = {{ 0, 0 }};
|
||||
bool allow_overlap = false;
|
||||
bool ignore_placement = false;
|
||||
bool optional = false;
|
||||
} text;
|
||||
};
|
||||
|
||||
|
||||
class CirclePaintProperties {
|
||||
public:
|
||||
float radius = 5.0f;
|
||||
Color color = {{ 0, 0, 0, 1 }};
|
||||
float opacity = 1.0f;
|
||||
std::array<float, 2> translate = {{ 0, 0 }};
|
||||
TranslateAnchorType translateAnchor = TranslateAnchorType::Map;
|
||||
float blur = 0;
|
||||
|
||||
inline bool isVisible() const {
|
||||
return radius > 0 && color[3] > 0 && opacity > 0;
|
||||
}
|
||||
};
|
||||
|
||||
class RasterPaintProperties {
|
||||
public:
|
||||
float opacity = 1.0f;
|
||||
float hue_rotate = 0.0f;
|
||||
std::array<float, 2> brightness = {{ 0, 1 }};
|
||||
@@ -105,26 +160,31 @@ struct RasterProperties {
|
||||
}
|
||||
};
|
||||
|
||||
struct BackgroundProperties {
|
||||
inline BackgroundProperties() {}
|
||||
class RasterLayoutProperties {
|
||||
public:
|
||||
};
|
||||
|
||||
class BackgroundPaintProperties {
|
||||
public:
|
||||
float opacity = 1.0f;
|
||||
Color color = {{ 0, 0, 0, 1 }};
|
||||
Faded<std::string> image;
|
||||
};
|
||||
|
||||
class BackgroundLayoutProperties {
|
||||
public:
|
||||
};
|
||||
|
||||
typedef mapbox::util::variant<
|
||||
FillProperties,
|
||||
LineProperties,
|
||||
CircleProperties,
|
||||
SymbolProperties,
|
||||
RasterProperties,
|
||||
BackgroundProperties,
|
||||
FillPaintProperties,
|
||||
LinePaintProperties,
|
||||
CirclePaintProperties,
|
||||
SymbolPaintProperties,
|
||||
RasterPaintProperties,
|
||||
BackgroundPaintProperties,
|
||||
std::false_type
|
||||
> StyleProperties;
|
||||
|
||||
template <typename T>
|
||||
const T &defaultStyleProperties();
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user