separates include headers and implementation
This commit is contained in:
parent
b833fe89ca
commit
a287d9ca59
118
CMakeLists.txt
118
CMakeLists.txt
@ -22,63 +22,63 @@ add_library(${CORE_WIDGETS_ADDON} SHARED
|
||||
"${CMAKE_JS_SRC}"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/main.cpp"
|
||||
# core internals
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/Extras/Utils/nutils.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/core/FlexLayout/flexlayout.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/core/FlexLayout/flexitem.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/core/YogaWidget/nodestyle.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/core/Events/eventsmap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/core/Events/eventwidget.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/core/YogaWidget/yogawidget.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/Extras/Utils/nutils.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/core/FlexLayout/flexlayout.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/core/FlexLayout/flexitem.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/core/YogaWidget/nodestyle.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/core/Events/eventsmap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/core/Events/eventwidget.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/core/YogaWidget/yogawidget.cpp"
|
||||
# core deps
|
||||
"${PROJECT_SOURCE_DIR}/deps/yoga/log.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/deps/yoga/Utils.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/deps/yoga/YGConfig.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/deps/yoga/YGEnums.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/deps/yoga/YGLayout.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/deps/yoga/YGNode.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/deps/yoga/YGNodePrint.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/deps/yoga/YGStyle.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/deps/yoga/YGValue.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/deps/yoga/Yoga.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/deps/yoga/event/event.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/deps/yoga/internal/experiments.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/deps/yoga/log.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/deps/yoga/Utils.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/deps/yoga/YGConfig.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/deps/yoga/YGEnums.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/deps/yoga/YGLayout.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/deps/yoga/YGNode.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/deps/yoga/YGNodePrint.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/deps/yoga/YGStyle.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/deps/yoga/YGValue.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/deps/yoga/Yoga.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/deps/yoga/event/event.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/deps/yoga/internal/experiments.cpp"
|
||||
# wrapped cpps
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtGui/QApplication/qapplication_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtGui/QClipboard/qclipboard_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtGui/QEvent/QKeyEvent/qkeyevent_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtGui/QPixmap/qpixmap_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtGui/QIcon/qicon_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtGui/QCursor/qcursor_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtWidgets/QWidget/qwidget_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtWidgets/QGridLayout/qgridlayout_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtWidgets/QDial/qdial_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtWidgets/QLabel/qlabel_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtWidgets/QLayout/qlayout_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtWidgets/QMainWindow/qmainwindow_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtWidgets/QPushButton/qpushbutton_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtWidgets/QSpinBox/qspinbox_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtWidgets/QCheckBox/qcheckbox_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtWidgets/QProgressBar/qprogressbar_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtWidgets/QRadioButton/qradiobutton_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtWidgets/QTabWidget/qtabwidget_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtWidgets/QLineEdit/qlineedit_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtWidgets/QPlainTextEdit/qplaintextedit_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtWidgets/QScrollArea/qscrollarea_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/core/FlexLayout/flexlayout_wrap.cpp"
|
||||
# Custom widgets
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtWidgets/QWidget/nwidget.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtWidgets/QLabel/nlabel.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtWidgets/QCheckBox/ncheckbox.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtWidgets/QDial/ndial.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtWidgets/QLineEdit/nlineedit.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtWidgets/QMainWindow/nmainwindow.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtWidgets/QProgressBar/nprogressbar.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtWidgets/QPushButton/npushbutton.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtWidgets/QSpinBox/nspinbox.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtWidgets/QRadioButton/nradiobutton.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtWidgets/QPlainTextEdit/nplaintextedit.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtWidgets/QScrollArea/nscrollarea.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/QtWidgets/QTabWidget/ntabwidget.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QApplication/qapplication_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QClipboard/qclipboard_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QEvent/QKeyEvent/qkeyevent_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QPixmap/qpixmap_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QIcon/qicon_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtGui/QCursor/qcursor_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QWidget/qwidget_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QGridLayout/qgridlayout_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QDial/qdial_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QLabel/qlabel_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QLayout/qlayout_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QMainWindow/qmainwindow_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QPushButton/qpushbutton_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QSpinBox/qspinbox_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QCheckBox/qcheckbox_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QProgressBar/qprogressbar_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QRadioButton/qradiobutton_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QTabWidget/qtabwidget_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QLineEdit/qlineedit_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QPlainTextEdit/qplaintextedit_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QScrollArea/qscrollarea_wrap.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/lib/core/FlexLayout/flexlayout_wrap.cpp"
|
||||
# Custom widgets (include them for automoc since they contain Q_OBJECT)
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QWidget/nwidget.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QLabel/nlabel.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QCheckBox/ncheckbox.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QDial/ndial.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QLineEdit/nlineedit.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QMainWindow/nmainwindow.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QProgressBar/nprogressbar.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QPushButton/npushbutton.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QSpinBox/nspinbox.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QRadioButton/nradiobutton.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QPlainTextEdit/nplaintextedit.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QScrollArea/nscrollarea.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QTabWidget/ntabwidget.hpp"
|
||||
)
|
||||
|
||||
# common
|
||||
@ -96,7 +96,13 @@ AddNapiSupport(${CORE_WIDGETS_ADDON})
|
||||
target_include_directories(${CORE_WIDGETS_ADDON} PRIVATE
|
||||
"${CMAKE_JS_INC}"
|
||||
"${PROJECT_SOURCE_DIR}"
|
||||
"${PROJECT_SOURCE_DIR}/deps"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/deps"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui"
|
||||
)
|
||||
|
||||
target_include_directories(${CORE_WIDGETS_ADDON} PUBLIC
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/cpp/include"
|
||||
)
|
||||
|
||||
target_link_libraries(${CORE_WIDGETS_ADDON} PRIVATE
|
||||
|
||||
45
deps/yoga/YGLayout.h
vendored
45
deps/yoga/YGLayout.h
vendored
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
#pragma once
|
||||
#include "YGFloatOptional.h"
|
||||
#include "Yoga-internal.h"
|
||||
|
||||
struct YGLayout {
|
||||
std::array<float, 4> position = {};
|
||||
std::array<float, 2> dimensions = {{YGUndefined, YGUndefined}};
|
||||
std::array<float, 4> margin = {};
|
||||
std::array<float, 4> border = {};
|
||||
std::array<float, 4> padding = {};
|
||||
YGDirection direction : 2;
|
||||
bool didUseLegacyFlag : 1;
|
||||
bool doesLegacyStretchFlagAffectsLayout : 1;
|
||||
bool hadOverflow : 1;
|
||||
|
||||
uint32_t computedFlexBasisGeneration = 0;
|
||||
YGFloatOptional computedFlexBasis = {};
|
||||
|
||||
// Instead of recomputing the entire layout every single time, we cache some
|
||||
// information to break early when nothing changed
|
||||
uint32_t generationCount = 0;
|
||||
YGDirection lastOwnerDirection = (YGDirection) -1;
|
||||
|
||||
uint32_t nextCachedMeasurementsIndex = 0;
|
||||
std::array<YGCachedMeasurement, YG_MAX_CACHED_RESULT_COUNT>
|
||||
cachedMeasurements = {};
|
||||
std::array<float, 2> measuredDimensions = {{YGUndefined, YGUndefined}};
|
||||
|
||||
YGCachedMeasurement cachedLayout = YGCachedMeasurement();
|
||||
|
||||
YGLayout()
|
||||
: direction(YGDirectionInherit),
|
||||
didUseLegacyFlag(false),
|
||||
doesLegacyStretchFlagAffectsLayout(false),
|
||||
hadOverflow(false) {}
|
||||
|
||||
bool operator==(YGLayout layout) const;
|
||||
bool operator!=(YGLayout layout) const { return !(*this == layout); }
|
||||
};
|
||||
301
deps/yoga/YGStyle.h
vendored
301
deps/yoga/YGStyle.h
vendored
@ -1,301 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
#pragma once
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <bitset>
|
||||
#include <cstdint>
|
||||
#include <type_traits>
|
||||
#include "CompactValue.h"
|
||||
#include "YGEnums.h"
|
||||
#include "YGFloatOptional.h"
|
||||
#include "Yoga-internal.h"
|
||||
#include "Yoga.h"
|
||||
|
||||
#if !defined(ENUM_BITFIELDS_NOT_SUPPORTED)
|
||||
#define BITFIELD_ENUM_SIZED(num) : num
|
||||
#else
|
||||
#define BITFIELD_ENUM_SIZED(num)
|
||||
#endif
|
||||
|
||||
#define BITFIELD_ACCESSORS(FIELD) \
|
||||
decltype(FIELD##_) get_##FIELD() const { return FIELD##_; } \
|
||||
void set_##FIELD(decltype(FIELD##_) x) { FIELD##_ = x; }
|
||||
|
||||
#define BITFIELD_REF(FIELD) \
|
||||
BitfieldRef< \
|
||||
decltype(FIELD##_), \
|
||||
&YGStyle::get_##FIELD, \
|
||||
&YGStyle::set_##FIELD, \
|
||||
FIELD##Bit>
|
||||
|
||||
class YGStyle {
|
||||
template <typename Enum>
|
||||
using Values =
|
||||
facebook::yoga::detail::Values<facebook::yoga::enums::count<Enum>()>;
|
||||
using CompactValue = facebook::yoga::detail::CompactValue;
|
||||
|
||||
static constexpr uint64_t allBits(int fromBit, int toBit) {
|
||||
return fromBit < toBit
|
||||
? (uint64_t{1} << fromBit) | allBits(fromBit + 1, toBit)
|
||||
: 0;
|
||||
}
|
||||
|
||||
public:
|
||||
using Dimensions = Values<YGDimension>;
|
||||
using Edges = Values<YGEdge>;
|
||||
|
||||
template <typename T, T YGStyle::*Prop, int PropBit>
|
||||
struct Ref {
|
||||
YGStyle& style;
|
||||
operator T() const { return style.*Prop; }
|
||||
Ref<T, Prop, PropBit>& operator=(T value) {
|
||||
style.*Prop = value;
|
||||
style.assignedProps_.set(PropBit);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Idx, Values<Idx> YGStyle::*Prop, int PropBit>
|
||||
struct IdxRef {
|
||||
struct Ref {
|
||||
YGStyle& style;
|
||||
Idx idx;
|
||||
operator CompactValue() const { return (style.*Prop)[idx]; }
|
||||
operator YGValue() const { return (style.*Prop)[idx]; }
|
||||
Ref& operator=(CompactValue value) {
|
||||
(style.*Prop)[idx] = value;
|
||||
style.assignedProps_.set(PropBit + idx);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
YGStyle& style;
|
||||
IdxRef<Idx, Prop, PropBit>& operator=(const Values<Idx>& values) {
|
||||
style.*Prop = values;
|
||||
style.assignedProps_ |=
|
||||
allBits(PropBit, PropBit + facebook::yoga::enums::count<Idx>());
|
||||
return *this;
|
||||
}
|
||||
operator const Values<Idx>&() const { return style.*Prop; }
|
||||
Ref operator[](Idx idx) { return {style, idx}; }
|
||||
CompactValue operator[](Idx idx) const { return (style.*Prop)[idx]; }
|
||||
};
|
||||
|
||||
template <
|
||||
typename T,
|
||||
T (YGStyle::*Get)() const,
|
||||
void (YGStyle::*Set)(T),
|
||||
int PropBit>
|
||||
struct BitfieldRef {
|
||||
YGStyle& style;
|
||||
|
||||
operator T() const { return (style.*Get)(); }
|
||||
BitfieldRef<T, Get, Set, PropBit>& operator=(T x) {
|
||||
(style.*Set)(x);
|
||||
style.assignedProps_.set(PropBit);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wbitfield-constant-conversion"
|
||||
#endif
|
||||
|
||||
YGStyle()
|
||||
: direction_(YGDirectionInherit),
|
||||
flexDirection_(YGFlexDirectionColumn),
|
||||
justifyContent_(YGJustifyFlexStart),
|
||||
alignContent_(YGAlignFlexStart),
|
||||
alignItems_(YGAlignStretch),
|
||||
alignSelf_(YGAlignAuto),
|
||||
positionType_(YGPositionTypeRelative),
|
||||
flexWrap_(YGWrapNoWrap),
|
||||
overflow_(YGOverflowVisible),
|
||||
display_(YGDisplayFlex) {}
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
~YGStyle() = default;
|
||||
|
||||
static constexpr int directionBit = 0;
|
||||
static constexpr int flexDirectionBit = directionBit + 1;
|
||||
static constexpr int justifyContentBit = flexDirectionBit + 1;
|
||||
static constexpr int alignContentBit = justifyContentBit + 1;
|
||||
static constexpr int alignItemsBit = alignContentBit + 1;
|
||||
static constexpr int alignSelfBit = alignItemsBit + 1;
|
||||
static constexpr int positionTypeBit = alignSelfBit + 1;
|
||||
static constexpr int flexWrapBit = positionTypeBit + 1;
|
||||
static constexpr int overflowBit = flexWrapBit + 1;
|
||||
static constexpr int displayBit = overflowBit + 1;
|
||||
static constexpr int flexBit = displayBit + 1;
|
||||
static constexpr int flexGrowBit = flexBit + 1;
|
||||
static constexpr int flexShrinkBit = flexGrowBit + 1;
|
||||
static constexpr int flexBasisBit = flexShrinkBit + 1;
|
||||
static constexpr int marginBit = flexBasisBit + 1;
|
||||
static constexpr int positionBit =
|
||||
marginBit + facebook::yoga::enums::count<YGEdge>();
|
||||
static constexpr int paddingBit =
|
||||
positionBit + facebook::yoga::enums::count<YGEdge>();
|
||||
static constexpr int borderBit =
|
||||
paddingBit + facebook::yoga::enums::count<YGEdge>();
|
||||
static constexpr int dimensionsBit =
|
||||
borderBit + facebook::yoga::enums::count<YGEdge>();
|
||||
static constexpr int maxDimensionsBit =
|
||||
dimensionsBit + facebook::yoga::enums::count<YGDimension>();
|
||||
static constexpr int minDimensionsBit =
|
||||
maxDimensionsBit + facebook::yoga::enums::count<YGDimension>();
|
||||
static constexpr int aspectRatioBit =
|
||||
minDimensionsBit + facebook::yoga::enums::count<YGDimension>();
|
||||
|
||||
static constexpr int numStyles = aspectRatioBit + 1;
|
||||
|
||||
private:
|
||||
std::bitset<aspectRatioBit + 1> assignedProps_;
|
||||
|
||||
/* Some platforms don't support enum bitfields,
|
||||
so please use BITFIELD_ENUM_SIZED(BITS_COUNT) */
|
||||
YGDirection direction_ BITFIELD_ENUM_SIZED(2);
|
||||
YGFlexDirection flexDirection_ BITFIELD_ENUM_SIZED(2);
|
||||
YGJustify justifyContent_ BITFIELD_ENUM_SIZED(3);
|
||||
YGAlign alignContent_ BITFIELD_ENUM_SIZED(3);
|
||||
YGAlign alignItems_ BITFIELD_ENUM_SIZED(3);
|
||||
YGAlign alignSelf_ BITFIELD_ENUM_SIZED(3);
|
||||
YGPositionType positionType_ BITFIELD_ENUM_SIZED(1);
|
||||
YGWrap flexWrap_ BITFIELD_ENUM_SIZED(2);
|
||||
YGOverflow overflow_ BITFIELD_ENUM_SIZED(2);
|
||||
YGDisplay display_ BITFIELD_ENUM_SIZED(1);
|
||||
YGFloatOptional flex_ = {};
|
||||
YGFloatOptional flexGrow_ = {};
|
||||
YGFloatOptional flexShrink_ = {};
|
||||
CompactValue flexBasis_ = CompactValue::ofAuto();
|
||||
Edges margin_ = {};
|
||||
Edges position_ = {};
|
||||
Edges padding_ = {};
|
||||
Edges border_ = {};
|
||||
Dimensions dimensions_{CompactValue::ofAuto()};
|
||||
Dimensions minDimensions_ = {};
|
||||
Dimensions maxDimensions_ = {};
|
||||
// Yoga specific properties, not compatible with flexbox specification
|
||||
YGFloatOptional aspectRatio_ = {};
|
||||
|
||||
BITFIELD_ACCESSORS(direction)
|
||||
BITFIELD_ACCESSORS(flexDirection)
|
||||
BITFIELD_ACCESSORS(justifyContent)
|
||||
BITFIELD_ACCESSORS(alignContent);
|
||||
BITFIELD_ACCESSORS(alignItems);
|
||||
BITFIELD_ACCESSORS(alignSelf);
|
||||
BITFIELD_ACCESSORS(positionType);
|
||||
BITFIELD_ACCESSORS(flexWrap);
|
||||
BITFIELD_ACCESSORS(overflow);
|
||||
BITFIELD_ACCESSORS(display);
|
||||
|
||||
public:
|
||||
const decltype(assignedProps_)& assignedProps() const {
|
||||
return assignedProps_;
|
||||
}
|
||||
|
||||
// for library users needing a type
|
||||
using ValueRepr = std::remove_reference<decltype(margin_[0])>::type;
|
||||
|
||||
YGDirection direction() const { return direction_; }
|
||||
BITFIELD_REF(direction) direction() { return {*this}; }
|
||||
|
||||
YGFlexDirection flexDirection() const { return flexDirection_; }
|
||||
BITFIELD_REF(flexDirection) flexDirection() { return {*this}; }
|
||||
|
||||
YGJustify justifyContent() const { return justifyContent_; }
|
||||
BITFIELD_REF(justifyContent) justifyContent() { return {*this}; }
|
||||
|
||||
YGAlign alignContent() const { return alignContent_; }
|
||||
BITFIELD_REF(alignContent) alignContent() { return {*this}; }
|
||||
|
||||
YGAlign alignItems() const { return alignItems_; }
|
||||
BITFIELD_REF(alignItems) alignItems() { return {*this}; }
|
||||
|
||||
YGAlign alignSelf() const { return alignSelf_; }
|
||||
BITFIELD_REF(alignSelf) alignSelf() { return {*this}; }
|
||||
|
||||
YGPositionType positionType() const { return positionType_; }
|
||||
BITFIELD_REF(positionType) positionType() { return {*this}; }
|
||||
|
||||
YGWrap flexWrap() const { return flexWrap_; }
|
||||
BITFIELD_REF(flexWrap) flexWrap() { return {*this}; }
|
||||
|
||||
YGOverflow overflow() const { return overflow_; }
|
||||
BITFIELD_REF(overflow) overflow() { return {*this}; }
|
||||
|
||||
YGDisplay display() const { return display_; }
|
||||
BITFIELD_REF(display) display() { return {*this}; }
|
||||
|
||||
YGFloatOptional flex() const { return flex_; }
|
||||
Ref<YGFloatOptional, &YGStyle::flex_, flexBit> flex() { return {*this}; }
|
||||
|
||||
YGFloatOptional flexGrow() const { return flexGrow_; }
|
||||
Ref<YGFloatOptional, &YGStyle::flexGrow_, flexGrowBit> flexGrow() {
|
||||
return {*this};
|
||||
}
|
||||
|
||||
YGFloatOptional flexShrink() const { return flexShrink_; }
|
||||
Ref<YGFloatOptional, &YGStyle::flexShrink_, flexShrinkBit> flexShrink() {
|
||||
return {*this};
|
||||
}
|
||||
|
||||
CompactValue flexBasis() const { return flexBasis_; }
|
||||
Ref<CompactValue, &YGStyle::flexBasis_, flexBasisBit> flexBasis() {
|
||||
return {*this};
|
||||
}
|
||||
|
||||
const Edges& margin() const { return margin_; }
|
||||
IdxRef<YGEdge, &YGStyle::margin_, marginBit> margin() { return {*this}; }
|
||||
|
||||
const Edges& position() const { return position_; }
|
||||
IdxRef<YGEdge, &YGStyle::position_, positionBit> position() {
|
||||
return {*this};
|
||||
}
|
||||
|
||||
const Edges& padding() const { return padding_; }
|
||||
IdxRef<YGEdge, &YGStyle::padding_, paddingBit> padding() { return {*this}; }
|
||||
|
||||
const Edges& border() const { return border_; }
|
||||
IdxRef<YGEdge, &YGStyle::border_, borderBit> border() { return {*this}; }
|
||||
|
||||
const Dimensions& dimensions() const { return dimensions_; }
|
||||
IdxRef<YGDimension, &YGStyle::dimensions_, dimensionsBit> dimensions() {
|
||||
return {*this};
|
||||
}
|
||||
|
||||
const Dimensions& minDimensions() const { return minDimensions_; }
|
||||
IdxRef<YGDimension, &YGStyle::minDimensions_, minDimensionsBit>
|
||||
minDimensions() {
|
||||
return {*this};
|
||||
}
|
||||
|
||||
const Dimensions& maxDimensions() const { return maxDimensions_; }
|
||||
IdxRef<YGDimension, &YGStyle::maxDimensions_, maxDimensionsBit>
|
||||
maxDimensions() {
|
||||
return {*this};
|
||||
}
|
||||
|
||||
// Yoga specific properties, not compatible with flexbox specification
|
||||
YGFloatOptional aspectRatio() const { return aspectRatio_; }
|
||||
Ref<YGFloatOptional, &YGStyle::aspectRatio_, aspectRatioBit> aspectRatio() {
|
||||
return {*this};
|
||||
}
|
||||
};
|
||||
|
||||
bool operator==(const YGStyle& lhs, const YGStyle& rhs);
|
||||
inline bool operator!=(const YGStyle& lhs, const YGStyle& rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
#undef BITFIELD_ENUM_SIZED
|
||||
#undef BITFIELD_ACCESSORS
|
||||
#undef BITFIELD_REF
|
||||
144
src/cpp/deps/yoga/Bitfield.h
Normal file
144
src/cpp/deps/yoga/Bitfield.h
Normal file
@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
#include <yoga/YGEnums.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
|
||||
namespace detail {
|
||||
|
||||
constexpr size_t log2ceil(size_t n) {
|
||||
return n < 1 ? 0 : (1 + log2ceil(n / 2));
|
||||
}
|
||||
|
||||
// The number of bits necessary to represent enums defined with YG_ENUM_SEQ_DECL
|
||||
template <typename Enum>
|
||||
constexpr size_t bitWidth() {
|
||||
static_assert(
|
||||
enums::count<Enum>() > 0, "Enums must have at least one entries");
|
||||
return log2ceil(enums::count<Enum>() - 1);
|
||||
}
|
||||
|
||||
// Number of bits needed for a boolean
|
||||
template <>
|
||||
constexpr size_t bitWidth<bool>() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
template <typename U, typename... Ts>
|
||||
struct BitTraits {};
|
||||
|
||||
template <typename U>
|
||||
struct BitTraits<U> {
|
||||
// Base cases
|
||||
static constexpr size_t width(size_t) { return 0; }
|
||||
static constexpr size_t shift(size_t) { return 0; }
|
||||
};
|
||||
|
||||
template <typename U, typename T, typename... Ts>
|
||||
struct BitTraits<U, T, Ts...> {
|
||||
using Rest = BitTraits<U, Ts...>;
|
||||
|
||||
static constexpr size_t width(size_t idx) {
|
||||
return idx == 0 ? bitWidth<T>() : Rest::width(idx - 1);
|
||||
}
|
||||
|
||||
static constexpr size_t shift(size_t idx) {
|
||||
return idx == 0 ? Rest::width(0) + Rest::shift(0) : Rest::shift(idx - 1);
|
||||
}
|
||||
|
||||
static constexpr U mask(size_t idx) {
|
||||
return ((U{1} << width(idx)) - 1) << shift(idx);
|
||||
}
|
||||
};
|
||||
|
||||
template <size_t Idx, typename T, typename... Ts>
|
||||
struct IndexedType {
|
||||
using Type = typename IndexedType<Idx - 1, Ts...>::Type;
|
||||
};
|
||||
|
||||
template <typename T, typename... Ts>
|
||||
struct IndexedType<0, T, Ts...> {
|
||||
using Type = T;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <typename Storage, typename... Fields>
|
||||
class Bitfield {
|
||||
static_assert(
|
||||
std::is_integral<Storage>::value,
|
||||
"Bitfield needs an integral storage type");
|
||||
static_assert(
|
||||
std::is_unsigned<Storage>::value,
|
||||
"Bitfield needs an unsigned storage type");
|
||||
static_assert(sizeof...(Fields) > 0, "Bitfield needs at least one member");
|
||||
|
||||
using BitTraits = detail::BitTraits<Storage, Fields...>;
|
||||
|
||||
#if !defined(_MSC_VER) || _MSC_VER > 1914
|
||||
static_assert(
|
||||
BitTraits::shift(0) + BitTraits::width(0) <=
|
||||
std::numeric_limits<Storage>::digits,
|
||||
"Specified storage type is too narrow to hold all types");
|
||||
#endif
|
||||
|
||||
template <size_t Idx>
|
||||
using TypeAt = typename detail::IndexedType<Idx, Fields...>::Type;
|
||||
|
||||
template <size_t Idx, typename Value, typename... Values>
|
||||
static constexpr Storage initStorage(Value value, Values... values) {
|
||||
return ((value << BitTraits::shift(Idx)) & BitTraits::mask(Idx)) |
|
||||
initStorage<Idx + 1, Values...>(values...);
|
||||
}
|
||||
|
||||
template <size_t Idx>
|
||||
static constexpr Storage initStorage() {
|
||||
return Storage{0};
|
||||
}
|
||||
|
||||
Storage storage_ = 0;
|
||||
|
||||
public:
|
||||
template <size_t Idx>
|
||||
class Ref {
|
||||
Bitfield& bitfield_;
|
||||
|
||||
public:
|
||||
Ref(Bitfield& bitfield) : bitfield_(bitfield) {}
|
||||
Ref& operator=(TypeAt<Idx> value) {
|
||||
bitfield_.storage_ = (bitfield_.storage_ & ~BitTraits::mask(Idx)) |
|
||||
((value << BitTraits::shift(Idx)) & BitTraits::mask(Idx));
|
||||
return *this;
|
||||
}
|
||||
operator TypeAt<Idx>() const {
|
||||
return const_cast<const Bitfield&>(bitfield_).at<Idx>();
|
||||
}
|
||||
};
|
||||
|
||||
constexpr Bitfield() = default;
|
||||
constexpr Bitfield(Fields... values) : storage_{initStorage<0>(values...)} {}
|
||||
|
||||
template <size_t Idx>
|
||||
constexpr TypeAt<Idx> at() const {
|
||||
return static_cast<TypeAt<Idx>>(
|
||||
(storage_ & BitTraits::mask(Idx)) >> BitTraits::shift(Idx));
|
||||
}
|
||||
|
||||
template <size_t Idx>
|
||||
Ref<Idx> at() {
|
||||
return {*this};
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
||||
@ -15,7 +15,8 @@ bool YGLayout::operator==(YGLayout layout) const {
|
||||
YGFloatArrayEqual(margin, layout.margin) &&
|
||||
YGFloatArrayEqual(border, layout.border) &&
|
||||
YGFloatArrayEqual(padding, layout.padding) &&
|
||||
direction == layout.direction && hadOverflow == layout.hadOverflow &&
|
||||
direction() == layout.direction() &&
|
||||
hadOverflow() == layout.hadOverflow() &&
|
||||
lastOwnerDirection == layout.lastOwnerDirection &&
|
||||
nextCachedMeasurementsIndex == layout.nextCachedMeasurementsIndex &&
|
||||
cachedLayout == layout.cachedLayout &&
|
||||
68
src/cpp/deps/yoga/YGLayout.h
Normal file
68
src/cpp/deps/yoga/YGLayout.h
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
#pragma once
|
||||
#include "Bitfield.h"
|
||||
#include "YGFloatOptional.h"
|
||||
#include "Yoga-internal.h"
|
||||
|
||||
struct YGLayout {
|
||||
std::array<float, 4> position = {};
|
||||
std::array<float, 2> dimensions = {{YGUndefined, YGUndefined}};
|
||||
std::array<float, 4> margin = {};
|
||||
std::array<float, 4> border = {};
|
||||
std::array<float, 4> padding = {};
|
||||
|
||||
private:
|
||||
static constexpr size_t directionIdx = 0;
|
||||
static constexpr size_t didUseLegacyFlagIdx = 1;
|
||||
static constexpr size_t doesLegacyStretchFlagAffectsLayoutIdx = 2;
|
||||
static constexpr size_t hadOverflowIdx = 3;
|
||||
facebook::yoga::Bitfield<uint8_t, YGDirection, bool, bool, bool> flags_ =
|
||||
{YGDirectionInherit, false, false, false};
|
||||
|
||||
public:
|
||||
uint32_t computedFlexBasisGeneration = 0;
|
||||
YGFloatOptional computedFlexBasis = {};
|
||||
|
||||
// Instead of recomputing the entire layout every single time, we cache some
|
||||
// information to break early when nothing changed
|
||||
uint32_t generationCount = 0;
|
||||
YGDirection lastOwnerDirection = (YGDirection) -1;
|
||||
|
||||
uint32_t nextCachedMeasurementsIndex = 0;
|
||||
std::array<YGCachedMeasurement, YG_MAX_CACHED_RESULT_COUNT>
|
||||
cachedMeasurements = {};
|
||||
std::array<float, 2> measuredDimensions = {{YGUndefined, YGUndefined}};
|
||||
|
||||
YGCachedMeasurement cachedLayout = YGCachedMeasurement();
|
||||
|
||||
YGDirection direction() const { return flags_.at<directionIdx>(); }
|
||||
decltype(flags_)::Ref<directionIdx> direction() {
|
||||
return flags_.at<directionIdx>();
|
||||
}
|
||||
|
||||
bool didUseLegacyFlag() const { return flags_.at<didUseLegacyFlagIdx>(); }
|
||||
decltype(flags_)::Ref<didUseLegacyFlagIdx> didUseLegacyFlag() {
|
||||
return flags_.at<didUseLegacyFlagIdx>();
|
||||
}
|
||||
|
||||
bool doesLegacyStretchFlagAffectsLayout() const {
|
||||
return flags_.at<doesLegacyStretchFlagAffectsLayoutIdx>();
|
||||
}
|
||||
decltype(flags_)::Ref<doesLegacyStretchFlagAffectsLayoutIdx>
|
||||
doesLegacyStretchFlagAffectsLayout() {
|
||||
return flags_.at<doesLegacyStretchFlagAffectsLayoutIdx>();
|
||||
}
|
||||
|
||||
bool hadOverflow() const { return flags_.at<hadOverflowIdx>(); }
|
||||
decltype(flags_)::Ref<hadOverflowIdx> hadOverflow() {
|
||||
return flags_.at<hadOverflowIdx>();
|
||||
}
|
||||
|
||||
bool operator==(YGLayout layout) const;
|
||||
bool operator!=(YGLayout layout) const { return !(*this == layout); }
|
||||
};
|
||||
@ -15,14 +15,7 @@ using facebook::yoga::detail::CompactValue;
|
||||
|
||||
YGNode::YGNode(YGNode&& node) {
|
||||
context_ = node.context_;
|
||||
hasNewLayout_ = node.hasNewLayout_;
|
||||
isReferenceBaseline_ = node.isReferenceBaseline_;
|
||||
isDirty_ = node.isDirty_;
|
||||
nodeType_ = node.nodeType_;
|
||||
measureUsesContext_ = node.measureUsesContext_;
|
||||
baselineUsesContext_ = node.baselineUsesContext_;
|
||||
printUsesContext_ = node.printUsesContext_;
|
||||
useWebDefaults_ = node.useWebDefaults_;
|
||||
flags_ = node.flags_;
|
||||
measure_ = node.measure_;
|
||||
baseline_ = node.baseline_;
|
||||
print_ = node.print_;
|
||||
@ -48,7 +41,7 @@ YGNode::YGNode(const YGNode& node, YGConfigRef config) : YGNode{node} {
|
||||
|
||||
void YGNode::print(void* printContext) {
|
||||
if (print_.noContext != nullptr) {
|
||||
if (printUsesContext_) {
|
||||
if (flags_.at<printUsesContext_>()) {
|
||||
print_.withContext(this, printContext);
|
||||
} else {
|
||||
print_.noContext(this);
|
||||
@ -154,14 +147,14 @@ YGSize YGNode::measure(
|
||||
YGMeasureMode heightMode,
|
||||
void* layoutContext) {
|
||||
|
||||
return measureUsesContext_
|
||||
return flags_.at<measureUsesContext_>()
|
||||
? measure_.withContext(
|
||||
this, width, widthMode, height, heightMode, layoutContext)
|
||||
: measure_.noContext(this, width, widthMode, height, heightMode);
|
||||
}
|
||||
|
||||
float YGNode::baseline(float width, float height, void* layoutContext) {
|
||||
return baselineUsesContext_
|
||||
return flags_.at<baselineUsesContext_>()
|
||||
? baseline_.withContext(this, width, height, layoutContext)
|
||||
: baseline_.noContext(this, width, height);
|
||||
}
|
||||
@ -172,7 +165,7 @@ void YGNode::setMeasureFunc(decltype(YGNode::measure_) measureFunc) {
|
||||
if (measureFunc.noContext == nullptr) {
|
||||
// TODO: t18095186 Move nodeType to opt-in function and mark appropriate
|
||||
// places in Litho
|
||||
nodeType_ = YGNodeTypeDefault;
|
||||
flags_.at<nodeType_>() = YGNodeTypeDefault;
|
||||
} else {
|
||||
YGAssertWithNode(
|
||||
this,
|
||||
@ -188,14 +181,14 @@ void YGNode::setMeasureFunc(decltype(YGNode::measure_) measureFunc) {
|
||||
}
|
||||
|
||||
void YGNode::setMeasureFunc(YGMeasureFunc measureFunc) {
|
||||
measureUsesContext_ = false;
|
||||
flags_.at<measureUsesContext_>() = false;
|
||||
decltype(YGNode::measure_) m;
|
||||
m.noContext = measureFunc;
|
||||
setMeasureFunc(m);
|
||||
}
|
||||
|
||||
void YGNode::setMeasureFunc(MeasureWithContextFn measureFunc) {
|
||||
measureUsesContext_ = true;
|
||||
flags_.at<measureUsesContext_>() = true;
|
||||
decltype(YGNode::measure_) m;
|
||||
m.withContext = measureFunc;
|
||||
setMeasureFunc(m);
|
||||
@ -214,10 +207,10 @@ void YGNode::insertChild(YGNodeRef child, uint32_t index) {
|
||||
}
|
||||
|
||||
void YGNode::setDirty(bool isDirty) {
|
||||
if (isDirty == isDirty_) {
|
||||
if (isDirty == flags_.at<isDirty_>()) {
|
||||
return;
|
||||
}
|
||||
isDirty_ = isDirty;
|
||||
flags_.at<isDirty_>() = isDirty;
|
||||
if (isDirty && dirtied_) {
|
||||
dirtied_(this);
|
||||
}
|
||||
@ -238,7 +231,7 @@ void YGNode::removeChild(uint32_t index) {
|
||||
}
|
||||
|
||||
void YGNode::setLayoutDirection(YGDirection direction) {
|
||||
layout_.direction = direction;
|
||||
layout_.direction() = direction;
|
||||
}
|
||||
|
||||
void YGNode::setLayoutMargin(float margin, int index) {
|
||||
@ -276,7 +269,7 @@ void YGNode::setLayoutMeasuredDimension(float measuredDimension, int index) {
|
||||
}
|
||||
|
||||
void YGNode::setLayoutHadOverflow(bool hadOverflow) {
|
||||
layout_.hadOverflow = hadOverflow;
|
||||
layout_.hadOverflow() = hadOverflow;
|
||||
}
|
||||
|
||||
void YGNode::setLayoutDimension(float dimension, int index) {
|
||||
@ -357,7 +350,7 @@ YGValue YGNode::resolveFlexBasisPtr() const {
|
||||
return flexBasis;
|
||||
}
|
||||
if (!style_.flex().isUndefined() && style_.flex().unwrap() > 0.0f) {
|
||||
return useWebDefaults_ ? YGValueAuto : YGValueZero;
|
||||
return flags_.at<useWebDefaults_>() ? YGValueAuto : YGValueZero;
|
||||
}
|
||||
return YGValueAuto;
|
||||
}
|
||||
@ -396,7 +389,7 @@ void YGNode::cloneChildrenIfNeeded(void* cloneContext) {
|
||||
}
|
||||
|
||||
void YGNode::markDirtyAndPropogate() {
|
||||
if (!isDirty_) {
|
||||
if (!flags_.at<isDirty_>()) {
|
||||
setDirty(true);
|
||||
setLayoutComputedFlexBasis(YGFloatOptional());
|
||||
if (owner_) {
|
||||
@ -406,7 +399,7 @@ void YGNode::markDirtyAndPropogate() {
|
||||
}
|
||||
|
||||
void YGNode::markDirtyAndPropogateDownwards() {
|
||||
isDirty_ = true;
|
||||
flags_.at<isDirty_>() = true;
|
||||
for_each(children_.begin(), children_.end(), [](YGNodeRef childNode) {
|
||||
childNode->markDirtyAndPropogateDownwards();
|
||||
});
|
||||
@ -433,11 +426,12 @@ float YGNode::resolveFlexShrink() const {
|
||||
if (!style_.flexShrink().isUndefined()) {
|
||||
return style_.flexShrink().unwrap();
|
||||
}
|
||||
if (!useWebDefaults_ && !style_.flex().isUndefined() &&
|
||||
if (!flags_.at<useWebDefaults_>() && !style_.flex().isUndefined() &&
|
||||
style_.flex().unwrap() < 0.0f) {
|
||||
return -style_.flex().unwrap();
|
||||
}
|
||||
return useWebDefaults_ ? kWebDefaultFlexShrink : kDefaultFlexShrink;
|
||||
return flags_.at<useWebDefaults_>() ? kWebDefaultFlexShrink
|
||||
: kDefaultFlexShrink;
|
||||
}
|
||||
|
||||
bool YGNode::isNodeFlexible() {
|
||||
@ -526,12 +520,12 @@ YGFloatOptional YGNode::getTrailingPaddingAndBorder(
|
||||
}
|
||||
|
||||
bool YGNode::didUseLegacyFlag() {
|
||||
bool didUseLegacyFlag = layout_.didUseLegacyFlag;
|
||||
bool didUseLegacyFlag = layout_.didUseLegacyFlag();
|
||||
if (didUseLegacyFlag) {
|
||||
return true;
|
||||
}
|
||||
for (const auto& child : children_) {
|
||||
if (child->layout_.didUseLegacyFlag) {
|
||||
if (child->layout_.didUseLegacyFlag()) {
|
||||
didUseLegacyFlag = true;
|
||||
break;
|
||||
}
|
||||
@ -541,11 +535,11 @@ bool YGNode::didUseLegacyFlag() {
|
||||
|
||||
void YGNode::setLayoutDoesLegacyFlagAffectsLayout(
|
||||
bool doesLegacyFlagAffectsLayout) {
|
||||
layout_.doesLegacyStretchFlagAffectsLayout = doesLegacyFlagAffectsLayout;
|
||||
layout_.doesLegacyStretchFlagAffectsLayout() = doesLegacyFlagAffectsLayout;
|
||||
}
|
||||
|
||||
void YGNode::setLayoutDidUseLegacyFlag(bool didUseLegacyFlag) {
|
||||
layout_.didUseLegacyFlag = didUseLegacyFlag;
|
||||
layout_.didUseLegacyFlag() = didUseLegacyFlag;
|
||||
}
|
||||
|
||||
bool YGNode::isLayoutTreeEqualToNode(const YGNode& node) const {
|
||||
@ -582,7 +576,7 @@ void YGNode::reset() {
|
||||
|
||||
clearChildren();
|
||||
|
||||
auto webDefaults = useWebDefaults_;
|
||||
auto webDefaults = flags_.at<useWebDefaults_>();
|
||||
*this = YGNode{getConfig()};
|
||||
if (webDefaults) {
|
||||
useWebDefaults();
|
||||
@ -7,6 +7,7 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <stdio.h>
|
||||
#include "Bitfield.h"
|
||||
#include "CompactValue.h"
|
||||
#include "YGConfig.h"
|
||||
#include "YGLayout.h"
|
||||
@ -23,15 +24,20 @@ struct YGNode {
|
||||
using PrintWithContextFn = void (*)(YGNode*, void*);
|
||||
|
||||
private:
|
||||
static constexpr size_t hasNewLayout_ = 0;
|
||||
static constexpr size_t isReferenceBaseline_ = 1;
|
||||
static constexpr size_t isDirty_ = 2;
|
||||
static constexpr size_t nodeType_ = 3;
|
||||
static constexpr size_t measureUsesContext_ = 4;
|
||||
static constexpr size_t baselineUsesContext_ = 5;
|
||||
static constexpr size_t printUsesContext_ = 6;
|
||||
static constexpr size_t useWebDefaults_ = 7;
|
||||
|
||||
void* context_ = nullptr;
|
||||
bool hasNewLayout_ : 1;
|
||||
bool isReferenceBaseline_ : 1;
|
||||
bool isDirty_ : 1;
|
||||
YGNodeType nodeType_ : 1;
|
||||
bool measureUsesContext_ : 1;
|
||||
bool baselineUsesContext_ : 1;
|
||||
bool printUsesContext_ : 1;
|
||||
bool useWebDefaults_ : 1;
|
||||
using Flags = facebook::yoga::
|
||||
Bitfield<uint8_t, bool, bool, bool, YGNodeType, bool, bool, bool, bool>;
|
||||
Flags flags_ =
|
||||
{true, false, false, YGNodeTypeDefault, false, false, false, false};
|
||||
uint8_t reserved_ = 0;
|
||||
union {
|
||||
YGMeasureFunc noContext;
|
||||
@ -63,7 +69,7 @@ private:
|
||||
void setBaselineFunc(decltype(baseline_));
|
||||
|
||||
void useWebDefaults() {
|
||||
useWebDefaults_ = true;
|
||||
flags_.at<useWebDefaults_>() = true;
|
||||
style_.flexDirection() = YGFlexDirectionRow;
|
||||
style_.alignContent() = YGAlignStretch;
|
||||
}
|
||||
@ -79,17 +85,8 @@ private:
|
||||
|
||||
public:
|
||||
YGNode() : YGNode{YGConfigGetDefault()} {}
|
||||
explicit YGNode(const YGConfigRef config)
|
||||
: hasNewLayout_{true},
|
||||
isReferenceBaseline_{false},
|
||||
isDirty_{false},
|
||||
nodeType_{YGNodeTypeDefault},
|
||||
measureUsesContext_{false},
|
||||
baselineUsesContext_{false},
|
||||
printUsesContext_{false},
|
||||
useWebDefaults_{config->useWebDefaults},
|
||||
config_{config} {
|
||||
if (useWebDefaults_) {
|
||||
explicit YGNode(const YGConfigRef config) : config_{config} {
|
||||
if (config->useWebDefaults) {
|
||||
useWebDefaults();
|
||||
}
|
||||
};
|
||||
@ -116,9 +113,9 @@ public:
|
||||
|
||||
void print(void*);
|
||||
|
||||
bool getHasNewLayout() const { return hasNewLayout_; }
|
||||
bool getHasNewLayout() const { return flags_.at<hasNewLayout_>(); }
|
||||
|
||||
YGNodeType getNodeType() const { return nodeType_; }
|
||||
YGNodeType getNodeType() const { return flags_.at<nodeType_>(); }
|
||||
|
||||
bool hasMeasureFunc() const noexcept { return measure_.noContext != nullptr; }
|
||||
|
||||
@ -144,7 +141,7 @@ public:
|
||||
|
||||
uint32_t getLineIndex() const { return lineIndex_; }
|
||||
|
||||
bool isReferenceBaseline() { return isReferenceBaseline_; }
|
||||
bool isReferenceBaseline() { return flags_.at<isReferenceBaseline_>(); }
|
||||
|
||||
// returns the YGNodeRef that owns this YGNode. An owner is used to identify
|
||||
// the YogaTree that a YGNode belongs to. This method will return the parent
|
||||
@ -177,7 +174,7 @@ public:
|
||||
|
||||
YGConfigRef getConfig() const { return config_; }
|
||||
|
||||
bool isDirty() const { return isDirty_; }
|
||||
bool isDirty() const { return flags_.at<isDirty_>(); }
|
||||
|
||||
std::array<YGValue, 2> getResolvedDimensions() const {
|
||||
return resolvedDimensions_;
|
||||
@ -225,17 +222,19 @@ public:
|
||||
|
||||
void setPrintFunc(YGPrintFunc printFunc) {
|
||||
print_.noContext = printFunc;
|
||||
printUsesContext_ = false;
|
||||
flags_.at<printUsesContext_>() = false;
|
||||
}
|
||||
void setPrintFunc(PrintWithContextFn printFunc) {
|
||||
print_.withContext = printFunc;
|
||||
printUsesContext_ = true;
|
||||
flags_.at<printUsesContext_>() = true;
|
||||
}
|
||||
void setPrintFunc(std::nullptr_t) { setPrintFunc(YGPrintFunc{nullptr}); }
|
||||
|
||||
void setHasNewLayout(bool hasNewLayout) { hasNewLayout_ = hasNewLayout; }
|
||||
void setHasNewLayout(bool hasNewLayout) {
|
||||
flags_.at<hasNewLayout_>() = hasNewLayout;
|
||||
}
|
||||
|
||||
void setNodeType(YGNodeType nodeType) { nodeType_ = nodeType; }
|
||||
void setNodeType(YGNodeType nodeType) { flags_.at<nodeType_>() = nodeType; }
|
||||
|
||||
void setMeasureFunc(YGMeasureFunc measureFunc);
|
||||
void setMeasureFunc(MeasureWithContextFn);
|
||||
@ -244,11 +243,11 @@ public:
|
||||
}
|
||||
|
||||
void setBaselineFunc(YGBaselineFunc baseLineFunc) {
|
||||
baselineUsesContext_ = false;
|
||||
flags_.at<baselineUsesContext_>() = false;
|
||||
baseline_.noContext = baseLineFunc;
|
||||
}
|
||||
void setBaselineFunc(BaselineWithContextFn baseLineFunc) {
|
||||
baselineUsesContext_ = true;
|
||||
flags_.at<baselineUsesContext_>() = true;
|
||||
baseline_.withContext = baseLineFunc;
|
||||
}
|
||||
void setBaselineFunc(std::nullptr_t) {
|
||||
@ -264,7 +263,7 @@ public:
|
||||
void setLineIndex(uint32_t lineIndex) { lineIndex_ = lineIndex; }
|
||||
|
||||
void setIsReferenceBaseline(bool isReferenceBaseline) {
|
||||
isReferenceBaseline_ = isReferenceBaseline;
|
||||
flags_.at<isReferenceBaseline_>() = isReferenceBaseline;
|
||||
}
|
||||
|
||||
void setOwner(YGNodeRef owner) { owner_ = owner; }
|
||||
202
src/cpp/deps/yoga/YGStyle.h
Normal file
202
src/cpp/deps/yoga/YGStyle.h
Normal file
@ -0,0 +1,202 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
#pragma once
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <type_traits>
|
||||
#include "Bitfield.h"
|
||||
#include "CompactValue.h"
|
||||
#include "YGEnums.h"
|
||||
#include "YGFloatOptional.h"
|
||||
#include "Yoga-internal.h"
|
||||
#include "Yoga.h"
|
||||
|
||||
class YGStyle {
|
||||
template <typename Enum>
|
||||
using Values =
|
||||
facebook::yoga::detail::Values<facebook::yoga::enums::count<Enum>()>;
|
||||
using CompactValue = facebook::yoga::detail::CompactValue;
|
||||
|
||||
public:
|
||||
using Dimensions = Values<YGDimension>;
|
||||
using Edges = Values<YGEdge>;
|
||||
|
||||
template <typename T, T YGStyle::*Prop>
|
||||
struct Ref {
|
||||
YGStyle& style;
|
||||
operator T() const { return style.*Prop; }
|
||||
Ref<T, Prop>& operator=(T value) {
|
||||
style.*Prop = value;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Idx, Values<Idx> YGStyle::*Prop>
|
||||
struct IdxRef {
|
||||
struct Ref {
|
||||
YGStyle& style;
|
||||
Idx idx;
|
||||
operator CompactValue() const { return (style.*Prop)[idx]; }
|
||||
operator YGValue() const { return (style.*Prop)[idx]; }
|
||||
Ref& operator=(CompactValue value) {
|
||||
(style.*Prop)[idx] = value;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
YGStyle& style;
|
||||
IdxRef<Idx, Prop>& operator=(const Values<Idx>& values) {
|
||||
style.*Prop = values;
|
||||
return *this;
|
||||
}
|
||||
operator const Values<Idx>&() const { return style.*Prop; }
|
||||
Ref operator[](Idx idx) { return {style, idx}; }
|
||||
CompactValue operator[](Idx idx) const { return (style.*Prop)[idx]; }
|
||||
};
|
||||
|
||||
YGStyle() = default;
|
||||
~YGStyle() = default;
|
||||
|
||||
private:
|
||||
static constexpr size_t directionIdx = 0;
|
||||
static constexpr size_t flexDirectionIdx = 1;
|
||||
static constexpr size_t justifyContentIdx = 2;
|
||||
static constexpr size_t alignContentIdx = 3;
|
||||
static constexpr size_t alignItemsIdx = 4;
|
||||
static constexpr size_t alignSelfIdx = 5;
|
||||
static constexpr size_t positionTypeIdx = 6;
|
||||
static constexpr size_t flexWrapIdx = 7;
|
||||
static constexpr size_t overflowIdx = 8;
|
||||
static constexpr size_t displayIdx = 9;
|
||||
using Flags = facebook::yoga::Bitfield<
|
||||
uint32_t,
|
||||
YGDirection,
|
||||
YGFlexDirection,
|
||||
YGJustify,
|
||||
YGAlign,
|
||||
YGAlign,
|
||||
YGAlign,
|
||||
YGPositionType,
|
||||
YGWrap,
|
||||
YGOverflow,
|
||||
YGDisplay>;
|
||||
|
||||
Flags flags_ = {YGDirectionInherit,
|
||||
YGFlexDirectionColumn,
|
||||
YGJustifyFlexStart,
|
||||
YGAlignFlexStart,
|
||||
YGAlignStretch,
|
||||
YGAlignAuto,
|
||||
YGPositionTypeRelative,
|
||||
YGWrapNoWrap,
|
||||
YGOverflowVisible,
|
||||
YGDisplayFlex};
|
||||
YGFloatOptional flex_ = {};
|
||||
YGFloatOptional flexGrow_ = {};
|
||||
YGFloatOptional flexShrink_ = {};
|
||||
CompactValue flexBasis_ = CompactValue::ofAuto();
|
||||
Edges margin_ = {};
|
||||
Edges position_ = {};
|
||||
Edges padding_ = {};
|
||||
Edges border_ = {};
|
||||
Dimensions dimensions_{CompactValue::ofAuto()};
|
||||
Dimensions minDimensions_ = {};
|
||||
Dimensions maxDimensions_ = {};
|
||||
// Yoga specific properties, not compatible with flexbox specification
|
||||
YGFloatOptional aspectRatio_ = {};
|
||||
|
||||
public:
|
||||
// for library users needing a type
|
||||
using ValueRepr = std::remove_reference<decltype(margin_[0])>::type;
|
||||
|
||||
YGDirection direction() const { return flags_.at<directionIdx>(); }
|
||||
Flags::Ref<directionIdx> direction() { return flags_.at<directionIdx>(); }
|
||||
|
||||
YGFlexDirection flexDirection() const {
|
||||
return flags_.at<flexDirectionIdx>();
|
||||
}
|
||||
Flags::Ref<flexDirectionIdx> flexDirection() {
|
||||
return flags_.at<flexDirectionIdx>();
|
||||
}
|
||||
|
||||
YGJustify justifyContent() const { return flags_.at<justifyContentIdx>(); }
|
||||
Flags::Ref<justifyContentIdx> justifyContent() {
|
||||
return flags_.at<justifyContentIdx>();
|
||||
}
|
||||
|
||||
YGAlign alignContent() const { return flags_.at<alignContentIdx>(); }
|
||||
Flags::Ref<alignContentIdx> alignContent() {
|
||||
return flags_.at<alignContentIdx>();
|
||||
}
|
||||
|
||||
YGAlign alignItems() const { return flags_.at<alignItemsIdx>(); }
|
||||
Flags::Ref<alignItemsIdx> alignItems() { return flags_.at<alignItemsIdx>(); }
|
||||
|
||||
YGAlign alignSelf() const { return flags_.at<alignSelfIdx>(); }
|
||||
Flags::Ref<alignSelfIdx> alignSelf() { return flags_.at<alignSelfIdx>(); }
|
||||
|
||||
YGPositionType positionType() const { return flags_.at<positionTypeIdx>(); }
|
||||
Flags::Ref<positionTypeIdx> positionType() {
|
||||
return flags_.at<positionTypeIdx>();
|
||||
}
|
||||
|
||||
YGWrap flexWrap() const { return flags_.at<flexWrapIdx>(); }
|
||||
Flags::Ref<flexWrapIdx> flexWrap() { return flags_.at<flexWrapIdx>(); }
|
||||
|
||||
YGOverflow overflow() const { return flags_.at<overflowIdx>(); }
|
||||
Flags::Ref<overflowIdx> overflow() { return flags_.at<overflowIdx>(); }
|
||||
|
||||
YGDisplay display() const { return flags_.at<displayIdx>(); }
|
||||
Flags::Ref<displayIdx> display() { return flags_.at<displayIdx>(); }
|
||||
|
||||
YGFloatOptional flex() const { return flex_; }
|
||||
Ref<YGFloatOptional, &YGStyle::flex_> flex() { return {*this}; }
|
||||
|
||||
YGFloatOptional flexGrow() const { return flexGrow_; }
|
||||
Ref<YGFloatOptional, &YGStyle::flexGrow_> flexGrow() { return {*this}; }
|
||||
|
||||
YGFloatOptional flexShrink() const { return flexShrink_; }
|
||||
Ref<YGFloatOptional, &YGStyle::flexShrink_> flexShrink() { return {*this}; }
|
||||
|
||||
CompactValue flexBasis() const { return flexBasis_; }
|
||||
Ref<CompactValue, &YGStyle::flexBasis_> flexBasis() { return {*this}; }
|
||||
|
||||
const Edges& margin() const { return margin_; }
|
||||
IdxRef<YGEdge, &YGStyle::margin_> margin() { return {*this}; }
|
||||
|
||||
const Edges& position() const { return position_; }
|
||||
IdxRef<YGEdge, &YGStyle::position_> position() { return {*this}; }
|
||||
|
||||
const Edges& padding() const { return padding_; }
|
||||
IdxRef<YGEdge, &YGStyle::padding_> padding() { return {*this}; }
|
||||
|
||||
const Edges& border() const { return border_; }
|
||||
IdxRef<YGEdge, &YGStyle::border_> border() { return {*this}; }
|
||||
|
||||
const Dimensions& dimensions() const { return dimensions_; }
|
||||
IdxRef<YGDimension, &YGStyle::dimensions_> dimensions() { return {*this}; }
|
||||
|
||||
const Dimensions& minDimensions() const { return minDimensions_; }
|
||||
IdxRef<YGDimension, &YGStyle::minDimensions_> minDimensions() {
|
||||
return {*this};
|
||||
}
|
||||
|
||||
const Dimensions& maxDimensions() const { return maxDimensions_; }
|
||||
IdxRef<YGDimension, &YGStyle::maxDimensions_> maxDimensions() {
|
||||
return {*this};
|
||||
}
|
||||
|
||||
// Yoga specific properties, not compatible with flexbox specification
|
||||
YGFloatOptional aspectRatio() const { return aspectRatio_; }
|
||||
Ref<YGFloatOptional, &YGStyle::aspectRatio_> aspectRatio() { return {*this}; }
|
||||
};
|
||||
|
||||
bool operator==(const YGStyle& lhs, const YGStyle& rhs);
|
||||
inline bool operator!=(const YGStyle& lhs, const YGStyle& rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
@ -15,7 +15,6 @@
|
||||
#include "YGNodePrint.h"
|
||||
#include "Yoga-internal.h"
|
||||
#include "event/event.h"
|
||||
#include "internal/experiments-inl.h"
|
||||
#ifdef _MSC_VER
|
||||
#include <float.h>
|
||||
|
||||
@ -892,7 +891,7 @@ YGValue YGNodeStyleGetMaxHeight(const YGNodeConstRef node) {
|
||||
"Cannot get layout properties of multi-edge shorthands"); \
|
||||
\
|
||||
if (edge == YGEdgeStart) { \
|
||||
if (node->getLayout().direction == YGDirectionRTL) { \
|
||||
if (node->getLayout().direction() == YGDirectionRTL) { \
|
||||
return node->getLayout().instanceName[YGEdgeRight]; \
|
||||
} else { \
|
||||
return node->getLayout().instanceName[YGEdgeLeft]; \
|
||||
@ -900,7 +899,7 @@ YGValue YGNodeStyleGetMaxHeight(const YGNodeConstRef node) {
|
||||
} \
|
||||
\
|
||||
if (edge == YGEdgeEnd) { \
|
||||
if (node->getLayout().direction == YGDirectionRTL) { \
|
||||
if (node->getLayout().direction() == YGDirectionRTL) { \
|
||||
return node->getLayout().instanceName[YGEdgeLeft]; \
|
||||
} else { \
|
||||
return node->getLayout().instanceName[YGEdgeRight]; \
|
||||
@ -916,15 +915,15 @@ YG_NODE_LAYOUT_PROPERTY_IMPL(float, Right, position[YGEdgeRight]);
|
||||
YG_NODE_LAYOUT_PROPERTY_IMPL(float, Bottom, position[YGEdgeBottom]);
|
||||
YG_NODE_LAYOUT_PROPERTY_IMPL(float, Width, dimensions[YGDimensionWidth]);
|
||||
YG_NODE_LAYOUT_PROPERTY_IMPL(float, Height, dimensions[YGDimensionHeight]);
|
||||
YG_NODE_LAYOUT_PROPERTY_IMPL(YGDirection, Direction, direction);
|
||||
YG_NODE_LAYOUT_PROPERTY_IMPL(bool, HadOverflow, hadOverflow);
|
||||
YG_NODE_LAYOUT_PROPERTY_IMPL(YGDirection, Direction, direction());
|
||||
YG_NODE_LAYOUT_PROPERTY_IMPL(bool, HadOverflow, hadOverflow());
|
||||
|
||||
YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Margin, margin);
|
||||
YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Border, border);
|
||||
YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Padding, padding);
|
||||
|
||||
bool YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(const YGNodeRef node) {
|
||||
return node->getLayout().doesLegacyStretchFlagAffectsLayout;
|
||||
return node->getLayout().doesLegacyStretchFlagAffectsLayout();
|
||||
}
|
||||
|
||||
uint32_t gCurrentGenerationCount = 0;
|
||||
@ -1645,6 +1644,8 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(
|
||||
layoutContext);
|
||||
|
||||
layoutMarkerData.measureCallbacks += 1;
|
||||
layoutMarkerData.measureCallbackReasonsCount[static_cast<size_t>(reason)] +=
|
||||
1;
|
||||
|
||||
Event::publish<Event::MeasureCallbackEnd>(
|
||||
node,
|
||||
@ -1657,15 +1658,6 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(
|
||||
measuredSize.height,
|
||||
reason});
|
||||
|
||||
if (internal::isEnabled(internal::Experiment::kDoubleMeasureCallbacks)) {
|
||||
node->measure(
|
||||
innerWidth,
|
||||
widthMeasureMode,
|
||||
innerHeight,
|
||||
heightMeasureMode,
|
||||
layoutContext);
|
||||
}
|
||||
|
||||
node->setLayoutMeasuredDimension(
|
||||
YGNodeBoundAxis(
|
||||
node,
|
||||
@ -1853,7 +1845,7 @@ static float YGNodeComputeFlexBasisForChildren(
|
||||
const uint32_t generationCount) {
|
||||
float totalOuterFlexBasis = 0.0f;
|
||||
YGNodeRef singleFlexChild = nullptr;
|
||||
YGVector children = node->getChildren();
|
||||
const YGVector &children = node->getChildren();
|
||||
YGMeasureMode measureModeMainDim =
|
||||
YGFlexDirectionIsRow(mainAxis) ? widthMeasureMode : heightMeasureMode;
|
||||
// If there is only one child with flexGrow + flexShrink it means we can set
|
||||
@ -2185,27 +2177,29 @@ static float YGDistributeFreeSpaceSecondPass(
|
||||
const YGMeasureMode childHeightMeasureMode =
|
||||
!isMainAxisRow ? childMainMeasureMode : childCrossMeasureMode;
|
||||
|
||||
const bool isLayoutPass = performLayout && !requiresStretchLayout;
|
||||
// Recursively call the layout algorithm for this child with the updated
|
||||
// main size.
|
||||
YGLayoutNodeInternal(
|
||||
currentRelativeChild,
|
||||
childWidth,
|
||||
childHeight,
|
||||
node->getLayout().direction,
|
||||
node->getLayout().direction(),
|
||||
childWidthMeasureMode,
|
||||
childHeightMeasureMode,
|
||||
availableInnerWidth,
|
||||
availableInnerHeight,
|
||||
performLayout && !requiresStretchLayout,
|
||||
LayoutPassReason::kFlex,
|
||||
isLayoutPass,
|
||||
isLayoutPass ? LayoutPassReason::kFlexLayout
|
||||
: LayoutPassReason::kFlexMeasure,
|
||||
config,
|
||||
layoutMarkerData,
|
||||
layoutContext,
|
||||
depth,
|
||||
generationCount);
|
||||
node->setLayoutHadOverflow(
|
||||
node->getLayout().hadOverflow |
|
||||
currentRelativeChild->getLayout().hadOverflow);
|
||||
node->getLayout().hadOverflow() |
|
||||
currentRelativeChild->getLayout().hadOverflow());
|
||||
}
|
||||
return deltaFreeSpace;
|
||||
}
|
||||
@ -2964,7 +2958,7 @@ static void YGNodelayoutImpl(
|
||||
}
|
||||
|
||||
node->setLayoutHadOverflow(
|
||||
node->getLayout().hadOverflow |
|
||||
node->getLayout().hadOverflow() |
|
||||
(collectedFlexItemsValues.remainingFreeSpace < 0));
|
||||
|
||||
// STEP 6: MAIN-AXIS JUSTIFICATION & CROSS-AXIS SIZE DETERMINATION
|
||||
@ -4143,7 +4137,7 @@ void YGNodeCalculateLayoutWithContext(
|
||||
0, // tree root
|
||||
gCurrentGenerationCount)) {
|
||||
node->setPosition(
|
||||
node->getLayout().direction, ownerWidth, ownerHeight, ownerWidth);
|
||||
node->getLayout().direction(), ownerWidth, ownerHeight, ownerWidth);
|
||||
YGRoundToPixelGrid(node, node->getConfig()->pointScaleFactor, 0.0f, 0.0f);
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -4193,7 +4187,7 @@ void YGNodeCalculateLayoutWithContext(
|
||||
0, // tree root
|
||||
gCurrentGenerationCount)) {
|
||||
nodeWithoutLegacyFlag->setPosition(
|
||||
nodeWithoutLegacyFlag->getLayout().direction,
|
||||
nodeWithoutLegacyFlag->getLayout().direction(),
|
||||
ownerWidth,
|
||||
ownerHeight,
|
||||
ownerWidth);
|
||||
@ -16,18 +16,20 @@ const char* LayoutPassReasonToString(const LayoutPassReason value) {
|
||||
switch (value) {
|
||||
case LayoutPassReason::kInitial:
|
||||
return "initial";
|
||||
case LayoutPassReason::kMeasureChild:
|
||||
return "measure";
|
||||
case LayoutPassReason::kAbsMeasureChild:
|
||||
return "abs_measure";
|
||||
case LayoutPassReason::kFlex:
|
||||
return "flex";
|
||||
case LayoutPassReason::kAbsLayout:
|
||||
return "abs_layout";
|
||||
case LayoutPassReason::kStretch:
|
||||
return "stretch";
|
||||
case LayoutPassReason::kMultilineStretch:
|
||||
return "multiline_stretch";
|
||||
case LayoutPassReason::kFlexLayout:
|
||||
return "flex_layout";
|
||||
case LayoutPassReason::kMeasureChild:
|
||||
return "measure";
|
||||
case LayoutPassReason::kAbsMeasureChild:
|
||||
return "abs_measure";
|
||||
case LayoutPassReason::kFlexMeasure:
|
||||
return "flex_measure";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
@ -8,6 +8,7 @@
|
||||
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include <yoga/YGEnums.h>
|
||||
|
||||
struct YGConfig;
|
||||
@ -23,6 +24,18 @@ enum struct LayoutType : int {
|
||||
kCachedMeasure = 3
|
||||
};
|
||||
|
||||
enum struct LayoutPassReason : int {
|
||||
kInitial = 0,
|
||||
kAbsLayout = 1,
|
||||
kStretch = 2,
|
||||
kMultilineStretch = 3,
|
||||
kFlexLayout = 4,
|
||||
kMeasureChild = 5,
|
||||
kAbsMeasureChild = 6,
|
||||
kFlexMeasure = 7,
|
||||
COUNT
|
||||
};
|
||||
|
||||
struct LayoutData {
|
||||
int layouts;
|
||||
int measures;
|
||||
@ -30,16 +43,8 @@ struct LayoutData {
|
||||
int cachedLayouts;
|
||||
int cachedMeasures;
|
||||
int measureCallbacks;
|
||||
};
|
||||
|
||||
enum struct LayoutPassReason : int {
|
||||
kInitial = 0,
|
||||
kMeasureChild = 1,
|
||||
kAbsMeasureChild = 2,
|
||||
kFlex = 3,
|
||||
kAbsLayout = 4,
|
||||
kStretch = 5,
|
||||
kMultilineStretch = 6
|
||||
std::array<int, static_cast<uint8_t>(LayoutPassReason::COUNT)>
|
||||
measureCallbackReasonsCount;
|
||||
};
|
||||
|
||||
const char* LayoutPassReasonToString(const LayoutPassReason value);
|
||||
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "src/cpp/core/FlexLayout/flexlayout.h"
|
||||
#include "core/FlexLayout/flexlayout.h"
|
||||
|
||||
namespace extrautils {
|
||||
YGSize measureQtWidget (YGNodeRef node, float width, YGMeasureMode widthMode, float height, YGMeasureMode heightMode);
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
#include <napi.h>
|
||||
#include <QClipboard>
|
||||
#include "src/cpp/core/Component/component_macro.h"
|
||||
#include "core/Component/component_macro.h"
|
||||
|
||||
class QClipboardWrap : public Napi::ObjectWrap<QClipboardWrap>
|
||||
{
|
||||
@ -3,7 +3,7 @@
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
#include <QCursor>
|
||||
#include "src/cpp/core/Component/component_macro.h"
|
||||
#include "core/Component/component_macro.h"
|
||||
|
||||
class QCursorWrap : public Napi::ObjectWrap<QCursorWrap>
|
||||
{
|
||||
@ -3,7 +3,7 @@
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
#include <QIcon>
|
||||
#include "src/cpp/core/Component/component_macro.h"
|
||||
#include "core/Component/component_macro.h"
|
||||
|
||||
class QIconWrap : public Napi::ObjectWrap<QIconWrap>
|
||||
{
|
||||
@ -3,7 +3,7 @@
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
#include <QPixmap>
|
||||
#include "src/cpp/core/Component/component_macro.h"
|
||||
#include "core/Component/component_macro.h"
|
||||
|
||||
class QPixmapWrap : public Napi::ObjectWrap<QPixmapWrap> {
|
||||
private:
|
||||
@ -1,7 +1,7 @@
|
||||
|
||||
#pragma once
|
||||
#include "src/cpp/QtWidgets/QWidget/qwidget_wrap.h"
|
||||
#include "src/cpp/QtWidgets/QWidget/qwidget_macro.h"
|
||||
#include "QtWidgets/QWidget/qwidget_wrap.h"
|
||||
#include "QtWidgets/QWidget/qwidget_macro.h"
|
||||
#include "deps/spdlog/spdlog.h"
|
||||
/*
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
|
||||
#pragma once
|
||||
#include "src/cpp/QtWidgets/QWidget/qwidget_wrap.h"
|
||||
#include "src/cpp/QtWidgets/QWidget/qwidget_macro.h"
|
||||
#include "QtWidgets/QWidget/qwidget_wrap.h"
|
||||
#include "QtWidgets/QWidget/qwidget_macro.h"
|
||||
#include "deps/spdlog/spdlog.h"
|
||||
/*
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <QCheckBox>
|
||||
#include "src/cpp/core/NodeWidget/nodewidget.h"
|
||||
#include "core/NodeWidget/nodewidget.h"
|
||||
#include "napi.h"
|
||||
|
||||
class NCheckBox: public QCheckBox, public NodeWidget
|
||||
@ -3,7 +3,7 @@
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
#include "ncheckbox.hpp"
|
||||
#include "src/cpp/QtWidgets/QWidget/qwidget_macro.h"
|
||||
#include "QtWidgets/QWidget/qwidget_macro.h"
|
||||
|
||||
|
||||
class QCheckBoxWrap : public Napi::ObjectWrap<QCheckBoxWrap>{
|
||||
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDial>
|
||||
#include "src/cpp/core/NodeWidget/nodewidget.h"
|
||||
#include "core/NodeWidget/nodewidget.h"
|
||||
|
||||
class NDial: public QDial, public NodeWidget
|
||||
{
|
||||
@ -4,8 +4,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdlib.h>
|
||||
#include "ndial.hpp"
|
||||
#include "src/cpp/QtWidgets/QWidget/qwidget_macro.h"
|
||||
#include "src/cpp/QtWidgets/QAbstractSlider/qabstractslider_macro.h"
|
||||
#include "QtWidgets/QWidget/qwidget_macro.h"
|
||||
#include "QtWidgets/QAbstractSlider/qabstractslider_macro.h"
|
||||
|
||||
class QDialWrap : public Napi::ObjectWrap<QDialWrap>{
|
||||
private:
|
||||
@ -3,7 +3,7 @@
|
||||
#include <napi.h>
|
||||
#include <stdlib.h>
|
||||
#include <QGridLayout>
|
||||
#include "src/cpp/QtWidgets/QLayout/qlayout_macro.h"
|
||||
#include "QtWidgets/QLayout/qlayout_macro.h"
|
||||
|
||||
class QGridLayoutWrap : public Napi::ObjectWrap<QGridLayoutWrap>{
|
||||
private:
|
||||
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <QLabel>
|
||||
#include "src/cpp/core/NodeWidget/nodewidget.h"
|
||||
#include "core/NodeWidget/nodewidget.h"
|
||||
|
||||
class NLabel: public QLabel, public NodeWidget
|
||||
{
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user