Skip to content

Commit

Permalink
back merged master
Browse files Browse the repository at this point in the history
  • Loading branch information
parro-it committed Jun 27, 2016
2 parents 5d3d754 + 1f1a6f2 commit 50409b5
Show file tree
Hide file tree
Showing 37 changed files with 251 additions and 137 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,8 @@ build
*.dylib

auto*.gypi
_libui

*.h

*.dylib
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "libui"]
path = libui
url = https://github.com/andlabs/libui.git
9 changes: 5 additions & 4 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"src/UiArea/UiAreaMouseEvent.cc",
"src/UiArea/UiArea.cc",
"src/UiArea/UiAreaHandler.cc",
"src/UiForm.cc",
"src/Size.cc",
"src/Point.cc",
"src/Color.cc",
Expand Down Expand Up @@ -47,19 +48,19 @@
"conditions": [
["OS!='mac'", {
'ldflags': [
'-Wl,-rpath,<(module_root_dir)/libui/build/out',
'-Wl,-rpath,<(module_root_dir)',
],
"libraries": [
"../libui/build/out/libui.so"
"<(module_root_dir)/libui.so"
]
}]
],
"xcode_settings": {
"OTHER_LDFLAGS": [
"-Llibui/build/out",
"-L<(module_root_dir)",
"-lui",
"-rpath",
"libui/build/out"
"<(module_root_dir)"
]
}
}
Expand Down
14 changes: 9 additions & 5 deletions examples/core-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ cmb.append('item 2');
cmb.append('item 3');

box.append(cmb, 0);
box.append(new libui.UiDateTimePicker(), 0);
box.append(new libui.UiEditableCombobox(), 0);
box.append(new libui.UiCheckbox('Optionally'), 0);
var hBox4 = new libui.UiHorizontalBox();
hBox4.append(new libui.UiDateTimePicker(), 0);
hBox4.append(new libui.UiVerticalSeparator(), 0);
hBox4.append(new libui.UiEditableCombobox(), 0);
hBox4.append(new libui.UiCheckbox('Optionally'), 0);

box.append(hBox4, 0);

var group = new libui.UiGroup('Options');
var radios = new libui.UiRadioButtons();
Expand All @@ -41,7 +45,7 @@ radios.append('option 3');
group.setChild(radios);
box.append(group, 1);

box.append(new libui.UiSeparator(), 1);
box.append(new libui.UiHorizontalSeparator(), 1);

var hBox2 = new libui.UiHorizontalBox();
var spin = new libui.UiSpinbox(0, 100);
Expand Down Expand Up @@ -75,4 +79,4 @@ tabs.append('text', new libui.UiMultilineEntry());

win.setChild(tabs);
win.show();
libui.Ui.main();
libui.startLoop();
47 changes: 47 additions & 0 deletions examples/forms.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
var libui = require('../index.js');

libui.Ui.init();
var win = new libui.UiWindow('Forms window', 800, 600, false);
win.margined = 1;
win.onClosing(function () {
libui.stopLoop();
});

var hBox = new libui.UiHorizontalBox();
hBox.padded = true;

var name = new libui.UiEntry();
var surname = new libui.UiEntry();
var age = new libui.UiSlider(0, 100);
var JSONData = new libui.UiMultilineEntry();

name.onChanged(setJSON);
surname.onChanged(setJSON);
age.onChanged(setJSON);

name.text = 'Andrea';
surname.text = 'Parodi';
age.value = 40;

var form = new libui.UiForm();
form.padded = true;
form.append('name', name, 0);
form.append('surname', surname, 0);
form.append('age', age, 0);

hBox.append(form, 1);
hBox.append(JSONData, 1);

win.setChild(hBox);
win.show();
libui.startLoop();

function setJSON() {
var data = {
name: name.text,
surname: surname.text,
age: age.value
};
JSONData.text = JSON.stringify(data, null, 4);
}

2 changes: 1 addition & 1 deletion examples/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ const label = mkControl(libui.UiLabel, {
visible: true
});

