-
Notifications
You must be signed in to change notification settings - Fork 16
/
rootconfig.h
1544 lines (1367 loc) · 57.8 KB
/
rootconfig.h
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#ifndef _APL_ROOT_CONFIG_H
#define _APL_ROOT_CONFIG_H
#include <memory>
#include <regex>
#include <string>
#include "apl/common.h"
#include "apl/component/componentproperties.h"
#include "apl/content/aplversion.h"
#include "apl/content/extensioncommanddefinition.h"
#include "apl/content/extensioncomponentdefinition.h"
#include "apl/content/extensioneventhandler.h"
#include "apl/content/extensionfilterdefinition.h"
#include "apl/content/rootproperties.h"
#include "apl/engine/propertymap.h"
#include "apl/livedata/liveobject.h"
#include "apl/primitives/color.h"
#include "apl/primitives/dimension.h"
#include "apl/utils/deprecated.h"
#include "apl/utils/stringfunctions.h"
#ifdef SCENEGRAPH
#include "apl/scenegraph/common.h"
#endif // SCENEGRAPH
#ifdef ALEXAEXTENSIONS
#include <alexaext/alexaext.h>
#endif
namespace apl {
class LiveDataObject;
class CoreEasing;
class TimeManager;
class LiveDataObjectWatcher;
class LocaleMethods;
class RootPropDefSet;
using LiveDataObjectWatcherPtr = std::shared_ptr<LiveDataObjectWatcher>;
using LiveDataObjectWatcherWPtr = std::weak_ptr<LiveDataObjectWatcher>;
using RootPropertyMap = PropertyMap<RootProperty, sRootPropertyBimap>;
extern Bimap<int, std::string> sScreenModeBimap;
extern Bimap<int, std::string> sAnimationQualityBimap;
/**
* Configuration settings used when creating a RootContext.
*
* This is normally used as:
*
* RootConfig config = RootConfig().agent("MyApplication", "1.0")
* .measure( measureObject )
* .timeManager( timeManager );
*/
class RootConfig {
public:
enum AnimationQuality {
kAnimationQualityNone,
kAnimationQualitySlow,
kAnimationQualityNormal
};
enum ScreenMode {
kScreenModeNormal,
kScreenModeHighContrast
};
enum ExperimentalFeature {
/// Mark EditText component dirty if text updated
kExperimentalFeatureMarkEditTextDirtyOnUpdate,
/// Manage media request status in core and update dirty properties
kExperimentalFeatureManageMediaRequests,
/// Enable the experimental API for Alexa Extensions, in addition to existing extension api.
/// The viewhost is responsible for configuring a ExtensionProvider. All extensions registered through
/// the ExtensionProvider will have messages mediated by the framework, reducing the burden on the runtime
/// to be a go-between.
kExperimentalFeatureExtensionProvider,
/// Focus EditText component on tap
kExperimentalFeatureFocusEditTextOnTap,
/// Send event when core assumes keyboard input is required
kExperimentalFeatureRequestKeyboard,
/// AVG should use layers for parameterized elements
kExperimentalFeatureGraphicLayers,
/// Accessibility actions reported on component may depend on component state
kExperimentalFeatureDynamicAccessibilityActions
};
/**
* @return RootConfig instance.
*/
static RootConfigPtr create() { return std::make_shared<RootConfig>(); }
/**
* Default constructor. Use create() instead.
*/
RootConfig();
/**
* Set RootConfig property
* @param name Property name,
* @param object property value
* @return This object for chaining
*/
RootConfig& set(const std::string& name, const Object& object);
/**
* Set RootConfigProperty.
* @param key property key
* @param object property value
* @return This object for chaining
*/
RootConfig& set(RootProperty key, const Object& object);
/**
* Set a dictionary of values.
* @param values dictionary from RootProperty to setting value
* @return This object for chaining
*/
RootConfig& set(const std::map<RootProperty, Object>& values);
/**
* @return Reference to evaluation context that can be used outside of data-binding context.
*/
const Context& evaluationContext();
/**
* Add a text measurement object for calculating the size of blocks
* of text and calculating the baseline of text.
* @param textMeasurementPtr The text measurement object.
* @return This object for chaining.
*/
RootConfig& measure(const TextMeasurementPtr& textMeasurementPtr) {
mTextMeasurement = textMeasurementPtr;
return *this;
}
/**
* Specify the document manager used for loading embedded documents.
* @param documentManager The document manager object.
* @return This object for chaining.
*/
RootConfig& documentManager(const DocumentManagerPtr& documentManager) {
mDocumentManager = documentManager;
return *this;
}
/**
* Specify the media manager used for loading images, videos, and vector graphics.
* @param mediaManager The media manager object.
* @return This object for chaining.
*/
RootConfig& mediaManager(const MediaManagerPtr& mediaManager) {
mMediaManager = mediaManager;
return *this;
}
/**
* Specify the media player factory used for creating media players for video
* @param mediaPlayerFactory The media player factory object.
* @return This object for chaining
*/
RootConfig& mediaPlayerFactory(const MediaPlayerFactoryPtr& mediaPlayerFactory) {
mMediaPlayerFactory = mediaPlayerFactory;
return *this;
}
/**
* Specify the audio player factory used for creating audio players.
*
* An audio player is used with the SpeakItem/SpeakList commands. When an audio
* player factory is set speech commands no longer send kEventTypePreroll, kEventTypeSpeak,
* and kEventTypeRequestFirstLineBounds. The local audio player takes care of preroll and
* speak; either the scene graph logic takes care of highlighting individual lines of text
* or separate events request highlighting.
*
* @param audioPlayerFactory The audio player factory object.
* @return This object for chaining
*/
RootConfig& audioPlayerFactory(const AudioPlayerFactoryPtr& audioPlayerFactory) {
mAudioPlayerFactory = audioPlayerFactory;
return *this;
}
/**
* Specify the set of enabled experimental features for this rootConfig
* @param enabledExperimentalFeatures The set of enabled experimental features.
* @return This object for chaining
*/
RootConfig& experimentalFeatures(const std::set<ExperimentalFeature>& enabledExperimentalFeatures){
mEnabledExperimentalFeatures = enabledExperimentalFeatures;
return *this;
}
#ifdef SCENEGRAPH
/**
* Specify the edit text factory used for creating edit text objects.
* @param editTextFactory The edit text layout factory object
* @return This object for chaining
*/
RootConfig& editTextFactory(const sg::EditTextFactoryPtr& editTextFactory) {
mEditTextFactory = editTextFactory;
return *this;
}
#endif // SCENEGRAPH
/**
* Specify the time manager.
* @param timeManager The time manager
* @return This object for chaining.
*/
RootConfig& timeManager(const std::shared_ptr<TimeManager>& timeManager) {
mTimeManager = timeManager;
return *this;
}
/**
* Specify the runtime specific locale methods.
* @param localeMethods The runtime implemented localeMethods
* @return This object for chaining.
*/
RootConfig& localeMethods(const std::shared_ptr<LocaleMethods>& localeMethods) {
mLocaleMethods = localeMethods;
return *this;
}
/**
* Set how APL spec version check should be enforced.
* @param version The require APL version. @see APLVersion::Value.
* @return This object for chaining
*/
RootConfig& enforceAPLVersion(APLVersion::Value version) {
mEnforcedAPLVersion = version;
return *this;
}
/**
* Set the default size of a built-in component. This applies to both horizontal and vertical components
* @param type The component type.
* @param width The new default width.
* @param height The new default height.
* @return This object for chaining.
*/
RootConfig& defaultComponentSize(ComponentType type, Dimension width, Dimension height) {
defaultComponentSize(type, true, width, height);
return *this;
}
/**
* Set the default size of a built-in component with a particular direction.
* @param type The component type
* @param isVertical If true, this applies to a vertical scrolling component. If false, it applies to a horizontal.
* @param width The new default width.
* @param height The new default height.
* @return This object for chaining.
*/
RootConfig& defaultComponentSize(ComponentType type, bool isVertical, Dimension width, Dimension height) {
mDefaultComponentSize[std::pair<ComponentType, bool>{type, isVertical}] = std::pair<Dimension, Dimension>{width,
height};
return *this;
}
/**
* Add DataSource provider implementation.
* @param type Type name of DataSource.
* @param dataSourceProvider provider implementation.
* @return This object for chaining.
*/
RootConfig& dataSourceProvider(const std::string& type, const DataSourceProviderPtr& dataSourceProvider) {
mDataSources.emplace(type, dataSourceProvider);
return *this;
}
/**
* Set the session
* @param session The session
* @return This object for chaining.
* @deprecated Session used for content creation will be used instead.
*/
APL_DEPRECATED RootConfig& session(const SessionPtr& session);
/**
* Assign a LiveObject to the top-level context
* @param name The name of the LiveObject
* @param object The object itself
* @return This object for chaining
*/
RootConfig& liveData(const std::string& name, const LiveObjectPtr& object) {
mLiveObjectMap.emplace(name, object);
return *this;
}
/**
* Register watcher for live data object with given name.
* @param name Name of LiveData object.
* @param watcher Watcher.
* @return This object for chaining
*/
RootConfig& liveDataWatcher(const std::string& name, const std::shared_ptr<LiveDataObjectWatcher>& watcher) {
mLiveDataObjectWatchersMap.emplace(name, watcher);
return *this;
}
/**
* Register an ordered list of regular expressions for allowing/denying URL headers.
* Each rules is pattern to match and a boolean value (true=accept, false=deny).
* The first rule to match a header is used. If no rules match, the header is accepted.
*
* For example, to deny all "X-*" rules and accept everything else:
*
* rootConfig.filterHeaders( {{"(X-)(.*)", false}} );
*
* To accept a subset of "Accept-*" rules, deny the others, and accept anything else:
*
* rootConfig.filterHeaders( {{"Accept-Language", true},
* {"Accept-Charset": true},
* {"(Accept-)(.*)", false}} );
*
* To deny all headers except "Content-Type":
*
* rootConfig.filterHeaders( {{"Content-Type", true}, {".*", false}} );
*
* @param filters list of rules to apply to apply to the headers
* @return This object for chaining
*/
RootConfig& filterHeaders(std::vector<std::pair<std::regex, bool>> filters) {
mHeaderFilters = std::move(filters);
return *this;
}
#ifdef ALEXAEXTENSIONS
/**
* Assign a Alexa Extension provider.
* Requires kExperimentalExtensionProvider feature be enabled.
*
* @param extensionProvider Enables access to the system available extensions.
* @return This object for chaining
*/
RootConfig& extensionProvider(const alexaext::ExtensionProviderPtr& extensionProvider) {
if (experimentalFeatureEnabled(kExperimentalFeatureExtensionProvider)) {
mExtensionProvider = extensionProvider;
}
return *this;
}
/**
* Assign a Alexa Extension mediator.
* Requires kExperimentalFeatureExtensionProvider feature be enabled.
*
* @param extensionMediator Message mediator manages messages between Extension and APL engine.
* and the APL engine.
* @return This object for chaining
*/
RootConfig& extensionMediator(const ExtensionMediatorPtr &extensionMediator) {
if (experimentalFeatureEnabled(kExperimentalFeatureExtensionProvider)) {
mExtensionMediator = extensionMediator;
}
return *this;
}
#endif
/**
* Register an extension event handler. The name should be something like 'onDomainAction'.
* This method will also register the extension as a supported extension.
* @param handler The name of the handler to support.
* @return This object for chaining.
* @deprecated Extensions should be managed via ExtensionMediator
*/
RootConfig& registerExtensionEventHandler(ExtensionEventHandler handler) {
auto uri = handler.getURI();
if (mSupportedExtensions.find(uri) == mSupportedExtensions.end()) {
registerExtension(uri);
}
mExtensionHandlers.emplace_back(std::move(handler));
return *this;
}
/**
* Register an extension command that can be executed in the document. The name should be something like 'DomainEvent'.
* This method will also register the extension as a supported extension.
* @param commandDef The definition of the custom command (includes the name, URI, etc).
* @return This object for chaining
* @deprecated Extensions should be managed via ExtensionMediator
*/
RootConfig& registerExtensionCommand(ExtensionCommandDefinition commandDef) {
auto uri = commandDef.getURI();
if (mSupportedExtensions.find(uri) == mSupportedExtensions.end()) {
registerExtension(uri);
}
mExtensionCommands.emplace_back(std::move(commandDef));
return *this;
}
/**
* Register an extension filter that can be executed in Image components.
* This method will also register the extension as a supported extension.
* @param filterDef The definition of the custom filter (includes the name, URI, properties)
* @return This object for chaining
* @deprecated Extensions should be managed via ExtensionMediator
*/
RootConfig& registerExtensionFilter(ExtensionFilterDefinition filterDef) {
const auto& uri = filterDef.getURI();
if (mSupportedExtensions.find(uri) == mSupportedExtensions.end())
registerExtension(uri);
mExtensionFilters.emplace_back(std::move(filterDef));
return *this;
}
/**
* Register an extension component that can be inflated in the document. The name should be something
* like 'DomainCanvas'.
* This method will also register the extension as a supported extension.
* @param componentDef The definition of the custom component (includes the name, URI, etc).
* @return This object for chaining
* @deprecated Extensions should be managed via ExtensionMediator
*/
RootConfig& registerExtensionComponent(ExtensionComponentDefinition componentDef) {
auto uri = componentDef.getURI();
if (mSupportedExtensions.find(uri) == mSupportedExtensions.end()) {
registerExtension(uri);
}
mExtensionComponentDefinitions.emplace_back(std::move(componentDef));
return *this;
}
/**
* Register an environment for an extension. The document may access the extension environment by
* the extension name in the “environment.extension” environment property.
* Any previously registered environment is overwritten.
* This method will also register the extension as a supported extension.
*
* @param uri The URI of the extension
* @param environment values
* @return This object for chaining
* @deprecated Extensions should be managed via ExtensionMediator
*/
RootConfig& registerExtensionEnvironment(const std::string& uri, const Object& environment) {
registerExtension(uri, environment);
return *this;
}
/**
* Register a supported extension. Any previously registered configuration is overwritten.
* @param uri The URI of the extension
* @param config Configuration value(s) supported by this extension.
* @return This object for chaining
* @deprecated Extensions should be managed via ExtensionMediator
*/
RootConfig& registerExtension(const std::string& uri, const Object& config = Object::TRUE_OBJECT()) {
if (!config.truthy()) {
mSupportedExtensions[uri] = Object::TRUE_OBJECT();
} else {
mSupportedExtensions[uri] = config;
}
return *this;
}
/**
* Register a flags for an extension. Flags are opaque data provided by the execution environment
* (not the document) and passed to the extension at the beginning of the document session.
* Flags may be a single non-null value, array, or key-value bag.
* @param uri The URI of the extension
* @param flags The extension flags
* @return This object for chaining
* @deprecated Extensions should be managed via ExtensionMediator
*/
RootConfig& registerExtensionFlags(const std::string& uri, const Object& flags) {
mExtensionFlags[uri] = flags;
return *this;
}
/**
* Register a value to be reported in the data-binding "environment" context. If this the specified property name
* would shadow a built-in environment, viewport, or ConfigurationChange event property, this method has no effect.
*
* @param name The name of the value
* @param value The value to report. This will be read-only.
* @return This object for chaining
*/
RootConfig& setEnvironmentValue(const std::string& name, const Object& value);
/**
* Enable experimental feature. @see enum ExperimentalFeatures for available set.
* None of the features enabled by default.
* @experimental Not guaranteed to work for any of available features and can change Engine behaviors drastically.
* @param feature experimental feature to enable.
* @return This object for chaining
*/
RootConfig& enableExperimentalFeature(ExperimentalFeature feature) {
mEnabledExperimentalFeatures.emplace(feature);
return *this;
}
/**
* Set the default font color for a particular theme.
* @param theme The named theme (must match exactly)
* @param color The font color
* @return This object for chaining
*/
RootConfig& defaultFontColor(const std::string& theme, Color color) {
mDefaultThemeFontColor[theme] = color;
return *this;
}
/////////////////////////////////////////////////
/**
* Configure the agent name and version
* @deprecated Use set({
{RootProperty::kAgentName, agentName},
{RootProperty::kAgentVersion, agentVersion}
}) instead
* @param agentName The name of the APL agent
* @param agentVersion The version of the APL agent
* @return This object for chaining
*/
APL_DEPRECATED RootConfig& agent(const std::string& agentName, const std::string& agentVersion) {
return set({
{RootProperty::kAgentName, agentName},
{RootProperty::kAgentVersion, agentVersion}
});
}
/**
* Set if the OpenURL command is supported
* @deprecated Use set(RootProperty::kAllowOpenUrl, allowed) instead
* @param allowed If true, the OpenURL command is supported.
* @return This object for chaining
*/
APL_DEPRECATED RootConfig& allowOpenUrl(bool allowed) {
return set(RootProperty::kAllowOpenUrl, allowed);
}
/**
* Set if video is supported
* @deprecated Use set(RootProperty::kDisallowVideo, disallowed) instead
* @param disallowed If true, the Video component is disabled
* @return This object for chaining
*/
APL_DEPRECATED RootConfig& disallowVideo(bool disallowed) {
return set(RootProperty::kDisallowVideo, disallowed);
}
/**
* Set the quality of animation expected. If set to kAnimationQualityNone,
* all animation commands are disabled (include onMount).
* @deprecated Use set(RootProperty::kAnimationQuality, quality) instead
* @param quality The expected quality of animation playback.
* @return This object for chaining
*/
APL_DEPRECATED RootConfig& animationQuality(AnimationQuality quality) {
return set(RootProperty::kAnimationQuality, quality);
}
/**
* Set the default idle timeout.
* @deprecated Use set(RootProperty::kDefaultIdleTimeout, idleTimeout) instead
* @param idleTimeout Device wide idle timeout.
* @return This object for chaining
*/
APL_DEPRECATED RootConfig& defaultIdleTimeout(int idleTimeout) {
return set(RootProperty::kDefaultIdleTimeout, idleTimeout);
}
/**
* Set the reported APL version of the specification that is supported
* by this application. This value will be reported in the data-binding
* context under "environment.aplVersion".
* @deprecated Use set(RootProperty::kReportedVersion, version) instead
* @param version The version string to report.
* @return This object for chaining.
*/
APL_DEPRECATED RootConfig& reportedAPLVersion(const std::string& version) {
return set(RootProperty::kReportedVersion, version);
}
/**
* Sets whether the "type" field of an APL document should be enforced.
* Type should always be "APL", but for backwards compatibility, this is
* optionally ignored.
* @deprecated Use set(RootProperty::kEnforceTypeField, enforce) instead
* @param enforce `true` to enforce that the "type" field is set to "APL"
* @return This object for chaining
*/
APL_DEPRECATED RootConfig& enforceTypeField(bool enforce) {
return set(RootProperty::kEnforceTypeField, enforce);
}
/**
* Set the default font color. This is the fallback color for all themes.
* This color will only be applied if there is not a theme-defined default color.
* @deprecated Use set(RootProperty::kDefaultFontColor, color) instead
* @param color The font color
* @return This object for chaining
*/
APL_DEPRECATED RootConfig& defaultFontColor(Color color) {
return set(RootProperty::kDefaultFontColor, color);
}
/**
* Set the default font family. This is usually locale-based.
* @deprecated Use set(RootProperty::kDefaultFontFamily, fontFamily) instead
* @param fontFamily The font family.
* @return This object for chaining.
*/
APL_DEPRECATED RootConfig& defaultFontFamily(const std::string& fontFamily) {
return set(RootProperty::kDefaultFontFamily, fontFamily);
}
/**
* Enable or disable tracking of resource, style, and component provenance
* @deprecated Use set(RootProperty::kTrackProvenance, trackProvenance) instead
* @param trackProvenance True if provenance should be tracked.
* @return This object for chaining.
*/
APL_DEPRECATED RootConfig& trackProvenance(bool trackProvenance) {
return set(RootProperty::kTrackProvenance, trackProvenance);
}
/**
* Set pager layout cache in both directions. 1 is default and results in 1 page ensured before and one after
* current one.
* @deprecated Use set(RootProperty::kPagerChildCache, cache) instead
* @param cache Number of pages to ensure before and after current one.
* @return This object for chaining.
*/
APL_DEPRECATED RootConfig& pagerChildCache(int cache) {
return set(RootProperty::kPagerChildCache, cache);
}
/**
* Set sequence layout cache in both directions. 1 is default and results in 1 page of children ensured before and
* one after current one.
* @deprecated Use set(RootProperty::kSequenceChildCache, cache) instead
* @param cache Number of pages to ensure before and after current one.
* @return This object for chaining.
*/
APL_DEPRECATED RootConfig& sequenceChildCache(int cache) {
return set(RootProperty::kSequenceChildCache, cache);
}
/**
* Set the current UTC time in milliseconds since the epoch.
* @deprecated Use set(RootProperty::kUTCTime, time) instead
* @param time Milliseconds.
* @return This object for chaining.
*/
APL_DEPRECATED RootConfig& utcTime(apl_time_t time) {
return set(RootProperty::kUTCTime, time);
}
/**
* Set the local time zone adjustment in milliseconds. When added to the current UTC time,
* this will give the local time. This includes any daylight saving time adjustment.
* @deprecated Use set(RootProperty::kLocalTimeAdjustment, adjustment) instead
* @param adjustment Milliseconds
* @return This object for chaining
*/
APL_DEPRECATED RootConfig& localTimeAdjustment(apl_duration_t adjustment) {
return set(RootProperty::kLocalTimeAdjustment, adjustment);
}
/**
* Set double press timeout.
* @deprecated Use set(RootProperty::kDoublePressTimeout, timeout) instead
* @param timeout new double press timeout. Default is 500 ms.
* @return This object for chaining
*/
APL_DEPRECATED RootConfig& doublePressTimeout(apl_duration_t timeout) {
return set(RootProperty::kDoublePressTimeout, timeout);
}
/**
* Set long press timeout.
* @deprecated Use set(RootProperty::kLongPressTimeout, timeout) instead
* @param timeout new long press timeout. Default is 1000 ms.
* @return This object for chaining
*/
APL_DEPRECATED RootConfig& longPressTimeout(apl_duration_t timeout) {
return set(RootProperty::kLongPressTimeout, timeout);
}
/**
* Set pressed duration timeout. This is the duration to show the "pressed" state of a component
* when programmatically invoked.
* @deprecated Use set(RootProperty::kPressedDuration, timeout) instead
* @param timeout Duration in milliseconds. Default is 64 ms.
* @return This object for chaining
*/
APL_DEPRECATED RootConfig& pressedDuration(apl_duration_t timeout) {
return set(RootProperty::kPressedDuration, timeout);
}
/**
* Set the tap or scroll timeout. This is the maximum amount of time that can pass before the
* system has to commit to this being a touch event instead of a scroll event.
* @deprecated Use set(RootProperty::kTapOrScrollTimeout, timeout) instead
* @param timeout Duration in milliseconds. Default is 100 ms.
* @return This object for chaining
*/
APL_DEPRECATED RootConfig& tapOrScrollTimeout(apl_duration_t timeout) {
return set(RootProperty::kTapOrScrollTimeout, timeout);
}
/**
* Set SwipeAway gesture trigger distance threshold in dp. Initial movement below this threshold does not trigger the
* gesture.
* @deprecated see RootConfig::pointerSlopThreshold. Swiping is not that different from scrolling.
* @param distance threshold distance.
* @return This object for chaining
*/
APL_DEPRECATED RootConfig& swipeAwayTriggerDistanceThreshold(float distance) {
return set(RootProperty::kPointerSlopThreshold, distance);
}
/**
* Set SwipeAway gesture fulfill distance threshold in percents. Gesture requires swipe to be performed above this
* threshold for it to be considered complete.
* @deprecated Use set(RootProperty::kSwipeAwayFulfillDistancePercentageThreshold, distance) instead
* @param distance threshold distance.
* @return This object for chaining
*/
APL_DEPRECATED RootConfig& swipeAwayFulfillDistancePercentageThreshold(float distance) {
return set(RootProperty::kSwipeAwayFulfillDistancePercentageThreshold, distance);
}
/**
* Set SwipeAway gesture animation easing.
* @deprecated Use set(RootProperty::kSwipeAwayAnimationEasing, easing) instead
* @param easing Easing string to use for gesture animation. Should be according to current APL spec.
* @return This object for chaining
*/
APL_DEPRECATED RootConfig& swipeAwayAnimationEasing(const std::string& easing) {
return set(RootProperty::kSwipeAwayAnimationEasing, easing);
}
/**
* Set SwipeAway (and any related gesture) gesture swipe speed threshold.
* @deprecated Use set(RootProperty::kSwipeVelocityThreshold, velocity) instead
* @param velocity swipe velocity threshold in dp per second.
* @return This object for chaining
*/
APL_DEPRECATED RootConfig& swipeVelocityThreshold(float velocity) {
return set(RootProperty::kSwipeVelocityThreshold, velocity);
}
/**
* Set maximum SwipeAway (and any related gesture) gesture swipe speed.
* @deprecated Use set(RootProperty::kSwipeMaxVelocity, velocity) instead
* @param velocity max swipe velocity in dp per second.
* @return This object for chaining
*/
APL_DEPRECATED RootConfig& swipeMaxVelocity(float velocity) {
return set(RootProperty::kSwipeMaxVelocity, velocity);
}
/**
* Set SwipeAway gesture tolerance in degrees when determining whether a swipe was triggered.
* @deprecated Use set(RootProperty::kSwipeAngleTolerance, degrees) instead
* @param degrees swipe direction tolerance, in degrees.
* @return This object for chaining
*/
APL_DEPRECATED RootConfig& swipeAngleTolerance(float degrees) {
return set(RootProperty::kSwipeAngleTolerance, degrees);
}
/**
* Set default animation duration, in ms, for SwipeAway animations.
* @deprecated Use set(RootProperty::kDefaultSwipeAnimationDuration, duration) instead
* @param duration the default duration for animations, in ms.
* @return This object for chaining
*/
APL_DEPRECATED RootConfig& defaultSwipeAnimationDuration(apl_duration_t duration) {
return set(RootProperty::kDefaultSwipeAnimationDuration, duration);
}
/**
* Set max animation duration, in ms, for SwipeAway animations.
* @deprecated Use set(RootProperty::kMaxSwipeAnimationDuration, duration) instead
* @param duration the maximum duration for animations, in ms.
* @return This object for chaining
*/
APL_DEPRECATED RootConfig& maxSwipeAnimationDuration(apl_duration_t duration) {
return set(RootProperty::kMaxSwipeAnimationDuration, duration);
}
/**
* Set the fling velocity threshold. The user must fling at least this fast to start a fling action.
* @deprecated Use set(RootProperty::kMinimumFlingVelocity, velocity) instead
* @param velocity Fling velocity in dp per second.
* @return This object for chaining
*/
APL_DEPRECATED RootConfig& minimumFlingVelocity(float velocity) {
return set(RootProperty::kMinimumFlingVelocity, velocity);
}
/**
* Set a tick handler update limit in ms. Default is 16ms (60 FPS).
* @deprecated Use set(RootProperty::kTickHandlerUpdateLimit, updateLimit) instead
* @param updateLimit update limit in ms. Should be > 0.
* @return This object for chaining
*/
APL_DEPRECATED RootConfig& tickHandlerUpdateLimit(apl_duration_t updateLimit) {
return set(RootProperty::kTickHandlerUpdateLimit, updateLimit);
}
/**
* Set the requested font scaling factor for the document.
* @deprecated Use set(RootProperty::kFontScale, scale) instead
* @param scale The scaling factor. Default is 1.0
* @return This object for chaining
*/
APL_DEPRECATED RootConfig& fontScale(float scale) {
return set(RootProperty::kFontScale, scale);
}
/**
* Set the screen display mode for accessibility (normal or high-contrast)
* @deprecated Use set(RootProperty::kScreenMode, screenMode) instead
* @param screenMode The screen display mode
* @return This object for chaining
*/
APL_DEPRECATED RootConfig& screenMode(ScreenMode screenMode) {
return set(RootProperty::kScreenMode, screenMode);
}
/**
* Inform that a screen reader is turned on.
* @deprecated Use set(RootProperty::kScreenReader, enabled) instead
* @param enabled True if the screen reader is enabled
* @return This object for chaining
*/
APL_DEPRECATED RootConfig& screenReader(bool enabled) {
return set(RootProperty::kScreenReader, enabled);
}
/**
* Set pointer inactivity timeout. Pointer considered stale after pointer was not updated for this time.
* @deprecated Use set(RootProperty::kPointerInactivityTimeout, timeout) instead
* @param timeout inactivity timeout in ms.
* @return This object for chaining
*/
APL_DEPRECATED RootConfig& pointerInactivityTimeout(apl_duration_t timeout) {
return set(RootProperty::kPointerInactivityTimeout, timeout);
}
/**
* Set fling gestures velocity limit.
* @deprecated Use set(RootProperty::kMaximumFlingVelocity, velocity) instead
* @param velocity fling gesture velocity in dp per second.
* @return This object for chaining
*/
APL_DEPRECATED RootConfig& maximumFlingVelocity(float velocity) {
return set(RootProperty::kMaximumFlingVelocity, velocity);
}
/**
* Set the gesture distance threshold in dp. Initial movement below this threshold does not trigger
* gestures.
* @deprecated Use set(RootProperty::kPointerSlopThreshold, distance) instead
* @param distance threshold distance.
* @return This object for chaining
*/
APL_DEPRECATED RootConfig& pointerSlopThreshold(float distance) {
return set(RootProperty::kPointerSlopThreshold, distance);
}
/**
* Set scroll commands duration.
* @deprecated Use set(RootProperty::kScrollCommandDuration, duration) instead
* @param duration duration in ms.
* @return This object for chaining
*/
APL_DEPRECATED RootConfig& scrollCommandDuration(apl_duration_t duration) {
return set(RootProperty::kScrollCommandDuration, duration);
}
/**
* Set scroll snap duration.
* @deprecated Use set(RootProperty::kScrollSnapDuration, duration) instead
* @param duration duration in ms.
* @return This object for chaining
*/
APL_DEPRECATED RootConfig& scrollSnapDuration(apl_duration_t duration) {
return set(RootProperty::kScrollSnapDuration, duration);
}
/**
* Set default pager page switch animation duration.
* @deprecated Use set(RootProperty::kDefaultPagerAnimationDuration, duration) instead
* @param duration duration in ms.
* @return This object for chaining
*/
APL_DEPRECATED RootConfig& defaultPagerAnimationDuration(apl_duration_t duration) {
return set(RootProperty::kDefaultPagerAnimationDuration, duration);
}
/// Specific getters
/**
* Get RootConfig property
* @param key property key
* @return property value
*/
Object getProperty(RootProperty key) const;
/**
* @return The configured text measurement object.
*/
TextMeasurementPtr getMeasure() const { return mTextMeasurement; }
/**
* @return The configured document manager object
*/
DocumentManagerPtr getDocumentManager() const { return mDocumentManager; }
/**
* @return The configured media manager object
*/
MediaManagerPtr getMediaManager() const { return mMediaManager; }
/**
* @return The configured media player factory
*/
MediaPlayerFactoryPtr getMediaPlayerFactory() const { return mMediaPlayerFactory; }
/**
* @return The configured audio player factory
*/
AudioPlayerFactoryPtr getAudioPlayerFactory() const { return mAudioPlayerFactory; }
#ifdef SCENEGRAPH
/**
* @return The configured edit text factory
*/
sg::EditTextFactoryPtr getEditTextFactory() const { return mEditTextFactory; }
#endif // SCENEGRAPH
/**
* @return The time manager object
*/
std::shared_ptr<TimeManager> getTimeManager() const { return mTimeManager; }
/**
* @return The locale methods object
*/
std::shared_ptr<LocaleMethods> getLocaleMethods() const { return mLocaleMethods; }
/**
* @deprecated Use getProperty(RootProperty::kAgentName) instead
* @return The agent name string
*/
APL_DEPRECATED std::string getAgentName() const { return getProperty(RootProperty::kAgentName).getString(); }
/**
* @deprecated Use getProperty(RootProperty::kAgentVersion) instead
* @return The agent version string
*/
APL_DEPRECATED std::string getAgentVersion() const { return getProperty(RootProperty::kAgentVersion).getString(); }
/**
* @return The expected animation quality
*/
AnimationQuality getAnimationQuality() const {
return static_cast<AnimationQuality>(getProperty(RootProperty::kAnimationQuality).getInteger());
}
/**
* @return The string name of the current animation quality
*/
const char* getAnimationQualityString() const;
/**
* @deprecated Use getProperty(RootProperty::kAllowOpenUrl) instead
* @return True if the OpenURL command is supported
*/
APL_DEPRECATED bool getAllowOpenUrl() const { return getProperty(RootProperty::kAllowOpenUrl).getBoolean(); }
/**
* @deprecated Use getProperty(RootProperty::kDisallowVideo) instead
* @return True if the video component is not supported.
*/
APL_DEPRECATED bool getDisallowVideo() const { return getProperty(RootProperty::kDisallowVideo).getBoolean(); }