11#include "IGraphicsFlexBox.h"
14using namespace igraphics;
18 mConfigRef = YGConfigNew();
19 mRootNodeRef = YGNodeNewWithConfig(mConfigRef);
24 YGNodeFreeRecursive(mRootNodeRef);
25 YGConfigFree(mConfigRef);
28void IFlexBox::Init(
const IRECT& r, YGFlexDirection direction, YGJustify justify, YGWrap wrap,
float padding,
float margin)
30 YGNodeStyleSetWidth(mRootNodeRef, r.
W());
31 YGNodeStyleSetHeight(mRootNodeRef, r.
H());
32 YGNodeStyleSetFlexDirection(mRootNodeRef, direction);
33 YGNodeStyleSetJustifyContent(mRootNodeRef, justify);
34 YGNodeStyleSetFlexWrap(mRootNodeRef, wrap);
35 YGNodeStyleSetPadding(mRootNodeRef, YGEdgeAll, padding);
36 YGNodeStyleSetMargin(mRootNodeRef, YGEdgeAll, margin);
41 YGNodeCalculateLayout(mRootNodeRef, YGUndefined, YGUndefined, direction);
44YGNodeRef
IFlexBox::AddItem(
float width,
float height, YGAlign alignSelf,
float grow,
float shrink,
float margin)
46 int index = mNodeCounter;
47 YGNodeRef child = YGNodeNew();
49 if(width == YGUndefined)
50 YGNodeStyleSetWidthAuto(child);
52 YGNodeStyleSetWidthPercent(child, width * -1.f);
54 YGNodeStyleSetWidth(child, width);
56 if(height == YGUndefined)
57 YGNodeStyleSetHeightAuto(child);
59 YGNodeStyleSetHeightPercent(child, height * -1.f);
61 YGNodeStyleSetHeight(child, height);
63 YGNodeStyleSetAlignSelf(child, alignSelf);
64 YGNodeStyleSetMargin(child, YGEdgeAll, margin);
65 YGNodeStyleSetFlexGrow(child, grow);
66 YGNodeStyleSetFlexShrink(child, shrink);
67 YGNodeInsertChild(mRootNodeRef, child, index);
76 YGNodeInsertChild(mRootNodeRef, child, mNodeCounter++);
81 return IRECT(YGNodeLayoutGetLeft(mRootNodeRef),
82 YGNodeLayoutGetTop(mRootNodeRef),
83 YGNodeLayoutGetLeft(mRootNodeRef) + YGNodeLayoutGetWidth(mRootNodeRef),
84 YGNodeLayoutGetTop(mRootNodeRef) + YGNodeLayoutGetHeight(mRootNodeRef));
89 YGNodeRef child = YGNodeGetChild(mRootNodeRef, nodeIndex);
90 return IRECT(YGNodeLayoutGetLeft(mRootNodeRef) + YGNodeLayoutGetLeft(child),
91 YGNodeLayoutGetTop(mRootNodeRef) + YGNodeLayoutGetTop(child),
92 YGNodeLayoutGetLeft(mRootNodeRef) + YGNodeLayoutGetLeft(child) + YGNodeLayoutGetWidth(child),
93 YGNodeLayoutGetTop(mRootNodeRef) + YGNodeLayoutGetTop(child) + YGNodeLayoutGetHeight(child));
103#define Style YGInternalStyle
104#include <yoga/YGConfig.cpp>
105#include <yoga/YGEnums.cpp>
106#include <yoga/YGNode.cpp>
107#include <yoga/YGNodeLayout.cpp>
108#include <yoga/YGNodeStyle.cpp>
109#include <yoga/YGPixelGrid.cpp>
110#include <yoga/YGValue.cpp>
111#include <yoga/algorithm/AbsoluteLayout.cpp>
112#include <yoga/algorithm/Baseline.cpp>
113#include <yoga/algorithm/Cache.cpp>
114#include <yoga/algorithm/CalculateLayout.cpp>
115#include <yoga/algorithm/FlexLine.cpp>
116#include <yoga/algorithm/PixelGrid.cpp>
117#include <yoga/config/Config.cpp>
118#include <yoga/debug/AssertFatal.cpp>
119#include <yoga/debug/Log.cpp>
120#include <yoga/node/LayoutResults.cpp>
121#include <yoga/node/Node.cpp>
125#define Node YGEventSubscriberNode
126#include <yoga/event/event.cpp>
YGNodeRef AddItem(float width, float height, YGAlign alignSelf=YGAlignAuto, float grow=0.f, float shrink=1.f, float margin=0.f)
Add a flex item, with some parameters.
void CalcLayout(YGDirection direction=YGDirectionLTR)
Calculate the layout, call after add all items.
IRECT GetItemBounds(int nodeIndex) const
Get the bounds for a particular flex item.
void Init(const IRECT &r, YGFlexDirection direction=YGFlexDirectionRow, YGJustify justify=YGJustifyFlexStart, YGWrap wrap=YGWrapNoWrap, float padding=0.f, float margin=0.f)
Initialize the IFlexBox flex container.
IRECT GetRootBounds() const
Get an IRECT of the root node bounds.
Used to manage a rectangular area, independent of draw class/platform.