Skip to content

Commit

Permalink
fix + example
Browse files Browse the repository at this point in the history
  • Loading branch information
tripolskypetr committed Jul 3, 2019
1 parent fcbf828 commit d57e635
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 24 deletions.
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ int main(int argc, char *argv[]) {

QQmlApplicationEngine engine;
engine.load(QUrl(
QStringLiteral("qrc:/qml/main.qml"))
QStringLiteral("qrc:/qml/example.qml"))
);

return app.exec();
Expand Down
20 changes: 11 additions & 9 deletions objects/flex/flexnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ void FlexNode::setAlignContentSpaceBetween() {
YGNodeStyleSetAlignContent(node, YGAlignSpaceBetween);
}

/*---------------------------------------------------------------------------*/

void FlexNode::setAlignItemsAuto() {
YGNodeStyleSetAlignItems(node, YGAlignAuto);
}
Expand All @@ -244,7 +246,7 @@ void FlexNode::setAlignItemsCenter() {
/*---------------------------------------------------------------------------*/

void FlexNode::setAlignItemsFlexEnd() {
YGNodeStyleSetAlignItems(node, YGAlignCenter);
YGNodeStyleSetAlignItems(node, YGAlignFlexEnd);
}

/*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -280,49 +282,49 @@ void FlexNode::setAlignItemsSpaceBetween() {
/*---------------------------------------------------------------------------*/

void FlexNode::setAlignSelfAuto() {
YGNodeStyleSetAlignItems(node, YGAlignAuto);
YGNodeStyleSetAlignSelf(node, YGAlignAuto);
}

/*---------------------------------------------------------------------------*/

void FlexNode::setAlignSelfCenter() {
YGNodeStyleSetAlignItems(node, YGAlignCenter);
YGNodeStyleSetAlignSelf(node, YGAlignCenter);
}

/*---------------------------------------------------------------------------*/

void FlexNode::setAlignSelfFlexEnd() {
YGNodeStyleSetAlignItems(node, YGAlignFlexEnd);
YGNodeStyleSetAlignSelf(node, YGAlignFlexEnd);
}

/*---------------------------------------------------------------------------*/

void FlexNode::setAlignSelfStretch() {
YGNodeStyleSetAlignItems(node, YGAlignStretch);
YGNodeStyleSetAlignSelf(node, YGAlignStretch);
}

/*---------------------------------------------------------------------------*/

void FlexNode::setAlignSelfBaseline() {
YGNodeStyleSetAlignItems(node, YGAlignBaseline);
YGNodeStyleSetAlignSelf(node, YGAlignBaseline);
}

/*---------------------------------------------------------------------------*/

void FlexNode::setAlignSelfFlexStart() {
YGNodeStyleSetAlignItems(node, YGAlignFlexStart);
YGNodeStyleSetAlignSelf(node, YGAlignFlexStart);
}

/*---------------------------------------------------------------------------*/

void FlexNode::setAlignSelfSpaceAround(){
YGNodeStyleSetAlignItems(node, YGAlignSpaceAround);
YGNodeStyleSetAlignSelf(node, YGAlignSpaceAround);
}

/*---------------------------------------------------------------------------*/

void FlexNode::setAlignSelfSpaceBetween() {
YGNodeStyleSetAlignItems(node, YGAlignSpaceBetween);
YGNodeStyleSetAlignSelf(node, YGAlignSpaceBetween);
}

/*---------------------------------------------------------------------------*/
Expand Down
1 change: 1 addition & 0 deletions qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<qresource prefix="/">
<file>qml/main.qml</file>
<file>qml/Flex.qml</file>
<file>qml/example.qml</file>
</qresource>
</RCC>
14 changes: 7 additions & 7 deletions qml/Flex.qml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Item {
} else if (align === "spaceAround") {
node.setAlignContentSpaceAround();
} else {
debugger;
throw "setAlignContent invalid param";
}
}

Expand All @@ -121,7 +121,7 @@ Item {
} else if (align === "spaceAround") {
node.setAlignItemsSpaceAround();
} else {
debugger;
throw "setAlignItems invalid param";
}
}

Expand All @@ -144,7 +144,7 @@ Item {
} else if (align === "spaceAround") {
node.setAlignSelfSpaceAround();
} else {
debugger;
throw "setAlignSelf invalid param";
}
}

Expand All @@ -155,7 +155,7 @@ Item {
} else if (display==="none") {
node.setDisplayNone();
} else {
debugger;
throw "setDisplay invalid param";
}
}

Expand All @@ -174,7 +174,7 @@ Item {
} else if (justify==="spaceBetween") {
node.setJustifySpaceBetween();
} else {
debugger;
throw "setJustifyContent invalid param";
}
}

Expand All @@ -187,7 +187,7 @@ Item {
} else if (wrap==="wrapReverser") {
node.setWrapReverser();
} else {
debugger;
throw "setFlexWrap invalid param";
}
}

Expand All @@ -202,7 +202,7 @@ Item {
} else if (direction==="columnReverse") {
node.setFlexDirectionColumnReverse();
} else {
debugger;
throw "setFlexDirection invalid param";
}
}

Expand Down
30 changes: 30 additions & 0 deletions qml/example.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import QtQuick 2.5
import QtQuick.Window 2.0

Window {
visible: true
height: 400
width: 675
Rectangle {
anchors.fill: parent
color: "cyan"
Flex {
height: parent.height
width: parent.width
flexDirection: "row"
flexWrap: "wrap"
justifyContent: "spaceAround"
alignItems: "center"
alignSelf: "center"
alignContent: "stretch"
flexShrink: 10
Rectangle { color: "green"; height: 150; width: 150 }
Rectangle { color: "green"; height: 150; width: 150 }
Rectangle { color: "green"; height: 150; width: 150 }
Rectangle { color: "green"; height: 150; width: 150 }
Rectangle { color: "green"; height: 150; width: 150 }
Rectangle { color: "green"; height: 150; width: 150 }
Rectangle { color: "green"; height: 150; width: 150 }
}
}
}
23 changes: 16 additions & 7 deletions qml/main.qml
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
import QtQuick 2.5
import QtQuick.Window 2.0
import "qrc:/qml"

Window {
visible: true
Flex {
height: parent.height
width: parent.width
alignSelf: "center"
justifyContent: "center"
Text { height: 15; width: 15; text: "1" }

/*
* Layout Wrapper. Do not delete if you are using
* layout tools other than flexbox
* anchors.fill, Layout.fillHeight, Layout.fillWidth...
*/
Item {
anchors.fill: parent

Flex {
height: parent.height
width: parent.width
alignSelf: "center"
justifyContent: "center"
Text { height: 15; width: 15; text: "1" }
}
}
}

0 comments on commit d57e635

Please sign in to comment.