2019-06-06 19:36:56 -07:00
|
|
|
/*
|
2022-10-04 13:59:32 -07:00
|
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
2017-01-02 02:22:45 -08:00
|
|
|
*
|
2019-10-15 10:30:08 -07:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2017-01-02 02:22:45 -08:00
|
|
|
*/
|
2019-10-15 10:30:08 -07:00
|
|
|
|
2017-01-02 02:22:45 -08:00
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
#include <yoga/Yoga.h>
|
|
|
|
|
2023-09-13 20:12:55 -07:00
|
|
|
#include "./Config.h"
|
2023-05-09 15:35:42 -07:00
|
|
|
#include "./Layout.h"
|
2023-09-13 20:12:55 -07:00
|
|
|
#include "./Node.h"
|
2023-05-09 15:35:42 -07:00
|
|
|
#include "./Size.h"
|
2017-01-02 02:22:45 -08:00
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
static YGSize globalMeasureFunc(
|
2023-09-11 19:51:40 -07:00
|
|
|
YGNodeConstRef nodeRef,
|
2019-03-25 05:37:36 -07:00
|
|
|
float width,
|
|
|
|
YGMeasureMode widthMode,
|
|
|
|
float height,
|
|
|
|
YGMeasureMode heightMode) {
|
|
|
|
Node const& node = *reinterpret_cast<Node const*>(YGNodeGetContext(nodeRef));
|
2017-01-02 02:22:45 -08:00
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
Size size = node.callMeasureFunc(width, widthMode, height, heightMode);
|
2021-01-10 10:03:53 -08:00
|
|
|
YGSize ygSize = {
|
|
|
|
static_cast<float>(size.width), static_cast<float>(size.height)};
|
2017-01-02 02:22:45 -08:00
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
return ygSize;
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2023-09-11 19:51:40 -07:00
|
|
|
static void globalDirtiedFunc(YGNodeConstRef nodeRef) {
|
2019-03-25 05:37:36 -07:00
|
|
|
Node const& node = *reinterpret_cast<Node const*>(YGNodeGetContext(nodeRef));
|
2019-01-31 09:06:57 -08:00
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
node.callDirtiedFunc();
|
2019-01-31 09:06:57 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
/* static */ Node* Node::createDefault(void) {
|
|
|
|
return new Node(nullptr);
|
2017-03-28 10:28:53 -07:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
/* static */ Node* Node::createWithConfig(Config* config) {
|
|
|
|
return new Node(config);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
/* static */ void Node::destroy(Node* node) {
|
|
|
|
delete node;
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
/* static */ Node* Node::fromYGNode(YGNodeRef nodeRef) {
|
|
|
|
return reinterpret_cast<Node*>(YGNodeGetContext(nodeRef));
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
Node::Node(Config* config)
|
|
|
|
: m_node(
|
|
|
|
config != nullptr ? YGNodeNewWithConfig(config->m_config)
|
|
|
|
: YGNodeNew()),
|
|
|
|
m_measureFunc(nullptr),
|
|
|
|
m_dirtiedFunc(nullptr) {
|
|
|
|
YGNodeSetContext(m_node, reinterpret_cast<void*>(this));
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
Node::~Node(void) {
|
|
|
|
YGNodeFree(m_node);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::reset(void) {
|
|
|
|
m_measureFunc.reset(nullptr);
|
|
|
|
m_dirtiedFunc.reset(nullptr);
|
2017-01-02 02:22:45 -08:00
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
YGNodeReset(m_node);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::copyStyle(Node const& other) {
|
|
|
|
YGNodeCopyStyle(m_node, other.m_node);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2024-09-25 15:46:55 -07:00
|
|
|
void Node::setBoxSizing(int boxSizing) {
|
|
|
|
YGNodeStyleSetBoxSizing(m_node, static_cast<YGBoxSizing>(boxSizing));
|
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setPositionType(int positionType) {
|
|
|
|
YGNodeStyleSetPositionType(m_node, static_cast<YGPositionType>(positionType));
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setPosition(int edge, double position) {
|
|
|
|
YGNodeStyleSetPosition(m_node, static_cast<YGEdge>(edge), position);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setPositionPercent(int edge, double position) {
|
|
|
|
YGNodeStyleSetPositionPercent(m_node, static_cast<YGEdge>(edge), position);
|
2017-01-04 04:33:39 -08:00
|
|
|
}
|
|
|
|
|
2024-08-27 06:00:34 -07:00
|
|
|
void Node::setPositionAuto(int edge) {
|
|
|
|
YGNodeStyleSetPositionAuto(m_node, static_cast<YGEdge>(edge));
|
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setAlignContent(int alignContent) {
|
|
|
|
YGNodeStyleSetAlignContent(m_node, static_cast<YGAlign>(alignContent));
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setAlignItems(int alignItems) {
|
|
|
|
YGNodeStyleSetAlignItems(m_node, static_cast<YGAlign>(alignItems));
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setAlignSelf(int alignSelf) {
|
|
|
|
YGNodeStyleSetAlignSelf(m_node, static_cast<YGAlign>(alignSelf));
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setFlexDirection(int flexDirection) {
|
|
|
|
YGNodeStyleSetFlexDirection(
|
|
|
|
m_node, static_cast<YGFlexDirection>(flexDirection));
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2024-03-12 11:31:46 -07:00
|
|
|
void Node::setDirection(int direction) {
|
|
|
|
YGNodeStyleSetDirection(m_node, static_cast<YGDirection>(direction));
|
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setFlexWrap(int flexWrap) {
|
|
|
|
YGNodeStyleSetFlexWrap(m_node, static_cast<YGWrap>(flexWrap));
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setJustifyContent(int justifyContent) {
|
|
|
|
YGNodeStyleSetJustifyContent(m_node, static_cast<YGJustify>(justifyContent));
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setMargin(int edge, double margin) {
|
|
|
|
YGNodeStyleSetMargin(m_node, static_cast<YGEdge>(edge), margin);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setMarginPercent(int edge, double margin) {
|
|
|
|
YGNodeStyleSetMarginPercent(m_node, static_cast<YGEdge>(edge), margin);
|
2017-01-04 04:33:39 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setMarginAuto(int edge) {
|
|
|
|
YGNodeStyleSetMarginAuto(m_node, static_cast<YGEdge>(edge));
|
2017-02-14 14:26:09 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setOverflow(int overflow) {
|
|
|
|
YGNodeStyleSetOverflow(m_node, static_cast<YGOverflow>(overflow));
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setDisplay(int display) {
|
|
|
|
YGNodeStyleSetDisplay(m_node, static_cast<YGDisplay>(display));
|
2017-02-06 09:31:22 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setFlex(double flex) {
|
|
|
|
YGNodeStyleSetFlex(m_node, flex);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setFlexBasis(double flexBasis) {
|
|
|
|
YGNodeStyleSetFlexBasis(m_node, flexBasis);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setFlexBasisPercent(double flexBasis) {
|
|
|
|
YGNodeStyleSetFlexBasisPercent(m_node, flexBasis);
|
2017-01-04 04:33:39 -08:00
|
|
|
}
|
|
|
|
|
2022-10-13 00:35:44 -07:00
|
|
|
void Node::setFlexBasisAuto() {
|
|
|
|
YGNodeStyleSetFlexBasisAuto(m_node);
|
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setFlexGrow(double flexGrow) {
|
|
|
|
YGNodeStyleSetFlexGrow(m_node, flexGrow);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setFlexShrink(double flexShrink) {
|
|
|
|
YGNodeStyleSetFlexShrink(m_node, flexShrink);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setWidth(double width) {
|
|
|
|
YGNodeStyleSetWidth(m_node, width);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setWidthPercent(double width) {
|
|
|
|
YGNodeStyleSetWidthPercent(m_node, width);
|
2017-01-04 04:33:39 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setWidthAuto() {
|
|
|
|
YGNodeStyleSetWidthAuto(m_node);
|
2017-02-14 14:26:09 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setHeight(double height) {
|
|
|
|
YGNodeStyleSetHeight(m_node, height);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setHeightPercent(double height) {
|
|
|
|
YGNodeStyleSetHeightPercent(m_node, height);
|
2017-01-04 04:33:39 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setHeightAuto() {
|
|
|
|
YGNodeStyleSetHeightAuto(m_node);
|
2017-02-14 14:26:09 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setMinWidth(double minWidth) {
|
|
|
|
YGNodeStyleSetMinWidth(m_node, minWidth);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setMinWidthPercent(double minWidth) {
|
|
|
|
YGNodeStyleSetMinWidthPercent(m_node, minWidth);
|
2017-01-04 04:33:39 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setMinHeight(double minHeight) {
|
|
|
|
YGNodeStyleSetMinHeight(m_node, minHeight);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setMinHeightPercent(double minHeight) {
|
|
|
|
YGNodeStyleSetMinHeightPercent(m_node, minHeight);
|
2017-01-04 04:33:39 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setMaxWidth(double maxWidth) {
|
|
|
|
YGNodeStyleSetMaxWidth(m_node, maxWidth);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setMaxWidthPercent(double maxWidth) {
|
|
|
|
YGNodeStyleSetMaxWidthPercent(m_node, maxWidth);
|
2017-01-04 04:33:39 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setMaxHeight(double maxHeight) {
|
|
|
|
YGNodeStyleSetMaxHeight(m_node, maxHeight);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setMaxHeightPercent(double maxHeight) {
|
|
|
|
YGNodeStyleSetMaxHeightPercent(m_node, maxHeight);
|
2017-01-04 04:33:39 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setAspectRatio(double aspectRatio) {
|
|
|
|
YGNodeStyleSetAspectRatio(m_node, aspectRatio);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setBorder(int edge, double border) {
|
|
|
|
YGNodeStyleSetBorder(m_node, static_cast<YGEdge>(edge), border);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setPadding(int edge, double padding) {
|
|
|
|
YGNodeStyleSetPadding(m_node, static_cast<YGEdge>(edge), padding);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::setPaddingPercent(int edge, double padding) {
|
|
|
|
YGNodeStyleSetPaddingPercent(m_node, static_cast<YGEdge>(edge), padding);
|
2017-01-04 04:33:39 -08:00
|
|
|
}
|
|
|
|
|
2018-11-14 02:49:27 -08:00
|
|
|
void Node::setIsReferenceBaseline(bool isReferenceBaseline) {
|
|
|
|
YGNodeSetIsReferenceBaseline(m_node, isReferenceBaseline);
|
|
|
|
}
|
|
|
|
|
2022-10-13 08:18:49 -07:00
|
|
|
void Node::setGap(int gutter, double gapLength) {
|
|
|
|
YGNodeStyleSetGap(m_node, static_cast<YGGutter>(gutter), gapLength);
|
|
|
|
}
|
|
|
|
|
2024-04-15 16:44:16 -07:00
|
|
|
void Node::setGapPercent(int gutter, double gapLength) {
|
|
|
|
YGNodeStyleSetGapPercent(m_node, static_cast<YGGutter>(gutter), gapLength);
|
|
|
|
}
|
|
|
|
|
2024-09-25 15:46:55 -07:00
|
|
|
int Node::getBoxSizing(void) const {
|
|
|
|
return YGNodeStyleGetBoxSizing(m_node);
|
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
int Node::getPositionType(void) const {
|
|
|
|
return YGNodeStyleGetPositionType(m_node);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
Value Node::getPosition(int edge) const {
|
|
|
|
return Value::fromYGValue(
|
|
|
|
YGNodeStyleGetPosition(m_node, static_cast<YGEdge>(edge)));
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
int Node::getAlignContent(void) const {
|
|
|
|
return YGNodeStyleGetAlignContent(m_node);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
int Node::getAlignItems(void) const {
|
|
|
|
return YGNodeStyleGetAlignItems(m_node);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
int Node::getAlignSelf(void) const {
|
|
|
|
return YGNodeStyleGetAlignSelf(m_node);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
int Node::getFlexDirection(void) const {
|
|
|
|
return YGNodeStyleGetFlexDirection(m_node);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2024-03-12 11:31:46 -07:00
|
|
|
int Node::getDirection(void) const {
|
|
|
|
return YGNodeStyleGetDirection(m_node);
|
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
int Node::getFlexWrap(void) const {
|
|
|
|
return YGNodeStyleGetFlexWrap(m_node);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
int Node::getJustifyContent(void) const {
|
|
|
|
return YGNodeStyleGetJustifyContent(m_node);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
Value Node::getMargin(int edge) const {
|
|
|
|
return Value::fromYGValue(
|
|
|
|
YGNodeStyleGetMargin(m_node, static_cast<YGEdge>(edge)));
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
int Node::getOverflow(void) const {
|
|
|
|
return YGNodeStyleGetOverflow(m_node);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
int Node::getDisplay(void) const {
|
|
|
|
return YGNodeStyleGetDisplay(m_node);
|
2017-02-06 09:31:22 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
Value Node::getFlexBasis(void) const {
|
|
|
|
return Value::fromYGValue(YGNodeStyleGetFlexBasis(m_node));
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
double Node::getFlexGrow(void) const {
|
|
|
|
return YGNodeStyleGetFlexGrow(m_node);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
double Node::getFlexShrink(void) const {
|
|
|
|
return YGNodeStyleGetFlexShrink(m_node);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
Value Node::getWidth(void) const {
|
|
|
|
return Value::fromYGValue(YGNodeStyleGetWidth(m_node));
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
Value Node::getHeight(void) const {
|
|
|
|
return Value::fromYGValue(YGNodeStyleGetHeight(m_node));
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
Value Node::getMinWidth(void) const {
|
|
|
|
return Value::fromYGValue(YGNodeStyleGetMinWidth(m_node));
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
Value Node::getMinHeight(void) const {
|
|
|
|
return Value::fromYGValue(YGNodeStyleGetMinHeight(m_node));
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
Value Node::getMaxWidth(void) const {
|
|
|
|
return Value::fromYGValue(YGNodeStyleGetMaxWidth(m_node));
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
Value Node::getMaxHeight(void) const {
|
|
|
|
return Value::fromYGValue(YGNodeStyleGetMaxHeight(m_node));
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
double Node::getAspectRatio(void) const {
|
|
|
|
return YGNodeStyleGetAspectRatio(m_node);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
double Node::getBorder(int edge) const {
|
|
|
|
return YGNodeStyleGetBorder(m_node, static_cast<YGEdge>(edge));
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
Value Node::getPadding(int edge) const {
|
|
|
|
return Value::fromYGValue(
|
|
|
|
YGNodeStyleGetPadding(m_node, static_cast<YGEdge>(edge)));
|
2022-10-13 08:18:49 -07:00
|
|
|
}
|
|
|
|
|
2022-12-28 01:27:12 -08:00
|
|
|
float Node::getGap(int gutter) {
|
|
|
|
return YGNodeStyleGetGap(m_node, static_cast<YGGutter>(gutter));
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2018-11-14 02:49:27 -08:00
|
|
|
bool Node::isReferenceBaseline() {
|
|
|
|
return YGNodeIsReferenceBaseline(m_node);
|
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::insertChild(Node* child, unsigned index) {
|
|
|
|
YGNodeInsertChild(m_node, child->m_node, index);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::removeChild(Node* child) {
|
|
|
|
YGNodeRemoveChild(m_node, child->m_node);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
unsigned Node::getChildCount(void) const {
|
|
|
|
return YGNodeGetChildCount(m_node);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
Node* Node::getParent(void) {
|
|
|
|
auto nodePtr = YGNodeGetParent(m_node);
|
2017-01-02 02:22:45 -08:00
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
if (nodePtr == nullptr)
|
|
|
|
return nullptr;
|
2017-01-02 02:22:45 -08:00
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
return Node::fromYGNode(nodePtr);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
Node* Node::getChild(unsigned index) {
|
|
|
|
auto nodePtr = YGNodeGetChild(m_node, index);
|
2017-01-02 02:22:45 -08:00
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
if (nodePtr == nullptr)
|
|
|
|
return nullptr;
|
2017-01-02 02:22:45 -08:00
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
return Node::fromYGNode(nodePtr);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2022-12-28 01:27:12 -08:00
|
|
|
void Node::setMeasureFunc(MeasureCallback* measureFunc) {
|
|
|
|
m_measureFunc.reset(measureFunc);
|
2017-01-02 02:22:45 -08:00
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
YGNodeSetMeasureFunc(m_node, &globalMeasureFunc);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::unsetMeasureFunc(void) {
|
|
|
|
m_measureFunc.reset(nullptr);
|
2017-01-02 02:22:45 -08:00
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
YGNodeSetMeasureFunc(m_node, nullptr);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
Size Node::callMeasureFunc(
|
|
|
|
double width,
|
|
|
|
int widthMode,
|
|
|
|
double height,
|
|
|
|
int heightMode) const {
|
2022-12-28 01:27:12 -08:00
|
|
|
return m_measureFunc->measure(width, widthMode, height, heightMode);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2022-12-28 01:27:12 -08:00
|
|
|
void Node::setDirtiedFunc(DirtiedCallback* dirtiedFunc) {
|
|
|
|
m_dirtiedFunc.reset(dirtiedFunc);
|
2019-01-31 09:06:57 -08:00
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
YGNodeSetDirtiedFunc(m_node, &globalDirtiedFunc);
|
2019-01-31 09:06:57 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Node::unsetDirtiedFunc(void) {
|
2019-03-25 05:37:36 -07:00
|
|
|
m_dirtiedFunc.reset(nullptr);
|
2019-01-31 09:06:57 -08:00
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
YGNodeSetDirtiedFunc(m_node, nullptr);
|
2019-01-31 09:06:57 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::callDirtiedFunc(void) const {
|
2022-12-28 01:27:12 -08:00
|
|
|
m_dirtiedFunc->dirtied();
|
2019-01-31 09:06:57 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::markDirty(void) {
|
|
|
|
YGNodeMarkDirty(m_node);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
bool Node::isDirty(void) const {
|
|
|
|
return YGNodeIsDirty(m_node);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2024-03-21 17:36:36 -07:00
|
|
|
void Node::markLayoutSeen() {
|
|
|
|
YGNodeSetHasNewLayout(m_node, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Node::hasNewLayout(void) const {
|
|
|
|
return YGNodeGetHasNewLayout(m_node);
|
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
void Node::calculateLayout(double width, double height, int direction) {
|
|
|
|
YGNodeCalculateLayout(
|
|
|
|
m_node, width, height, static_cast<YGDirection>(direction));
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
double Node::getComputedLeft(void) const {
|
|
|
|
return YGNodeLayoutGetLeft(m_node);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
double Node::getComputedRight(void) const {
|
|
|
|
return YGNodeLayoutGetRight(m_node);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
double Node::getComputedTop(void) const {
|
|
|
|
return YGNodeLayoutGetTop(m_node);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
double Node::getComputedBottom(void) const {
|
|
|
|
return YGNodeLayoutGetBottom(m_node);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
double Node::getComputedWidth(void) const {
|
|
|
|
return YGNodeLayoutGetWidth(m_node);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
double Node::getComputedHeight(void) const {
|
|
|
|
return YGNodeLayoutGetHeight(m_node);
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
Layout Node::getComputedLayout(void) const {
|
|
|
|
Layout layout;
|
2017-01-02 02:22:45 -08:00
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
layout.left = YGNodeLayoutGetLeft(m_node);
|
|
|
|
layout.right = YGNodeLayoutGetRight(m_node);
|
2017-01-02 02:22:45 -08:00
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
layout.top = YGNodeLayoutGetTop(m_node);
|
|
|
|
layout.bottom = YGNodeLayoutGetBottom(m_node);
|
2017-01-02 02:22:45 -08:00
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
layout.width = YGNodeLayoutGetWidth(m_node);
|
|
|
|
layout.height = YGNodeLayoutGetHeight(m_node);
|
2017-01-02 02:22:45 -08:00
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
return layout;
|
2017-01-02 02:22:45 -08:00
|
|
|
}
|
2017-01-15 15:16:10 -08:00
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
double Node::getComputedMargin(int edge) const {
|
|
|
|
return YGNodeLayoutGetMargin(m_node, static_cast<YGEdge>(edge));
|
2017-01-15 15:16:10 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
double Node::getComputedBorder(int edge) const {
|
|
|
|
return YGNodeLayoutGetBorder(m_node, static_cast<YGEdge>(edge));
|
2017-01-26 13:36:38 -08:00
|
|
|
}
|
|
|
|
|
2019-03-25 05:37:36 -07:00
|
|
|
double Node::getComputedPadding(int edge) const {
|
|
|
|
return YGNodeLayoutGetPadding(m_node, static_cast<YGEdge>(edge));
|
2017-01-15 15:16:10 -08:00
|
|
|
}
|
2024-01-08 20:28:49 -08:00
|
|
|
|
|
|
|
void Node::setAlwaysFormsContainingBlock(bool alwaysFormsContainingBlock) {
|
2024-01-09 11:46:05 -08:00
|
|
|
return YGNodeSetAlwaysFormsContainingBlock(
|
|
|
|
m_node, alwaysFormsContainingBlock);
|
2024-01-08 20:28:49 -08:00
|
|
|
}
|