slot 0.0.1
A real time UI render framework
载入中...
搜索中...
未找到
FlexLine.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 <vector>
11
12#include <yoga/Yoga.h>
13#include <yoga/node/Node.h>
14
15namespace facebook::yoga {
16
18 // Total flex grow factors of flex items which are to be laid in the current
19 // line. This is decremented as free space is distributed.
21
22 // Total flex shrink factors of flex items which are to be laid in the current
23 // line. This is decremented as free space is distributed.
25
26 // The amount of available space within inner dimensions of the line which may
27 // still be distributed.
28 float remainingFreeSpace{0.0f};
29
30 // The size of the mainDim for the row after considering size, padding, margin
31 // and border of flex items. This is used to calculate maxLineDim after going
32 // through all the rows to decide on the main axis size of owner.
33 float mainDim{0.0f};
34
35 // The size of the crossDim for the row after considering size, padding,
36 // margin and border of flex items. Used for calculating containers crossSize.
37 float crossDim{0.0f};
38};
39
40struct FlexLine {
41 // List of children which are part of the line flow. This means they are not
42 // positioned absolutely, or with `display: "none"`, and do not overflow the
43 // available dimensions.
44 const std::vector<yoga::Node*> itemsInFlow{};
45
46 // Accumulation of the dimensions and margin of all the children on the
47 // current line. This will be used in order to either set the dimensions of
48 // the node if none already exist or to compute the remaining space left for
49 // the flexible children.
50 const float sizeConsumed{0.0f};
51
52 // Number of edges along the line flow with an auto margin.
53 const size_t numberOfAutoMargins{0};
54
55 // Layout information about the line computed in steps after line-breaking
57};
58
59// Calculates where a line starting at a given index should break, returning
60// information about the collective children on the liune.
61//
62// This function assumes that all the children of node have their
63// computedFlexBasis properly computed(To do this use
64// computeFlexBasisForChildren function).
65FlexLine calculateFlexLine(
66 yoga::Node* node,
67 Direction ownerDirection,
68 float ownerWidth,
69 float mainAxisOwnerSize,
70 float availableInnerWidth,
71 float availableInnerMainDim,
72 Node::LayoutableChildren::Iterator& iterator,
73 size_t lineCount);
74
75} // namespace facebook::yoga
Definition Benchmark.cpp:19
Direction
Definition Direction.h:18
FlexLine calculateFlexLine(yoga::Node *const node, const Direction ownerDirection, const float ownerWidth, const float mainAxisOwnerSize, const float availableInnerWidth, const float availableInnerMainDim, Node::LayoutableChildren::Iterator &iterator, const size_t lineCount)
Definition FlexLine.cpp:16
Definition FlexLine.h:40
const std::vector< yoga::Node * > itemsInFlow
Definition FlexLine.h:44
FlexLineRunningLayout layout
Definition FlexLine.h:56
const size_t numberOfAutoMargins
Definition FlexLine.h:53
const float sizeConsumed
Definition FlexLine.h:50
float totalFlexShrinkScaledFactors
Definition FlexLine.h:24
float crossDim
Definition FlexLine.h:37
float totalFlexGrowFactors
Definition FlexLine.h:20
float remainingFreeSpace
Definition FlexLine.h:28
float mainDim
Definition FlexLine.h:33