blob: c92e95a7ff66395bb65dd19358cdae9bbe3c3906 (
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
|
#ifndef LLMR_STYLE_STYLE
#define LLMR_STYLE_STYLE
#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>
#include <set>
#include <memory>
namespace llmr {
class Sprite;
class Source;
class StyleLayer;
class StyleLayerGroup;
struct BackgroundProperties;
class Style {
public:
struct exception : std::runtime_error { exception(const char *msg) : std::runtime_error(msg) {} };
public:
Style();
void loadJSON(const uint8_t *const data);
size_t layerCount() const;
void updateProperties(float z, timestamp t);
void setDefaultTransitionDuration(uint16_t duration_milliseconds = 0);
const std::set<std::shared_ptr<Source>> getActiveSources() const;
void setAppliedClasses(const std::vector<std::string> &classes);
const std::vector<std::string> &getAppliedClasses() const;
void toggleClass(const std::string &name);
// Updates the styling information to reflect the current array
// of applied classes.
void updateClasses();
bool hasTransitions() const;
const BackgroundProperties &getBackgroundProperties() const;
public:
std::shared_ptr<Sprite> sprite;
std::shared_ptr<StyleLayerGroup> layers;
std::vector<std::string> appliedClasses;
std::string sprite_url;
std::string glyph_url;
private:
void updateSources();
void updateSources(const std::shared_ptr<StyleLayerGroup> &group);
private:
std::set<std::shared_ptr<Source>> activeSources;
PropertyTransition defaultTransition;
bool initial_render_complete = false;
mutable uv::rwlock mtx;
};
}
#endif
|