Merge branch 'master' of https://github.com/mapbox/mapbox-gl-native
Conflicts: src/style/style.cpp
This commit is contained in:
@@ -281,7 +281,7 @@ void show_color_debug_image(std::string name, const char *data, size_t logical_w
|
||||
}
|
||||
#endif
|
||||
|
||||
void notify_map_change() {
|
||||
void notify_map_change(MapChange change) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ public:
|
||||
void setAppliedClasses(const std::vector<std::string> &classes);
|
||||
void toggleClass(const std::string &name);
|
||||
const std::vector<std::string> &getAppliedClasses() const;
|
||||
void setAppliedClasses(std::vector<std::string> &class_names);
|
||||
void setDefaultTransitionDuration(uint64_t duration_milliseconds = 0);
|
||||
void setStyleJSON(std::string newStyleJSON);
|
||||
std::string getStyleJSON() const;
|
||||
|
||||
@@ -24,6 +24,19 @@ struct Response {
|
||||
std::function<void(Response *)> callback;
|
||||
};
|
||||
|
||||
enum MapChange : uint8_t {
|
||||
MapChangeRegionWillChange = 0,
|
||||
MapChangeRegionWillChangeAnimated = 1,
|
||||
MapChangeRegionDidChange = 2,
|
||||
MapChangeRegionDidChangeAnimated = 3,
|
||||
MapChangeWillStartLoadingMap = 4,
|
||||
MapChangeDidFinishLoadingMap = 5,
|
||||
MapChangeDidFailLoadingMap = 6,
|
||||
MapChangeWillStartRenderingMap = 7,
|
||||
MapChangeDidFinishRenderingMap = 8,
|
||||
MapChangeDidFinishRenderingMapFullyRendered = 9
|
||||
};
|
||||
|
||||
// Makes an HTTP request of a URL, preferrably on a background thread, and calls a function with the
|
||||
// results in the original thread (which runs the libuv loop).
|
||||
// If the loop pointer is NULL, the callback function will be called on an arbitrary thread.
|
||||
@@ -35,8 +48,8 @@ std::shared_ptr<Request> request_http(const std::string &url,
|
||||
// Cancels an HTTP request.
|
||||
void cancel_request_http(const std::shared_ptr<Request> &req);
|
||||
|
||||
// Notifies a watcher of map x/y/scale/rotation changes.
|
||||
void notify_map_change();
|
||||
// Notifies a watcher of map changes.
|
||||
void notify_map_change(MapChange key);
|
||||
|
||||
// Shows an alpha image with the specified dimensions in a named window.
|
||||
void show_debug_image(std::string name, const char *data, size_t width, size_t height);
|
||||
|
||||
@@ -39,6 +39,7 @@ public:
|
||||
|
||||
void setAppliedClasses(const std::vector<std::string> &classes);
|
||||
const std::vector<std::string> &getAppliedClasses() const;
|
||||
void setAppliedClasses(std::vector<std::string> &class_names);
|
||||
void toggleClass(const std::string &name);
|
||||
|
||||
// Updates the styling information to reflect the current array
|
||||
|
||||
@@ -40,6 +40,7 @@ class StyleBucketText {
|
||||
public:
|
||||
std::string field;
|
||||
TextPathType path = TextPathType::Default;
|
||||
TextTransformType transform = TextTransformType::Default;
|
||||
std::string font;
|
||||
float max_size = 16.0f;
|
||||
float max_width = 15.0f * 24;
|
||||
|
||||
@@ -52,6 +52,13 @@ enum class TextPathType : uint8_t {
|
||||
Default = Horizontal
|
||||
};
|
||||
|
||||
enum class TextTransformType : uint8_t {
|
||||
None,
|
||||
Uppercase,
|
||||
Lowercase,
|
||||
Default = None
|
||||
};
|
||||
|
||||
enum class TranslateAnchorType : uint8_t {
|
||||
Map,
|
||||
Viewport,
|
||||
@@ -98,6 +105,12 @@ inline TextPathType parseTextPathType(const std::string &path) {
|
||||
return TextPathType::Default;
|
||||
}
|
||||
|
||||
inline TextTransformType parseTextTransformType(const std::string& transform) {
|
||||
if (transform == "uppercase") return TextTransformType::Uppercase;
|
||||
if (transform == "lowercase") return TextTransformType::Lowercase;
|
||||
return TextTransformType::Default;
|
||||
};
|
||||
|
||||
inline TranslateAnchorType parseTranslateAnchorType(const std::string &anchor) {
|
||||
if (anchor == "map") return TranslateAnchorType::Map;
|
||||
if (anchor == "viewport") return TranslateAnchorType::Viewport;
|
||||
|
||||
Submodule ios/mapbox-gl-cocoa updated: 359b6b6b03...8269f98e8b
@@ -397,6 +397,10 @@ const std::vector<std::string> &Map::getAppliedClasses() const {
|
||||
return style->getAppliedClasses();
|
||||
}
|
||||
|
||||
void Map::setAppliedClasses(std::vector<std::string> &class_names) {
|
||||
style->setAppliedClasses(class_names);
|
||||
}
|
||||
|
||||
void Map::setDefaultTransitionDuration(uint64_t duration_milliseconds) {
|
||||
style->setDefaultTransitionDuration(duration_milliseconds);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
#include <llmr/util/std.hpp>
|
||||
#include <llmr/util/utf.hpp>
|
||||
|
||||
#include <locale>
|
||||
|
||||
#ifdef __linux__
|
||||
#include <boost/regex.hpp>
|
||||
namespace regex_impl = boost;
|
||||
@@ -208,8 +210,16 @@ std::unique_ptr<Bucket> TileParser::createTextBucket(const VectorTileLayer& laye
|
||||
return nullptr;
|
||||
VectorTileFeature feature{feature_pbf, layer};
|
||||
|
||||
const std::u32string string = ucs4conv.convert(
|
||||
util::replaceTokens(properties.field, feature.properties));
|
||||
std::string u8string = util::replaceTokens(properties.field, feature.properties);
|
||||
|
||||
auto& convert = std::use_facet<std::ctype<char>>(std::locale());
|
||||
if (properties.transform == TextTransformType::Uppercase) {
|
||||
convert.toupper(&u8string[0], &u8string[0] + u8string.size());
|
||||
} else if (properties.transform == TextTransformType::Lowercase) {
|
||||
convert.tolower(&u8string[0], &u8string[0] + u8string.size());
|
||||
}
|
||||
|
||||
std::u32string string = ucs4conv.convert(u8string);
|
||||
|
||||
// Loop through all characters of this text and collect unique codepoints.
|
||||
for (char32_t chr : string) {
|
||||
|
||||
@@ -28,6 +28,8 @@ bool Transform::resize(const uint16_t w, const uint16_t h, const float ratio,
|
||||
if (final.width != w || final.height != h || final.pixelRatio != ratio ||
|
||||
final.framebuffer[0] != fb_w || final.framebuffer[1] != fb_h) {
|
||||
|
||||
platform::notify_map_change(platform::MapChangeRegionWillChange);
|
||||
|
||||
current.width = final.width = w;
|
||||
current.height = final.height = h;
|
||||
current.pixelRatio = final.pixelRatio = ratio;
|
||||
@@ -35,7 +37,9 @@ bool Transform::resize(const uint16_t w, const uint16_t h, const float ratio,
|
||||
current.framebuffer[1] = final.framebuffer[1] = fb_h;
|
||||
if (!canRotate() && current.angle) _setAngle(0);
|
||||
constrain(current.scale, current.y);
|
||||
platform::notify_map_change();
|
||||
|
||||
platform::notify_map_change(platform::MapChangeRegionDidChange);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -76,7 +80,9 @@ void Transform::_moveBy(const double dx, const double dy, const timestamp durati
|
||||
std::make_shared<util::ease_transition<double>>(current.y, final.y, current.y, start, duration));
|
||||
}
|
||||
|
||||
platform::notify_map_change();
|
||||
platform::notify_map_change(duration ?
|
||||
platform::MapChangeRegionDidChangeAnimated :
|
||||
platform::MapChangeRegionDidChange);
|
||||
}
|
||||
|
||||
void Transform::setLonLat(const double lon, const double lat, const timestamp duration) {
|
||||
@@ -294,7 +300,9 @@ void Transform::_setScaleXY(const double new_scale, const double xn, const doubl
|
||||
Bc = s / 360;
|
||||
Cc = s / (2 * M_PI);
|
||||
|
||||
platform::notify_map_change();
|
||||
platform::notify_map_change(duration ?
|
||||
platform::MapChangeRegionDidChangeAnimated :
|
||||
platform::MapChangeRegionDidChange);
|
||||
}
|
||||
|
||||
#pragma mark - Constraints
|
||||
@@ -388,7 +396,9 @@ void Transform::_setAngle(double new_angle, const timestamp duration) {
|
||||
current.angle, final.angle, current.angle, start, duration));
|
||||
}
|
||||
|
||||
platform::notify_map_change();
|
||||
platform::notify_map_change(duration ?
|
||||
platform::MapChangeRegionDidChangeAnimated :
|
||||
platform::MapChangeRegionDidChange);
|
||||
}
|
||||
|
||||
double Transform::getAngle() const {
|
||||
|
||||
@@ -63,8 +63,8 @@ const std::vector<std::string> &Style::getAppliedClasses() const {
|
||||
return appliedClasses;
|
||||
}
|
||||
|
||||
void Style::setAppliedClasses(const std::vector<std::string> &classes) {
|
||||
appliedClasses = classes;
|
||||
void Style::setAppliedClasses(std::vector<std::string> &class_names) {
|
||||
appliedClasses.swap(class_names);
|
||||
updateClasses();
|
||||
}
|
||||
|
||||
|
||||
@@ -890,6 +890,7 @@ void StyleParser::parseRender(JSVal value, std::shared_ptr<StyleLayer> &layer) {
|
||||
|
||||
parseRenderProperty(value, render.field, "text-field");
|
||||
parseRenderProperty(value, render.path, "text-path", parseTextPathType);
|
||||
parseRenderProperty(value, render.transform, "text-transform", parseTextTransformType);
|
||||
parseRenderProperty(value, render.font, "text-font");
|
||||
parseRenderProperty(value, render.max_size, "text-max-size");
|
||||
if (parseRenderProperty(value, render.max_width, "text-max-width")) {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
namespace llmr {
|
||||
namespace platform {
|
||||
|
||||
void notify_map_change() {
|
||||
void notify_map_change(MapChange change) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user