Added more logging
This commit is contained in:
parent
001d83b860
commit
a2bbc24f3d
3
demo.ts
3
demo.ts
@ -94,12 +94,11 @@ const testFlexLayout = () => {
|
||||
color:white;
|
||||
qproperty-alignSelf: 'stretch';
|
||||
`);
|
||||
view.setLayout(flayout);
|
||||
|
||||
flayout.addWidget(label2, label2.getFlexNode());
|
||||
flayout.addWidget(label, label.getFlexNode());
|
||||
|
||||
view.setLayout(flayout);
|
||||
|
||||
win.show();
|
||||
return win;
|
||||
};
|
||||
|
||||
@ -6,10 +6,6 @@ import { QLabel } from "../../src/lib/QtWidgets/QLabel";
|
||||
|
||||
const globals = global as any;
|
||||
|
||||
// Main Window
|
||||
const win = new QMainWindow();
|
||||
win.resize(400, 600);
|
||||
|
||||
const getButton = (
|
||||
label: string,
|
||||
value: number | string,
|
||||
@ -24,6 +20,10 @@ const getButton = (
|
||||
};
|
||||
};
|
||||
|
||||
// Main Window
|
||||
const win = new QMainWindow();
|
||||
win.resize(400, 600);
|
||||
|
||||
// Top Row
|
||||
const btnClear = getButton("AC", "AC", "command");
|
||||
const resultText = new QLabel();
|
||||
@ -34,9 +34,9 @@ row0.setStyleSheet(`
|
||||
`);
|
||||
const row0Layout = new FlexLayout();
|
||||
row0Layout.setFlexNode(row0.getFlexNode());
|
||||
row0.setLayout(row0Layout);
|
||||
row0Layout.addWidget(btnClear.ui, btnClear.ui.getFlexNode());
|
||||
row0Layout.addWidget(resultText, resultText.getFlexNode());
|
||||
row0.setLayout(row0Layout);
|
||||
|
||||
// First Row
|
||||
const btn7 = getButton("7", 7, "value");
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#include <QDebug>
|
||||
#include <QWidget>
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "src/cpp/core/YogaWidget/yogawidget.h"
|
||||
|
||||
FlexLayout::NodeContext *FlexLayout::getNodeContext(YGNodeRef node)
|
||||
{
|
||||
@ -47,7 +48,12 @@ QSize FlexLayout::sizeHint() const{
|
||||
}
|
||||
|
||||
void FlexLayout::addItem(QLayoutItem * item){
|
||||
spdlog::warn("Unsupported method addItem. item: {}. Use FlexLayout::addWidget instead", reinterpret_cast<ulong>(item));
|
||||
QWidget* childWidget = item->widget();
|
||||
if(childWidget){
|
||||
spdlog::info("flexlayout: addItem - noop for: {}",childWidget->metaObject()->className());
|
||||
return;
|
||||
}
|
||||
spdlog::info("flexlayout: addItem - noop for: {}", reinterpret_cast<ulong>(item));
|
||||
}
|
||||
|
||||
QLayoutItem *FlexLayout::itemAt(int index) const
|
||||
@ -55,9 +61,11 @@ QLayoutItem *FlexLayout::itemAt(int index) const
|
||||
if(!this->node){
|
||||
return nullptr;
|
||||
}
|
||||
spdlog::info("flexlayout: itemAt {}",index);
|
||||
YGNodeRef childNode = YGNodeGetChild(this->node, static_cast<uint>(index));
|
||||
NodeContext *ctx = getNodeContext(childNode);
|
||||
if(!ctx){
|
||||
spdlog::info("flexlayout: itemAt null context {}",index);
|
||||
return nullptr;
|
||||
}
|
||||
return ctx->item;
|
||||
@ -69,6 +77,7 @@ QLayoutItem *FlexLayout::takeAt(int index)
|
||||
NodeContext *ctx = getNodeContext(childNode);
|
||||
QLayoutItem* childLayoutItem = ctx->item;
|
||||
YGNodeRemoveChild(this->node, childNode);
|
||||
spdlog::info("flexlayout: takeAt ",index);
|
||||
delete ctx;
|
||||
return childLayoutItem;
|
||||
}
|
||||
@ -79,6 +88,7 @@ int FlexLayout::count() const
|
||||
return 0;
|
||||
}
|
||||
float childCount = YGNodeGetChildCount(this->node);
|
||||
spdlog::info("flexlayout: count {}",childCount);
|
||||
return static_cast<int>(childCount);
|
||||
|
||||
}
|
||||
@ -89,11 +99,14 @@ void FlexLayout::addWidget(QWidget* childWidget, YGNodeRef childNode)
|
||||
spdlog::warn("Flex layout's parent yoga node not set yet. Set it using setFlexNode. Child widget will not be added to Flex Layout");
|
||||
return;
|
||||
}
|
||||
spdlog::info("flexlayout: addWidget Object: {}",childWidget->metaObject()->className());
|
||||
|
||||
uint count = YGNodeGetChildCount(this->node);
|
||||
YGNodeInsertChild(this->node,childNode, count);
|
||||
QLayoutItem* layoutItem = new QWidgetItem(childWidget);
|
||||
NodeContext* childContext = new NodeContext(layoutItem);
|
||||
YGNodeSetContext(childNode, static_cast<void *>(childContext));
|
||||
QLayout::addWidget(childWidget);
|
||||
}
|
||||
|
||||
void FlexLayout::setGeometry(const QRect &rect)
|
||||
@ -122,7 +135,7 @@ void FlexLayout::setGeometry(const QRect &rect)
|
||||
QWidget* childWidget = childLayoutItem->widget();
|
||||
if(childWidget){
|
||||
childWidget->setGeometry(childRect);
|
||||
spdlog::info("Object: {}, rect: w:{}, h:{}, l:{}, t:{}",childWidget->metaObject()->className(),width,height,left,top);
|
||||
spdlog::info("flexlayout setGeometry: {}, rect: w:{}, h:{}, l:{}, t:{}",childWidget->metaObject()->className(),width,height,left,top);
|
||||
}else {
|
||||
childLayoutItem->setGeometry(childRect);
|
||||
}
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
#ifndef FLEXNODE_WRAP_H
|
||||
#define FLEXNODE_WRAP_H
|
||||
#pragma once
|
||||
#include <napi.h>
|
||||
#include "deps/yoga/YGNode.h"
|
||||
|
||||
@ -22,4 +21,4 @@ class FlexNodeWrap : public Napi::ObjectWrap<FlexNodeWrap>{
|
||||
Napi::Value debugValue(const Napi::CallbackInfo& info);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user