const separator = mkControl(libui.UiSeparator, {
const separator = mkControl(libui.UiHorizontalSeparator, {
enabled: true,
visible: true
});
Expand Down
1 change: 0 additions & 1 deletion libui
Submodule libui deleted from ec15e2
104 changes: 56 additions & 48 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,50 +1,58 @@
{
"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"
}
],
"scripts": {
"test": "NO_AT_BRIDGE=1 ava && xo",
"start": "NO_AT_BRIDGE=1 node examples/control-gallery.js",
"start-np": "NO_AT_BRIDGE=1 node examples/node-pad.js",
"start-core": "NO_AT_BRIDGE=1 node examples/core-api.js",
"autogypi": "autogypi",
"node-gyp": "node-gyp",
"install": "npm run build:libui && autogypi && npm run build",
"build:libui": "mkdir -p libui/build && cd libui/build && cmake .. && make && cd ../..",
"build": "node-gyp configure build || echo failed"
},
"keywords": [
"libui",
"desktop",
"GUI"
],
"engines": {
"node": ">=0.12"
},
"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"
}
"name": "libui-node",
"version": "0.0.9",
"description": "Node.js bindings for libui",
"repository": "parro-it/libui-node",
"license": "MIT",
"libui": "pre5.alpha.4",
"contributors": [
{
"name": "Chan Guan Hao",
"email": "[email protected]",
"url": "http://mavenave.me"
},
{
"name": "Andrea Parodi",
"email": "[email protected]",
"url": "http://www.parro.it"
}
],
"scripts": {
"test": "NO_AT_BRIDGE=1 ava && xo",
"start": "NO_AT_BRIDGE=1 node examples/control-gallery.js",
"start-np": "NO_AT_BRIDGE=1 node examples/node-pad.js",
"start-core": "NO_AT_BRIDGE=1 node examples/core-api.js",
"autogypi": "autogypi",
"node-gyp": "node-gyp",
"install": "libui-download ${npm_package_libui} && autogypi && npm run build",
"build": "node-gyp configure build",
"clean": "rm -rf build; rm *.h; rm *.dylib"
},
"keywords": [
"libui",
"desktop",
"multiplatform",
"GUI"
],
"engines": {
"node": ">=0.12"
},
"files": [
"index.js",
"src",
"binding.gyp",
"auto-top.gypi",
"auto.gypi",
"autogypi.json"
],
"devDependencies": {
"ava": "^0.14.0",
"xo": "^0.14.0"
},
"dependencies": {
"autogypi": "^0.2.2",
"libui-download": "0.0.3",
"nbind": "^0.2.1",
"node-gyp": "^3.3.1"
}
}
62 changes: 22 additions & 40 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ It could become an awesome, lightweight alternative to Electron to develop multi
</p>

