Organised code so that its easier to modify all widgets at once.
This commit is contained in:
parent
e77ee16c6e
commit
085c05dd85
@ -1,5 +1,5 @@
|
||||
{
|
||||
"include": "src/cpp/core/YogaWidget/yogawidget.h",
|
||||
"include": "src/cpp/core/NodeWidget/nodewidget.h",
|
||||
"headers": [
|
||||
"src/cpp/QtGui/QWidget/nwidget.h",
|
||||
"src/cpp/QtWidgets/QLabel/nlabel.h",
|
||||
|
||||
@ -1,17 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include <QCheckBox>
|
||||
#include "src/cpp/core/YogaWidget/yogawidget.h"
|
||||
#include "src/cpp/core/Events/eventwidget.h"
|
||||
#include "src/cpp/core/NodeWidget/nodewidget.h"
|
||||
|
||||
class NCheckBox: public QCheckBox, public YogaWidget, public EventWidget
|
||||
class NCheckBox: public QCheckBox, public NodeWidget
|
||||
{
|
||||
|
||||
NODEWIDGET_IMPLEMENTATIONS
|
||||
public:
|
||||
SET_YOGA_WIDGET_Q_PROPERTIES
|
||||
using QCheckBox::QCheckBox; //inherit all constructors of QCheckBox
|
||||
Q_OBJECT
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -1,17 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include "src/cpp/core/YogaWidget/yogawidget.h"
|
||||
#include "src/cpp/core/Events/eventwidget.h"
|
||||
#include "src/cpp/core/NodeWidget/nodewidget.h"
|
||||
|
||||
class NLabel: public QLabel, public YogaWidget, public EventWidget
|
||||
class NLabel: public QLabel, public NodeWidget
|
||||
{
|
||||
|
||||
NODEWIDGET_IMPLEMENTATIONS
|
||||
public:
|
||||
SET_YOGA_WIDGET_Q_PROPERTIES
|
||||
using QLabel::QLabel; //inherit all constructors of QLabel
|
||||
Q_OBJECT
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -1,17 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLineEdit>
|
||||
#include "src/cpp/core/YogaWidget/yogawidget.h"
|
||||
#include "src/cpp/core/Events/eventwidget.h"
|
||||
#include "src/cpp/core/NodeWidget/nodewidget.h"
|
||||
|
||||
class NLineEdit: public QLineEdit, public YogaWidget, public EventWidget
|
||||
class NLineEdit: public QLineEdit, public NodeWidget
|
||||
{
|
||||
|
||||
NODEWIDGET_IMPLEMENTATIONS
|
||||
public:
|
||||
SET_YOGA_WIDGET_Q_PROPERTIES
|
||||
using QLineEdit::QLineEdit; //inherit all constructors of QLineEdit
|
||||
Q_OBJECT
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -1,15 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include <QMainWindow>
|
||||
#include "src/cpp/core/YogaWidget/yogawidget.h"
|
||||
#include "src/cpp/core/Events/eventwidget.h"
|
||||
#include "deps/spdlog/spdlog.h"
|
||||
#include "src/cpp/core/NodeWidget/nodewidget.h"
|
||||
#include <QEvent>
|
||||
|
||||
class NMainWindow: public QMainWindow, public YogaWidget, public EventWidget
|
||||
class NMainWindow: public QMainWindow, public NodeWidget
|
||||
{
|
||||
|
||||
NODEWIDGET_IMPLEMENTATIONS
|
||||
public:
|
||||
using QMainWindow::QMainWindow; //inherit all constructors of QMainWindow
|
||||
private:
|
||||
void calculateLayout(){
|
||||
YGDirection direction = YGNodeStyleGetDirection(this->getFlexNode());
|
||||
@ -28,10 +27,6 @@ private:
|
||||
void resizeEvent(QResizeEvent * event){
|
||||
calculateLayout();
|
||||
}
|
||||
public:
|
||||
SET_YOGA_WIDGET_Q_PROPERTIES
|
||||
using QMainWindow::QMainWindow; //inherit all constructors of QMainWindow
|
||||
Q_OBJECT
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -1,17 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include <QProgressBar>
|
||||
#include "src/cpp/core/YogaWidget/yogawidget.h"
|
||||
#include "src/cpp/core/Events/eventwidget.h"
|
||||
#include "src/cpp/core/NodeWidget/nodewidget.h"
|
||||
|
||||
class NProgressBar: public QProgressBar, public YogaWidget, public EventWidget
|
||||
class NProgressBar: public QProgressBar, public NodeWidget
|
||||
{
|
||||
|
||||
NODEWIDGET_IMPLEMENTATIONS
|
||||
public:
|
||||
SET_YOGA_WIDGET_Q_PROPERTIES
|
||||
using QProgressBar::QProgressBar; //inherit all constructors of QProgressBar
|
||||
Q_OBJECT
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -1,23 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <QPushButton>
|
||||
#include "src/cpp/core/YogaWidget/yogawidget.h"
|
||||
#include "src/cpp/core/Events/eventwidget.h"
|
||||
#include "src/cpp/core/NodeWidget/nodewidget.h"
|
||||
#include "napi.h"
|
||||
|
||||
class NPushButton: public QPushButton, public YogaWidget, public EventWidget
|
||||
class NPushButton: public QPushButton, public NodeWidget
|
||||
{
|
||||
NODEWIDGET_IMPLEMENTATIONS
|
||||
public:
|
||||
SET_YOGA_WIDGET_Q_PROPERTIES
|
||||
using QPushButton::QPushButton; //inherit all constructors of QPushButton
|
||||
Q_OBJECT
|
||||
public:
|
||||
bool event(QEvent* event){
|
||||
EventWidget::event(event);
|
||||
return QWidget::event(event);
|
||||
}
|
||||
|
||||
void connectWidgetSignalsToEventEmitter(){
|
||||
void connectWidgetSignalsToEventEmitter() {
|
||||
// Qt Connects: Implement all signal connects here
|
||||
QObject::connect(this, &QPushButton::clicked, [=](bool checked) {
|
||||
this->emitOnNode->call([=](Napi::Env env, std::vector<napi_value>& args) {
|
||||
|
||||
@ -1,17 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include <QRadioButton>
|
||||
#include "src/cpp/core/YogaWidget/yogawidget.h"
|
||||
#include "src/cpp/core/Events/eventwidget.h"
|
||||
|
||||
class NRadioButton: public QRadioButton, public YogaWidget, public EventWidget
|
||||
{
|
||||
#include "src/cpp/core/NodeWidget/nodewidget.h"
|
||||
|
||||
class NRadioButton: public QRadioButton, public NodeWidget
|
||||
{
|
||||
NODEWIDGET_IMPLEMENTATIONS
|
||||
public:
|
||||
SET_YOGA_WIDGET_Q_PROPERTIES
|
||||
using QRadioButton::QRadioButton; //inherit all constructors of QRadioButton
|
||||
Q_OBJECT
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -292,10 +292,8 @@ void *NCheckBox::qt_metacast(const char *_clname)
|
||||
if (!_clname) return nullptr;
|
||||
if (!strcmp(_clname, qt_meta_stringdata_NCheckBox.stringdata0))
|
||||
return static_cast<void*>(this);
|
||||
if (!strcmp(_clname, "YogaWidget"))
|
||||
return static_cast< YogaWidget*>(this);
|
||||
if (!strcmp(_clname, "EventWidget"))
|
||||
return static_cast< EventWidget*>(this);
|
||||
if (!strcmp(_clname, "NodeWidget"))
|
||||
return static_cast< NodeWidget*>(this);
|
||||
return QCheckBox::qt_metacast(_clname);
|
||||
}
|
||||
|
||||
|
||||
@ -292,10 +292,8 @@ 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);
|
||||
if (!strcmp(_clname, "EventWidget"))
|
||||
return static_cast< EventWidget*>(this);
|
||||
if (!strcmp(_clname, "NodeWidget"))
|
||||
return static_cast< NodeWidget*>(this);
|
||||
return QLabel::qt_metacast(_clname);
|
||||
}
|
||||
|
||||
|
||||
@ -292,10 +292,8 @@ void *NLineEdit::qt_metacast(const char *_clname)
|
||||
if (!_clname) return nullptr;
|
||||
if (!strcmp(_clname, qt_meta_stringdata_NLineEdit.stringdata0))
|
||||
return static_cast<void*>(this);
|
||||
if (!strcmp(_clname, "YogaWidget"))
|
||||
return static_cast< YogaWidget*>(this);
|
||||
if (!strcmp(_clname, "EventWidget"))
|
||||
return static_cast< EventWidget*>(this);
|
||||
if (!strcmp(_clname, "NodeWidget"))
|
||||
return static_cast< NodeWidget*>(this);
|
||||
return QLineEdit::qt_metacast(_clname);
|
||||
}
|
||||
|
||||
|
||||
@ -292,10 +292,8 @@ void *NMainWindow::qt_metacast(const char *_clname)
|
||||
if (!_clname) return nullptr;
|
||||
if (!strcmp(_clname, qt_meta_stringdata_NMainWindow.stringdata0))
|
||||
return static_cast<void*>(this);
|
||||
if (!strcmp(_clname, "YogaWidget"))
|
||||
return static_cast< YogaWidget*>(this);
|
||||
if (!strcmp(_clname, "EventWidget"))
|
||||
return static_cast< EventWidget*>(this);
|
||||
if (!strcmp(_clname, "NodeWidget"))
|
||||
return static_cast< NodeWidget*>(this);
|
||||
return QMainWindow::qt_metacast(_clname);
|
||||
}
|
||||
|
||||
|
||||
@ -292,10 +292,8 @@ void *NProgressBar::qt_metacast(const char *_clname)
|
||||
if (!_clname) return nullptr;
|
||||
if (!strcmp(_clname, qt_meta_stringdata_NProgressBar.stringdata0))
|
||||
return static_cast<void*>(this);
|
||||
if (!strcmp(_clname, "YogaWidget"))
|
||||
return static_cast< YogaWidget*>(this);
|
||||
if (!strcmp(_clname, "EventWidget"))
|
||||
return static_cast< EventWidget*>(this);
|
||||
if (!strcmp(_clname, "NodeWidget"))
|
||||
return static_cast< NodeWidget*>(this);
|
||||
return QProgressBar::qt_metacast(_clname);
|
||||
}
|
||||
|
||||
|
||||
@ -292,10 +292,8 @@ void *NPushButton::qt_metacast(const char *_clname)
|
||||
if (!_clname) return nullptr;
|
||||
if (!strcmp(_clname, qt_meta_stringdata_NPushButton.stringdata0))
|
||||
return static_cast<void*>(this);
|
||||
if (!strcmp(_clname, "YogaWidget"))
|
||||
return static_cast< YogaWidget*>(this);
|
||||
if (!strcmp(_clname, "EventWidget"))
|
||||
return static_cast< EventWidget*>(this);
|
||||
if (!strcmp(_clname, "NodeWidget"))
|
||||
return static_cast< NodeWidget*>(this);
|
||||
return QPushButton::qt_metacast(_clname);
|
||||
}
|
||||
|
||||
|
||||
@ -292,10 +292,8 @@ void *NRadioButton::qt_metacast(const char *_clname)
|
||||
if (!_clname) return nullptr;
|
||||
if (!strcmp(_clname, qt_meta_stringdata_NRadioButton.stringdata0))
|
||||
return static_cast<void*>(this);
|
||||
if (!strcmp(_clname, "YogaWidget"))
|
||||
return static_cast< YogaWidget*>(this);
|
||||
if (!strcmp(_clname, "EventWidget"))
|
||||
return static_cast< EventWidget*>(this);
|
||||
if (!strcmp(_clname, "NodeWidget"))
|
||||
return static_cast< NodeWidget*>(this);
|
||||
return QRadioButton::qt_metacast(_clname);
|
||||
}
|
||||
|
||||
|
||||
25
src/cpp/core/NodeWidget/nodewidget.h
Normal file
25
src/cpp/core/NodeWidget/nodewidget.h
Normal file
@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
#include "src/cpp/core/YogaWidget/yogawidget.h"
|
||||
#include "src/cpp/core/Events/eventwidget.h"
|
||||
|
||||
// class to unify all the custom features + add extra features if needed
|
||||
class NodeWidget : public YogaWidget, public EventWidget {
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#ifndef NODEWIDGET_IMPLEMENTATIONS
|
||||
#define NODEWIDGET_IMPLEMENTATIONS \
|
||||
\
|
||||
Q_OBJECT \
|
||||
public: \
|
||||
SET_YOGA_WIDGET_Q_PROPERTIES \
|
||||
bool event(QEvent* event) { \
|
||||
EventWidget::event(event); \
|
||||
return QWidget::event(event); \
|
||||
} \
|
||||
|
||||
#endif //NODEWIDGET_IMPLEMENTATIONS
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user