forked from parro-it/libui-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
353 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Automatically generated file. Edits will be lost. | ||
# Based on: autogypi.json | ||
|
||
{ | ||
"includes": [ | ||
"node_modules/nbind/src/nbind-common.gypi" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Automatically generated file. Edits will be lost. | ||
# Based on: autogypi.json | ||
|
||
{ | ||
"include_dirs": [ | ||
"node_modules/nbind/node_modules/nan" | ||
], | ||
"includes": [ | ||
"node_modules/nbind/src/nbind.gypi" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"dependencies": [ | ||
"nbind" | ||
], | ||
"includes": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,23 @@ | ||
{ | ||
"targets": [ | ||
{ | ||
"target_name": "liblibui", | ||
"sources": [ "libui.cc" ], | ||
"include_dirs": [ | ||
"<!(node -e \"require('nan')\")" | ||
"includes": [ | ||
"auto.gypi" | ||
], | ||
"libraries": ["-Wl,-rpath, ../libui/out/libui.so.0"] | ||
"sources": [ | ||
"src/Ui.cc", | ||
"src/UiWindow.cc", | ||
"src/UiControl.cc", | ||
"src/UiEntry.cc", | ||
"src/UiBox.cc" | ||
], | ||
"libraries": [ | ||
"../libui/build/out/libui.so" | ||
|
||
] | ||
} | ||
], | ||
"includes": [ | ||
"auto-top.gypi" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
const bindings = require('bindings'); | ||
module.exports = bindings('libui'); | ||
const nbind = require('nbind'); | ||
const binding = nbind.init(); | ||
|
||
module.exports = binding.lib; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,47 @@ | ||
{ | ||
"name": "libui-node", | ||
"version": "0.0.0", | ||
"description": "Node.js bindings for libui", | ||
"repository": "parro-it/libui-node", | ||
"license": "MIT", | ||
"contributors": [ | ||
"name": "libui-node", | ||
"version": "0.0.0", | ||
"description": "Node.js bindings for libui", | ||
"repository": "parro-it/libui-node", | ||
"license": "MIT", | ||
"contributors": [ | ||
{ | ||
"name": "Chan Guan Hao", | ||
"email": "[email protected]", | ||
"url": "http://mavenave.me" | ||
}, | ||
{ | ||
"name": "Andrea Parodi", | ||
"email": "[email protected]", | ||
"url": "http://www.parro.it" | ||
} | ||
|
||
"name": "Chan Guan Hao", | ||
"email": "[email protected]", | ||
"url": "http://mavenave.me" | ||
}, | ||
{ | ||
"name": "Andrea Parodi", | ||
"email": "[email protected]", | ||
"url": "http://www.parro.it" | ||
} | ||
], | ||
"scripts": { | ||
"test": "LD_LIBRARY_PATH=./libui/out ava && xo", | ||
"start": "LD_LIBRARY_PATH=./libui/out node example.js", | ||
"build-libui": "cd libui && make clean && make", | ||
"build": "node-gyp build" | ||
}, | ||
"keywords": [ | ||
"libui", | ||
"scripts": { | ||
"test": "ava && xo", | ||
"start": "LD_LIBRARY_PATH=./libui/build/out node example.js", | ||
"autogypi": "autogypi", | ||
"node-gyp": "node-gyp", | ||
"configure": "npm run -- autogypi --init-gyp -p nbind -s src/Ui.cc", | ||
"build": "node-gyp configure build || echo failed" | ||
}, | ||
"keywords": [ | ||
"libui", | ||
"desktop", | ||
"GUI" | ||
], | ||
"engines": { | ||
"node": ">=5" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"devDependencies": { | ||
"ava": "^0.14.0", | ||
"xo": "^0.14.0" | ||
}, | ||
"gypfile": true, | ||
"dependencies": { | ||
"bindings": "^1.2.1", | ||
"nan": "^2.3.3" | ||
} | ||
"engines": { | ||
"node": ">=5" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"devDependencies": { | ||
"ava": "^0.14.0", | ||
"xo": "^0.14.0" | ||
}, | ||
"dependencies": { | ||
"autogypi": "^0.2.2", | ||
"nbind": "^0.2.1", | ||
"node-gyp": "^3.3.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include "../libui/ui.h" | ||
#include "nbind/api.h" | ||
#include "nbind/nbind.h" | ||
|
||
struct Ui { | ||
static void main() { | ||
uiMain(); | ||
} | ||
|
||
static void quit() { | ||
uiQuit(); | ||
} | ||
|
||
static void init() { | ||
uiInitOptions o; | ||
memset(&o, 0, sizeof (uiInitOptions)); | ||
const char *err = uiInit(&o); | ||
if (err != NULL) { | ||
NBIND_ERR(err); | ||
uiFreeInitError(err); | ||
} | ||
} | ||
}; | ||
|
||
NBIND_CLASS(Ui) { | ||
method(init); | ||
method(main); | ||
method(quit); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include "../libui/ui.h" | ||
#include "nbind/api.h" | ||
#include "nbind/nbind.h" | ||
#include "ui-node.h" | ||
|
||
UiBox::UiBox() : UiControl( (uiControl*) uiNewVerticalBox() ) {} | ||
|
||
void UiBox::append(UiControl *control, int stretchy) { | ||
uiBoxAppend( | ||
(uiBox *) getHandle(), | ||
control->getHandle(), | ||
stretchy | ||
); | ||
} | ||
|
||
|
||
void UiBox::destroy() { UiControl::destroy(); } | ||
void UiBox::setParent(UiControl *parent) { UiControl::setParent(parent); } | ||
int UiBox::toplevel() { return UiControl::toplevel(); } | ||
int UiBox::getVisible() { return UiControl::getVisible(); } | ||
void UiBox::setVisible(int visible) { UiControl::setVisible(visible); } | ||
int UiBox::getEnabled() { return UiControl::getEnabled(); } | ||
void UiBox::setEnabled(int enabled) { UiControl::setEnabled(enabled); } | ||
|
||
|
||
NBIND_CLASS(UiBox) { | ||
construct<>(); | ||
method(append); | ||
method(destroy); | ||
method(setParent); | ||
method(toplevel); | ||
getset(getVisible, setVisible); | ||
getset(getEnabled, setEnabled); | ||
} | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include "../libui/ui.h" | ||
#include "nbind/api.h" | ||
#include "nbind/nbind.h" | ||
#include "ui-node.h" | ||
|
||
uiControl * UiControl::getHandle() { | ||
return handle; | ||
} | ||
|
||
UiControl::UiControl(uiControl* hnd) { | ||
handle = hnd; | ||
} | ||
|
||
void UiControl::destroy() { | ||
uiControlDestroy(handle); | ||
} | ||
|
||
void UiControl::setParent (UiControl *parent) { | ||
uiControlSetParent(handle, parent->getHandle()); | ||
} | ||
|
||
int UiControl::toplevel() { | ||
return uiControlToplevel(handle); | ||
} | ||
|
||
int UiControl::getVisible() { | ||
return uiControlVisible(handle); | ||
} | ||
|
||
void UiControl::setVisible(int visible) { | ||
if (visible == 1) { | ||
uiControlShow(handle); | ||
} else { | ||
uiControlHide(handle); | ||
} | ||
} | ||
|
||
int UiControl::getEnabled() { | ||
return uiControlEnabled(handle); | ||
} | ||
|
||
void UiControl::setEnabled(int enabled) { | ||
if (enabled == 1) { | ||
uiControlEnable(handle); | ||
} else { | ||
uiControlDisable(handle); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include "../libui/ui.h" | ||
#include "nbind/api.h" | ||
#include "nbind/nbind.h" | ||
#include "ui-node.h" | ||
|
||
|
||
UiEntry::UiEntry() : UiControl( (uiControl*) uiNewEntry() ) {} | ||
|
||
void UiEntry::destroy() { UiControl::destroy(); } | ||
void UiEntry::setParent(UiControl *parent) { UiControl::setParent(parent); } | ||
int UiEntry::toplevel() { return UiControl::toplevel(); } | ||
int UiEntry::getVisible() { return UiControl::getVisible(); } | ||
void UiEntry::setVisible(int visible) { UiControl::setVisible(visible); } | ||
int UiEntry::getEnabled() { return UiControl::getEnabled(); } | ||
void UiEntry::setEnabled(int enabled) { UiControl::setEnabled(enabled); } | ||
|
||
NBIND_CLASS(UiEntry) { | ||
construct<>(); | ||
method(destroy); | ||
method(setParent); | ||
method(toplevel); | ||
getset(getVisible, setVisible); | ||
getset(getEnabled, setEnabled); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include "../libui/ui.h" | ||
#include "ui-node.h" | ||
#include "nbind/api.h" | ||
#include "nbind/nbind.h" | ||
|
||
|
||
static int closing(uiWindow *w, void *data) | ||
{ | ||
uiControlDestroy(uiControl(w)); | ||
return 0; | ||
} | ||
|
||
UiWindow::UiWindow(const char* title, int width, int height, int hasMenubar) { | ||
win = uiNewWindow(title, width, height, hasMenubar); | ||
uiWindowOnClosing(win, closing, NULL); | ||
} | ||
|
||
void UiWindow::show() { | ||
uiControlShow(uiControl(win)); | ||
} | ||
|
||
void UiWindow::close() { | ||
uiControlDestroy(uiControl(win)); | ||
} | ||
|
||
void UiWindow::setMargined(int margined) { | ||
uiWindowSetMargined(win, margined); | ||
} | ||
|
||
int UiWindow::getMargined() { | ||
return uiWindowMargined(win); | ||
} | ||
|
||
void UiWindow::setChild(UiControl *control) { | ||
uiWindowSetChild(win, control->getHandle()); | ||
} | ||
|
||
NBIND_CLASS(UiWindow) { | ||
construct<const char *, int, int, int>(); | ||
method(show); | ||
method(close); | ||
method(setChild); | ||
getset(getMargined, setMargined); | ||
} | ||
|
Oops, something went wrong.