removed unnecessary code and cleans up Flexlayout
This commit is contained in:
parent
2aeda4a556
commit
e757f38eb5
4
demo.ts
4
demo.ts
@ -7,7 +7,7 @@ import { QCheckBox } from "./src/lib/QtWidgets/QCheckBox";
|
||||
import { QProgressBar } from "./src/lib/QtWidgets/QProgressBar";
|
||||
import { QRadioButton } from "./src/lib/QtWidgets/QRadioButton";
|
||||
import { QLineEdit } from "./src/lib/QtWidgets/QLineEdit";
|
||||
import { FlexLayout } from "./src/lib/QtWidgets/FlexLayout";
|
||||
import { FlexLayout } from "./src/lib/core/FlexLayout";
|
||||
|
||||
const win = new QMainWindow();
|
||||
const view = new QWidget();
|
||||
@ -21,7 +21,7 @@ const label2 = new QLabel();
|
||||
label2.setText("Hello12321");
|
||||
label2.setStyleSheet("background-color:blue; color:white;");
|
||||
const label2FlexNode = label2.getFlexNode();
|
||||
label2FlexNode.debugValue();
|
||||
console.log("lbl2 flexNode", label2FlexNode.debugValue());
|
||||
const flayout = new FlexLayout();
|
||||
flayout.addWidget(label2, label2FlexNode);
|
||||
|
||||
|
||||
@ -3,6 +3,11 @@
|
||||
|
||||
#include "deps/yoga/YGNode.h"
|
||||
|
||||
/*
|
||||
FlexItem class is used to extend regular QWidget Classes to include Yoga/Flex Node in them.
|
||||
*/
|
||||
|
||||
|
||||
class FlexItem
|
||||
{
|
||||
YGNodeRef node;
|
||||
|
||||
@ -4,6 +4,23 @@
|
||||
#include "deps/yoga/YGNode.h"
|
||||
#include <QLayout>
|
||||
|
||||
/*
|
||||
FlexLayout is a custom Layout built for QT. This layout will be used to layout qt widgets using facebook's yoga library.
|
||||
Thus giving ability to layout Qt Widgets using Flexbox.
|
||||
Usage:
|
||||
QWidget *container = new QWidget();
|
||||
YGNodeRef root = YGNodeNew();
|
||||
YGNodeRef child1 = YGNodeNew();
|
||||
YGNodeRef child2 = YGNodeNew();
|
||||
FlexLayout * flayout = new FlexLayout(container,root);
|
||||
// or FlexLayout * flayout = new FlexLayout(container);
|
||||
// or FlexLayout *flayout = new FlexLayout();
|
||||
|
||||
flayout->addWidget(btn1, child1);
|
||||
flayout->addWidget(btn2, child2);
|
||||
*/
|
||||
|
||||
|
||||
class FlexLayout: public QLayout
|
||||
{
|
||||
private:
|
||||
|
||||
@ -7,7 +7,7 @@ void FlexNodeWrap::init(Napi::Env env) {
|
||||
Napi::HandleScope scope(env);
|
||||
char CLASSNAME[] = "FlexNode";
|
||||
Napi::Function func = DefineClass(env, CLASSNAME, {
|
||||
InstanceMethod("debugValue", &FlexNodeWrap::printValue),
|
||||
InstanceMethod("debugValue", &FlexNodeWrap::debugValue),
|
||||
});
|
||||
constructor = Napi::Persistent(func);
|
||||
}
|
||||
@ -23,7 +23,7 @@ FlexNodeWrap::FlexNodeWrap(const Napi::CallbackInfo& info): Napi::ObjectWrap<Fle
|
||||
|
||||
Napi::Value FlexNodeWrap::debugValue(const Napi::CallbackInfo& info) {
|
||||
uint64_t addr = reinterpret_cast<long>(this->getInternalInstance());
|
||||
return info.Env().Null();
|
||||
return Napi::Number::New(info.Env(), addr);
|
||||
}
|
||||
|
||||
FlexNodeWrap::~FlexNodeWrap() {
|
||||
|
||||
@ -3,6 +3,12 @@
|
||||
#include <napi.h>
|
||||
#include "deps/yoga/YGNode.h"
|
||||
|
||||
/*
|
||||
|
||||
NAPI Wrapper class to export YGNodeRef/Yoga/Flex Node of a Widget
|
||||
*/
|
||||
|
||||
|
||||
//ABSTRACT CLASS
|
||||
class FlexNodeWrap : public Napi::ObjectWrap<FlexNodeWrap>{
|
||||
public:
|
||||
|
||||
@ -7,6 +7,6 @@ export class FlexNode extends Component {
|
||||
this.native = nativeNode;
|
||||
}
|
||||
debugValue() {
|
||||
this.native.debugValue();
|
||||
return this.native.debugValue();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import addon from "../../core/addon";
|
||||
import { Component } from "../../core/Component";
|
||||
import addon from "../addon";
|
||||
import { Component } from "../Component";
|
||||
import { QWidget } from "../../QtGui/QWidget";
|
||||
import { FlexNode } from "../../core/FlexLayout/FlexNode";
|
||||
import { FlexNode } from "./FlexNode";
|
||||
|
||||
export class FlexLayout extends Component {
|
||||
native = new addon.FlexLayout();
|
||||
Loading…
Reference in New Issue
Block a user