This converts the style property classes (CirclePaintProperties and so on) to the same tuple-based approach as gl::Attribute and gl::Uniform. The approach is outlined in https://github.com/mapbox/cpp/blob/master/C%2B%2B%20Structural%20Metaprogramming.md. The main advantage of this approach is it allows writing algorithms that work on sets of style properties, without resorting to code generation or manually repetitive code. This lets us iterate on approaches to data-driven properties more easily. Another advantage is that the cascading, unevaluated, and evaluated states of a set of properties exist as independent structures, instead of individual properties holding their own state. This is a more functional approach that makes data flow clearer and reduces state.
28 lines
556 B
C++
28 lines
556 B
C++
#pragma once
|
|
|
|
#include <mbgl/util/chrono.hpp>
|
|
#include <mbgl/util/optional.hpp>
|
|
|
|
namespace mbgl {
|
|
namespace style {
|
|
|
|
class TransitionOptions {
|
|
public:
|
|
optional<Duration> duration = {};
|
|
optional<Duration> delay = {};
|
|
|
|
TransitionOptions reverseMerge(const TransitionOptions& defaults) const {
|
|
return {
|
|
duration ? duration : defaults.duration,
|
|
delay ? delay : defaults.delay
|
|
};
|
|
}
|
|
|
|
explicit operator bool() const {
|
|
return duration || delay;
|
|
}
|
|
};
|
|
|
|
} // namespace style
|
|
} // namespace mbgl
|