<center>
## OSX
![OSX](https://cloud.githubusercontent.com/assets/11197111/16003613/bf03b908-315d-11e6-9c67-850ace39ffc1.png)
## macOS
![macOS](https://cloud.githubusercontent.com/assets/11197111/16003613/bf03b908-315d-11e6-9c67-850ace39ffc1.png)
</center>


Expand All @@ -32,64 +32,51 @@ It could become an awesome, lightweight alternative to Electron to develop multi
# Node version requirement

The project run on any node version > 0.12.
However, some example in examples folder uses ES6 syntax. We will soon configure babel transpilation for them. Meanwhile, if you are testing the project on Node.js < 6,
you can check `examples/core-api.js` that use Es5 syntax.


# Project status

* All current `libui` API, except for [these ones](https://github.com/parro-it/libui-node/issues?q=is%3Aissue+is%3Aopen+label%3Aenhancement) are implemented.
* I'm developing on `linux`, so this is the preferred platform to test. OSX should work too, but it's not tested. Windows has yet to be configured in build scripts, but it will be supported in further releases.
* There are very few tests developed, but they are passing in `Travis` thank you to @jjrv awesome work.
* All current `libui` API, except for [these ones](https://github.com/parro-it/libui-node/issues?q=is%3Aissue+is%3Aopen+label%3A%22Missing+bind%22) are implemented.
* I'm developing on `linux`, so this is the preferred platform to test. macOS should work too, but it's not tested. Windows has yet to be configured in build scripts, but it will be supported in further releases.
* There are some tests developed, and they are passing in `Travis` thank you to @jjrv awesome work, both on macOS and on Linux, in Node > 0.12
* This is not yet battle-tested in a real app, but the control gallery example you saw in the screenshot above is fully working.

# Build Requirements

* All platforms:
- CMake 2.8.11 or newer
* Windows: either
-Microsoft Visual Studio 2013 or newer (2013 is needed for va_copy())
-MinGW-w64 (other flavors of MinGW may not work)
* Unix: nothing else specific
* Mac OS X: nothing else specific, so long as you can build Cocoa programs

# Installation

We don't publish new versions to NPM yet.
When we will, we are planning to download `libui` binaries directly from its github repo. See some details [here](https://github.com/andlabs/libui/issues/124).

Meanwhile, you have to build `libui` on your machine. This require the use of CMake 2.8.11 or newer.

## Install cmake on OSX:
We had published a first pre-release to npm.
You can now install `libui-node` as a simple dependency in your project:

```bash
brew install cmake
npm install -S libui-node
```

## Install cmake on Debian base Linux distro:
`libui` prebuilt binaries are automatically downloaded after install.

```bash
apt-get install cmake
```
This is tested with:

* Linux 64bit
* Linux 32bit
* macOS

Windows built script is not supported for the moment, I yet hadn't get the time to write build script to it.

You also need to pull the `libui` git submodule to grab it's sources.
# Examples

Some example in examples folder uses ES6 syntax. We will soon configure babel transpilation for them. Meanwhile, if you are testing the project on Node.js < 6, you can check `examples/core-api.js` that use Es5 syntax.

First, you have to clonse the GitHub repo and npm install it:

```bash
git clone https://github.com/parro-it/libui-node.git
git submodule init
git submodule update
npm install
```

To run the control gallery example, type:
Then, to run the control gallery example, type:

```bash
npm start
```

__Note__: There is some problem with then control gallery example on OSX.
We are investigating it, if you are affected, you can meanwhile try the core-api example:
And for the core api, example, type:

```bash
npm run start-core
Expand All @@ -113,10 +100,6 @@ This new API will support transpilation from JSX to further simplify GUI buildin

These works will become in future the base for a React-Native like project.

## Publishing

Since `libui` binaries are relatively small, we plan to precompile them for supported platforms and publish binaries file directly to NPM, to avoid the native build stage on install.

# Contribution & design

* Each `libui` widget implementaion is written in it's own C++ file in `src` folder.
Expand All @@ -131,7 +114,6 @@ Since `libui` binaries are relatively small, we plan to precompile them for supp
* test - run AVA tests && XO linting.
* start - start the control gallery example
* build - rebuild C++ sources
* build:libui - rebuild libui sources under `libui` git submodule

## Related projects

Expand Down
2 changes: 1 addition & 1 deletion src/Color.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "../libui/ui.h"
#include "../ui.h"
#include "ui-node.h"
#include "nbind/nbind.h"

Expand Down
2 changes: 1 addition & 1 deletion src/Point.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "../libui/ui.h"
#include "../ui.h"
#include "ui-node.h"
#include "nbind/nbind.h"

Expand Down
2 changes: 1 addition & 1 deletion src/Size.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "../libui/ui.h"
#include "../ui.h"
#include "ui-node.h"
#include "nbind/nbind.h"

Expand Down
2 changes: 1 addition & 1 deletion src/Ui.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "../libui/ui.h"
#include "../ui.h"
#include "nbind/api.h"
#include "nbind/nbind.h"

Expand Down
2 changes: 1 addition & 1 deletion src/UiBox.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "../libui/ui.h"
#include "../ui.h"
#include "nbind/api.h"
#include "nbind/nbind.h"
#include "ui-node.h"
Expand Down
2 changes: 1 addition & 1 deletion src/UiButton.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "../libui/ui.h"
#include "../ui.h"
#include "nbind/api.h"
#include "nbind/nbind.h"
#include "ui-node.h"
Expand Down
2 changes: 1 addition & 1 deletion src/UiCheckbox.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "../libui/ui.h"
#include "../ui.h"
#include "nbind/api.h"
#include "nbind/nbind.h"
#include "ui-node.h"
Expand Down
Loading

0 comments on commit 50409b5

Please sign in to comment.