slot 0.0.1
A real time UI render framework
载入中...
搜索中...
未找到
Config.h
浏览该文件的文档.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#pragma once
9
10#include <bitset>
11
12#include <yoga/Yoga.h>
13#include <yoga/enums/Errata.h>
15#include <yoga/enums/LogLevel.h>
16
17// Tag struct used to form the opaque YGConfigRef for the public C API
18struct YGConfig {};
19
20namespace facebook::yoga {
21
22class Config;
23class Node;
24
25using ExperimentalFeatureSet = std::bitset<ordinalCount<ExperimentalFeature>()>;
26
27// Whether moving a node from an old to new config should dirty previously
28// calculated layout results.
30 const Config& oldConfig,
31 const Config& newConfig);
32
33class YG_EXPORT Config : public ::YGConfig {
34 public:
35 explicit Config(YGLogger logger) : logger_{logger} {}
36
37 void setUseWebDefaults(bool useWebDefaults);
38 bool useWebDefaults() const;
39
40 void setExperimentalFeatureEnabled(ExperimentalFeature feature, bool enabled);
41 bool isExperimentalFeatureEnabled(ExperimentalFeature feature) const;
42 ExperimentalFeatureSet getEnabledExperiments() const;
43
44 void setErrata(Errata errata);
45 void addErrata(Errata errata);
46 void removeErrata(Errata errata);
47 Errata getErrata() const;
48 bool hasErrata(Errata errata) const;
49
50 void setPointScaleFactor(float pointScaleFactor);
51 float getPointScaleFactor() const;
52
53 void setContext(void* context);
54 void* getContext() const;
55
56 uint32_t getVersion() const noexcept;
57
58 void setLogger(YGLogger logger);
59 void log(
60 const yoga::Node* node,
61 LogLevel logLevel,
62 const char* format,
63 va_list args) const;
64
65 void setCloneNodeCallback(YGCloneNodeFunc cloneNode);
67 cloneNode(YGNodeConstRef node, YGNodeConstRef owner, size_t childIndex) const;
68
69 static const Config& getDefault();
70
71 private:
72 YGCloneNodeFunc cloneNodeCallback_{nullptr};
73 YGLogger logger_{};
74
75 bool useWebDefaults_ : 1 = false;
76
77 uint32_t version_ = 0;
78 ExperimentalFeatureSet experimentalFeatures_{};
79 Errata errata_ = Errata::None;
80 float pointScaleFactor_ = 1.0f;
81 void* context_ = nullptr;
82};
83
84inline Config* resolveRef(const YGConfigRef ref) {
85 return static_cast<Config*>(ref);
86}
87
88inline const Config* resolveRef(const YGConfigConstRef ref) {
89 return static_cast<const Config*>(ref);
90}
91
92} // namespace facebook::yoga
YGNodeRef(* YGCloneNodeFunc)(YGNodeConstRef oldNode, YGNodeConstRef owner, size_t childIndex)
Definition YGConfig.h:130
int(* YGLogger)(YGConfigConstRef config, YGNodeConstRef node, YGLogLevel level, const char *format, va_list args)
Definition YGConfig.h:103
typedefYG_EXTERN_C_BEGIN struct YGNode * YGNodeRef
Definition YGConfig.h:19
#define YG_EXPORT
Definition YGMacros.h:35
Definition Config.h:33
Config(YGLogger logger)
Definition Config.h:35
bool useWebDefaults_
Definition Config.h:75
Definition Benchmark.cpp:19
bool configUpdateInvalidatesLayout(const Config &oldConfig, const Config &newConfig)
Definition Config.cpp:14
LogLevel
Definition LogLevel.h:18
std::bitset< ordinalCount< ExperimentalFeature >()> ExperimentalFeatureSet
Definition Config.h:25
ExperimentalFeature
Definition ExperimentalFeature.h:18
Errata
Definition Errata.h:18
Config * resolveRef(const YGConfigRef ref)
Definition Config.h:84
Definition Config.h:18
Definition Node.h:29