Adds all yoga stylesheet props to qlabel

This commit is contained in:
Atul R 2019-06-03 19:10:33 +02:00
parent 539b343007
commit 26cbc465f0
8 changed files with 130 additions and 7 deletions

View File

@ -212,6 +212,14 @@ To run docs locally,
- 4. `npm run docs:serve` runs docs in development mode.
- 5. `npm run docs:build` to build the docs for publishing in `/docs` folder.
## RUNNING MOC
To run moc:
```sh
moc headername.h -o headername_moc.h
```
#DEBUGGING
https://medium.com/cameron-nokes/how-to-debug-native-node-addons-in-mac-osx-66f69f81afcb

View File

@ -18,6 +18,7 @@
"../src/cpp/QtGui/QApplication/qapplication_wrap.cpp",
"../src/cpp/QtGui/QWidget/qwidget_wrap.cpp",
"../src/cpp/QtWidgets/QGridLayout/qgridlayout_wrap.cpp",
"../src/cpp/QtWidgets/QLabel/nlabel.cpp",
"../src/cpp/QtWidgets/QLabel/qlabel_wrap.cpp",
"../src/cpp/QtWidgets/QLayout/qlayout_wrap.cpp",
"../src/cpp/QtWidgets/QMainWindow/qmainwindow_wrap.cpp",

View File

@ -14,7 +14,7 @@
"typescript": "^3.4.5"
},
"scripts": {
"build:addon": "node-gyp -j 8 rebuild",
"build:addon": "node-gyp -j 8 build",
"build:lib": "rm -rf ./dist/ && tsc",
"dev": "yarn build:lib && qode dist/demo.js"
},

View File

@ -0,0 +1 @@
#include "nlabel_moc.h"

View File

@ -0,0 +1,17 @@
#ifndef N_LABEL_H
#define N_LABEL_H
#include <QWidget>
#include <QLabel>
#include "src/cpp/core/YogaWidget/yogawidget.h"
class NLabel: public QLabel, public YogaWidget
{
public:
using QLabel::QLabel; //inherit all constructors of QLabel
SET_YOGA_WIDGET_Q_PROPERTIES
Q_OBJECT
};
#endif // N_LABEL_H

View File

@ -0,0 +1,96 @@
/****************************************************************************
** Meta object code from reading C++ file 'nlabel.h'
**
** Created by: The Qt Meta Object Compiler version 67 (Qt 5.12.1)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "nlabel.h"
#include <QtCore/qbytearray.h>
#include <QtCore/qmetatype.h>
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'nlabel.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 67
#error "This file was generated using the moc from 5.12.1. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
struct qt_meta_stringdata_NLabel_t {
QByteArrayData data[1];
char stringdata0[7];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
qptrdiff(offsetof(qt_meta_stringdata_NLabel_t, stringdata0) + ofs \
- idx * sizeof(QByteArrayData)) \
)
static const qt_meta_stringdata_NLabel_t qt_meta_stringdata_NLabel = {
{
QT_MOC_LITERAL(0, 0, 6) // "NLabel"
},
"NLabel"
};
#undef QT_MOC_LITERAL
static const uint qt_meta_data_NLabel[] = {
// content:
8, // revision
0, // classname
0, 0, // classinfo
0, 0, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
0 // eod
};
void NLabel::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
Q_UNUSED(_o);
Q_UNUSED(_id);
Q_UNUSED(_c);
Q_UNUSED(_a);
}
QT_INIT_METAOBJECT const QMetaObject NLabel::staticMetaObject = { {
&QLabel::staticMetaObject,
qt_meta_stringdata_NLabel.data,
qt_meta_data_NLabel,
qt_static_metacall,
nullptr,
nullptr
} };
const QMetaObject *NLabel::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}
void *NLabel::qt_metacast(const char *_clname)
{
if (!_clname) return nullptr;
if (!strcmp(_clname, qt_meta_stringdata_NLabel.stringdata0))
return static_cast<void*>(this);
if (!strcmp(_clname, "YogaWidget"))
return static_cast< YogaWidget*>(this);
return QLabel::qt_metacast(_clname);
}
int NLabel::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QLabel::qt_metacall(_c, _id, _a);
return _id;
}
QT_WARNING_POP
QT_END_MOC_NAMESPACE

View File

@ -19,7 +19,7 @@ Napi::Object QLabelWrap::init(Napi::Env env, Napi::Object exports) {
return exports;
}
QLabel* QLabelWrap::getInternalInstance() {
NLabel* QLabelWrap::getInternalInstance() {
return this->instance;
}
@ -31,12 +31,12 @@ QLabelWrap::QLabelWrap(const Napi::CallbackInfo& info): Napi::ObjectWrap<QLabelW
if(info[0].IsObject()){
Napi::Object object_parent = info[0].As<Napi::Object>();
QWidgetWrap* w_parent = Napi::ObjectWrap<QWidgetWrap>::Unwrap(object_parent);
this->instance = new QLabel(w_parent->getInternalInstance()); //this sets the parent to current widget
this->instance = new NLabel(w_parent->getInternalInstance()); //this sets the parent to current widget
}else{
extrautils::throwTypeError(env, "Wrong type of arguments");
}
}else if (info.Length() == 0){
this->instance = new QLabel();
this->instance = new NLabel();
}else {
extrautils::throwTypeError(env, "Wrong number of arguments");
}

View File

@ -1,17 +1,17 @@
#ifndef QLABEL_WRAP_H
#define QLABEL_WRAP_H
#include <napi.h>
#include <QLabel>
#include "nlabel.h"
#include "src/cpp/QtGui/QWidget/qwidget_macro.h"
class QLabelWrap : public Napi::ObjectWrap<QLabelWrap>{
private:
QLabel* instance;
NLabel* instance;
public:
static Napi::Object init(Napi::Env env, Napi::Object exports);
QLabelWrap(const Napi::CallbackInfo& info);
~QLabelWrap();
QLabel* getInternalInstance();
NLabel* getInternalInstance();
//class constructor
static Napi::FunctionReference constructor;
//wrapped methods