mirror of
https://github.com/status-im/react-native.git
synced 2025-02-09 16:14:47 +00:00
Add api for retrieving computed padding
Differential Revision: D4376572 fbshipit-source-id: 3ffb66e77090fc1257511bec5c933f9b0c304b9f
This commit is contained in:
parent
da59258372
commit
d9c35e8952
@ -47,6 +47,7 @@ typedef struct YGCachedMeasurement {
|
|||||||
typedef struct YGLayout {
|
typedef struct YGLayout {
|
||||||
float position[4];
|
float position[4];
|
||||||
float dimensions[2];
|
float dimensions[2];
|
||||||
|
float padding[6];
|
||||||
YGDirection direction;
|
YGDirection direction;
|
||||||
|
|
||||||
uint32_t computedFlexBasisGeneration;
|
uint32_t computedFlexBasisGeneration;
|
||||||
@ -94,16 +95,18 @@ typedef struct YGNode {
|
|||||||
YGStyle style;
|
YGStyle style;
|
||||||
YGLayout layout;
|
YGLayout layout;
|
||||||
uint32_t lineIndex;
|
uint32_t lineIndex;
|
||||||
bool hasNewLayout;
|
|
||||||
YGNodeRef parent;
|
YGNodeRef parent;
|
||||||
YGNodeListRef children;
|
YGNodeListRef children;
|
||||||
bool isDirty;
|
|
||||||
|
|
||||||
struct YGNode *nextChild;
|
struct YGNode *nextChild;
|
||||||
|
|
||||||
YGMeasureFunc measure;
|
YGMeasureFunc measure;
|
||||||
YGPrintFunc print;
|
YGPrintFunc print;
|
||||||
void *context;
|
void *context;
|
||||||
|
|
||||||
|
bool isDirty;
|
||||||
|
bool hasNewLayout;
|
||||||
} YGNode;
|
} YGNode;
|
||||||
|
|
||||||
#define YG_UNDEFINED_VALUES \
|
#define YG_UNDEFINED_VALUES \
|
||||||
@ -561,6 +564,28 @@ YG_NODE_LAYOUT_PROPERTY_IMPL(float, Width, dimensions[YGDimensionWidth]);
|
|||||||
YG_NODE_LAYOUT_PROPERTY_IMPL(float, Height, dimensions[YGDimensionHeight]);
|
YG_NODE_LAYOUT_PROPERTY_IMPL(float, Height, dimensions[YGDimensionHeight]);
|
||||||
YG_NODE_LAYOUT_PROPERTY_IMPL(YGDirection, Direction, direction);
|
YG_NODE_LAYOUT_PROPERTY_IMPL(YGDirection, Direction, direction);
|
||||||
|
|
||||||
|
float YGNodeLayoutGetPadding(const YGNodeRef node, const YGEdge edge) {
|
||||||
|
YG_ASSERT(edge <= YGEdgeEnd, "Cannot get layout paddings of multi-edge shorthands");
|
||||||
|
|
||||||
|
if (edge == YGEdgeLeft) {
|
||||||
|
if (node->layout.direction == YGDirectionRTL) {
|
||||||
|
return node->layout.padding[YGEdgeEnd];
|
||||||
|
} else {
|
||||||
|
return node->layout.padding[YGEdgeStart];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (edge == YGEdgeRight) {
|
||||||
|
if (node->layout.direction == YGDirectionRTL) {
|
||||||
|
return node->layout.padding[YGEdgeStart];
|
||||||
|
} else {
|
||||||
|
return node->layout.padding[YGEdgeEnd];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return node->layout.padding[edge];
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t gCurrentGenerationCount = 0;
|
uint32_t gCurrentGenerationCount = 0;
|
||||||
|
|
||||||
bool YGLayoutNodeInternal(const YGNodeRef node,
|
bool YGLayoutNodeInternal(const YGNodeRef node,
|
||||||
@ -1655,6 +1680,11 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||||||
const YGDirection direction = YGNodeResolveDirection(node, parentDirection);
|
const YGDirection direction = YGNodeResolveDirection(node, parentDirection);
|
||||||
node->layout.direction = direction;
|
node->layout.direction = direction;
|
||||||
|
|
||||||
|
node->layout.padding[YGEdgeStart] = YGNodeLeadingPadding(node, YGFlexDirectionResolve(YGFlexDirectionRow, direction), parentWidth);
|
||||||
|
node->layout.padding[YGEdgeEnd] = YGNodeTrailingPadding(node, YGFlexDirectionResolve(YGFlexDirectionRow, direction), parentWidth);
|
||||||
|
node->layout.padding[YGEdgeTop] = YGNodeLeadingPadding(node, YGFlexDirectionResolve(YGFlexDirectionColumn, direction), parentWidth);
|
||||||
|
node->layout.padding[YGEdgeBottom] = YGNodeTrailingPadding(node, YGFlexDirectionResolve(YGFlexDirectionColumn, direction), parentWidth);
|
||||||
|
|
||||||
if (node->measure) {
|
if (node->measure) {
|
||||||
YGNodeWithMeasureFuncSetMeasuredDimensions(
|
YGNodeWithMeasureFuncSetMeasuredDimensions(
|
||||||
node, availableWidth, availableHeight, widthMeasureMode, heightMeasureMode);
|
node, availableWidth, availableHeight, widthMeasureMode, heightMeasureMode);
|
||||||
|
@ -191,6 +191,12 @@ YG_NODE_LAYOUT_PROPERTY(float, Width);
|
|||||||
YG_NODE_LAYOUT_PROPERTY(float, Height);
|
YG_NODE_LAYOUT_PROPERTY(float, Height);
|
||||||
YG_NODE_LAYOUT_PROPERTY(YGDirection, Direction);
|
YG_NODE_LAYOUT_PROPERTY(YGDirection, Direction);
|
||||||
|
|
||||||
|
// Get the computed padding for this node after performing layout. If padding was set using
|
||||||
|
// pixel values then the returned value will be the same as YGNodeStyleGetPadding. However if
|
||||||
|
// padding was set using a percentage value then the returned value is the computed value used
|
||||||
|
// during layout.
|
||||||
|
WIN_EXPORT float YGNodeLayoutGetPadding(const YGNodeRef node, const YGEdge edge);
|
||||||
|
|
||||||
WIN_EXPORT void YGSetLogger(YGLogger logger);
|
WIN_EXPORT void YGSetLogger(YGLogger logger);
|
||||||
WIN_EXPORT void YGLog(YGLogLevel level, const char *message, ...);
|
WIN_EXPORT void YGLog(YGLogLevel level, const char *message, ...);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user