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));
98#include "YGLayout.cpp"
100#include "YGNodePrint.cpp"
101#include "YGValue.cpp"
102#include "YGConfig.cpp"
104#include "YGStyle.cpp"
108#include "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.