diff --git a/examples/calculator/index.ts b/examples/calculator/index.ts index 88512fbdb..c26ac92e6 100644 --- a/examples/calculator/index.ts +++ b/examples/calculator/index.ts @@ -108,6 +108,7 @@ rootViewFlexLayout.addWidget(row0, row0.getFlexNode()); rootViewFlexLayout.addWidget(row1, row1.getFlexNode()); rootViewFlexLayout.addWidget(row2, row2.getFlexNode()); rootViewFlexLayout.addWidget(row3, row3.getFlexNode()); +rootViewFlexLayout.addWidget(row4, row4.getFlexNode()); rootView.setLayout(rootViewFlexLayout); win.show(); diff --git a/src/cpp/QtGui/QWidget/qwidget_macro.h b/src/cpp/QtGui/QWidget/qwidget_macro.h index ab0307429..8ec443a38 100644 --- a/src/cpp/QtGui/QWidget/qwidget_macro.h +++ b/src/cpp/QtGui/QWidget/qwidget_macro.h @@ -39,8 +39,8 @@ Napi::Value setLayout(const Napi::CallbackInfo& info){ \ Napi::Env env = info.Env(); \ Napi::HandleScope scope(env); \ Napi::Object layoutObject = info[0].As(); \ - QLayoutWrap* layoutParent = Napi::ObjectWrap::Unwrap(layoutObject); \ - this->instance->setLayout(layoutParent->getInternalInstance()); \ + QLayoutWrap* layoutWrap = Napi::ObjectWrap::Unwrap(layoutObject); \ + this->instance->setLayout(layoutWrap->getInternalInstance()); \ return env.Null(); \ } \ \ diff --git a/src/cpp/core/FlexLayout/flexitem.cpp b/src/cpp/core/FlexLayout/flexitem.cpp index 7b0fdd7f7..0972d3f24 100644 --- a/src/cpp/core/FlexLayout/flexitem.cpp +++ b/src/cpp/core/FlexLayout/flexitem.cpp @@ -3,6 +3,7 @@ FlexItem::FlexItem() { this->node = YGNodeNew(); + YGConfigSetUseWebDefaults(this->node->getConfig(),true); } YGNodeRef FlexItem::getFlexNode() const diff --git a/src/cpp/core/FlexLayout/flexitem.h b/src/cpp/core/FlexLayout/flexitem.h index f65e2155a..cec773ca6 100644 --- a/src/cpp/core/FlexLayout/flexitem.h +++ b/src/cpp/core/FlexLayout/flexitem.h @@ -1,5 +1,4 @@ -#ifndef FLEX_ITEM_H -#define FLEX_ITEM_H +#pragma once #include "deps/yoga/YGNode.h" @@ -8,7 +7,6 @@ In most cases you will use YogaWidget class instead of this one since it inherits from FlexItem. */ - class FlexItem { YGNodeRef node; @@ -18,4 +16,3 @@ public: ~FlexItem(); }; -#endif // FLEX_ITEM_H diff --git a/src/cpp/core/FlexLayout/flexlayout.cpp b/src/cpp/core/FlexLayout/flexlayout.cpp index b709cfe4f..d7258d637 100644 --- a/src/cpp/core/FlexLayout/flexlayout.cpp +++ b/src/cpp/core/FlexLayout/flexlayout.cpp @@ -40,8 +40,9 @@ QSize FlexLayout::sizeHint() const{ return QSize(0,0); } QSize size; - int width = static_cast(YGNodeLayoutGetWidth(this->node)); - int height = static_cast(YGNodeLayoutGetHeight(this->node)); + int width = static_cast(YGNodeLayoutGetWidth(this->node)); + int height = static_cast(YGNodeLayoutGetHeight(this->node)); + spdlog::info("flexlayout: sizeHint {}x{}",width, height); size.setWidth(width); size.setHeight(height); return size; @@ -89,8 +90,7 @@ int FlexLayout::count() const } float childCount = YGNodeGetChildCount(this->node); spdlog::info("flexlayout: count {}",childCount); - return static_cast(childCount); - + return static_cast(childCount); } void FlexLayout::addWidget(QWidget* childWidget, YGNodeRef childNode) @@ -123,10 +123,10 @@ void FlexLayout::setGeometry(const QRect &rect) for (uint i = 0; i < count; ++i) { YGNode *childNode = YGNodeGetChild(this->node, i); - int width = static_cast(YGNodeLayoutGetWidth(childNode)); - int height = static_cast(YGNodeLayoutGetHeight(childNode)); - int left = static_cast(YGNodeLayoutGetLeft(childNode)); - int top = static_cast(YGNodeLayoutGetTop(childNode)); + int width = static_cast(YGNodeLayoutGetWidth(childNode)); + int height = static_cast(YGNodeLayoutGetHeight(childNode)); + int left = static_cast(YGNodeLayoutGetLeft(childNode)); + int top = static_cast(YGNodeLayoutGetTop(childNode)); QRect childRect(left, top,width, height); NodeContext *ctx = getNodeContext(childNode);