diff options
Diffstat (limited to 'platform/android/src/style')
25 files changed, 128 insertions, 31 deletions
diff --git a/platform/android/src/style/android_conversion.hpp b/platform/android/src/style/android_conversion.hpp index cea7ce6d2a..de0ac91502 100644 --- a/platform/android/src/style/android_conversion.hpp +++ b/platform/android/src/style/android_conversion.hpp @@ -2,7 +2,7 @@ #include "value.hpp" -#include <mbgl/platform/log.hpp> +#include <mbgl/util/logging.hpp> #include <mbgl/style/conversion.hpp> #include <mbgl/util/feature.hpp> #include <mbgl/util/optional.hpp> diff --git a/platform/android/src/style/conversion/geojson.hpp b/platform/android/src/style/conversion/geojson.hpp index 920c670fcb..6bc48b3700 100644 --- a/platform/android/src/style/conversion/geojson.hpp +++ b/platform/android/src/style/conversion/geojson.hpp @@ -6,7 +6,7 @@ #include <mbgl/style/conversion.hpp> #include <mbgl/style/conversion/geojson.hpp> #include <mbgl/util/rapidjson.hpp> -#include <mbgl/platform/log.hpp> +#include <mbgl/util/logging.hpp> #include <jni/jni.hpp> #include <sstream> diff --git a/platform/android/src/style/conversion/types.hpp b/platform/android/src/style/conversion/types.hpp index d3c12ff89a..1c433bb264 100644 --- a/platform/android/src/style/conversion/types.hpp +++ b/platform/android/src/style/conversion/types.hpp @@ -1,4 +1,4 @@ -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. #pragma once #include "types_string_values.hpp" diff --git a/platform/android/src/style/conversion/types.hpp.ejs b/platform/android/src/style/conversion/types.hpp.ejs index de26d061f7..d248d42b72 100644 --- a/platform/android/src/style/conversion/types.hpp.ejs +++ b/platform/android/src/style/conversion/types.hpp.ejs @@ -1,7 +1,7 @@ <% const properties = locals.properties; -%> -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. #pragma once #include "types_string_values.hpp" diff --git a/platform/android/src/style/conversion/types_string_values.hpp b/platform/android/src/style/conversion/types_string_values.hpp index b42ca52acd..9f21a2fed9 100644 --- a/platform/android/src/style/conversion/types_string_values.hpp +++ b/platform/android/src/style/conversion/types_string_values.hpp @@ -1,4 +1,4 @@ -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. #pragma once #include <mbgl/style/types.hpp> diff --git a/platform/android/src/style/conversion/types_string_values.hpp.ejs b/platform/android/src/style/conversion/types_string_values.hpp.ejs index 39021d390d..c1646baa1a 100644 --- a/platform/android/src/style/conversion/types_string_values.hpp.ejs +++ b/platform/android/src/style/conversion/types_string_values.hpp.ejs @@ -1,7 +1,7 @@ <% const properties = locals.properties; -%> -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. #pragma once #include <mbgl/style/types.hpp> diff --git a/platform/android/src/style/layers/background_layer.cpp b/platform/android/src/style/layers/background_layer.cpp index 25526a07fa..021ac947ad 100644 --- a/platform/android/src/style/layers/background_layer.cpp +++ b/platform/android/src/style/layers/background_layer.cpp @@ -1,4 +1,4 @@ -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. #include "background_layer.hpp" diff --git a/platform/android/src/style/layers/background_layer.hpp b/platform/android/src/style/layers/background_layer.hpp index f201213e46..bd62c024f4 100644 --- a/platform/android/src/style/layers/background_layer.hpp +++ b/platform/android/src/style/layers/background_layer.hpp @@ -1,4 +1,4 @@ -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. #pragma once diff --git a/platform/android/src/style/layers/circle_layer.cpp b/platform/android/src/style/layers/circle_layer.cpp index c2d6ff06d1..4a6ba95d31 100644 --- a/platform/android/src/style/layers/circle_layer.cpp +++ b/platform/android/src/style/layers/circle_layer.cpp @@ -1,4 +1,4 @@ -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. #include "circle_layer.hpp" @@ -63,6 +63,24 @@ namespace android { return jni::Object<jni::ObjectTag>(*converted); } + jni::Object<jni::ObjectTag> CircleLayer::getCircleStrokeWidth(jni::JNIEnv& env) { + using namespace mbgl::android::conversion; + Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleStrokeWidth()); + return jni::Object<jni::ObjectTag>(*converted); + } + + jni::Object<jni::ObjectTag> CircleLayer::getCircleStrokeColor(jni::JNIEnv& env) { + using namespace mbgl::android::conversion; + Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleStrokeColor()); + return jni::Object<jni::ObjectTag>(*converted); + } + + jni::Object<jni::ObjectTag> CircleLayer::getCircleStrokeOpacity(jni::JNIEnv& env) { + using namespace mbgl::android::conversion; + Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::CircleLayer>()->CircleLayer::getCircleStrokeOpacity()); + return jni::Object<jni::ObjectTag>(*converted); + } + jni::Class<CircleLayer> CircleLayer::javaClass; jni::jobject* CircleLayer::createJavaPeer(jni::JNIEnv& env) { @@ -88,7 +106,10 @@ namespace android { METHOD(&CircleLayer::getCircleOpacity, "nativeGetCircleOpacity"), METHOD(&CircleLayer::getCircleTranslate, "nativeGetCircleTranslate"), METHOD(&CircleLayer::getCircleTranslateAnchor, "nativeGetCircleTranslateAnchor"), - METHOD(&CircleLayer::getCirclePitchScale, "nativeGetCirclePitchScale")); + METHOD(&CircleLayer::getCirclePitchScale, "nativeGetCirclePitchScale"), + METHOD(&CircleLayer::getCircleStrokeWidth, "nativeGetCircleStrokeWidth"), + METHOD(&CircleLayer::getCircleStrokeColor, "nativeGetCircleStrokeColor"), + METHOD(&CircleLayer::getCircleStrokeOpacity, "nativeGetCircleStrokeOpacity")); } } // namespace android diff --git a/platform/android/src/style/layers/circle_layer.hpp b/platform/android/src/style/layers/circle_layer.hpp index 91c99c686e..d45984f23b 100644 --- a/platform/android/src/style/layers/circle_layer.hpp +++ b/platform/android/src/style/layers/circle_layer.hpp @@ -1,4 +1,4 @@ -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. #pragma once @@ -39,6 +39,12 @@ public: jni::Object<jni::ObjectTag> getCirclePitchScale(jni::JNIEnv&); + jni::Object<jni::ObjectTag> getCircleStrokeWidth(jni::JNIEnv&); + + jni::Object<jni::ObjectTag> getCircleStrokeColor(jni::JNIEnv&); + + jni::Object<jni::ObjectTag> getCircleStrokeOpacity(jni::JNIEnv&); + jni::jobject* createJavaPeer(jni::JNIEnv&); }; // class CircleLayer diff --git a/platform/android/src/style/layers/custom_layer.cpp b/platform/android/src/style/layers/custom_layer.cpp index 6568455c67..d5d330a019 100644 --- a/platform/android/src/style/layers/custom_layer.cpp +++ b/platform/android/src/style/layers/custom_layer.cpp @@ -2,7 +2,7 @@ #include <string> -#include <mbgl/platform/log.hpp> +#include <mbgl/util/logging.hpp> namespace mbgl { namespace android { diff --git a/platform/android/src/style/layers/fill_layer.cpp b/platform/android/src/style/layers/fill_layer.cpp index 8cb96c9cd3..84d47b6afe 100644 --- a/platform/android/src/style/layers/fill_layer.cpp +++ b/platform/android/src/style/layers/fill_layer.cpp @@ -1,4 +1,4 @@ -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. #include "fill_layer.hpp" diff --git a/platform/android/src/style/layers/fill_layer.hpp b/platform/android/src/style/layers/fill_layer.hpp index 5dbd7a3412..7609a5742f 100644 --- a/platform/android/src/style/layers/fill_layer.hpp +++ b/platform/android/src/style/layers/fill_layer.hpp @@ -1,4 +1,4 @@ -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. #pragma once diff --git a/platform/android/src/style/layers/layer.cpp b/platform/android/src/style/layers/layer.cpp index 3c1fc0af62..c0c57c839d 100644 --- a/platform/android/src/style/layers/layer.cpp +++ b/platform/android/src/style/layers/layer.cpp @@ -3,7 +3,7 @@ #include <jni/jni.hpp> -#include <mbgl/platform/log.hpp> +#include <mbgl/util/logging.hpp> //Java -> C++ conversion #include <mbgl/style/conversion.hpp> @@ -32,8 +32,21 @@ namespace android { Layer::~Layer() { } - jni::String Layer::getId(jni::JNIEnv& env) { - return jni::Make<jni::String>(env, layer.getID()); + void Layer::addToMap(mbgl::Map& _map, mbgl::optional<std::string> before) { + //Check to see if we own the layer first + if (!ownedLayer) { + throw std::runtime_error("Cannot add layer twice"); + } + + //Add layer to map + _map.addLayer(releaseCoreLayer(), before); + + //Save pointer to the map + this->map = &_map; + } + + void Layer::setLayer(std::unique_ptr<mbgl::style::Layer> sourceLayer) { + this->ownedLayer = std::move(sourceLayer); } std::unique_ptr<mbgl::style::Layer> Layer::releaseCoreLayer() { @@ -41,6 +54,14 @@ namespace android { return std::move(ownedLayer); } + jni::String Layer::getId(jni::JNIEnv& env) { + return jni::Make<jni::String>(env, layer.getID()); + } + + style::Layer& Layer::get() { + return layer; + } + void Layer::setLayoutProperty(jni::JNIEnv& env, jni::String jname, jni::Object<> jvalue) { Value value(env, jvalue); diff --git a/platform/android/src/style/layers/layer.cpp.ejs b/platform/android/src/style/layers/layer.cpp.ejs index 68dd27b801..500c76ea7a 100644 --- a/platform/android/src/style/layers/layer.cpp.ejs +++ b/platform/android/src/style/layers/layer.cpp.ejs @@ -2,9 +2,9 @@ const type = locals.type; const properties = locals.properties; -%> -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. -#include "<%- type %>_layer.hpp" +#include "<%- type.replace('-', '_') %>_layer.hpp" #include <string> diff --git a/platform/android/src/style/layers/layer.hpp b/platform/android/src/style/layers/layer.hpp index 024a3c38b7..f3cd073552 100644 --- a/platform/android/src/style/layers/layer.hpp +++ b/platform/android/src/style/layers/layer.hpp @@ -34,10 +34,16 @@ public: virtual jni::jobject* createJavaPeer(jni::JNIEnv&) = 0; + /** + * Set core layer (ie return ownership after remove) + */ + void setLayer(std::unique_ptr<mbgl::style::Layer>); + + void addToMap(mbgl::Map&, mbgl::optional<std::string>); + jni::String getId(jni::JNIEnv&); - //Release the owned view and return it - std::unique_ptr<mbgl::style::Layer> releaseCoreLayer(); + style::Layer& get(); void setLayoutProperty(jni::JNIEnv&, jni::String, jni::Object<> value); @@ -64,8 +70,16 @@ public: jni::Object<jni::ObjectTag> getVisibility(jni::JNIEnv&); protected: + //Release the owned view and return it + std::unique_ptr<mbgl::style::Layer> releaseCoreLayer(); + + //Owned layer is set when creating a new layer, before adding it to the map std::unique_ptr<mbgl::style::Layer> ownedLayer; + + //Raw reference to the layer mbgl::style::Layer& layer; + + //Map is set when the layer is retrieved or after adding to the map mbgl::Map* map; }; diff --git a/platform/android/src/style/layers/layer.hpp.ejs b/platform/android/src/style/layers/layer.hpp.ejs index 826e133fca..3d715746ff 100644 --- a/platform/android/src/style/layers/layer.hpp.ejs +++ b/platform/android/src/style/layers/layer.hpp.ejs @@ -2,12 +2,12 @@ const type = locals.type; const properties = locals.properties; -%> -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. #pragma once #include "layer.hpp" -#include <mbgl/style/layers/<%- type %>_layer.hpp> +#include <mbgl/style/layers/<%- type.replace('-', '_') %>_layer.hpp> #include <jni/jni.hpp> namespace mbgl { diff --git a/platform/android/src/style/layers/line_layer.cpp b/platform/android/src/style/layers/line_layer.cpp index 91d3e4a1cd..2dce8b618a 100644 --- a/platform/android/src/style/layers/line_layer.cpp +++ b/platform/android/src/style/layers/line_layer.cpp @@ -1,4 +1,4 @@ -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. #include "line_layer.hpp" diff --git a/platform/android/src/style/layers/line_layer.hpp b/platform/android/src/style/layers/line_layer.hpp index da9b564325..e2fc93329e 100644 --- a/platform/android/src/style/layers/line_layer.hpp +++ b/platform/android/src/style/layers/line_layer.hpp @@ -1,4 +1,4 @@ -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. #pragma once diff --git a/platform/android/src/style/layers/raster_layer.cpp b/platform/android/src/style/layers/raster_layer.cpp index da78ccb8e3..25b26155ae 100644 --- a/platform/android/src/style/layers/raster_layer.cpp +++ b/platform/android/src/style/layers/raster_layer.cpp @@ -1,4 +1,4 @@ -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. #include "raster_layer.hpp" diff --git a/platform/android/src/style/layers/raster_layer.hpp b/platform/android/src/style/layers/raster_layer.hpp index e59cd05f87..3cc2d96dde 100644 --- a/platform/android/src/style/layers/raster_layer.hpp +++ b/platform/android/src/style/layers/raster_layer.hpp @@ -1,4 +1,4 @@ -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. #pragma once diff --git a/platform/android/src/style/layers/symbol_layer.cpp b/platform/android/src/style/layers/symbol_layer.cpp index fd69b6591f..9318d42d5b 100644 --- a/platform/android/src/style/layers/symbol_layer.cpp +++ b/platform/android/src/style/layers/symbol_layer.cpp @@ -1,4 +1,4 @@ -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. #include "symbol_layer.hpp" diff --git a/platform/android/src/style/layers/symbol_layer.hpp b/platform/android/src/style/layers/symbol_layer.hpp index f5165327bf..1048b01b14 100644 --- a/platform/android/src/style/layers/symbol_layer.hpp +++ b/platform/android/src/style/layers/symbol_layer.hpp @@ -1,4 +1,4 @@ -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. +// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. #pragma once diff --git a/platform/android/src/style/sources/source.cpp b/platform/android/src/style/sources/source.cpp index f3daa777d1..aca7bd6a84 100644 --- a/platform/android/src/style/sources/source.cpp +++ b/platform/android/src/style/sources/source.cpp @@ -3,7 +3,7 @@ #include <jni/jni.hpp> -#include <mbgl/platform/log.hpp> +#include <mbgl/util/logging.hpp> //Java -> C++ conversion #include <mbgl/style/conversion.hpp> @@ -31,10 +31,31 @@ namespace android { Source::~Source() { } + style::Source& Source::get() { + return source; + } + + void Source::setSource(std::unique_ptr<style::Source> coreSource) { + this->ownedSource = std::move(coreSource); + } + jni::String Source::getId(jni::JNIEnv& env) { return jni::Make<jni::String>(env, source.getID()); } + void Source::addToMap(mbgl::Map& _map) { + //Check to see if we own the source first + if (!ownedSource) { + throw std::runtime_error("Cannot add source twice"); + } + + //Add source to map + _map.addSource(releaseCoreSource()); + + //Save pointer to the map + this->map = &_map; + } + std::unique_ptr<mbgl::style::Source> Source::releaseCoreSource() { assert(ownedSource != nullptr); return std::move(ownedSource); diff --git a/platform/android/src/style/sources/source.hpp b/platform/android/src/style/sources/source.hpp index 0785e4d4e0..0e5d354d93 100644 --- a/platform/android/src/style/sources/source.hpp +++ b/platform/android/src/style/sources/source.hpp @@ -32,16 +32,30 @@ public: virtual ~Source(); + /** + * Set core source (ie return ownership after remove) + */ + void setSource(std::unique_ptr<style::Source>); + + style::Source& get(); + + void addToMap(mbgl::Map&); + virtual jni::jobject* createJavaPeer(jni::JNIEnv&) = 0; jni::String getId(jni::JNIEnv&); +protected: //Release the owned view and return it std::unique_ptr<mbgl::style::Source> releaseCoreSource(); -protected: + //Set on newly created sources until added to the map std::unique_ptr<mbgl::style::Source> ownedSource; + + //Raw pointer that is valid until the source is removed from the map mbgl::style::Source& source; + + //Map pointer is valid for newly created sources only after adding to the map mbgl::Map* map; }; |