summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAlexander Shalamov <alexander.shalamov@mapbox.com>2019-03-11 10:26:19 +0200
committerAlexander Shalamov <alexander.shalamov@mapbox.com>2019-03-13 17:14:53 +0200
commit8be135231d9efe41a3b12037518d02b36104e8cf (patch)
treeefecd5380232f899aed2cd5824dc16f057f0469a /scripts
parent8a51362bccbd6487dd1ed8518443b16ba6114fd8 (diff)
downloadqtlocation-mapboxgl-8be135231d9efe41a3b12037518d02b36104e8cf.tar.gz
[core] Add possibility of overriding paint properties inside format expression #14062
* [core] Add format override expression and formatted section to evaluation context * [core] Add textColor to TaggedString's formatted section * [core] Add FormatSectionOverrides and introduce overridable properties * [core] Populate symbol layer paint properties for text sections * [core] Add benchmark for style that uses text-color override * [core] Add unit test for FormatOverrideExpression * [core] Add unit test for FormatSectionOverrides
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/generate-style-code.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/scripts/generate-style-code.js b/scripts/generate-style-code.js
index c002718038..ae25a856a8 100755
--- a/scripts/generate-style-code.js
+++ b/scripts/generate-style-code.js
@@ -19,6 +19,29 @@ global.isLightProperty = function (property) {
return property['light-property'] === true;
};
+global.isOverridable = function (property) {
+ return ['text-color'].includes(property.name);
+};
+
+global.expressionType = function (property) {
+ switch (property.type) {
+ case 'boolean':
+ return 'BooleanType';
+ case 'number':
+ case 'enum':
+ return 'NumberType';
+ case 'string':
+ return 'StringType';
+ case 'color':
+ return `ColorType`;
+ case 'formatted':
+ return `FormattedType`;
+ case 'array':
+ return `Array<${expressionType({type: property.value})}>`;
+ default: throw new Error(`unknown type for ${property.name}`)
+ }
+};
+
global.evaluatedType = function (property) {
if (/-translate-anchor$/.test(property.name)) {
return 'TranslateAnchorType';
@@ -93,6 +116,8 @@ global.layoutPropertyType = function (property) {
global.paintPropertyType = function (property, type) {
switch (property['property-type']) {
case 'data-driven':
+ if (isOverridable(property))
+ return `DataDrivenPaintProperty<${evaluatedType(property)}, ${attributeUniformType(property, type)}, true>`;
return `DataDrivenPaintProperty<${evaluatedType(property)}, ${attributeUniformType(property, type)}>`;
case 'cross-faded-data-driven':
return `CrossFadedDataDrivenPaintProperty<${evaluatedType(property)}, ${attributeUniformType(property, type)}>`;