Added YogaWidget : Adds stylesheet support for all yoga related stuff.
Added guards for the macros.
This commit is contained in:
parent
cb0bdfa08d
commit
8486f40a99
@ -11,6 +11,9 @@
|
||||
# non-wrapped cpps
|
||||
"../src/cpp/Extras/Utils/utils.cpp",
|
||||
"../src/cpp/core/FlexLayout/flexlayout.cpp",
|
||||
"../src/cpp/core/FlexLayout/flexitem.cpp",
|
||||
"../src/cpp/core/YogaWidget/nodestyle.cpp",
|
||||
"../src/cpp/core/YogaWidget/yogawidget.cpp",
|
||||
# wrapped cpps
|
||||
"../src/cpp/QtGui/QApplication/qapplication_wrap.cpp",
|
||||
"../src/cpp/QtGui/QWidget/qwidget_wrap.cpp",
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
|
||||
#include "src/cpp/QtWidgets/QLayout/qlayout_wrap.h"
|
||||
|
||||
#ifndef QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
#define QWIDGET_WRAPPED_METHODS_DECLARATION \
|
||||
\
|
||||
Napi::Value show(const Napi::CallbackInfo& info) { \
|
||||
@ -53,7 +54,10 @@ Napi::Value hide(const Napi::CallbackInfo& info) { \
|
||||
return env.Null(); \
|
||||
}
|
||||
|
||||
#endif //QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
|
||||
|
||||
#ifndef QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE
|
||||
#define QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(WidgetWrapName) \
|
||||
\
|
||||
InstanceMethod("show", &WidgetWrapName::show), \
|
||||
@ -64,4 +68,8 @@ Napi::Value hide(const Napi::CallbackInfo& info) { \
|
||||
InstanceMethod("hide",&WidgetWrapName::hide), \
|
||||
|
||||
|
||||
#endif
|
||||
#endif // QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE
|
||||
|
||||
|
||||
|
||||
#endif // QWIDGET_MACRO_H
|
||||
@ -2,5 +2,15 @@
|
||||
|
||||
FlexItem::FlexItem()
|
||||
{
|
||||
|
||||
this->node = YGNodeNew();
|
||||
}
|
||||
|
||||
YGNodeRef FlexItem::getFlexNode() const
|
||||
{
|
||||
return this->node;
|
||||
}
|
||||
|
||||
FlexItem::~FlexItem()
|
||||
{
|
||||
YGNodeFree(this->node);
|
||||
}
|
||||
|
||||
@ -1,11 +1,15 @@
|
||||
#ifndef FLEXITEM_H
|
||||
#define FLEXITEM_H
|
||||
#ifndef FLEX_ITEM_H
|
||||
#define FLEX_ITEM_H
|
||||
|
||||
#include "deps/yoga/YGNode.h"
|
||||
|
||||
class FlexItem
|
||||
{
|
||||
YGNodeRef node;
|
||||
public:
|
||||
FlexItem();
|
||||
FlexItem();
|
||||
YGNodeRef getFlexNode() const;
|
||||
~FlexItem();
|
||||
};
|
||||
|
||||
#endif // FLEXITEM_H
|
||||
#endif // FLEX_ITEM_H
|
||||
|
||||
70
src/cpp/core/YogaWidget/nodestyle.cpp
Normal file
70
src/cpp/core/YogaWidget/nodestyle.cpp
Normal file
@ -0,0 +1,70 @@
|
||||
#include "nodestyle.h"
|
||||
|
||||
std::unordered_map<std::string, int> NodeStyle::NodeAlign {
|
||||
{"auto",YGAlignAuto},
|
||||
{"flex-start",YGAlignFlexStart},
|
||||
{"center",YGAlignCenter},
|
||||
{"flex-end",YGAlignFlexEnd},
|
||||
{"stretch",YGAlignStretch},
|
||||
{"baseline",YGAlignBaseline},
|
||||
{"space-between",YGAlignSpaceBetween},
|
||||
{"space-around",YGAlignSpaceAround},
|
||||
};
|
||||
|
||||
std::unordered_map<std::string, int> NodeStyle::NodeJustifyContent {
|
||||
{"flex-start",YGJustifyFlexStart},
|
||||
{"center",YGJustifyCenter},
|
||||
{"flex-end",YGJustifyFlexEnd},
|
||||
{"space-between",YGJustifySpaceBetween},
|
||||
{"space-around",YGJustifySpaceAround},
|
||||
{"space-evenly",YGJustifySpaceEvenly}
|
||||
};
|
||||
|
||||
|
||||
std::unordered_map<std::string, int> NodeStyle::NodeDirection {
|
||||
{"inherit", YGDirectionInherit},
|
||||
{"ltr",YGDirectionLTR},
|
||||
{"rtl",YGDirectionRTL}
|
||||
};
|
||||
|
||||
std::unordered_map<std::string, int> NodeStyle::NodeDisplay {
|
||||
{"flex", YGDisplayFlex},
|
||||
{"none", YGDisplayNone}
|
||||
};
|
||||
|
||||
|
||||
std::unordered_map<std::string, int> NodeStyle::NodeFlexDirection {
|
||||
{"column", YGFlexDirectionColumn},
|
||||
{"column-reverse", YGFlexDirectionColumnReverse},
|
||||
{"row", YGFlexDirectionRow},
|
||||
{"row-reverse", YGFlexDirectionRowReverse}
|
||||
};
|
||||
|
||||
|
||||
std::unordered_map<std::string, int> NodeStyle::NodeOverflow {
|
||||
{"visible",YGOverflowVisible},
|
||||
{"hidden",YGOverflowHidden},
|
||||
{"scroll",YGOverflowScroll}
|
||||
};
|
||||
|
||||
std::unordered_map<std::string, int> NodeStyle::NodePosition {
|
||||
{"relative",YGPositionTypeRelative},
|
||||
{"absolute",YGPositionTypeAbsolute},
|
||||
};
|
||||
|
||||
std::unordered_map<std::string, int> NodeStyle::NodeWrap {
|
||||
{"no-wrap",YGWrapNoWrap},
|
||||
{"wrap",YGWrapWrap},
|
||||
{"wrap-reverse",YGWrapWrapReverse}
|
||||
};
|
||||
|
||||
NodeValueUnit NodeStyle::parseMeasurement(QString rawValue){
|
||||
float value = std::stof(rawValue.toStdString());
|
||||
if(rawValue.back() == "%"){
|
||||
return NodeValueUnit(value, YGUnitPercent);
|
||||
}
|
||||
return NodeValueUnit(value, YGUnitPoint);
|
||||
}
|
||||
|
||||
|
||||
|
||||
38
src/cpp/core/YogaWidget/nodestyle.h
Normal file
38
src/cpp/core/YogaWidget/nodestyle.h
Normal file
@ -0,0 +1,38 @@
|
||||
#ifndef NODESTYLE_H
|
||||
#define NODESTYLE_H
|
||||
|
||||
#include <QString>
|
||||
#include <unordered_map>
|
||||
#include "deps/yoga/YGStyle.h"
|
||||
|
||||
struct NodeValueUnit{
|
||||
YGUnit unit;
|
||||
float value;
|
||||
NodeValueUnit(float v, YGUnit u){
|
||||
unit = u;
|
||||
value = v;
|
||||
}
|
||||
};
|
||||
|
||||
class NodeStyle {
|
||||
public:
|
||||
static std::unordered_map<std::string, int> NodeAlign;
|
||||
|
||||
static std::unordered_map<std::string, int> NodeJustifyContent;
|
||||
|
||||
static std::unordered_map<std::string, int> NodeDirection;
|
||||
|
||||
static std::unordered_map<std::string, int> NodeDisplay;
|
||||
|
||||
static std::unordered_map<std::string, int> NodeFlexDirection;
|
||||
|
||||
static std::unordered_map<std::string, int> NodeOverflow;
|
||||
|
||||
static std::unordered_map<std::string, int> NodePosition;
|
||||
|
||||
static std::unordered_map<std::string, int> NodeWrap;
|
||||
|
||||
static NodeValueUnit parseMeasurement(QString rawValue);
|
||||
};
|
||||
|
||||
#endif // NODESTYLE_H
|
||||
458
src/cpp/core/YogaWidget/yogawidget.cpp
Normal file
458
src/cpp/core/YogaWidget/yogawidget.cpp
Normal file
@ -0,0 +1,458 @@
|
||||
#include "yogawidget.h"
|
||||
|
||||
void YogaWidget::setYDisplay(QString display){
|
||||
|
||||
try {
|
||||
int value = NodeStyle::NodeDisplay.at(display.toStdString());
|
||||
YGNodeStyleSetDisplay(this->getFlexNode(),static_cast<YGDisplay>(value));
|
||||
this->_yDisplay = display;
|
||||
qDebug()<<"Value set display "<<display;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: display "<<display<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYAlignItems(QString alignItems){
|
||||
try {
|
||||
int value = NodeStyle::NodeAlign.at(alignItems.toStdString());
|
||||
YGNodeStyleSetAlignItems(this->getFlexNode(),static_cast<YGAlign>(value));
|
||||
this->_yAlignItems = alignItems;
|
||||
qDebug()<<"Value set alignItems "<<alignItems;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: alignItems: "<<alignItems<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYAlignContent(QString alignContent){
|
||||
try {
|
||||
int value = NodeStyle::NodeAlign.at(alignContent.toStdString());
|
||||
YGNodeStyleSetAlignContent(this->getFlexNode(),static_cast<YGAlign>(value));
|
||||
this->_yAlignContent = alignContent;
|
||||
qDebug()<<"Value set alignContent "<<alignContent;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: alignContent: "<<alignContent<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYAlignSelf(QString alignSelf){
|
||||
try {
|
||||
int value = NodeStyle::NodeAlign.at(alignSelf.toStdString());
|
||||
YGNodeStyleSetAlignSelf(this->getFlexNode(),static_cast<YGAlign>(value));
|
||||
this->_yAlignSelf = alignSelf;
|
||||
qDebug()<<"Value set alignSelf "<<alignSelf;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: alignSelf: "<<alignSelf<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYJustifyContent(QString justifyContent){
|
||||
try {
|
||||
int value = NodeStyle::NodeJustifyContent.at(justifyContent.toStdString());
|
||||
YGNodeStyleSetJustifyContent(this->getFlexNode(),static_cast<YGJustify>(value));
|
||||
this->_yJustifyContent = justifyContent;
|
||||
qDebug()<<"Value set justifyContent "<<justifyContent;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: justifyContent: "<<justifyContent<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYDirection(QString direction){
|
||||
try {
|
||||
int value = NodeStyle::NodeDirection.at(direction.toStdString());
|
||||
YGNodeStyleSetDirection(this->getFlexNode(),static_cast<YGDirection>(value));
|
||||
this->_yDirection = direction;
|
||||
qDebug()<<"Value set direction "<<direction;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: direction: "<<direction<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYFlexDirection(QString flexDirection){
|
||||
try {
|
||||
int value = NodeStyle::NodeFlexDirection.at(flexDirection.toStdString());
|
||||
YGNodeStyleSetFlexDirection(this->getFlexNode(),static_cast<YGFlexDirection>(value));
|
||||
this->_yFlexDirection = flexDirection;
|
||||
qDebug()<<"Value set flexDirection "<<flexDirection;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: flexDirection: "<<flexDirection<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYOverflow(QString overflow){
|
||||
try {
|
||||
int value = NodeStyle::NodeOverflow.at(overflow.toStdString());
|
||||
YGNodeStyleSetOverflow(this->getFlexNode(),static_cast<YGOverflow>(value));
|
||||
this->_yOverflow = overflow;
|
||||
qDebug()<<"Value set overflow "<<overflow;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: overflow: "<<overflow<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYPosition(QString position){
|
||||
try {
|
||||
int value = NodeStyle::NodePosition.at(position.toStdString());
|
||||
YGNodeStyleSetPositionType(this->getFlexNode(),static_cast<YGPositionType>(value));
|
||||
this->_yPosition = position;
|
||||
qDebug()<<"Value set positionType "<<position;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: positionType: "<<position<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYFlexWrap(QString flexWrap){
|
||||
try {
|
||||
int value = NodeStyle::NodeWrap.at(flexWrap.toStdString());
|
||||
YGNodeStyleSetFlexWrap(this->getFlexNode(),static_cast<YGWrap>(value));
|
||||
this->_yFlexWrap = flexWrap;
|
||||
qDebug()<<"Value set flexWrap "<<flexWrap;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: flexWrap: "<<flexWrap<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYFlex(float flex){
|
||||
try {
|
||||
YGNodeStyleSetFlex(this->getFlexNode(),flex);
|
||||
this->_yFlex = flex;
|
||||
qDebug()<<"Value set flex "<<flex;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: flex: "<<flex<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYFlexGrow(float flexGrow){
|
||||
try {
|
||||
YGNodeStyleSetFlexGrow(this->getFlexNode(),flexGrow);
|
||||
this->_yFlexGrow = flexGrow;
|
||||
qDebug()<<"Value set flexGrow "<<flexGrow;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: flexGrow: "<<flexGrow<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYFlexShrink(float flexShrink){
|
||||
try {
|
||||
YGNodeStyleSetFlexShrink(this->getFlexNode(),flexShrink);
|
||||
this->_yFlexShrink = flexShrink;
|
||||
qDebug()<<"Value set flexShrink "<<flexShrink;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: flexShrink: "<<flexShrink<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYAspectRatio(float aspectRatio){
|
||||
try {
|
||||
YGNodeStyleSetAspectRatio(this->getFlexNode(),aspectRatio);
|
||||
this->_yAspectRatio = aspectRatio;
|
||||
qDebug()<<"Value set aspectRatio "<<aspectRatio;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: aspectRatio: "<<aspectRatio<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYNodeTop(QString rawValue){
|
||||
try {
|
||||
NodeValueUnit measurement = NodeStyle::parseMeasurement(rawValue);
|
||||
(measurement.unit == YGUnitPercent)
|
||||
? YGNodeStyleSetPositionPercent(this->getFlexNode(), YGEdgeTop,measurement.value)
|
||||
: YGNodeStyleSetPosition(this->getFlexNode(),YGEdgeTop,measurement.value);
|
||||
this->_yTop = rawValue;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: top: "<<rawValue<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYNodeRight(QString rawValue){
|
||||
try {
|
||||
NodeValueUnit measurement = NodeStyle::parseMeasurement(rawValue);
|
||||
(measurement.unit == YGUnitPercent)
|
||||
? YGNodeStyleSetPositionPercent(this->getFlexNode(), YGEdgeRight,measurement.value)
|
||||
: YGNodeStyleSetPosition(this->getFlexNode(),YGEdgeRight,measurement.value);
|
||||
this->_yRight = rawValue;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: right: "<<rawValue<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
|
||||
void YogaWidget::setYNodeBottom(QString rawValue){
|
||||
try {
|
||||
NodeValueUnit measurement = NodeStyle::parseMeasurement(rawValue);
|
||||
(measurement.unit == YGUnitPercent)
|
||||
? YGNodeStyleSetPositionPercent(this->getFlexNode(), YGEdgeBottom,measurement.value)
|
||||
: YGNodeStyleSetPosition(this->getFlexNode(),YGEdgeBottom,measurement.value);
|
||||
this->_yBottom = rawValue;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: bottom: "<<rawValue<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
|
||||
void YogaWidget::setYNodeLeft(QString rawValue){
|
||||
try {
|
||||
NodeValueUnit measurement = NodeStyle::parseMeasurement(rawValue);
|
||||
(measurement.unit == YGUnitPercent)
|
||||
? YGNodeStyleSetPositionPercent(this->getFlexNode(), YGEdgeLeft,measurement.value)
|
||||
: YGNodeStyleSetPosition(this->getFlexNode(),YGEdgeLeft,measurement.value);
|
||||
this->_yLeft = rawValue;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: left: "<<rawValue<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
|
||||
void YogaWidget::setYFlexBasis(QString rawValue){
|
||||
try {
|
||||
if(rawValue == "auto"){
|
||||
YGNodeStyleSetFlexBasisAuto(this->getFlexNode());
|
||||
}else {
|
||||
NodeValueUnit measurement = NodeStyle::parseMeasurement(rawValue);
|
||||
(measurement.unit == YGUnitPercent)
|
||||
? YGNodeStyleSetFlexBasisPercent(this->getFlexNode(), measurement.value)
|
||||
: YGNodeStyleSetFlexBasis(this->getFlexNode(),measurement.value);
|
||||
}
|
||||
this->_yFlexBasis = rawValue;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: flexBasis: "<<rawValue<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
|
||||
void YogaWidget::setYMinWidth(QString rawValue){
|
||||
try {
|
||||
NodeValueUnit measurement = NodeStyle::parseMeasurement(rawValue);
|
||||
(measurement.unit==YGUnitPercent)
|
||||
? YGNodeStyleSetMinWidthPercent(this->getFlexNode(), measurement.value)
|
||||
: YGNodeStyleSetMinWidth(this->getFlexNode(), measurement.value);
|
||||
this->_yMinWidth = rawValue;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: minWidth: "<<rawValue<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYMinHeight(QString rawValue){
|
||||
try {
|
||||
NodeValueUnit measurement = NodeStyle::parseMeasurement(rawValue);
|
||||
(measurement.unit==YGUnitPercent)
|
||||
? YGNodeStyleSetMinHeightPercent(this->getFlexNode(), measurement.value)
|
||||
: YGNodeStyleSetMinHeight(this->getFlexNode(), measurement.value);
|
||||
this->_yMinHeight = rawValue;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: minHeight: "<<rawValue<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYMaxWidth(QString rawValue){
|
||||
try {
|
||||
NodeValueUnit measurement = NodeStyle::parseMeasurement(rawValue);
|
||||
(measurement.unit==YGUnitPercent)
|
||||
? YGNodeStyleSetMaxWidthPercent(this->getFlexNode(), measurement.value)
|
||||
: YGNodeStyleSetMaxWidth(this->getFlexNode(), measurement.value);
|
||||
this->_yMaxWidth = rawValue;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: maxWidth: "<<rawValue<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYMaxHeight(QString rawValue){
|
||||
try {
|
||||
NodeValueUnit measurement = NodeStyle::parseMeasurement(rawValue);
|
||||
(measurement.unit==YGUnitPercent)
|
||||
? YGNodeStyleSetMaxHeightPercent(this->getFlexNode(), measurement.value)
|
||||
: YGNodeStyleSetMaxHeight(this->getFlexNode(), measurement.value);
|
||||
this->_yMaxHeight = rawValue;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: maxHeight: "<<rawValue<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYPaddingTop(QString rawValue){
|
||||
try {
|
||||
NodeValueUnit measurement = NodeStyle::parseMeasurement(rawValue);
|
||||
(measurement.unit==YGUnitPercent)
|
||||
? YGNodeStyleSetPaddingPercent(this->getFlexNode(),YGEdgeTop, measurement.value)
|
||||
: YGNodeStyleSetPadding(this->getFlexNode(),YGEdgeTop, measurement.value);
|
||||
this->_yPaddingTop = rawValue;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: paddingTop: "<<rawValue<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYPaddingRight(QString rawValue){
|
||||
try {
|
||||
NodeValueUnit measurement = NodeStyle::parseMeasurement(rawValue);
|
||||
(measurement.unit==YGUnitPercent)
|
||||
? YGNodeStyleSetPaddingPercent(this->getFlexNode(),YGEdgeRight, measurement.value)
|
||||
: YGNodeStyleSetPadding(this->getFlexNode(),YGEdgeRight, measurement.value);
|
||||
this->_yPaddingRight = rawValue;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: paddingRight: "<<rawValue<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYPaddingBottom(QString rawValue){
|
||||
try {
|
||||
NodeValueUnit measurement = NodeStyle::parseMeasurement(rawValue);
|
||||
(measurement.unit==YGUnitPercent)
|
||||
? YGNodeStyleSetPaddingPercent(this->getFlexNode(),YGEdgeBottom, measurement.value)
|
||||
: YGNodeStyleSetPadding(this->getFlexNode(),YGEdgeBottom, measurement.value);
|
||||
this->_yPaddingBottom = rawValue;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: paddingBottom: "<<rawValue<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYPaddingLeft(QString rawValue){
|
||||
try {
|
||||
NodeValueUnit measurement = NodeStyle::parseMeasurement(rawValue);
|
||||
(measurement.unit==YGUnitPercent)
|
||||
? YGNodeStyleSetPaddingPercent(this->getFlexNode(),YGEdgeLeft, measurement.value)
|
||||
: YGNodeStyleSetPadding(this->getFlexNode(), YGEdgeLeft, measurement.value);
|
||||
this->_yPaddingLeft = rawValue;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: paddingLeft: "<<rawValue<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYPaddingHorizontal(QString rawValue){
|
||||
try {
|
||||
NodeValueUnit measurement = NodeStyle::parseMeasurement(rawValue);
|
||||
(measurement.unit==YGUnitPercent)
|
||||
? YGNodeStyleSetPaddingPercent(this->getFlexNode(), YGEdgeHorizontal, measurement.value)
|
||||
: YGNodeStyleSetPadding(this->getFlexNode(),YGEdgeHorizontal, measurement.value);
|
||||
this->_yPaddingHorizontal = rawValue;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: paddingHorizontal: "<<rawValue<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYPaddingVertical(QString rawValue){
|
||||
try {
|
||||
NodeValueUnit measurement = NodeStyle::parseMeasurement(rawValue);
|
||||
(measurement.unit==YGUnitPercent)
|
||||
? YGNodeStyleSetPaddingPercent(this->getFlexNode(),YGEdgeVertical, measurement.value)
|
||||
: YGNodeStyleSetPadding(this->getFlexNode(),YGEdgeVertical, measurement.value);
|
||||
this->_yPaddingVertical = rawValue;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: paddingVertical: "<<rawValue<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYPadding(QString rawValue){
|
||||
try {
|
||||
NodeValueUnit measurement = NodeStyle::parseMeasurement(rawValue);
|
||||
(measurement.unit==YGUnitPercent)
|
||||
? YGNodeStyleSetPaddingPercent(this->getFlexNode(),YGEdgeAll, measurement.value)
|
||||
: YGNodeStyleSetPadding(this->getFlexNode(),YGEdgeAll, measurement.value);
|
||||
this->_yPadding = rawValue;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: padding: "<<rawValue<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYMarginTop(QString rawValue){
|
||||
try {
|
||||
NodeValueUnit measurement = NodeStyle::parseMeasurement(rawValue);
|
||||
(measurement.unit==YGUnitPercent)
|
||||
? YGNodeStyleSetMarginPercent(this->getFlexNode(),YGEdgeTop, measurement.value)
|
||||
: YGNodeStyleSetMargin(this->getFlexNode(),YGEdgeTop, measurement.value);
|
||||
this->_yMarginTop = rawValue;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: marginTop: "<<rawValue<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYMarginRight(QString rawValue){
|
||||
try {
|
||||
NodeValueUnit measurement = NodeStyle::parseMeasurement(rawValue);
|
||||
(measurement.unit==YGUnitPercent)
|
||||
? YGNodeStyleSetMarginPercent(this->getFlexNode(),YGEdgeRight, measurement.value)
|
||||
: YGNodeStyleSetMargin(this->getFlexNode(),YGEdgeRight, measurement.value);
|
||||
this->_yMarginRight = rawValue;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: marginRight: "<<rawValue<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYMarginBottom(QString rawValue){
|
||||
try {
|
||||
NodeValueUnit measurement = NodeStyle::parseMeasurement(rawValue);
|
||||
(measurement.unit==YGUnitPercent)
|
||||
? YGNodeStyleSetMarginPercent(this->getFlexNode(),YGEdgeBottom, measurement.value)
|
||||
: YGNodeStyleSetMargin(this->getFlexNode(),YGEdgeBottom, measurement.value);
|
||||
this->_yMarginBottom = rawValue;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: marginBottom: "<<rawValue<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYMarginLeft(QString rawValue){
|
||||
try {
|
||||
NodeValueUnit measurement = NodeStyle::parseMeasurement(rawValue);
|
||||
(measurement.unit==YGUnitPercent)
|
||||
? YGNodeStyleSetMarginPercent(this->getFlexNode(),YGEdgeLeft, measurement.value)
|
||||
: YGNodeStyleSetMargin(this->getFlexNode(), YGEdgeLeft, measurement.value);
|
||||
this->_yMarginLeft = rawValue;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: marginLeft: "<<rawValue<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYMarginHorizontal(QString rawValue){
|
||||
try {
|
||||
NodeValueUnit measurement = NodeStyle::parseMeasurement(rawValue);
|
||||
(measurement.unit==YGUnitPercent)
|
||||
? YGNodeStyleSetMarginPercent(this->getFlexNode(), YGEdgeHorizontal, measurement.value)
|
||||
: YGNodeStyleSetMargin(this->getFlexNode(),YGEdgeHorizontal, measurement.value);
|
||||
this->_yMarginHorizontal = rawValue;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: marginHorizontal: "<<rawValue<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYMarginVertical(QString rawValue){
|
||||
try {
|
||||
NodeValueUnit measurement = NodeStyle::parseMeasurement(rawValue);
|
||||
(measurement.unit==YGUnitPercent)
|
||||
? YGNodeStyleSetMarginPercent(this->getFlexNode(),YGEdgeVertical, measurement.value)
|
||||
: YGNodeStyleSetMargin(this->getFlexNode(),YGEdgeVertical, measurement.value);
|
||||
this->_yMarginVertical = rawValue;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: marginVertical: "<<rawValue<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYMarginAll(QString rawValue){
|
||||
try {
|
||||
NodeValueUnit measurement = NodeStyle::parseMeasurement(rawValue);
|
||||
(measurement.unit==YGUnitPercent)
|
||||
? YGNodeStyleSetMarginPercent(this->getFlexNode(),YGEdgeAll, measurement.value)
|
||||
: YGNodeStyleSetMargin(this->getFlexNode(),YGEdgeAll, measurement.value);
|
||||
this->_yMargin = rawValue;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: margin: "<<rawValue<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
|
||||
void YogaWidget::setYBorderTop(float rawValue){
|
||||
try {
|
||||
YGNodeStyleSetBorder(this->getFlexNode(),YGEdgeTop, rawValue);
|
||||
this->_yBorderTop = rawValue;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: borderTop: "<<rawValue<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYBorderRight(float rawValue){
|
||||
try {
|
||||
YGNodeStyleSetBorder(this->getFlexNode(),YGEdgeRight, rawValue);
|
||||
this->_yBorderRight = rawValue;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: borderRight: "<<rawValue<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYBorderBottom(float rawValue){
|
||||
try {
|
||||
YGNodeStyleSetBorder(this->getFlexNode(),YGEdgeBottom, rawValue);
|
||||
this->_yBorderBottom = rawValue;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: borderBottom: "<<rawValue<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYBorderLeft(float rawValue){
|
||||
try {
|
||||
YGNodeStyleSetBorder(this->getFlexNode(), YGEdgeLeft, rawValue);
|
||||
this->_yBorderLeft = rawValue;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: borderLeft: "<<rawValue<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYBorderHorizontal(float rawValue){
|
||||
try {
|
||||
YGNodeStyleSetBorder(this->getFlexNode(),YGEdgeHorizontal, rawValue);
|
||||
this->_yBorderHorizontal = rawValue;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: borderHorizontal: "<<rawValue<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
void YogaWidget::setYBorderVertical(float rawValue){
|
||||
try {
|
||||
YGNodeStyleSetBorder(this->getFlexNode(),YGEdgeVertical, rawValue);
|
||||
this->_yBorderVertical = rawValue;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: borderVertical: "<<rawValue<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
|
||||
void YogaWidget::setYBorder(float rawValue){
|
||||
try {
|
||||
YGNodeStyleSetBorder(this->getFlexNode(), YGEdgeAll, rawValue);
|
||||
this->_yBorder = rawValue;
|
||||
}catch(std::exception &e){
|
||||
qDebug()<<"Error: border: "<<rawValue<<" "<<e.what();
|
||||
}
|
||||
}
|
||||
161
src/cpp/core/YogaWidget/yogawidget.h
Normal file
161
src/cpp/core/YogaWidget/yogawidget.h
Normal file
@ -0,0 +1,161 @@
|
||||
#ifndef YOGAWIDGET_H
|
||||
#define YOGAWIDGET_H
|
||||
#include <QWidget>
|
||||
#include <QDebug>
|
||||
#include "nodestyle.h"
|
||||
#include "src/cpp/core/FlexLayout/flexitem.h"
|
||||
|
||||
/*
|
||||
All Widgets for which you need to set yoga props via qstylesheet should
|
||||
1. inherit from YogaWidget
|
||||
2. should add Q_OBJECT macro so that Q_PROPERTY inside YogaWidget can work.
|
||||
3. should call the macro SET_YOGA_WIDGET_Q_PROPERTIES inside them to add all necessary q_properties.
|
||||
4. Lastly, since Q_OBJECT is used they should make a call to qt moc.
|
||||
*/
|
||||
|
||||
#ifndef SET_YOGA_WIDGET_Q_PROPERTIES
|
||||
#define SET_YOGA_WIDGET_Q_PROPERTIES \
|
||||
Q_PROPERTY(QString display MEMBER _yDisplay WRITE setYDisplay) \
|
||||
Q_PROPERTY(QString alignItems MEMBER _yAlignItems WRITE setYAlignItems) \
|
||||
Q_PROPERTY(QString alignContent MEMBER _yAlignContent WRITE setYAlignContent) \
|
||||
Q_PROPERTY(QString alignSelf MEMBER _yAlignSelf WRITE setYAlignSelf) \
|
||||
Q_PROPERTY(QString justifyContent MEMBER _yJustifyContent WRITE setYJustifyContent) \
|
||||
Q_PROPERTY(QString direction MEMBER _yDirection WRITE setYDirection) \
|
||||
Q_PROPERTY(QString flexDirection MEMBER _yFlexDirection WRITE setYFlexDirection) \
|
||||
Q_PROPERTY(QString overflow MEMBER _yOverflow WRITE setYOverflow) \
|
||||
Q_PROPERTY(QString position MEMBER _yPosition WRITE setYPosition) \
|
||||
Q_PROPERTY(QString flexWrap MEMBER _yFlexWrap WRITE setYFlexWrap) \
|
||||
Q_PROPERTY(float flex MEMBER _yFlex WRITE setYFlex) \
|
||||
Q_PROPERTY(float flexGrow MEMBER _yFlexGrow WRITE setYFlexGrow) \
|
||||
Q_PROPERTY(float flexShrink MEMBER _yFlexShrink WRITE setYFlexShrink) \
|
||||
Q_PROPERTY(float aspectRatio MEMBER _yAspectRatio WRITE setYAspectRatio) \
|
||||
Q_PROPERTY(QString top MEMBER _yTop WRITE setYNodeTop) \
|
||||
Q_PROPERTY(QString right MEMBER _yRight WRITE setYNodeRight) \
|
||||
Q_PROPERTY(QString bottom MEMBER _yBottom WRITE setYNodeBottom) \
|
||||
Q_PROPERTY(QString left MEMBER _yLeft WRITE setYNodeLeft) \
|
||||
Q_PROPERTY(QString flexBasis MEMBER _yFlexBasis WRITE setYFlexBasis) \
|
||||
Q_PROPERTY(QString minWidth MEMBER _yMinWidth WRITE setYMinWidth) \
|
||||
Q_PROPERTY(QString minHeight MEMBER _yMinHeight WRITE setYMinHeight) \
|
||||
Q_PROPERTY(QString maxWidth MEMBER _yMaxWidth WRITE setYMaxWidth) \
|
||||
Q_PROPERTY(QString maxHeight MEMBER _yMaxHeight WRITE setYMaxHeight) \
|
||||
Q_PROPERTY(QString paddingTop MEMBER _yPaddingTop WRITE setYPaddingTop) \
|
||||
Q_PROPERTY(QString paddingRight MEMBER _yPaddingRight WRITE setYPaddingRight) \
|
||||
Q_PROPERTY(QString paddingBottom MEMBER _yPaddingBottom WRITE setYPaddingBottom) \
|
||||
Q_PROPERTY(QString paddingLeft MEMBER _yPaddingLeft WRITE setYPaddingLeft) \
|
||||
Q_PROPERTY(QString paddingHorizontal MEMBER _yPaddingHorizontal WRITE setYPaddingHorizontal) \
|
||||
Q_PROPERTY(QString paddingVertical MEMBER _yPaddingVertical WRITE setYPaddingVertical) \
|
||||
Q_PROPERTY(QString padding MEMBER _yPadding WRITE setYPadding) \
|
||||
Q_PROPERTY(QString marginTop MEMBER _yMarginTop WRITE setYMarginTop) \
|
||||
Q_PROPERTY(QString marginRight MEMBER _yMarginRight WRITE setYMarginRight) \
|
||||
Q_PROPERTY(QString marginBottom MEMBER _yMarginBottom WRITE setYMarginBottom) \
|
||||
Q_PROPERTY(QString marginLeft MEMBER _yMarginLeft WRITE setYMarginLeft) \
|
||||
Q_PROPERTY(QString marginHorizontal MEMBER _yMarginHorizontal WRITE setYMarginHorizontal) \
|
||||
Q_PROPERTY(QString marginVertical MEMBER _yMarginVertical WRITE setYMarginVertical) \
|
||||
Q_PROPERTY(QString margin MEMBER _yMargin WRITE setYMarginAll) \
|
||||
Q_PROPERTY(float borderTop MEMBER _yBorderTop WRITE setYBorderTop) \
|
||||
Q_PROPERTY(float borderRight MEMBER _yBorderRight WRITE setYBorderRight) \
|
||||
Q_PROPERTY(float borderBottom MEMBER _yBorderBottom WRITE setYBorderBottom) \
|
||||
Q_PROPERTY(float borderLeft MEMBER _yBorderLeft WRITE setYBorderLeft) \
|
||||
Q_PROPERTY(float borderHorizontal MEMBER _yBorderHorizontal WRITE setYBorderHorizontal) \
|
||||
Q_PROPERTY(float borderVertical MEMBER _yBorderVertical WRITE setYBorderVertical) \
|
||||
Q_PROPERTY(float border MEMBER _yBorder WRITE setYBorder)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
class YogaWidget: public FlexItem
|
||||
{
|
||||
public:
|
||||
QString _yDisplay;
|
||||
QString _yAlignItems;
|
||||
QString _yAlignContent;
|
||||
QString _yAlignSelf;
|
||||
QString _yJustifyContent;
|
||||
QString _yDirection;
|
||||
QString _yFlexDirection;
|
||||
QString _yOverflow;
|
||||
QString _yPosition;
|
||||
QString _yFlexWrap;
|
||||
float _yFlex;
|
||||
float _yFlexGrow;
|
||||
float _yFlexShrink;
|
||||
float _yAspectRatio;
|
||||
QString _yTop;
|
||||
QString _yRight;
|
||||
QString _yBottom;
|
||||
QString _yLeft;
|
||||
QString _yFlexBasis;
|
||||
QString _yMinWidth;
|
||||
QString _yMinHeight;
|
||||
QString _yMaxWidth;
|
||||
QString _yMaxHeight;
|
||||
QString _yPaddingTop;
|
||||
QString _yPaddingRight;
|
||||
QString _yPaddingBottom;
|
||||
QString _yPaddingLeft;
|
||||
QString _yPaddingHorizontal;
|
||||
QString _yPaddingVertical;
|
||||
QString _yPadding;
|
||||
QString _yMarginTop;
|
||||
QString _yMarginRight;
|
||||
QString _yMarginBottom;
|
||||
QString _yMarginLeft;
|
||||
QString _yMarginHorizontal;
|
||||
QString _yMarginVertical;
|
||||
QString _yMargin;
|
||||
float _yBorderTop;
|
||||
float _yBorderRight;
|
||||
float _yBorderBottom;
|
||||
float _yBorderLeft;
|
||||
float _yBorderHorizontal;
|
||||
float _yBorderVertical;
|
||||
float _yBorder;
|
||||
|
||||
void setYDisplay(QString display);
|
||||
void setYAlignItems(QString alignItems);
|
||||
void setYAlignContent(QString alignContent);
|
||||
void setYAlignSelf(QString alignSelf);
|
||||
void setYJustifyContent(QString justifyContent);
|
||||
void setYDirection(QString direction);
|
||||
void setYFlexDirection(QString flexDirection);
|
||||
void setYOverflow(QString overflow);
|
||||
void setYPosition(QString position);
|
||||
void setYFlexWrap(QString flexWrap);
|
||||
void setYFlex(float flex);
|
||||
void setYFlexGrow(float flexGrow);
|
||||
void setYFlexShrink(float flexShrink);
|
||||
void setYAspectRatio(float aspectRatio);
|
||||
void setYNodeTop(QString rawValue);
|
||||
void setYNodeRight(QString rawValue);
|
||||
void setYNodeBottom(QString rawValue);
|
||||
void setYNodeLeft(QString rawValue);
|
||||
void setYFlexBasis(QString rawValue);
|
||||
void setYMinWidth(QString rawValue);
|
||||
void setYMinHeight(QString rawValue);
|
||||
void setYMaxWidth(QString rawValue);
|
||||
void setYMaxHeight(QString rawValue);
|
||||
void setYPaddingTop(QString rawValue);
|
||||
void setYPaddingRight(QString rawValue);
|
||||
void setYPaddingBottom(QString rawValue);
|
||||
void setYPaddingLeft(QString rawValue);
|
||||
void setYPaddingHorizontal(QString rawValue);
|
||||
void setYPaddingVertical(QString rawValue);
|
||||
void setYPadding(QString rawValue);
|
||||
void setYMarginTop(QString rawValue);
|
||||
void setYMarginRight(QString rawValue);
|
||||
void setYMarginBottom(QString rawValue);
|
||||
void setYMarginLeft(QString rawValue);
|
||||
void setYMarginHorizontal(QString rawValue);
|
||||
void setYMarginVertical(QString rawValue);
|
||||
void setYMarginAll(QString rawValue);
|
||||
void setYBorderTop(float rawValue);
|
||||
void setYBorderRight(float rawValue);
|
||||
void setYBorderBottom(float rawValue);
|
||||
void setYBorderLeft(float rawValue);
|
||||
void setYBorderHorizontal(float rawValue);
|
||||
void setYBorderVertical(float rawValue);
|
||||
void setYBorder(float rawValue);
|
||||
};
|
||||
|
||||
|
||||
#endif // YOGAWIDGET_H
|
||||
Loading…
Reference in New Issue
Block a user