move StyleLayerGroup and PropertyTransition to their own files
This commit is contained in:
@@ -132,7 +132,7 @@ private:
|
||||
|
||||
// Unconditionally performs a render with the current map state.
|
||||
void render();
|
||||
void renderLayers(std::shared_ptr<StyleLayerGroup> layers);
|
||||
void renderLayers(std::shared_ptr<StyleLayerGroup> group);
|
||||
void renderLayer(std::shared_ptr<StyleLayer> layer_desc, RenderPass pass);
|
||||
|
||||
private:
|
||||
|
||||
@@ -16,7 +16,7 @@ class GlyphStore;
|
||||
class SpriteAtlas;
|
||||
class VectorTileData;
|
||||
class StyleLayer;
|
||||
typedef std::vector<std::shared_ptr<StyleLayer>> StyleLayerGroup;
|
||||
class StyleLayerGroup;
|
||||
class StyleBucket;
|
||||
class StyleBucketFill;
|
||||
class StyleBucketLine;
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
private:
|
||||
bool obsolete() const;
|
||||
void parseGlyphs();
|
||||
void parseStyleLayers(std::shared_ptr<StyleLayerGroup> layers);
|
||||
void parseStyleLayers(std::shared_ptr<StyleLayerGroup> group);
|
||||
void addGlyph(uint64_t tileid, const std::string stackname, const std::u32string &string, const FontStack &fontStack, GlyphAtlas &glyphAtlas, GlyphPositions &face);
|
||||
std::unique_ptr<Bucket> createBucket(std::shared_ptr<StyleBucket> bucket_desc);
|
||||
|
||||
|
||||
@@ -14,10 +14,10 @@ public:
|
||||
AppliedClassProperty(ClassID class_id, timestamp begin, timestamp end, const PropertyValue &value);
|
||||
|
||||
public:
|
||||
ClassID name;
|
||||
timestamp begin;
|
||||
timestamp end;
|
||||
PropertyValue value;
|
||||
const ClassID name;
|
||||
const timestamp begin;
|
||||
const timestamp end;
|
||||
const PropertyValue value;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -3,16 +3,12 @@
|
||||
|
||||
#include <llmr/style/property_key.hpp>
|
||||
#include <llmr/style/property_value.hpp>
|
||||
#include <llmr/style/property_transition.hpp>
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace llmr {
|
||||
|
||||
struct ClassPropertyTransition {
|
||||
uint16_t duration = 0;
|
||||
uint16_t delay = 0;
|
||||
};
|
||||
|
||||
class ClassProperties {
|
||||
public:
|
||||
inline ClassProperties() {}
|
||||
@@ -28,7 +24,7 @@ public:
|
||||
transitions.emplace(::std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
inline const ClassPropertyTransition &getTransition(PropertyKey key, const ClassPropertyTransition &defaultTransition) const {
|
||||
inline const PropertyTransition &getTransition(PropertyKey key, const PropertyTransition &defaultTransition) const {
|
||||
auto it = transitions.find(key);
|
||||
if (it == transitions.end()) {
|
||||
return defaultTransition;
|
||||
@@ -47,7 +43,7 @@ public:
|
||||
|
||||
public:
|
||||
std::map<PropertyKey, PropertyValue> properties;
|
||||
std::map<PropertyKey, ClassPropertyTransition> transitions;
|
||||
std::map<PropertyKey, PropertyTransition> transitions;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
15
include/llmr/style/property_transition.hpp
Normal file
15
include/llmr/style/property_transition.hpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef LLMR_STYLE_PROPERTY_TRANSITION
|
||||
#define LLMR_STYLE_PROPERTY_TRANSITION
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace llmr {
|
||||
|
||||
struct PropertyTransition {
|
||||
uint16_t duration = 0;
|
||||
uint16_t delay = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,11 +1,12 @@
|
||||
#ifndef LLMR_STYLE_STYLE
|
||||
#define LLMR_STYLE_STYLE
|
||||
|
||||
#include <cstdint>
|
||||
#include <llmr/style/property_transition.hpp>
|
||||
|
||||
#include <llmr/util/time.hpp>
|
||||
#include <llmr/util/uv.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
@@ -17,7 +18,7 @@ namespace llmr {
|
||||
class Sprite;
|
||||
class Source;
|
||||
class StyleLayer;
|
||||
typedef std::vector<std::shared_ptr<StyleLayer>> StyleLayerGroup;
|
||||
class StyleLayerGroup;
|
||||
|
||||
class Style {
|
||||
public:
|
||||
@@ -26,20 +27,13 @@ public:
|
||||
public:
|
||||
Style();
|
||||
|
||||
void reset();
|
||||
|
||||
void loadJSON(const uint8_t *const data);
|
||||
|
||||
size_t layerCount() const;
|
||||
void cascade(float z);
|
||||
void updateProperties(float z, timestamp t);
|
||||
|
||||
bool needsTransition() const;
|
||||
void updateTransitions(timestamp now);
|
||||
void cancelTransitions();
|
||||
void setDefaultTransitionDuration(uint16_t duration_milliseconds = 0);
|
||||
|
||||
void setDefaultTransitionDuration(uint64_t duration_milliseconds = 0);
|
||||
|
||||
void updateSources();
|
||||
const std::set<std::shared_ptr<Source>> getActiveSources() const;
|
||||
|
||||
const std::vector<std::string> &getAppliedClasses() const;
|
||||
@@ -51,14 +45,17 @@ public:
|
||||
std::shared_ptr<StyleLayer> background;
|
||||
std::vector<std::string> appliedClasses;
|
||||
|
||||
|
||||
private:
|
||||
void updateSources(const std::shared_ptr<StyleLayerGroup> &layers);
|
||||
void cascade(const std::shared_ptr<StyleLayerGroup> &layers, float z);
|
||||
void updateSources();
|
||||
void updateSources(const std::shared_ptr<StyleLayerGroup> &group);
|
||||
|
||||
void updateProperties(const std::shared_ptr<StyleLayerGroup> &group, float z, timestamp t);
|
||||
|
||||
void updateClasses();
|
||||
|
||||
private:
|
||||
std::set<std::shared_ptr<Source>> activeSources;
|
||||
uint64_t default_transition_duration = 0;
|
||||
PropertyTransition defaultTransition;
|
||||
bool initial_render_complete = false;
|
||||
|
||||
mutable uv::rwlock mtx;
|
||||
|
||||
@@ -16,9 +16,7 @@
|
||||
namespace llmr {
|
||||
|
||||
class StyleBucket;
|
||||
|
||||
class StyleLayer;
|
||||
typedef std::vector<std::shared_ptr<StyleLayer>> StyleLayerGroup;
|
||||
class StyleLayerGroup;
|
||||
|
||||
class StyleLayer {
|
||||
public:
|
||||
@@ -33,16 +31,21 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
// Determines whether this layer is the background layer.
|
||||
bool isBackground() const;
|
||||
|
||||
// Updates the StyleProperties information in this layer by evaluating all
|
||||
// pending transitions and applied classes in order.
|
||||
void updateStyle(float z);
|
||||
|
||||
// Sets the list of classes and creates transitions to the currently applied values.
|
||||
void setClasses(const std::vector<std::string> &class_names, timestamp now,
|
||||
const ClassPropertyTransition &defaultTransition);
|
||||
const PropertyTransition &defaultTransition);
|
||||
|
||||
private:
|
||||
// Applies all properties from a class, if they haven't been applied already.
|
||||
void applyClassProperties(ClassID class_id, std::set<PropertyKey> &already_applied,
|
||||
timestamp now, const ClassPropertyTransition &defaultTransition);
|
||||
timestamp now, const PropertyTransition &defaultTransition);
|
||||
|
||||
public:
|
||||
// The name of this layer.
|
||||
@@ -74,7 +77,6 @@ public:
|
||||
std::shared_ptr<StyleLayerGroup> layers;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
21
include/llmr/style/style_layer_group.hpp
Normal file
21
include/llmr/style/style_layer_group.hpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef LLMR_STYLE_STYLE_LAYER_GROUP
|
||||
#define LLMR_STYLE_STYLE_LAYER_GROUP
|
||||
|
||||
#include <llmr/style/style_layer.hpp>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace llmr {
|
||||
|
||||
class StyleLayerGroup {
|
||||
public:
|
||||
void setClasses(const std::vector<std::string> &class_names, timestamp now,
|
||||
const PropertyTransition &defaultTransition);
|
||||
|
||||
public:
|
||||
std::vector<std::shared_ptr<StyleLayer>> layers;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -18,7 +18,7 @@ namespace llmr {
|
||||
enum class ClassID : uint32_t;
|
||||
|
||||
class StyleLayer;
|
||||
typedef std::vector<std::shared_ptr<StyleLayer>> StyleLayerGroup;
|
||||
class StyleLayerGroup;
|
||||
|
||||
class StyleParser {
|
||||
public:
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <llmr/util/string.hpp>
|
||||
#include <llmr/util/constants.hpp>
|
||||
#include <llmr/util/uv.hpp>
|
||||
#include <llmr/style/style_layer.hpp>
|
||||
#include <llmr/style/style_layer_group.hpp>
|
||||
#include <llmr/style/style_bucket.hpp>
|
||||
#include <llmr/geometry/sprite_atlas.hpp>
|
||||
|
||||
@@ -176,7 +176,6 @@ void Map::setup() {
|
||||
|
||||
void Map::setStyleJSON(std::string newStyleJSON) {
|
||||
styleJSON.swap(newStyleJSON);
|
||||
style->cancelTransitions();
|
||||
style->loadJSON((const uint8_t *)styleJSON.c_str());
|
||||
update();
|
||||
}
|
||||
@@ -384,14 +383,6 @@ void Map::toggleClass(const std::string &name) {
|
||||
style->toggleClass(name);
|
||||
}
|
||||
|
||||
//void Map::setAppliedClasses(const std::vector<std::string> &appliedClasses) {
|
||||
// style->cancelTransitions();
|
||||
//
|
||||
// style->appliedClasses = appliedClasses;
|
||||
//
|
||||
// update();
|
||||
//}
|
||||
|
||||
const std::vector<std::string> &Map::getAppliedClasses() const {
|
||||
return style->getAppliedClasses();
|
||||
}
|
||||
@@ -448,14 +439,8 @@ void Map::prepare() {
|
||||
painter.clearFramebuffers();
|
||||
}
|
||||
|
||||
style->cascade(state.getNormalizedZoom());
|
||||
|
||||
// Update style transitions.
|
||||
animationTime = util::now();
|
||||
if (style->needsTransition()) {
|
||||
style->updateTransitions(animationTime);
|
||||
update();
|
||||
}
|
||||
style->updateProperties(state.getNormalizedZoom(), animationTime);
|
||||
|
||||
// Allow the sprite atlas to potentially pull new sprite images if needed.
|
||||
if (style->sprite && style->sprite->isLoaded()) {
|
||||
@@ -517,14 +502,14 @@ void Map::render() {
|
||||
glFlush();
|
||||
}
|
||||
|
||||
void Map::renderLayers(std::shared_ptr<StyleLayerGroup> layers) {
|
||||
if (!layers) {
|
||||
void Map::renderLayers(std::shared_ptr<StyleLayerGroup> group) {
|
||||
if (!group) {
|
||||
// Make sure that we actually do have a layer group.
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Correctly compute the number of layers recursively beforehand.
|
||||
float strata_thickness = 1.0f / (layers->size() + 1);
|
||||
float strata_thickness = 1.0f / (group->layers.size() + 1);
|
||||
|
||||
// - FIRST PASS ------------------------------------------------------------
|
||||
// Render everything top-to-bottom by using reverse iterators. Render opaque
|
||||
@@ -533,9 +518,8 @@ void Map::renderLayers(std::shared_ptr<StyleLayerGroup> layers) {
|
||||
if (debug::renderTree) {
|
||||
std::cout << std::string(indent++ * 4, ' ') << "OPAQUE {" << std::endl;
|
||||
}
|
||||
typedef StyleLayerGroup::reverse_iterator riterator;
|
||||
int i = 0;
|
||||
for (riterator it = layers->rbegin(), end = layers->rend(); it != end; ++it, ++i) {
|
||||
for (auto it = group->layers.rbegin(), end = group->layers.rend(); it != end; ++it, ++i) {
|
||||
painter.setOpaque();
|
||||
painter.setStrata(i * strata_thickness);
|
||||
renderLayer(*it, Opaque);
|
||||
@@ -550,9 +534,8 @@ void Map::renderLayers(std::shared_ptr<StyleLayerGroup> layers) {
|
||||
if (debug::renderTree) {
|
||||
std::cout << std::string(indent++ * 4, ' ') << "TRANSLUCENT {" << std::endl;
|
||||
}
|
||||
typedef StyleLayerGroup::iterator iterator;
|
||||
--i;
|
||||
for (iterator it = layers->begin(), end = layers->end(); it != end; ++it, --i) {
|
||||
for (auto it = group->layers.begin(), end = group->layers.end(); it != end; ++it, --i) {
|
||||
painter.setTranslucent();
|
||||
painter.setStrata(i * strata_thickness);
|
||||
renderLayer(*it, Translucent);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <llmr/map/vector_tile_data.hpp>
|
||||
#include <llmr/style/style.hpp>
|
||||
#include <llmr/style/style_layer.hpp>
|
||||
#include <llmr/style/style_layer_group.hpp>
|
||||
#include <llmr/renderer/fill_bucket.hpp>
|
||||
#include <llmr/renderer/line_bucket.hpp>
|
||||
#include <llmr/renderer/icon_bucket.hpp>
|
||||
@@ -63,12 +64,12 @@ void TileParser::addGlyph(uint64_t tileid, const std::string stackname,
|
||||
}
|
||||
}
|
||||
|
||||
void TileParser::parseStyleLayers(std::shared_ptr<StyleLayerGroup> layers) {
|
||||
if (!layers) {
|
||||
void TileParser::parseStyleLayers(std::shared_ptr<StyleLayerGroup> group) {
|
||||
if (!group) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const std::shared_ptr<StyleLayer> &layer_desc : *layers) {
|
||||
for (const std::shared_ptr<StyleLayer> &layer_desc : group->layers) {
|
||||
// Cancel early when parsing.
|
||||
if (obsolete()) {
|
||||
return;
|
||||
|
||||
11
src/style/applied_class_properties.cpp
Normal file
11
src/style/applied_class_properties.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include <llmr/style/applied_class_properties.hpp>
|
||||
|
||||
namespace llmr {
|
||||
|
||||
AppliedClassProperty::AppliedClassProperty(ClassID class_id, timestamp begin, timestamp end, const PropertyValue &value)
|
||||
: name(class_id),
|
||||
begin(begin),
|
||||
end(end),
|
||||
value(value) {}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <llmr/style/style.hpp>
|
||||
#include <llmr/style/style_layer.hpp>
|
||||
#include <llmr/style/style_layer_group.hpp>
|
||||
#include <llmr/style/style_parser.hpp>
|
||||
#include <llmr/style/style_bucket.hpp>
|
||||
#include <llmr/util/constants.hpp>
|
||||
@@ -13,9 +13,6 @@ namespace llmr {
|
||||
Style::Style() {
|
||||
}
|
||||
|
||||
void Style::reset() {
|
||||
}
|
||||
|
||||
void Style::updateSources() {
|
||||
activeSources.clear();
|
||||
updateSources(layers);
|
||||
@@ -25,11 +22,11 @@ const std::set<std::shared_ptr<Source>> Style::getActiveSources() const {
|
||||
return activeSources;
|
||||
}
|
||||
|
||||
void Style::updateSources(const std::shared_ptr<StyleLayerGroup> &layers) {
|
||||
if (!layers) {
|
||||
void Style::updateSources(const std::shared_ptr<StyleLayerGroup> &group) {
|
||||
if (!group) {
|
||||
return;
|
||||
}
|
||||
for (const std::shared_ptr<StyleLayer> &layer : *layers) {
|
||||
for (const std::shared_ptr<StyleLayer> &layer : group->layers) {
|
||||
if (!layer) continue;
|
||||
if (layer->bucket) {
|
||||
if (layer->bucket->source) {
|
||||
@@ -143,16 +140,16 @@ void applyClassProperties(StyleProperties &style, const ClassProperties &propert
|
||||
}
|
||||
}
|
||||
|
||||
void Style::cascade(const std::shared_ptr<StyleLayerGroup> &layers, float z) {
|
||||
if (!layers) {
|
||||
void Style::updateProperties(const std::shared_ptr<StyleLayerGroup> &group, float z, timestamp t) {
|
||||
if (!group) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const std::shared_ptr<StyleLayer> &layer : *layers) {
|
||||
for (const std::shared_ptr<StyleLayer> &layer : group->layers) {
|
||||
if (!layer) continue;
|
||||
|
||||
if (layer->layers) {
|
||||
cascade(layer->layers, z);
|
||||
updateProperties(layer->layers, z, t);
|
||||
}
|
||||
|
||||
// Accomodate for different tile size.
|
||||
@@ -183,13 +180,12 @@ void Style::cascade(const std::shared_ptr<StyleLayerGroup> &layers, float z) {
|
||||
}
|
||||
}
|
||||
|
||||
void Style::cascade(float z) {
|
||||
void Style::updateProperties(float z, timestamp t) {
|
||||
uv::writelock lock(mtx);
|
||||
|
||||
updateSources();
|
||||
|
||||
reset();
|
||||
cascade(layers, z);
|
||||
updateProperties(layers, z, t);
|
||||
|
||||
// Apply transitions after the first time.
|
||||
if (!initial_render_complete) {
|
||||
@@ -198,22 +194,8 @@ void Style::cascade(float z) {
|
||||
}
|
||||
}
|
||||
|
||||
bool Style::needsTransition() const {
|
||||
uv::readlock lock(mtx);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Style::updateTransitions(timestamp now) {
|
||||
uv::writelock lock(mtx);
|
||||
}
|
||||
|
||||
void Style::cancelTransitions() {
|
||||
uv::writelock lock(mtx);
|
||||
}
|
||||
|
||||
void Style::setDefaultTransitionDuration(uint64_t duration_milliseconds) {
|
||||
default_transition_duration = duration_milliseconds;
|
||||
void Style::setDefaultTransitionDuration(uint16_t duration_milliseconds) {
|
||||
defaultTransition.duration = duration_milliseconds;
|
||||
}
|
||||
|
||||
const std::vector<std::string> &Style::getAppliedClasses() const {
|
||||
@@ -229,6 +211,14 @@ void Style::toggleClass(const std::string &name) {
|
||||
appliedClasses.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
updateClasses();
|
||||
}
|
||||
|
||||
void Style::updateClasses() {
|
||||
if (layers) {
|
||||
layers->setClasses(appliedClasses, util::now(), defaultTransition);
|
||||
}
|
||||
}
|
||||
|
||||
void Style::loadJSON(const uint8_t *const data) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <llmr/style/style_layer.hpp>
|
||||
#include <llmr/style/style_layer_group.hpp>
|
||||
#include <llmr/style/property_fallback.hpp>
|
||||
|
||||
namespace llmr {
|
||||
@@ -12,7 +13,7 @@ bool StyleLayer::isBackground() const {
|
||||
}
|
||||
|
||||
void StyleLayer::setClasses(const std::vector<std::string> &class_names, const timestamp now,
|
||||
const ClassPropertyTransition &defaultTransition) {
|
||||
const PropertyTransition &defaultTransition) {
|
||||
// Stores all keys that we have already added transitions for.
|
||||
std::set<PropertyKey> already_applied;
|
||||
|
||||
@@ -51,18 +52,14 @@ void StyleLayer::setClasses(const std::vector<std::string> &class_names, const t
|
||||
|
||||
// Update all child layers as well.
|
||||
if (layers) {
|
||||
for (std::shared_ptr<StyleLayer> &layer : *layers) {
|
||||
if (layer) {
|
||||
layer->setClasses(class_names, now, defaultTransition);
|
||||
}
|
||||
}
|
||||
layers->setClasses(class_names, now, defaultTransition);
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function for applying all properties of a a single class that haven't been applied yet.
|
||||
void StyleLayer::applyClassProperties(const ClassID class_id,
|
||||
std::set<PropertyKey> &already_applied, timestamp now,
|
||||
const ClassPropertyTransition &defaultTransition) {
|
||||
const PropertyTransition &defaultTransition) {
|
||||
auto style_it = styles.find(class_id);
|
||||
if (style_it == styles.end()) {
|
||||
// There is no class in this layer with this class_name.
|
||||
@@ -87,7 +84,7 @@ void StyleLayer::applyClassProperties(const ClassID class_id,
|
||||
// a transition.
|
||||
AppliedClassProperties &appliedProperties = appliedStyle[key];
|
||||
if (appliedProperties.mostRecent() != class_id) {
|
||||
const ClassPropertyTransition &transition =
|
||||
const PropertyTransition &transition =
|
||||
properties.getTransition(key, defaultTransition);
|
||||
const timestamp begin = now + transition.delay;
|
||||
const timestamp end = begin + transition.duration;
|
||||
|
||||
14
src/style/style_layer_group.cpp
Normal file
14
src/style/style_layer_group.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <llmr/style/style_layer_group.hpp>
|
||||
|
||||
namespace llmr {
|
||||
|
||||
void StyleLayerGroup::setClasses(const std::vector<std::string> &class_names, timestamp now,
|
||||
const PropertyTransition &defaultTransition) {
|
||||
for (const std::shared_ptr<StyleLayer> &layer : layers) {
|
||||
if (layer) {
|
||||
layer->setClasses(class_names, now, defaultTransition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <llmr/style/style_parser.hpp>
|
||||
#include <llmr/style/style_layer.hpp>
|
||||
#include <llmr/style/style_layer_group.hpp>
|
||||
#include <llmr/util/constants.hpp>
|
||||
#include <llmr/util/std.hpp>
|
||||
#include <csscolorparser/csscolorparser.hpp>
|
||||
@@ -257,12 +257,12 @@ template<> bool StyleParser::parseStyleProperty<Color>(const char *property_name
|
||||
return true;
|
||||
}
|
||||
|
||||
template <> bool StyleParser::parseStyleProperty<ClassPropertyTransition>(const char *property_name, PropertyKey key, ClassProperties &klass, JSVal value) {
|
||||
template <> bool StyleParser::parseStyleProperty<PropertyTransition>(const char *property_name, PropertyKey key, ClassProperties &klass, JSVal value) {
|
||||
if (!value.HasMember(property_name)) {
|
||||
return false;
|
||||
}
|
||||
JSVal elements = replaceConstant(value[property_name]);
|
||||
ClassPropertyTransition transition;
|
||||
PropertyTransition transition;
|
||||
|
||||
if (elements.IsObject()) {
|
||||
if (elements.HasMember("duration") && elements["duration"].IsNumber()) {
|
||||
@@ -380,14 +380,14 @@ bool StyleParser::parseStyleProperty(const char *property_name, const std::vecto
|
||||
|
||||
std::unique_ptr<StyleLayerGroup> StyleParser::createLayers(JSVal value) {
|
||||
if (value.IsArray()) {
|
||||
std::unique_ptr<StyleLayerGroup> layers = std::make_unique<StyleLayerGroup>();
|
||||
std::unique_ptr<StyleLayerGroup> group = std::make_unique<StyleLayerGroup>();
|
||||
for (rapidjson::SizeType i = 0; i < value.Size(); ++i) {
|
||||
std::shared_ptr<StyleLayer> layer = createLayer(value[i]);
|
||||
if (layer) {
|
||||
layers->emplace_back(layer);
|
||||
group->layers.emplace_back(layer);
|
||||
}
|
||||
}
|
||||
return layers;
|
||||
return group;
|
||||
} else {
|
||||
throw Style::exception("layers must be an array");
|
||||
}
|
||||
@@ -491,81 +491,81 @@ void StyleParser::parseStyle(JSVal value, ClassProperties &klass) {
|
||||
using Key = PropertyKey;
|
||||
|
||||
parseStyleProperty<FunctionProperty>("fill-enabled", Key::FillEnabled, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-fill-enabled", Key::FillEnabled, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-fill-enabled", Key::FillEnabled, klass, value);
|
||||
parseStyleProperty<FunctionProperty>("fill-antialias", Key::FillAntialias, klass, value);
|
||||
parseStyleProperty<FunctionProperty>("fill-opacity", Key::FillOpacity, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-fill-opacity", Key::FillOpacity, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-fill-opacity", Key::FillOpacity, klass, value);
|
||||
parseStyleProperty<Color>("fill-color", Key::FillColor, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-fill-color", Key::FillColor, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-fill-color", Key::FillColor, klass, value);
|
||||
parseStyleProperty<Color>("fill-outline-color", Key::FillOutlineColor, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-fill-outline-color", Key::FillOutlineColor, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-fill-outline-color", Key::FillOutlineColor, klass, value);
|
||||
parseStyleProperty<FunctionProperty>("fill-translate", { Key::FillTranslateX, Key::FillTranslateY }, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-fill-translate", Key::FillTranslate, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-fill-translate", Key::FillTranslate, klass, value);
|
||||
parseStyleProperty<TranslateAnchorType>("fill-translate-anchor", Key::FillTranslateAnchor, klass, value);
|
||||
parseStyleProperty<std::string>("fill-image", Key::FillImage, klass, value);
|
||||
|
||||
parseStyleProperty<FunctionProperty>("line-enabled", Key::LineEnabled, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-line-enabled", Key::LineEnabled, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-line-enabled", Key::LineEnabled, klass, value);
|
||||
parseStyleProperty<FunctionProperty>("line-opacity", Key::LineOpacity, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-line-opacity", Key::LineOpacity, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-line-opacity", Key::LineOpacity, klass, value);
|
||||
parseStyleProperty<Color>("line-color", Key::LineColor, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-line-color", Key::LineColor, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-line-color", Key::LineColor, klass, value);
|
||||
parseStyleProperty<FunctionProperty>("line-translate", { Key::LineTranslateX, Key::LineTranslateY }, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-line-translate", Key::LineTranslate, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-line-translate", Key::LineTranslate, klass, value);
|
||||
parseStyleProperty<TranslateAnchorType>("line-translate-anchor", Key::LineTranslateAnchor, klass, value);
|
||||
parseStyleProperty<FunctionProperty>("line-width", Key::LineWidth, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-line-width", Key::LineWidth, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-line-width", Key::LineWidth, klass, value);
|
||||
parseStyleProperty<FunctionProperty>("line-offset", Key::LineOffset, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-line-offset", Key::LineOffset, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-line-offset", Key::LineOffset, klass, value);
|
||||
parseStyleProperty<FunctionProperty>("line-blur", Key::LineBlur, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-line-blur", Key::LineBlur, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-line-blur", Key::LineBlur, klass, value);
|
||||
parseStyleProperty<FunctionProperty>("line-dasharray", { Key::LineDashLand, Key::LineDashGap }, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-line-dasharray", Key::LineDashArray, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-line-dasharray", Key::LineDashArray, klass, value);
|
||||
parseStyleProperty<std::string>("line-image", Key::LineImage, klass, value);
|
||||
|
||||
parseStyleProperty<FunctionProperty>("icon-enabled", Key::IconEnabled, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-icon-enabled", Key::IconEnabled, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-icon-enabled", Key::IconEnabled, klass, value);
|
||||
parseStyleProperty<FunctionProperty>("icon-opacity", Key::IconOpacity, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-icon-opacity", Key::IconOpacity, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-icon-opacity", Key::IconOpacity, klass, value);
|
||||
parseStyleProperty<FunctionProperty>("icon-rotate", Key::IconRotate, klass, value);
|
||||
parseStyleProperty<RotateAnchorType>("icon-rotate-anchor", Key::IconRotateAnchor, klass, value);
|
||||
|
||||
parseStyleProperty<FunctionProperty>("text-enabled", Key::TextEnabled, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-text-enabled", Key::TextEnabled, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-text-enabled", Key::TextEnabled, klass, value);
|
||||
parseStyleProperty<FunctionProperty>("text-opacity", Key::TextOpacity, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-text-opacity", Key::TextOpacity, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-text-opacity", Key::TextOpacity, klass, value);
|
||||
parseStyleProperty<FunctionProperty>("text-size", Key::TextSize, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-text-size", Key::TextSize, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-text-size", Key::TextSize, klass, value);
|
||||
parseStyleProperty<Color>("text-color", Key::TextColor, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-text-color", Key::TextColor, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-text-color", Key::TextColor, klass, value);
|
||||
parseStyleProperty<Color>("text-halo-color", Key::TextHaloColor, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-text-halo-color", Key::TextHaloColor, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-text-halo-color", Key::TextHaloColor, klass, value);
|
||||
parseStyleProperty<FunctionProperty>("text-halo-width", Key::TextHaloWidth, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-text-halo-width", Key::TextHaloWidth, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-text-halo-width", Key::TextHaloWidth, klass, value);
|
||||
parseStyleProperty<FunctionProperty>("text-halo-blur", Key::TextHaloBlur, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-text-halo-blur", Key::TextHaloBlur, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-text-halo-blur", Key::TextHaloBlur, klass, value);
|
||||
|
||||
parseStyleProperty<FunctionProperty>("composite-enabled", Key::CompositeEnabled, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-composite-enabled", Key::CompositeEnabled, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-composite-enabled", Key::CompositeEnabled, klass, value);
|
||||
parseStyleProperty<FunctionProperty>("composite-opacity", Key::CompositeOpacity, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-composite-opacity", Key::CompositeOpacity, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-composite-opacity", Key::CompositeOpacity, klass, value);
|
||||
|
||||
parseStyleProperty<FunctionProperty>("raster-enabled", Key::RasterEnabled, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-raster-enabled", Key::RasterEnabled, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-raster-enabled", Key::RasterEnabled, klass, value);
|
||||
parseStyleProperty<FunctionProperty>("raster-opacity", Key::RasterOpacity, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-raster-opacity", Key::RasterOpacity, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-raster-opacity", Key::RasterOpacity, klass, value);
|
||||
parseStyleProperty<FunctionProperty>("raster-spin", Key::RasterSpin, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-raster-spin", Key::RasterSpin, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-raster-spin", Key::RasterSpin, klass, value);
|
||||
parseStyleProperty<FunctionProperty>("raster-brightness-low", Key::RasterBrightnessLow, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-raster-brightness-low", Key::RasterBrightnessLow, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-raster-brightness-low", Key::RasterBrightnessLow, klass, value);
|
||||
parseStyleProperty<FunctionProperty>("raster-brightness-high", Key::RasterBrightnessHigh, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-raster-brightness-high", Key::RasterBrightnessHigh, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-raster-brightness-high", Key::RasterBrightnessHigh, klass, value);
|
||||
parseStyleProperty<FunctionProperty>("raster-saturation", Key::RasterSaturation, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-raster-saturation", Key::RasterSaturation, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-raster-saturation", Key::RasterSaturation, klass, value);
|
||||
parseStyleProperty<FunctionProperty>("raster-contrast", Key::RasterContrast, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-raster-contrast", Key::RasterContrast, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-raster-contrast", Key::RasterContrast, klass, value);
|
||||
parseStyleProperty<FunctionProperty>("raster-fade", Key::RasterFade, klass, value);
|
||||
parseStyleProperty<ClassPropertyTransition>("transition-raster-fade", Key::RasterFade, klass, value);
|
||||
parseStyleProperty<PropertyTransition>("transition-raster-fade", Key::RasterFade, klass, value);
|
||||
|
||||
parseStyleProperty<Color>("background-color", Key::BackgroundColor, klass, value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user