Fix Yoga issue and reorder gypi files
This commit is contained in:
parent
67aa261402
commit
e20c458d82
10
binding.gyp
10
binding.gyp
@ -1,8 +1,14 @@
|
||||
{
|
||||
"includes": [
|
||||
'./config/deps.gypi',
|
||||
"./config/application.gypi",
|
||||
"./config/common.gypi",
|
||||
"./config/qt.gypi",
|
||||
"./config/deps.gypi",
|
||||
"./config/moc.gypi",
|
||||
],
|
||||
"targets": []
|
||||
"targets": [{
|
||||
"target_name": "qtnode",
|
||||
# 'type': 'shared_library',
|
||||
'include_dirs': ['.']
|
||||
}]
|
||||
}
|
||||
|
||||
@ -1,36 +1,29 @@
|
||||
{
|
||||
"includes": [
|
||||
"./common.gypi"
|
||||
],
|
||||
"targets": [
|
||||
{
|
||||
"target_name": "qtnode",
|
||||
'include_dirs': ['<(module_root_dir)'],
|
||||
"sources": [
|
||||
"../src/cpp/main.cpp",
|
||||
# non-wrapped cpps
|
||||
"../src/cpp/Extras/Utils/nutils.cpp",
|
||||
"../src/cpp/core/FlexLayout/flexlayout.cpp",
|
||||
"../src/cpp/core/FlexLayout/flexitem.cpp",
|
||||
"../src/cpp/core/YogaWidget/nodestyle.cpp",
|
||||
"../src/cpp/core/Events/eventsmap.cpp",
|
||||
"../src/cpp/core/Events/eventwidget.cpp",
|
||||
"../src/cpp/core/YogaWidget/yogawidget.cpp",
|
||||
# wrapped cpps
|
||||
"../src/cpp/QtGui/QApplication/qapplication_wrap.cpp",
|
||||
"../src/cpp/QtGui/QWidget/qwidget_wrap.cpp",
|
||||
"../src/cpp/QtGui/QEvent/QKeyEvent/qkeyevent_wrap.cpp",
|
||||
'../src/cpp/core/FlexLayout/flexlayout_wrap.cpp',
|
||||
"../src/cpp/QtWidgets/QGridLayout/qgridlayout_wrap.cpp",
|
||||
"../src/cpp/QtWidgets/QLabel/qlabel_wrap.cpp",
|
||||
"../src/cpp/QtWidgets/QLayout/qlayout_wrap.cpp",
|
||||
"../src/cpp/QtWidgets/QMainWindow/qmainwindow_wrap.cpp",
|
||||
"../src/cpp/QtWidgets/QPushButton/qpushbutton_wrap.cpp",
|
||||
"../src/cpp/QtWidgets/QCheckBox/qcheckbox_wrap.cpp",
|
||||
"../src/cpp/QtWidgets/QProgressBar/qprogressbar_wrap.cpp",
|
||||
"../src/cpp/QtWidgets/QRadioButton/qradiobutton_wrap.cpp",
|
||||
"../src/cpp/QtWidgets/QLineEdit/qlineedit_wrap.cpp",
|
||||
],
|
||||
}
|
||||
]
|
||||
"target_defaults": {
|
||||
"sources": [
|
||||
"../src/cpp/main.cpp",
|
||||
# non-wrapped cpps
|
||||
"../src/cpp/Extras/Utils/nutils.cpp",
|
||||
"../src/cpp/core/FlexLayout/flexlayout.cpp",
|
||||
"../src/cpp/core/FlexLayout/flexitem.cpp",
|
||||
"../src/cpp/core/YogaWidget/nodestyle.cpp",
|
||||
"../src/cpp/core/Events/eventsmap.cpp",
|
||||
"../src/cpp/core/Events/eventwidget.cpp",
|
||||
"../src/cpp/core/YogaWidget/yogawidget.cpp",
|
||||
# wrapped cpps
|
||||
"../src/cpp/QtGui/QApplication/qapplication_wrap.cpp",
|
||||
"../src/cpp/QtGui/QWidget/qwidget_wrap.cpp",
|
||||
"../src/cpp/QtGui/QEvent/QKeyEvent/qkeyevent_wrap.cpp",
|
||||
'../src/cpp/core/FlexLayout/flexlayout_wrap.cpp',
|
||||
"../src/cpp/QtWidgets/QGridLayout/qgridlayout_wrap.cpp",
|
||||
"../src/cpp/QtWidgets/QLabel/qlabel_wrap.cpp",
|
||||
"../src/cpp/QtWidgets/QLayout/qlayout_wrap.cpp",
|
||||
"../src/cpp/QtWidgets/QMainWindow/qmainwindow_wrap.cpp",
|
||||
"../src/cpp/QtWidgets/QPushButton/qpushbutton_wrap.cpp",
|
||||
"../src/cpp/QtWidgets/QCheckBox/qcheckbox_wrap.cpp",
|
||||
"../src/cpp/QtWidgets/QProgressBar/qprogressbar_wrap.cpp",
|
||||
"../src/cpp/QtWidgets/QRadioButton/qradiobutton_wrap.cpp",
|
||||
"../src/cpp/QtWidgets/QLineEdit/qlineedit_wrap.cpp",
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +1,4 @@
|
||||
{
|
||||
'includes': [],
|
||||
'type': 'shared_library',
|
||||
'variables': {
|
||||
'qt_home_dir%': "<!(node -p \"require('@nodegui/test').qtHome\")",
|
||||
},
|
||||
'target_defaults': {
|
||||
'cflags!': ['-fno-exceptions'],
|
||||
'cflags_cc!': ['-fno-exceptions'],
|
||||
@ -26,49 +21,9 @@
|
||||
'MACOSX_DEPLOYMENT_TARGET': '10.7',
|
||||
'OTHER_CFLAGS': ['-std=c++14'],
|
||||
},
|
||||
'actions':[
|
||||
{
|
||||
'action_name': 'symlink_qt_headers',
|
||||
'inputs': [],
|
||||
'outputs': [
|
||||
'<(qt_home_dir)/include/QtCore',
|
||||
'<(qt_home_dir)/include/QtGui',
|
||||
'<(qt_home_dir)/include/QtWidgets',
|
||||
],
|
||||
'action': [
|
||||
'sh', '-c',
|
||||
'mkdir -p <(qt_home_dir)/include && \
|
||||
ln -sfn <(qt_home_dir)/lib/QtCore.framework/Versions/5/Headers <(qt_home_dir)/include/QtCore && \
|
||||
ln -sfn <(qt_home_dir)/lib/QtGui.framework/Versions/5/Headers <(qt_home_dir)/include/QtGui && \
|
||||
ln -sfn <(qt_home_dir)/lib/QtWidgets.framework/Versions/5/Headers <(qt_home_dir)/include/QtWidgets'
|
||||
],
|
||||
}
|
||||
],
|
||||
'include_dirs': [
|
||||
'<(qt_home_dir)/include',
|
||||
'<(qt_home_dir)/lib/QtCore.framework/Versions/5/Headers',
|
||||
'<(qt_home_dir)/lib/QtGui.framework/Versions/5/Headers',
|
||||
'<(qt_home_dir)/lib/QtWidgets.framework/Versions/5/Headers',
|
||||
],
|
||||
'libraries': [
|
||||
'<(qt_home_dir)/lib/QtCore.framework/Versions/5/QtCore',
|
||||
'<(qt_home_dir)/lib/QtGui.framework/Versions/5/QtGui',
|
||||
'<(qt_home_dir)/lib/QtWidgets.framework/Versions/5/QtWidgets',
|
||||
],
|
||||
}],
|
||||
['OS=="linux"', {
|
||||
'include_dirs': [
|
||||
'<(qt_home_dir)/include',
|
||||
'<(qt_home_dir)/include/QtCore',
|
||||
'<(qt_home_dir)/include/QtGui',
|
||||
'<(qt_home_dir)/include/QtWidgets',
|
||||
],
|
||||
'libraries': [
|
||||
'<(qt_home_dir)/lib/libQt5Core.so',
|
||||
'<(qt_home_dir)/lib/libQt5Gui.so',
|
||||
'<(qt_home_dir)/lib/libQt5Widgets.so',
|
||||
],
|
||||
'cflags':[
|
||||
'cflags': [
|
||||
'-fPIC'
|
||||
],
|
||||
}],
|
||||
@ -84,18 +39,7 @@
|
||||
},
|
||||
},
|
||||
"defines": [
|
||||
"_HAS_EXCEPTIONS=1"
|
||||
],
|
||||
'include_dirs': [
|
||||
'<(qt_home_dir)\\include',
|
||||
'<(qt_home_dir)\\include\\QtCore',
|
||||
'<(qt_home_dir)\\include\\QtGui',
|
||||
'<(qt_home_dir)\\include\\QtWidgets',
|
||||
],
|
||||
'libraries': [
|
||||
'<(qt_home_dir)\\lib\\Qt5Core.lib',
|
||||
'<(qt_home_dir)\\lib\\Qt5Gui.lib',
|
||||
'<(qt_home_dir)\\lib\\Qt5Widgets.lib',
|
||||
"_HAS_EXCEPTIONS=1",
|
||||
],
|
||||
}],
|
||||
],
|
||||
|
||||
@ -1,21 +1,29 @@
|
||||
{
|
||||
"includes": [],
|
||||
"target_defaults": {
|
||||
"include_dirs": ['../deps/'],
|
||||
"cflags": ['-DSPDLOG_COMPILED_LIB'],
|
||||
"sources": [
|
||||
"../deps/yoga/log.cpp",
|
||||
"../deps/yoga/Utils.cpp",
|
||||
"../deps/yoga/YGConfig.cpp",
|
||||
"../deps/yoga/YGEnums.cpp",
|
||||
"../deps/yoga/YGLayout.cpp",
|
||||
"../deps/yoga/YGNode.cpp",
|
||||
"../deps/yoga/YGNodePrint.cpp",
|
||||
"../deps/yoga/YGStyle.cpp",
|
||||
"../deps/yoga/YGValue.cpp",
|
||||
"../deps/yoga/Yoga.cpp",
|
||||
"../deps/yoga/event/event.cpp",
|
||||
"../deps/yoga/internal/experiments.cpp"
|
||||
"../deps/yoga/log.cpp",
|
||||
"../deps/yoga/Utils.cpp",
|
||||
"../deps/yoga/YGConfig.cpp",
|
||||
"../deps/yoga/YGEnums.cpp",
|
||||
"../deps/yoga/YGLayout.cpp",
|
||||
"../deps/yoga/YGNode.cpp",
|
||||
"../deps/yoga/YGNodePrint.cpp",
|
||||
"../deps/yoga/YGStyle.cpp",
|
||||
"../deps/yoga/YGValue.cpp",
|
||||
"../deps/yoga/Yoga.cpp",
|
||||
"../deps/yoga/event/event.cpp",
|
||||
"../deps/yoga/internal/experiments.cpp"
|
||||
],
|
||||
'defines': [
|
||||
'SPDLOG_COMPILED_LIB'
|
||||
],
|
||||
'conditions': [
|
||||
['OS=="win"', {
|
||||
'defines': [
|
||||
'ENUM_BITFIELDS_NOT_SUPPORTED', # Needed for yoga to work nicely on windows
|
||||
],
|
||||
}]
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,4 +13,4 @@
|
||||
"../src/cpp/autogen/nradiobutton_moc.cpp"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
66
config/qt.gypi
Normal file
66
config/qt.gypi
Normal file
@ -0,0 +1,66 @@
|
||||
{
|
||||
"target_defaults": {
|
||||
'variables': {
|
||||
'qt_home_dir%': "<!(node -p \"require('@nodegui/test').qtHome\")",
|
||||
},
|
||||
'target_conditions': [
|
||||
['OS=="mac"', {
|
||||
'actions': [
|
||||
{
|
||||
'action_name': 'symlink_qt_headers',
|
||||
'inputs': [],
|
||||
'outputs': [
|
||||
'<(qt_home_dir)/include/QtCore',
|
||||
'<(qt_home_dir)/include/QtGui',
|
||||
'<(qt_home_dir)/include/QtWidgets',
|
||||
],
|
||||
'action': [
|
||||
'sh', '-c',
|
||||
'mkdir -p <(qt_home_dir)/include && \
|
||||
ln -sfn <(qt_home_dir)/lib/QtCore.framework/Versions/5/Headers <(qt_home_dir)/include/QtCore && \
|
||||
ln -sfn <(qt_home_dir)/lib/QtGui.framework/Versions/5/Headers <(qt_home_dir)/include/QtGui && \
|
||||
ln -sfn <(qt_home_dir)/lib/QtWidgets.framework/Versions/5/Headers <(qt_home_dir)/include/QtWidgets'
|
||||
],
|
||||
}
|
||||
],
|
||||
'include_dirs': [
|
||||
'<(qt_home_dir)/include',
|
||||
'<(qt_home_dir)/lib/QtCore.framework/Versions/5/Headers',
|
||||
'<(qt_home_dir)/lib/QtGui.framework/Versions/5/Headers',
|
||||
'<(qt_home_dir)/lib/QtWidgets.framework/Versions/5/Headers',
|
||||
],
|
||||
'libraries': [
|
||||
'<(qt_home_dir)/lib/QtCore.framework/Versions/5/QtCore',
|
||||
'<(qt_home_dir)/lib/QtGui.framework/Versions/5/QtGui',
|
||||
'<(qt_home_dir)/lib/QtWidgets.framework/Versions/5/QtWidgets',
|
||||
],
|
||||
}],
|
||||
['OS=="linux"', {
|
||||
'include_dirs': [
|
||||
'<(qt_home_dir)/include',
|
||||
'<(qt_home_dir)/include/QtCore',
|
||||
'<(qt_home_dir)/include/QtGui',
|
||||
'<(qt_home_dir)/include/QtWidgets',
|
||||
],
|
||||
'libraries': [
|
||||
'<(qt_home_dir)/lib/libQt5Core.so',
|
||||
'<(qt_home_dir)/lib/libQt5Gui.so',
|
||||
'<(qt_home_dir)/lib/libQt5Widgets.so',
|
||||
],
|
||||
}],
|
||||
['OS=="win"', {
|
||||
'include_dirs': [
|
||||
'<(qt_home_dir)\\include',
|
||||
'<(qt_home_dir)\\include\\QtCore',
|
||||
'<(qt_home_dir)\\include\\QtGui',
|
||||
'<(qt_home_dir)\\include\\QtWidgets',
|
||||
],
|
||||
'libraries': [
|
||||
'<(qt_home_dir)\\lib\\Qt5Core.lib',
|
||||
'<(qt_home_dir)\\lib\\Qt5Gui.lib',
|
||||
'<(qt_home_dir)\\lib\\Qt5Widgets.lib',
|
||||
]
|
||||
}],
|
||||
],
|
||||
}
|
||||
}
|
||||
48
demo.ts
48
demo.ts
@ -70,7 +70,7 @@ const testGridLayout = () => {
|
||||
// JUSTIFY CONTENT: SPACE-EVENLY, SPACE-AROUND
|
||||
// ALIGNSELF: STRETCH
|
||||
|
||||
const testFlexLayout = () => {
|
||||
const example1 = () => {
|
||||
// rootView -> view1 -> label1
|
||||
// -> label2
|
||||
// -> view2 -> button
|
||||
@ -138,5 +138,49 @@ const testFlexLayout = () => {
|
||||
return win;
|
||||
};
|
||||
|
||||
const example2 = ()=>{
|
||||
const win = new QMainWindow();
|
||||
win.setStyleSheet(`
|
||||
#root {
|
||||
background-color: grey;
|
||||
qproperty-qWidth: '100%';
|
||||
qproperty-qHeight: '100%';
|
||||
qproperty-alignItems: 'center';
|
||||
qproperty-justifyContent: 'center';
|
||||
qproperty-flexDirection: 'row';
|
||||
qproperty-flex: 1;
|
||||
}
|
||||
#view1 {
|
||||
background-color: green;
|
||||
qproperty-flex: 1;
|
||||
qproperty-qHeight: '100%';
|
||||
}
|
||||
#view2 {
|
||||
background-color: orange;
|
||||
qproperty-flex: 1;
|
||||
qproperty-qHeight: '100%';
|
||||
}
|
||||
|
||||
`);
|
||||
const rootView = new QWidget();
|
||||
rootView.setObjectName("root");
|
||||
const rootLayout = new FlexLayout();
|
||||
rootLayout.setFlexNode(rootView.getFlexNode());
|
||||
rootView.setLayout(rootLayout);
|
||||
//--------------------------------------
|
||||
const view1 = new QWidget();
|
||||
view1.setObjectName("view1");
|
||||
//--------------------------------------
|
||||
const view2 = new QWidget();
|
||||
view2.setObjectName("view2");
|
||||
//--------------------------------------
|
||||
rootLayout.addWidget(view1);
|
||||
rootLayout.addWidget(view2);
|
||||
win.setCentralWidget(rootView);
|
||||
win.show();
|
||||
return win;
|
||||
}
|
||||
|
||||
// (global as any).win1 = testGridLayout(); //to keep gc from collecting
|
||||
(global as any).win2 = testFlexLayout(); //to keep gc from collecting
|
||||
// (global as any).ex1 = example1(); //to keep gc from collecting
|
||||
(global as any).ex2 = example2(); //to keep gc from collecting
|
||||
|
||||
Loading…
Reference in New Issue
Block a user