1/*
2 * Copyright (C) 2016 The Qt Company Ltd.
3 * Copyright (c) Meta Platforms, Inc. and affiliates.
4 *
5 * SPDX-License-Identifier: MIT
6 */
7
8#pragma once
9
10#include <yoga/Yoga.h>
11
12#include "BitUtils.h"
13#include "Yoga-internal.h"
14
15QT_YOGA_NAMESPACE_BEGIN
16
17namespace facebook {
18namespace yoga {
19
20// Whether moving a node from config "a" to config "b" should dirty previously
21// calculated layout results.
22bool configUpdateInvalidatesLayout(YGConfigRef a, YGConfigRef b);
23
24// Internal variants of log functions, currently used only by JNI bindings.
25// TODO: Reconcile this with the public API
26using LogWithContextFn = int (*)(
27 YGConfigRef config,
28 YGNodeRef node,
29 YGLogLevel level,
30 void* context,
31 const char* format,
32 va_list args);
33using CloneWithContextFn = YGNodeRef (*)(
34 YGNodeRef node,
35 YGNodeRef owner,
36 int childIndex,
37 void* cloneContext);
38
39using ExperimentalFeatureSet =
40 facebook::yoga::detail::EnumBitset<YGExperimentalFeature>;
41
42#pragma pack(push)
43#pragma pack(1)
44// Packed structure of <32-bit options to miminize size per node.
45struct YGConfigFlags {
46 bool useWebDefaults : 1;
47 bool printTree : 1;
48 bool cloneNodeUsesContext : 1;
49 bool loggerUsesContext : 1;
50};
51#pragma pack(pop)
52
53} // namespace yoga
54} // namespace facebook
55
56struct YOGA_EXPORT YGConfig {
57 YGConfig(YGLogger logger);
58
59 void setUseWebDefaults(bool useWebDefaults);
60 bool useWebDefaults() const;
61
62 void setShouldPrintTree(bool printTree);
63 bool shouldPrintTree() const;
64
65 void setExperimentalFeatureEnabled(
66 YGExperimentalFeature feature,
67 bool enabled);
68 bool isExperimentalFeatureEnabled(YGExperimentalFeature feature) const;
69 facebook::yoga::ExperimentalFeatureSet getEnabledExperiments() const;
70
71 void setErrata(YGErrata errata);
72 void addErrata(YGErrata errata);
73 void removeErrata(YGErrata errata);
74 YGErrata getErrata() const;
75 bool hasErrata(YGErrata errata) const;
76
77 void setPointScaleFactor(float pointScaleFactor);
78 float getPointScaleFactor() const;
79
80 void setContext(void* context);
81 void* getContext() const;
82
83 void setLogger(YGLogger logger);
84 void setLogger(facebook::yoga::LogWithContextFn logger);
85 void setLogger(std::nullptr_t);
86 void log(YGConfig*, YGNode*, YGLogLevel, void*, const char*, va_list) const;
87
88 void setCloneNodeCallback(YGCloneNodeFunc cloneNode);
89 void setCloneNodeCallback(facebook::yoga::CloneWithContextFn cloneNode);
90 void setCloneNodeCallback(std::nullptr_t);
91 YGNodeRef cloneNode(
92 YGNodeRef node,
93 YGNodeRef owner,
94 int childIndex,
95 void* cloneContext) const;
96
97private:
98 union {
99 facebook::yoga::CloneWithContextFn withContext;
100 YGCloneNodeFunc noContext;
101 } cloneNodeCallback_;
102 union {
103 facebook::yoga::LogWithContextFn withContext;
104 YGLogger noContext;
105 } logger_;
106
107 facebook::yoga::YGConfigFlags flags_{};
108 facebook::yoga::ExperimentalFeatureSet experimentalFeatures_{};
109 YGErrata errata_ = YGErrataNone;
110 float pointScaleFactor_ = 1.0f;
111 void* context_ = nullptr;
112};
113
114QT_YOGA_NAMESPACE_END
115

source code of qtdeclarative/src/3rdparty/yoga/YGConfig.h