slot
0.0.1
A real time UI render framework
载入中...
搜索中...
未找到
third
yoga
yoga
algorithm
Align.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 <
yoga/Yoga.h
>
11
12
#include <
yoga/algorithm/FlexDirection.h
>
13
#include <
yoga/node/Node.h
>
14
15
namespace
facebook::yoga
{
16
17
inline
Align
resolveChildAlignment
(
18
const
yoga::Node* node,
19
const
yoga::Node* child) {
20
const
Align
align = child->style().alignSelf() ==
Align::Auto
21
? node->style().alignItems()
22
: child->style().alignSelf();
23
24
if
(node->style().display() ==
Display::Flex
&& align ==
Align::Baseline
&&
25
isColumn
(node->style().flexDirection())) {
26
return
Align::FlexStart
;
27
}
28
29
return
align;
30
}
31
32
inline
Justify
resolveChildJustification
(
33
const
yoga::Node* node,
34
const
yoga::Node* child) {
35
return
child->style().justifySelf() ==
Justify::Auto
36
? node->style().justifyItems()
37
: child->style().justifySelf();
38
}
39
44
constexpr
Align
fallbackAlignment
(
Align
align) {
45
switch
(align) {
46
// Fallback to flex-start
47
case
Align::SpaceBetween
:
48
case
Align::Stretch
:
49
return
Align::FlexStart
;
50
51
// Fallback to safe center. TODO (T208209388): This should be aligned to
52
// Start instead of FlexStart (for row-reverse containers)
53
case
Align::SpaceAround
:
54
case
Align::SpaceEvenly
:
55
return
Align::FlexStart
;
56
default
:
57
return
align;
58
}
59
}
60
65
constexpr
Justify
fallbackAlignment
(
Justify
align) {
66
switch
(align) {
67
// Fallback to flex-start
68
case
Justify::SpaceBetween
:
69
// TODO: Support `justify-content: stretch`
70
// case Justify::Stretch:
71
return
Justify::FlexStart
;
72
73
// Fallback to safe center. TODO (T208209388): This should be aligned to
74
// Start instead of FlexStart (for row-reverse containers)
75
case
Justify::SpaceAround
:
76
case
Justify::SpaceEvenly
:
77
return
Justify::FlexStart
;
78
default
:
79
return
align;
80
}
81
}
82
83
}
// namespace facebook::yoga
Node.h
Yoga.h
FlexDirection.h
facebook::yoga
Definition
Benchmark.cpp:19
facebook::yoga::fallbackAlignment
constexpr Align fallbackAlignment(Align align)
Definition
Align.h:44
facebook::yoga::Justify
Justify
Definition
Justify.h:18
facebook::yoga::Justify::Auto
@ Auto
facebook::yoga::Justify::SpaceEvenly
@ SpaceEvenly
facebook::yoga::Justify::FlexStart
@ FlexStart
facebook::yoga::Justify::SpaceAround
@ SpaceAround
facebook::yoga::Justify::SpaceBetween
@ SpaceBetween
facebook::yoga::Align
Align
Definition
Align.h:18
facebook::yoga::Align::Auto
@ Auto
facebook::yoga::Align::SpaceEvenly
@ SpaceEvenly
facebook::yoga::Align::FlexStart
@ FlexStart
facebook::yoga::Align::Baseline
@ Baseline
facebook::yoga::Align::SpaceAround
@ SpaceAround
facebook::yoga::Align::SpaceBetween
@ SpaceBetween
facebook::yoga::Align::Stretch
@ Stretch
facebook::yoga::resolveChildJustification
Justify resolveChildJustification(const yoga::Node *node, const yoga::Node *child)
Definition
Align.h:32
facebook::yoga::resolveChildAlignment
Align resolveChildAlignment(const yoga::Node *node, const yoga::Node *child)
Definition
Align.h:17
facebook::yoga::isColumn
bool isColumn(const FlexDirection flexDirection)
Definition
FlexDirection.h:26
facebook::yoga::Display::Flex
@ Flex
制作者
1.10.0