From 3f79cd1ce790ff2c52640233fd98a7d7d8d1438d Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Tue, 20 Mar 2018 23:15:57 +0100 Subject: [PATCH 001/190] Attempt to improve (fix) Windows event loop --- src/arch/win32/libui_loop.cc | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/arch/win32/libui_loop.cc b/src/arch/win32/libui_loop.cc index 38efa94..87d6503 100644 --- a/src/arch/win32/libui_loop.cc +++ b/src/arch/win32/libui_loop.cc @@ -67,12 +67,21 @@ int waitForNodeEvents(uv_loop_t* loop, int timeout) { int ret = GetQueuedCompletionStatus(loop->iocp, &bytes, &key, &overlapped, timeout); - /* - // Does we need to requeue the queued completions? - if (ret != 0 && overlapped != NULL) { - printf("node event!\n"); - PostQueuedCompletionStatus(loop->iocp, bytes, key, overlapped); + + // Does we need to requeue the queued completions? + // this happen to be same code used by Electron + // on Windows: + // https://github.com/electron/electron/blob/master/atom/common/node_bindings_win.cc#L24 + // but the application become unstable when this + // part is uncommented. + // See laso this PRs on libuv repo: + // https://github.com/libuv/libuv/pull/1007 + // https://github.com/libuv/libuv/pull/1544 + // https://github.com/libuv/libuv/pull/1651 + if (overlapped != NULL) { + printf("node event!\n"); + PostQueuedCompletionStatus(loop->iocp, bytes, key, overlapped); } - */ + return ret; } From 0c9006d8133a7fa3fadb7acecff2b03576fcb3d3 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Wed, 21 Mar 2018 17:46:21 +0100 Subject: [PATCH 002/190] core api example: add interval and http server to test node event loop integration --- examples/core-api.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/examples/core-api.js b/examples/core-api.js index 53b2581..9b1ed79 100644 --- a/examples/core-api.js +++ b/examples/core-api.js @@ -12,8 +12,26 @@ var box = new libui.UiVerticalBox(); var hBox = new libui.UiHorizontalBox(); var e1 = new libui.UiEntry(); e1.enabled = 0; -hBox.append(new libui.UiLabel("ciao"), false); +var lblCiao = new libui.UiLabel("ciao"); +hBox.append(lblCiao, false); hBox.append(e1, false); +let idxLbl = 0; +setInterval(() => { + lblCiao.text = String(idxLbl++); +}, 1000); +const http = require('http'); +const net = require('net'); +const url = require('url'); + +// Create an HTTP tunneling proxy +const proxy = http.createServer((req, res) => { + lblCiao.text = String(idxLbl++); + res.writeHead(200, { 'Content-Type': 'text/plain' }); + res.end(String(idxLbl)); +}); +proxy.listen(3000, '127.0.0.1', () => { + console.log('listening...'); +}); box.append(new libui.UiEntry(), false); box.append(hBox, false); From a5253e4fe76145a766e402aed3461c8c313070f4 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Wed, 21 Mar 2018 17:48:11 +0100 Subject: [PATCH 003/190] Fixed main GUI loop wake up --- src/arch/darwin/libui_loop.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/arch/darwin/libui_loop.mm b/src/arch/darwin/libui_loop.mm index ab824cd..2d9b659 100644 --- a/src/arch/darwin/libui_loop.mm +++ b/src/arch/darwin/libui_loop.mm @@ -7,8 +7,8 @@ void noop(void* data) {} int uiLoopWakeup() { - dispatch_async(dispatch_get_main_queue(), ^{ - }); + [NSApp postEvent: [NSEvent otherEventWithType: NSApplicationDefined location: NSZeroPoint modifierFlags: 0 timestamp: 0.0 ++ windowNumber: 0 context: nil subtype: 0 data1: 0 data2: 0] atStart: NO]; return 0; } From 4d86348a5453fa1130d79e44885c4e6eaf20de3b Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Wed, 21 Mar 2018 17:48:30 +0100 Subject: [PATCH 004/190] logs & tweaks --- src/EventLoop.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/EventLoop.cc b/src/EventLoop.cc index 1ffb394..32dd3a6 100644 --- a/src/EventLoop.cc +++ b/src/EventLoop.cc @@ -1,5 +1,7 @@ #include #include +#include + #include "../ui.h" #include "nbind/nbind.h" @@ -28,16 +30,20 @@ static void backgroundNodeEventsPoller(void* arg) { if (timeout <= 0) { timeout = 1000; } - int pendingEvents; /* wait for pending */ do { + // printf("entering waitForNodeEvents with timeout %d\n", timeout); pendingEvents = waitForNodeEvents(uv_default_loop(), timeout); + // printf("exit waitForNodeEvents\n"); } while (pendingEvents == -1 && errno == EINTR); + // printf("guiBlocked && pendingEvents %s && %d\n", guiBlocked ? "blocked" : "non blocked", pendingEvents ); if (guiBlocked && pendingEvents > 0) { + printf("wake up neo\n"); uiLoopWakeup(); + usleep(500 * 1000); } } } @@ -60,15 +66,19 @@ void redraw(uv_timer_t* handle) { Nan::HandleScope scope; /* Blocking call that wait for a node or GUI event pending */ + printf("blocking GUI\n"); guiBlocked = true; uiMainStep(true); guiBlocked = false; + printf("unblocking GUI\n"); /* dequeue and run every event pending */ while (uiEventsPending()) { running = uiMainStep(false); } + printf("rescheduling\n"); + /* schedule another call to redraw as soon as possible */ uv_timer_start(handle, redraw, 1, 0); } From a669c4f43252ade2b3f419f27690ee36b185546f Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Wed, 21 Mar 2018 17:56:37 +0100 Subject: [PATCH 005/190] fix & some comments --- src/EventLoop.cc | 7 +++++-- src/arch/darwin/libui_loop.mm | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/EventLoop.cc b/src/EventLoop.cc index 32dd3a6..7329d31 100644 --- a/src/EventLoop.cc +++ b/src/EventLoop.cc @@ -79,8 +79,11 @@ void redraw(uv_timer_t* handle) { printf("rescheduling\n"); - /* schedule another call to redraw as soon as possible */ - uv_timer_start(handle, redraw, 1, 0); + // schedule another call to redraw as soon as possible + // how to find a correct amount of time to scheduke next call? + //.because too long and UI is not responsive, too short and node + // become really slow + uv_timer_start(handle, redraw, 1000, 0); } /* This function start the event loop and exit immediately */ diff --git a/src/arch/darwin/libui_loop.mm b/src/arch/darwin/libui_loop.mm index 2d9b659..d524e0e 100644 --- a/src/arch/darwin/libui_loop.mm +++ b/src/arch/darwin/libui_loop.mm @@ -1,4 +1,5 @@ #import +#import #include #include #include @@ -8,7 +9,7 @@ void noop(void* data) {} int uiLoopWakeup() { [NSApp postEvent: [NSEvent otherEventWithType: NSApplicationDefined location: NSZeroPoint modifierFlags: 0 timestamp: 0.0 -+ windowNumber: 0 context: nil subtype: 0 data1: 0 data2: 0] atStart: NO]; + windowNumber: 0 context: nil subtype: 0 data1: 0 data2: 0] atStart: NO]; return 0; } From 73dd89103526c12a97b4365f050f41d18d1dcdb7 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Wed, 21 Mar 2018 20:27:47 +0100 Subject: [PATCH 006/190] loop improvements on linux --- examples/core-api.js | 30 ++++++++++++++++-------------- src/EventLoop.cc | 25 ++++++++++++++----------- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/examples/core-api.js b/examples/core-api.js index 9b1ed79..9cb1f94 100644 --- a/examples/core-api.js +++ b/examples/core-api.js @@ -1,12 +1,9 @@ - var os = require("os"); +var http = require("http"); var libui = require("../index.js"); var win = new libui.UiWindow("Test window", 800, 600, false); win.margined = 1; -win.onClosing(function () { - libui.stopLoop(); -}); var box = new libui.UiVerticalBox(); var hBox = new libui.UiHorizontalBox(); @@ -15,22 +12,27 @@ e1.enabled = 0; var lblCiao = new libui.UiLabel("ciao"); hBox.append(lblCiao, false); hBox.append(e1, false); -let idxLbl = 0; -setInterval(() => { +var idxLbl = 0; + +var interval = setInterval(function() { lblCiao.text = String(idxLbl++); }, 1000); -const http = require('http'); -const net = require('net'); -const url = require('url'); // Create an HTTP tunneling proxy const proxy = http.createServer((req, res) => { - lblCiao.text = String(idxLbl++); - res.writeHead(200, { 'Content-Type': 'text/plain' }); - res.end(String(idxLbl)); + lblCiao.text = String(idxLbl++); + res.writeHead(200, { "Content-Type": "text/plain" }); + res.end(String(idxLbl)); +}); +proxy.listen(3000, "127.0.0.1", () => { + console.log("listening..."); }); -proxy.listen(3000, '127.0.0.1', () => { - console.log('listening...'); + +win.onClosing(() => { + win.close(); + clearInterval(interval); + proxy.close(); + libui.stopLoop(); }); box.append(new libui.UiEntry(), false); diff --git a/src/EventLoop.cc b/src/EventLoop.cc index 7329d31..b9ec58e 100644 --- a/src/EventLoop.cc +++ b/src/EventLoop.cc @@ -1,6 +1,6 @@ +#include #include #include -#include #include "../ui.h" #include "nbind/nbind.h" @@ -27,23 +27,26 @@ static void backgroundNodeEventsPoller(void* arg) { int timeout = uv_backend_timeout(uv_default_loop()); /* wait for 1s by default */ - if (timeout <= 0) { + if (timeout == 0) { timeout = 1000; } - int pendingEvents; + int pendingEvents = 1; /* wait for pending */ - do { - // printf("entering waitForNodeEvents with timeout %d\n", timeout); - pendingEvents = waitForNodeEvents(uv_default_loop(), timeout); - // printf("exit waitForNodeEvents\n"); - } while (pendingEvents == -1 && errno == EINTR); + if (timeout != -1) { + do { + // printf("entering waitForNodeEvents with timeout %d\n", timeout); + pendingEvents = waitForNodeEvents(uv_default_loop(), timeout); + // printf("exit waitForNodeEvents\n"); + } while (pendingEvents == -1 && errno == EINTR); + } - // printf("guiBlocked && pendingEvents %s && %d\n", guiBlocked ? "blocked" : "non blocked", pendingEvents ); + // printf("guiBlocked && pendingEvents %s && %d\n", guiBlocked ? "blocked" : + // "non blocked", pendingEvents ); if (guiBlocked && pendingEvents > 0) { printf("wake up neo\n"); uiLoopWakeup(); - usleep(500 * 1000); + usleep(50 * 1000); } } } @@ -83,7 +86,7 @@ void redraw(uv_timer_t* handle) { // how to find a correct amount of time to scheduke next call? //.because too long and UI is not responsive, too short and node // become really slow - uv_timer_start(handle, redraw, 1000, 0); + uv_timer_start(handle, redraw, 10, 0); } /* This function start the event loop and exit immediately */ From 531149df23eefa4cab59767a284653052a8bafe4 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Wed, 21 Mar 2018 22:01:20 +0100 Subject: [PATCH 007/190] basic timer support --- src/EventLoop.cc | 11 +++++++---- src/arch/unix/libui_loop.cc | 19 +++++++++++++++++-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/EventLoop.cc b/src/EventLoop.cc index b9ec58e..7e765d7 100644 --- a/src/EventLoop.cc +++ b/src/EventLoop.cc @@ -30,22 +30,25 @@ static void backgroundNodeEventsPoller(void* arg) { if (timeout == 0) { timeout = 1000; } + int pendingEvents = 1; - /* wait for pending */ if (timeout != -1) { do { // printf("entering waitForNodeEvents with timeout %d\n", timeout); + /* wait for pending events*/ pendingEvents = waitForNodeEvents(uv_default_loop(), timeout); // printf("exit waitForNodeEvents\n"); } while (pendingEvents == -1 && errno == EINTR); } - // printf("guiBlocked && pendingEvents %s && %d\n", guiBlocked ? "blocked" : - // "non blocked", pendingEvents ); + printf("guiBlocked && pendingEvents %s && %d\n", + guiBlocked ? "blocked" : "non blocked", pendingEvents); if (guiBlocked && pendingEvents > 0) { - printf("wake up neo\n"); + printf("------ wake up neo\n"); uiLoopWakeup(); + + // give main thread some time to react usleep(50 * 1000); } } diff --git a/src/arch/unix/libui_loop.cc b/src/arch/unix/libui_loop.cc index 3973ee8..8b4182f 100644 --- a/src/arch/unix/libui_loop.cc +++ b/src/arch/unix/libui_loop.cc @@ -16,13 +16,24 @@ int uiEventsPending() { return gtk_events_pending(); } +struct heap_node { + struct heap_node* left; + struct heap_node* right; + struct heap_node* parent; +}; + +struct heap { + struct heap_node* min; + unsigned int nelts; +}; + int waitForNodeEvents(uv_loop_t* loop, int timeout) { // printf("uv_backend_fd\n"); int nodeBackendFd = uv_backend_fd(loop); // printf("uv_backend_fd %d\n", nodeBackendFd); if (nodeBackendFd == -1) { - // printf(stderr, "Invalid node backend fd.\n"); + fprintf(stderr, "Invalid node backend fd.\n"); return 0; } @@ -30,7 +41,11 @@ int waitForNodeEvents(uv_loop_t* loop, int timeout) { // printf("epoll_wait\n"); int ret = epoll_wait(nodeBackendFd, &ev, 1, timeout); + struct heap_node* node = ((struct heap*)&loop->timer_heap)->min; + if (node != NULL) { + return 1; + } + // printf("epoll_wait %d\n", ret); return ret; - } From 30aff633a65becc878b59de88e9b7e8ebfe5df46 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 24 Mar 2018 10:24:30 +0100 Subject: [PATCH 008/190] Reduce timeout in background event thread to a max of 100ms --- src/EventLoop.cc | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/EventLoop.cc b/src/EventLoop.cc index 7e765d7..c937896 100644 --- a/src/EventLoop.cc +++ b/src/EventLoop.cc @@ -27,8 +27,8 @@ static void backgroundNodeEventsPoller(void* arg) { int timeout = uv_backend_timeout(uv_default_loop()); /* wait for 1s by default */ - if (timeout == 0) { - timeout = 1000; + if (timeout == 0 || timeout > 100) { + timeout = 100; } int pendingEvents = 1; @@ -42,10 +42,11 @@ static void backgroundNodeEventsPoller(void* arg) { } while (pendingEvents == -1 && errno == EINTR); } - printf("guiBlocked && pendingEvents %s && %d\n", - guiBlocked ? "blocked" : "non blocked", pendingEvents); + // printf("guiBlocked && pendingEvents %s && %d\n", + // guiBlocked ? "blocked" : "non blocked", pendingEvents); + if (guiBlocked && pendingEvents > 0) { - printf("------ wake up neo\n"); + // printf("------ wake up neo\n"); uiLoopWakeup(); // give main thread some time to react @@ -72,18 +73,18 @@ void redraw(uv_timer_t* handle) { Nan::HandleScope scope; /* Blocking call that wait for a node or GUI event pending */ - printf("blocking GUI\n"); + // printf("blocking GUI\n"); guiBlocked = true; uiMainStep(true); guiBlocked = false; - printf("unblocking GUI\n"); + // printf("unblocking GUI\n"); /* dequeue and run every event pending */ while (uiEventsPending()) { running = uiMainStep(false); } - printf("rescheduling\n"); + // printf("rescheduling\n"); // schedule another call to redraw as soon as possible // how to find a correct amount of time to scheduke next call? From cbf3fdb44ddd02b40787f6ebebb5305556fa9342 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 24 Mar 2018 12:06:58 +0100 Subject: [PATCH 009/190] Extracted event loop includes for commmon & linux --- .gitignore | 3 ++- src/EventLoop.cc | 16 +++++----------- src/arch/unix/libui_loop.cc | 17 +---------------- src/includes/event-loop-linux.h | 27 +++++++++++++++++++++++++++ src/includes/event-loop.h | 14 ++++++++++++++ 5 files changed, 49 insertions(+), 28 deletions(-) create mode 100644 src/includes/event-loop-linux.h create mode 100644 src/includes/event-loop.h diff --git a/.gitignore b/.gitignore index 8529d07..d41c6ef 100644 --- a/.gitignore +++ b/.gitignore @@ -93,7 +93,8 @@ build auto*.gypi _libui -*.h +ui.h +ui*.h *.dylib *.dll diff --git a/src/EventLoop.cc b/src/EventLoop.cc index c937896..58043c5 100644 --- a/src/EventLoop.cc +++ b/src/EventLoop.cc @@ -1,19 +1,11 @@ -#include -#include -#include - -#include "../ui.h" -#include "nbind/nbind.h" - -extern int uiEventsPending(); -extern int uiLoopWakeup(); -extern int waitForNodeEvents(uv_loop_t* loop, int timeout); +#include "includes/event-loop.h" static std::atomic running; static std::atomic guiBlocked; static uv_thread_t* thread; static uv_timer_t* redrawTimer; + /* This function is executed in the background thread and is responsible to continuosly polling @@ -155,7 +147,9 @@ struct EventLoop { /* This function start the event loop and exit immediately */ static void stop() { - // printf("stopping\n"); + if (!running) { + return; + } uv_timer_t* closeTimer = new uv_timer_t(); uv_timer_init(uv_default_loop(), closeTimer); diff --git a/src/arch/unix/libui_loop.cc b/src/arch/unix/libui_loop.cc index 8b4182f..2561d09 100644 --- a/src/arch/unix/libui_loop.cc +++ b/src/arch/unix/libui_loop.cc @@ -1,8 +1,4 @@ -#include -#include -#include -#include -#include +#include "../../includes/event-loop-linux.h" int uiLoopWakeup() { // printf("uiLoopWakeup\n"); @@ -16,17 +12,6 @@ int uiEventsPending() { return gtk_events_pending(); } -struct heap_node { - struct heap_node* left; - struct heap_node* right; - struct heap_node* parent; -}; - -struct heap { - struct heap_node* min; - unsigned int nelts; -}; - int waitForNodeEvents(uv_loop_t* loop, int timeout) { // printf("uv_backend_fd\n"); int nodeBackendFd = uv_backend_fd(loop); diff --git a/src/includes/event-loop-linux.h b/src/includes/event-loop-linux.h new file mode 100644 index 0000000..bd071cf --- /dev/null +++ b/src/includes/event-loop-linux.h @@ -0,0 +1,27 @@ +#ifndef ui_node_evetn_loop_linux +#define ui_node_evetn_loop_linux 1 + +#include +#include +#include +#include +#include + +/* + Internal libuv structures + to deal with timers on macOS + and linux. + */ + +struct heap_node { + struct heap_node* left; + struct heap_node* right; + struct heap_node* parent; +}; + +struct heap { + struct heap_node* min; + unsigned int nelts; +}; + +#endif diff --git a/src/includes/event-loop.h b/src/includes/event-loop.h new file mode 100644 index 0000000..4ca8fc3 --- /dev/null +++ b/src/includes/event-loop.h @@ -0,0 +1,14 @@ +#ifndef ui_node_evetn_loop +#define ui_node_evetn_loop 1 + +#include +#include +#include +#include "../../ui.h" +#include "nbind/nbind.h" + +int uiEventsPending(); +int uiLoopWakeup(); +int waitForNodeEvents(uv_loop_t* loop, int timeout); + +#endif From c87b9fb86b07c21e7de09de852626dd5a4b1155b Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 24 Mar 2018 12:34:32 +0100 Subject: [PATCH 010/190] DEBUG macro for logging --- src/EventLoop.cc | 32 ++++++++++++++++---------------- src/arch/unix/libui_loop.cc | 20 +++++++++++--------- src/includes/event-loop.h | 14 ++++++++++++-- 3 files changed, 39 insertions(+), 27 deletions(-) diff --git a/src/EventLoop.cc b/src/EventLoop.cc index 58043c5..56cec4a 100644 --- a/src/EventLoop.cc +++ b/src/EventLoop.cc @@ -27,18 +27,18 @@ static void backgroundNodeEventsPoller(void* arg) { if (timeout != -1) { do { - // printf("entering waitForNodeEvents with timeout %d\n", timeout); + DEBUG_F("entering waitForNodeEvents with timeout %d\n", timeout); /* wait for pending events*/ pendingEvents = waitForNodeEvents(uv_default_loop(), timeout); - // printf("exit waitForNodeEvents\n"); + DEBUG("exit waitForNodeEvents\n"); } while (pendingEvents == -1 && errno == EINTR); } - // printf("guiBlocked && pendingEvents %s && %d\n", - // guiBlocked ? "blocked" : "non blocked", pendingEvents); + DEBUG_F("guiBlocked && pendingEvents %s && %d\n", + guiBlocked ? "blocked" : "non blocked", pendingEvents); if (guiBlocked && pendingEvents > 0) { - // printf("------ wake up neo\n"); + DEBUG("------ wake up main thread\n"); uiLoopWakeup(); // give main thread some time to react @@ -65,18 +65,18 @@ void redraw(uv_timer_t* handle) { Nan::HandleScope scope; /* Blocking call that wait for a node or GUI event pending */ - // printf("blocking GUI\n"); + DEBUG("blocking GUI\n"); guiBlocked = true; uiMainStep(true); guiBlocked = false; - // printf("unblocking GUI\n"); + DEBUG("unblocking GUI\n"); /* dequeue and run every event pending */ while (uiEventsPending()) { running = uiMainStep(false); } - // printf("rescheduling\n"); + DEBUG("rescheduling next redraw\n"); // schedule another call to redraw as soon as possible // how to find a correct amount of time to scheduke next call? @@ -87,7 +87,7 @@ void redraw(uv_timer_t* handle) { /* This function start the event loop and exit immediately */ void stopAsync(uv_timer_t* handle) { - // printf("stopAsync\n"); + DEBUG("stopAsync\n"); /* if the loop is already running, this is a noop */ if (!running) { @@ -98,16 +98,16 @@ void stopAsync(uv_timer_t* handle) { /* stop redraw handler */ uv_timer_stop(redrawTimer); uv_close((uv_handle_t*)redrawTimer, NULL); - // printf("redrawTimer\n"); + DEBUG("redrawTimer\n"); uv_timer_stop(handle); uv_close((uv_handle_t*)handle, NULL); - // printf("handle\n"); + DEBUG("handle\n"); /* await for the background thread to finish */ - // printf("11\n"); + DEBUG("uv_thread_join\n"); uv_thread_join(thread); - // printf("22\n"); + /* delete handle; delete redrawTimer; @@ -130,19 +130,19 @@ struct EventLoop { /* init libui event loop */ uiMainSteps(); - // // printf("uiMainSteps...\n"); + DEBUG("uiMainSteps...\n"); /* start the background thread that check for node evnts pending */ thread = new uv_thread_t(); uv_thread_create(thread, backgroundNodeEventsPoller, NULL); - // // printf("thread...\n"); + DEBUG("thread...\n"); /* start redraw timer */ redrawTimer = new uv_timer_t(); uv_timer_init(uv_default_loop(), redrawTimer); redraw(redrawTimer); - // // printf("redrawTimer...\n"); + DEBUG("redrawTimer...\n"); } /* This function start the event loop and exit immediately */ diff --git a/src/arch/unix/libui_loop.cc b/src/arch/unix/libui_loop.cc index 2561d09..aba99b3 100644 --- a/src/arch/unix/libui_loop.cc +++ b/src/arch/unix/libui_loop.cc @@ -1,21 +1,22 @@ #include "../../includes/event-loop-linux.h" +#include "../../includes/event-loop.h" int uiLoopWakeup() { - // printf("uiLoopWakeup\n"); + DEBUG("uiLoopWakeup\n"); g_main_context_wakeup(NULL); - // printf("uiLoopWakeup exit\n"); + DEBUG("uiLoopWakeup exit\n"); return 0; } int uiEventsPending() { - // printf("uiEventsPending\n"); + DEBUG("uiEventsPending\n"); return gtk_events_pending(); } int waitForNodeEvents(uv_loop_t* loop, int timeout) { - // printf("uv_backend_fd\n"); + DEBUG("uv_backend_fd\n"); int nodeBackendFd = uv_backend_fd(loop); - // printf("uv_backend_fd %d\n", nodeBackendFd); + DEBUG_F("uv_backend_fd %d\n", nodeBackendFd); if (nodeBackendFd == -1) { fprintf(stderr, "Invalid node backend fd.\n"); @@ -23,14 +24,15 @@ int waitForNodeEvents(uv_loop_t* loop, int timeout) { } struct epoll_event ev; - // printf("epoll_wait\n"); + DEBUG("epoll_wait\n"); int ret = epoll_wait(nodeBackendFd, &ev, 1, timeout); - struct heap_node* node = ((struct heap*)&loop->timer_heap)->min; - if (node != NULL) { + struct heap* timer_heap = (struct heap*)&loop->timer_heap; + struct heap_node* timer_node = timer_heap->min; + if (timer_node != NULL) { return 1; } - // printf("epoll_wait %d\n", ret); + DEBUG_F("epoll_wait %d\n", ret); return ret; } diff --git a/src/includes/event-loop.h b/src/includes/event-loop.h index 4ca8fc3..f23164b 100644 --- a/src/includes/event-loop.h +++ b/src/includes/event-loop.h @@ -1,5 +1,5 @@ -#ifndef ui_node_evetn_loop -#define ui_node_evetn_loop 1 +#ifndef ui_node_event_loop +#define ui_node_event_loop 1 #include #include @@ -7,6 +7,16 @@ #include "../../ui.h" #include "nbind/nbind.h" +#define UI_NODE_DEBUG 1 + +#ifdef UI_NODE_DEBUG +#define DEBUG(msg) fprintf(stderr, msg) +#define DEBUG_F(msg, ...) fprintf(stderr, msg, __VA_ARGS__) +#else +#define DEBUG(msg) ; +#define DEBUG_F(msg, ...) ; +#endif + int uiEventsPending(); int uiLoopWakeup(); int waitForNodeEvents(uv_loop_t* loop, int timeout); From 398d55bb93d9075d78ba24216661ffb954efd6df Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 24 Mar 2018 12:37:08 +0100 Subject: [PATCH 011/190] external include for darwin --- src/arch/darwin/libui_loop.mm | 22 ++++++++++++---------- src/includes/event-loop-darwin.h | 12 ++++++++++++ src/includes/event-loop-linux.h | 4 ++-- 3 files changed, 26 insertions(+), 12 deletions(-) create mode 100644 src/includes/event-loop-darwin.h diff --git a/src/arch/darwin/libui_loop.mm b/src/arch/darwin/libui_loop.mm index d524e0e..083781b 100644 --- a/src/arch/darwin/libui_loop.mm +++ b/src/arch/darwin/libui_loop.mm @@ -1,15 +1,17 @@ -#import -#import -#include -#include -#include -#include -#include -void noop(void* data) {} +#include "../../includes/event-loop-darwin.h" +#include "../../includes/event-loop.h" int uiLoopWakeup() { - [NSApp postEvent: [NSEvent otherEventWithType: NSApplicationDefined location: NSZeroPoint modifierFlags: 0 timestamp: 0.0 - windowNumber: 0 context: nil subtype: 0 data1: 0 data2: 0] atStart: NO]; + [NSApp postEvent:[NSEvent otherEventWithType:NSApplicationDefined + location:NSZeroPoint + modifierFlags:0 + timestamp:0.0 + windowNumber:0 + context:nil + subtype:0 + data1:0 + data2:0] + atStart:NO]; return 0; } diff --git a/src/includes/event-loop-darwin.h b/src/includes/event-loop-darwin.h new file mode 100644 index 0000000..ca5c62c --- /dev/null +++ b/src/includes/event-loop-darwin.h @@ -0,0 +1,12 @@ +#ifndef ui_node_event_loop_darwin +#define ui_node_event_loop_darwin 1 + +#import +#import +#include +#include +#include +#include +#include + +#endif diff --git a/src/includes/event-loop-linux.h b/src/includes/event-loop-linux.h index bd071cf..3c39cc4 100644 --- a/src/includes/event-loop-linux.h +++ b/src/includes/event-loop-linux.h @@ -1,5 +1,5 @@ -#ifndef ui_node_evetn_loop_linux -#define ui_node_evetn_loop_linux 1 +#ifndef ui_node_event_loop_linux +#define ui_node_event_loop_linux 1 #include #include From aa8c782a296880fe595f831ad6c83f48897b28cb Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 24 Mar 2018 12:44:13 +0100 Subject: [PATCH 012/190] lint --- examples/core-api.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/core-api.js b/examples/core-api.js index 9cb1f94..a6e625c 100644 --- a/examples/core-api.js +++ b/examples/core-api.js @@ -14,14 +14,14 @@ hBox.append(lblCiao, false); hBox.append(e1, false); var idxLbl = 0; -var interval = setInterval(function() { +var interval = setInterval(() => { lblCiao.text = String(idxLbl++); }, 1000); // Create an HTTP tunneling proxy const proxy = http.createServer((req, res) => { lblCiao.text = String(idxLbl++); - res.writeHead(200, { "Content-Type": "text/plain" }); + res.writeHead(200, {"Content-Type": "text/plain"}); res.end(String(idxLbl)); }); proxy.listen(3000, "127.0.0.1", () => { From 55fbf09103737eb7148c841132ee7cf43188f5fd Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 24 Mar 2018 21:24:47 +0100 Subject: [PATCH 013/190] Add usleep implementation for windows --- binding.gyp | 1 + src/EventLoop.cc | 3 --- src/arch/darwin/libui_loop.mm | 2 ++ src/arch/unix/libui_loop.cc | 2 ++ src/arch/win32/libui_loop.cc | 9 +++++++-- src/arch/win32/usleep.cc | 14 ++++++++++++++ src/includes/event-loop-linux.h | 1 + src/includes/event-loop-windows.h | 6 ++++++ src/includes/event-loop.h | 1 - 9 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 src/arch/win32/usleep.cc create mode 100644 src/includes/event-loop-windows.h diff --git a/binding.gyp b/binding.gyp index 7aa16cc..97ef1f0 100644 --- a/binding.gyp +++ b/binding.gyp @@ -57,6 +57,7 @@ ["OS=='win'", { "sources": [ "src/arch/win32/libui_loop.cc" + "src/arch/win32/usleep.cc" ], "libraries": [ "<(module_root_dir)/libui.lib" diff --git a/src/EventLoop.cc b/src/EventLoop.cc index 56cec4a..8804b11 100644 --- a/src/EventLoop.cc +++ b/src/EventLoop.cc @@ -40,9 +40,6 @@ static void backgroundNodeEventsPoller(void* arg) { if (guiBlocked && pendingEvents > 0) { DEBUG("------ wake up main thread\n"); uiLoopWakeup(); - - // give main thread some time to react - usleep(50 * 1000); } } } diff --git a/src/arch/darwin/libui_loop.mm b/src/arch/darwin/libui_loop.mm index 083781b..561c1c2 100644 --- a/src/arch/darwin/libui_loop.mm +++ b/src/arch/darwin/libui_loop.mm @@ -12,6 +12,8 @@ int uiLoopWakeup() { data1:0 data2:0] atStart:NO]; + // give main thread some time to react + usleep(50 * 1000); return 0; } diff --git a/src/arch/unix/libui_loop.cc b/src/arch/unix/libui_loop.cc index aba99b3..a535fdf 100644 --- a/src/arch/unix/libui_loop.cc +++ b/src/arch/unix/libui_loop.cc @@ -5,6 +5,8 @@ int uiLoopWakeup() { DEBUG("uiLoopWakeup\n"); g_main_context_wakeup(NULL); DEBUG("uiLoopWakeup exit\n"); + // give main thread some time to react + usleep(50 * 1000); return 0; } diff --git a/src/arch/win32/libui_loop.cc b/src/arch/win32/libui_loop.cc index 38efa94..6b23c48 100644 --- a/src/arch/win32/libui_loop.cc +++ b/src/arch/win32/libui_loop.cc @@ -1,3 +1,6 @@ +#include "../../includes/event-loop-windows.h" +#include "../../includes/event-loop.h" + #include #include #include "../../../ui.h" @@ -52,6 +55,8 @@ void noop(void* data) {} int uiLoopWakeup() { uiQueueMain(noop, NULL); + // give main thread some time to react + usleep(50 * 1000); return 0; } @@ -68,11 +73,11 @@ int waitForNodeEvents(uv_loop_t* loop, int timeout) { int ret = GetQueuedCompletionStatus(loop->iocp, &bytes, &key, &overlapped, timeout); /* - // Does we need to requeue the queued completions? + // Does we need to requeue the queued completions? if (ret != 0 && overlapped != NULL) { printf("node event!\n"); PostQueuedCompletionStatus(loop->iocp, bytes, key, overlapped); } - */ + */ return ret; } diff --git a/src/arch/win32/usleep.cc b/src/arch/win32/usleep.cc new file mode 100644 index 0000000..d80a799 --- /dev/null +++ b/src/arch/win32/usleep.cc @@ -0,0 +1,14 @@ +#include + +void usleep(__int64 usec) { + HANDLE timer; + LARGE_INTEGER ft; + + ft.QuadPart = -(10 * usec); // Convert to 100 nanosecond interval, negative + // value indicates relative time + + timer = CreateWaitableTimer(NULL, TRUE, NULL); + SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0); + WaitForSingleObject(timer, INFINITE); + CloseHandle(timer); +} diff --git a/src/includes/event-loop-linux.h b/src/includes/event-loop-linux.h index 3c39cc4..f81d2c4 100644 --- a/src/includes/event-loop-linux.h +++ b/src/includes/event-loop-linux.h @@ -5,6 +5,7 @@ #include #include #include +#include #include /* diff --git a/src/includes/event-loop-windows.h b/src/includes/event-loop-windows.h new file mode 100644 index 0000000..80d1cdf --- /dev/null +++ b/src/includes/event-loop-windows.h @@ -0,0 +1,6 @@ +#ifndef ui_node_event_loop_windows +#define ui_node_event_loop_windows 1 + +void usleep(__int64 usec); + +#endif diff --git a/src/includes/event-loop.h b/src/includes/event-loop.h index f23164b..9ce7dcc 100644 --- a/src/includes/event-loop.h +++ b/src/includes/event-loop.h @@ -1,7 +1,6 @@ #ifndef ui_node_event_loop #define ui_node_event_loop 1 -#include #include #include #include "../../ui.h" From cd0a93aaceff681bb828783b99230ef22f596b48 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 24 Mar 2018 21:25:47 +0100 Subject: [PATCH 014/190] moved check for stopping non running loop --- src/EventLoop.cc | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/EventLoop.cc b/src/EventLoop.cc index 8804b11..0df4a07 100644 --- a/src/EventLoop.cc +++ b/src/EventLoop.cc @@ -86,12 +86,6 @@ void redraw(uv_timer_t* handle) { void stopAsync(uv_timer_t* handle) { DEBUG("stopAsync\n"); - /* if the loop is already running, this is a noop */ - if (!running) { - return; - } - running = false; - /* stop redraw handler */ uv_timer_stop(redrawTimer); uv_close((uv_handle_t*)redrawTimer, NULL); From 72acc7cd23ed714cefe284d0face1b173bef45ae Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 24 Mar 2018 21:29:48 +0100 Subject: [PATCH 015/190] typo --- binding.gyp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/binding.gyp b/binding.gyp index 97ef1f0..fe54ef4 100644 --- a/binding.gyp +++ b/binding.gyp @@ -56,7 +56,7 @@ "conditions": [ ["OS=='win'", { "sources": [ - "src/arch/win32/libui_loop.cc" + "src/arch/win32/libui_loop.cc", "src/arch/win32/usleep.cc" ], "libraries": [ From 888803b2a13eac38615a79951c511806c155c51d Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 24 Mar 2018 21:41:12 +0100 Subject: [PATCH 016/190] moved uv struct to header --- src/arch/win32/libui_loop.cc | 50 ------------------------------ src/includes/event-loop-windows.h | 51 +++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 50 deletions(-) diff --git a/src/arch/win32/libui_loop.cc b/src/arch/win32/libui_loop.cc index 2d0afb0..bafcd01 100644 --- a/src/arch/win32/libui_loop.cc +++ b/src/arch/win32/libui_loop.cc @@ -1,56 +1,6 @@ #include "../../includes/event-loop-windows.h" #include "../../includes/event-loop.h" -#include -#include -#include "../../../ui.h" - -typedef struct uv_loop_s { - /* User data - use this for whatever. */ - void* data; - /* Loop reference counting. */ - unsigned int active_handles; - void* handle_queue[2]; - void* active_reqs[2]; - /* Internal flag to signal loop stop. */ - unsigned int stop_flag; - /* The loop's I/O completion port */ - HANDLE iocp; - /* The current time according to the event loop. in msecs. - // uint64_t tim - // Tail of a single-linked circular queue of pending reqs. If the queue - // is empty, tail_ is NULL. If there is only one item, - // tail_->next_req == tail_ - void* pending_reqs_tail; - // Head of a single-linked list of closed handles - void* endgame_handles; - // The head of the timers tree - struct uv_timer_tree_s timers; - // Lists of active loop (prepare / check / idle) watchers - uv_prepare_t* prepare_handles; - uv_check_t* check_handles; - uv_idle_t* idle_handles; - // This pointer will refer to the prepare/check/idle handle whose - // callback is scheduled to be called next. This is needed to allow - // safe removal from one of the lists above while that list being - // iterated over. - uv_prepare_t* next_prepare_handle; - uv_check_t* next_check_handle; - uv_idle_t* next_idle_handle; - // This handle holds the peer sockets for the fast variant of uv_poll_t - SOCKET poll_peer_sockets[UV_MSAFD_PROVIDER_COUNT]; - // Counter to keep track of active tcp streams - unsigned int active_tcp_streams; - // Counter to keep track of active udp streams - unsigned int active_udp_streams; - // Counter to started timer - uint64_t timer_counter; - // Threadpool - void* wq[2]; - uv_mutex_t wq_mutex; - uv_async_t wq_async; - */ -} uv_loop_t; void noop(void* data) {} int uiLoopWakeup() { diff --git a/src/includes/event-loop-windows.h b/src/includes/event-loop-windows.h index 80d1cdf..3858fec 100644 --- a/src/includes/event-loop-windows.h +++ b/src/includes/event-loop-windows.h @@ -3,4 +3,55 @@ void usleep(__int64 usec); +#include +#include +#include "../../../ui.h" + +typedef struct uv_loop_s { + /* User data - use this for whatever. */ + void* data; + /* Loop reference counting. */ + unsigned int active_handles; + void* handle_queue[2]; + void* active_reqs[2]; + /* Internal flag to signal loop stop. */ + unsigned int stop_flag; + /* The loop's I/O completion port */ + HANDLE iocp; + /* The current time according to the event loop. in msecs. + // uint64_t tim + // Tail of a single-linked circular queue of pending reqs. If the queue + // is empty, tail_ is NULL. If there is only one item, + // tail_->next_req == tail_ + void* pending_reqs_tail; + // Head of a single-linked list of closed handles + void* endgame_handles; + // The head of the timers tree + struct uv_timer_tree_s timers; + // Lists of active loop (prepare / check / idle) watchers + uv_prepare_t* prepare_handles; + uv_check_t* check_handles; + uv_idle_t* idle_handles; + // This pointer will refer to the prepare/check/idle handle whose + // callback is scheduled to be called next. This is needed to allow + // safe removal from one of the lists above while that list being + // iterated over. + uv_prepare_t* next_prepare_handle; + uv_check_t* next_check_handle; + uv_idle_t* next_idle_handle; + // This handle holds the peer sockets for the fast variant of uv_poll_t + SOCKET poll_peer_sockets[UV_MSAFD_PROVIDER_COUNT]; + // Counter to keep track of active tcp streams + unsigned int active_tcp_streams; + // Counter to keep track of active udp streams + unsigned int active_udp_streams; + // Counter to started timer + uint64_t timer_counter; + // Threadpool + void* wq[2]; + uv_mutex_t wq_mutex; + uv_async_t wq_async; + */ +} uv_loop_t; + #endif From 73b499756a11b13b23d67b402daefd2da6791bb1 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 24 Mar 2018 21:47:41 +0100 Subject: [PATCH 017/190] Fix loop_t redeclaration on windows --- src/arch/win32/libui_loop.cc | 10 ++++++---- src/includes/event-loop-windows.h | 4 ++-- src/includes/event-loop.h | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/arch/win32/libui_loop.cc b/src/arch/win32/libui_loop.cc index bafcd01..b27be09 100644 --- a/src/arch/win32/libui_loop.cc +++ b/src/arch/win32/libui_loop.cc @@ -20,8 +20,10 @@ int waitForNodeEvents(uv_loop_t* loop, int timeout) { ULONG_PTR key; OVERLAPPED* overlapped; - int ret = - GetQueuedCompletionStatus(loop->iocp, &bytes, &key, &overlapped, timeout); + struct _internal_uv_loop_s* _loop = (_internal_uv_loop_s*)loop; + + int ret = GetQueuedCompletionStatus(_loop->iocp, &bytes, &key, &overlapped, + timeout); // Does we need to requeue the queued completions? // this happen to be same code used by Electron @@ -34,8 +36,8 @@ int waitForNodeEvents(uv_loop_t* loop, int timeout) { // https://github.com/libuv/libuv/pull/1544 // https://github.com/libuv/libuv/pull/1651 if (overlapped != NULL) { - printf("node event!\n"); - PostQueuedCompletionStatus(loop->iocp, bytes, key, overlapped); + DEBUG("node event!\n"); + PostQueuedCompletionStatus(_loop->iocp, bytes, key, overlapped); } return ret; diff --git a/src/includes/event-loop-windows.h b/src/includes/event-loop-windows.h index 3858fec..77ffc5d 100644 --- a/src/includes/event-loop-windows.h +++ b/src/includes/event-loop-windows.h @@ -7,7 +7,7 @@ void usleep(__int64 usec); #include #include "../../../ui.h" -typedef struct uv_loop_s { +typedef struct _internal_uv_loop_s { /* User data - use this for whatever. */ void* data; /* Loop reference counting. */ @@ -52,6 +52,6 @@ typedef struct uv_loop_s { uv_mutex_t wq_mutex; uv_async_t wq_async; */ -} uv_loop_t; +}; #endif diff --git a/src/includes/event-loop.h b/src/includes/event-loop.h index 9ce7dcc..fd3e624 100644 --- a/src/includes/event-loop.h +++ b/src/includes/event-loop.h @@ -6,7 +6,7 @@ #include "../../ui.h" #include "nbind/nbind.h" -#define UI_NODE_DEBUG 1 +// #define UI_NODE_DEBUG 1 #ifdef UI_NODE_DEBUG #define DEBUG(msg) fprintf(stderr, msg) From c12a913940fba9ad71d3c25e4c12427a4f44caa3 Mon Sep 17 00:00:00 2001 From: andrea parodi Date: Sat, 24 Mar 2018 21:38:01 +0100 Subject: [PATCH 018/190] Fix loop on windows --- src/arch/darwin/libui_loop.mm | 11 ++++++++++- src/arch/unix/libui_loop.cc | 2 +- src/arch/win32/libui_loop.cc | 5 +++++ src/includes/event-loop-linux.h | 16 ---------------- src/includes/event-loop-windows.h | 6 ++---- src/includes/event-loop.h | 18 ++++++++++++++++++ 6 files changed, 36 insertions(+), 22 deletions(-) diff --git a/src/arch/darwin/libui_loop.mm b/src/arch/darwin/libui_loop.mm index 561c1c2..8537822 100644 --- a/src/arch/darwin/libui_loop.mm +++ b/src/arch/darwin/libui_loop.mm @@ -36,5 +36,14 @@ int waitForNodeEvents(uv_loop_t* loop, int timeout) { struct timespec ts; ts.tv_sec = timeout / 1000; ts.tv_nsec = (timeout % 1000) * 1000000; - return kevent(nodeBackendFd, NULL, 0, &event, 1, &ts); + + int ret = kevent(nodeBackendFd, NULL, 0, &event, 1, &ts); + + struct heap* timer_heap = (struct heap*)&loop->timer_heap; + struct heap_node* timer_node = timer_heap->min; + if (timer_node != NULL) { + return 1; + } + + return ret; } diff --git a/src/arch/unix/libui_loop.cc b/src/arch/unix/libui_loop.cc index a535fdf..aeb76c0 100644 --- a/src/arch/unix/libui_loop.cc +++ b/src/arch/unix/libui_loop.cc @@ -29,7 +29,7 @@ int waitForNodeEvents(uv_loop_t* loop, int timeout) { DEBUG("epoll_wait\n"); int ret = epoll_wait(nodeBackendFd, &ev, 1, timeout); - struct heap* timer_heap = (struct heap*)&loop->timer_heap; + struct heap* timer_heap = (struct heap*)&loop->timers; struct heap_node* timer_node = timer_heap->min; if (timer_node != NULL) { return 1; diff --git a/src/arch/win32/libui_loop.cc b/src/arch/win32/libui_loop.cc index b27be09..7ee2f90 100644 --- a/src/arch/win32/libui_loop.cc +++ b/src/arch/win32/libui_loop.cc @@ -40,5 +40,10 @@ int waitForNodeEvents(uv_loop_t* loop, int timeout) { PostQueuedCompletionStatus(_loop->iocp, bytes, key, overlapped); } + if (loop->timers.rbh_root != NULL) { + return 1; + } + + return ret; } diff --git a/src/includes/event-loop-linux.h b/src/includes/event-loop-linux.h index f81d2c4..f24db5c 100644 --- a/src/includes/event-loop-linux.h +++ b/src/includes/event-loop-linux.h @@ -8,21 +8,5 @@ #include #include -/* - Internal libuv structures - to deal with timers on macOS - and linux. - */ - -struct heap_node { - struct heap_node* left; - struct heap_node* right; - struct heap_node* parent; -}; - -struct heap { - struct heap_node* min; - unsigned int nelts; -}; #endif diff --git a/src/includes/event-loop-windows.h b/src/includes/event-loop-windows.h index 77ffc5d..8c904ba 100644 --- a/src/includes/event-loop-windows.h +++ b/src/includes/event-loop-windows.h @@ -3,11 +3,9 @@ void usleep(__int64 usec); -#include #include -#include "../../../ui.h" -typedef struct _internal_uv_loop_s { +struct _internal_uv_loop_s { /* User data - use this for whatever. */ void* data; /* Loop reference counting. */ @@ -17,7 +15,7 @@ typedef struct _internal_uv_loop_s { /* Internal flag to signal loop stop. */ unsigned int stop_flag; /* The loop's I/O completion port */ - HANDLE iocp; + void * iocp; /* The current time according to the event loop. in msecs. // uint64_t tim // Tail of a single-linked circular queue of pending reqs. If the queue diff --git a/src/includes/event-loop.h b/src/includes/event-loop.h index fd3e624..43f28ee 100644 --- a/src/includes/event-loop.h +++ b/src/includes/event-loop.h @@ -20,4 +20,22 @@ int uiEventsPending(); int uiLoopWakeup(); int waitForNodeEvents(uv_loop_t* loop, int timeout); + +/* + Internal libuv structures + to deal with timers on macOS + and linux. + */ + +struct heap_node { + struct heap_node* left; + struct heap_node* right; + struct heap_node* parent; +}; + +struct heap { + struct heap_node* min; + unsigned int nelts; +}; + #endif From 3534ede5966da3b501cb38ba1894516b6a22f5fb Mon Sep 17 00:00:00 2001 From: andrea parodi Date: Sat, 24 Mar 2018 21:39:49 +0100 Subject: [PATCH 019/190] Fix stopLoop --- src/EventLoop.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/EventLoop.cc b/src/EventLoop.cc index 0df4a07..e1883ac 100644 --- a/src/EventLoop.cc +++ b/src/EventLoop.cc @@ -141,6 +141,8 @@ struct EventLoop { if (!running) { return; } + + running = false; uv_timer_t* closeTimer = new uv_timer_t(); uv_timer_init(uv_default_loop(), closeTimer); From 40064a225d39f614e2408d6ddb9f367151c99b11 Mon Sep 17 00:00:00 2001 From: andrea parodi Date: Sat, 24 Mar 2018 21:44:37 +0100 Subject: [PATCH 020/190] Fix loop on unix --- src/arch/unix/libui_loop.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arch/unix/libui_loop.cc b/src/arch/unix/libui_loop.cc index aeb76c0..a535fdf 100644 --- a/src/arch/unix/libui_loop.cc +++ b/src/arch/unix/libui_loop.cc @@ -29,7 +29,7 @@ int waitForNodeEvents(uv_loop_t* loop, int timeout) { DEBUG("epoll_wait\n"); int ret = epoll_wait(nodeBackendFd, &ev, 1, timeout); - struct heap* timer_heap = (struct heap*)&loop->timers; + struct heap* timer_heap = (struct heap*)&loop->timer_heap; struct heap_node* timer_node = timer_heap->min; if (timer_node != NULL) { return 1; From a1a70e8c086b6e9ac3038caae69361648c968450 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 24 Mar 2018 22:54:00 +0100 Subject: [PATCH 021/190] Reverted event loop stop change --- src/EventLoop.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/EventLoop.cc b/src/EventLoop.cc index e1883ac..3e96ca4 100644 --- a/src/EventLoop.cc +++ b/src/EventLoop.cc @@ -84,6 +84,12 @@ void redraw(uv_timer_t* handle) { /* This function start the event loop and exit immediately */ void stopAsync(uv_timer_t* handle) { + if (!running) { + return; + } + + running = false; + DEBUG("stopAsync\n"); /* stop redraw handler */ @@ -138,12 +144,6 @@ struct EventLoop { /* This function start the event loop and exit immediately */ static void stop() { - if (!running) { - return; - } - - running = false; - uv_timer_t* closeTimer = new uv_timer_t(); uv_timer_init(uv_default_loop(), closeTimer); uv_timer_start(closeTimer, stopAsync, 1, 0); From e88d1c1d5a855a80a11a3ccc6bdb7727b8d2ec49 Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Mon, 26 Mar 2018 00:26:29 +0200 Subject: [PATCH 022/190] Font header --- src/UiFontButton.cc | 30 ++++---- src/ui-node.h | 170 +++++++++++++++++++++++++++++++++----------- 2 files changed, 146 insertions(+), 54 deletions(-) diff --git a/src/UiFontButton.cc b/src/UiFontButton.cc index bba02f3..124c8c3 100644 --- a/src/UiFontButton.cc +++ b/src/UiFontButton.cc @@ -3,19 +3,25 @@ #include "nbind/nbind.h" #include "ui-node.h" -UiFontButton::UiFontButton() : UiControl((uiControl*)uiNewFontButton()) {} +// UiFontButton::UiFontButton() : UiControl((uiControl*)uiNewFontButton()) {} -INHERITS_CONTROL_METHODS(UiFontButton) +// INHERITS_CONTROL_METHODS(uiFontButton) -IMPLEMENT_EVENT(UiFontButton, uiFontButton, onChanged, uiFontButtonOnChanged) +// IMPLEMENT_EVENT(UiFontButton, uiFontButton, onChanged, uiFontButtonOnChanged) -DrawTextFont* UiFontButton::getFont() { - return new DrawTextFont(uiFontButtonFont((uiFontButton*)getHandle())); -} +// UiFontDescriptor* UiFontButton::getFont() { +// uiFontDescriptor *desc = new UiFontDescriptor(); +// uiFontButtonFont((uiFontButton*)getHandle(), desc); +// return desc; +// //TODO: uiFreeFontButtonFont +// } -NBIND_CLASS(UiFontButton) { - construct<>(); - DECLARE_CHILD_CONTROL_METHODS() - method(getFont); - method(onChanged); -} +// NBIND_CLASS(UiFontButton) { +// construct<>(); +// DECLARE_CHILD_CONTROL_METHODS() +// method(getFont); +// method(onChanged); +// } + + +DONT' COMPILE \ No newline at end of file diff --git a/src/ui-node.h b/src/ui-node.h index a23151a..68a7c3b 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -635,74 +635,160 @@ class UiDrawPath { void end(); }; -class DrawTextFontMetrics { - private: - uiDrawTextFontMetrics* m; - public: - DrawTextFontMetrics(uiDrawTextFontMetrics* metrics); - double getAscent(); - double getDescent(); - double getLeading(); - double getUnderlinePos(); - double getUnderlineThickness(); -}; +//TODO how to expose to js? +enum class UiAttributeType { + Family = uiAttributeTypeFamily, + Size = uiAttributeTypeSize, + Weight = uiAttributeTypeWeight, + Italic = uiAttributeTypeItalic, + Stretch = uiAttributeTypeStretch, + Color = uiAttributeTypeColor, + Background = uiAttributeTypeBackground, + Underline = uiAttributeTypeUnderline, + UnderlineColor = uiAttributeTypeUnderlineColor, + Features = uiAttributeTypeFeatures +}; + +enum class UiTextWeight { + Minimum, + Thin, + UltraLight, + Light, + Book, + Normal, + Medium, + SemiBold, + Bold, + UltraBold, + Heavy, + UltraHeavy, + Maximum +}; + +enum class UiTextItalic { + Normal, + Oblique, + Italic +}; + +enum class UiTextStretch { + UltraCondensed, + ExtraCondensed, + Condensed, + SemiCondensed, + Normal, + SemiExpanded, + Expanded, + ExtraExpanded, + UltraExpanded +}; + +enum class UiTextUnderline { + None, + Single, + Double, + Suggestion +}; + +enum class UiTextUnderlineColor { + Custom, + Spelling, + Grammar, + Auxiliary +}; + +class UiFontAttribute { + private: + uiAttribute* a; + + public: + UiFontAttribute() = delete; + + UiAttributeType getAttributeType(UiFontAttribute*); + + //TODO need to actually be of that type + const char *uiAttributeFamily(); + double uiAttributeSize(); + uiTextWeight uiAttributeWeight(); + uiTextItalic uiAttributeItalic(); + uiTextStretch uiAttributeStretch(); + void uiAttributeColor(double *r, double *g, double *b, double *alpha); + uiUnderline uiAttributeUnderline(); + void uiAttributeUnderlineColor(UiTextUnderlineColor *u, double *r, double *g, double *b, double *alpha); + + static UiFontAttribute *newFamilyAttribute(const char *family); + static UiFontAttribute *newSizeAttribute(double size); + static UiFontAttribute *uiNewWeightAttribute(UiTextWeight weight); + static UiFontAttribute *newItalicAttribute(UiTextItalic italic); + static UiFontAttribute *newStretchAttribute(UiTextStretch stretch); + static UiFontAttribute *newColorAttribute(double r, double g, double b, double a); + static UiFontAttribute *newBackgroundAttribute(double r, double g, double b, double a); + static UiFontAttribute *newUnderlineAttribute(UiTextUnderline u); + static UiFontAttribute *newUnderlineColorAttribute(UiTextUnderlineColor u, double r, double g, double b, double a); +}; + + +class UiAttributedString { + private: + uiAttributedString* s; + public: + UiAttributedString(const char *str); + void free(); + const char * toString(); + size_t toStringLen(); + + void appendUnattributed(const char *str); + void insertUnattributed(const char *str, size_t at); + void deleteString(size_t start, size_t end); + void setAttribute(uiAttribute *a, size_t start, size_t end); + // void forEachAttribute(uiAttributedStringForEachAttributeFunc f, void *data); -class DrawTextFontDescriptor { - private: - uiDrawTextFontDescriptor* d; + size_t numGraphemes(); + size_t byteIndexToGrapheme(size_t pos); + size_t graphemeToByteIndex(size_t pos); - public: - DrawTextFontDescriptor(uiDrawTextFontDescriptor* descr); - const char* getFamily(); - double getSize(); - int getWeight(); - int getItalic(); - int getStretch(); }; -class DrawTextFont { - private: - uiDrawTextFont* handle; - - public: - DrawTextFont(); - DrawTextFont(uiDrawTextFont* h); +class UiFontDescriptor { + private: + uiFontDescriptor *d; + public: + UiFontDescriptor(char *family, double size, UiTextWeight weight, UiTextItalic italic, UiTextStretch stretch); - uiDrawTextFont* getHandle(); - void free(); - DrawTextFontDescriptor* describe(); - DrawTextFontMetrics* getMetrics(); +}; - static std::vector listFontFamilies(); - void loadClosestFont(const char* family, double size, int weight, int italic, - int stretch); +//TODO with or without "Draw"? +enum class UiDrawTextAlign { + Left = uiDrawTextAlignLeft, + Center = uiDrawTextAlignCenter, + Right = uiDrawTextAlignRight }; + + class UiFontButton : public UiControl { DEFINE_EVENT(onChanged) public: UiFontButton(); - DrawTextFont* getFont(); + UiFontDescriptor* getFont(); DEFINE_CONTROL_METHODS() }; + class DrawTextLayout { private: uiDrawTextLayout* handle; - double w; public: - DrawTextLayout(const char* text, DrawTextFont* defaultFont, double width); + DrawTextLayout(uiAttributedString *s, uiFontDescriptor *defaultFont, double width, uiDrawTextAlign align); void free(); - void setWidth(double value); - double getWidth(); SizeDouble getExtents(); uiDrawTextLayout* getHandle(); - void setColor(int startChar, int endChar, Color color); }; + class UiDrawContext { private: uiDrawContext* c; @@ -715,7 +801,7 @@ class UiDrawContext { void clip(UiDrawPath* path); void save(); void restore(); - void text(double x, double y, DrawTextLayout* layout); + void text(double x, double y, uiDrawTextLayout* layout); }; class UiAreaDrawParams { From d8e3db829954f886fe2974ed9d277ba52904c0eb Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Mon, 26 Mar 2018 12:19:29 +0200 Subject: [PATCH 023/190] Work --- binding.gyp | 2 - index.js | 68 +++++++++++++---- src/UiArea/DrawTextFont.cc | 64 ---------------- src/UiArea/DrawTextFontDescriptor.cc | 49 ++++++++---- src/UiArea/DrawTextFontMetrics.cc | 38 ---------- src/UiArea/DrawTextLayout.cc | 39 ++-------- src/UiFontButton.cc | 31 ++++---- src/ui-node.h | 108 ++++++--------------------- 8 files changed, 131 insertions(+), 268 deletions(-) delete mode 100644 src/UiArea/DrawTextFont.cc delete mode 100644 src/UiArea/DrawTextFontMetrics.cc diff --git a/binding.gyp b/binding.gyp index 7aa16cc..30f439d 100644 --- a/binding.gyp +++ b/binding.gyp @@ -8,9 +8,7 @@ "sources": [ "src/EventLoop.cc", "src/UiFontButton.cc", - "src/UiArea/DrawTextFont.cc", "src/UiArea/DrawTextFontDescriptor.cc", - "src/UiArea/DrawTextFontMetrics.cc", "src/UiArea/DrawTextLayout.cc", "src/UiArea/UiArea.cc", "src/UiArea/DrawStrokeParams.cc", diff --git a/index.js b/index.js index b5ac8bf..71c85c4 100755 --- a/index.js +++ b/index.js @@ -78,17 +78,19 @@ SizeDouble.prototype.fromJS = fromJSSizeDouble; binding.bind('SizeDouble', SizeDouble); const textWeight = { - thin: 0, - ultraLight: 1, - light: 2, - book: 3, - normal: 4, - medium: 5, - semiBold: 6, - bold: 7, - utraBold: 8, - heavy: 9, - ultraHeavy: 10 + minimum: 0, + thin: 100, + ultraLight: 200 + light: 300, + book: 350, + normal: 400, + medium: 500, + semiBold: 600, + bold: 700, + ultraBold: 800, + heavy: 900, + ultraHeavy: 950 + maximum: 1000 }; const textItalic = { @@ -109,9 +111,49 @@ const textStretch = { ultraExpanded: 8 }; -module.exports.textStretch = textStretch; -module.exports.textItalic = textItalic; + +const textAttributeType = { + Family: 0, + Size: 1, + Weight: 2, + Italic: 3, + Stretch: 4, + Color: 5, + Background: 6, + Underline: 7, + UnderlineColor: 8, + Features: 9 +}; + + +const textUnderline = { + None: 0, + Single: 1, + Double: 2, + Suggestion: 3 +}; + +const textUnderlineColor = { + Custom: 0, + Spelling: 1, + Grammar: 2, + Auxiliary: 3 +}; + +const textAlign = { + Left: 0, + Center: 1, + Right: 2 +}; + + module.exports.textWeight = textWeight; +module.exports.textItalic = textItalic; +module.exports.textStretch = textStretch; +module.exports.textAttributeType = textAttributeType; +module.exports.textUnderline = textUnderline; +module.exports.textUnderlineColor = textUnderlineColor; +module.exports.textAlign = textAlign; module.exports.Size = Size; module.exports.Point = Point; module.exports.Color = Color; diff --git a/src/UiArea/DrawTextFont.cc b/src/UiArea/DrawTextFont.cc deleted file mode 100644 index cbdcc83..0000000 --- a/src/UiArea/DrawTextFont.cc +++ /dev/null @@ -1,64 +0,0 @@ -#include "../../ui.h" -#include "../ui-node.h" -#include "nbind/nbind.h" - - -DrawTextFont::DrawTextFont () {} -DrawTextFont::DrawTextFont (uiDrawTextFont * h) { - handle = h; -} - -uiDrawTextFont * DrawTextFont::getHandle () { - return handle; -} - -void DrawTextFont::free() { - uiDrawFreeTextFont(handle); -} - -DrawTextFontDescriptor * DrawTextFont::describe() { - uiDrawTextFontDescriptor * desc = new uiDrawTextFontDescriptor(); - uiDrawTextFontDescribe(handle, desc); - return new DrawTextFontDescriptor(desc); -} - -DrawTextFontMetrics * DrawTextFont::getMetrics() { - uiDrawTextFontMetrics * metrics = new uiDrawTextFontMetrics(); - uiDrawTextFontGetMetrics(handle, metrics); - return new DrawTextFontMetrics(metrics); -} - -std::vector DrawTextFont::listFontFamilies() { - uiDrawFontFamilies * families = uiDrawListFontFamilies(); - int numFamilies = uiDrawFontFamiliesNumFamilies(families); - std::vector result(numFamilies); - - for (int i = 0; i < numFamilies; i++) { - result[i] = uiDrawFontFamiliesFamily(families, i); - } - - uiDrawFreeFontFamilies(families); - - return result; -} - -void DrawTextFont::loadClosestFont(const char *family, double size, int weight, int italic, int stretch) { - uiDrawTextFontDescriptor *descr = new uiDrawTextFontDescriptor(); - descr->Family = family; - descr->Size = size; - descr->Weight = weight; - descr->Italic = italic; - descr->Stretch = stretch; - - handle = uiDrawLoadClosestFont(descr); -// printf("font handle %p\n", handle); -} - -NBIND_CLASS(DrawTextFont) { - construct<>(); - method(listFontFamilies); - method(loadClosestFont); - method(free); - method(describe); - method(getMetrics); -} diff --git a/src/UiArea/DrawTextFontDescriptor.cc b/src/UiArea/DrawTextFontDescriptor.cc index e9e7704..2a76c91 100644 --- a/src/UiArea/DrawTextFontDescriptor.cc +++ b/src/UiArea/DrawTextFontDescriptor.cc @@ -2,35 +2,56 @@ #include "../ui-node.h" #include "nbind/nbind.h" +UiFontDescriptor::UiFontDescriptor(uiFontDescriptor * desc) { + d = desc; + cleanup = 1; +} + +UiFontDescriptor::UiFontDescriptor(char *family, double size, int weight, int italic, int stretch) { + d = new uiFontDescriptor(); + d->Family = family; + d->Size = size; + d->Weight = weight; + d->Italic = italic + d->Stretch = stretch; +} -const char * DrawTextFontDescriptor::getFamily() { - return d->Family; +UiFontDescriptor::~UiFontDescriptor(){ + if(cleanup){ + uiFreeFontButtonFont(d); + } + delete d; } -double DrawTextFontDescriptor::getSize() { - return d->Size; +char *UiFontDescriptor::getFamily() { + return m->Family; } -int DrawTextFontDescriptor::getWeight() { - return d->Weight; +double UiFontDescriptor::getSize() { + return m->Size; } -int DrawTextFontDescriptor::getItalic() { - return d->Italic; +int UiFontDescriptor::getWeight() { + return m->Weight; } -int DrawTextFontDescriptor::getStretch() { - return d->Stretch; +int UiFontDescriptor::getItalic() { + return m->Italic; } -DrawTextFontDescriptor::DrawTextFontDescriptor(uiDrawTextFontDescriptor * descr) { - d = descr; +int UiFontDescriptor::getStetch() { + return m->Stretch; } -NBIND_CLASS(DrawTextFontDescriptor) { +uiFontDescriptor *UiFontDescriptor::getHandle(){ + return m; +} + + +NBIND_CLASS(UiFontDescriptor) { method(getFamily); method(getSize); method(getWeight); method(getItalic); - method(getStretch); + method(getStetch); } diff --git a/src/UiArea/DrawTextFontMetrics.cc b/src/UiArea/DrawTextFontMetrics.cc deleted file mode 100644 index 9ccb90c..0000000 --- a/src/UiArea/DrawTextFontMetrics.cc +++ /dev/null @@ -1,38 +0,0 @@ -#include "../../ui.h" -#include "../ui-node.h" -#include "nbind/nbind.h" - - - -DrawTextFontMetrics::DrawTextFontMetrics(uiDrawTextFontMetrics * metrics) { - m = metrics; -} - -double DrawTextFontMetrics::getAscent() { - return m->Ascent; -} - -double DrawTextFontMetrics::getDescent() { - return m->Descent; -} - -double DrawTextFontMetrics::getLeading() { - return m->Leading; -} - -double DrawTextFontMetrics::getUnderlinePos() { - return m->UnderlinePos; -} - -double DrawTextFontMetrics::getUnderlineThickness() { - return m->UnderlineThickness; -} - - -NBIND_CLASS(DrawTextFontMetrics) { - method(getAscent); - method(getDescent); - method(getLeading); - method(getUnderlinePos); - method(getUnderlineThickness); -} diff --git a/src/UiArea/DrawTextLayout.cc b/src/UiArea/DrawTextLayout.cc index 5f34f37..956ed0d 100644 --- a/src/UiArea/DrawTextLayout.cc +++ b/src/UiArea/DrawTextLayout.cc @@ -2,24 +2,16 @@ #include "../ui-node.h" #include "nbind/nbind.h" -DrawTextLayout::DrawTextLayout(const char *text, DrawTextFont *defaultFont, double width) { - handle = uiDrawNewTextLayout(text, defaultFont->getHandle(), width); - w = width; +DrawTextLayout::DrawTextLayout(const char *text, UiFontDescriptor *defaultFont, double width, int align) { + handle = uiDrawNewTextLayout({ + text, defaultFont->getHandle(), width, align + }); } void DrawTextLayout::free() { uiDrawFreeTextLayout(handle); } -void DrawTextLayout::setWidth(double value) { - uiDrawTextLayoutSetWidth(handle, value); - w = value; -} - -double DrawTextLayout::getWidth() { - return w; -} - uiDrawTextLayout * DrawTextLayout::getHandle() { return handle; } @@ -31,30 +23,9 @@ SizeDouble DrawTextLayout::getExtents() { return SizeDouble(width, height); } - -void DrawTextLayout::setColor(int startChar, int endChar, Color color) { - uiDrawTextLayoutSetColor( - handle, - startChar, - endChar, - color.getR(), - color.getG(), - color.getB(), - color.getA() - ); -} - - - - - NBIND_CLASS(DrawTextLayout) { - construct(); + construct(); method(free); - method(setWidth); - method(getWidth); method(getExtents); - method(setColor); - getset(getWidth, setWidth); } diff --git a/src/UiFontButton.cc b/src/UiFontButton.cc index 124c8c3..f2ea824 100644 --- a/src/UiFontButton.cc +++ b/src/UiFontButton.cc @@ -3,25 +3,24 @@ #include "nbind/nbind.h" #include "ui-node.h" -// UiFontButton::UiFontButton() : UiControl((uiControl*)uiNewFontButton()) {} +UiFontButton::UiFontButton() : UiControl((uiControl*)uiNewFontButton()) {} -// INHERITS_CONTROL_METHODS(uiFontButton) +INHERITS_CONTROL_METHODS(UiFontButton) -// IMPLEMENT_EVENT(UiFontButton, uiFontButton, onChanged, uiFontButtonOnChanged) +IMPLEMENT_EVENT(UiFontButton, uiFontButton, onChanged, uiFontButtonOnChanged) -// UiFontDescriptor* UiFontButton::getFont() { -// uiFontDescriptor *desc = new UiFontDescriptor(); -// uiFontButtonFont((uiFontButton*)getHandle(), desc); -// return desc; -// //TODO: uiFreeFontButtonFont -// } +UiFontDescriptor* UiFontButton::getFont() { + uiFontDescriptor *desc = new uiFontDescriptor(); + uiFontButtonFont((uiFontButton*)getHandle(), desc); + return new UiFontDescriptor(desc); +} -// NBIND_CLASS(UiFontButton) { -// construct<>(); -// DECLARE_CHILD_CONTROL_METHODS() -// method(getFont); -// method(onChanged); -// } +NBIND_CLASS(UiFontButton) { + construct<>(); + DECLARE_CHILD_CONTROL_METHODS() + method(getFont); + method(onChanged); +} -DONT' COMPILE \ No newline at end of file +DONT_COMPILE \ No newline at end of file diff --git a/src/ui-node.h b/src/ui-node.h index 68a7c3b..ffe5235 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -636,68 +636,6 @@ class UiDrawPath { }; -//TODO how to expose to js? -enum class UiAttributeType { - Family = uiAttributeTypeFamily, - Size = uiAttributeTypeSize, - Weight = uiAttributeTypeWeight, - Italic = uiAttributeTypeItalic, - Stretch = uiAttributeTypeStretch, - Color = uiAttributeTypeColor, - Background = uiAttributeTypeBackground, - Underline = uiAttributeTypeUnderline, - UnderlineColor = uiAttributeTypeUnderlineColor, - Features = uiAttributeTypeFeatures -}; - -enum class UiTextWeight { - Minimum, - Thin, - UltraLight, - Light, - Book, - Normal, - Medium, - SemiBold, - Bold, - UltraBold, - Heavy, - UltraHeavy, - Maximum -}; - -enum class UiTextItalic { - Normal, - Oblique, - Italic -}; - -enum class UiTextStretch { - UltraCondensed, - ExtraCondensed, - Condensed, - SemiCondensed, - Normal, - SemiExpanded, - Expanded, - ExtraExpanded, - UltraExpanded -}; - -enum class UiTextUnderline { - None, - Single, - Double, - Suggestion -}; - -enum class UiTextUnderlineColor { - Custom, - Spelling, - Grammar, - Auxiliary -}; - class UiFontAttribute { private: uiAttribute* a; @@ -705,27 +643,28 @@ class UiFontAttribute { public: UiFontAttribute() = delete; - UiAttributeType getAttributeType(UiFontAttribute*); + int getAttributeType(); - //TODO need to actually be of that type + // TODO needs to actually be of that type + // It is an error to call this on a uiAttribute that does not hold a ... const char *uiAttributeFamily(); double uiAttributeSize(); - uiTextWeight uiAttributeWeight(); - uiTextItalic uiAttributeItalic(); - uiTextStretch uiAttributeStretch(); - void uiAttributeColor(double *r, double *g, double *b, double *alpha); - uiUnderline uiAttributeUnderline(); - void uiAttributeUnderlineColor(UiTextUnderlineColor *u, double *r, double *g, double *b, double *alpha); + int uiAttributeWeight(); + int uiAttributeItalic(); + int uiAttributeStretch(); + void uiAttributeColor(Color c); + int uiAttributeUnderline(); + void uiAttributeUnderlineColor(int *u, Color *c); static UiFontAttribute *newFamilyAttribute(const char *family); static UiFontAttribute *newSizeAttribute(double size); - static UiFontAttribute *uiNewWeightAttribute(UiTextWeight weight); - static UiFontAttribute *newItalicAttribute(UiTextItalic italic); - static UiFontAttribute *newStretchAttribute(UiTextStretch stretch); - static UiFontAttribute *newColorAttribute(double r, double g, double b, double a); - static UiFontAttribute *newBackgroundAttribute(double r, double g, double b, double a); - static UiFontAttribute *newUnderlineAttribute(UiTextUnderline u); - static UiFontAttribute *newUnderlineColorAttribute(UiTextUnderlineColor u, double r, double g, double b, double a); + static UiFontAttribute *uiNewWeightAttribute(int weightAttribute); + static UiFontAttribute *newItalicAttribute(int italicAttribute); + static UiFontAttribute *newStretchAttribute(int stretchAttribute); + static UiFontAttribute *newColorAttribute(Color c); + static UiFontAttribute *newBackgroundAttribute(Color c); + static UiFontAttribute *newUnderlineAttribute(int underLineAttr); + static UiFontAttribute *newUnderlineColorAttribute(int underLineColorAttr, Color c); }; @@ -741,7 +680,7 @@ class UiAttributedString { void appendUnattributed(const char *str); void insertUnattributed(const char *str, size_t at); void deleteString(size_t start, size_t end); - void setAttribute(uiAttribute *a, size_t start, size_t end); + void setAttribute(int *attr, size_t start, size_t end); // void forEachAttribute(uiAttributedStringForEachAttributeFunc f, void *data); size_t numGraphemes(); @@ -753,19 +692,14 @@ class UiAttributedString { class UiFontDescriptor { private: uiFontDescriptor *d; + int cleanup; public: - UiFontDescriptor(char *family, double size, UiTextWeight weight, UiTextItalic italic, UiTextStretch stretch); + UiFontDescriptor(uiFontDescriptor *d); + UiFontDescriptor(char *family, double size, int weight, int italic, int stretch); + uiFontDescriptor* getHandle(); }; -//TODO with or without "Draw"? -enum class UiDrawTextAlign { - Left = uiDrawTextAlignLeft, - Center = uiDrawTextAlignCenter, - Right = uiDrawTextAlignRight -}; - - class UiFontButton : public UiControl { DEFINE_EVENT(onChanged) From df26d26c40c64e4e1ac2b3541f430caa1a19e28e Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Mon, 26 Mar 2018 12:23:04 +0200 Subject: [PATCH 024/190] Fixup --- src/UiArea/DrawTextFontDescriptor.cc | 6 +++--- src/ui-node.h | 9 +++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/UiArea/DrawTextFontDescriptor.cc b/src/UiArea/DrawTextFontDescriptor.cc index 2a76c91..26c9393 100644 --- a/src/UiArea/DrawTextFontDescriptor.cc +++ b/src/UiArea/DrawTextFontDescriptor.cc @@ -16,7 +16,7 @@ UiFontDescriptor::UiFontDescriptor(char *family, double size, int weight, int it d->Stretch = stretch; } -UiFontDescriptor::~UiFontDescriptor(){ +UiFontDescriptor::free() { if(cleanup){ uiFreeFontButtonFont(d); } @@ -39,7 +39,7 @@ int UiFontDescriptor::getItalic() { return m->Italic; } -int UiFontDescriptor::getStetch() { +int UiFontDescriptor::getStretch() { return m->Stretch; } @@ -53,5 +53,5 @@ NBIND_CLASS(UiFontDescriptor) { method(getSize); method(getWeight); method(getItalic); - method(getStetch); + method(getStretch); } diff --git a/src/ui-node.h b/src/ui-node.h index ffe5235..cfa89f9 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -696,8 +696,13 @@ class UiFontDescriptor { public: UiFontDescriptor(uiFontDescriptor *d); UiFontDescriptor(char *family, double size, int weight, int italic, int stretch); - uiFontDescriptor* getHandle(); - + void free(); + char *getFamily(); + double getSize(); + int getWeight(); + int getItalic(); + int getStretch(); + uiFontDescriptor *getHandle(); }; From 957a61d99775a3922ab8fcc5b2c72670012caf2f Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Mon, 26 Mar 2018 12:40:19 +0200 Subject: [PATCH 025/190] Compile errors --- binding.gyp | 2 +- .../UiFontDescriptor.cc} | 16 ++++++++-------- src/UiArea/DrawTextLayout.cc | 15 ++++++++++----- src/UiArea/UiDrawContext.cc | 2 +- src/UiFontButton.cc | 3 --- src/ui-node.h | 5 +++-- 6 files changed, 23 insertions(+), 20 deletions(-) rename src/{UiArea/DrawTextFontDescriptor.cc => Font/UiFontDescriptor.cc} (83%) diff --git a/binding.gyp b/binding.gyp index 30f439d..d4d5888 100644 --- a/binding.gyp +++ b/binding.gyp @@ -8,7 +8,7 @@ "sources": [ "src/EventLoop.cc", "src/UiFontButton.cc", - "src/UiArea/DrawTextFontDescriptor.cc", + "src/Font/UiFontDescriptor.cc", "src/UiArea/DrawTextLayout.cc", "src/UiArea/UiArea.cc", "src/UiArea/DrawStrokeParams.cc", diff --git a/src/UiArea/DrawTextFontDescriptor.cc b/src/Font/UiFontDescriptor.cc similarity index 83% rename from src/UiArea/DrawTextFontDescriptor.cc rename to src/Font/UiFontDescriptor.cc index 26c9393..fa6ee3f 100644 --- a/src/UiArea/DrawTextFontDescriptor.cc +++ b/src/Font/UiFontDescriptor.cc @@ -12,11 +12,11 @@ UiFontDescriptor::UiFontDescriptor(char *family, double size, int weight, int it d->Family = family; d->Size = size; d->Weight = weight; - d->Italic = italic + d->Italic = italic; d->Stretch = stretch; } -UiFontDescriptor::free() { +void UiFontDescriptor::free() { if(cleanup){ uiFreeFontButtonFont(d); } @@ -24,27 +24,27 @@ UiFontDescriptor::free() { } char *UiFontDescriptor::getFamily() { - return m->Family; + return d->Family; } double UiFontDescriptor::getSize() { - return m->Size; + return d->Size; } int UiFontDescriptor::getWeight() { - return m->Weight; + return d->Weight; } int UiFontDescriptor::getItalic() { - return m->Italic; + return d->Italic; } int UiFontDescriptor::getStretch() { - return m->Stretch; + return d->Stretch; } uiFontDescriptor *UiFontDescriptor::getHandle(){ - return m; + return d; } diff --git a/src/UiArea/DrawTextLayout.cc b/src/UiArea/DrawTextLayout.cc index 956ed0d..58b64f0 100644 --- a/src/UiArea/DrawTextLayout.cc +++ b/src/UiArea/DrawTextLayout.cc @@ -2,10 +2,15 @@ #include "../ui-node.h" #include "nbind/nbind.h" -DrawTextLayout::DrawTextLayout(const char *text, UiFontDescriptor *defaultFont, double width, int align) { - handle = uiDrawNewTextLayout({ - text, defaultFont->getHandle(), width, align - }); +DrawTextLayout::DrawTextLayout(UiAttributedString *str, UiFontDescriptor *defaultFont, double width, int align) { + uiDrawTextLayoutParams params = { + .String = str->getHandle(), + .DefaultFont = defaultFont->getHandle(), + .Width = width, + .Align = static_cast(align) + }; + + handle = uiDrawNewTextLayout(¶ms); } void DrawTextLayout::free() { @@ -24,7 +29,7 @@ SizeDouble DrawTextLayout::getExtents() { } NBIND_CLASS(DrawTextLayout) { - construct(); + construct(); method(free); method(getExtents); } diff --git a/src/UiArea/UiDrawContext.cc b/src/UiArea/UiDrawContext.cc index 06b43de..b555875 100644 --- a/src/UiArea/UiDrawContext.cc +++ b/src/UiArea/UiDrawContext.cc @@ -31,7 +31,7 @@ void UiDrawContext::restore() { } void UiDrawContext::text(double x, double y, DrawTextLayout *layout) { - uiDrawText(c, x, y, layout->getHandle()); + uiDrawText(c, layout->getHandle(), x, y); } diff --git a/src/UiFontButton.cc b/src/UiFontButton.cc index f2ea824..b27ab7b 100644 --- a/src/UiFontButton.cc +++ b/src/UiFontButton.cc @@ -21,6 +21,3 @@ NBIND_CLASS(UiFontButton) { method(getFont); method(onChanged); } - - -DONT_COMPILE \ No newline at end of file diff --git a/src/ui-node.h b/src/ui-node.h index cfa89f9..938b9c1 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -674,6 +674,7 @@ class UiAttributedString { public: UiAttributedString(const char *str); void free(); + uiAttributedString *getHandle(); const char * toString(); size_t toStringLen(); @@ -721,7 +722,7 @@ class DrawTextLayout { uiDrawTextLayout* handle; public: - DrawTextLayout(uiAttributedString *s, uiFontDescriptor *defaultFont, double width, uiDrawTextAlign align); + DrawTextLayout(UiAttributedString *s, UiFontDescriptor *defaultFont, double width, int align); void free(); SizeDouble getExtents(); uiDrawTextLayout* getHandle(); @@ -740,7 +741,7 @@ class UiDrawContext { void clip(UiDrawPath* path); void save(); void restore(); - void text(double x, double y, uiDrawTextLayout* layout); + void text(double x, double y, DrawTextLayout* layout); }; class UiAreaDrawParams { From c5c0534630fb38b0b921b46e0777f135bfe1db35 Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Mon, 26 Mar 2018 13:54:16 +0200 Subject: [PATCH 026/190] Attribute, AttributedString, fixes --- binding.gyp | 2 + index.js | 4 +- src/Font/UiAttributedString.cc | 74 ++++++++++++++++++ src/Font/UiFontAttribute.cc | 134 +++++++++++++++++++++++++++++++++ src/Font/UiFontDescriptor.cc | 5 +- src/UiArea/DrawTextLayout.cc | 8 +- src/ui-node.h | 46 +++++------ 7 files changed, 243 insertions(+), 30 deletions(-) create mode 100644 src/Font/UiAttributedString.cc create mode 100644 src/Font/UiFontAttribute.cc diff --git a/binding.gyp b/binding.gyp index d4d5888..4c18e1a 100644 --- a/binding.gyp +++ b/binding.gyp @@ -9,6 +9,8 @@ "src/EventLoop.cc", "src/UiFontButton.cc", "src/Font/UiFontDescriptor.cc", + "src/Font/UiFontAttribute.cc", + "src/Font/UiAttributedString.cc", "src/UiArea/DrawTextLayout.cc", "src/UiArea/UiArea.cc", "src/UiArea/DrawStrokeParams.cc", diff --git a/index.js b/index.js index 71c85c4..eaa93d5 100755 --- a/index.js +++ b/index.js @@ -80,7 +80,7 @@ binding.bind('SizeDouble', SizeDouble); const textWeight = { minimum: 0, thin: 100, - ultraLight: 200 + ultraLight: 200, light: 300, book: 350, normal: 400, @@ -89,7 +89,7 @@ const textWeight = { bold: 700, ultraBold: 800, heavy: 900, - ultraHeavy: 950 + ultraHeavy: 950, maximum: 1000 }; diff --git a/src/Font/UiAttributedString.cc b/src/Font/UiAttributedString.cc new file mode 100644 index 0000000..0916182 --- /dev/null +++ b/src/Font/UiAttributedString.cc @@ -0,0 +1,74 @@ +#include "../../ui.h" +#include "../ui-node.h" +#include "nbind/nbind.h" + +UiAttributedString::UiAttributedString(const char *str) { + s = uiNewAttributedString(str); +} + +void UiAttributedString::free() { + uiFreeAttributedString(s); +} + +uiAttributedString *UiAttributedString::getHandle() { + return s; +} + +const char * UiAttributedString::toString() { + return uiAttributedStringString(s); +} + +size_t UiAttributedString::toStringLen() { + return uiAttributedStringLen(s); +} + +void UiAttributedString::appendUnattributed(const char *str) { + uiAttributedStringAppendUnattributed(s, str); +} + +void UiAttributedString::insertUnattributed(const char *str, size_t at) { + uiAttributedStringInsertAtUnattributed(s, str, at); +} + +void UiAttributedString::deleteString(size_t start, size_t end) { + uiAttributedStringDelete(s, start, end); +} + +void UiAttributedString::setAttribute(UiFontAttribute *attr, size_t start, size_t end) { + uiAttributedStringSetAttribute(s, attr->getHandle(), start, end); +} + +// void forEachAttribute(uiAttributedStringForEachAttributeFunc f, void *data) { +// +// } + +size_t UiAttributedString::numGraphemes() { + return uiAttributedStringNumGraphemes(s); +} + +size_t UiAttributedString::byteIndexToGrapheme(size_t pos) { + return uiAttributedStringByteIndexToGrapheme(s, pos); +} + +size_t UiAttributedString::graphemeToByteIndex(size_t pos) { + return uiAttributedStringGraphemeToByteIndex(s, pos); +} + + +NBIND_CLASS(UiAttributedString) { + construct(); + method(free); + method(getHandle); + method(toString); + method(toStringLen); + method(appendUnattributed); + method(insertUnattributed); + method(deleteString); + method(setAttribute); + // method(forEachAttribute); + method(numGraphemes); + method(byteIndexToGrapheme); + method(graphemeToByteIndex); +} + + diff --git a/src/Font/UiFontAttribute.cc b/src/Font/UiFontAttribute.cc new file mode 100644 index 0000000..b3ef6ad --- /dev/null +++ b/src/Font/UiFontAttribute.cc @@ -0,0 +1,134 @@ +#include "../../ui.h" +#include "../ui-node.h" +#include "nbind/nbind.h" + +UiFontAttribute::UiFontAttribute(uiAttribute *attr){ + a = attr; +} + +int UiFontAttribute::getAttributeType() { + return uiAttributeGetType(a); +} + +uiAttribute *UiFontAttribute::getHandle(){ + return a; +} + +void UiFontAttribute::free(){ + uiFreeAttribute(a); +} + +// TODO needs to actually be of that type +// It is an error to call this on a uiAttribute that does not hold a ... +const char *UiFontAttribute::getFamily(){ + return uiAttributeFamily(a); +} + +double UiFontAttribute::getSize() { + return uiAttributeSize(a); +} + +int UiFontAttribute::getWeight(){ + return uiAttributeWeight(a); +} + +int UiFontAttribute::getItalic(){ + return uiAttributeItalic(a); +} + +int UiFontAttribute::getStretch(){ + return uiAttributeStretch(a); +} + +Color UiFontAttribute::getColor(){ + double r; + double g; + double b; + double alpha; + + uiAttributeColor(a, &r, &g, &b, &alpha); + + return Color(r, g, b, alpha); +} + +int UiFontAttribute::getUnderline(){ + return uiAttributeUnderline(a); +} + +int UiFontAttribute::getUnderlineColor(Color *c){ + double r; + double g; + double b; + double alpha; + + uiUnderlineColor type; + uiAttributeUnderlineColor(a, &type, &r, &g, &b, &alpha); + c->setR(r); + c->setG(g); + c->setB(b); + c->setA(alpha); + + return type; +} + +UiFontAttribute *UiFontAttribute::newFamily(const char *family) { + return new UiFontAttribute(uiNewFamilyAttribute(family)); +} + +UiFontAttribute *UiFontAttribute::newSize(double size) { + return new UiFontAttribute(uiNewSizeAttribute(size)); +} + +UiFontAttribute *UiFontAttribute::newWeight(int weightAttribute) { + return new UiFontAttribute(uiNewWeightAttribute(weightAttribute)); +} + +UiFontAttribute *UiFontAttribute::newItalic(int italicAttribute) { + return new UiFontAttribute(uiNewItalicAttribute(italicAttribute)); +} + +UiFontAttribute *UiFontAttribute::newStretch(int stretchAttribute) { + return new UiFontAttribute(uiNewStretchAttribute(stretchAttribute)); +} + +UiFontAttribute *UiFontAttribute::newColor(Color *c) { + return new UiFontAttribute(uiNewColorAttribute(c->getR(), c->getG(), c->getB(), c->getA())); +} + +UiFontAttribute *UiFontAttribute::newBackground(Color *c) { + return new UiFontAttribute(uiNewBackgroundAttribute(c->getR(), c->getG(), c->getB(), c->getA())); +} + +UiFontAttribute *UiFontAttribute::newUnderline(int underlineAttr) { + return new UiFontAttribute(uiNewUnderlineAttribute(underlineAttr)); +} + +UiFontAttribute *UiFontAttribute::newUnderlineColor(int underlineColorAttr, Color *c) { + return new UiFontAttribute(uiNewUnderlineColorAttribute(underlineColorAttr, c->getR(), c->getG(), c->getB(), c->getA())); +} + + + +NBIND_CLASS(UiFontAttribute) { + method(free); + method(getAttributeType); + + method(getFamily); + method(getSize); + method(getWeight); + method(getItalic); + method(getStretch); + method(getColor); + method(getUnderline); + method(getUnderlineColor); + + method(newFamily); + method(newSize); + method(newWeight); + method(newItalic); + method(newStretch); + method(newColor); + method(newBackground); + method(newUnderline); + method(newUnderlineColor); +} diff --git a/src/Font/UiFontDescriptor.cc b/src/Font/UiFontDescriptor.cc index fa6ee3f..3edb3d1 100644 --- a/src/Font/UiFontDescriptor.cc +++ b/src/Font/UiFontDescriptor.cc @@ -4,7 +4,7 @@ UiFontDescriptor::UiFontDescriptor(uiFontDescriptor * desc) { d = desc; - cleanup = 1; + buttonCleanup = 1; } UiFontDescriptor::UiFontDescriptor(char *family, double size, int weight, int italic, int stretch) { @@ -17,7 +17,7 @@ UiFontDescriptor::UiFontDescriptor(char *family, double size, int weight, int it } void UiFontDescriptor::free() { - if(cleanup){ + if(buttonCleanup){ uiFreeFontButtonFont(d); } delete d; @@ -49,6 +49,7 @@ uiFontDescriptor *UiFontDescriptor::getHandle(){ NBIND_CLASS(UiFontDescriptor) { + // construct(); method(getFamily); method(getSize); method(getWeight); diff --git a/src/UiArea/DrawTextLayout.cc b/src/UiArea/DrawTextLayout.cc index 58b64f0..ae35948 100644 --- a/src/UiArea/DrawTextLayout.cc +++ b/src/UiArea/DrawTextLayout.cc @@ -7,7 +7,7 @@ DrawTextLayout::DrawTextLayout(UiAttributedString *str, UiFontDescriptor *defaul .String = str->getHandle(), .DefaultFont = defaultFont->getHandle(), .Width = width, - .Align = static_cast(align) + .Align = (uiDrawTextAlign) align }; handle = uiDrawNewTextLayout(¶ms); @@ -29,8 +29,8 @@ SizeDouble DrawTextLayout::getExtents() { } NBIND_CLASS(DrawTextLayout) { - construct(); - method(free); - method(getExtents); + construct(); + method(free); + method(getExtents); } diff --git a/src/ui-node.h b/src/ui-node.h index 938b9c1..4d17475 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -638,33 +638,35 @@ class UiDrawPath { class UiFontAttribute { private: + UiFontAttribute(uiAttribute *a); uiAttribute* a; public: - UiFontAttribute() = delete; - + // DON'T CALL IF USED IN AN AttributedString + void free(); int getAttributeType(); + uiAttribute *getHandle(); // TODO needs to actually be of that type // It is an error to call this on a uiAttribute that does not hold a ... - const char *uiAttributeFamily(); - double uiAttributeSize(); - int uiAttributeWeight(); - int uiAttributeItalic(); - int uiAttributeStretch(); - void uiAttributeColor(Color c); - int uiAttributeUnderline(); - void uiAttributeUnderlineColor(int *u, Color *c); - - static UiFontAttribute *newFamilyAttribute(const char *family); - static UiFontAttribute *newSizeAttribute(double size); - static UiFontAttribute *uiNewWeightAttribute(int weightAttribute); - static UiFontAttribute *newItalicAttribute(int italicAttribute); - static UiFontAttribute *newStretchAttribute(int stretchAttribute); - static UiFontAttribute *newColorAttribute(Color c); - static UiFontAttribute *newBackgroundAttribute(Color c); - static UiFontAttribute *newUnderlineAttribute(int underLineAttr); - static UiFontAttribute *newUnderlineColorAttribute(int underLineColorAttr, Color c); + const char *getFamily(); + double getSize(); + int getWeight(); + int getItalic(); + int getStretch(); + Color getColor(); + int getUnderline(); + int getUnderlineColor(Color *c); + + static UiFontAttribute *newFamily(const char *family); + static UiFontAttribute *newSize(double size); + static UiFontAttribute *newWeight(int weightAttribute); + static UiFontAttribute *newItalic(int italicAttribute); + static UiFontAttribute *newStretch(int stretchAttribute); + static UiFontAttribute *newColor(Color *c); + static UiFontAttribute *newBackground(Color *c); + static UiFontAttribute *newUnderline(int underlineAttr); + static UiFontAttribute *newUnderlineColor(int underlineColorAttr, Color *c); }; @@ -681,7 +683,7 @@ class UiAttributedString { void appendUnattributed(const char *str); void insertUnattributed(const char *str, size_t at); void deleteString(size_t start, size_t end); - void setAttribute(int *attr, size_t start, size_t end); + void setAttribute(UiFontAttribute *attr, size_t start, size_t end); // void forEachAttribute(uiAttributedStringForEachAttributeFunc f, void *data); size_t numGraphemes(); @@ -693,7 +695,7 @@ class UiAttributedString { class UiFontDescriptor { private: uiFontDescriptor *d; - int cleanup; + int buttonCleanup = 0; public: UiFontDescriptor(uiFontDescriptor *d); UiFontDescriptor(char *family, double size, int weight, int italic, int stretch); From 8e29ebe6d43e52664179a7167e82c47ecda06959 Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Mon, 26 Mar 2018 16:50:31 +0200 Subject: [PATCH 027/190] Update examples, fix almost everything --- binding.gyp | 1 + examples/text.js | 130 ++++++++++++++++++++------------- index.js | 42 +++++------ src/Font/UiAttributedString.cc | 27 ++++++- src/Font/UiFontAttribute.cc | 38 ++++++---- src/Font/UiFontDescriptor.cc | 6 +- src/Font/UiOpenTypeFeatures.cc | 64 ++++++++++++++++ src/ui-node.h | 29 ++++++-- 8 files changed, 240 insertions(+), 97 deletions(-) create mode 100644 src/Font/UiOpenTypeFeatures.cc diff --git a/binding.gyp b/binding.gyp index 4c18e1a..27a4af5 100644 --- a/binding.gyp +++ b/binding.gyp @@ -11,6 +11,7 @@ "src/Font/UiFontDescriptor.cc", "src/Font/UiFontAttribute.cc", "src/Font/UiAttributedString.cc", + "src/Font/UiOpenTypeFeatures.cc", "src/UiArea/DrawTextLayout.cc", "src/UiArea/UiArea.cc", "src/UiArea/DrawStrokeParams.cc", diff --git a/examples/text.js b/examples/text.js index 1130f46..139353d 100644 --- a/examples/text.js +++ b/examples/text.js @@ -1,54 +1,77 @@ 'use strict'; /* eslint-disable unicorn/number-literal-case */ const libui = require('..'); +const { UiFontAttribute } = libui; -let mainwin; let textDrawArea; -let fontSize; -let textString; -const colorWhite = 0xff00ff; - -function buildSolidBrush(color, alpha) { - let component; - - component = (color >> 16) & 0xff; - const R = component / 255; - component = (color >> 8) & 0xff; - const G = component / 255; - component = color & 0xff; - const B = component / 255; - const A = alpha; - - const uiDrawBrushTypeSolid = 0; - const brush = new libui.DrawBrush(); - brush.color = new libui.Color(R, G, B, A); - brush.type = uiDrawBrushTypeSolid; - - return brush; -} +let fontButton; +let align; + +const str = new libui.UiAttributedString( + "Drawing strings with libui is done with the uiAttributedString and uiDrawTextLayout objects.\n"+ + "uiAttributedString lets you have a variety of attributes: "); + +str.appendAttributed("font family", UiFontAttribute.newFamily("Courier New")); +str.appendUnattributed(", "); + + +str.appendAttributed("font size", UiFontAttribute.newSize(18)); +str.appendUnattributed(", "); + +str.appendAttributed("font weight", UiFontAttribute.newWeight(libui.textWeight.bold)); +str.appendUnattributed(", "); + +str.appendAttributed("font italicness", UiFontAttribute.newItalic(libui.textItalic.italic)); +str.appendUnattributed(", "); + +str.appendAttributed("font stretch", UiFontAttribute.newStretch(libui.textStretch.condensed)); +str.appendUnattributed(", "); + +str.appendAttributed("text color", UiFontAttribute.newColor(new libui.Color(0.75, 0.25, 0.5, 0.75))); +str.appendUnattributed(", "); + +str.appendAttributed("text background color", UiFontAttribute.newBackground(new libui.Color(0.5, 0.5, 0.25, 0.5))); +str.appendUnattributed(", "); -function handlerDraw(area, p) { - const brush = buildSolidBrush(colorWhite, 1.0); - const path = new libui.UiDrawPath(0); - path.addRectangle(0, 0, p.getAreaWidth(), p.getAreaHeight()); - path.end(); - p.getContext().fill(path, brush); - path.freePath(); +str.appendAttributed("underline style", UiFontAttribute.newUnderline(libui.textUnderline.single)); +str.appendUnattributed(", "); - const font = new libui.DrawTextFont(); +str.appendUnattributed("and "); +str.appendAttributed2("underline color", + UiFontAttribute.newUnderline(libui.textUnderline.double), + UiFontAttribute.newUnderlineColor(libui.textUnderlineColor.custom, new libui.Color(1.0, 0.0, 0.5, 1.0))); +str.appendUnattributed(". "); - font.loadClosestFont( - 'Monospace', - fontSize.value, - libui.textWeight.ultraLight, - libui.textItalic.oblique, - libui.textStretch.normal - ); +str.appendUnattributed("Furthermore, there are attributes allowing for "); +str.appendAttributed2("special underlines for indicating spelling errors", + UiFontAttribute.newUnderline(libui.textUnderline.suggestion), + UiFontAttribute.newUnderlineColor(libui.textUnderlineColor.spelling, new libui.Color(0, 0, 0, 0))); +str.appendUnattributed(" (and other types of errors) "); - const layout = new libui.DrawTextLayout(textString.text, font, 40); +str.appendUnattributed("and control over OpenType features such as ligatures (for instance, "); - layout.setColor(0, textString.text.length, new libui.Color(1, 0, 0, 1)); +const otf = new libui.UiOpenTypeFeatures(); +otf.add("liga", 0); +str.appendAttributed("afford", UiFontAttribute.newOTFeatures(otf)); +str.appendUnattributed(" vs. "); + +otf.add("liga", 1); +str.appendAttributed("afford", UiFontAttribute.newOTFeatures(otf)); +otf.free() +str.appendUnattributed(").\n"); + +str.appendUnattributed("Use the controls opposite to the text to control properties of the text."); + + + + + + +function handlerDraw(area, p) { + const font = fontButton.getFont(); + + const layout = new libui.DrawTextLayout(str, font, p.getAreaWidth(), align.getSelected()); p.getContext().text(0, 0, layout); @@ -63,7 +86,7 @@ function redraw() { } function main() { - mainwin = new libui.UiWindow('libui textDrawArea Example', 640, 480, 1); + const mainwin = new libui.UiWindow('libui textDrawArea Example', 640, 480, 1); mainwin.margined = true; mainwin.onClosing(() => { libui.stopLoop(); @@ -75,18 +98,25 @@ function main() { const vbox = new libui.UiVerticalBox(); vbox.padded = true; - hbox.append(vbox, true); + hbox.append(vbox, false); + + fontButton = new libui.UiFontButton(); + fontButton.onChanged(redraw); + vbox.append(fontButton, false); - fontSize = new libui.UiSpinbox(); - fontSize.value = 24; - fontSize.onChanged(redraw); + const form = new libui.UiForm(); + form.padded = true; + vbox.append(form, false); - textString = new libui.UiEntry(); - textString.text = 'Sample'; - textString.onChanged(redraw); + align = new libui.UiCombobox(); + // note that the items match with the values of the uiDrawTextAlign values + align.append("Left"); + align.append("Center"); + align.append("Right"); + align.setSelected(0); + align.onSelected(redraw); + form.append("Alignment", align, false); - vbox.append(textString, false); - vbox.append(fontSize, false); textDrawArea = new libui.UiArea(handlerDraw, noop, noop, noop, noop); hbox.append(textDrawArea, true); diff --git a/index.js b/index.js index eaa93d5..ef9c957 100755 --- a/index.js +++ b/index.js @@ -113,37 +113,37 @@ const textStretch = { const textAttributeType = { - Family: 0, - Size: 1, - Weight: 2, - Italic: 3, - Stretch: 4, - Color: 5, - Background: 6, - Underline: 7, - UnderlineColor: 8, - Features: 9 + family: 0, + size: 1, + weight: 2, + italic: 3, + stretch: 4, + color: 5, + background: 6, + underline: 7, + underlineColor: 8, + features: 9 }; const textUnderline = { - None: 0, - Single: 1, - Double: 2, - Suggestion: 3 + none: 0, + single: 1, + double: 2, + suggestion: 3 }; const textUnderlineColor = { - Custom: 0, - Spelling: 1, - Grammar: 2, - Auxiliary: 3 + custom: 0, + spelling: 1, + grammar: 2, + auxiliary: 3 }; const textAlign = { - Left: 0, - Center: 1, - Right: 2 + left: 0, + center: 1, + right: 2 }; diff --git a/src/Font/UiAttributedString.cc b/src/Font/UiAttributedString.cc index 0916182..0732649 100644 --- a/src/Font/UiAttributedString.cc +++ b/src/Font/UiAttributedString.cc @@ -42,6 +42,25 @@ void UiAttributedString::setAttribute(UiFontAttribute *attr, size_t start, size_ // // } + +void UiAttributedString::appendAttributed(const char *str, UiFontAttribute *attr) { + this->appendAttributed2(str, attr, nullptr); +} + + +void UiAttributedString::appendAttributed2(const char *str, UiFontAttribute *attr, UiFontAttribute *attr2) { + size_t start = this->toStringLen(); + // TODO how this (and strlen) work with unicode? + size_t end = start + strlen(str); + + this->appendUnattributed(str); + this->setAttribute(attr, start, end); + if(attr2 != nullptr){ + this->setAttribute(attr2, start, end); + } +} + + size_t UiAttributedString::numGraphemes() { return uiAttributedStringNumGraphemes(s); } @@ -54,15 +73,17 @@ size_t UiAttributedString::graphemeToByteIndex(size_t pos) { return uiAttributedStringGraphemeToByteIndex(s, pos); } - NBIND_CLASS(UiAttributedString) { construct(); method(free); - method(getHandle); method(toString); method(toStringLen); method(appendUnattributed); method(insertUnattributed); + method(appendAttributed); + method(appendAttributed2); + // multimethod(appendAttributed, args(const char *, UiFontAttribute *)); + // multimethod(appendAttributed, args(const char *, UiFontAttribute *, UiFontAttribute *), "appendAttributed2"); method(deleteString); method(setAttribute); // method(forEachAttribute); @@ -70,5 +91,3 @@ NBIND_CLASS(UiAttributedString) { method(byteIndexToGrapheme); method(graphemeToByteIndex); } - - diff --git a/src/Font/UiFontAttribute.cc b/src/Font/UiFontAttribute.cc index b3ef6ad..23fd07b 100644 --- a/src/Font/UiFontAttribute.cc +++ b/src/Font/UiFontAttribute.cc @@ -10,7 +10,7 @@ int UiFontAttribute::getAttributeType() { return uiAttributeGetType(a); } -uiAttribute *UiFontAttribute::getHandle(){ +uiAttribute *UiFontAttribute::getHandle() { return a; } @@ -20,7 +20,7 @@ void UiFontAttribute::free(){ // TODO needs to actually be of that type // It is an error to call this on a uiAttribute that does not hold a ... -const char *UiFontAttribute::getFamily(){ +const char *UiFontAttribute::getFamily() { return uiAttributeFamily(a); } @@ -28,19 +28,19 @@ double UiFontAttribute::getSize() { return uiAttributeSize(a); } -int UiFontAttribute::getWeight(){ +int UiFontAttribute::getWeight() { return uiAttributeWeight(a); } -int UiFontAttribute::getItalic(){ +int UiFontAttribute::getItalic() { return uiAttributeItalic(a); } -int UiFontAttribute::getStretch(){ +int UiFontAttribute::getStretch() { return uiAttributeStretch(a); } -Color UiFontAttribute::getColor(){ +Color UiFontAttribute::getColor() { double r; double g; double b; @@ -51,11 +51,11 @@ Color UiFontAttribute::getColor(){ return Color(r, g, b, alpha); } -int UiFontAttribute::getUnderline(){ +int UiFontAttribute::getUnderline() { return uiAttributeUnderline(a); } -int UiFontAttribute::getUnderlineColor(Color *c){ +int UiFontAttribute::getUnderlineColor(Color *c) { double r; double g; double b; @@ -71,6 +71,12 @@ int UiFontAttribute::getUnderlineColor(Color *c){ return type; } +UiOpenTypeFeatures *UiFontAttribute::getOTFeatures() { + return new UiOpenTypeFeatures((uiOpenTypeFeatures*) uiAttributeFeatures(a)); +} + + + UiFontAttribute *UiFontAttribute::newFamily(const char *family) { return new UiFontAttribute(uiNewFamilyAttribute(family)); } @@ -91,22 +97,25 @@ UiFontAttribute *UiFontAttribute::newStretch(int stretchAttribute) { return new UiFontAttribute(uiNewStretchAttribute(stretchAttribute)); } -UiFontAttribute *UiFontAttribute::newColor(Color *c) { - return new UiFontAttribute(uiNewColorAttribute(c->getR(), c->getG(), c->getB(), c->getA())); +UiFontAttribute *UiFontAttribute::newColor(Color c) { + return new UiFontAttribute(uiNewColorAttribute(c.getR(), c.getG(), c.getB(), c.getA())); } -UiFontAttribute *UiFontAttribute::newBackground(Color *c) { - return new UiFontAttribute(uiNewBackgroundAttribute(c->getR(), c->getG(), c->getB(), c->getA())); +UiFontAttribute *UiFontAttribute::newBackground(Color c) { + return new UiFontAttribute(uiNewBackgroundAttribute(c.getR(), c.getG(), c.getB(), c.getA())); } UiFontAttribute *UiFontAttribute::newUnderline(int underlineAttr) { return new UiFontAttribute(uiNewUnderlineAttribute(underlineAttr)); } -UiFontAttribute *UiFontAttribute::newUnderlineColor(int underlineColorAttr, Color *c) { - return new UiFontAttribute(uiNewUnderlineColorAttribute(underlineColorAttr, c->getR(), c->getG(), c->getB(), c->getA())); +UiFontAttribute *UiFontAttribute::newUnderlineColor(int underlineColorAttr, Color c) { + return new UiFontAttribute(uiNewUnderlineColorAttribute(underlineColorAttr, c.getR(), c.getG(), c.getB(), c.getA())); } +UiFontAttribute *UiFontAttribute::newOTFeatures(UiOpenTypeFeatures *otf) { + return new UiFontAttribute(uiNewFeaturesAttribute(otf->getHandle())); +} NBIND_CLASS(UiFontAttribute) { @@ -131,4 +140,5 @@ NBIND_CLASS(UiFontAttribute) { method(newBackground); method(newUnderline); method(newUnderlineColor); + method(newOTFeatures); } diff --git a/src/Font/UiFontDescriptor.cc b/src/Font/UiFontDescriptor.cc index 3edb3d1..9bd6462 100644 --- a/src/Font/UiFontDescriptor.cc +++ b/src/Font/UiFontDescriptor.cc @@ -7,9 +7,9 @@ UiFontDescriptor::UiFontDescriptor(uiFontDescriptor * desc) { buttonCleanup = 1; } -UiFontDescriptor::UiFontDescriptor(char *family, double size, int weight, int italic, int stretch) { +UiFontDescriptor::UiFontDescriptor(const char *family, double size, int weight, int italic, int stretch) { d = new uiFontDescriptor(); - d->Family = family; + d->Family = (char*) family; d->Size = size; d->Weight = weight; d->Italic = italic; @@ -49,7 +49,7 @@ uiFontDescriptor *UiFontDescriptor::getHandle(){ NBIND_CLASS(UiFontDescriptor) { - // construct(); + construct(); method(getFamily); method(getSize); method(getWeight); diff --git a/src/Font/UiOpenTypeFeatures.cc b/src/Font/UiOpenTypeFeatures.cc new file mode 100644 index 0000000..9adab9a --- /dev/null +++ b/src/Font/UiOpenTypeFeatures.cc @@ -0,0 +1,64 @@ +#include "../../ui.h" +#include "../ui-node.h" +#include "nbind/nbind.h" + +UiOpenTypeFeatures::UiOpenTypeFeatures(uiOpenTypeFeatures *feat) { + f = feat; +} + +UiOpenTypeFeatures::UiOpenTypeFeatures() { + f = uiNewOpenTypeFeatures(); +} + +void UiOpenTypeFeatures::free() { + uiFreeOpenTypeFeatures(f); +} + +uiOpenTypeFeatures *UiOpenTypeFeatures::getHandle() { + return f; +} + +UiOpenTypeFeatures *UiOpenTypeFeatures::clone(UiOpenTypeFeatures *f2) { + return new UiOpenTypeFeatures(uiOpenTypeFeaturesClone(f2->f)); +} + +void UiOpenTypeFeatures::add(const char *c, uint32_t value) { + uiOpenTypeFeaturesAdd(f, c[0], c[1], c[2], c[3], value); +} + +void UiOpenTypeFeatures::remove(const char *c) { + uiOpenTypeFeaturesRemove(f, c[0], c[1], c[2], c[3]); +} + +// uiOpenTypeFeaturesGet() determines whether the given feature +// tag is present in otf. If it is, *value is set to the tag's value and +// nonzero is returned. Otherwise, zero is returned. +// +// Note that if uiOpenTypeFeaturesGet() returns zero, value isn't +// changed. This is important: if a feature is not present in a +// uiOpenTypeFeatures, the feature is NOT treated as if its +// value was zero anyway. Script-specific font shaping rules and +// font-specific feature settings may use a different default value +// for a feature. You should likewise not treat a missing feature as +// having a value of zero either. Instead, a missing feature should +// be treated as having some unspecified default value. +int UiOpenTypeFeatures::get(const char *c, uint32_t *value) { + return uiOpenTypeFeaturesGet(f, c[0], c[1], c[2], c[3], value); +} + + +// uiOpenTypeFeaturesForEach() executes f for every tag-value +// pair in otf. The enumeration order is unspecified. You cannot +// modify otf while uiOpenTypeFeaturesForEach() is running. +// typedef uiForEach (*uiOpenTypeFeaturesForEachFunc)(const uiOpenTypeFeatures *otf, char a, char b, char c, char d, uint32_t value, void *data); +// _UI_EXTERN void uiOpenTypeFeaturesForEach(const uiOpenTypeFeatures *otf, uiOpenTypeFeaturesForEachFunc f, void *data); + + +NBIND_CLASS(UiOpenTypeFeatures) { + construct<>(); + method(free); + method(clone); + method(add); + method(remove); + method(get); +} diff --git a/src/ui-node.h b/src/ui-node.h index 4d17475..426791a 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -635,6 +635,20 @@ class UiDrawPath { void end(); }; +class UiOpenTypeFeatures { + private: + uiOpenTypeFeatures *f; + public: + UiOpenTypeFeatures(); + UiOpenTypeFeatures(uiOpenTypeFeatures *feat); + void free(); + uiOpenTypeFeatures *getHandle(); + + static UiOpenTypeFeatures *clone(UiOpenTypeFeatures *f2); + void add(const char *c, uint32_t value); + void remove(const char *c); + int get(const char *c, uint32_t *value); +}; class UiFontAttribute { private: @@ -657,16 +671,18 @@ class UiFontAttribute { Color getColor(); int getUnderline(); int getUnderlineColor(Color *c); + UiOpenTypeFeatures *getOTFeatures(); static UiFontAttribute *newFamily(const char *family); static UiFontAttribute *newSize(double size); static UiFontAttribute *newWeight(int weightAttribute); static UiFontAttribute *newItalic(int italicAttribute); static UiFontAttribute *newStretch(int stretchAttribute); - static UiFontAttribute *newColor(Color *c); - static UiFontAttribute *newBackground(Color *c); + static UiFontAttribute *newColor(Color c); + static UiFontAttribute *newBackground(Color c); static UiFontAttribute *newUnderline(int underlineAttr); - static UiFontAttribute *newUnderlineColor(int underlineColorAttr, Color *c); + static UiFontAttribute *newUnderlineColor(int underlineColorAttr, Color c); + static UiFontAttribute *newOTFeatures(UiOpenTypeFeatures *otf); }; @@ -686,6 +702,10 @@ class UiAttributedString { void setAttribute(UiFontAttribute *attr, size_t start, size_t end); // void forEachAttribute(uiAttributedStringForEachAttributeFunc f, void *data); + void appendAttributed(const char *str, UiFontAttribute *attr); + // TODO multiple attr? does nbind support variadic arguments? or use array? + void appendAttributed2(const char *str, UiFontAttribute *attr, UiFontAttribute *attr2); + size_t numGraphemes(); size_t byteIndexToGrapheme(size_t pos); size_t graphemeToByteIndex(size_t pos); @@ -698,7 +718,7 @@ class UiFontDescriptor { int buttonCleanup = 0; public: UiFontDescriptor(uiFontDescriptor *d); - UiFontDescriptor(char *family, double size, int weight, int italic, int stretch); + UiFontDescriptor(const char *family, double size, int weight, int italic, int stretch); void free(); char *getFamily(); double getSize(); @@ -708,7 +728,6 @@ class UiFontDescriptor { uiFontDescriptor *getHandle(); }; - class UiFontButton : public UiControl { DEFINE_EVENT(onChanged) From e58ee78b817a1dc4d58bfad58ace2a4c998c7a78 Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Mon, 26 Mar 2018 20:29:13 +0200 Subject: [PATCH 028/190] Added foreach --- examples/text.js | 16 +++++++++++----- index.js | 6 ++++++ src/Font/UiAttributedString.cc | 20 +++++++++++++++++--- src/Font/UiOpenTypeFeatures.cc | 16 +++++++++++----- src/ui-node.h | 15 +++++++++++++-- 5 files changed, 58 insertions(+), 15 deletions(-) diff --git a/examples/text.js b/examples/text.js index 139353d..7b241c9 100644 --- a/examples/text.js +++ b/examples/text.js @@ -49,22 +49,28 @@ str.appendAttributed2("special underlines for indicating spelling errors", UiFontAttribute.newUnderlineColor(libui.textUnderlineColor.spelling, new libui.Color(0, 0, 0, 0))); str.appendUnattributed(" (and other types of errors) "); -str.appendUnattributed("and control over OpenType features such as ligatures (for instance, "); +str.appendUnattributed("and control over OpenType features such as ligatures (with a suitable font - for instance, "); const otf = new libui.UiOpenTypeFeatures(); otf.add("liga", 0); -str.appendAttributed("afford", UiFontAttribute.newOTFeatures(otf)); +str.appendAttributed("affix", UiFontAttribute.newOTFeatures(otf)); str.appendUnattributed(" vs. "); otf.add("liga", 1); -str.appendAttributed("afford", UiFontAttribute.newOTFeatures(otf)); +str.appendAttributed("affix", UiFontAttribute.newOTFeatures(otf)); + +otf.forEach((feat, str, val)=>{ + console.log(feat, str, val); +}, null); + otf.free() str.appendUnattributed(").\n"); str.appendUnattributed("Use the controls opposite to the text to control properties of the text."); - - +str.forEach((str, attr, start, end)=>{ + console.log(feat, str, val); +}, null); diff --git a/index.js b/index.js index ef9c957..adccbed 100755 --- a/index.js +++ b/index.js @@ -146,6 +146,11 @@ const textAlign = { right: 2 }; +const forEach = { + continue: 0, + stop: 1 +} + module.exports.textWeight = textWeight; module.exports.textItalic = textItalic; @@ -154,6 +159,7 @@ module.exports.textAttributeType = textAttributeType; module.exports.textUnderline = textUnderline; module.exports.textUnderlineColor = textUnderlineColor; module.exports.textAlign = textAlign; +module.exports.forEach = forEach; module.exports.Size = Size; module.exports.Point = Point; module.exports.Color = Color; diff --git a/src/Font/UiAttributedString.cc b/src/Font/UiAttributedString.cc index 0732649..89e1056 100644 --- a/src/Font/UiAttributedString.cc +++ b/src/Font/UiAttributedString.cc @@ -2,6 +2,10 @@ #include "../ui-node.h" #include "nbind/nbind.h" +UiAttributedString::UiAttributedString(uiAttributedString *str) { + s = str; +} + UiAttributedString::UiAttributedString(const char *str) { s = uiNewAttributedString(str); } @@ -38,9 +42,18 @@ void UiAttributedString::setAttribute(UiFontAttribute *attr, size_t start, size_ uiAttributedStringSetAttribute(s, attr->getHandle(), start, end); } -// void forEachAttribute(uiAttributedStringForEachAttributeFunc f, void *data) { -// -// } +static unsigned int UiAttributedString__forEach(const uiAttributedString *s, const uiAttribute *a, size_t start, size_t end, void *d) { + return ((cb_data*)d)->cb.call( + UiAttributedString((uiAttributedString*)s), + UiFontAttribute((uiAttribute*)a), + start, end, ((cb_data*)d)->data); +} + +void UiAttributedString::forEach(nbind::cbFunction& cb, void *data) { + cb_data d = {cb, data}; + uiAttributedStringForEachAttribute(s, UiAttributedString__forEach, &d); +} + void UiAttributedString::appendAttributed(const char *str, UiFontAttribute *attr) { @@ -80,6 +93,7 @@ NBIND_CLASS(UiAttributedString) { method(toStringLen); method(appendUnattributed); method(insertUnattributed); + method(forEach); method(appendAttributed); method(appendAttributed2); // multimethod(appendAttributed, args(const char *, UiFontAttribute *)); diff --git a/src/Font/UiOpenTypeFeatures.cc b/src/Font/UiOpenTypeFeatures.cc index 9adab9a..59ea4d5 100644 --- a/src/Font/UiOpenTypeFeatures.cc +++ b/src/Font/UiOpenTypeFeatures.cc @@ -46,13 +46,18 @@ int UiOpenTypeFeatures::get(const char *c, uint32_t *value) { return uiOpenTypeFeaturesGet(f, c[0], c[1], c[2], c[3], value); } +static unsigned int UiOpenTypeFeatures__forEach(const uiOpenTypeFeatures *otf, char a, char b, char c, char d, uint32_t value, void *data) { + const char str[4] = {a, b, c, d}; -// uiOpenTypeFeaturesForEach() executes f for every tag-value -// pair in otf. The enumeration order is unspecified. You cannot -// modify otf while uiOpenTypeFeaturesForEach() is running. -// typedef uiForEach (*uiOpenTypeFeaturesForEachFunc)(const uiOpenTypeFeatures *otf, char a, char b, char c, char d, uint32_t value, void *data); -// _UI_EXTERN void uiOpenTypeFeaturesForEach(const uiOpenTypeFeatures *otf, uiOpenTypeFeaturesForEachFunc f, void *data); + return ((cb_data*)data)->cb.call( + UiOpenTypeFeatures((uiOpenTypeFeatures*)otf), + str, value, ((cb_data*)data)->data); +} +void UiOpenTypeFeatures::forEach(nbind::cbFunction& cb, void *data) { + cb_data d = {cb, data}; + uiOpenTypeFeaturesForEach(f, UiOpenTypeFeatures__forEach, &d); +} NBIND_CLASS(UiOpenTypeFeatures) { construct<>(); @@ -61,4 +66,5 @@ NBIND_CLASS(UiOpenTypeFeatures) { method(add); method(remove); method(get); + method(forEach); } diff --git a/src/ui-node.h b/src/ui-node.h index 426791a..20ec4b2 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -108,6 +108,11 @@ method(append); \ method(deleteAt); +typedef struct cb_data { + nbind::cbFunction& cb; + void *data; +} cb_data; + class UiControl { private: uiControl* handle; @@ -648,14 +653,17 @@ class UiOpenTypeFeatures { void add(const char *c, uint32_t value); void remove(const char *c); int get(const char *c, uint32_t *value); + + void forEach(nbind::cbFunction& cb, void *data); + }; class UiFontAttribute { private: - UiFontAttribute(uiAttribute *a); uiAttribute* a; public: + UiFontAttribute(uiAttribute *a); // DON'T CALL IF USED IN AN AttributedString void free(); int getAttributeType(); @@ -690,6 +698,7 @@ class UiAttributedString { private: uiAttributedString* s; public: + UiAttributedString(uiAttributedString *str); UiAttributedString(const char *str); void free(); uiAttributedString *getHandle(); @@ -700,12 +709,14 @@ class UiAttributedString { void insertUnattributed(const char *str, size_t at); void deleteString(size_t start, size_t end); void setAttribute(UiFontAttribute *attr, size_t start, size_t end); - // void forEachAttribute(uiAttributedStringForEachAttributeFunc f, void *data); void appendAttributed(const char *str, UiFontAttribute *attr); // TODO multiple attr? does nbind support variadic arguments? or use array? void appendAttributed2(const char *str, UiFontAttribute *attr, UiFontAttribute *attr2); + void forEach(nbind::cbFunction& cb, void *data); + + size_t numGraphemes(); size_t byteIndexToGrapheme(size_t pos); size_t graphemeToByteIndex(size_t pos); From e7b6b15a8acfec75aa11a6fb7510a555f6797e3b Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Mon, 26 Mar 2018 20:51:02 +0200 Subject: [PATCH 029/190] bump libui version [UNSTABLE VERSION ON MASTER] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7aa4bd4..0e0f225 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Node.js bindings for libui", "repository": "parro-it/libui-node", "license": "MIT", - "libui": "alpha3.5-004", + "libui": "alpha3.5-master-001", "contributors": [ { "name": "Andrea Parodi", From a7748017ba3eb25e9404d7bbbbca368d6e0a7922 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Mon, 26 Mar 2018 21:15:07 +0200 Subject: [PATCH 030/190] Removed `void* data` parameter from public forEach methods. --- examples/text.js | 8 ++++---- src/Font/UiAttributedString.cc | 16 +++++++++------- src/Font/UiOpenTypeFeatures.cc | 13 ++++++------- src/ui-node.h | 9 ++------- 4 files changed, 21 insertions(+), 25 deletions(-) diff --git a/examples/text.js b/examples/text.js index 7b241c9..0882eb0 100644 --- a/examples/text.js +++ b/examples/text.js @@ -60,8 +60,8 @@ otf.add("liga", 1); str.appendAttributed("affix", UiFontAttribute.newOTFeatures(otf)); otf.forEach((feat, str, val)=>{ - console.log(feat, str, val); -}, null); + console.log({feat, str, val}); +}); otf.free() str.appendUnattributed(").\n"); @@ -69,8 +69,8 @@ str.appendUnattributed(").\n"); str.appendUnattributed("Use the controls opposite to the text to control properties of the text."); str.forEach((str, attr, start, end)=>{ - console.log(feat, str, val); -}, null); + console.log({str, attr, start, end}); +}); diff --git a/src/Font/UiAttributedString.cc b/src/Font/UiAttributedString.cc index 89e1056..211fc19 100644 --- a/src/Font/UiAttributedString.cc +++ b/src/Font/UiAttributedString.cc @@ -42,16 +42,18 @@ void UiAttributedString::setAttribute(UiFontAttribute *attr, size_t start, size_ uiAttributedStringSetAttribute(s, attr->getHandle(), start, end); } -static unsigned int UiAttributedString__forEach(const uiAttributedString *s, const uiAttribute *a, size_t start, size_t end, void *d) { - return ((cb_data*)d)->cb.call( +static unsigned int UiAttributedString__forEach(const uiAttributedString *s, const uiAttribute *a, size_t start, size_t end, void *data) { + nbind::cbFunction *cb = (nbind::cbFunction *) data; + + return cb->call( UiAttributedString((uiAttributedString*)s), UiFontAttribute((uiAttribute*)a), - start, end, ((cb_data*)d)->data); + start, end, NULL); } -void UiAttributedString::forEach(nbind::cbFunction& cb, void *data) { - cb_data d = {cb, data}; - uiAttributedStringForEachAttribute(s, UiAttributedString__forEach, &d); +void UiAttributedString::forEach(nbind::cbFunction& cb) { + + uiAttributedStringForEachAttribute(s, UiAttributedString__forEach, &cb); } @@ -69,7 +71,7 @@ void UiAttributedString::appendAttributed2(const char *str, UiFontAttribute *att this->appendUnattributed(str); this->setAttribute(attr, start, end); if(attr2 != nullptr){ - this->setAttribute(attr2, start, end); + this->setAttribute(attr2, start, end); } } diff --git a/src/Font/UiOpenTypeFeatures.cc b/src/Font/UiOpenTypeFeatures.cc index 59ea4d5..f1d18fd 100644 --- a/src/Font/UiOpenTypeFeatures.cc +++ b/src/Font/UiOpenTypeFeatures.cc @@ -33,7 +33,7 @@ void UiOpenTypeFeatures::remove(const char *c) { // uiOpenTypeFeaturesGet() determines whether the given feature // tag is present in otf. If it is, *value is set to the tag's value and // nonzero is returned. Otherwise, zero is returned. -// +// // Note that if uiOpenTypeFeaturesGet() returns zero, value isn't // changed. This is important: if a feature is not present in a // uiOpenTypeFeatures, the feature is NOT treated as if its @@ -48,15 +48,14 @@ int UiOpenTypeFeatures::get(const char *c, uint32_t *value) { static unsigned int UiOpenTypeFeatures__forEach(const uiOpenTypeFeatures *otf, char a, char b, char c, char d, uint32_t value, void *data) { const char str[4] = {a, b, c, d}; - - return ((cb_data*)data)->cb.call( + nbind::cbFunction *cb = (nbind::cbFunction *) data; + return cb->call( UiOpenTypeFeatures((uiOpenTypeFeatures*)otf), - str, value, ((cb_data*)data)->data); + str, value, NULL); } -void UiOpenTypeFeatures::forEach(nbind::cbFunction& cb, void *data) { - cb_data d = {cb, data}; - uiOpenTypeFeaturesForEach(f, UiOpenTypeFeatures__forEach, &d); +void UiOpenTypeFeatures::forEach(nbind::cbFunction& cb) { + uiOpenTypeFeaturesForEach(f, UiOpenTypeFeatures__forEach, &cb); } NBIND_CLASS(UiOpenTypeFeatures) { diff --git a/src/ui-node.h b/src/ui-node.h index 20ec4b2..212a890 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -108,11 +108,6 @@ method(append); \ method(deleteAt); -typedef struct cb_data { - nbind::cbFunction& cb; - void *data; -} cb_data; - class UiControl { private: uiControl* handle; @@ -654,7 +649,7 @@ class UiOpenTypeFeatures { void remove(const char *c); int get(const char *c, uint32_t *value); - void forEach(nbind::cbFunction& cb, void *data); + void forEach(nbind::cbFunction& cb); }; @@ -714,7 +709,7 @@ class UiAttributedString { // TODO multiple attr? does nbind support variadic arguments? or use array? void appendAttributed2(const char *str, UiFontAttribute *attr, UiFontAttribute *attr2); - void forEach(nbind::cbFunction& cb, void *data); + void forEach(nbind::cbFunction& cb); size_t numGraphemes(); From 2baefd3a52edd123ecd2121fbb8259ae6741b8af Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Mon, 26 Mar 2018 21:59:48 +0200 Subject: [PATCH 031/190] Fix `Designated Initializers` not qorking on Windows --- examples/text.js | 1 - src/UiArea/DrawTextLayout.cc | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/examples/text.js b/examples/text.js index 0882eb0..a644f8b 100644 --- a/examples/text.js +++ b/examples/text.js @@ -73,7 +73,6 @@ str.forEach((str, attr, start, end)=>{ }); - function handlerDraw(area, p) { const font = fontButton.getFont(); diff --git a/src/UiArea/DrawTextLayout.cc b/src/UiArea/DrawTextLayout.cc index ae35948..168c6a3 100644 --- a/src/UiArea/DrawTextLayout.cc +++ b/src/UiArea/DrawTextLayout.cc @@ -4,10 +4,10 @@ DrawTextLayout::DrawTextLayout(UiAttributedString *str, UiFontDescriptor *defaultFont, double width, int align) { uiDrawTextLayoutParams params = { - .String = str->getHandle(), - .DefaultFont = defaultFont->getHandle(), - .Width = width, - .Align = (uiDrawTextAlign) align + str->getHandle(), + defaultFont->getHandle(), + width, + (uiDrawTextAlign) align }; handle = uiDrawNewTextLayout(¶ms); From 54fe2bd4cfcfc7d40047d75174402414001f1e5b Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Mon, 26 Mar 2018 22:01:19 +0200 Subject: [PATCH 032/190] Lint JS, add string null terminator --- examples/text.js | 94 +++++++++++++++++----------------- index.js | 5 +- src/Font/UiOpenTypeFeatures.cc | 2 +- 3 files changed, 48 insertions(+), 53 deletions(-) diff --git a/examples/text.js b/examples/text.js index a644f8b..6ba61e8 100644 --- a/examples/text.js +++ b/examples/text.js @@ -1,78 +1,76 @@ 'use strict'; /* eslint-disable unicorn/number-literal-case */ const libui = require('..'); -const { UiFontAttribute } = libui; + +const {UiFontAttribute} = libui; let textDrawArea; let fontButton; let align; const str = new libui.UiAttributedString( - "Drawing strings with libui is done with the uiAttributedString and uiDrawTextLayout objects.\n"+ - "uiAttributedString lets you have a variety of attributes: "); - -str.appendAttributed("font family", UiFontAttribute.newFamily("Courier New")); -str.appendUnattributed(", "); + 'Drawing strings with libui is done with the uiAttributedString and uiDrawTextLayout objects.\n' + + 'uiAttributedString lets you have a variety of attributes: '); +str.appendAttributed('font family', UiFontAttribute.newFamily('Courier New')); +str.appendUnattributed(', '); -str.appendAttributed("font size", UiFontAttribute.newSize(18)); -str.appendUnattributed(", "); +str.appendAttributed('font size', UiFontAttribute.newSize(18)); +str.appendUnattributed(', '); -str.appendAttributed("font weight", UiFontAttribute.newWeight(libui.textWeight.bold)); -str.appendUnattributed(", "); +str.appendAttributed('font weight', UiFontAttribute.newWeight(libui.textWeight.bold)); +str.appendUnattributed(', '); -str.appendAttributed("font italicness", UiFontAttribute.newItalic(libui.textItalic.italic)); -str.appendUnattributed(", "); +str.appendAttributed('font italicness', UiFontAttribute.newItalic(libui.textItalic.italic)); +str.appendUnattributed(', '); -str.appendAttributed("font stretch", UiFontAttribute.newStretch(libui.textStretch.condensed)); -str.appendUnattributed(", "); +str.appendAttributed('font stretch', UiFontAttribute.newStretch(libui.textStretch.condensed)); +str.appendUnattributed(', '); -str.appendAttributed("text color", UiFontAttribute.newColor(new libui.Color(0.75, 0.25, 0.5, 0.75))); -str.appendUnattributed(", "); +str.appendAttributed('text color', UiFontAttribute.newColor(new libui.Color(0.75, 0.25, 0.5, 0.75))); +str.appendUnattributed(', '); -str.appendAttributed("text background color", UiFontAttribute.newBackground(new libui.Color(0.5, 0.5, 0.25, 0.5))); -str.appendUnattributed(", "); +str.appendAttributed('text background color', UiFontAttribute.newBackground(new libui.Color(0.5, 0.5, 0.25, 0.5))); +str.appendUnattributed(', '); +str.appendAttributed('underline style', UiFontAttribute.newUnderline(libui.textUnderline.single)); +str.appendUnattributed(', '); -str.appendAttributed("underline style", UiFontAttribute.newUnderline(libui.textUnderline.single)); -str.appendUnattributed(", "); +str.appendUnattributed('and '); +str.appendAttributed2('underline color', + UiFontAttribute.newUnderline(libui.textUnderline.double), + UiFontAttribute.newUnderlineColor(libui.textUnderlineColor.custom, new libui.Color(1.0, 0.0, 0.5, 1.0))); +str.appendUnattributed('. '); -str.appendUnattributed("and "); -str.appendAttributed2("underline color", - UiFontAttribute.newUnderline(libui.textUnderline.double), - UiFontAttribute.newUnderlineColor(libui.textUnderlineColor.custom, new libui.Color(1.0, 0.0, 0.5, 1.0))); -str.appendUnattributed(". "); +str.appendUnattributed('Furthermore, there are attributes allowing for '); +str.appendAttributed2('special underlines for indicating spelling errors', + UiFontAttribute.newUnderline(libui.textUnderline.suggestion), + UiFontAttribute.newUnderlineColor(libui.textUnderlineColor.spelling, new libui.Color(0, 0, 0, 0))); +str.appendUnattributed(' (and other types of errors) '); -str.appendUnattributed("Furthermore, there are attributes allowing for "); -str.appendAttributed2("special underlines for indicating spelling errors", - UiFontAttribute.newUnderline(libui.textUnderline.suggestion), - UiFontAttribute.newUnderlineColor(libui.textUnderlineColor.spelling, new libui.Color(0, 0, 0, 0))); -str.appendUnattributed(" (and other types of errors) "); - -str.appendUnattributed("and control over OpenType features such as ligatures (with a suitable font - for instance, "); +str.appendUnattributed('and control over OpenType features such as ligatures (with a suitable font - for instance, '); const otf = new libui.UiOpenTypeFeatures(); -otf.add("liga", 0); -str.appendAttributed("affix", UiFontAttribute.newOTFeatures(otf)); -str.appendUnattributed(" vs. "); +otf.add('liga', 0); +str.appendAttributed('affix', UiFontAttribute.newOTFeatures(otf)); +str.appendUnattributed(' vs. '); -otf.add("liga", 1); -str.appendAttributed("affix", UiFontAttribute.newOTFeatures(otf)); +otf.add('liga', 1); +str.appendAttributed('affix', UiFontAttribute.newOTFeatures(otf)); -otf.forEach((feat, str, val)=>{ +otf.forEach((feat, str, val) => { console.log({feat, str, val}); }); -otf.free() -str.appendUnattributed(").\n"); +otf.free(); +str.appendUnattributed(').\n'); -str.appendUnattributed("Use the controls opposite to the text to control properties of the text."); +str.appendUnattributed('Use the controls opposite to the text to control properties of the text.'); -str.forEach((str, attr, start, end)=>{ +str.forEach((str, attr, start, end) => { console.log({str, attr, start, end}); }); - function handlerDraw(area, p) { const font = fontButton.getFont(); @@ -114,13 +112,13 @@ function main() { vbox.append(form, false); align = new libui.UiCombobox(); - // note that the items match with the values of the uiDrawTextAlign values - align.append("Left"); - align.append("Center"); - align.append("Right"); + // Note that the items match with the values of the uiDrawTextAlign values + align.append('Left'); + align.append('Center'); + align.append('Right'); align.setSelected(0); align.onSelected(redraw); - form.append("Alignment", align, false); + form.append('Alignment', align, false); textDrawArea = new libui.UiArea(handlerDraw, noop, noop, noop, noop); hbox.append(textDrawArea, true); diff --git a/index.js b/index.js index adccbed..e5b8a7d 100755 --- a/index.js +++ b/index.js @@ -111,7 +111,6 @@ const textStretch = { ultraExpanded: 8 }; - const textAttributeType = { family: 0, size: 1, @@ -125,7 +124,6 @@ const textAttributeType = { features: 9 }; - const textUnderline = { none: 0, single: 1, @@ -149,8 +147,7 @@ const textAlign = { const forEach = { continue: 0, stop: 1 -} - +}; module.exports.textWeight = textWeight; module.exports.textItalic = textItalic; diff --git a/src/Font/UiOpenTypeFeatures.cc b/src/Font/UiOpenTypeFeatures.cc index f1d18fd..6f8a8cb 100644 --- a/src/Font/UiOpenTypeFeatures.cc +++ b/src/Font/UiOpenTypeFeatures.cc @@ -47,7 +47,7 @@ int UiOpenTypeFeatures::get(const char *c, uint32_t *value) { } static unsigned int UiOpenTypeFeatures__forEach(const uiOpenTypeFeatures *otf, char a, char b, char c, char d, uint32_t value, void *data) { - const char str[4] = {a, b, c, d}; + const char str[5] = {a, b, c, d, '\0'}; nbind::cbFunction *cb = (nbind::cbFunction *) data; return cb->call( UiOpenTypeFeatures((uiOpenTypeFeatures*)otf), From 4eba3ff01823867f99b645b5a740eafe84db6220 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Mon, 26 Mar 2018 22:09:49 +0200 Subject: [PATCH 033/190] Try to cast the char[] arg to char* --- src/Font/UiOpenTypeFeatures.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Font/UiOpenTypeFeatures.cc b/src/Font/UiOpenTypeFeatures.cc index 6f8a8cb..d22c832 100644 --- a/src/Font/UiOpenTypeFeatures.cc +++ b/src/Font/UiOpenTypeFeatures.cc @@ -51,7 +51,7 @@ static unsigned int UiOpenTypeFeatures__forEach(const uiOpenTypeFeatures *otf, c nbind::cbFunction *cb = (nbind::cbFunction *) data; return cb->call( UiOpenTypeFeatures((uiOpenTypeFeatures*)otf), - str, value, NULL); + &str[0], value, NULL); } void UiOpenTypeFeatures::forEach(nbind::cbFunction& cb) { From 1643eddb5ec7c68a80758e24a19053a21a0dd5ef Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Mon, 26 Mar 2018 22:25:57 +0200 Subject: [PATCH 034/190] Cleanup callback parameters (and silence warning) --- src/Font/UiAttributedString.cc | 2 +- src/Font/UiOpenTypeFeatures.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Font/UiAttributedString.cc b/src/Font/UiAttributedString.cc index 211fc19..4367ce5 100644 --- a/src/Font/UiAttributedString.cc +++ b/src/Font/UiAttributedString.cc @@ -48,7 +48,7 @@ static unsigned int UiAttributedString__forEach(const uiAttributedString *s, con return cb->call( UiAttributedString((uiAttributedString*)s), UiFontAttribute((uiAttribute*)a), - start, end, NULL); + start, end); } void UiAttributedString::forEach(nbind::cbFunction& cb) { diff --git a/src/Font/UiOpenTypeFeatures.cc b/src/Font/UiOpenTypeFeatures.cc index d22c832..c5bb504 100644 --- a/src/Font/UiOpenTypeFeatures.cc +++ b/src/Font/UiOpenTypeFeatures.cc @@ -51,7 +51,7 @@ static unsigned int UiOpenTypeFeatures__forEach(const uiOpenTypeFeatures *otf, c nbind::cbFunction *cb = (nbind::cbFunction *) data; return cb->call( UiOpenTypeFeatures((uiOpenTypeFeatures*)otf), - &str[0], value, NULL); + &str[0], value); } void UiOpenTypeFeatures::forEach(nbind::cbFunction& cb) { From faa4b9ddc4b0a38872b2d3dea5f58fe5e5495ebd Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Mon, 26 Mar 2018 22:41:42 +0200 Subject: [PATCH 035/190] Cleaner overload (no API change) --- examples/text.js | 6 +++++- src/Font/UiAttributedString.cc | 12 +++++------- src/ui-node.h | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/examples/text.js b/examples/text.js index 6ba61e8..9febc9c 100644 --- a/examples/text.js +++ b/examples/text.js @@ -46,7 +46,11 @@ str.appendUnattributed('Furthermore, there are attributes allowing for '); str.appendAttributed2('special underlines for indicating spelling errors', UiFontAttribute.newUnderline(libui.textUnderline.suggestion), UiFontAttribute.newUnderlineColor(libui.textUnderlineColor.spelling, new libui.Color(0, 0, 0, 0))); -str.appendUnattributed(' (and other types of errors) '); +str.appendUnattributed(' (and '); +str.appendAttributed2('other types of errors', + UiFontAttribute.newUnderline(libui.textUnderline.suggestion), + UiFontAttribute.newUnderlineColor(libui.textUnderlineColor.grammar, new libui.Color(0, 0, 0, 0))); +str.appendUnattributed(') '); str.appendUnattributed('and control over OpenType features such as ligatures (with a suitable font - for instance, '); diff --git a/src/Font/UiAttributedString.cc b/src/Font/UiAttributedString.cc index 4367ce5..c3895e3 100644 --- a/src/Font/UiAttributedString.cc +++ b/src/Font/UiAttributedString.cc @@ -59,11 +59,11 @@ void UiAttributedString::forEach(nbind::cbFunction& cb) { void UiAttributedString::appendAttributed(const char *str, UiFontAttribute *attr) { - this->appendAttributed2(str, attr, nullptr); + this->appendAttributed(str, attr, nullptr); } -void UiAttributedString::appendAttributed2(const char *str, UiFontAttribute *attr, UiFontAttribute *attr2) { +void UiAttributedString::appendAttributed(const char *str, UiFontAttribute *attr, UiFontAttribute *attr2) { size_t start = this->toStringLen(); // TODO how this (and strlen) work with unicode? size_t end = start + strlen(str); @@ -96,13 +96,11 @@ NBIND_CLASS(UiAttributedString) { method(appendUnattributed); method(insertUnattributed); method(forEach); - method(appendAttributed); - method(appendAttributed2); - // multimethod(appendAttributed, args(const char *, UiFontAttribute *)); - // multimethod(appendAttributed, args(const char *, UiFontAttribute *, UiFontAttribute *), "appendAttributed2"); + multimethod(appendAttributed, args(const char *, UiFontAttribute *)); + multimethod(appendAttributed, args(const char *, UiFontAttribute *, UiFontAttribute *), "appendAttributed2"); method(deleteString); method(setAttribute); - // method(forEachAttribute); + method(numGraphemes); method(byteIndexToGrapheme); method(graphemeToByteIndex); diff --git a/src/ui-node.h b/src/ui-node.h index 212a890..670799e 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -706,8 +706,8 @@ class UiAttributedString { void setAttribute(UiFontAttribute *attr, size_t start, size_t end); void appendAttributed(const char *str, UiFontAttribute *attr); + void appendAttributed(const char *str, UiFontAttribute *attr, UiFontAttribute *attr2); // TODO multiple attr? does nbind support variadic arguments? or use array? - void appendAttributed2(const char *str, UiFontAttribute *attr, UiFontAttribute *attr2); void forEach(nbind::cbFunction& cb); From b7f279d58cfdec3f65bf32d80ae39b6519c130e5 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Tue, 27 Mar 2018 22:44:59 +0200 Subject: [PATCH 036/190] Add event-loop example --- examples/event-loop.js | 115 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 examples/event-loop.js diff --git a/examples/event-loop.js b/examples/event-loop.js new file mode 100644 index 0000000..882e6cf --- /dev/null +++ b/examples/event-loop.js @@ -0,0 +1,115 @@ +'use strict'; +const libui = require('..'); + +let setIntervalHandle = null; +let setIntervalLast = Date.now(); + +const win = new libui.UiWindow('Event loop tests', 800, 600, false); +win.margined = 1; + +const box = new libui.UiVerticalBox(); +box.padded = true; +win.setChild(box); + +const setIntervalMs = new libui.UiSlider(0, 1000); +setIntervalMs.onChanged(setIntervalChanged); +setIntervalMs.value = 0; + +const form = new libui.UiForm(); +form.padded = true; +form.append('setInterval', setIntervalMs, 0); +form.append('actions', makeToolbar(), 0); +box.append(form, true); + +const log = new libui.UiMultilineEntry(); +box.append(log, true); + +win.onClosing(() => { + if (setIntervalHandle !== null) { + clearInterval(setIntervalHandle); + setIntervalHandle = null; + } + win.close(); + libui.stopLoop(); +}); + +win.show(); +libui.startLoop(); + +function logAppend(line) { + const lines = log.text.split('\n'); + if (lines.length > 20) { + log.text = lines.slice(1).join('\n'); + } + log.append(line + '\n'); +} + +function setIntervalChanged() { + const ms = setIntervalMs.value; + if (setIntervalHandle !== null) { + clearInterval(setIntervalHandle); + setIntervalHandle = null; + } + + if (ms > 0) { + setIntervalHandle = setInterval(() => { + const now = Date.now(); + const elapsed = now - setIntervalLast; + logAppend(`setInterval:${now} - elapsed ${elapsed} ms`); + setIntervalLast = now; + }, ms); + } +} + +function makeToolbar() { + const toolbar = new libui.UiHorizontalBox(); + toolbar.padded = true; + + const btnSetImmediate = new libui.UiButton('setImmediate'); + btnSetImmediate.onClicked(() => { + const now = Date.now(); + setImmediate(() => { + const elapsed = Date.now() - now; + logAppend(`setImmediate:${now} - elapsed ${elapsed} ms`); + }); + }); + + toolbar.append(btnSetImmediate, false); + + const btnPromise = new libui.UiButton('Promise'); + btnPromise.onClicked(() => { + const now = Date.now(); + + Promise.resolve(true).then(() => { + const elapsed = Date.now() - now; + logAppend(`Promise: ${now} - elapsed ${elapsed} ms`); + }); + }); + + toolbar.append(btnPromise, false); + + const btnNextTick = new libui.UiButton('NextTick'); + btnNextTick.onClicked(() => { + const now = Date.now(); + process.nextTick(() => { + const elapsed = Date.now() - now; + logAppend(`nextTick:${now} - elapsed ${elapsed} ms`); + }); + }); + + toolbar.append(btnNextTick, false); + + const btnReadFile = new libui.UiButton('ReadFile'); + btnReadFile.onClicked(() => { + const {createReadStream} = require('fs'); + const stream = createReadStream('/tmp/big'); + let i = 0; + stream.on('data', data => { + logAppend(`ReadFile: chunk ${i++} - ` + data.length); + }); + }); + + toolbar.append(btnReadFile, false); + + return toolbar; +} From b459fb70f47c555e629becefa0eb9c638fca4192 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Tue, 27 Mar 2018 22:46:30 +0200 Subject: [PATCH 037/190] Fixed double onClosing in core-api example --- examples/core-api.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/examples/core-api.js b/examples/core-api.js index 936f803..99e6234 100644 --- a/examples/core-api.js +++ b/examples/core-api.js @@ -5,9 +5,6 @@ const libui = require('..'); const win = new libui.UiWindow('Test window', 800, 600, false); win.margined = 1; -win.onClosing(() => { - libui.stopLoop(); -}); const box = new libui.UiVerticalBox(); const hBox = new libui.UiHorizontalBox(); From 2576fc86a8f7cbbbc1148b6c9be2717c9203fa42 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Tue, 27 Mar 2018 22:53:53 +0200 Subject: [PATCH 038/190] Add http server --- examples/event-loop.js | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/examples/event-loop.js b/examples/event-loop.js index 882e6cf..8720542 100644 --- a/examples/event-loop.js +++ b/examples/event-loop.js @@ -2,6 +2,7 @@ const libui = require('..'); let setIntervalHandle = null; +let lastTimeout = 0; let setIntervalLast = Date.now(); const win = new libui.UiWindow('Event loop tests', 800, 600, false); @@ -38,14 +39,18 @@ libui.startLoop(); function logAppend(line) { const lines = log.text.split('\n'); - if (lines.length > 20) { + /*if (lines.length > 20) { log.text = lines.slice(1).join('\n'); - } + }*/ log.append(line + '\n'); } function setIntervalChanged() { const ms = setIntervalMs.value; + if (Math.abs(ms - lastTimeout) < 100) { + return; + } + lastTimeout = ms; if (setIntervalHandle !== null) { clearInterval(setIntervalHandle); setIntervalHandle = null; @@ -109,7 +114,23 @@ function makeToolbar() { }); }); - toolbar.append(btnReadFile, false); + const btnHttp = new libui.UiButton('Http'); + btnHttp.onClicked(() => { + const http = require('http'); + let i = 0; + + const server = http.createServer((req, res) => { + res.writeHead(200, {'Content-Type': 'text/plain'}); + logAppend(`Http: request ${i}`); + res.end(String(i++)); + }); + + server.listen(3000, '127.0.0.1', () => { + logAppend('listening...'); + }); + }); + + toolbar.append(btnHttp, false); return toolbar; } From e0039847f3ed3cc3ac9fb1fc5aa0393e7713c3c3 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Tue, 27 Mar 2018 22:54:24 +0200 Subject: [PATCH 039/190] Restored limited lines --- examples/event-loop.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/event-loop.js b/examples/event-loop.js index 8720542..9c7cc54 100644 --- a/examples/event-loop.js +++ b/examples/event-loop.js @@ -39,9 +39,9 @@ libui.startLoop(); function logAppend(line) { const lines = log.text.split('\n'); - /*if (lines.length > 20) { + if (lines.length > 20) { log.text = lines.slice(1).join('\n'); - }*/ + } log.append(line + '\n'); } From aabd7f2921c76d6b8f23b3d7ad4395854947778e Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Tue, 27 Mar 2018 23:06:11 +0200 Subject: [PATCH 040/190] Overview for documentation --- docs/area.md | 3 +- docs/attributedstring.md | 184 +++++++++++++++++++++++++++++++++ src/Font/UiAttributedString.cc | 1 - src/Font/UiFontAttribute.cc | 2 - src/Font/UiOpenTypeFeatures.cc | 28 ++--- src/ui-node.h | 9 +- 6 files changed, 197 insertions(+), 30 deletions(-) create mode 100644 docs/attributedstring.md diff --git a/docs/area.md b/docs/area.md index afcb8d3..ac8cc7b 100644 --- a/docs/area.md +++ b/docs/area.md @@ -192,8 +192,7 @@ Draws a given text at the given (x,y) position. * x: Number - the horizontal position at which to draw the text. * y: Number - the vertical position at which to draw the text. -* layout: DrawTextLayout - the text to draw, complete with font and color information. - +* layout: DrawTextLayout (see [AttributedString](Attributedstring.md)) - the text to draw, complete with font, width and alignment information. # UiDrawPath diff --git a/docs/attributedstring.md b/docs/attributedstring.md new file mode 100644 index 0000000..035d9c3 --- /dev/null +++ b/docs/attributedstring.md @@ -0,0 +1,184 @@ +# AttributedString + +```cpp +class UiOpenTypeFeatures { + public: + UiOpenTypeFeatures(); + void free(); + + static UiOpenTypeFeatures *clone(UiOpenTypeFeatures *f2); + void add(const char *tag, uint32_t value); + void remove(const char *tag); + // uiOpenTypeFeaturesGet() determines whether the given feature + // tag is present in otf. If it is, *value is set to the tag's value and + // nonzero is returned. Otherwise, zero is returned. + // + // Note that if uiOpenTypeFeaturesGet() returns zero, value isn't + // changed. This is important: if a feature is not present in a + // uiOpenTypeFeatures, the feature is NOT treated as if its + // value was zero anyway. Script-specific font shaping rules and + // font-specific feature settings may use a different default value + // for a feature. You should likewise not treat a missing feature as + // having a value of zero either. Instead, a missing feature should + // be treated as having some unspecified default value. + int get(const char *tag, uint32_t *value); + + // cb(UiOpenTypeFeatures, tag, value) + void forEach(nbind::cbFunction& cb); +}; + +class UiFontAttribute { + public: + // DON'T CALL IF USED/APPENDED IN AN AttributedString + void free(); + int getAttributeType(); + + // It is an error to call this on a uiAttribute that does not hold the corresponding type + const char *getFamily(); + double getSize(); + int getWeight(); + int getItalic(); + int getStretch(); + Color getColor(); + int getUnderline(); + int getUnderlineColor(Color *c); + UiOpenTypeFeatures *getOTFeatures(); + + static UiFontAttribute *newFamily(const char *family); + static UiFontAttribute *newSize(double size); + static UiFontAttribute *newWeight(int weightAttribute); + static UiFontAttribute *newItalic(int italicAttribute); + static UiFontAttribute *newStretch(int stretchAttribute); + static UiFontAttribute *newColor(Color c); + static UiFontAttribute *newBackground(Color c); + static UiFontAttribute *newUnderline(int underlineAttr); + static UiFontAttribute *newUnderlineColor(int underlineColorAttr, Color c); + static UiFontAttribute *newOTFeatures(UiOpenTypeFeatures *otf); +}; + + +class UiAttributedString { + UiAttributedString(const char *str); + void free(); + const char * toString(); + size_t toStringLen(); + + void appendUnattributed(const char *str); + void insertUnattributed(const char *str, size_t at); + void deleteString(size_t start, size_t end); + void setAttribute(UiFontAttribute *attr, size_t start, size_t end); + + //TODO overloaded in javascript? + void appendAttributed(const char *str, UiFontAttribute *attr); + void appendAttributed(const char *str, UiFontAttribute *attr, UiFontAttribute *attr2); + + void forEach(nbind::cbFunction& cb); + + size_t numGraphemes(); + size_t byteIndexToGrapheme(size_t pos); + size_t graphemeToByteIndex(size_t pos); +}; + +class UiFontDescriptor { + UiFontDescriptor(const char *family, double size, int weight, int italic, int stretch); + void free(); + char *getFamily(); + double getSize(); + int getWeight(); + int getItalic(); + int getStretch(); + uiFontDescriptor *getHandle(); +}; + +class UiFontButton : public UiControl { + UiFontButton(); + UiFontDescriptor* getFont(); + // onChanged, default button +}; + + +class DrawTextLayout { + public: + DrawTextLayout(UiAttributedString *s, UiFontDescriptor *defaultFont, double width, int align); + void free(); + SizeDouble getExtents(); + uiDrawTextLayout* getHandle(); +}; +``` + +for drawing: see Area: `UiDrawContext.text` + + +```js +libui.textWeight = { + minimum: 0, + thin: 100, + ultraLight: 200, + light: 300, + book: 350, + normal: 400, + medium: 500, + semiBold: 600, + bold: 700, + ultraBold: 800, + heavy: 900, + ultraHeavy: 950, + maximum: 1000 +}; + +libui.textItalic = { + normal: 0, + oblique: 1, + italic: 2 +}; + +libui.textStretch = { + ultraCondensed: 0, + extraCondensed: 1, + condensed: 2, + semiCondensed: 3, + normal: 4, + semiExpanded: 5, + expanded: 6, + extraExpanded: 7, + ultraExpanded: 8 +}; + +libui.textAttributeType = { + family: 0, + size: 1, + weight: 2, + italic: 3, + stretch: 4, + color: 5, + background: 6, + underline: 7, + underlineColor: 8, + features: 9 +}; + +libui.textUnderline = { + none: 0, + single: 1, + double: 2, + suggestion: 3 +}; + +libui.textUnderlineColor = { + custom: 0, + spelling: 1, + grammar: 2, + auxiliary: 3 +}; + +libui.textAlign = { + left: 0, + center: 1, + right: 2 +}; + +libui.forEach = { + continue: 0, + stop: 1 +}; +``` \ No newline at end of file diff --git a/src/Font/UiAttributedString.cc b/src/Font/UiAttributedString.cc index c3895e3..111148f 100644 --- a/src/Font/UiAttributedString.cc +++ b/src/Font/UiAttributedString.cc @@ -52,7 +52,6 @@ static unsigned int UiAttributedString__forEach(const uiAttributedString *s, con } void UiAttributedString::forEach(nbind::cbFunction& cb) { - uiAttributedStringForEachAttribute(s, UiAttributedString__forEach, &cb); } diff --git a/src/Font/UiFontAttribute.cc b/src/Font/UiFontAttribute.cc index 23fd07b..5451eb3 100644 --- a/src/Font/UiFontAttribute.cc +++ b/src/Font/UiFontAttribute.cc @@ -18,8 +18,6 @@ void UiFontAttribute::free(){ uiFreeAttribute(a); } -// TODO needs to actually be of that type -// It is an error to call this on a uiAttribute that does not hold a ... const char *UiFontAttribute::getFamily() { return uiAttributeFamily(a); } diff --git a/src/Font/UiOpenTypeFeatures.cc b/src/Font/UiOpenTypeFeatures.cc index c5bb504..4cce17b 100644 --- a/src/Font/UiOpenTypeFeatures.cc +++ b/src/Font/UiOpenTypeFeatures.cc @@ -22,36 +22,24 @@ UiOpenTypeFeatures *UiOpenTypeFeatures::clone(UiOpenTypeFeatures *f2) { return new UiOpenTypeFeatures(uiOpenTypeFeaturesClone(f2->f)); } -void UiOpenTypeFeatures::add(const char *c, uint32_t value) { - uiOpenTypeFeaturesAdd(f, c[0], c[1], c[2], c[3], value); +void UiOpenTypeFeatures::add(const char *tag, uint32_t value) { + uiOpenTypeFeaturesAdd(f, tag[0], tag[1], tag[2], tag[3], value); } -void UiOpenTypeFeatures::remove(const char *c) { - uiOpenTypeFeaturesRemove(f, c[0], c[1], c[2], c[3]); +void UiOpenTypeFeatures::remove(const char *tag) { + uiOpenTypeFeaturesRemove(f, tag[0], tag[1], tag[2], tag[3]); } -// uiOpenTypeFeaturesGet() determines whether the given feature -// tag is present in otf. If it is, *value is set to the tag's value and -// nonzero is returned. Otherwise, zero is returned. -// -// Note that if uiOpenTypeFeaturesGet() returns zero, value isn't -// changed. This is important: if a feature is not present in a -// uiOpenTypeFeatures, the feature is NOT treated as if its -// value was zero anyway. Script-specific font shaping rules and -// font-specific feature settings may use a different default value -// for a feature. You should likewise not treat a missing feature as -// having a value of zero either. Instead, a missing feature should -// be treated as having some unspecified default value. -int UiOpenTypeFeatures::get(const char *c, uint32_t *value) { - return uiOpenTypeFeaturesGet(f, c[0], c[1], c[2], c[3], value); +int UiOpenTypeFeatures::get(const char *tag, uint32_t *value) { + return uiOpenTypeFeaturesGet(f, tag[0], tag[1], tag[2], tag[3], value); } static unsigned int UiOpenTypeFeatures__forEach(const uiOpenTypeFeatures *otf, char a, char b, char c, char d, uint32_t value, void *data) { - const char str[5] = {a, b, c, d, '\0'}; + const char tag[5] = {a, b, c, d, '\0'}; nbind::cbFunction *cb = (nbind::cbFunction *) data; return cb->call( UiOpenTypeFeatures((uiOpenTypeFeatures*)otf), - &str[0], value); + &tag[0], value); } void UiOpenTypeFeatures::forEach(nbind::cbFunction& cb) { diff --git a/src/ui-node.h b/src/ui-node.h index 670799e..81804ca 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -645,9 +645,9 @@ class UiOpenTypeFeatures { uiOpenTypeFeatures *getHandle(); static UiOpenTypeFeatures *clone(UiOpenTypeFeatures *f2); - void add(const char *c, uint32_t value); - void remove(const char *c); - int get(const char *c, uint32_t *value); + void add(const char *tag, uint32_t value); + void remove(const char *tag); + int get(const char *tag, uint32_t *value); void forEach(nbind::cbFunction& cb); @@ -664,7 +664,7 @@ class UiFontAttribute { int getAttributeType(); uiAttribute *getHandle(); - // TODO needs to actually be of that type + // TODO needs to actually be of that type - maybe implement check and return -1 if wrong (or throw js error) // It is an error to call this on a uiAttribute that does not hold a ... const char *getFamily(); double getSize(); @@ -711,7 +711,6 @@ class UiAttributedString { void forEach(nbind::cbFunction& cb); - size_t numGraphemes(); size_t byteIndexToGrapheme(size_t pos); size_t graphemeToByteIndex(size_t pos); From afa4c6b015a3054286fe4c4c7052e327466feb0a Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Thu, 29 Mar 2018 00:15:21 +0200 Subject: [PATCH 041/190] Fix FontDescriptor crash, add example --- examples/text.js | 28 ++++++++++++++++++++-------- src/Font/UiFontDescriptor.cc | 6 +++++- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/examples/text.js b/examples/text.js index 9febc9c..c96f235 100644 --- a/examples/text.js +++ b/examples/text.js @@ -7,6 +7,7 @@ const {UiFontAttribute} = libui; let textDrawArea; let fontButton; let align; +let checkbox; const str = new libui.UiAttributedString( 'Drawing strings with libui is done with the uiAttributedString and uiDrawTextLayout objects.\n' + @@ -62,21 +63,24 @@ str.appendUnattributed(' vs. '); otf.add('liga', 1); str.appendAttributed('affix', UiFontAttribute.newOTFeatures(otf)); -otf.forEach((feat, str, val) => { - console.log({feat, str, val}); -}); +// otf.forEach((feat, str, val) => { +// console.log({feat, str, val}); +// }); otf.free(); str.appendUnattributed(').\n'); str.appendUnattributed('Use the controls opposite to the text to control properties of the text.'); -str.forEach((str, attr, start, end) => { - console.log({str, attr, start, end}); -}); +// str.forEach((str, attr, start, end) => { +// console.log({str, attr, start, end}); +// }); function handlerDraw(area, p) { - const font = fontButton.getFont(); + const font = checkbox.checked ? + new libui.UiFontDescriptor("Georgia", 14, libui.textWeight.normal, libui.textItalic.normal, libui.textStretch.normal) : + fontButton.getFont(); + const layout = new libui.DrawTextLayout(str, font, p.getAreaWidth(), align.getSelected()); @@ -115,8 +119,16 @@ function main() { form.padded = true; vbox.append(form, false); + checkbox = new libui.UiCheckbox(); + checkbox.text = "Use Georgia instead of button"; + checkbox.onToggled(()=>{ + fontButton.enabled = !checkbox.checked; + redraw(); + }) + vbox.append(checkbox, false); + align = new libui.UiCombobox(); - // Note that the items match with the values of the uiDrawTextAlign values + // Note that the items match with the valueorder of libui.textAlign align.append('Left'); align.append('Center'); align.append('Right'); diff --git a/src/Font/UiFontDescriptor.cc b/src/Font/UiFontDescriptor.cc index 9bd6462..ab8e280 100644 --- a/src/Font/UiFontDescriptor.cc +++ b/src/Font/UiFontDescriptor.cc @@ -9,7 +9,9 @@ UiFontDescriptor::UiFontDescriptor(uiFontDescriptor * desc) { UiFontDescriptor::UiFontDescriptor(const char *family, double size, int weight, int italic, int stretch) { d = new uiFontDescriptor(); - d->Family = (char*) family; + + d->Family = new char[strlen(family)]; + strcpy(d->Family, family); d->Size = size; d->Weight = weight; d->Italic = italic; @@ -19,6 +21,8 @@ UiFontDescriptor::UiFontDescriptor(const char *family, double size, int weight, void UiFontDescriptor::free() { if(buttonCleanup){ uiFreeFontButtonFont(d); + } else { + delete d->Family; } delete d; } From a4f0fc51bb7507adb5bb901d08cbc0e39ce039a6 Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Thu, 29 Mar 2018 09:30:47 +0200 Subject: [PATCH 042/190] Whoops --- index.js | 2 ++ src/Font/UiFontDescriptor.cc | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index e5b8a7d..d02354d 100755 --- a/index.js +++ b/index.js @@ -149,6 +149,8 @@ const forEach = { stop: 1 }; + + module.exports.textWeight = textWeight; module.exports.textItalic = textItalic; module.exports.textStretch = textStretch; diff --git a/src/Font/UiFontDescriptor.cc b/src/Font/UiFontDescriptor.cc index ab8e280..b6871bf 100644 --- a/src/Font/UiFontDescriptor.cc +++ b/src/Font/UiFontDescriptor.cc @@ -22,7 +22,7 @@ void UiFontDescriptor::free() { if(buttonCleanup){ uiFreeFontButtonFont(d); } else { - delete d->Family; + delete[] d->Family; } delete d; } From 145293a680125f1fd6c4a2f770c2bc46c134df7c Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Thu, 29 Mar 2018 09:51:25 +0200 Subject: [PATCH 043/190] Properly overload AttributedString.appendAttributed --- docs/attributedstring.md | 1 - examples/text.js | 29 ++++++++++++++--------------- index.js | 7 ++++++- src/Font/UiAttributedString.cc | 2 +- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/docs/attributedstring.md b/docs/attributedstring.md index 035d9c3..b437435 100644 --- a/docs/attributedstring.md +++ b/docs/attributedstring.md @@ -68,7 +68,6 @@ class UiAttributedString { void deleteString(size_t start, size_t end); void setAttribute(UiFontAttribute *attr, size_t start, size_t end); - //TODO overloaded in javascript? void appendAttributed(const char *str, UiFontAttribute *attr); void appendAttributed(const char *str, UiFontAttribute *attr, UiFontAttribute *attr2); diff --git a/examples/text.js b/examples/text.js index c96f235..1712a5e 100644 --- a/examples/text.js +++ b/examples/text.js @@ -38,19 +38,19 @@ str.appendAttributed('underline style', UiFontAttribute.newUnderline(libui.textU str.appendUnattributed(', '); str.appendUnattributed('and '); -str.appendAttributed2('underline color', +str.appendAttributed('underline color', UiFontAttribute.newUnderline(libui.textUnderline.double), UiFontAttribute.newUnderlineColor(libui.textUnderlineColor.custom, new libui.Color(1.0, 0.0, 0.5, 1.0))); str.appendUnattributed('. '); str.appendUnattributed('Furthermore, there are attributes allowing for '); -str.appendAttributed2('special underlines for indicating spelling errors', +str.appendAttributed('special underlines for indicating spelling errors', UiFontAttribute.newUnderline(libui.textUnderline.suggestion), UiFontAttribute.newUnderlineColor(libui.textUnderlineColor.spelling, new libui.Color(0, 0, 0, 0))); str.appendUnattributed(' (and '); -str.appendAttributed2('other types of errors', UiFontAttribute.newUnderline(libui.textUnderline.suggestion), UiFontAttribute.newUnderlineColor(libui.textUnderlineColor.grammar, new libui.Color(0, 0, 0, 0))); +str.appendAttributed('other types of errors', str.appendUnattributed(') '); str.appendUnattributed('and control over OpenType features such as ligatures (with a suitable font - for instance, '); @@ -63,24 +63,23 @@ str.appendUnattributed(' vs. '); otf.add('liga', 1); str.appendAttributed('affix', UiFontAttribute.newOTFeatures(otf)); -// otf.forEach((feat, str, val) => { -// console.log({feat, str, val}); -// }); +otf.forEach((feat, str, val) => { + console.log({feat, str, val}); +}); otf.free(); str.appendUnattributed(').\n'); str.appendUnattributed('Use the controls opposite to the text to control properties of the text.'); -// str.forEach((str, attr, start, end) => { -// console.log({str, attr, start, end}); -// }); +str.forEach((str, attr, start, end) => { + console.log({str, attr, start, end}); +}); function handlerDraw(area, p) { const font = checkbox.checked ? - new libui.UiFontDescriptor("Georgia", 14, libui.textWeight.normal, libui.textItalic.normal, libui.textStretch.normal) : - fontButton.getFont(); - + new libui.UiFontDescriptor('Georgia', 14, libui.textWeight.normal, libui.textItalic.normal, libui.textStretch.normal) : + fontButton.getFont(); const layout = new libui.DrawTextLayout(str, font, p.getAreaWidth(), align.getSelected()); @@ -120,11 +119,11 @@ function main() { vbox.append(form, false); checkbox = new libui.UiCheckbox(); - checkbox.text = "Use Georgia instead of button"; - checkbox.onToggled(()=>{ + checkbox.text = 'Use Georgia instead of button'; + checkbox.onToggled(() => { fontButton.enabled = !checkbox.checked; redraw(); - }) + }); vbox.append(checkbox, false); align = new libui.UiCombobox(); diff --git a/index.js b/index.js index d02354d..26b7348 100755 --- a/index.js +++ b/index.js @@ -149,7 +149,12 @@ const forEach = { stop: 1 }; - +binding.lib.UiAttributedString.prototype.appendAttributed = function (str, attr, attr2) { + if (attr2) { + return this.appendAttributed2(str, attr, attr2); + } + return this.appendAttributed1(str, attr); +}; module.exports.textWeight = textWeight; module.exports.textItalic = textItalic; diff --git a/src/Font/UiAttributedString.cc b/src/Font/UiAttributedString.cc index 111148f..3aeee1a 100644 --- a/src/Font/UiAttributedString.cc +++ b/src/Font/UiAttributedString.cc @@ -95,7 +95,7 @@ NBIND_CLASS(UiAttributedString) { method(appendUnattributed); method(insertUnattributed); method(forEach); - multimethod(appendAttributed, args(const char *, UiFontAttribute *)); + multimethod(appendAttributed, args(const char *, UiFontAttribute *), "appendAttributed1"); multimethod(appendAttributed, args(const char *, UiFontAttribute *, UiFontAttribute *), "appendAttributed2"); method(deleteString); method(setAttribute); From f7e720157e4c14daffbbc97a420620d6eb07a5dc Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Thu, 29 Mar 2018 10:20:33 +0200 Subject: [PATCH 044/190] Expose UiFontDescriptor.free --- examples/text.js | 5 +++-- src/Font/UiFontDescriptor.cc | 1 + src/ui-node.h | 1 - 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/text.js b/examples/text.js index 1712a5e..74cf2cd 100644 --- a/examples/text.js +++ b/examples/text.js @@ -4,6 +4,7 @@ const libui = require('..'); const {UiFontAttribute} = libui; +let mainwin; let textDrawArea; let fontButton; let align; @@ -48,9 +49,9 @@ str.appendAttributed('special underlines for indicating spelling errors', UiFontAttribute.newUnderline(libui.textUnderline.suggestion), UiFontAttribute.newUnderlineColor(libui.textUnderlineColor.spelling, new libui.Color(0, 0, 0, 0))); str.appendUnattributed(' (and '); +str.appendAttributed('other types of errors', UiFontAttribute.newUnderline(libui.textUnderline.suggestion), UiFontAttribute.newUnderlineColor(libui.textUnderlineColor.grammar, new libui.Color(0, 0, 0, 0))); -str.appendAttributed('other types of errors', str.appendUnattributed(') '); str.appendUnattributed('and control over OpenType features such as ligatures (with a suitable font - for instance, '); @@ -96,7 +97,7 @@ function redraw() { } function main() { - const mainwin = new libui.UiWindow('libui textDrawArea Example', 640, 480, 1); + mainwin = new libui.UiWindow('libui textDrawArea Example', 640, 480, 1); mainwin.margined = true; mainwin.onClosing(() => { libui.stopLoop(); diff --git a/src/Font/UiFontDescriptor.cc b/src/Font/UiFontDescriptor.cc index b6871bf..1d1cde5 100644 --- a/src/Font/UiFontDescriptor.cc +++ b/src/Font/UiFontDescriptor.cc @@ -54,6 +54,7 @@ uiFontDescriptor *UiFontDescriptor::getHandle(){ NBIND_CLASS(UiFontDescriptor) { construct(); + method(free); method(getFamily); method(getSize); method(getWeight); diff --git a/src/ui-node.h b/src/ui-node.h index 81804ca..6a55ac4 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -659,7 +659,6 @@ class UiFontAttribute { public: UiFontAttribute(uiAttribute *a); - // DON'T CALL IF USED IN AN AttributedString void free(); int getAttributeType(); uiAttribute *getHandle(); From c20e9c45c9520e5b5850c765a0f062d3a6043d56 Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Thu, 29 Mar 2018 10:55:48 +0200 Subject: [PATCH 045/190] Guard UiFontAttribute::free --- docs/attributedstring.md | 2 +- src/Font/UiAttributedString.cc | 1 + src/Font/UiFontAttribute.cc | 8 +++++++- src/ui-node.h | 2 ++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/attributedstring.md b/docs/attributedstring.md index b437435..874bf09 100644 --- a/docs/attributedstring.md +++ b/docs/attributedstring.md @@ -29,7 +29,7 @@ class UiOpenTypeFeatures { class UiFontAttribute { public: - // DON'T CALL IF USED/APPENDED IN AN AttributedString + // doesn't need to be called when appended void free(); int getAttributeType(); diff --git a/src/Font/UiAttributedString.cc b/src/Font/UiAttributedString.cc index 3aeee1a..881ff3c 100644 --- a/src/Font/UiAttributedString.cc +++ b/src/Font/UiAttributedString.cc @@ -40,6 +40,7 @@ void UiAttributedString::deleteString(size_t start, size_t end) { void UiAttributedString::setAttribute(UiFontAttribute *attr, size_t start, size_t end) { uiAttributedStringSetAttribute(s, attr->getHandle(), start, end); + attr->setAppended(); } static unsigned int UiAttributedString__forEach(const uiAttributedString *s, const uiAttribute *a, size_t start, size_t end, void *data) { diff --git a/src/Font/UiFontAttribute.cc b/src/Font/UiFontAttribute.cc index 5451eb3..c08a339 100644 --- a/src/Font/UiFontAttribute.cc +++ b/src/Font/UiFontAttribute.cc @@ -15,7 +15,13 @@ uiAttribute *UiFontAttribute::getHandle() { } void UiFontAttribute::free(){ - uiFreeAttribute(a); + if(!appended){ + uiFreeAttribute(a); + } +} + +void UiFontAttribute::setAppended(){ + appended = 1; } const char *UiFontAttribute::getFamily() { diff --git a/src/ui-node.h b/src/ui-node.h index 6a55ac4..98aaf49 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -656,10 +656,12 @@ class UiOpenTypeFeatures { class UiFontAttribute { private: uiAttribute* a; + int appended = 0; public: UiFontAttribute(uiAttribute *a); void free(); + void setAppended(); int getAttributeType(); uiAttribute *getHandle(); From 26148b1f85845214882bad9ee61819b971e0b259 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Wed, 4 Apr 2018 23:18:16 +0200 Subject: [PATCH 046/190] Move nbind header inclusion to ui-node.h --- src/Color.cc | 1 - src/Point.cc | 1 - src/PointDouble.cc | 1 - src/Size.cc | 1 - src/SizeDouble.cc | 1 - src/Ui.cc | 3 ++- src/UiArea/BrushGradientStop.cc | 1 - src/UiArea/DrawBrush.cc | 1 - src/UiArea/DrawMatrix.cc | 1 - src/UiArea/DrawStrokeParams.cc | 1 - src/UiArea/DrawTextFont.cc | 1 - src/UiArea/DrawTextFontDescriptor.cc | 1 - src/UiArea/DrawTextFontMetrics.cc | 1 - src/UiArea/DrawTextLayout.cc | 1 - src/UiArea/UiArea.cc | 1 - src/UiArea/UiAreaDrawParams.cc | 1 - src/UiArea/UiAreaHandler.cc | 1 - src/UiArea/UiAreaKeyEvent.cc | 1 - src/UiArea/UiAreaMouseEvent.cc | 1 - src/UiArea/UiDrawContext.cc | 1 - src/UiArea/UiDrawPath.cc | 1 - src/UiBox.cc | 1 - src/UiButton.cc | 1 - src/UiCheckbox.cc | 1 - src/UiColorButton.cc | 1 - src/UiCombobox.cc | 1 - src/UiControl.cc | 1 - src/UiDateTimePicker.cc | 1 - src/UiDialogs.cc | 1 - src/UiEditableCombobox.cc | 1 - src/UiEntry.cc | 2 -- src/UiFontButton.cc | 1 - src/UiForm.cc | 1 - src/UiGrid.cc | 1 - src/UiGroup.cc | 1 - src/UiLabel.cc | 1 - src/UiMenu.cc | 1 - src/UiMultilineEntry.cc | 1 - src/UiProgressBar.cc | 1 - src/UiRadioButtons.cc | 1 - src/UiSeparator.cc | 1 - src/UiSlider.cc | 1 - src/UiSpinbox.cc | 1 - src/UiTab.cc | 1 - src/UiWindow.cc | 1 - src/ui-node.h | 5 +++++ 46 files changed, 7 insertions(+), 46 deletions(-) diff --git a/src/Color.cc b/src/Color.cc index e35a42e..0400e68 100644 --- a/src/Color.cc +++ b/src/Color.cc @@ -1,6 +1,5 @@ #include "../ui.h" #include "ui-node.h" -#include "nbind/nbind.h" Color::Color(const Color &other) { r = other.r; diff --git a/src/Point.cc b/src/Point.cc index 7c11597..61a388c 100644 --- a/src/Point.cc +++ b/src/Point.cc @@ -1,6 +1,5 @@ #include "../ui.h" #include "ui-node.h" -#include "nbind/nbind.h" Point::Point(const Point &other) { x = other.x; diff --git a/src/PointDouble.cc b/src/PointDouble.cc index 4ee8fd9..deeab65 100644 --- a/src/PointDouble.cc +++ b/src/PointDouble.cc @@ -1,6 +1,5 @@ #include "../ui.h" #include "ui-node.h" -#include "nbind/nbind.h" PointDouble::PointDouble(const PointDouble &other) { x = other.x; diff --git a/src/Size.cc b/src/Size.cc index 41a9063..32e30a2 100644 --- a/src/Size.cc +++ b/src/Size.cc @@ -1,6 +1,5 @@ #include "../ui.h" #include "ui-node.h" -#include "nbind/nbind.h" Size::Size(int width, int height) { w = width; diff --git a/src/SizeDouble.cc b/src/SizeDouble.cc index b12e902..30e768f 100644 --- a/src/SizeDouble.cc +++ b/src/SizeDouble.cc @@ -1,6 +1,5 @@ #include "../ui.h" #include "ui-node.h" -#include "nbind/nbind.h" SizeDouble::SizeDouble(double width, double height) { w = width; diff --git a/src/Ui.cc b/src/Ui.cc index 119534d..0a9bd4c 100644 --- a/src/Ui.cc +++ b/src/Ui.cc @@ -1,7 +1,8 @@ #include "../ui.h" #include "nbind/api.h" #include "nbind/nbind.h" -/* TODO: this has to be removed */ + +/* TODO: this file has to be removed */ static int onShouldQuit_cb(void *data) { nbind::cbFunction *cb = (nbind::cbFunction *)data; diff --git a/src/UiArea/BrushGradientStop.cc b/src/UiArea/BrushGradientStop.cc index 2598ec7..9b44d55 100644 --- a/src/UiArea/BrushGradientStop.cc +++ b/src/UiArea/BrushGradientStop.cc @@ -1,6 +1,5 @@ #include "../../ui.h" #include "../ui-node.h" -#include "nbind/nbind.h" BrushGradientStop::BrushGradientStop(double pos, Color color) : c(color) { p = pos; diff --git a/src/UiArea/DrawBrush.cc b/src/UiArea/DrawBrush.cc index 4afccee..8fa47e3 100644 --- a/src/UiArea/DrawBrush.cc +++ b/src/UiArea/DrawBrush.cc @@ -1,6 +1,5 @@ #include "../../ui.h" #include "../ui-node.h" -#include "nbind/nbind.h" DrawBrush::DrawBrush() { b = new uiDrawBrush(); diff --git a/src/UiArea/DrawMatrix.cc b/src/UiArea/DrawMatrix.cc index 5361d17..09eb333 100644 --- a/src/UiArea/DrawMatrix.cc +++ b/src/UiArea/DrawMatrix.cc @@ -1,6 +1,5 @@ #include "../../ui.h" #include "../ui-node.h" -#include "nbind/nbind.h" UiDrawMatrix::UiDrawMatrix() { m = new uiDrawMatrix(); diff --git a/src/UiArea/DrawStrokeParams.cc b/src/UiArea/DrawStrokeParams.cc index ce0fc6b..cd874f3 100644 --- a/src/UiArea/DrawStrokeParams.cc +++ b/src/UiArea/DrawStrokeParams.cc @@ -1,6 +1,5 @@ #include "../../ui.h" #include "../ui-node.h" -#include "nbind/nbind.h" DrawStrokeParams::DrawStrokeParams() { sp = new uiDrawStrokeParams(); diff --git a/src/UiArea/DrawTextFont.cc b/src/UiArea/DrawTextFont.cc index ec56fa0..5c33082 100644 --- a/src/UiArea/DrawTextFont.cc +++ b/src/UiArea/DrawTextFont.cc @@ -1,6 +1,5 @@ #include "../../ui.h" #include "../ui-node.h" -#include "nbind/nbind.h" DrawTextFont::DrawTextFont() {} DrawTextFont::DrawTextFont(uiDrawTextFont *h) { diff --git a/src/UiArea/DrawTextFontDescriptor.cc b/src/UiArea/DrawTextFontDescriptor.cc index cf68800..60df92c 100644 --- a/src/UiArea/DrawTextFontDescriptor.cc +++ b/src/UiArea/DrawTextFontDescriptor.cc @@ -1,6 +1,5 @@ #include "../../ui.h" #include "../ui-node.h" -#include "nbind/nbind.h" const char *DrawTextFontDescriptor::getFamily() { return d->Family; diff --git a/src/UiArea/DrawTextFontMetrics.cc b/src/UiArea/DrawTextFontMetrics.cc index 1516afd..0f4b238 100644 --- a/src/UiArea/DrawTextFontMetrics.cc +++ b/src/UiArea/DrawTextFontMetrics.cc @@ -1,6 +1,5 @@ #include "../../ui.h" #include "../ui-node.h" -#include "nbind/nbind.h" DrawTextFontMetrics::DrawTextFontMetrics(uiDrawTextFontMetrics *metrics) { m = metrics; diff --git a/src/UiArea/DrawTextLayout.cc b/src/UiArea/DrawTextLayout.cc index 0843523..37b3e26 100644 --- a/src/UiArea/DrawTextLayout.cc +++ b/src/UiArea/DrawTextLayout.cc @@ -1,6 +1,5 @@ #include "../../ui.h" #include "../ui-node.h" -#include "nbind/nbind.h" DrawTextLayout::DrawTextLayout(const char *text, DrawTextFont *defaultFont, double width) { diff --git a/src/UiArea/UiArea.cc b/src/UiArea/UiArea.cc index 9f430f9..e29d78b 100644 --- a/src/UiArea/UiArea.cc +++ b/src/UiArea/UiArea.cc @@ -1,6 +1,5 @@ #include "../../ui.h" #include "../ui-node.h" -#include "nbind/nbind.h" std::map areasMap; diff --git a/src/UiArea/UiAreaDrawParams.cc b/src/UiArea/UiAreaDrawParams.cc index 173a23d..f3f04aa 100644 --- a/src/UiArea/UiAreaDrawParams.cc +++ b/src/UiArea/UiAreaDrawParams.cc @@ -1,6 +1,5 @@ #include "../../ui.h" #include "../ui-node.h" -#include "nbind/nbind.h" UiAreaDrawParams::UiAreaDrawParams(uiAreaDrawParams *params) { p = params; diff --git a/src/UiArea/UiAreaHandler.cc b/src/UiArea/UiAreaHandler.cc index 6970ab4..dc7be70 100644 --- a/src/UiArea/UiAreaHandler.cc +++ b/src/UiArea/UiAreaHandler.cc @@ -1,6 +1,5 @@ #include "../../ui.h" #include "../ui-node.h" -#include "nbind/nbind.h" void Draw(UiAreaHandler *self, uiArea *area, uiAreaDrawParams *params) { UiAreaDrawParams *pp = new UiAreaDrawParams(params); diff --git a/src/UiArea/UiAreaKeyEvent.cc b/src/UiArea/UiAreaKeyEvent.cc index 56b539c..9e3f2c3 100644 --- a/src/UiArea/UiAreaKeyEvent.cc +++ b/src/UiArea/UiAreaKeyEvent.cc @@ -1,7 +1,6 @@ #include "../../ui.h" #include "../ui-node.h" -#include "nbind/nbind.h" UiAreaKeyEvent::UiAreaKeyEvent(uiAreaKeyEvent *event) { e = event; diff --git a/src/UiArea/UiAreaMouseEvent.cc b/src/UiArea/UiAreaMouseEvent.cc index 33c2b8b..176dc37 100644 --- a/src/UiArea/UiAreaMouseEvent.cc +++ b/src/UiArea/UiAreaMouseEvent.cc @@ -1,6 +1,5 @@ #include "../../ui.h" #include "../ui-node.h" -#include "nbind/nbind.h" UiAreaMouseEvent::UiAreaMouseEvent(uiAreaMouseEvent *event) { e = event; diff --git a/src/UiArea/UiDrawContext.cc b/src/UiArea/UiDrawContext.cc index bad6766..aea7d1f 100644 --- a/src/UiArea/UiDrawContext.cc +++ b/src/UiArea/UiDrawContext.cc @@ -1,6 +1,5 @@ #include "../../ui.h" #include "../ui-node.h" -#include "nbind/nbind.h" UiDrawContext::UiDrawContext(uiDrawContext *ctx) { c = ctx; diff --git a/src/UiArea/UiDrawPath.cc b/src/UiArea/UiDrawPath.cc index 89b219a..33824e0 100644 --- a/src/UiArea/UiDrawPath.cc +++ b/src/UiArea/UiDrawPath.cc @@ -1,6 +1,5 @@ #include "../../ui.h" #include "../ui-node.h" -#include "nbind/nbind.h" UiDrawPath::UiDrawPath(int fillMode) { handle = uiDrawNewPath(fillMode); diff --git a/src/UiBox.cc b/src/UiBox.cc index 6b54c91..252eae6 100644 --- a/src/UiBox.cc +++ b/src/UiBox.cc @@ -1,7 +1,6 @@ #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" -#include "nbind/nbind.h" UiBox::UiBox(uiControl *control) : UiControl(control) {} diff --git a/src/UiButton.cc b/src/UiButton.cc index 2acc737..08abf1a 100644 --- a/src/UiButton.cc +++ b/src/UiButton.cc @@ -1,7 +1,6 @@ #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" -#include "nbind/nbind.h" UiButton::UiButton(const char *text) : UiControl((uiControl *)uiNewButton(text)) {} diff --git a/src/UiCheckbox.cc b/src/UiCheckbox.cc index 02536bb..cda7a76 100644 --- a/src/UiCheckbox.cc +++ b/src/UiCheckbox.cc @@ -1,7 +1,6 @@ #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" -#include "nbind/nbind.h" IMPLEMENT_EVENT(UiCheckbox, uiCheckbox, onToggled, uiCheckboxOnToggled) diff --git a/src/UiColorButton.cc b/src/UiColorButton.cc index ca2324d..221549f 100644 --- a/src/UiColorButton.cc +++ b/src/UiColorButton.cc @@ -1,7 +1,6 @@ #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" -#include "nbind/nbind.h" UiColorButton::UiColorButton() : UiControl((uiControl *)uiNewColorButton()) {} diff --git a/src/UiCombobox.cc b/src/UiCombobox.cc index 37ab2e8..6bdc871 100644 --- a/src/UiCombobox.cc +++ b/src/UiCombobox.cc @@ -1,7 +1,6 @@ #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" -#include "nbind/nbind.h" UiCombobox::UiCombobox() : UiControl((uiControl *)uiNewCombobox()) {} diff --git a/src/UiControl.cc b/src/UiControl.cc index ec4866a..7bb3df2 100644 --- a/src/UiControl.cc +++ b/src/UiControl.cc @@ -1,7 +1,6 @@ #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" -#include "nbind/nbind.h" uiControl *UiControl::getHandle() { return handle; diff --git a/src/UiDateTimePicker.cc b/src/UiDateTimePicker.cc index e75294e..3d66b8e 100644 --- a/src/UiDateTimePicker.cc +++ b/src/UiDateTimePicker.cc @@ -1,7 +1,6 @@ #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" -#include "nbind/nbind.h" UiDateTimePicker::UiDateTimePicker() : UiControl((uiControl *)uiNewDateTimePicker()) {} diff --git a/src/UiDialogs.cc b/src/UiDialogs.cc index 8a14630..0f4a803 100644 --- a/src/UiDialogs.cc +++ b/src/UiDialogs.cc @@ -1,7 +1,6 @@ #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" -#include "nbind/nbind.h" struct UiDialogs { diff --git a/src/UiEditableCombobox.cc b/src/UiEditableCombobox.cc index ca0f44d..d3fa0f8 100644 --- a/src/UiEditableCombobox.cc +++ b/src/UiEditableCombobox.cc @@ -1,7 +1,6 @@ #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" -#include "nbind/nbind.h" UiEditableCombobox::UiEditableCombobox() : UiControl((uiControl *)uiNewEditableCombobox()) {} diff --git a/src/UiEntry.cc b/src/UiEntry.cc index e021c1a..5f54889 100644 --- a/src/UiEntry.cc +++ b/src/UiEntry.cc @@ -41,8 +41,6 @@ UiSearchEntry::UiSearchEntry() : UiEntryBase((uiControl *)uiNewSearchEntry()) {} INHERITS_CONTROL_METHODS(UiSearchEntry) INHERITS_ENTRY_METHODS(UiSearchEntry) -#include "nbind/nbind.h" - NBIND_CLASS(UiSearchEntry) { construct<>(); DECLARE_CHILD_CONTROL_METHODS() diff --git a/src/UiFontButton.cc b/src/UiFontButton.cc index e034bea..4dee2d0 100644 --- a/src/UiFontButton.cc +++ b/src/UiFontButton.cc @@ -1,7 +1,6 @@ #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" -#include "nbind/nbind.h" UiFontButton::UiFontButton() : UiControl((uiControl *)uiNewFontButton()) {} diff --git a/src/UiForm.cc b/src/UiForm.cc index b8688b9..bed661c 100644 --- a/src/UiForm.cc +++ b/src/UiForm.cc @@ -1,7 +1,6 @@ #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" -#include "nbind/nbind.h" UiForm::UiForm() : UiControl((uiControl *)uiNewForm()) {} diff --git a/src/UiGrid.cc b/src/UiGrid.cc index b1ae23a..b49c3dc 100644 --- a/src/UiGrid.cc +++ b/src/UiGrid.cc @@ -1,7 +1,6 @@ #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" -#include "nbind/nbind.h" UiGrid::UiGrid() : UiControl((uiControl *)uiNewGrid()) {} diff --git a/src/UiGroup.cc b/src/UiGroup.cc index b0de88d..7254854 100644 --- a/src/UiGroup.cc +++ b/src/UiGroup.cc @@ -1,7 +1,6 @@ #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" -#include "nbind/nbind.h" UiGroup::UiGroup(const char *text) : UiControl((uiControl *)uiNewGroup(text)) {} UiGroup::UiGroup() : UiControl((uiControl *)uiNewGroup("")) {} diff --git a/src/UiLabel.cc b/src/UiLabel.cc index f745acd..ee93fd4 100644 --- a/src/UiLabel.cc +++ b/src/UiLabel.cc @@ -1,7 +1,6 @@ #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" -#include "nbind/nbind.h" UiLabel::UiLabel(const char *text) : UiControl((uiControl *)uiNewLabel(text)) {} UiLabel::UiLabel() : UiControl((uiControl *)uiNewLabel("")) {} diff --git a/src/UiMenu.cc b/src/UiMenu.cc index 9eaf64f..c75a026 100644 --- a/src/UiMenu.cc +++ b/src/UiMenu.cc @@ -1,7 +1,6 @@ #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" -#include "nbind/nbind.h" static void UiMenuItem_onClicked(uiMenuItem *sender, uiWindow *window, void *data) { diff --git a/src/UiMultilineEntry.cc b/src/UiMultilineEntry.cc index a021a47..d69cf57 100644 --- a/src/UiMultilineEntry.cc +++ b/src/UiMultilineEntry.cc @@ -1,7 +1,6 @@ #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" -#include "nbind/nbind.h" UiMultilineEntry::UiMultilineEntry() : UiControl((uiControl *)uiNewNonWrappingMultilineEntry()) {} diff --git a/src/UiProgressBar.cc b/src/UiProgressBar.cc index d2f5aed..3ea94b6 100644 --- a/src/UiProgressBar.cc +++ b/src/UiProgressBar.cc @@ -1,7 +1,6 @@ #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" -#include "nbind/nbind.h" UiProgressBar::UiProgressBar() : UiControl((uiControl *)uiNewProgressBar()) {} diff --git a/src/UiRadioButtons.cc b/src/UiRadioButtons.cc index 8b50205..22ebf25 100644 --- a/src/UiRadioButtons.cc +++ b/src/UiRadioButtons.cc @@ -1,7 +1,6 @@ #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" -#include "nbind/nbind.h" UiRadioButtons::UiRadioButtons() : UiControl((uiControl *)uiNewRadioButtons()) {} diff --git a/src/UiSeparator.cc b/src/UiSeparator.cc index 47be4ae..ca51e2d 100644 --- a/src/UiSeparator.cc +++ b/src/UiSeparator.cc @@ -1,7 +1,6 @@ #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" -#include "nbind/nbind.h" UiHorizontalSeparator::UiHorizontalSeparator() : UiControl((uiControl *)uiNewHorizontalSeparator()) {} diff --git a/src/UiSlider.cc b/src/UiSlider.cc index bad01bf..77e2baf 100644 --- a/src/UiSlider.cc +++ b/src/UiSlider.cc @@ -1,7 +1,6 @@ #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" -#include "nbind/nbind.h" UiSlider::UiSlider(int min, int max) : UiControl((uiControl *)uiNewSlider(min, max)) {} diff --git a/src/UiSpinbox.cc b/src/UiSpinbox.cc index cb9415a..a023c2a 100644 --- a/src/UiSpinbox.cc +++ b/src/UiSpinbox.cc @@ -1,7 +1,6 @@ #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" -#include "nbind/nbind.h" UiSpinbox::UiSpinbox(int min, int max) : UiControl((uiControl *)uiNewSpinbox(min, max)) {} diff --git a/src/UiTab.cc b/src/UiTab.cc index 27a1a96..6c645d1 100644 --- a/src/UiTab.cc +++ b/src/UiTab.cc @@ -1,7 +1,6 @@ #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" -#include "nbind/nbind.h" UiTab::UiTab() : UiControl((uiControl *)uiNewTab()) {} diff --git a/src/UiWindow.cc b/src/UiWindow.cc index 11daa8c..de6d4e8 100644 --- a/src/UiWindow.cc +++ b/src/UiWindow.cc @@ -1,7 +1,6 @@ #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" -#include "nbind/nbind.h" static int UiWindow_onClosing(uiWindow *w, void *data) { nbind::cbFunction *cb = (nbind::cbFunction *)data; diff --git a/src/ui-node.h b/src/ui-node.h index 02cf11f..a7ad51a 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -818,4 +818,9 @@ class UiGrid : public UiControl { DEFINE_CONTROL_METHODS() }; +// This is included at end of file +// to minimize conflicts with existing +// symbols from other headers. +#include "nbind/nbind.h" + #endif From 4fbe1b8cac9a5bcc8919ccb8b4ddddd947b37b19 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Wed, 4 Apr 2018 23:32:18 +0200 Subject: [PATCH 047/190] Add include for vector header --- src/UiArea/DrawBrush.cc | 1 + src/UiArea/DrawStrokeParams.cc | 1 + src/UiArea/DrawTextFont.cc | 1 + src/ui-node.h | 2 ++ 4 files changed, 5 insertions(+) diff --git a/src/UiArea/DrawBrush.cc b/src/UiArea/DrawBrush.cc index 8fa47e3..a5d73b8 100644 --- a/src/UiArea/DrawBrush.cc +++ b/src/UiArea/DrawBrush.cc @@ -1,3 +1,4 @@ +#include #include "../../ui.h" #include "../ui-node.h" diff --git a/src/UiArea/DrawStrokeParams.cc b/src/UiArea/DrawStrokeParams.cc index cd874f3..3372424 100644 --- a/src/UiArea/DrawStrokeParams.cc +++ b/src/UiArea/DrawStrokeParams.cc @@ -1,3 +1,4 @@ +#include #include "../../ui.h" #include "../ui-node.h" diff --git a/src/UiArea/DrawTextFont.cc b/src/UiArea/DrawTextFont.cc index 5c33082..9b02657 100644 --- a/src/UiArea/DrawTextFont.cc +++ b/src/UiArea/DrawTextFont.cc @@ -1,3 +1,4 @@ +#include #include "../../ui.h" #include "../ui-node.h" diff --git a/src/ui-node.h b/src/ui-node.h index a7ad51a..32a0fa7 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -3,7 +3,9 @@ #define ui_node #include +#include // TODO: this has to be removed once UiArea classes #include "nbind/api.h" +// declarations are moved to their own cc files #define DEFINE_EVENT(NAME) \ private: \ From cdd8cf7bc4d98c91f03611cec0e9638f79ff0afa Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Wed, 4 Apr 2018 23:41:07 +0200 Subject: [PATCH 048/190] std::string --> UiRadioButtons::append --- src/UiRadioButtons.cc | 17 +++++++++++++++-- src/ui-node.h | 12 ------------ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/UiRadioButtons.cc b/src/UiRadioButtons.cc index 22ebf25..f22d6bd 100644 --- a/src/UiRadioButtons.cc +++ b/src/UiRadioButtons.cc @@ -1,7 +1,20 @@ +#include #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" +class UiRadioButtons : public UiControl { + DEFINE_EVENT(onSelected) + + public: + UiRadioButtons(); + void append(std::string text); + int getSelected(); + void setSelected(int n); + + DEFINE_CONTROL_METHODS() +}; + UiRadioButtons::UiRadioButtons() : UiControl((uiControl *)uiNewRadioButtons()) {} @@ -21,8 +34,8 @@ void UiRadioButtons::setSelected(int n) { } } -void UiRadioButtons::append(const char *text) { - uiRadioButtonsAppend((uiRadioButtons *)getHandle(), text); +void UiRadioButtons::append(std::string text) { + uiRadioButtonsAppend(uiRadioButtons(getHandle()), text.c_str()); } NBIND_CLASS(UiRadioButtons) { diff --git a/src/ui-node.h b/src/ui-node.h index 32a0fa7..19084e2 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -148,18 +148,6 @@ class UiControl { DEFINE_CONTROL_METHODS() }; -class UiRadioButtons : public UiControl { - DEFINE_EVENT(onSelected) - - public: - UiRadioButtons(); - void append(const char *text); - int getSelected(); - void setSelected(int n); - - DEFINE_CONTROL_METHODS() -}; - class UiTab : public UiControl { public: UiTab(); From da2e1993c3200a8be88afc07bd3bbcababb840f1 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Thu, 5 Apr 2018 00:03:32 +0200 Subject: [PATCH 049/190] Moved most class declarations from headers to their on cc file --- src/UiBox.cc | 20 +++ src/UiButton.cc | 11 ++ src/UiCheckbox.cc | 13 ++ src/UiCombobox.cc | 11 ++ src/UiDateTimePicker.cc | 18 +++ src/UiEditableCombobox.cc | 11 ++ src/UiEntry.cc | 33 ++++ src/UiFontButton.cc | 9 ++ src/UiForm.cc | 10 ++ src/UiGrid.cc | 14 ++ src/UiGroup.cc | 12 ++ src/UiLabel.cc | 9 ++ src/UiMenu.cc | 30 ++++ src/UiMultilineEntry.cc | 13 ++ src/UiProgressBar.cc | 11 ++ src/UiSeparator.cc | 10 ++ src/UiSlider.cc | 12 ++ src/UiSpinbox.cc | 11 ++ src/UiTab.cc | 30 +++- src/ui-node.h | 318 +++----------------------------------- 20 files changed, 302 insertions(+), 304 deletions(-) diff --git a/src/UiBox.cc b/src/UiBox.cc index 252eae6..27ec2f1 100644 --- a/src/UiBox.cc +++ b/src/UiBox.cc @@ -2,6 +2,26 @@ #include "ui-node.h" #include "nbind/api.h" +class UiBox : public UiControl { + public: + UiBox(uiControl *hnd); + DEFINE_BOX_METHODS() +}; + +class UiVerticalBox : public UiBox { + public: + UiVerticalBox(); + DEFINE_BOX_METHODS() + DEFINE_CONTROL_METHODS() +}; + +class UiHorizontalBox : public UiBox { + public: + UiHorizontalBox(); + DEFINE_BOX_METHODS() + DEFINE_CONTROL_METHODS() +}; + UiBox::UiBox(uiControl *control) : UiControl(control) {} void UiBox::append(UiControl *control, bool stretchy) { diff --git a/src/UiButton.cc b/src/UiButton.cc index 08abf1a..3751439 100644 --- a/src/UiButton.cc +++ b/src/UiButton.cc @@ -2,6 +2,17 @@ #include "ui-node.h" #include "nbind/api.h" +class UiButton : public UiControl { + DEFINE_EVENT(onClicked) + + public: + UiButton(const char *text); + UiButton(); + DEFINE_CONTROL_METHODS() + void setText(const char *text); + const char *getText(); +}; + UiButton::UiButton(const char *text) : UiControl((uiControl *)uiNewButton(text)) {} UiButton::UiButton() : UiControl((uiControl *)uiNewButton("")) {} diff --git a/src/UiCheckbox.cc b/src/UiCheckbox.cc index cda7a76..137f2a6 100644 --- a/src/UiCheckbox.cc +++ b/src/UiCheckbox.cc @@ -2,6 +2,19 @@ #include "ui-node.h" #include "nbind/api.h" +class UiCheckbox : public UiControl { + DEFINE_EVENT(onToggled) + + public: + UiCheckbox(const char *text); + UiCheckbox(); + DEFINE_CONTROL_METHODS() + void setText(const char *text); + const char *getText(); + void setChecked(bool checked); + bool getChecked(); +}; + IMPLEMENT_EVENT(UiCheckbox, uiCheckbox, onToggled, uiCheckboxOnToggled) UiCheckbox::UiCheckbox(const char *text) diff --git a/src/UiCombobox.cc b/src/UiCombobox.cc index 6bdc871..474ec2c 100644 --- a/src/UiCombobox.cc +++ b/src/UiCombobox.cc @@ -2,6 +2,17 @@ #include "ui-node.h" #include "nbind/api.h" +class UiCombobox : public UiControl { + DEFINE_EVENT(onSelected) + + public: + UiCombobox(); + DEFINE_CONTROL_METHODS() + void append(const char *text); + int getSelected(); + void setSelected(int n); +}; + UiCombobox::UiCombobox() : UiControl((uiControl *)uiNewCombobox()) {} INHERITS_CONTROL_METHODS(UiCombobox) diff --git a/src/UiDateTimePicker.cc b/src/UiDateTimePicker.cc index 3d66b8e..bd1a01f 100644 --- a/src/UiDateTimePicker.cc +++ b/src/UiDateTimePicker.cc @@ -2,6 +2,12 @@ #include "ui-node.h" #include "nbind/api.h" +class UiDateTimePicker : public UiControl { + public: + UiDateTimePicker(); + DEFINE_CONTROL_METHODS() +}; + UiDateTimePicker::UiDateTimePicker() : UiControl((uiControl *)uiNewDateTimePicker()) {} @@ -12,6 +18,12 @@ NBIND_CLASS(UiDateTimePicker) { DECLARE_CHILD_CONTROL_METHODS() } +class UiTimePicker : public UiControl { + public: + UiTimePicker(); + DEFINE_CONTROL_METHODS() +}; + UiTimePicker::UiTimePicker() : UiControl((uiControl *)uiNewTimePicker()) {} INHERITS_CONTROL_METHODS(UiTimePicker) @@ -21,6 +33,12 @@ NBIND_CLASS(UiTimePicker) { DECLARE_CHILD_CONTROL_METHODS() } +class UiDatePicker : public UiControl { + public: + UiDatePicker(); + DEFINE_CONTROL_METHODS() +}; + UiDatePicker::UiDatePicker() : UiControl((uiControl *)uiNewDatePicker()) {} INHERITS_CONTROL_METHODS(UiDatePicker) diff --git a/src/UiEditableCombobox.cc b/src/UiEditableCombobox.cc index d3fa0f8..0edeb80 100644 --- a/src/UiEditableCombobox.cc +++ b/src/UiEditableCombobox.cc @@ -2,6 +2,17 @@ #include "ui-node.h" #include "nbind/api.h" +class UiEditableCombobox : public UiControl { + DEFINE_EVENT(onChanged) + + public: + UiEditableCombobox(); + DEFINE_CONTROL_METHODS() + void append(const char *text); + const char *getText(); + void setText(const char *text); +}; + UiEditableCombobox::UiEditableCombobox() : UiControl((uiControl *)uiNewEditableCombobox()) {} diff --git a/src/UiEntry.cc b/src/UiEntry.cc index 5f54889..3cf809f 100644 --- a/src/UiEntry.cc +++ b/src/UiEntry.cc @@ -2,6 +2,39 @@ #include "ui-node.h" #include "nbind/api.h" +class UiEntryBase : public UiControl { + DEFINE_EVENT(onChanged) + + public: + UiEntryBase(uiControl *); + DEFINE_CONTROL_METHODS() + DEFINE_ENTRY_METHODS() +}; + +class UiEntry : public UiEntryBase { + public: + UiEntry(); + DEFINE_CONTROL_METHODS() + DEFINE_ENTRY_METHODS() + void onChanged(nbind::cbFunction &cb); +}; + +class UiPasswordEntry : public UiEntryBase { + public: + UiPasswordEntry(); + DEFINE_CONTROL_METHODS() + DEFINE_ENTRY_METHODS() + void onChanged(nbind::cbFunction &cb); +}; + +class UiSearchEntry : public UiEntryBase { + public: + UiSearchEntry(); + DEFINE_CONTROL_METHODS() + DEFINE_ENTRY_METHODS() + void onChanged(nbind::cbFunction &cb); +}; + UiEntryBase::UiEntryBase(uiControl *hnd) : UiControl(hnd) {} void UiEntryBase::setText(const char *text) { diff --git a/src/UiFontButton.cc b/src/UiFontButton.cc index 4dee2d0..145728d 100644 --- a/src/UiFontButton.cc +++ b/src/UiFontButton.cc @@ -2,6 +2,15 @@ #include "ui-node.h" #include "nbind/api.h" +class UiFontButton : public UiControl { + DEFINE_EVENT(onChanged) + + public: + UiFontButton(); + DrawTextFont *getFont(); + DEFINE_CONTROL_METHODS() +}; + UiFontButton::UiFontButton() : UiControl((uiControl *)uiNewFontButton()) {} INHERITS_CONTROL_METHODS(UiFontButton) diff --git a/src/UiForm.cc b/src/UiForm.cc index bed661c..db3a711 100644 --- a/src/UiForm.cc +++ b/src/UiForm.cc @@ -2,6 +2,16 @@ #include "ui-node.h" #include "nbind/api.h" +class UiForm : public UiControl { + public: + UiForm(); + DEFINE_CONTROL_METHODS() + void append(const char *label, UiControl *c, bool stretchy); + void deleteAt(int index); + bool getPadded(); + void setPadded(bool padded); +}; + UiForm::UiForm() : UiControl((uiControl *)uiNewForm()) {} void UiForm::append(const char *label, UiControl *c, bool stretchy) { diff --git a/src/UiGrid.cc b/src/UiGrid.cc index b49c3dc..03d62c9 100644 --- a/src/UiGrid.cc +++ b/src/UiGrid.cc @@ -2,6 +2,20 @@ #include "ui-node.h" #include "nbind/api.h" +// TODO - document +class UiGrid : public UiControl { + public: + UiGrid(); + bool getPadded(); + void setPadded(bool value); + void append(UiControl *c, int left, int top, int xspan, int yspan, + int hexpand, int halign, int vexpand, int valign); + void insertAt(UiControl *c, UiControl *existing, int at, int xspan, + int yspan, int hexpand, int halign, int vexpand, int valign); + + DEFINE_CONTROL_METHODS() +}; + UiGrid::UiGrid() : UiControl((uiControl *)uiNewGrid()) {} bool UiGrid::getPadded() { diff --git a/src/UiGroup.cc b/src/UiGroup.cc index 7254854..e6580c2 100644 --- a/src/UiGroup.cc +++ b/src/UiGroup.cc @@ -2,6 +2,18 @@ #include "ui-node.h" #include "nbind/api.h" +class UiGroup : public UiControl { + public: + UiGroup(const char *text); + UiGroup(); + void setChild(UiControl *control); + bool getMargined(); + void setMargined(bool margined); + const char *getTitle(); + void setTitle(const char *title); + DEFINE_CONTROL_METHODS() +}; + UiGroup::UiGroup(const char *text) : UiControl((uiControl *)uiNewGroup(text)) {} UiGroup::UiGroup() : UiControl((uiControl *)uiNewGroup("")) {} diff --git a/src/UiLabel.cc b/src/UiLabel.cc index ee93fd4..b0e5e6e 100644 --- a/src/UiLabel.cc +++ b/src/UiLabel.cc @@ -2,6 +2,15 @@ #include "ui-node.h" #include "nbind/api.h" +class UiLabel : public UiControl { + public: + UiLabel(); + UiLabel(const char *text); + DEFINE_CONTROL_METHODS() + void setText(const char *text); + const char *getText(); +}; + UiLabel::UiLabel(const char *text) : UiControl((uiControl *)uiNewLabel(text)) {} UiLabel::UiLabel() : UiControl((uiControl *)uiNewLabel("")) {} diff --git a/src/UiMenu.cc b/src/UiMenu.cc index c75a026..46897c9 100644 --- a/src/UiMenu.cc +++ b/src/UiMenu.cc @@ -2,6 +2,36 @@ #include "ui-node.h" #include "nbind/api.h" +// TODO - document +class UiMenuItem { + DEFINE_EVENT(onClicked) + + private: + uiMenuItem *handle; + + public: + UiMenuItem(uiMenuItem *hnd); + void enable(); + void disable(); + bool getChecked(); + void setChecked(bool checked); +}; + +// TODO - document +class UiMenu { + private: + uiMenu *handle; + + public: + UiMenu(const char *name); + UiMenuItem *appendItem(const char *name); + UiMenuItem *appendCheckItem(const char *name); + UiMenuItem *appendQuitItem(); + UiMenuItem *appendPreferencesItem(); + UiMenuItem *appendAboutItem(); + void appendSeparator(); +}; + static void UiMenuItem_onClicked(uiMenuItem *sender, uiWindow *window, void *data) { nbind::cbFunction *cb = (nbind::cbFunction *)data; diff --git a/src/UiMultilineEntry.cc b/src/UiMultilineEntry.cc index d69cf57..ac8e2a3 100644 --- a/src/UiMultilineEntry.cc +++ b/src/UiMultilineEntry.cc @@ -2,6 +2,19 @@ #include "ui-node.h" #include "nbind/api.h" +class UiMultilineEntry : public UiControl { + DEFINE_EVENT(onChanged) + + public: + UiMultilineEntry(); + DEFINE_CONTROL_METHODS() + void setText(const char *text); + const char *getText(); + void setReadOnly(bool readOnly); + bool getReadOnly(); + void append(const char *text); +}; + UiMultilineEntry::UiMultilineEntry() : UiControl((uiControl *)uiNewNonWrappingMultilineEntry()) {} diff --git a/src/UiProgressBar.cc b/src/UiProgressBar.cc index 3ea94b6..58656a8 100644 --- a/src/UiProgressBar.cc +++ b/src/UiProgressBar.cc @@ -2,6 +2,17 @@ #include "ui-node.h" #include "nbind/api.h" +class UiProgressBar : public UiControl { + private: + int value = 0; + + public: + UiProgressBar(); + DEFINE_CONTROL_METHODS() + int getValue(); + void setValue(int value); +}; + UiProgressBar::UiProgressBar() : UiControl((uiControl *)uiNewProgressBar()) {} INHERITS_CONTROL_METHODS(UiProgressBar) diff --git a/src/UiSeparator.cc b/src/UiSeparator.cc index ca51e2d..c903102 100644 --- a/src/UiSeparator.cc +++ b/src/UiSeparator.cc @@ -1,7 +1,17 @@ #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" +class UiHorizontalSeparator : public UiControl { + public: + UiHorizontalSeparator(); + DEFINE_CONTROL_METHODS() +}; +class UiVerticalSeparator : public UiControl { + public: + UiVerticalSeparator(); + DEFINE_CONTROL_METHODS() +}; UiHorizontalSeparator::UiHorizontalSeparator() : UiControl((uiControl *)uiNewHorizontalSeparator()) {} diff --git a/src/UiSlider.cc b/src/UiSlider.cc index 77e2baf..06fda50 100644 --- a/src/UiSlider.cc +++ b/src/UiSlider.cc @@ -2,6 +2,18 @@ #include "ui-node.h" #include "nbind/api.h" +class UiSlider : public UiControl { + DEFINE_EVENT(onChanged) + + public: + UiSlider(int min, int max); + UiSlider(); + DEFINE_CONTROL_METHODS() + + int getValue(); + void setValue(int value); +}; + UiSlider::UiSlider(int min, int max) : UiControl((uiControl *)uiNewSlider(min, max)) {} diff --git a/src/UiSpinbox.cc b/src/UiSpinbox.cc index a023c2a..58f172d 100644 --- a/src/UiSpinbox.cc +++ b/src/UiSpinbox.cc @@ -2,6 +2,17 @@ #include "ui-node.h" #include "nbind/api.h" +class UiSpinbox : public UiControl { + DEFINE_EVENT(onChanged) + + public: + UiSpinbox(int min, int max); + UiSpinbox(); + DEFINE_CONTROL_METHODS() + + int getValue(); + void setValue(int value); +}; UiSpinbox::UiSpinbox(int min, int max) : UiControl((uiControl *)uiNewSpinbox(min, max)) {} diff --git a/src/UiTab.cc b/src/UiTab.cc index 6c645d1..515a2da 100644 --- a/src/UiTab.cc +++ b/src/UiTab.cc @@ -1,33 +1,47 @@ +#include #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" +class UiTab : public UiControl { + public: + UiTab(); + void append(std::string text, UiControl *child); + void insertAt(std::string name, int before, UiControl *child); + void deleteAt(int index); + int numPages(); + bool getMargined(int page); + void setMargined(int page, bool margined); + + DEFINE_CONTROL_METHODS() +}; + UiTab::UiTab() : UiControl((uiControl *)uiNewTab()) {} INHERITS_CONTROL_METHODS(UiTab) -void UiTab::append(const char *text, UiControl *child) { - uiTabAppend((uiTab *)getHandle(), text, child->getHandle()); +void UiTab::append(std::string text, UiControl *child) { + uiTabAppend(uiTab(getHandle()), text.c_str(), child->getHandle()); } -void UiTab::insertAt(const char *name, int before, UiControl *child) { - uiTabInsertAt((uiTab *)getHandle(), name, before, child->getHandle()); +void UiTab::insertAt(std::string name, int before, UiControl *child) { + uiTabInsertAt(uiTab(getHandle()), name.c_str(), before, child->getHandle()); } void UiTab::deleteAt(int index) { - uiTabDelete((uiTab *)getHandle(), index); + uiTabDelete(uiTab(getHandle()), index); } int UiTab::numPages() { - return uiTabNumPages((uiTab *)getHandle()); + return uiTabNumPages(uiTab(getHandle())); } bool UiTab::getMargined(int page) { - return uiTabMargined((uiTab *)getHandle(), page); + return uiTabMargined(uiTab(getHandle()), page); } void UiTab::setMargined(int page, bool margined) { - uiTabSetMargined((uiTab *)getHandle(), page, margined); + uiTabSetMargined(uiTab(getHandle()), page, margined); } NBIND_CLASS(UiTab) { diff --git a/src/ui-node.h b/src/ui-node.h index 19084e2..96e141d 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -148,217 +148,6 @@ class UiControl { DEFINE_CONTROL_METHODS() }; -class UiTab : public UiControl { - public: - UiTab(); - void append(const char *text, UiControl *child); - void insertAt(const char *name, int before, UiControl *child); - void deleteAt(int index); - int numPages(); - bool getMargined(int page); - void setMargined(int page, bool margined); - - DEFINE_CONTROL_METHODS() -}; - -class UiMultilineEntry : public UiControl { - DEFINE_EVENT(onChanged) - - public: - UiMultilineEntry(); - DEFINE_CONTROL_METHODS() - void setText(const char *text); - const char *getText(); - void setReadOnly(bool readOnly); - bool getReadOnly(); - void append(const char *text); -}; - -class UiCombobox : public UiControl { - DEFINE_EVENT(onSelected) - - public: - UiCombobox(); - DEFINE_CONTROL_METHODS() - void append(const char *text); - int getSelected(); - void setSelected(int n); -}; - -class UiDateTimePicker : public UiControl { - public: - UiDateTimePicker(); - DEFINE_CONTROL_METHODS() -}; - -class UiDatePicker : public UiControl { - public: - UiDatePicker(); - DEFINE_CONTROL_METHODS() -}; - -class UiTimePicker : public UiControl { - public: - UiTimePicker(); - DEFINE_CONTROL_METHODS() -}; - -class UiEditableCombobox : public UiControl { - DEFINE_EVENT(onChanged) - - public: - UiEditableCombobox(); - DEFINE_CONTROL_METHODS() - void append(const char *text); - const char *getText(); - void setText(const char *text); -}; - -class UiEntryBase : public UiControl { - DEFINE_EVENT(onChanged) - - public: - UiEntryBase(uiControl *); - DEFINE_CONTROL_METHODS() - DEFINE_ENTRY_METHODS() -}; - -class UiEntry : public UiEntryBase { - public: - UiEntry(); - DEFINE_CONTROL_METHODS() - DEFINE_ENTRY_METHODS() - void onChanged(nbind::cbFunction &cb); -}; - -class UiPasswordEntry : public UiEntryBase { - public: - UiPasswordEntry(); - DEFINE_CONTROL_METHODS() - DEFINE_ENTRY_METHODS() - void onChanged(nbind::cbFunction &cb); -}; - -class UiSearchEntry : public UiEntryBase { - public: - UiSearchEntry(); - DEFINE_CONTROL_METHODS() - DEFINE_ENTRY_METHODS() - void onChanged(nbind::cbFunction &cb); -}; - -class UiHorizontalSeparator : public UiControl { - public: - UiHorizontalSeparator(); - DEFINE_CONTROL_METHODS() -}; - -class UiVerticalSeparator : public UiControl { - public: - UiVerticalSeparator(); - DEFINE_CONTROL_METHODS() -}; - -class UiLabel : public UiControl { - public: - UiLabel(); - UiLabel(const char *text); - DEFINE_CONTROL_METHODS() - void setText(const char *text); - const char *getText(); -}; - -class UiGroup : public UiControl { - public: - UiGroup(const char *text); - UiGroup(); - void setChild(UiControl *control); - bool getMargined(); - void setMargined(bool margined); - const char *getTitle(); - void setTitle(const char *title); - DEFINE_CONTROL_METHODS() -}; - -class UiButton : public UiControl { - DEFINE_EVENT(onClicked) - - public: - UiButton(const char *text); - UiButton(); - DEFINE_CONTROL_METHODS() - void setText(const char *text); - const char *getText(); -}; - -class UiCheckbox : public UiControl { - DEFINE_EVENT(onToggled) - - public: - UiCheckbox(const char *text); - UiCheckbox(); - DEFINE_CONTROL_METHODS() - void setText(const char *text); - const char *getText(); - void setChecked(bool checked); - bool getChecked(); -}; - -class UiProgressBar : public UiControl { - private: - int value = 0; - - public: - UiProgressBar(); - DEFINE_CONTROL_METHODS() - int getValue(); - void setValue(int value); -}; - -class UiSlider : public UiControl { - DEFINE_EVENT(onChanged) - - public: - UiSlider(int min, int max); - UiSlider(); - DEFINE_CONTROL_METHODS() - - int getValue(); - void setValue(int value); -}; - -class UiSpinbox : public UiControl { - DEFINE_EVENT(onChanged) - - public: - UiSpinbox(int min, int max); - UiSpinbox(); - DEFINE_CONTROL_METHODS() - - int getValue(); - void setValue(int value); -}; - -class UiBox : public UiControl { - public: - UiBox(uiControl *hnd); - DEFINE_BOX_METHODS() -}; - -class UiVerticalBox : public UiBox { - public: - UiVerticalBox(); - DEFINE_BOX_METHODS() - DEFINE_CONTROL_METHODS() -}; - -class UiHorizontalBox : public UiBox { - public: - UiHorizontalBox(); - DEFINE_BOX_METHODS() - DEFINE_CONTROL_METHODS() -}; - class Point { private: int x; @@ -417,71 +206,6 @@ class SizeDouble { void toJS(nbind::cbOutput output); }; -class UiWindow { - DEFINE_EVENT(onClosing) - DEFINE_EVENT(onContentSizeChanged) - - private: - uiWindow *win; - - public: - UiWindow(const char *title, int width, int height, bool hasMenubar); - uiWindow *getHandle(); - void show(); - void close(); - void setMargined(bool margined); - bool getMargined(); - void setChild(UiControl *control); - void setTitle(const char *title); - const char *getTitle(); - bool getFullscreen(); - void setFullscreen(bool value); - bool getBorderless(); - void setBorderless(bool value); - Size getContentSize(); - void setContentSize(Size value); -}; - -class UiForm : public UiControl { - public: - UiForm(); - DEFINE_CONTROL_METHODS() - void append(const char *label, UiControl *c, bool stretchy); - void deleteAt(int index); - bool getPadded(); - void setPadded(bool padded); -}; - -// TODO - document -class UiMenuItem { - DEFINE_EVENT(onClicked) - - private: - uiMenuItem *handle; - - public: - UiMenuItem(uiMenuItem *hnd); - void enable(); - void disable(); - bool getChecked(); - void setChecked(bool checked); -}; - -// TODO - document -class UiMenu { - private: - uiMenu *handle; - - public: - UiMenu(const char *name); - UiMenuItem *appendItem(const char *name); - UiMenuItem *appendCheckItem(const char *name); - UiMenuItem *appendQuitItem(); - UiMenuItem *appendPreferencesItem(); - UiMenuItem *appendAboutItem(); - void appendSeparator(); -}; - class Color { private: double r; @@ -697,15 +421,6 @@ class DrawTextFont { int italic, int stretch); }; -class UiFontButton : public UiControl { - DEFINE_EVENT(onChanged) - - public: - UiFontButton(); - DrawTextFont *getFont(); - DEFINE_CONTROL_METHODS() -}; - class DrawTextLayout { private: uiDrawTextLayout *handle; @@ -794,18 +509,29 @@ struct UiAreaHandlerFactory { nbind::cbFunction &keyEvent); }; -// TODO - document -class UiGrid : public UiControl { - public: - UiGrid(); - bool getPadded(); - void setPadded(bool value); - void append(UiControl *c, int left, int top, int xspan, int yspan, - int hexpand, int halign, int vexpand, int valign); - void insertAt(UiControl *c, UiControl *existing, int at, int xspan, - int yspan, int hexpand, int halign, int vexpand, int valign); +class UiWindow { + DEFINE_EVENT(onClosing) + DEFINE_EVENT(onContentSizeChanged) - DEFINE_CONTROL_METHODS() + private: + uiWindow *win; + + public: + UiWindow(const char *title, int width, int height, bool hasMenubar); + uiWindow *getHandle(); + void show(); + void close(); + void setMargined(bool margined); + bool getMargined(); + void setChild(UiControl *control); + void setTitle(const char *title); + const char *getTitle(); + bool getFullscreen(); + void setFullscreen(bool value); + bool getBorderless(); + void setBorderless(bool value); + Size getContentSize(); + void setContentSize(Size value); }; // This is included at end of file From 8c0e6efce9444069d089d3813390fed8cf4ce5aa Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Thu, 5 Apr 2018 00:10:55 +0200 Subject: [PATCH 050/190] Moved UiWindow class declaration to its own cc file. Move dialogs there too becuase they're small and the only ones to use UiWindow --- binding.gyp | 1 - src/UiDialogs.cc | 31 ---------------------------- src/UiWindow.cc | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ src/ui-node.h | 25 ----------------------- 4 files changed, 53 insertions(+), 57 deletions(-) delete mode 100644 src/UiDialogs.cc diff --git a/binding.gyp b/binding.gyp index 7aa16cc..fdc5556 100644 --- a/binding.gyp +++ b/binding.gyp @@ -31,7 +31,6 @@ "src/Point.cc", "src/Color.cc", "src/UiColorButton.cc", - "src/UiDialogs.cc", "src/UiMenu.cc", "src/UiCombobox.cc", "src/UiSlider.cc", diff --git a/src/UiDialogs.cc b/src/UiDialogs.cc deleted file mode 100644 index 0f4a803..0000000 --- a/src/UiDialogs.cc +++ /dev/null @@ -1,31 +0,0 @@ -#include "../ui.h" -#include "ui-node.h" -#include "nbind/api.h" - -struct UiDialogs { - - static char *openFile(UiWindow *parent) { - return uiOpenFile(parent->getHandle()); - } - - static char *saveFile(UiWindow *parent) { - return uiSaveFile(parent->getHandle()); - } - - static void msgBox(UiWindow *parent, const char *title, - const char *description) { - uiMsgBox(parent->getHandle(), title, description); - } - - static void msgBoxError(UiWindow *parent, const char *title, - const char *description) { - uiMsgBoxError(parent->getHandle(), title, description); - } -}; - -NBIND_CLASS(UiDialogs) { - method(openFile); - method(saveFile); - method(msgBox); - method(msgBoxError); -} diff --git a/src/UiWindow.cc b/src/UiWindow.cc index de6d4e8..44219aa 100644 --- a/src/UiWindow.cc +++ b/src/UiWindow.cc @@ -2,6 +2,31 @@ #include "ui-node.h" #include "nbind/api.h" +class UiWindow { + DEFINE_EVENT(onClosing) + DEFINE_EVENT(onContentSizeChanged) + + private: + uiWindow *win; + + public: + UiWindow(const char *title, int width, int height, bool hasMenubar); + uiWindow *getHandle(); + void show(); + void close(); + void setMargined(bool margined); + bool getMargined(); + void setChild(UiControl *control); + void setTitle(const char *title); + const char *getTitle(); + bool getFullscreen(); + void setFullscreen(bool value); + bool getBorderless(); + void setBorderless(bool value); + Size getContentSize(); + void setContentSize(Size value); +}; + static int UiWindow_onClosing(uiWindow *w, void *data) { nbind::cbFunction *cb = (nbind::cbFunction *)data; (*cb)(); @@ -110,3 +135,31 @@ NBIND_CLASS(UiWindow) { method(getBorderless); method(setBorderless); } + +struct UiDialogs { + + static char *openFile(UiWindow *parent) { + return uiOpenFile(parent->getHandle()); + } + + static char *saveFile(UiWindow *parent) { + return uiSaveFile(parent->getHandle()); + } + + static void msgBox(UiWindow *parent, const char *title, + const char *description) { + uiMsgBox(parent->getHandle(), title, description); + } + + static void msgBoxError(UiWindow *parent, const char *title, + const char *description) { + uiMsgBoxError(parent->getHandle(), title, description); + } +}; + +NBIND_CLASS(UiDialogs) { + method(openFile); + method(saveFile); + method(msgBox); + method(msgBoxError); +} diff --git a/src/ui-node.h b/src/ui-node.h index 96e141d..c670703 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -509,31 +509,6 @@ struct UiAreaHandlerFactory { nbind::cbFunction &keyEvent); }; -class UiWindow { - DEFINE_EVENT(onClosing) - DEFINE_EVENT(onContentSizeChanged) - - private: - uiWindow *win; - - public: - UiWindow(const char *title, int width, int height, bool hasMenubar); - uiWindow *getHandle(); - void show(); - void close(); - void setMargined(bool margined); - bool getMargined(); - void setChild(UiControl *control); - void setTitle(const char *title); - const char *getTitle(); - bool getFullscreen(); - void setFullscreen(bool value); - bool getBorderless(); - void setBorderless(bool value); - Size getContentSize(); - void setContentSize(Size value); -}; - // This is included at end of file // to minimize conflicts with existing // symbols from other headers. From 359ff6b17a6ef0e065b5c4caa3e7b0ce194dd17a Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Thu, 5 Apr 2018 00:15:51 +0200 Subject: [PATCH 051/190] Moved UiColorButton class declarations from header to its own cc file --- src/UiColorButton.cc | 10 ++++++++++ src/ui-node.h | 10 ---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/UiColorButton.cc b/src/UiColorButton.cc index 221549f..32c977e 100644 --- a/src/UiColorButton.cc +++ b/src/UiColorButton.cc @@ -2,6 +2,16 @@ #include "ui-node.h" #include "nbind/api.h" +class UiColorButton : public UiControl { + DEFINE_EVENT(onChanged) + + public: + UiColorButton(); + Color getColor(); + void setColor(Color value); + DEFINE_CONTROL_METHODS() +}; + UiColorButton::UiColorButton() : UiControl((uiControl *)uiNewColorButton()) {} INHERITS_CONTROL_METHODS(UiColorButton) diff --git a/src/ui-node.h b/src/ui-node.h index c670703..8c9e4de 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -227,16 +227,6 @@ class Color { void toJS(nbind::cbOutput output); }; -class UiColorButton : public UiControl { - DEFINE_EVENT(onChanged) - - public: - UiColorButton(); - Color getColor(); - void setColor(Color value); - DEFINE_CONTROL_METHODS() -}; - // UIArea class DrawStrokeParams { From f6e3ec3e22bdb2d2d52decfd13baedd5840dc506 Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Fri, 6 Apr 2018 16:27:05 +0200 Subject: [PATCH 052/190] Overload UiFontAttribute.newUnderlineColor --- examples/text.js | 4 ++-- index.js | 8 ++++++++ src/Font/UiFontAttribute.cc | 4 ++-- src/ui-node.h | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/examples/text.js b/examples/text.js index 74cf2cd..88ea88f 100644 --- a/examples/text.js +++ b/examples/text.js @@ -47,11 +47,11 @@ str.appendUnattributed('. '); str.appendUnattributed('Furthermore, there are attributes allowing for '); str.appendAttributed('special underlines for indicating spelling errors', UiFontAttribute.newUnderline(libui.textUnderline.suggestion), - UiFontAttribute.newUnderlineColor(libui.textUnderlineColor.spelling, new libui.Color(0, 0, 0, 0))); + UiFontAttribute.newUnderlineColor(libui.textUnderlineColor.spelling)); str.appendUnattributed(' (and '); str.appendAttributed('other types of errors', UiFontAttribute.newUnderline(libui.textUnderline.suggestion), - UiFontAttribute.newUnderlineColor(libui.textUnderlineColor.grammar, new libui.Color(0, 0, 0, 0))); + UiFontAttribute.newUnderlineColor(libui.textUnderlineColor.grammar)); str.appendUnattributed(') '); str.appendUnattributed('and control over OpenType features such as ligatures (with a suitable font - for instance, '); diff --git a/index.js b/index.js index 26b7348..3e863de 100755 --- a/index.js +++ b/index.js @@ -156,6 +156,14 @@ binding.lib.UiAttributedString.prototype.appendAttributed = function (str, attr, return this.appendAttributed1(str, attr); }; +binding.lib.UiFontAttribute.newUnderlineColor = function (type, color){ + if(type === textUnderlineColor.custom && !color){ + console.error("With textUnderlineColor.custom a color needs to passed"); + } + color = color || new Color(0, 0, 0, 0); + return binding.lib.UiFontAttribute.newUnderlineColor2(type, color); +} + module.exports.textWeight = textWeight; module.exports.textItalic = textItalic; module.exports.textStretch = textStretch; diff --git a/src/Font/UiFontAttribute.cc b/src/Font/UiFontAttribute.cc index c08a339..cae10d7 100644 --- a/src/Font/UiFontAttribute.cc +++ b/src/Font/UiFontAttribute.cc @@ -113,7 +113,7 @@ UiFontAttribute *UiFontAttribute::newUnderline(int underlineAttr) { return new UiFontAttribute(uiNewUnderlineAttribute(underlineAttr)); } -UiFontAttribute *UiFontAttribute::newUnderlineColor(int underlineColorAttr, Color c) { +UiFontAttribute *UiFontAttribute::newUnderlineColor2(int underlineColorAttr, Color c) { return new UiFontAttribute(uiNewUnderlineColorAttribute(underlineColorAttr, c.getR(), c.getG(), c.getB(), c.getA())); } @@ -143,6 +143,6 @@ NBIND_CLASS(UiFontAttribute) { method(newColor); method(newBackground); method(newUnderline); - method(newUnderlineColor); + method(newUnderlineColor2); method(newOTFeatures); } diff --git a/src/ui-node.h b/src/ui-node.h index 98aaf49..35165ba 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -685,7 +685,7 @@ class UiFontAttribute { static UiFontAttribute *newColor(Color c); static UiFontAttribute *newBackground(Color c); static UiFontAttribute *newUnderline(int underlineAttr); - static UiFontAttribute *newUnderlineColor(int underlineColorAttr, Color c); + static UiFontAttribute *newUnderlineColor2(int underlineColorAttr, Color c); static UiFontAttribute *newOTFeatures(UiOpenTypeFeatures *otf); }; From b07c7b706444c8f50438a65d0331ad0aecb6c40e Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Fri, 6 Apr 2018 16:45:15 +0200 Subject: [PATCH 053/190] strlen doesn't include the null terminator --- src/Font/UiFontDescriptor.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Font/UiFontDescriptor.cc b/src/Font/UiFontDescriptor.cc index 1d1cde5..81b569e 100644 --- a/src/Font/UiFontDescriptor.cc +++ b/src/Font/UiFontDescriptor.cc @@ -1,6 +1,7 @@ #include "../../ui.h" #include "../ui-node.h" #include "nbind/nbind.h" +#include UiFontDescriptor::UiFontDescriptor(uiFontDescriptor * desc) { d = desc; @@ -10,8 +11,8 @@ UiFontDescriptor::UiFontDescriptor(uiFontDescriptor * desc) { UiFontDescriptor::UiFontDescriptor(const char *family, double size, int weight, int italic, int stretch) { d = new uiFontDescriptor(); - d->Family = new char[strlen(family)]; - strcpy(d->Family, family); + d->Family = new char[std::strlen(family) + 1]; + std::strcpy(d->Family, family); d->Size = size; d->Weight = weight; d->Italic = italic; From fa9487c39a331d387d883488f97f029103d4f868 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 7 Apr 2018 07:58:16 +0200 Subject: [PATCH 054/190] fix comment --- src/ui-node.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ui-node.h b/src/ui-node.h index 8c9e4de..fefb860 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -1,11 +1,13 @@ -// A2DD.h #ifndef ui_node #define ui_node #include -#include // TODO: this has to be removed once UiArea classes +/* + TODO: this has to be removed once UiArea classes + declarations are moved to their own cc files + */ +#include #include "nbind/api.h" -// declarations are moved to their own cc files #define DEFINE_EVENT(NAME) \ private: \ From 05c29a22e89f83a2a790138270da0b17ca9a8781 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 7 Apr 2018 08:08:19 +0200 Subject: [PATCH 055/190] std::string --> UiButton --- src/UiButton.cc | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/UiButton.cc b/src/UiButton.cc index 3751439..cf6e9d0 100644 --- a/src/UiButton.cc +++ b/src/UiButton.cc @@ -1,3 +1,4 @@ +#include #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" @@ -6,31 +7,34 @@ class UiButton : public UiControl { DEFINE_EVENT(onClicked) public: - UiButton(const char *text); + UiButton(std::string text); UiButton(); DEFINE_CONTROL_METHODS() - void setText(const char *text); - const char *getText(); + void setText(std::string text); + std::string getText(); }; -UiButton::UiButton(const char *text) - : UiControl((uiControl *)uiNewButton(text)) {} -UiButton::UiButton() : UiControl((uiControl *)uiNewButton("")) {} +UiButton::UiButton(std::string text) + : UiControl(uiControl(uiNewButton(text.c_str()))) {} +UiButton::UiButton() : UiControl(uiControl(uiNewButton(""))) {} INHERITS_CONTROL_METHODS(UiButton) -void UiButton::setText(const char *text) { - uiButtonSetText((uiButton *)getHandle(), text); +void UiButton::setText(std::string text) { + uiButtonSetText(uiButton(getHandle()), text.c_str()); } -const char *UiButton::getText() { - return uiButtonText((uiButton *)getHandle()); +std::string UiButton::getText() { + char *char_ptr = uiButtonText(uiButton(getHandle())); + std::string s(char_ptr); + uiFreeText(char_ptr); + return s; } IMPLEMENT_EVENT(UiButton, uiButton, onClicked, uiButtonOnClicked) NBIND_CLASS(UiButton) { - construct(); + construct(); construct<>(); DECLARE_CHILD_CONTROL_METHODS() getset(getText, setText); From 86fff15f0ddf684f946a961878d3c8546d01d439 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 7 Apr 2018 08:25:38 +0200 Subject: [PATCH 056/190] std::string --> UiCheckbox --- src/UiCheckbox.cc | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/UiCheckbox.cc b/src/UiCheckbox.cc index 137f2a6..101fd20 100644 --- a/src/UiCheckbox.cc +++ b/src/UiCheckbox.cc @@ -1,3 +1,4 @@ +#include #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" @@ -6,44 +7,47 @@ class UiCheckbox : public UiControl { DEFINE_EVENT(onToggled) public: - UiCheckbox(const char *text); + UiCheckbox(std::string text); UiCheckbox(); DEFINE_CONTROL_METHODS() - void setText(const char *text); - const char *getText(); + void setText(std::string text); + std::string getText(); void setChecked(bool checked); bool getChecked(); }; IMPLEMENT_EVENT(UiCheckbox, uiCheckbox, onToggled, uiCheckboxOnToggled) -UiCheckbox::UiCheckbox(const char *text) - : UiControl((uiControl *)uiNewCheckbox(text)) {} -UiCheckbox::UiCheckbox() : UiControl((uiControl *)uiNewCheckbox("")) {} +UiCheckbox::UiCheckbox(std::string text) + : UiControl(uiControl(uiNewCheckbox(text.c_str()))) {} +UiCheckbox::UiCheckbox() : UiControl(uiControl(uiNewCheckbox(""))) {} INHERITS_CONTROL_METHODS(UiCheckbox) -void UiCheckbox::setText(const char *text) { - uiCheckboxSetText((uiCheckbox *)getHandle(), text); +void UiCheckbox::setText(std::string text) { + uiCheckboxSetText(uiCheckbox(getHandle()), text.c_str()); } -const char *UiCheckbox::getText() { - return uiCheckboxText((uiCheckbox *)getHandle()); +std::string UiCheckbox::getText() { + char *char_ptr = uiCheckboxText(uiCheckbox(getHandle())); + std::string s(char_ptr); + uiFreeText(char_ptr); + return s; } void UiCheckbox::setChecked(bool checked) { - uiCheckboxSetChecked((uiCheckbox *)getHandle(), checked); + uiCheckboxSetChecked(uiCheckbox(getHandle()), checked); if (onToggledCallback != NULL) { (*onToggledCallback)(); } } bool UiCheckbox::getChecked() { - return uiCheckboxChecked((uiCheckbox *)getHandle()); + return uiCheckboxChecked(uiCheckbox(getHandle())); } NBIND_CLASS(UiCheckbox) { - construct(); + construct(); construct<>(); DECLARE_CHILD_CONTROL_METHODS() getset(getChecked, setChecked); From 8aad4ab135ddc952cef9b3722a7f028c59fc6d42 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 7 Apr 2018 08:10:54 +0200 Subject: [PATCH 057/190] std::string --> UiCombobox --- src/UiCombobox.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/UiCombobox.cc b/src/UiCombobox.cc index 474ec2c..429762f 100644 --- a/src/UiCombobox.cc +++ b/src/UiCombobox.cc @@ -1,3 +1,4 @@ +#include #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" @@ -8,7 +9,7 @@ class UiCombobox : public UiControl { public: UiCombobox(); DEFINE_CONTROL_METHODS() - void append(const char *text); + void append(std::string text); int getSelected(); void setSelected(int n); }; @@ -19,8 +20,8 @@ INHERITS_CONTROL_METHODS(UiCombobox) IMPLEMENT_EVENT(UiCombobox, uiCombobox, onSelected, uiComboboxOnSelected) -void UiCombobox::append(const char *text) { - uiComboboxAppend((uiCombobox *)getHandle(), text); +void UiCombobox::append(std::string text) { + uiComboboxAppend((uiCombobox *)getHandle(), text.c_str()); } int UiCombobox::getSelected() { From 0fea662631cc12d5dffca4aa6006b7218e716207 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 7 Apr 2018 08:13:45 +0200 Subject: [PATCH 058/190] std::string --> UiEditableCombobox --- src/UiEditableCombobox.cc | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/UiEditableCombobox.cc b/src/UiEditableCombobox.cc index 0edeb80..5958d37 100644 --- a/src/UiEditableCombobox.cc +++ b/src/UiEditableCombobox.cc @@ -1,3 +1,4 @@ +#include #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" @@ -8,32 +9,35 @@ class UiEditableCombobox : public UiControl { public: UiEditableCombobox(); DEFINE_CONTROL_METHODS() - void append(const char *text); - const char *getText(); - void setText(const char *text); + void append(std::string text); + std::string getText(); + void setText(std::string text); }; UiEditableCombobox::UiEditableCombobox() - : UiControl((uiControl *)uiNewEditableCombobox()) {} + : UiControl(uiControl(uiNewEditableCombobox())) {} INHERITS_CONTROL_METHODS(UiEditableCombobox) IMPLEMENT_EVENT(UiEditableCombobox, uiEditableCombobox, onChanged, uiEditableComboboxOnChanged) -void UiEditableCombobox::append(const char *text) { - uiEditableComboboxAppend((uiEditableCombobox *)getHandle(), text); +void UiEditableCombobox::append(std::string text) { + uiEditableComboboxAppend(uiEditableCombobox(getHandle()), text.c_str()); } -void UiEditableCombobox::setText(const char *text) { - uiEditableComboboxSetText((uiEditableCombobox *)getHandle(), text); +void UiEditableCombobox::setText(std::string text) { + uiEditableComboboxSetText(uiEditableCombobox(getHandle()), text.c_str()); if (onChangedCallback != NULL) { (*onChangedCallback)(); } } -const char *UiEditableCombobox::getText() { - return uiEditableComboboxText((uiEditableCombobox *)getHandle()); +std::string UiEditableCombobox::getText() { + char *char_ptr = uiEditableComboboxText(uiEditableCombobox(getHandle())); + std::string s(char_ptr); + uiFreeText(char_ptr); + return s; } NBIND_CLASS(UiEditableCombobox) { From 983883637b15ec8abefa40d49284853459db9330 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 7 Apr 2018 08:22:00 +0200 Subject: [PATCH 059/190] std::string --> UiEntry --- src/UiEntry.cc | 23 ++++++++++++++--------- src/ui-node.h | 32 -------------------------------- 2 files changed, 14 insertions(+), 41 deletions(-) diff --git a/src/UiEntry.cc b/src/UiEntry.cc index 3cf809f..c8146f0 100644 --- a/src/UiEntry.cc +++ b/src/UiEntry.cc @@ -1,6 +1,8 @@ +#include #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" +#include "includes/entry.h" class UiEntryBase : public UiControl { DEFINE_EVENT(onChanged) @@ -37,39 +39,42 @@ class UiSearchEntry : public UiEntryBase { UiEntryBase::UiEntryBase(uiControl *hnd) : UiControl(hnd) {} -void UiEntryBase::setText(const char *text) { - uiEntrySetText((uiEntry *)getHandle(), text); +void UiEntryBase::setText(std::string text) { + uiEntrySetText(uiEntry(getHandle()), text.c_str()); if (onChangedCallback != NULL) { (*onChangedCallback)(); } } -const char *UiEntryBase::getText() { - return uiEntryText((uiEntry *)getHandle()); +std::string UiEntryBase::getText() { + char *char_ptr = uiEntryText(uiEntry(getHandle())); + std::string s(char_ptr); + uiFreeText(char_ptr); + return s; } void UiEntryBase::setReadOnly(bool readOnly) { - uiEntrySetReadOnly((uiEntry *)getHandle(), readOnly); + uiEntrySetReadOnly(uiEntry(getHandle()), readOnly); } bool UiEntryBase::getReadOnly() { - return uiEntryReadOnly((uiEntry *)getHandle()); + return uiEntryReadOnly(uiEntry(getHandle())); } IMPLEMENT_EVENT(UiEntryBase, uiEntry, onChanged, uiEntryOnChanged) -UiEntry::UiEntry() : UiEntryBase((uiControl *)uiNewEntry()) {} +UiEntry::UiEntry() : UiEntryBase(uiControl(uiNewEntry())) {} INHERITS_CONTROL_METHODS(UiEntry) INHERITS_ENTRY_METHODS(UiEntry) UiPasswordEntry::UiPasswordEntry() - : UiEntryBase((uiControl *)uiNewPasswordEntry()) {} + : UiEntryBase(uiControl(uiNewPasswordEntry())) {} INHERITS_CONTROL_METHODS(UiPasswordEntry) INHERITS_ENTRY_METHODS(UiPasswordEntry) -UiSearchEntry::UiSearchEntry() : UiEntryBase((uiControl *)uiNewSearchEntry()) {} +UiSearchEntry::UiSearchEntry() : UiEntryBase(uiControl(uiNewSearchEntry())) {} INHERITS_CONTROL_METHODS(UiSearchEntry) INHERITS_ENTRY_METHODS(UiSearchEntry) diff --git a/src/ui-node.h b/src/ui-node.h index fefb860..f15b1c5 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -81,38 +81,6 @@ getset(getVisible, setVisible); \ getset(getEnabled, setEnabled); -#define DEFINE_ENTRY_METHODS() \ - void setText(const char *text); \ - const char *getText(); \ - void setReadOnly(bool readOnly); \ - bool getReadOnly(); - -#define INHERITS_ENTRY_METHODS(CLASS) \ - void CLASS::setText(const char *text) { \ - UiEntryBase::setText(text); \ - } \ - const char *CLASS::getText() { \ - return UiEntryBase::getText(); \ - } \ - void CLASS::setReadOnly(bool readOnly) { \ - UiEntryBase::setReadOnly(readOnly); \ - } \ - bool CLASS::getReadOnly() { \ - return UiEntryBase::getReadOnly(); \ - } \ - void CLASS::onChanged(nbind::cbFunction &cb) { \ - UiEntryBase::onChanged(cb); \ - } - -#define DECLARE_ENTRY_METHODS() \ - getset(getText, setText); \ - getset(getReadOnly, setReadOnly); \ - method(onChanged); \ - method(getText); \ - method(setText); \ - method(getReadOnly); \ - method(setReadOnly); - #define DEFINE_BOX_METHODS() \ void append(UiControl *control, bool stretchy); \ void deleteAt(int index); \ From b2c9aa85541ff4ae4687eba3bc991ab4ede50814 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 7 Apr 2018 08:31:26 +0200 Subject: [PATCH 060/190] std::string --> UiForm --- src/UiForm.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/UiForm.cc b/src/UiForm.cc index db3a711..a7debd5 100644 --- a/src/UiForm.cc +++ b/src/UiForm.cc @@ -1,3 +1,4 @@ +#include #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" @@ -6,28 +7,28 @@ class UiForm : public UiControl { public: UiForm(); DEFINE_CONTROL_METHODS() - void append(const char *label, UiControl *c, bool stretchy); + void append(std::string label, UiControl *c, bool stretchy); void deleteAt(int index); bool getPadded(); void setPadded(bool padded); }; -UiForm::UiForm() : UiControl((uiControl *)uiNewForm()) {} +UiForm::UiForm() : UiControl(uiControl(uiNewForm())) {} -void UiForm::append(const char *label, UiControl *c, bool stretchy) { - uiFormAppend((uiForm *)getHandle(), label, c->getHandle(), stretchy); +void UiForm::append(std::string label, UiControl *c, bool stretchy) { + uiFormAppend(uiForm(getHandle()), label.c_str(), c->getHandle(), stretchy); } void UiForm::deleteAt(int index) { - uiFormDelete((uiForm *)getHandle(), index); + uiFormDelete(uiForm(getHandle()), index); } bool UiForm::getPadded() { - return uiFormPadded((uiForm *)getHandle()); + return uiFormPadded(uiForm(getHandle())); } void UiForm::setPadded(bool padded) { - uiFormSetPadded((uiForm *)getHandle(), padded); + uiFormSetPadded(uiForm(getHandle()), padded); } INHERITS_CONTROL_METHODS(UiForm) From 9b3a2d9a44bf6888ec3d53b9a1808c246180d235 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 7 Apr 2018 08:32:45 +0200 Subject: [PATCH 061/190] std::string --> UiGroup --- src/UiGroup.cc | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/UiGroup.cc b/src/UiGroup.cc index e6580c2..1e4e785 100644 --- a/src/UiGroup.cc +++ b/src/UiGroup.cc @@ -1,46 +1,51 @@ +#include #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" class UiGroup : public UiControl { public: - UiGroup(const char *text); + UiGroup(std::string text); UiGroup(); void setChild(UiControl *control); bool getMargined(); void setMargined(bool margined); - const char *getTitle(); - void setTitle(const char *title); + std::string getTitle(); + void setTitle(std::string title); DEFINE_CONTROL_METHODS() }; -UiGroup::UiGroup(const char *text) : UiControl((uiControl *)uiNewGroup(text)) {} -UiGroup::UiGroup() : UiControl((uiControl *)uiNewGroup("")) {} +UiGroup::UiGroup(std::string text) + : UiControl(uiControl(uiNewGroup(text.c_str()))) {} +UiGroup::UiGroup() : UiControl(uiControl(uiNewGroup(""))) {} void UiGroup::setChild(UiControl *control) { - uiGroupSetChild((uiGroup *)getHandle(), control->getHandle()); + uiGroupSetChild(uiGroup(getHandle()), control->getHandle()); } bool UiGroup::getMargined() { - return uiGroupMargined((uiGroup *)getHandle()); + return uiGroupMargined(uiGroup(getHandle())); } void UiGroup::setMargined(bool margined) { - uiGroupSetMargined((uiGroup *)getHandle(), margined); + uiGroupSetMargined(uiGroup(getHandle()), margined); } -const char *UiGroup::getTitle() { - return uiGroupTitle((uiGroup *)getHandle()); +std::string UiGroup::getTitle() { + char *char_ptr = uiGroupTitle(uiGroup(getHandle())); + std::string s(char_ptr); + uiFreeText(char_ptr); + return s; } -void UiGroup::setTitle(const char *title) { - uiGroupSetTitle((uiGroup *)getHandle(), title); +void UiGroup::setTitle(std::string title) { + uiGroupSetTitle(uiGroup(getHandle()), title.c_str()); } INHERITS_CONTROL_METHODS(UiGroup) NBIND_CLASS(UiGroup) { - construct(); + construct(); construct<>(); method(setChild); method(getTitle); From b3e0415053908d3615e63652278788744079fa38 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 7 Apr 2018 08:34:46 +0200 Subject: [PATCH 062/190] std::string --> UiLabel --- src/UiLabel.cc | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/UiLabel.cc b/src/UiLabel.cc index b0e5e6e..a576aab 100644 --- a/src/UiLabel.cc +++ b/src/UiLabel.cc @@ -1,3 +1,4 @@ +#include #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" @@ -5,27 +6,31 @@ class UiLabel : public UiControl { public: UiLabel(); - UiLabel(const char *text); + UiLabel(std::string text); DEFINE_CONTROL_METHODS() - void setText(const char *text); - const char *getText(); + void setText(std::string text); + std::string getText(); }; -UiLabel::UiLabel(const char *text) : UiControl((uiControl *)uiNewLabel(text)) {} -UiLabel::UiLabel() : UiControl((uiControl *)uiNewLabel("")) {} +UiLabel::UiLabel(std::string text) + : UiControl(uiControl(uiNewLabel(text.c_str()))) {} +UiLabel::UiLabel() : UiControl(uiControl(uiNewLabel(""))) {} INHERITS_CONTROL_METHODS(UiLabel) -void UiLabel::setText(const char *text) { - uiLabelSetText((uiLabel *)getHandle(), text); +void UiLabel::setText(std::string text) { + uiLabelSetText(uiLabel(getHandle()), text.c_str()); } -const char *UiLabel::getText() { - return uiLabelText((uiLabel *)getHandle()); +std::string UiLabel::getText() { + char *char_ptr = uiLabelText(uiLabel(getHandle())); + std::string s(char_ptr); + uiFreeText(char_ptr); + return s; } NBIND_CLASS(UiLabel) { - construct(); + construct(); construct<>(); DECLARE_CHILD_CONTROL_METHODS() getset(getText, setText); From 57e1ba9b00cb4012a2595f3b0acdf2844ffa63a2 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 7 Apr 2018 08:39:00 +0200 Subject: [PATCH 063/190] std::string --> UiMenu --- src/UiMenu.cc | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/UiMenu.cc b/src/UiMenu.cc index 46897c9..14184f6 100644 --- a/src/UiMenu.cc +++ b/src/UiMenu.cc @@ -1,3 +1,4 @@ +#include #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" @@ -23,9 +24,9 @@ class UiMenu { uiMenu *handle; public: - UiMenu(const char *name); - UiMenuItem *appendItem(const char *name); - UiMenuItem *appendCheckItem(const char *name); + UiMenu(std::string name); + UiMenuItem *appendItem(std::string name); + UiMenuItem *appendCheckItem(std::string name); UiMenuItem *appendQuitItem(); UiMenuItem *appendPreferencesItem(); UiMenuItem *appendAboutItem(); @@ -63,16 +64,16 @@ void UiMenuItem::setChecked(bool checked) { uiMenuItemSetChecked(handle, checked); } -UiMenu::UiMenu(const char *name) { - handle = uiNewMenu(name); +UiMenu::UiMenu(std::string name) { + handle = uiNewMenu(name.c_str()); } -UiMenuItem *UiMenu::appendItem(const char *name) { - return new UiMenuItem(uiMenuAppendItem(handle, name)); +UiMenuItem *UiMenu::appendItem(std::string name) { + return new UiMenuItem(uiMenuAppendItem(handle, name.c_str())); } -UiMenuItem *UiMenu::appendCheckItem(const char *name) { - return new UiMenuItem(uiMenuAppendCheckItem(handle, name)); +UiMenuItem *UiMenu::appendCheckItem(std::string name) { + return new UiMenuItem(uiMenuAppendCheckItem(handle, name.c_str())); } UiMenuItem *UiMenu::appendQuitItem() { @@ -92,7 +93,7 @@ void UiMenu::appendSeparator() { } NBIND_CLASS(UiMenu) { - construct(); + construct(); method(appendItem); method(appendCheckItem); method(appendQuitItem); From a2a7597025f59300cd12acd76790baf349ce68d8 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 7 Apr 2018 08:41:49 +0200 Subject: [PATCH 064/190] std::string --> UiMultilineEntry --- src/UiMultilineEntry.cc | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/UiMultilineEntry.cc b/src/UiMultilineEntry.cc index ac8e2a3..e398423 100644 --- a/src/UiMultilineEntry.cc +++ b/src/UiMultilineEntry.cc @@ -1,3 +1,4 @@ +#include #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" @@ -8,42 +9,45 @@ class UiMultilineEntry : public UiControl { public: UiMultilineEntry(); DEFINE_CONTROL_METHODS() - void setText(const char *text); - const char *getText(); + void setText(std::string text); + std::string getText(); void setReadOnly(bool readOnly); bool getReadOnly(); - void append(const char *text); + void append(std::string text); }; UiMultilineEntry::UiMultilineEntry() - : UiControl((uiControl *)uiNewNonWrappingMultilineEntry()) {} + : UiControl(uiControl(uiNewNonWrappingMultilineEntry())) {} INHERITS_CONTROL_METHODS(UiMultilineEntry) IMPLEMENT_EVENT(UiMultilineEntry, uiMultilineEntry, onChanged, uiMultilineEntryOnChanged) -void UiMultilineEntry::setText(const char *text) { - uiMultilineEntrySetText((uiMultilineEntry *)getHandle(), text); +void UiMultilineEntry::setText(std::string text) { + uiMultilineEntrySetText(uiMultilineEntry(getHandle()), text.c_str()); if (onChangedCallback != NULL) { (*onChangedCallback)(); } } -const char *UiMultilineEntry::getText() { - return uiMultilineEntryText((uiMultilineEntry *)getHandle()); +std::string UiMultilineEntry::getText() { + char *char_ptr = uiMultilineEntryText(uiMultilineEntry(getHandle())); + std::string s(char_ptr); + uiFreeText(char_ptr); + return s; } void UiMultilineEntry::setReadOnly(bool readOnly) { - uiMultilineEntrySetReadOnly((uiMultilineEntry *)getHandle(), readOnly); + uiMultilineEntrySetReadOnly(uiMultilineEntry(getHandle()), readOnly); } bool UiMultilineEntry::getReadOnly() { - return uiMultilineEntryReadOnly((uiMultilineEntry *)getHandle()); + return uiMultilineEntryReadOnly(uiMultilineEntry(getHandle())); } -void UiMultilineEntry::append(const char *text) { - uiMultilineEntryAppend((uiMultilineEntry *)getHandle(), text); +void UiMultilineEntry::append(std::string text) { + uiMultilineEntryAppend(uiMultilineEntry(getHandle()), text.c_str()); } NBIND_CLASS(UiMultilineEntry) { From 371ac4556c1892b328dfcd7e11180f4b88b050f9 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 7 Apr 2018 08:54:05 +0200 Subject: [PATCH 065/190] std::string --> UiWindow --- src/UiWindow.cc | 54 +++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/src/UiWindow.cc b/src/UiWindow.cc index 44219aa..a7340fe 100644 --- a/src/UiWindow.cc +++ b/src/UiWindow.cc @@ -1,3 +1,4 @@ +#include #include "../ui.h" #include "ui-node.h" #include "nbind/api.h" @@ -10,15 +11,15 @@ class UiWindow { uiWindow *win; public: - UiWindow(const char *title, int width, int height, bool hasMenubar); + UiWindow(std::string title, int width, int height, bool hasMenubar); uiWindow *getHandle(); void show(); void close(); void setMargined(bool margined); bool getMargined(); void setChild(UiControl *control); - void setTitle(const char *title); - const char *getTitle(); + void setTitle(std::string title); + std::string getTitle(); bool getFullscreen(); void setFullscreen(bool value); bool getBorderless(); @@ -35,7 +36,7 @@ static int UiWindow_onClosing(uiWindow *w, void *data) { void UiWindow::onClosing(nbind::cbFunction &cb) { onClosingCallback = new nbind::cbFunction(cb); - uiWindowOnClosing((uiWindow *)getHandle(), UiWindow_onClosing, + uiWindowOnClosing(uiWindow(getHandle()), UiWindow_onClosing, onClosingCallback); } @@ -46,13 +47,13 @@ static void UiWindow_onContentSizeChanged(uiWindow *w, void *data) { void UiWindow::onContentSizeChanged(nbind::cbFunction &cb) { onContentSizeChangedCallback = new nbind::cbFunction(cb); - uiWindowOnContentSizeChanged((uiWindow *)getHandle(), + uiWindowOnContentSizeChanged(uiWindow(getHandle()), UiWindow_onContentSizeChanged, onContentSizeChangedCallback); } -UiWindow::UiWindow(const char *title, int width, int height, bool hasMenubar) { - win = uiNewWindow(title, width, height, hasMenubar); +UiWindow::UiWindow(std::string title, int width, int height, bool hasMenubar) { + win = uiNewWindow(title.c_str(), width, height, hasMenubar); } uiWindow *UiWindow::getHandle() { @@ -79,12 +80,15 @@ void UiWindow::setChild(UiControl *control) { uiWindowSetChild(win, control->getHandle()); } -void UiWindow::setTitle(const char *title) { - uiWindowSetTitle(win, title); +void UiWindow::setTitle(std::string title) { + uiWindowSetTitle(win, title.c_str()); } -const char *UiWindow::getTitle() { - return uiWindowTitle(win); +std::string UiWindow::getTitle() { + char *char_ptr = uiWindowTitle(win); + std::string s(char_ptr); + uiFreeText(char_ptr); + return s; } bool UiWindow::getFullscreen() { @@ -114,7 +118,7 @@ Size UiWindow::getContentSize() { } NBIND_CLASS(UiWindow) { - construct(); + construct(); method(show); method(close); method(setChild); @@ -138,22 +142,28 @@ NBIND_CLASS(UiWindow) { struct UiDialogs { - static char *openFile(UiWindow *parent) { - return uiOpenFile(parent->getHandle()); + static std::string openFile(UiWindow *parent) { + char *char_ptr = uiOpenFile(parent->getHandle()); + std::string s(char_ptr); + uiFreeText(char_ptr); + return s; } - static char *saveFile(UiWindow *parent) { - return uiSaveFile(parent->getHandle()); + static std::string saveFile(UiWindow *parent) { + char *char_ptr = uiSaveFile(parent->getHandle()); + std::string s(char_ptr); + uiFreeText(char_ptr); + return s; } - static void msgBox(UiWindow *parent, const char *title, - const char *description) { - uiMsgBox(parent->getHandle(), title, description); + static void msgBox(UiWindow *parent, std::string title, + std::string description) { + uiMsgBox(parent->getHandle(), title.c_str(), description.c_str()); } - static void msgBoxError(UiWindow *parent, const char *title, - const char *description) { - uiMsgBoxError(parent->getHandle(), title, description); + static void msgBoxError(UiWindow *parent, std::string title, + std::string description) { + uiMsgBoxError(parent->getHandle(), title.c_str(), description.c_str()); } }; From 392a1ac002a112f5f8d8c940a13cd598232db260 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 7 Apr 2018 09:44:56 +0200 Subject: [PATCH 066/190] Completed headers refactoring --- src/Color.cc | 3 +- src/Point.cc | 3 +- src/PointDouble.cc | 3 +- src/Size.cc | 3 +- src/SizeDouble.cc | 3 +- src/UiArea/BrushGradientStop.cc | 2 +- src/UiArea/DrawBrush.cc | 2 +- src/UiArea/DrawMatrix.cc | 2 +- src/UiArea/DrawStrokeParams.cc | 2 +- src/UiArea/DrawTextFont.cc | 2 +- src/UiArea/DrawTextFontDescriptor.cc | 2 +- src/UiArea/DrawTextFontMetrics.cc | 2 +- src/UiArea/DrawTextLayout.cc | 2 +- src/UiArea/UiArea.cc | 3 +- src/UiArea/UiAreaDrawParams.cc | 2 +- src/UiArea/UiAreaHandler.cc | 2 +- src/UiArea/UiAreaKeyEvent.cc | 2 +- src/UiArea/UiAreaMouseEvent.cc | 2 +- src/UiArea/UiDrawContext.cc | 2 +- src/UiArea/UiDrawPath.cc | 2 +- src/UiBox.cc | 3 +- src/UiButton.cc | 2 +- src/UiCheckbox.cc | 2 +- src/UiColorButton.cc | 3 +- src/UiCombobox.cc | 2 +- src/UiControl.cc | 2 +- src/UiDateTimePicker.cc | 2 +- src/UiEditableCombobox.cc | 2 +- src/UiEntry.cc | 2 +- src/UiFontButton.cc | 4 +- src/UiForm.cc | 3 +- src/UiGrid.cc | 2 +- src/UiGroup.cc | 2 +- src/UiLabel.cc | 2 +- src/UiMenu.cc | 2 +- src/UiMultilineEntry.cc | 2 +- src/UiProgressBar.cc | 2 +- src/UiRadioButtons.cc | 2 +- src/UiSeparator.cc | 3 +- src/UiSlider.cc | 2 +- src/UiSpinbox.cc | 2 +- src/UiTab.cc | 2 +- src/UiWindow.cc | 3 +- src/ui-node.h | 477 --------------------------- 44 files changed, 51 insertions(+), 525 deletions(-) delete mode 100644 src/ui-node.h diff --git a/src/Color.cc b/src/Color.cc index 0400e68..1282e4b 100644 --- a/src/Color.cc +++ b/src/Color.cc @@ -1,5 +1,4 @@ -#include "../ui.h" -#include "ui-node.h" +#include "includes/values.h" Color::Color(const Color &other) { r = other.r; diff --git a/src/Point.cc b/src/Point.cc index 61a388c..bc06902 100644 --- a/src/Point.cc +++ b/src/Point.cc @@ -1,5 +1,4 @@ -#include "../ui.h" -#include "ui-node.h" +#include "includes/values.h" Point::Point(const Point &other) { x = other.x; diff --git a/src/PointDouble.cc b/src/PointDouble.cc index deeab65..156e3ec 100644 --- a/src/PointDouble.cc +++ b/src/PointDouble.cc @@ -1,5 +1,4 @@ -#include "../ui.h" -#include "ui-node.h" +#include "includes/values.h" PointDouble::PointDouble(const PointDouble &other) { x = other.x; diff --git a/src/Size.cc b/src/Size.cc index 32e30a2..974ba91 100644 --- a/src/Size.cc +++ b/src/Size.cc @@ -1,5 +1,4 @@ -#include "../ui.h" -#include "ui-node.h" +#include "includes/values.h" Size::Size(int width, int height) { w = width; diff --git a/src/SizeDouble.cc b/src/SizeDouble.cc index 30e768f..dde29c8 100644 --- a/src/SizeDouble.cc +++ b/src/SizeDouble.cc @@ -1,5 +1,4 @@ -#include "../ui.h" -#include "ui-node.h" +#include "includes/values.h" SizeDouble::SizeDouble(double width, double height) { w = width; diff --git a/src/UiArea/BrushGradientStop.cc b/src/UiArea/BrushGradientStop.cc index 9b44d55..8b0df83 100644 --- a/src/UiArea/BrushGradientStop.cc +++ b/src/UiArea/BrushGradientStop.cc @@ -1,5 +1,5 @@ #include "../../ui.h" -#include "../ui-node.h" +#include "../includes/area.h" BrushGradientStop::BrushGradientStop(double pos, Color color) : c(color) { p = pos; diff --git a/src/UiArea/DrawBrush.cc b/src/UiArea/DrawBrush.cc index a5d73b8..6b23685 100644 --- a/src/UiArea/DrawBrush.cc +++ b/src/UiArea/DrawBrush.cc @@ -1,6 +1,6 @@ #include #include "../../ui.h" -#include "../ui-node.h" +#include "../includes/area.h" DrawBrush::DrawBrush() { b = new uiDrawBrush(); diff --git a/src/UiArea/DrawMatrix.cc b/src/UiArea/DrawMatrix.cc index 09eb333..2abd419 100644 --- a/src/UiArea/DrawMatrix.cc +++ b/src/UiArea/DrawMatrix.cc @@ -1,5 +1,5 @@ #include "../../ui.h" -#include "../ui-node.h" +#include "../includes/area.h" UiDrawMatrix::UiDrawMatrix() { m = new uiDrawMatrix(); diff --git a/src/UiArea/DrawStrokeParams.cc b/src/UiArea/DrawStrokeParams.cc index 3372424..bd5a1ae 100644 --- a/src/UiArea/DrawStrokeParams.cc +++ b/src/UiArea/DrawStrokeParams.cc @@ -1,6 +1,6 @@ #include #include "../../ui.h" -#include "../ui-node.h" +#include "../includes/area.h" DrawStrokeParams::DrawStrokeParams() { sp = new uiDrawStrokeParams(); diff --git a/src/UiArea/DrawTextFont.cc b/src/UiArea/DrawTextFont.cc index 9b02657..173d050 100644 --- a/src/UiArea/DrawTextFont.cc +++ b/src/UiArea/DrawTextFont.cc @@ -1,6 +1,6 @@ #include #include "../../ui.h" -#include "../ui-node.h" +#include "../includes/area.h" DrawTextFont::DrawTextFont() {} DrawTextFont::DrawTextFont(uiDrawTextFont *h) { diff --git a/src/UiArea/DrawTextFontDescriptor.cc b/src/UiArea/DrawTextFontDescriptor.cc index 60df92c..07e65c7 100644 --- a/src/UiArea/DrawTextFontDescriptor.cc +++ b/src/UiArea/DrawTextFontDescriptor.cc @@ -1,5 +1,5 @@ #include "../../ui.h" -#include "../ui-node.h" +#include "../includes/area.h" const char *DrawTextFontDescriptor::getFamily() { return d->Family; diff --git a/src/UiArea/DrawTextFontMetrics.cc b/src/UiArea/DrawTextFontMetrics.cc index 0f4b238..ad98ba0 100644 --- a/src/UiArea/DrawTextFontMetrics.cc +++ b/src/UiArea/DrawTextFontMetrics.cc @@ -1,5 +1,5 @@ #include "../../ui.h" -#include "../ui-node.h" +#include "../includes/area.h" DrawTextFontMetrics::DrawTextFontMetrics(uiDrawTextFontMetrics *metrics) { m = metrics; diff --git a/src/UiArea/DrawTextLayout.cc b/src/UiArea/DrawTextLayout.cc index 37b3e26..529b8f3 100644 --- a/src/UiArea/DrawTextLayout.cc +++ b/src/UiArea/DrawTextLayout.cc @@ -1,5 +1,5 @@ #include "../../ui.h" -#include "../ui-node.h" +#include "../includes/area.h" DrawTextLayout::DrawTextLayout(const char *text, DrawTextFont *defaultFont, double width) { diff --git a/src/UiArea/UiArea.cc b/src/UiArea/UiArea.cc index e29d78b..15b8f8c 100644 --- a/src/UiArea/UiArea.cc +++ b/src/UiArea/UiArea.cc @@ -1,5 +1,6 @@ #include "../../ui.h" -#include "../ui-node.h" +#include "../includes/area.h" +#include "../includes/control.h" std::map areasMap; diff --git a/src/UiArea/UiAreaDrawParams.cc b/src/UiArea/UiAreaDrawParams.cc index f3f04aa..c2684c1 100644 --- a/src/UiArea/UiAreaDrawParams.cc +++ b/src/UiArea/UiAreaDrawParams.cc @@ -1,5 +1,5 @@ #include "../../ui.h" -#include "../ui-node.h" +#include "../includes/area.h" UiAreaDrawParams::UiAreaDrawParams(uiAreaDrawParams *params) { p = params; diff --git a/src/UiArea/UiAreaHandler.cc b/src/UiArea/UiAreaHandler.cc index dc7be70..777320c 100644 --- a/src/UiArea/UiAreaHandler.cc +++ b/src/UiArea/UiAreaHandler.cc @@ -1,5 +1,5 @@ #include "../../ui.h" -#include "../ui-node.h" +#include "../includes/area.h" void Draw(UiAreaHandler *self, uiArea *area, uiAreaDrawParams *params) { UiAreaDrawParams *pp = new UiAreaDrawParams(params); diff --git a/src/UiArea/UiAreaKeyEvent.cc b/src/UiArea/UiAreaKeyEvent.cc index 9e3f2c3..76292a2 100644 --- a/src/UiArea/UiAreaKeyEvent.cc +++ b/src/UiArea/UiAreaKeyEvent.cc @@ -1,6 +1,6 @@ #include "../../ui.h" -#include "../ui-node.h" +#include "../includes/area.h" UiAreaKeyEvent::UiAreaKeyEvent(uiAreaKeyEvent *event) { e = event; diff --git a/src/UiArea/UiAreaMouseEvent.cc b/src/UiArea/UiAreaMouseEvent.cc index 176dc37..4e5fb2d 100644 --- a/src/UiArea/UiAreaMouseEvent.cc +++ b/src/UiArea/UiAreaMouseEvent.cc @@ -1,5 +1,5 @@ #include "../../ui.h" -#include "../ui-node.h" +#include "../includes/area.h" UiAreaMouseEvent::UiAreaMouseEvent(uiAreaMouseEvent *event) { e = event; diff --git a/src/UiArea/UiDrawContext.cc b/src/UiArea/UiDrawContext.cc index aea7d1f..1e6c32f 100644 --- a/src/UiArea/UiDrawContext.cc +++ b/src/UiArea/UiDrawContext.cc @@ -1,5 +1,5 @@ #include "../../ui.h" -#include "../ui-node.h" +#include "../includes/area.h" UiDrawContext::UiDrawContext(uiDrawContext *ctx) { c = ctx; diff --git a/src/UiArea/UiDrawPath.cc b/src/UiArea/UiDrawPath.cc index 33824e0..fb4199f 100644 --- a/src/UiArea/UiDrawPath.cc +++ b/src/UiArea/UiDrawPath.cc @@ -1,5 +1,5 @@ #include "../../ui.h" -#include "../ui-node.h" +#include "../includes/area.h" UiDrawPath::UiDrawPath(int fillMode) { handle = uiDrawNewPath(fillMode); diff --git a/src/UiBox.cc b/src/UiBox.cc index 27ec2f1..9aae59f 100644 --- a/src/UiBox.cc +++ b/src/UiBox.cc @@ -1,6 +1,7 @@ #include "../ui.h" -#include "ui-node.h" #include "nbind/api.h" +#include "includes/box.h" +#include "includes/control.h" class UiBox : public UiControl { public: diff --git a/src/UiButton.cc b/src/UiButton.cc index cf6e9d0..6599433 100644 --- a/src/UiButton.cc +++ b/src/UiButton.cc @@ -1,7 +1,7 @@ #include #include "../ui.h" -#include "ui-node.h" #include "nbind/api.h" +#include "includes/control.h" class UiButton : public UiControl { DEFINE_EVENT(onClicked) diff --git a/src/UiCheckbox.cc b/src/UiCheckbox.cc index 101fd20..00e8e48 100644 --- a/src/UiCheckbox.cc +++ b/src/UiCheckbox.cc @@ -1,7 +1,7 @@ #include #include "../ui.h" -#include "ui-node.h" #include "nbind/api.h" +#include "includes/control.h" class UiCheckbox : public UiControl { DEFINE_EVENT(onToggled) diff --git a/src/UiColorButton.cc b/src/UiColorButton.cc index 32c977e..8341e66 100644 --- a/src/UiColorButton.cc +++ b/src/UiColorButton.cc @@ -1,6 +1,7 @@ #include "../ui.h" -#include "ui-node.h" #include "nbind/api.h" +#include "includes/control.h" +#include "includes/values.h" class UiColorButton : public UiControl { DEFINE_EVENT(onChanged) diff --git a/src/UiCombobox.cc b/src/UiCombobox.cc index 429762f..90146c5 100644 --- a/src/UiCombobox.cc +++ b/src/UiCombobox.cc @@ -1,7 +1,7 @@ #include #include "../ui.h" -#include "ui-node.h" #include "nbind/api.h" +#include "includes/control.h" class UiCombobox : public UiControl { DEFINE_EVENT(onSelected) diff --git a/src/UiControl.cc b/src/UiControl.cc index 7bb3df2..7326a1f 100644 --- a/src/UiControl.cc +++ b/src/UiControl.cc @@ -1,6 +1,6 @@ #include "../ui.h" -#include "ui-node.h" #include "nbind/api.h" +#include "includes/control.h" uiControl *UiControl::getHandle() { return handle; diff --git a/src/UiDateTimePicker.cc b/src/UiDateTimePicker.cc index bd1a01f..94de1a6 100644 --- a/src/UiDateTimePicker.cc +++ b/src/UiDateTimePicker.cc @@ -1,6 +1,6 @@ #include "../ui.h" -#include "ui-node.h" #include "nbind/api.h" +#include "includes/control.h" class UiDateTimePicker : public UiControl { public: diff --git a/src/UiEditableCombobox.cc b/src/UiEditableCombobox.cc index 5958d37..778d59b 100644 --- a/src/UiEditableCombobox.cc +++ b/src/UiEditableCombobox.cc @@ -1,7 +1,7 @@ #include #include "../ui.h" -#include "ui-node.h" #include "nbind/api.h" +#include "includes/control.h" class UiEditableCombobox : public UiControl { DEFINE_EVENT(onChanged) diff --git a/src/UiEntry.cc b/src/UiEntry.cc index c8146f0..13ec422 100644 --- a/src/UiEntry.cc +++ b/src/UiEntry.cc @@ -1,7 +1,7 @@ #include #include "../ui.h" -#include "ui-node.h" #include "nbind/api.h" +#include "includes/control.h" #include "includes/entry.h" class UiEntryBase : public UiControl { diff --git a/src/UiFontButton.cc b/src/UiFontButton.cc index 145728d..db92c1b 100644 --- a/src/UiFontButton.cc +++ b/src/UiFontButton.cc @@ -1,6 +1,8 @@ #include "../ui.h" -#include "ui-node.h" #include "nbind/api.h" +#include "includes/area.h" +#include "includes/control.h" +#include "includes/values.h" class UiFontButton : public UiControl { DEFINE_EVENT(onChanged) diff --git a/src/UiForm.cc b/src/UiForm.cc index a7debd5..dbbaa10 100644 --- a/src/UiForm.cc +++ b/src/UiForm.cc @@ -1,7 +1,8 @@ #include #include "../ui.h" -#include "ui-node.h" + #include "nbind/api.h" +#include "includes/control.h" class UiForm : public UiControl { public: diff --git a/src/UiGrid.cc b/src/UiGrid.cc index 03d62c9..33349a0 100644 --- a/src/UiGrid.cc +++ b/src/UiGrid.cc @@ -1,6 +1,6 @@ #include "../ui.h" -#include "ui-node.h" #include "nbind/api.h" +#include "includes/control.h" // TODO - document class UiGrid : public UiControl { diff --git a/src/UiGroup.cc b/src/UiGroup.cc index 1e4e785..f235692 100644 --- a/src/UiGroup.cc +++ b/src/UiGroup.cc @@ -1,7 +1,7 @@ #include #include "../ui.h" -#include "ui-node.h" #include "nbind/api.h" +#include "includes/control.h" class UiGroup : public UiControl { public: diff --git a/src/UiLabel.cc b/src/UiLabel.cc index a576aab..d823e35 100644 --- a/src/UiLabel.cc +++ b/src/UiLabel.cc @@ -1,7 +1,7 @@ #include #include "../ui.h" -#include "ui-node.h" #include "nbind/api.h" +#include "includes/control.h" class UiLabel : public UiControl { public: diff --git a/src/UiMenu.cc b/src/UiMenu.cc index 14184f6..6d6198a 100644 --- a/src/UiMenu.cc +++ b/src/UiMenu.cc @@ -1,7 +1,7 @@ #include #include "../ui.h" -#include "ui-node.h" #include "nbind/api.h" +#include "includes/control.h" // TODO - document class UiMenuItem { diff --git a/src/UiMultilineEntry.cc b/src/UiMultilineEntry.cc index e398423..2b2340b 100644 --- a/src/UiMultilineEntry.cc +++ b/src/UiMultilineEntry.cc @@ -1,7 +1,7 @@ #include #include "../ui.h" -#include "ui-node.h" #include "nbind/api.h" +#include "includes/control.h" class UiMultilineEntry : public UiControl { DEFINE_EVENT(onChanged) diff --git a/src/UiProgressBar.cc b/src/UiProgressBar.cc index 58656a8..da121c8 100644 --- a/src/UiProgressBar.cc +++ b/src/UiProgressBar.cc @@ -1,6 +1,6 @@ #include "../ui.h" -#include "ui-node.h" #include "nbind/api.h" +#include "includes/control.h" class UiProgressBar : public UiControl { private: diff --git a/src/UiRadioButtons.cc b/src/UiRadioButtons.cc index f22d6bd..d3fbf72 100644 --- a/src/UiRadioButtons.cc +++ b/src/UiRadioButtons.cc @@ -1,7 +1,7 @@ #include #include "../ui.h" -#include "ui-node.h" #include "nbind/api.h" +#include "includes/control.h" class UiRadioButtons : public UiControl { DEFINE_EVENT(onSelected) diff --git a/src/UiSeparator.cc b/src/UiSeparator.cc index c903102..57f8661 100644 --- a/src/UiSeparator.cc +++ b/src/UiSeparator.cc @@ -1,6 +1,7 @@ #include "../ui.h" -#include "ui-node.h" #include "nbind/api.h" +#include "includes/control.h" + class UiHorizontalSeparator : public UiControl { public: UiHorizontalSeparator(); diff --git a/src/UiSlider.cc b/src/UiSlider.cc index 06fda50..4656284 100644 --- a/src/UiSlider.cc +++ b/src/UiSlider.cc @@ -1,6 +1,6 @@ #include "../ui.h" -#include "ui-node.h" #include "nbind/api.h" +#include "includes/control.h" class UiSlider : public UiControl { DEFINE_EVENT(onChanged) diff --git a/src/UiSpinbox.cc b/src/UiSpinbox.cc index 58f172d..325a216 100644 --- a/src/UiSpinbox.cc +++ b/src/UiSpinbox.cc @@ -1,6 +1,6 @@ #include "../ui.h" -#include "ui-node.h" #include "nbind/api.h" +#include "includes/control.h" class UiSpinbox : public UiControl { DEFINE_EVENT(onChanged) diff --git a/src/UiTab.cc b/src/UiTab.cc index 515a2da..77e74db 100644 --- a/src/UiTab.cc +++ b/src/UiTab.cc @@ -1,7 +1,7 @@ #include #include "../ui.h" -#include "ui-node.h" #include "nbind/api.h" +#include "includes/control.h" class UiTab : public UiControl { public: diff --git a/src/UiWindow.cc b/src/UiWindow.cc index a7340fe..7065513 100644 --- a/src/UiWindow.cc +++ b/src/UiWindow.cc @@ -1,7 +1,8 @@ #include #include "../ui.h" -#include "ui-node.h" #include "nbind/api.h" +#include "includes/control.h" +#include "includes/values.h" class UiWindow { DEFINE_EVENT(onClosing) diff --git a/src/ui-node.h b/src/ui-node.h deleted file mode 100644 index f15b1c5..0000000 --- a/src/ui-node.h +++ /dev/null @@ -1,477 +0,0 @@ -#ifndef ui_node -#define ui_node - -#include -/* - TODO: this has to be removed once UiArea classes - declarations are moved to their own cc files - */ -#include -#include "nbind/api.h" - -#define DEFINE_EVENT(NAME) \ - private: \ - nbind::cbFunction *NAME##Callback = NULL; \ - \ - public: \ - void NAME(nbind::cbFunction &cb); - -#define IMPLEMENT_EVENT(CLASS, WIDGET, NAME, LIBUI_FUN) \ - static void CLASS##_##NAME(WIDGET *w, void *data) { \ - nbind::cbFunction *cb = (nbind::cbFunction *)data; \ - (*cb)(); \ - } \ - void CLASS::NAME(nbind::cbFunction &cb) { \ - NAME##Callback = new nbind::cbFunction(cb); \ - LIBUI_FUN((WIDGET *)getHandle(), CLASS##_##NAME, NAME##Callback); \ - } - -#define DEFINE_CONTROL_METHODS() \ - void destroy(); \ - void setParent(UiControl *parent); \ - bool toplevel(); \ - bool getVisible(); \ - void setVisible(bool visible); \ - bool getEnabled(); \ - void setEnabled(bool enabled); - -#define INHERITS_CONTROL_METHODS(CLASS) \ - void CLASS::destroy() { \ - UiControl::destroy(); \ - } \ - void CLASS::setParent(UiControl *parent) { \ - UiControl::setParent(parent); \ - } \ - bool CLASS::toplevel() { \ - return UiControl::toplevel(); \ - } \ - bool CLASS::getVisible() { \ - return UiControl::getVisible(); \ - } \ - void CLASS::setVisible(bool visible) { \ - UiControl::setVisible(visible); \ - } \ - bool CLASS::getEnabled() { \ - return UiControl::getEnabled(); \ - } \ - void CLASS::setEnabled(bool enabled) { \ - UiControl::setEnabled(enabled); \ - } - -#define DECLARE_CHILD_CONTROL_METHODS() \ - inherit(UiControl); \ - method(destroy); \ - method(setParent); \ - method(toplevel); \ - method(getVisible); \ - method(setVisible); \ - method(getEnabled); \ - method(setEnabled); \ - getset(getVisible, setVisible); \ - getset(getEnabled, setEnabled); - -#define DECLARE_CONTROL_METHODS() \ - method(destroy); \ - method(setParent); \ - method(toplevel); \ - method(getVisible); \ - method(setVisible); \ - method(getEnabled); \ - method(setEnabled); \ - getset(getVisible, setVisible); \ - getset(getEnabled, setEnabled); - -#define DEFINE_BOX_METHODS() \ - void append(UiControl *control, bool stretchy); \ - void deleteAt(int index); \ - bool getPadded(); \ - void setPadded(bool padded); - -#define INHERITS_BOX_METHODS(CLASS) \ - void CLASS::append(UiControl *control, bool stretchy) { \ - UiBox::append(control, stretchy); \ - } \ - void CLASS::deleteAt(int index) { \ - UiBox::deleteAt(index); \ - } \ - bool CLASS::getPadded() { \ - return UiBox::getPadded(); \ - } \ - void CLASS::setPadded(bool padded) { \ - UiBox::setPadded(padded); \ - } - -#define DECLARE_BOX_METHODS() \ - getset(getPadded, setPadded); \ - method(getPadded); \ - method(setPadded); \ - method(append); \ - method(deleteAt); - -class UiControl { - private: - uiControl *handle; - - public: - uiControl *getHandle(); - UiControl(uiControl *hnd); - DEFINE_CONTROL_METHODS() -}; - -class Point { - private: - int x; - int y; - - public: - Point(const Point &other); - Point(int x, int y); - int getX(); - void setX(int value); - int getY(); - void setY(int value); - void toJS(nbind::cbOutput output); -}; - -class Size { - private: - int w; - int h; - - public: - Size(int w, int h); - int getWidth(); - void setWidth(int value); - int getHeight(); - void setHeight(int value); - void toJS(nbind::cbOutput output); -}; - -class PointDouble { - private: - double x; - double y; - - public: - PointDouble(double x, double y); - PointDouble(const PointDouble &other); - double getX(); - void setX(double value); - double getY(); - void setY(double value); - void toJS(nbind::cbOutput output); -}; - -class SizeDouble { - private: - double w; - double h; - - public: - SizeDouble(double w, double h); - double getWidth(); - void setWidth(double value); - double getHeight(); - void setHeight(double value); - void toJS(nbind::cbOutput output); -}; - -class Color { - private: - double r; - double g; - double b; - double a; - - public: - Color(const Color &other); - Color(double r, double g, double b, double a); - double getR(); - void setR(double value); - double getG(); - void setG(double value); - double getB(); - void setB(double value); - double getA(); - void setA(double value); - void toJS(nbind::cbOutput output); -}; - -// UIArea - -class DrawStrokeParams { - private: - uiDrawStrokeParams *sp; - - public: - DrawStrokeParams(); - int getCap(); - int getJoin(); - double getThickness(); - double getMiterLimit(); - std::vector getDashes(); - int getNumDashes(); - double getDashPhase(); - void setCap(int value); - void setJoin(int value); - void setThickness(double value); - void setMiterLimit(double value); - void setDashes(std::vector value); - void setNumDashes(int value); - void setDashPhase(double value); - uiDrawStrokeParams *toStruct(); - // void toJS(nbind::cbOutput output); -}; -class UiDrawMatrix { - private: - uiDrawMatrix *m; - - public: - UiDrawMatrix(); - uiDrawMatrix *getStruct(); - double getM11(); - double getM12(); - double getM21(); - double getM22(); - double getM31(); - double getM32(); - void setM11(double value); - void setM12(double value); - void setM21(double value); - void setM22(double value); - void setM31(double value); - void setM32(double value); - void setIdentity(); - void translate(double x, double y); - void scale(double xCenter, double yCenter, double x, double y); - void rotate(double x, double y, double amount); - void skew(double x, double y, double xamount, double yamount); - void multiply(UiDrawMatrix *src); - int invertible(); - int invert(); - PointDouble transformPoint(); - SizeDouble transformSize(); -}; - -class BrushGradientStop { - private: - double p; - Color c; - - public: - BrushGradientStop(double pos, Color color); - Color getColor(); - void setColor(Color value); - double getPos(); - void setPos(double value); - void toJS(nbind::cbOutput output); -}; - -class DrawBrush { - private: - uiDrawBrush *b; - - public: - DrawBrush(); - Color getColor(); - void setColor(Color value); - Point getStart(); - void setStart(Point value); - Point getEnd(); - void setEnd(Point value); - int getType(); - void setType(int value); - std::vector getStops(); - void setStops(std::vector value); - uiDrawBrush *toStruct(); -}; - -class UiAreaMouseEvent { - private: - uiAreaMouseEvent *e; - - public: - UiAreaMouseEvent(uiAreaMouseEvent *event); - double getX(); - double getY(); - double getAreaWidth(); - double getAreaHeight(); - int getDown(); - int getUp(); - int getCount(); - int getModifiers(); - unsigned int getHeld1To64(); -}; - -class UiAreaKeyEvent { - private: - uiAreaKeyEvent *e; - - public: - UiAreaKeyEvent(uiAreaKeyEvent *event); - char *getKey(); - int getExtKey(); - int getModifier(); - int getModifiers(); - int getUp(); -}; - -class UiDrawPath { - private: - uiDrawPath *handle; - - public: - uiDrawPath *getHandle(); - UiDrawPath(int fillMode); - void freePath(); - void newFigure(double x, double y); - void newFigureWithArc(double xCenter, double yCenter, double radius, - double startAngle, double sweep, int negative); - void lineTo(double x, double y); - void arcTo(double xCenter, double yCenter, double radius, double startAngle, - double sweep, int negative); - void bezierTo(double c1x, double c1y, double c2x, double c2y, double endX, - double endY); - void closeFigure(); - void addRectangle(double x, double y, double width, double height); - void end(); -}; - -class DrawTextFontMetrics { - private: - uiDrawTextFontMetrics *m; - - public: - DrawTextFontMetrics(uiDrawTextFontMetrics *metrics); - double getAscent(); - double getDescent(); - double getLeading(); - double getUnderlinePos(); - double getUnderlineThickness(); -}; - -class DrawTextFontDescriptor { - private: - uiDrawTextFontDescriptor *d; - - public: - DrawTextFontDescriptor(uiDrawTextFontDescriptor *descr); - const char *getFamily(); - double getSize(); - int getWeight(); - int getItalic(); - int getStretch(); -}; - -class DrawTextFont { - private: - uiDrawTextFont *handle; - - public: - DrawTextFont(); - DrawTextFont(uiDrawTextFont *h); - - uiDrawTextFont *getHandle(); - void free(); - DrawTextFontDescriptor *describe(); - DrawTextFontMetrics *getMetrics(); - - static std::vector listFontFamilies(); - void loadClosestFont(const char *family, double size, int weight, - int italic, int stretch); -}; - -class DrawTextLayout { - private: - uiDrawTextLayout *handle; - double w; - - public: - DrawTextLayout(const char *text, DrawTextFont *defaultFont, double width); - void free(); - void setWidth(double value); - double getWidth(); - SizeDouble getExtents(); - uiDrawTextLayout *getHandle(); - void setColor(int startChar, int endChar, Color color); -}; - -class UiDrawContext { - private: - uiDrawContext *c; - - public: - UiDrawContext(uiDrawContext *ctx); - void stroke(UiDrawPath *path, DrawBrush *b, DrawStrokeParams *p); - void fill(UiDrawPath *path, DrawBrush *b); - void transform(UiDrawMatrix *m); - void clip(UiDrawPath *path); - void save(); - void restore(); - void text(double x, double y, DrawTextLayout *layout); -}; - -class UiAreaDrawParams { - private: - uiAreaDrawParams *p; - - public: - UiAreaDrawParams(uiAreaDrawParams *params); - UiDrawContext *getContext(); - double getAreaWidth(); - double getAreaHeight(); - double getClipX(); - double getClipY(); - double getClipWidth(); - double getClipHeight(); -}; - -// TODO - document -class UiArea : public UiControl { - public: - // Workaround for nbind bug solved in 0.3 - UiArea(int dummy); - - UiArea(nbind::cbFunction &drawCb, nbind::cbFunction &mouseEventCb, - nbind::cbFunction &mouseCrossedCb, nbind::cbFunction &dragBrokenCb, - nbind::cbFunction &keyEventCb); - UiArea(nbind::cbFunction &drawCb, nbind::cbFunction &mouseEventCb, - nbind::cbFunction &mouseCrossedCb, nbind::cbFunction &dragBrokenCb, - nbind::cbFunction &keyEventCb, int width, int height); - void setSize(int width, int height); - void queueRedrawAll(); - void scrollTo(double x, double y, double width, double height); - DEFINE_CONTROL_METHODS() -}; - -extern std::map areasMap; - -typedef struct UiAreaHandler { - void (*Draw)(UiAreaHandler *self, uiArea *area, uiAreaDrawParams *params); - void (*MouseEvent)(UiAreaHandler *self, uiArea *area, - uiAreaMouseEvent *event); - void (*MouseCrossed)(UiAreaHandler *self, uiArea *area, int left); - void (*DragBroken)(UiAreaHandler *self, uiArea *area); - int (*KeyEvent)(UiAreaHandler *self, uiArea *area, uiAreaKeyEvent *event); - - nbind::cbFunction *draw; - nbind::cbFunction *mouseEvent; - nbind::cbFunction *mouseCrossed; - nbind::cbFunction *dragBroken; - nbind::cbFunction *keyEvent; -} UiAreaHandler; - -struct UiAreaHandlerFactory { - static UiAreaHandler *build(nbind::cbFunction &draw, - nbind::cbFunction &mouseEvent, - nbind::cbFunction &mouseCrossed, - nbind::cbFunction &dragBroken, - nbind::cbFunction &keyEvent); -}; - -// This is included at end of file -// to minimize conflicts with existing -// symbols from other headers. -#include "nbind/nbind.h" - -#endif From ea9fbed5e0284360bad55d70ca6e64b2e4304a64 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 7 Apr 2018 09:59:56 +0200 Subject: [PATCH 067/190] Remove paths from #include-s --- binding.gyp | 1 + src/Color.cc | 2 +- src/EventLoop.cc | 2 +- src/Point.cc | 2 +- src/PointDouble.cc | 2 +- src/Size.cc | 2 +- src/SizeDouble.cc | 2 +- src/Ui.cc | 2 +- src/UiArea/BrushGradientStop.cc | 4 ++-- src/UiArea/DrawBrush.cc | 4 ++-- src/UiArea/DrawMatrix.cc | 4 ++-- src/UiArea/DrawStrokeParams.cc | 4 ++-- src/UiArea/DrawTextFont.cc | 4 ++-- src/UiArea/DrawTextFontDescriptor.cc | 4 ++-- src/UiArea/DrawTextFontMetrics.cc | 4 ++-- src/UiArea/DrawTextLayout.cc | 4 ++-- src/UiArea/UiArea.cc | 6 +++--- src/UiArea/UiAreaDrawParams.cc | 4 ++-- src/UiArea/UiAreaHandler.cc | 4 ++-- src/UiArea/UiAreaKeyEvent.cc | 4 ++-- src/UiArea/UiAreaMouseEvent.cc | 4 ++-- src/UiArea/UiDrawContext.cc | 4 ++-- src/UiArea/UiDrawPath.cc | 4 ++-- src/UiBox.cc | 6 +++--- src/UiButton.cc | 4 ++-- src/UiCheckbox.cc | 4 ++-- src/UiColorButton.cc | 6 +++--- src/UiCombobox.cc | 4 ++-- src/UiControl.cc | 4 ++-- src/UiDateTimePicker.cc | 4 ++-- src/UiEditableCombobox.cc | 4 ++-- src/UiEntry.cc | 6 +++--- src/UiFontButton.cc | 8 ++++---- src/UiForm.cc | 4 ++-- src/UiGrid.cc | 4 ++-- src/UiGroup.cc | 4 ++-- src/UiLabel.cc | 4 ++-- src/UiMenu.cc | 4 ++-- src/UiMultilineEntry.cc | 4 ++-- src/UiProgressBar.cc | 4 ++-- src/UiRadioButtons.cc | 4 ++-- src/UiSeparator.cc | 4 ++-- src/UiSlider.cc | 4 ++-- src/UiSpinbox.cc | 4 ++-- src/UiTab.cc | 4 ++-- src/UiWindow.cc | 6 +++--- src/arch/win32/libui_loop.cc | 2 +- 47 files changed, 92 insertions(+), 91 deletions(-) diff --git a/binding.gyp b/binding.gyp index fdc5556..c2db57d 100644 --- a/binding.gyp +++ b/binding.gyp @@ -2,6 +2,7 @@ "targets": [ { "target_name": "nbind", + 'include_dirs': ["<(module_root_dir)/src/includes", "<(module_root_dir)"], "includes": [ "auto.gypi" ], diff --git a/src/Color.cc b/src/Color.cc index 1282e4b..e6ba6cc 100644 --- a/src/Color.cc +++ b/src/Color.cc @@ -1,4 +1,4 @@ -#include "includes/values.h" +#include "values.h" Color::Color(const Color &other) { r = other.r; diff --git a/src/EventLoop.cc b/src/EventLoop.cc index 7307ba8..ded34e0 100644 --- a/src/EventLoop.cc +++ b/src/EventLoop.cc @@ -1,7 +1,7 @@ #include #include -#include "../ui.h" #include "nbind/nbind.h" +#include "ui.h" extern int uiEventsPending(); extern int uiLoopWakeup(); diff --git a/src/Point.cc b/src/Point.cc index bc06902..79cb403 100644 --- a/src/Point.cc +++ b/src/Point.cc @@ -1,4 +1,4 @@ -#include "includes/values.h" +#include "values.h" Point::Point(const Point &other) { x = other.x; diff --git a/src/PointDouble.cc b/src/PointDouble.cc index 156e3ec..0ababa9 100644 --- a/src/PointDouble.cc +++ b/src/PointDouble.cc @@ -1,4 +1,4 @@ -#include "includes/values.h" +#include "values.h" PointDouble::PointDouble(const PointDouble &other) { x = other.x; diff --git a/src/Size.cc b/src/Size.cc index 974ba91..9a5d44a 100644 --- a/src/Size.cc +++ b/src/Size.cc @@ -1,4 +1,4 @@ -#include "includes/values.h" +#include "values.h" Size::Size(int width, int height) { w = width; diff --git a/src/SizeDouble.cc b/src/SizeDouble.cc index dde29c8..390061e 100644 --- a/src/SizeDouble.cc +++ b/src/SizeDouble.cc @@ -1,4 +1,4 @@ -#include "includes/values.h" +#include "values.h" SizeDouble::SizeDouble(double width, double height) { w = width; diff --git a/src/Ui.cc b/src/Ui.cc index 0a9bd4c..5342ead 100644 --- a/src/Ui.cc +++ b/src/Ui.cc @@ -1,4 +1,4 @@ -#include "../ui.h" +#include "ui.h" #include "nbind/api.h" #include "nbind/nbind.h" diff --git a/src/UiArea/BrushGradientStop.cc b/src/UiArea/BrushGradientStop.cc index 8b0df83..3e9a044 100644 --- a/src/UiArea/BrushGradientStop.cc +++ b/src/UiArea/BrushGradientStop.cc @@ -1,5 +1,5 @@ -#include "../../ui.h" -#include "../includes/area.h" +#include "area.h" +#include "ui.h" BrushGradientStop::BrushGradientStop(double pos, Color color) : c(color) { p = pos; diff --git a/src/UiArea/DrawBrush.cc b/src/UiArea/DrawBrush.cc index 6b23685..b2f904a 100644 --- a/src/UiArea/DrawBrush.cc +++ b/src/UiArea/DrawBrush.cc @@ -1,6 +1,6 @@ #include -#include "../../ui.h" -#include "../includes/area.h" +#include "area.h" +#include "ui.h" DrawBrush::DrawBrush() { b = new uiDrawBrush(); diff --git a/src/UiArea/DrawMatrix.cc b/src/UiArea/DrawMatrix.cc index 2abd419..c6f14c6 100644 --- a/src/UiArea/DrawMatrix.cc +++ b/src/UiArea/DrawMatrix.cc @@ -1,5 +1,5 @@ -#include "../../ui.h" -#include "../includes/area.h" +#include "area.h" +#include "ui.h" UiDrawMatrix::UiDrawMatrix() { m = new uiDrawMatrix(); diff --git a/src/UiArea/DrawStrokeParams.cc b/src/UiArea/DrawStrokeParams.cc index bd5a1ae..eac9184 100644 --- a/src/UiArea/DrawStrokeParams.cc +++ b/src/UiArea/DrawStrokeParams.cc @@ -1,6 +1,6 @@ #include -#include "../../ui.h" -#include "../includes/area.h" +#include "area.h" +#include "ui.h" DrawStrokeParams::DrawStrokeParams() { sp = new uiDrawStrokeParams(); diff --git a/src/UiArea/DrawTextFont.cc b/src/UiArea/DrawTextFont.cc index 173d050..9e2ab67 100644 --- a/src/UiArea/DrawTextFont.cc +++ b/src/UiArea/DrawTextFont.cc @@ -1,6 +1,6 @@ #include -#include "../../ui.h" -#include "../includes/area.h" +#include "area.h" +#include "ui.h" DrawTextFont::DrawTextFont() {} DrawTextFont::DrawTextFont(uiDrawTextFont *h) { diff --git a/src/UiArea/DrawTextFontDescriptor.cc b/src/UiArea/DrawTextFontDescriptor.cc index 07e65c7..30b6a51 100644 --- a/src/UiArea/DrawTextFontDescriptor.cc +++ b/src/UiArea/DrawTextFontDescriptor.cc @@ -1,5 +1,5 @@ -#include "../../ui.h" -#include "../includes/area.h" +#include "area.h" +#include "ui.h" const char *DrawTextFontDescriptor::getFamily() { return d->Family; diff --git a/src/UiArea/DrawTextFontMetrics.cc b/src/UiArea/DrawTextFontMetrics.cc index ad98ba0..676a36b 100644 --- a/src/UiArea/DrawTextFontMetrics.cc +++ b/src/UiArea/DrawTextFontMetrics.cc @@ -1,5 +1,5 @@ -#include "../../ui.h" -#include "../includes/area.h" +#include "area.h" +#include "ui.h" DrawTextFontMetrics::DrawTextFontMetrics(uiDrawTextFontMetrics *metrics) { m = metrics; diff --git a/src/UiArea/DrawTextLayout.cc b/src/UiArea/DrawTextLayout.cc index 529b8f3..a31cfff 100644 --- a/src/UiArea/DrawTextLayout.cc +++ b/src/UiArea/DrawTextLayout.cc @@ -1,5 +1,5 @@ -#include "../../ui.h" -#include "../includes/area.h" +#include "area.h" +#include "ui.h" DrawTextLayout::DrawTextLayout(const char *text, DrawTextFont *defaultFont, double width) { diff --git a/src/UiArea/UiArea.cc b/src/UiArea/UiArea.cc index 15b8f8c..2c80be8 100644 --- a/src/UiArea/UiArea.cc +++ b/src/UiArea/UiArea.cc @@ -1,6 +1,6 @@ -#include "../../ui.h" -#include "../includes/area.h" -#include "../includes/control.h" +#include "area.h" +#include "control.h" +#include "ui.h" std::map areasMap; diff --git a/src/UiArea/UiAreaDrawParams.cc b/src/UiArea/UiAreaDrawParams.cc index c2684c1..490d535 100644 --- a/src/UiArea/UiAreaDrawParams.cc +++ b/src/UiArea/UiAreaDrawParams.cc @@ -1,5 +1,5 @@ -#include "../../ui.h" -#include "../includes/area.h" +#include "area.h" +#include "ui.h" UiAreaDrawParams::UiAreaDrawParams(uiAreaDrawParams *params) { p = params; diff --git a/src/UiArea/UiAreaHandler.cc b/src/UiArea/UiAreaHandler.cc index 777320c..332b287 100644 --- a/src/UiArea/UiAreaHandler.cc +++ b/src/UiArea/UiAreaHandler.cc @@ -1,5 +1,5 @@ -#include "../../ui.h" -#include "../includes/area.h" +#include "area.h" +#include "ui.h" void Draw(UiAreaHandler *self, uiArea *area, uiAreaDrawParams *params) { UiAreaDrawParams *pp = new UiAreaDrawParams(params); diff --git a/src/UiArea/UiAreaKeyEvent.cc b/src/UiArea/UiAreaKeyEvent.cc index 76292a2..688658a 100644 --- a/src/UiArea/UiAreaKeyEvent.cc +++ b/src/UiArea/UiAreaKeyEvent.cc @@ -1,6 +1,6 @@ -#include "../../ui.h" -#include "../includes/area.h" +#include "area.h" +#include "ui.h" UiAreaKeyEvent::UiAreaKeyEvent(uiAreaKeyEvent *event) { e = event; diff --git a/src/UiArea/UiAreaMouseEvent.cc b/src/UiArea/UiAreaMouseEvent.cc index 4e5fb2d..7985c5c 100644 --- a/src/UiArea/UiAreaMouseEvent.cc +++ b/src/UiArea/UiAreaMouseEvent.cc @@ -1,5 +1,5 @@ -#include "../../ui.h" -#include "../includes/area.h" +#include "area.h" +#include "ui.h" UiAreaMouseEvent::UiAreaMouseEvent(uiAreaMouseEvent *event) { e = event; diff --git a/src/UiArea/UiDrawContext.cc b/src/UiArea/UiDrawContext.cc index 1e6c32f..778c5f9 100644 --- a/src/UiArea/UiDrawContext.cc +++ b/src/UiArea/UiDrawContext.cc @@ -1,5 +1,5 @@ -#include "../../ui.h" -#include "../includes/area.h" +#include "area.h" +#include "ui.h" UiDrawContext::UiDrawContext(uiDrawContext *ctx) { c = ctx; diff --git a/src/UiArea/UiDrawPath.cc b/src/UiArea/UiDrawPath.cc index fb4199f..41ed5bf 100644 --- a/src/UiArea/UiDrawPath.cc +++ b/src/UiArea/UiDrawPath.cc @@ -1,5 +1,5 @@ -#include "../../ui.h" -#include "../includes/area.h" +#include "area.h" +#include "ui.h" UiDrawPath::UiDrawPath(int fillMode) { handle = uiDrawNewPath(fillMode); diff --git a/src/UiBox.cc b/src/UiBox.cc index 9aae59f..15a68d1 100644 --- a/src/UiBox.cc +++ b/src/UiBox.cc @@ -1,7 +1,7 @@ -#include "../ui.h" #include "nbind/api.h" -#include "includes/box.h" -#include "includes/control.h" +#include "box.h" +#include "control.h" +#include "ui.h" class UiBox : public UiControl { public: diff --git a/src/UiButton.cc b/src/UiButton.cc index 6599433..c0803de 100644 --- a/src/UiButton.cc +++ b/src/UiButton.cc @@ -1,7 +1,7 @@ #include -#include "../ui.h" #include "nbind/api.h" -#include "includes/control.h" +#include "control.h" +#include "ui.h" class UiButton : public UiControl { DEFINE_EVENT(onClicked) diff --git a/src/UiCheckbox.cc b/src/UiCheckbox.cc index 00e8e48..1157a12 100644 --- a/src/UiCheckbox.cc +++ b/src/UiCheckbox.cc @@ -1,7 +1,7 @@ #include -#include "../ui.h" #include "nbind/api.h" -#include "includes/control.h" +#include "control.h" +#include "ui.h" class UiCheckbox : public UiControl { DEFINE_EVENT(onToggled) diff --git a/src/UiColorButton.cc b/src/UiColorButton.cc index 8341e66..3d110e2 100644 --- a/src/UiColorButton.cc +++ b/src/UiColorButton.cc @@ -1,7 +1,7 @@ -#include "../ui.h" #include "nbind/api.h" -#include "includes/control.h" -#include "includes/values.h" +#include "control.h" +#include "ui.h" +#include "values.h" class UiColorButton : public UiControl { DEFINE_EVENT(onChanged) diff --git a/src/UiCombobox.cc b/src/UiCombobox.cc index 90146c5..d51fcab 100644 --- a/src/UiCombobox.cc +++ b/src/UiCombobox.cc @@ -1,7 +1,7 @@ #include -#include "../ui.h" #include "nbind/api.h" -#include "includes/control.h" +#include "control.h" +#include "ui.h" class UiCombobox : public UiControl { DEFINE_EVENT(onSelected) diff --git a/src/UiControl.cc b/src/UiControl.cc index 7326a1f..c3d99b9 100644 --- a/src/UiControl.cc +++ b/src/UiControl.cc @@ -1,6 +1,6 @@ -#include "../ui.h" #include "nbind/api.h" -#include "includes/control.h" +#include "control.h" +#include "ui.h" uiControl *UiControl::getHandle() { return handle; diff --git a/src/UiDateTimePicker.cc b/src/UiDateTimePicker.cc index 94de1a6..586d85c 100644 --- a/src/UiDateTimePicker.cc +++ b/src/UiDateTimePicker.cc @@ -1,6 +1,6 @@ -#include "../ui.h" #include "nbind/api.h" -#include "includes/control.h" +#include "control.h" +#include "ui.h" class UiDateTimePicker : public UiControl { public: diff --git a/src/UiEditableCombobox.cc b/src/UiEditableCombobox.cc index 778d59b..12bf3b2 100644 --- a/src/UiEditableCombobox.cc +++ b/src/UiEditableCombobox.cc @@ -1,7 +1,7 @@ #include -#include "../ui.h" #include "nbind/api.h" -#include "includes/control.h" +#include "control.h" +#include "ui.h" class UiEditableCombobox : public UiControl { DEFINE_EVENT(onChanged) diff --git a/src/UiEntry.cc b/src/UiEntry.cc index 13ec422..fee88d7 100644 --- a/src/UiEntry.cc +++ b/src/UiEntry.cc @@ -1,8 +1,8 @@ #include -#include "../ui.h" #include "nbind/api.h" -#include "includes/control.h" -#include "includes/entry.h" +#include "control.h" +#include "entry.h" +#include "ui.h" class UiEntryBase : public UiControl { DEFINE_EVENT(onChanged) diff --git a/src/UiFontButton.cc b/src/UiFontButton.cc index db92c1b..6151f71 100644 --- a/src/UiFontButton.cc +++ b/src/UiFontButton.cc @@ -1,8 +1,8 @@ -#include "../ui.h" #include "nbind/api.h" -#include "includes/area.h" -#include "includes/control.h" -#include "includes/values.h" +#include "area.h" +#include "control.h" +#include "ui.h" +#include "values.h" class UiFontButton : public UiControl { DEFINE_EVENT(onChanged) diff --git a/src/UiForm.cc b/src/UiForm.cc index dbbaa10..0136b27 100644 --- a/src/UiForm.cc +++ b/src/UiForm.cc @@ -1,8 +1,8 @@ #include -#include "../ui.h" +#include "ui.h" #include "nbind/api.h" -#include "includes/control.h" +#include "control.h" class UiForm : public UiControl { public: diff --git a/src/UiGrid.cc b/src/UiGrid.cc index 33349a0..937e596 100644 --- a/src/UiGrid.cc +++ b/src/UiGrid.cc @@ -1,6 +1,6 @@ -#include "../ui.h" #include "nbind/api.h" -#include "includes/control.h" +#include "control.h" +#include "ui.h" // TODO - document class UiGrid : public UiControl { diff --git a/src/UiGroup.cc b/src/UiGroup.cc index f235692..3a57120 100644 --- a/src/UiGroup.cc +++ b/src/UiGroup.cc @@ -1,7 +1,7 @@ #include -#include "../ui.h" #include "nbind/api.h" -#include "includes/control.h" +#include "control.h" +#include "ui.h" class UiGroup : public UiControl { public: diff --git a/src/UiLabel.cc b/src/UiLabel.cc index d823e35..c6e506a 100644 --- a/src/UiLabel.cc +++ b/src/UiLabel.cc @@ -1,7 +1,7 @@ #include -#include "../ui.h" #include "nbind/api.h" -#include "includes/control.h" +#include "control.h" +#include "ui.h" class UiLabel : public UiControl { public: diff --git a/src/UiMenu.cc b/src/UiMenu.cc index 6d6198a..7b490cd 100644 --- a/src/UiMenu.cc +++ b/src/UiMenu.cc @@ -1,7 +1,7 @@ #include -#include "../ui.h" #include "nbind/api.h" -#include "includes/control.h" +#include "control.h" +#include "ui.h" // TODO - document class UiMenuItem { diff --git a/src/UiMultilineEntry.cc b/src/UiMultilineEntry.cc index 2b2340b..e6ddca1 100644 --- a/src/UiMultilineEntry.cc +++ b/src/UiMultilineEntry.cc @@ -1,7 +1,7 @@ #include -#include "../ui.h" #include "nbind/api.h" -#include "includes/control.h" +#include "control.h" +#include "ui.h" class UiMultilineEntry : public UiControl { DEFINE_EVENT(onChanged) diff --git a/src/UiProgressBar.cc b/src/UiProgressBar.cc index da121c8..33a452b 100644 --- a/src/UiProgressBar.cc +++ b/src/UiProgressBar.cc @@ -1,6 +1,6 @@ -#include "../ui.h" #include "nbind/api.h" -#include "includes/control.h" +#include "control.h" +#include "ui.h" class UiProgressBar : public UiControl { private: diff --git a/src/UiRadioButtons.cc b/src/UiRadioButtons.cc index d3fbf72..7a228d2 100644 --- a/src/UiRadioButtons.cc +++ b/src/UiRadioButtons.cc @@ -1,7 +1,7 @@ #include -#include "../ui.h" #include "nbind/api.h" -#include "includes/control.h" +#include "control.h" +#include "ui.h" class UiRadioButtons : public UiControl { DEFINE_EVENT(onSelected) diff --git a/src/UiSeparator.cc b/src/UiSeparator.cc index 57f8661..9395b4e 100644 --- a/src/UiSeparator.cc +++ b/src/UiSeparator.cc @@ -1,6 +1,6 @@ -#include "../ui.h" #include "nbind/api.h" -#include "includes/control.h" +#include "control.h" +#include "ui.h" class UiHorizontalSeparator : public UiControl { public: diff --git a/src/UiSlider.cc b/src/UiSlider.cc index 4656284..a92dc55 100644 --- a/src/UiSlider.cc +++ b/src/UiSlider.cc @@ -1,6 +1,6 @@ -#include "../ui.h" #include "nbind/api.h" -#include "includes/control.h" +#include "control.h" +#include "ui.h" class UiSlider : public UiControl { DEFINE_EVENT(onChanged) diff --git a/src/UiSpinbox.cc b/src/UiSpinbox.cc index 325a216..11e9571 100644 --- a/src/UiSpinbox.cc +++ b/src/UiSpinbox.cc @@ -1,6 +1,6 @@ -#include "../ui.h" #include "nbind/api.h" -#include "includes/control.h" +#include "control.h" +#include "ui.h" class UiSpinbox : public UiControl { DEFINE_EVENT(onChanged) diff --git a/src/UiTab.cc b/src/UiTab.cc index 77e74db..4730037 100644 --- a/src/UiTab.cc +++ b/src/UiTab.cc @@ -1,7 +1,7 @@ #include -#include "../ui.h" #include "nbind/api.h" -#include "includes/control.h" +#include "control.h" +#include "ui.h" class UiTab : public UiControl { public: diff --git a/src/UiWindow.cc b/src/UiWindow.cc index 7065513..5d032c8 100644 --- a/src/UiWindow.cc +++ b/src/UiWindow.cc @@ -1,8 +1,8 @@ #include -#include "../ui.h" #include "nbind/api.h" -#include "includes/control.h" -#include "includes/values.h" +#include "control.h" +#include "ui.h" +#include "values.h" class UiWindow { DEFINE_EVENT(onClosing) diff --git a/src/arch/win32/libui_loop.cc b/src/arch/win32/libui_loop.cc index a81eb48..81b4207 100644 --- a/src/arch/win32/libui_loop.cc +++ b/src/arch/win32/libui_loop.cc @@ -1,6 +1,6 @@ #include #include -#include "../../../ui.h" +#include "ui.h" typedef struct uv_loop_s { /* User data - use this for whatever. */ From 899f7baa41e379a88d79d5826feab678941cdb09 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sun, 8 Apr 2018 09:49:29 +0200 Subject: [PATCH 068/190] Ignore only libui headers, keep others --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 8529d07..1141b71 100644 --- a/.gitignore +++ b/.gitignore @@ -93,7 +93,8 @@ build auto*.gypi _libui -*.h +ui_*.h +ui.h *.dylib *.dll From bc8c77259d8bd60e6670fa1b2fb5abad0b38a74b Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sun, 8 Apr 2018 09:50:06 +0200 Subject: [PATCH 069/190] headers --- src/includes/area.h | 288 +++++++++++++++++++++++++++++++++++++++++ src/includes/box.h | 31 +++++ src/includes/control.h | 93 +++++++++++++ src/includes/entry.h | 36 ++++++ src/includes/values.h | 90 +++++++++++++ 5 files changed, 538 insertions(+) create mode 100644 src/includes/area.h create mode 100644 src/includes/box.h create mode 100644 src/includes/control.h create mode 100644 src/includes/entry.h create mode 100644 src/includes/values.h diff --git a/src/includes/area.h b/src/includes/area.h new file mode 100644 index 0000000..ee93e74 --- /dev/null +++ b/src/includes/area.h @@ -0,0 +1,288 @@ +#ifndef UI_NODE_AREA +#define UI_NODE_AREA 1 + +#include +#include +#include "nbind/api.h" +#include "control.h" +#include "ui.h" +#include "values.h" + +// UIArea + +// TODO - document +class UiArea : public UiControl { + public: + // Workaround for nbind bug solved in 0.3 + UiArea(int dummy); + + UiArea(nbind::cbFunction &drawCb, nbind::cbFunction &mouseEventCb, + nbind::cbFunction &mouseCrossedCb, nbind::cbFunction &dragBrokenCb, + nbind::cbFunction &keyEventCb); + UiArea(nbind::cbFunction &drawCb, nbind::cbFunction &mouseEventCb, + nbind::cbFunction &mouseCrossedCb, nbind::cbFunction &dragBrokenCb, + nbind::cbFunction &keyEventCb, int width, int height); + void setSize(int width, int height); + void queueRedrawAll(); + void scrollTo(double x, double y, double width, double height); + DEFINE_CONTROL_METHODS() +}; + +extern std::map areasMap; + +class DrawStrokeParams { + private: + uiDrawStrokeParams *sp; + + public: + DrawStrokeParams(); + int getCap(); + int getJoin(); + double getThickness(); + double getMiterLimit(); + std::vector getDashes(); + int getNumDashes(); + double getDashPhase(); + void setCap(int value); + void setJoin(int value); + void setThickness(double value); + void setMiterLimit(double value); + void setDashes(std::vector value); + void setNumDashes(int value); + void setDashPhase(double value); + uiDrawStrokeParams *toStruct(); + // void toJS(nbind::cbOutput output); +}; +class UiDrawMatrix { + private: + uiDrawMatrix *m; + + public: + UiDrawMatrix(); + uiDrawMatrix *getStruct(); + double getM11(); + double getM12(); + double getM21(); + double getM22(); + double getM31(); + double getM32(); + void setM11(double value); + void setM12(double value); + void setM21(double value); + void setM22(double value); + void setM31(double value); + void setM32(double value); + void setIdentity(); + void translate(double x, double y); + void scale(double xCenter, double yCenter, double x, double y); + void rotate(double x, double y, double amount); + void skew(double x, double y, double xamount, double yamount); + void multiply(UiDrawMatrix *src); + int invertible(); + int invert(); + PointDouble transformPoint(); + SizeDouble transformSize(); +}; + +class BrushGradientStop { + private: + double p; + Color c; + + public: + BrushGradientStop(double pos, Color color); + Color getColor(); + void setColor(Color value); + double getPos(); + void setPos(double value); + void toJS(nbind::cbOutput output); +}; + +class DrawBrush { + private: + uiDrawBrush *b; + + public: + DrawBrush(); + Color getColor(); + void setColor(Color value); + Point getStart(); + void setStart(Point value); + Point getEnd(); + void setEnd(Point value); + int getType(); + void setType(int value); + std::vector getStops(); + void setStops(std::vector value); + uiDrawBrush *toStruct(); +}; + +class UiAreaMouseEvent { + private: + uiAreaMouseEvent *e; + + public: + UiAreaMouseEvent(uiAreaMouseEvent *event); + double getX(); + double getY(); + double getAreaWidth(); + double getAreaHeight(); + int getDown(); + int getUp(); + int getCount(); + int getModifiers(); + unsigned int getHeld1To64(); +}; + +class UiAreaKeyEvent { + private: + uiAreaKeyEvent *e; + + public: + UiAreaKeyEvent(uiAreaKeyEvent *event); + char *getKey(); + int getExtKey(); + int getModifier(); + int getModifiers(); + int getUp(); +}; + +class UiDrawPath { + private: + uiDrawPath *handle; + + public: + uiDrawPath *getHandle(); + UiDrawPath(int fillMode); + void freePath(); + void newFigure(double x, double y); + void newFigureWithArc(double xCenter, double yCenter, double radius, + double startAngle, double sweep, int negative); + void lineTo(double x, double y); + void arcTo(double xCenter, double yCenter, double radius, double startAngle, + double sweep, int negative); + void bezierTo(double c1x, double c1y, double c2x, double c2y, double endX, + double endY); + void closeFigure(); + void addRectangle(double x, double y, double width, double height); + void end(); +}; + +class DrawTextFontMetrics { + private: + uiDrawTextFontMetrics *m; + + public: + DrawTextFontMetrics(uiDrawTextFontMetrics *metrics); + double getAscent(); + double getDescent(); + double getLeading(); + double getUnderlinePos(); + double getUnderlineThickness(); +}; + +class DrawTextFontDescriptor { + private: + uiDrawTextFontDescriptor *d; + + public: + DrawTextFontDescriptor(uiDrawTextFontDescriptor *descr); + const char *getFamily(); + double getSize(); + int getWeight(); + int getItalic(); + int getStretch(); +}; + +class DrawTextFont { + private: + uiDrawTextFont *handle; + + public: + DrawTextFont(); + DrawTextFont(uiDrawTextFont *h); + + uiDrawTextFont *getHandle(); + void free(); + DrawTextFontDescriptor *describe(); + DrawTextFontMetrics *getMetrics(); + + static std::vector listFontFamilies(); + void loadClosestFont(const char *family, double size, int weight, + int italic, int stretch); +}; + +class DrawTextLayout { + private: + uiDrawTextLayout *handle; + double w; + + public: + DrawTextLayout(const char *text, DrawTextFont *defaultFont, double width); + void free(); + void setWidth(double value); + double getWidth(); + SizeDouble getExtents(); + uiDrawTextLayout *getHandle(); + void setColor(int startChar, int endChar, Color color); +}; + +class UiDrawContext { + private: + uiDrawContext *c; + + public: + UiDrawContext(uiDrawContext *ctx); + void stroke(UiDrawPath *path, DrawBrush *b, DrawStrokeParams *p); + void fill(UiDrawPath *path, DrawBrush *b); + void transform(UiDrawMatrix *m); + void clip(UiDrawPath *path); + void save(); + void restore(); + void text(double x, double y, DrawTextLayout *layout); +}; + +class UiAreaDrawParams { + private: + uiAreaDrawParams *p; + + public: + UiAreaDrawParams(uiAreaDrawParams *params); + UiDrawContext *getContext(); + double getAreaWidth(); + double getAreaHeight(); + double getClipX(); + double getClipY(); + double getClipWidth(); + double getClipHeight(); +}; + +typedef struct UiAreaHandler { + void (*Draw)(UiAreaHandler *self, uiArea *area, uiAreaDrawParams *params); + void (*MouseEvent)(UiAreaHandler *self, uiArea *area, + uiAreaMouseEvent *event); + void (*MouseCrossed)(UiAreaHandler *self, uiArea *area, int left); + void (*DragBroken)(UiAreaHandler *self, uiArea *area); + int (*KeyEvent)(UiAreaHandler *self, uiArea *area, uiAreaKeyEvent *event); + + nbind::cbFunction *draw; + nbind::cbFunction *mouseEvent; + nbind::cbFunction *mouseCrossed; + nbind::cbFunction *dragBroken; + nbind::cbFunction *keyEvent; +} UiAreaHandler; + +struct UiAreaHandlerFactory { + static UiAreaHandler *build(nbind::cbFunction &draw, + nbind::cbFunction &mouseEvent, + nbind::cbFunction &mouseCrossed, + nbind::cbFunction &dragBroken, + nbind::cbFunction &keyEvent); +}; + +// This is included at end of file +// to minimize conflicts with existing +// symbols from other headers. +#include "nbind/nbind.h" + +#endif diff --git a/src/includes/box.h b/src/includes/box.h new file mode 100644 index 0000000..a3db858 --- /dev/null +++ b/src/includes/box.h @@ -0,0 +1,31 @@ +#ifndef UI_NODE_BOX +#define UI_NODE_BOX 1 + +#define DEFINE_BOX_METHODS() \ + void append(UiControl *control, bool stretchy); \ + void deleteAt(int index); \ + bool getPadded(); \ + void setPadded(bool padded); + +#define INHERITS_BOX_METHODS(CLASS) \ + void CLASS::append(UiControl *control, bool stretchy) { \ + UiBox::append(control, stretchy); \ + } \ + void CLASS::deleteAt(int index) { \ + UiBox::deleteAt(index); \ + } \ + bool CLASS::getPadded() { \ + return UiBox::getPadded(); \ + } \ + void CLASS::setPadded(bool padded) { \ + UiBox::setPadded(padded); \ + } + +#define DECLARE_BOX_METHODS() \ + getset(getPadded, setPadded); \ + method(getPadded); \ + method(setPadded); \ + method(append); \ + method(deleteAt); + +#endif diff --git a/src/includes/control.h b/src/includes/control.h new file mode 100644 index 0000000..07c6b48 --- /dev/null +++ b/src/includes/control.h @@ -0,0 +1,93 @@ +#ifndef UI_NODE_CONTROL +#define UI_NODE_CONTROL 1 + +#include "ui.h" + +#define DEFINE_EVENT(NAME) \ + private: \ + nbind::cbFunction *NAME##Callback = NULL; \ + \ + public: \ + void NAME(nbind::cbFunction &cb); + +#define IMPLEMENT_EVENT(CLASS, WIDGET, NAME, LIBUI_FUN) \ + static void CLASS##_##NAME(WIDGET *w, void *data) { \ + nbind::cbFunction *cb = (nbind::cbFunction *)data; \ + (*cb)(); \ + } \ + void CLASS::NAME(nbind::cbFunction &cb) { \ + NAME##Callback = new nbind::cbFunction(cb); \ + LIBUI_FUN((WIDGET *)getHandle(), CLASS##_##NAME, NAME##Callback); \ + } + +#define DEFINE_CONTROL_METHODS() \ + void destroy(); \ + void setParent(UiControl *parent); \ + bool toplevel(); \ + bool getVisible(); \ + void setVisible(bool visible); \ + bool getEnabled(); \ + void setEnabled(bool enabled); + +#define INHERITS_CONTROL_METHODS(CLASS) \ + void CLASS::destroy() { \ + UiControl::destroy(); \ + } \ + void CLASS::setParent(UiControl *parent) { \ + UiControl::setParent(parent); \ + } \ + bool CLASS::toplevel() { \ + return UiControl::toplevel(); \ + } \ + bool CLASS::getVisible() { \ + return UiControl::getVisible(); \ + } \ + void CLASS::setVisible(bool visible) { \ + UiControl::setVisible(visible); \ + } \ + bool CLASS::getEnabled() { \ + return UiControl::getEnabled(); \ + } \ + void CLASS::setEnabled(bool enabled) { \ + UiControl::setEnabled(enabled); \ + } + +#define DECLARE_CHILD_CONTROL_METHODS() \ + inherit(UiControl); \ + method(destroy); \ + method(setParent); \ + method(toplevel); \ + method(getVisible); \ + method(setVisible); \ + method(getEnabled); \ + method(setEnabled); \ + getset(getVisible, setVisible); \ + getset(getEnabled, setEnabled); + +#define DECLARE_CONTROL_METHODS() \ + method(destroy); \ + method(setParent); \ + method(toplevel); \ + method(getVisible); \ + method(setVisible); \ + method(getEnabled); \ + method(setEnabled); \ + getset(getVisible, setVisible); \ + getset(getEnabled, setEnabled); + +class UiControl { + private: + uiControl *handle; + + public: + uiControl *getHandle(); + UiControl(uiControl *hnd); + DEFINE_CONTROL_METHODS() +}; + +// This is included at end of file +// to minimize conflicts with existing +// symbols from other headers. +#include "nbind/nbind.h" + +#endif diff --git a/src/includes/entry.h b/src/includes/entry.h new file mode 100644 index 0000000..37af491 --- /dev/null +++ b/src/includes/entry.h @@ -0,0 +1,36 @@ +#ifndef UI_NODE_ENTRY +#define UI_NODE_ENTRY 1 + +#define DEFINE_ENTRY_METHODS() \ + void setText(std::string text); \ + std::string getText(); \ + void setReadOnly(bool readOnly); \ + bool getReadOnly(); + +#define INHERITS_ENTRY_METHODS(CLASS) \ + void CLASS::setText(std::string text) { \ + UiEntryBase::setText(text); \ + } \ + std::string CLASS::getText() { \ + return UiEntryBase::getText(); \ + } \ + void CLASS::setReadOnly(bool readOnly) { \ + UiEntryBase::setReadOnly(readOnly); \ + } \ + bool CLASS::getReadOnly() { \ + return UiEntryBase::getReadOnly(); \ + } \ + void CLASS::onChanged(nbind::cbFunction &cb) { \ + UiEntryBase::onChanged(cb); \ + } + +#define DECLARE_ENTRY_METHODS() \ + getset(getText, setText); \ + getset(getReadOnly, setReadOnly); \ + method(onChanged); \ + method(getText); \ + method(setText); \ + method(getReadOnly); \ + method(setReadOnly); + +#endif diff --git a/src/includes/values.h b/src/includes/values.h new file mode 100644 index 0000000..57e9f4f --- /dev/null +++ b/src/includes/values.h @@ -0,0 +1,90 @@ +#ifndef UI_VALUES +#define UI_VALUES 1 + +#include "nbind/api.h" + +class Point { + private: + int x; + int y; + + public: + Point(const Point &other); + Point(int x, int y); + int getX(); + void setX(int value); + int getY(); + void setY(int value); + void toJS(nbind::cbOutput output); +}; + +class Size { + private: + int w; + int h; + + public: + Size(int w, int h); + int getWidth(); + void setWidth(int value); + int getHeight(); + void setHeight(int value); + void toJS(nbind::cbOutput output); +}; + +class PointDouble { + private: + double x; + double y; + + public: + PointDouble(double x, double y); + PointDouble(const PointDouble &other); + double getX(); + void setX(double value); + double getY(); + void setY(double value); + void toJS(nbind::cbOutput output); +}; + +class SizeDouble { + private: + double w; + double h; + + public: + SizeDouble(double w, double h); + double getWidth(); + void setWidth(double value); + double getHeight(); + void setHeight(double value); + void toJS(nbind::cbOutput output); +}; + +class Color { + private: + double r; + double g; + double b; + double a; + + public: + Color(const Color &other); + Color(double r, double g, double b, double a); + double getR(); + void setR(double value); + double getG(); + void setG(double value); + double getB(); + void setB(double value); + double getA(); + void setA(double value); + void toJS(nbind::cbOutput output); +}; + +// This is included at end of file +// to minimize conflicts with existing +// symbols from other headers. +#include "nbind/nbind.h" + +#endif From dbb5a30eb0653de865c80dac354a4e38bb2b86dc Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sun, 8 Apr 2018 10:03:03 +0200 Subject: [PATCH 070/190] Freeing event callbacks on close to allow JS to garbage collect UiWindow --- src/UiWindow.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/UiWindow.cc b/src/UiWindow.cc index 5d032c8..cf4faa3 100644 --- a/src/UiWindow.cc +++ b/src/UiWindow.cc @@ -67,6 +67,19 @@ void UiWindow::show() { void UiWindow::close() { uiControlDestroy(uiControl(win)); + /* + freeing event callbacks to allow JS to garbage collect this class + when there are no references to it left in JS code. + */ + if (onClosingCallback != nullptr) { + delete onClosingCallback; + onClosingCallback = nullptr; + } + + if (onContentSizeChangedCallback != nullptr) { + delete onContentSizeChangedCallback; + onContentSizeChangedCallback = nullptr; + } } void UiWindow::setMargined(bool margined) { From 9eee914e5db44f6feaee17092d96ad79af9cce77 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sun, 8 Apr 2018 19:51:53 +0200 Subject: [PATCH 071/190] onDestroy event implemented with map --- examples/control-gallery.js | 397 +++++++++++++++--------------------- src/UiControl.cc | 18 ++ src/includes/control.h | 6 + 3 files changed, 186 insertions(+), 235 deletions(-) diff --git a/examples/control-gallery.js b/examples/control-gallery.js index 0779161..5e671ee 100644 --- a/examples/control-gallery.js +++ b/examples/control-gallery.js @@ -4,31 +4,31 @@ const os = require('os'); const libui = require('..'); const { - size, - datePicker, - dateTimePicker, - timePicker, - separator, - label, - window, - entry, - searchEntry, - passwordEntry, - hBox, - group, - button, - colors, - colorButton, - checkBox, - spinbox, - slider, - progressBar, - vBox, - combobox, - editableCombobox, - radioButtons, - tab, - menu + size, + datePicker, + dateTimePicker, + timePicker, + separator, + label, + window, + entry, + searchEntry, + passwordEntry, + hBox, + group, + button, + colors, + colorButton, + checkBox, + spinbox, + slider, + progressBar, + vBox, + combobox, + editableCombobox, + radioButtons, + tab, + menu } = require('./utils.js'); const lorem = `Lorem ipsum dolor sit amet, consectetur adipiscing elit, @@ -46,249 +46,176 @@ let colorBtn; let status; const onClosing = () => { - win.close(); - libui.stopLoop(); + win.close(); + libui.stopLoop(); }; -libui.Ui.onShouldQuit(() => { - onClosing(); -}); +libui.Ui.onShouldQuit(() => { onClosing(); }); function onPositionChanged() { - status.text = `(${win.position.x}, ${win.position.y}) - (${win.contentSize - .w} x ${win.contentSize.h})`; + status.text = + `(${win.position.x}, ${win.position.y}) - (${ + win.contentSize.w + } x ${win.contentSize.h})`; } const updateValue = value => { - if (value === spin.value) { - return; - } - spin.value = value; - slide.value = value; - progress.value = value; + if (value === spin.value) { + return; + } + spin.value = value; + slide.value = value; + progress.value = value; }; const changeTitle = () => { - win.title = 'Title changed'; - colorBtn.color = colors.red; + win.title = 'Title changed'; + colorBtn.color = colors.red; }; const areaHandler = { - drawCb() { - console.log('drawCb'); - }, + drawCb() { console.log('drawCb'); }, - mouseEventCb() { - console.log('mouseEventCb'); - }, + mouseEventCb() { console.log('mouseEventCb'); }, - mouseCrossedCb() { - console.log('mouseCrossedCb'); - }, + mouseCrossedCb() { console.log('mouseCrossedCb'); }, - dragBrokenCb() { - console.log('dragBrokenCb'); - }, + dragBrokenCb() { console.log('dragBrokenCb'); }, - keyEventCb() { - console.log('keyEventCb'); - } + keyEventCb() { console.log('keyEventCb'); } }; const area = new libui.UiArea( - areaHandler.drawCb, - areaHandler.mouseEventCb, - areaHandler.mouseCrossedCb, - areaHandler.dragBrokenCb, - areaHandler.keyEventCb, - 300, - 150 -); + areaHandler.drawCb, areaHandler.mouseEventCb, areaHandler.mouseCrossedCb, + areaHandler.dragBrokenCb, areaHandler.keyEventCb, 300, 150); area.props = { - tabTitle: 'Area', - stretchy: true + tabTitle : 'Area', + stretchy : true }; menu([ - { - label: 'File', - submenu: [ - { - label: 'Open', - click: () => { - const filename = libui.UiDialogs.openFile(win); - if (filename) { - libui.UiDialogs.msgBox(win, 'File selected', filename); - } else { - libui.UiDialogs.msgBox( - win, - 'No file selected', - `Don't be alarmed!` - ); - } - } - }, - { - label: 'Save', - click: () => { - const filename = libui.UiDialogs.saveFile(win); - if (filename) { - libui.UiDialogs.msgBox(win, 'File selected', filename); - } else { - libui.UiDialogs.msgBox( - win, - 'No file selected', - `Don't be alarmed!` - ); - } - } - }, - { - role: 'quit' - } - ] - }, - { - label: 'Edit', - submenu: [ - { - label: 'Checkable Item', - type: 'checkbox' - }, - { - type: 'separator' - }, - { - label: 'Disabled Item', - disabled: true - }, - { - role: 'preferences' - } - ] - }, - { - label: 'Help', - submenu: [ - { - label: 'Help', - click: () => {} - }, - { - role: 'about' - } - ] - }, - { - label: 'Window', - submenu: [ - { - label: 'Full screen', - click: () => { - win.fullscreen = !win.fullscreen; - } - }, - { - label: 'Borderless', - click: () => { - win.borderless = !win.borderless; - } - }, - { - label: 'Reset size', - click: () => { - win.contentSize = size(800, 600); - } - } - ] - } + { + label : 'File', + submenu : [ + { + label : 'Open', + click : () => { + const filename = libui.UiDialogs.openFile(win); + if (filename) { + libui.UiDialogs.msgBox(win, 'File selected', filename); + } else { + libui.UiDialogs.msgBox(win, 'No file selected', + `Don't be alarmed!`); + } + } + }, + { + label : 'Save', + click : () => { + const filename = libui.UiDialogs.saveFile(win); + if (filename) { + libui.UiDialogs.msgBox(win, 'File selected', filename); + } else { + libui.UiDialogs.msgBox(win, 'No file selected', + `Don't be alarmed!`); + } + } + }, + {role : 'quit'} + ] + }, + { + label : 'Edit', + submenu : [ + {label : 'Checkable Item', type : 'checkbox'}, {type : 'separator'}, + {label : 'Disabled Item', disabled : true}, {role : 'preferences'} + ] + }, + { + label : 'Help', + submenu : [ + {label : 'Help', click : () => { win.title = null; }}, + {role : 'about'} + ] + }, + { + label : 'Window', + submenu : [ + { + label : 'Full screen', + click : () => { win.fullscreen = !win.fullscreen; } + }, + { + label : 'Borderless', + click : () => { win.borderless = !win.borderless; } + }, + { + label : 'Reset size', + click : () => { win.contentSize = size(800, 600); } + } + ] + } ]); const winProps = { - hasMenubar: true, - title: 'Control Gallery', - width: 640, - height: 480, - onClosing, - onContentSizeChanged: onPositionChanged + hasMenubar : true, + title : 'Control Gallery', + width : 640, + height : 480, + onClosing, + onContentSizeChanged : onPositionChanged }; const onDarwin = os.platform() === 'darwin'; -const searchText = {text: 'Search Entry'}; +const searchText = { + text : 'Search Entry' +}; win = window( - winProps, - hBox( - {padded: true}, - group( - {margined: true, title: 'Basic Controls'}, - button({text: 'Button', onClicked: changeTitle}), - (colorBtn = colorButton({})), - checkBox({text: 'Checkbox'}), - entry({text: 'Entry'}), - onDarwin ? entry(searchText) : searchEntry(searchText), - passwordEntry({text: 'Password Entry'}), - label({text: 'Label'}), - separator({}), - datePicker({}), - dateTimePicker({}), - timePicker({}) - ), - - vBox( - {padded: true}, - group( - {margined: true, title: 'Numbers'}, - (spin = spinbox({onChanged: () => updateValue(spin.value)})), - (slide = slider({onChanged: () => updateValue(slide.value)})), - (progress = progressBar({})) - ), - - group( - {margined: true, title: 'Lists', stretchy: true}, - combobox( - {}, - 'Combobox Item 1', - 'Combobox Item 2', - 'Combobox Item 3' - ), - editableCombobox( - {}, - 'Editable Item 1', - 'Editable Item 2', - 'Editable Item 3' - ), - radioButtons( - {}, - 'Radio Button 1', - 'Radio Button 2', - 'Radio Button 3' - ), - tab( - {stretchy: true}, - entry({ - text: lorem.slice(5), - tabTitle: 'Page 1', - stretchy: true - }), - entry({ - text: lorem.slice(10), - tabTitle: 'Page 2', - stretchy: true - }), - entry({ - text: lorem.slice(20), - tabTitle: 'Page 3', - stretchy: true - }), - area - ) - ) - ) - ), - (status = label({stretchy: true, text: '(0, 0)'})) -); + winProps, + hBox( + {padded : true}, + group({margined : true, title : 'Basic Controls'}, + button({text : 'Button', onClicked : changeTitle}), + (colorBtn = colorButton({})), checkBox({text : 'Checkbox'}), + entry({text : 'Entry'}), + onDarwin ? entry(searchText) : searchEntry(searchText), + passwordEntry({text : 'Password Entry'}), label({text : 'Label'}), + separator({}), datePicker({}), dateTimePicker({}), + timePicker({})), + + vBox({padded : true}, + group( + {margined : true, title : 'Numbers'}, + (spin = spinbox({onChanged : () => updateValue(spin.value)})), + (slide = slider({onChanged : () => updateValue(slide.value)})), + (progress = progressBar({}))), + + group({margined : true, title : 'Lists', stretchy : true}, + combobox({}, 'Combobox Item 1', 'Combobox Item 2', + 'Combobox Item 3'), + editableCombobox({}, 'Editable Item 1', 'Editable Item 2', + 'Editable Item 3'), + radioButtons({}, 'Radio Button 1', 'Radio Button 2', + 'Radio Button 3'), + tab({stretchy : true}, entry({ + text : lorem.slice(5), + tabTitle : 'Page 1', + stretchy : true + }), + entry({ + text : lorem.slice(10), + tabTitle : 'Page 2', + stretchy : true + }), + entry({ + text : lorem.slice(20), + tabTitle : 'Page 3', + stretchy : true + }), + area)))), + (status = label({stretchy : true, text : '(0, 0)'}))); win.show(); libui.startLoop(); diff --git a/src/UiControl.cc b/src/UiControl.cc index c3d99b9..04f3626 100644 --- a/src/UiControl.cc +++ b/src/UiControl.cc @@ -1,13 +1,31 @@ +#include #include "nbind/api.h" #include "control.h" #include "ui.h" +std::map controlsMap; + uiControl *UiControl::getHandle() { return handle; } +static void _uicontrol_onDestroy(uiControl *control) { + UiControl *wrapper = controlsMap[control]; + wrapper->onDestroy(control); + wrapper->originalDestroy(control); + wrapper->destroyed = true; +} + +void UiControl::onDestroy(uiControl *control) { + printf("Control %p destroyed with wrapper %p.\n", control, this); +} + UiControl::UiControl(uiControl *hnd) { handle = hnd; + originalDestroy = hnd->Destroy; + hnd->Destroy = _uicontrol_onDestroy; + destroyed = false; + controlsMap[hnd] = this; } void UiControl::destroy() { diff --git a/src/includes/control.h b/src/includes/control.h index 07c6b48..755fd06 100644 --- a/src/includes/control.h +++ b/src/includes/control.h @@ -75,11 +75,17 @@ getset(getVisible, setVisible); \ getset(getEnabled, setEnabled); +typedef void (*DestroyCb)(uiControl *); + class UiControl { private: uiControl *handle; public: + DestroyCb originalDestroy; + bool destroyed; + void onDestroy(uiControl *); + uiControl *getHandle(); UiControl(uiControl *hnd); DEFINE_CONTROL_METHODS() From 1fdd749b410d45aa476daf0dea172eab867ea702 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Mon, 9 Apr 2018 23:18:56 +0200 Subject: [PATCH 072/190] ignored uitable.h. It shouldn't be here anyway, I'm not sure where it come from! --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1141b71..7f984f9 100644 --- a/.gitignore +++ b/.gitignore @@ -95,6 +95,7 @@ _libui ui_*.h ui.h +uitable.h *.dylib *.dll From 2360a2826b835a370d0f71c4a3d081df6d3c911f Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Mon, 9 Apr 2018 23:37:23 +0200 Subject: [PATCH 073/190] ported changed area class declaration from ui-node.h -> area.h --- src/includes/area.h | 14 +- src/ui-node.h | 824 -------------------------------------------- 2 files changed, 9 insertions(+), 829 deletions(-) delete mode 100644 src/ui-node.h diff --git a/src/includes/area.h b/src/includes/area.h index ee93e74..5d11d7b 100644 --- a/src/includes/area.h +++ b/src/includes/area.h @@ -36,29 +36,30 @@ class DrawStrokeParams { public: DrawStrokeParams(); + ~DrawStrokeParams(); int getCap(); int getJoin(); double getThickness(); double getMiterLimit(); std::vector getDashes(); - int getNumDashes(); double getDashPhase(); void setCap(int value); void setJoin(int value); void setThickness(double value); void setMiterLimit(double value); void setDashes(std::vector value); - void setNumDashes(int value); void setDashPhase(double value); uiDrawStrokeParams *toStruct(); // void toJS(nbind::cbOutput output); }; + class UiDrawMatrix { private: uiDrawMatrix *m; public: UiDrawMatrix(); + ~UiDrawMatrix(); uiDrawMatrix *getStruct(); double getM11(); double getM12(); @@ -80,8 +81,8 @@ class UiDrawMatrix { void multiply(UiDrawMatrix *src); int invertible(); int invert(); - PointDouble transformPoint(); - SizeDouble transformSize(); + PointDouble transformPoint(PointDouble value); + SizeDouble transformSize(SizeDouble value); }; class BrushGradientStop { @@ -104,12 +105,15 @@ class DrawBrush { public: DrawBrush(); + ~DrawBrush(); Color getColor(); void setColor(Color value); Point getStart(); void setStart(Point value); Point getEnd(); void setEnd(Point value); + double getOuterRadius(); + void setOuterRadius(double r); int getType(); void setType(int value); std::vector getStops(); @@ -140,7 +144,7 @@ class UiAreaKeyEvent { public: UiAreaKeyEvent(uiAreaKeyEvent *event); - char *getKey(); + std::string getKey(); int getExtKey(); int getModifier(); int getModifiers(); diff --git a/src/ui-node.h b/src/ui-node.h deleted file mode 100644 index 7f8dfe1..0000000 --- a/src/ui-node.h +++ /dev/null @@ -1,824 +0,0 @@ -// A2DD.h -#ifndef ui_node -#define ui_node - -#include -#include "nbind/api.h" - -#define DEFINE_EVENT(NAME) \ - private: \ - nbind::cbFunction *NAME##Callback = NULL; \ - \ - public: \ - void NAME(nbind::cbFunction &cb); - -#define IMPLEMENT_EVENT(CLASS, WIDGET, NAME, LIBUI_FUN) \ - static void CLASS##_##NAME(WIDGET *w, void *data) { \ - nbind::cbFunction *cb = (nbind::cbFunction *)data; \ - (*cb)(); \ - } \ - void CLASS::NAME(nbind::cbFunction &cb) { \ - NAME##Callback = new nbind::cbFunction(cb); \ - LIBUI_FUN((WIDGET *)getHandle(), CLASS##_##NAME, NAME##Callback); \ - } - -#define DEFINE_CONTROL_METHODS() \ - void destroy(); \ - void setParent(UiControl *parent); \ - bool toplevel(); \ - bool getVisible(); \ - void setVisible(bool visible); \ - bool getEnabled(); \ - void setEnabled(bool enabled); - -#define INHERITS_CONTROL_METHODS(CLASS) \ - void CLASS::destroy() { \ - UiControl::destroy(); \ - } \ - void CLASS::setParent(UiControl *parent) { \ - UiControl::setParent(parent); \ - } \ - bool CLASS::toplevel() { \ - return UiControl::toplevel(); \ - } \ - bool CLASS::getVisible() { \ - return UiControl::getVisible(); \ - } \ - void CLASS::setVisible(bool visible) { \ - UiControl::setVisible(visible); \ - } \ - bool CLASS::getEnabled() { \ - return UiControl::getEnabled(); \ - } \ - void CLASS::setEnabled(bool enabled) { \ - UiControl::setEnabled(enabled); \ - } - -#define DECLARE_CHILD_CONTROL_METHODS() \ - inherit(UiControl); \ - method(destroy); \ - method(setParent); \ - method(toplevel); \ - method(getVisible); \ - method(setVisible); \ - method(getEnabled); \ - method(setEnabled); \ - getset(getVisible, setVisible); \ - getset(getEnabled, setEnabled); - -#define DECLARE_CONTROL_METHODS() \ - method(destroy); \ - method(setParent); \ - method(toplevel); \ - method(getVisible); \ - method(setVisible); \ - method(getEnabled); \ - method(setEnabled); \ - getset(getVisible, setVisible); \ - getset(getEnabled, setEnabled); - -#define DEFINE_ENTRY_METHODS() \ - void setText(const char *text); \ - const char *getText(); \ - void setReadOnly(bool readOnly); \ - bool getReadOnly(); - -#define INHERITS_ENTRY_METHODS(CLASS) \ - void CLASS::setText(const char *text) { \ - UiEntryBase::setText(text); \ - } \ - const char *CLASS::getText() { \ - return UiEntryBase::getText(); \ - } \ - void CLASS::setReadOnly(bool readOnly) { \ - UiEntryBase::setReadOnly(readOnly); \ - } \ - bool CLASS::getReadOnly() { \ - return UiEntryBase::getReadOnly(); \ - } \ - void CLASS::onChanged(nbind::cbFunction &cb) { \ - UiEntryBase::onChanged(cb); \ - } - -#define DECLARE_ENTRY_METHODS() \ - getset(getText, setText); \ - getset(getReadOnly, setReadOnly); \ - method(onChanged); \ - method(getText); \ - method(setText); \ - method(getReadOnly); \ - method(setReadOnly); - -#define DEFINE_BOX_METHODS() \ - void append(UiControl *control, bool stretchy); \ - void deleteAt(int index); \ - bool getPadded(); \ - void setPadded(bool padded); - -#define INHERITS_BOX_METHODS(CLASS) \ - void CLASS::append(UiControl *control, bool stretchy) { \ - UiBox::append(control, stretchy); \ - } \ - void CLASS::deleteAt(int index) { \ - UiBox::deleteAt(index); \ - } \ - bool CLASS::getPadded() { \ - return UiBox::getPadded(); \ - } \ - void CLASS::setPadded(bool padded) { \ - UiBox::setPadded(padded); \ - } - -#define DECLARE_BOX_METHODS() \ - getset(getPadded, setPadded); \ - method(getPadded); \ - method(setPadded); \ - method(append); \ - method(deleteAt); - -class UiControl { - private: - uiControl *handle; - - public: - uiControl *getHandle(); - UiControl(uiControl *hnd); - DEFINE_CONTROL_METHODS() -}; - -class UiRadioButtons : public UiControl { - DEFINE_EVENT(onSelected) - - public: - UiRadioButtons(); - void append(const char *text); - int getSelected(); - void setSelected(int n); - - DEFINE_CONTROL_METHODS() -}; - -class UiTab : public UiControl { - public: - UiTab(); - void append(const char *text, UiControl *child); - void insertAt(const char *name, int before, UiControl *child); - void deleteAt(int index); - int numPages(); - bool getMargined(int page); - void setMargined(int page, bool margined); - - DEFINE_CONTROL_METHODS() -}; - -class UiMultilineEntry : public UiControl { - DEFINE_EVENT(onChanged) - - public: - UiMultilineEntry(); - DEFINE_CONTROL_METHODS() - void setText(const char *text); - const char *getText(); - void setReadOnly(bool readOnly); - bool getReadOnly(); - void append(const char *text); -}; - -class UiCombobox : public UiControl { - DEFINE_EVENT(onSelected) - - public: - UiCombobox(); - DEFINE_CONTROL_METHODS() - void append(const char *text); - int getSelected(); - void setSelected(int n); -}; - -class UiDateTimePicker : public UiControl { - public: - UiDateTimePicker(); - DEFINE_CONTROL_METHODS() -}; - -class UiDatePicker : public UiControl { - public: - UiDatePicker(); - DEFINE_CONTROL_METHODS() -}; - -class UiTimePicker : public UiControl { - public: - UiTimePicker(); - DEFINE_CONTROL_METHODS() -}; - -class UiEditableCombobox : public UiControl { - DEFINE_EVENT(onChanged) - - public: - UiEditableCombobox(); - DEFINE_CONTROL_METHODS() - void append(const char *text); - const char *getText(); - void setText(const char *text); -}; - -class UiEntryBase : public UiControl { - DEFINE_EVENT(onChanged) - - public: - UiEntryBase(uiControl *); - DEFINE_CONTROL_METHODS() - DEFINE_ENTRY_METHODS() -}; - -class UiEntry : public UiEntryBase { - public: - UiEntry(); - DEFINE_CONTROL_METHODS() - DEFINE_ENTRY_METHODS() - void onChanged(nbind::cbFunction &cb); -}; - -class UiPasswordEntry : public UiEntryBase { - public: - UiPasswordEntry(); - DEFINE_CONTROL_METHODS() - DEFINE_ENTRY_METHODS() - void onChanged(nbind::cbFunction &cb); -}; - -class UiSearchEntry : public UiEntryBase { - public: - UiSearchEntry(); - DEFINE_CONTROL_METHODS() - DEFINE_ENTRY_METHODS() - void onChanged(nbind::cbFunction &cb); -}; - -class UiHorizontalSeparator : public UiControl { - public: - UiHorizontalSeparator(); - DEFINE_CONTROL_METHODS() -}; - -class UiVerticalSeparator : public UiControl { - public: - UiVerticalSeparator(); - DEFINE_CONTROL_METHODS() -}; - -class UiLabel : public UiControl { - public: - UiLabel(); - UiLabel(const char *text); - DEFINE_CONTROL_METHODS() - void setText(const char *text); - const char *getText(); -}; - -class UiGroup : public UiControl { - public: - UiGroup(const char *text); - UiGroup(); - void setChild(UiControl *control); - bool getMargined(); - void setMargined(bool margined); - const char *getTitle(); - void setTitle(const char *title); - DEFINE_CONTROL_METHODS() -}; - -class UiButton : public UiControl { - DEFINE_EVENT(onClicked) - - public: - UiButton(const char *text); - UiButton(); - DEFINE_CONTROL_METHODS() - void setText(const char *text); - const char *getText(); -}; - -class UiCheckbox : public UiControl { - DEFINE_EVENT(onToggled) - - public: - UiCheckbox(const char *text); - UiCheckbox(); - DEFINE_CONTROL_METHODS() - void setText(const char *text); - const char *getText(); - void setChecked(bool checked); - bool getChecked(); -}; - -class UiProgressBar : public UiControl { - private: - int value = 0; - - public: - UiProgressBar(); - DEFINE_CONTROL_METHODS() - int getValue(); - void setValue(int value); -}; - -class UiSlider : public UiControl { - DEFINE_EVENT(onChanged) - - public: - UiSlider(int min, int max); - UiSlider(); - DEFINE_CONTROL_METHODS() - - int getValue(); - void setValue(int value); -}; - -class UiSpinbox : public UiControl { - DEFINE_EVENT(onChanged) - - public: - UiSpinbox(int min, int max); - UiSpinbox(); - DEFINE_CONTROL_METHODS() - - int getValue(); - void setValue(int value); -}; - -class UiBox : public UiControl { - public: - UiBox(uiControl *hnd); - DEFINE_BOX_METHODS() -}; - -class UiVerticalBox : public UiBox { - public: - UiVerticalBox(); - DEFINE_BOX_METHODS() - DEFINE_CONTROL_METHODS() -}; - -class UiHorizontalBox : public UiBox { - public: - UiHorizontalBox(); - DEFINE_BOX_METHODS() - DEFINE_CONTROL_METHODS() -}; - -class Point { - private: - int x; - int y; - - public: - Point(const Point &other); - Point(int x, int y); - int getX(); - void setX(int value); - int getY(); - void setY(int value); - void toJS(nbind::cbOutput output); -}; - -class Size { - private: - int w; - int h; - - public: - Size(int w, int h); - int getWidth(); - void setWidth(int value); - int getHeight(); - void setHeight(int value); - void toJS(nbind::cbOutput output); -}; - -class PointDouble { - private: - double x; - double y; - - public: - PointDouble(double x, double y); - PointDouble(const PointDouble &other); - double getX(); - void setX(double value); - double getY(); - void setY(double value); - void toJS(nbind::cbOutput output); -}; - -class SizeDouble { - private: - double w; - double h; - - public: - SizeDouble(double w, double h); - double getWidth(); - void setWidth(double value); - double getHeight(); - void setHeight(double value); - void toJS(nbind::cbOutput output); -}; - -class UiWindow { - DEFINE_EVENT(onClosing) - DEFINE_EVENT(onContentSizeChanged) - - private: - uiWindow *win; - - public: - UiWindow(const char *title, int width, int height, bool hasMenubar); - uiWindow *getHandle(); - void show(); - void close(); - void setMargined(bool margined); - bool getMargined(); - void setChild(UiControl *control); - void setTitle(const char *title); - const char *getTitle(); - bool getFullscreen(); - void setFullscreen(bool value); - bool getBorderless(); - void setBorderless(bool value); - Size getContentSize(); - void setContentSize(Size value); -}; - -class UiForm : public UiControl { - public: - UiForm(); - DEFINE_CONTROL_METHODS() - void append(const char *label, UiControl *c, bool stretchy); - void deleteAt(int index); - bool getPadded(); - void setPadded(bool padded); -}; - -// TODO - document -class UiMenuItem { - DEFINE_EVENT(onClicked) - - private: - uiMenuItem *handle; - - public: - UiMenuItem(uiMenuItem *hnd); - void enable(); - void disable(); - bool getChecked(); - void setChecked(bool checked); -}; - -// TODO - document -class UiMenu { - private: - uiMenu *handle; - - public: - UiMenu(const char *name); - UiMenuItem *appendItem(const char *name); - UiMenuItem *appendCheckItem(const char *name); - UiMenuItem *appendQuitItem(); - UiMenuItem *appendPreferencesItem(); - UiMenuItem *appendAboutItem(); - void appendSeparator(); -}; - -class Color { - private: - double r; - double g; - double b; - double a; - - public: - Color(const Color &other); - Color(double r, double g, double b, double a); - double getR(); - void setR(double value); - double getG(); - void setG(double value); - double getB(); - void setB(double value); - double getA(); - void setA(double value); - void toJS(nbind::cbOutput output); -}; - -class UiColorButton : public UiControl { - DEFINE_EVENT(onChanged) - - public: - UiColorButton(); - Color getColor(); - void setColor(Color value); - DEFINE_CONTROL_METHODS() -}; - -// UIArea - -class DrawStrokeParams { - private: - uiDrawStrokeParams *sp; - - public: - DrawStrokeParams(); - ~DrawStrokeParams(); - int getCap(); - int getJoin(); - double getThickness(); - double getMiterLimit(); - std::vector getDashes(); - double getDashPhase(); - void setCap(int value); - void setJoin(int value); - void setThickness(double value); - void setMiterLimit(double value); - void setDashes(std::vector value); - void setDashPhase(double value); - uiDrawStrokeParams *toStruct(); - // void toJS(nbind::cbOutput output); -}; -class UiDrawMatrix { - private: - uiDrawMatrix *m; - - public: - UiDrawMatrix(); - ~UiDrawMatrix(); - uiDrawMatrix *getStruct(); - double getM11(); - double getM12(); - double getM21(); - double getM22(); - double getM31(); - double getM32(); - void setM11(double value); - void setM12(double value); - void setM21(double value); - void setM22(double value); - void setM31(double value); - void setM32(double value); - void setIdentity(); - void translate(double x, double y); - void scale(double xCenter, double yCenter, double x, double y); - void rotate(double x, double y, double amount); - void skew(double x, double y, double xamount, double yamount); - void multiply(UiDrawMatrix *src); - int invertible(); - int invert(); - PointDouble transformPoint(PointDouble value); - SizeDouble transformSize(SizeDouble value); -}; - -class BrushGradientStop { - private: - double p; - Color c; - - public: - BrushGradientStop(double pos, Color color); - Color getColor(); - void setColor(Color value); - double getPos(); - void setPos(double value); - void toJS(nbind::cbOutput output); -}; - -class DrawBrush { - private: - uiDrawBrush *b; - - public: - DrawBrush(); - ~DrawBrush(); - Color getColor(); - void setColor(Color value); - Point getStart(); - void setStart(Point value); - Point getEnd(); - void setEnd(Point value); - double getOuterRadius(); - void setOuterRadius(double r); - int getType(); - void setType(int value); - std::vector getStops(); - void setStops(std::vector value); - uiDrawBrush *toStruct(); -}; - -class UiAreaMouseEvent { - private: - uiAreaMouseEvent *e; - - public: - UiAreaMouseEvent(uiAreaMouseEvent *event); - double getX(); - double getY(); - double getAreaWidth(); - double getAreaHeight(); - int getDown(); - int getUp(); - int getCount(); - int getModifiers(); - unsigned int getHeld1To64(); -}; - -class UiAreaKeyEvent { - private: - uiAreaKeyEvent *e; - - public: - UiAreaKeyEvent(uiAreaKeyEvent *event); - std::string getKey(); - int getExtKey(); - int getModifier(); - int getModifiers(); - int getUp(); -}; - -class UiDrawPath { - private: - uiDrawPath *handle; - - public: - uiDrawPath *getHandle(); - UiDrawPath(int fillMode); - void freePath(); - void newFigure(double x, double y); - void newFigureWithArc(double xCenter, double yCenter, double radius, - double startAngle, double sweep, int negative); - void lineTo(double x, double y); - void arcTo(double xCenter, double yCenter, double radius, double startAngle, - double sweep, int negative); - void bezierTo(double c1x, double c1y, double c2x, double c2y, double endX, - double endY); - void closeFigure(); - void addRectangle(double x, double y, double width, double height); - void end(); -}; - -class DrawTextFontMetrics { - private: - uiDrawTextFontMetrics *m; - - public: - DrawTextFontMetrics(uiDrawTextFontMetrics *metrics); - double getAscent(); - double getDescent(); - double getLeading(); - double getUnderlinePos(); - double getUnderlineThickness(); -}; - -class DrawTextFontDescriptor { - private: - uiDrawTextFontDescriptor *d; - - public: - DrawTextFontDescriptor(uiDrawTextFontDescriptor *descr); - const char *getFamily(); - double getSize(); - int getWeight(); - int getItalic(); - int getStretch(); -}; - -class DrawTextFont { - private: - uiDrawTextFont *handle; - - public: - DrawTextFont(); - DrawTextFont(uiDrawTextFont *h); - - uiDrawTextFont *getHandle(); - void free(); - DrawTextFontDescriptor *describe(); - DrawTextFontMetrics *getMetrics(); - - static std::vector listFontFamilies(); - void loadClosestFont(const char *family, double size, int weight, - int italic, int stretch); -}; - -class UiFontButton : public UiControl { - DEFINE_EVENT(onChanged) - - public: - UiFontButton(); - DrawTextFont *getFont(); - DEFINE_CONTROL_METHODS() -}; - -class DrawTextLayout { - private: - uiDrawTextLayout *handle; - double w; - - public: - DrawTextLayout(const char *text, DrawTextFont *defaultFont, double width); - void free(); - void setWidth(double value); - double getWidth(); - SizeDouble getExtents(); - uiDrawTextLayout *getHandle(); - void setColor(int startChar, int endChar, Color color); -}; - -class UiDrawContext { - private: - uiDrawContext *c; - - public: - UiDrawContext(uiDrawContext *ctx); - void stroke(UiDrawPath *path, DrawBrush *b, DrawStrokeParams *p); - void fill(UiDrawPath *path, DrawBrush *b); - void transform(UiDrawMatrix *m); - void clip(UiDrawPath *path); - void save(); - void restore(); - void text(double x, double y, DrawTextLayout *layout); -}; - -class UiAreaDrawParams { - private: - uiAreaDrawParams *p; - - public: - UiAreaDrawParams(uiAreaDrawParams *params); - UiDrawContext *getContext(); - double getAreaWidth(); - double getAreaHeight(); - double getClipX(); - double getClipY(); - double getClipWidth(); - double getClipHeight(); -}; - -// TODO - document -class UiArea : public UiControl { - public: - // Workaround for nbind bug solved in 0.3 - UiArea(int dummy); - - UiArea(nbind::cbFunction &drawCb, nbind::cbFunction &mouseEventCb, - nbind::cbFunction &mouseCrossedCb, nbind::cbFunction &dragBrokenCb, - nbind::cbFunction &keyEventCb); - UiArea(nbind::cbFunction &drawCb, nbind::cbFunction &mouseEventCb, - nbind::cbFunction &mouseCrossedCb, nbind::cbFunction &dragBrokenCb, - nbind::cbFunction &keyEventCb, int width, int height); - void setSize(int width, int height); - void queueRedrawAll(); - void scrollTo(double x, double y, double width, double height); - DEFINE_CONTROL_METHODS() -}; - -extern std::map areasMap; - -typedef struct UiAreaHandler { - void (*Draw)(UiAreaHandler *self, uiArea *area, uiAreaDrawParams *params); - void (*MouseEvent)(UiAreaHandler *self, uiArea *area, - uiAreaMouseEvent *event); - void (*MouseCrossed)(UiAreaHandler *self, uiArea *area, int left); - void (*DragBroken)(UiAreaHandler *self, uiArea *area); - int (*KeyEvent)(UiAreaHandler *self, uiArea *area, uiAreaKeyEvent *event); - - nbind::cbFunction *draw; - nbind::cbFunction *mouseEvent; - nbind::cbFunction *mouseCrossed; - nbind::cbFunction *dragBroken; - nbind::cbFunction *keyEvent; -} UiAreaHandler; - -struct UiAreaHandlerFactory { - static UiAreaHandler *build(nbind::cbFunction &draw, - nbind::cbFunction &mouseEvent, - nbind::cbFunction &mouseCrossed, - nbind::cbFunction &dragBroken, - nbind::cbFunction &keyEvent); -}; - -// TODO - document -class UiGrid : public UiControl { - public: - UiGrid(); - bool getPadded(); - void setPadded(bool value); - void append(UiControl *c, int left, int top, int xspan, int yspan, - int hexpand, int halign, int vexpand, int valign); - void insertAt(UiControl *c, UiControl *existing, int at, int xspan, - int yspan, int hexpand, int halign, int vexpand, int valign); - - DEFINE_CONTROL_METHODS() -}; - -#endif From 69581484bd1b31c3d8557dfc6a948054ebfa7442 Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Mon, 9 Apr 2018 23:45:31 +0200 Subject: [PATCH 074/190] Rename Font classes --- binding.gyp | 8 +- examples/text.js | 40 ++--- index.js | 12 +- src/Font/AttributedString.cc | 107 +++++++++++++ src/Font/FontAttribute.cc | 148 ++++++++++++++++++ ...{UiFontDescriptor.cc => FontDescriptor.cc} | 20 +-- src/Font/OpenTypeFeatures.cc | 57 +++++++ src/Font/UiAttributedString.cc | 107 ------------- src/Font/UiFontAttribute.cc | 148 ------------------ src/Font/UiOpenTypeFeatures.cc | 57 ------- src/UiArea/DrawTextLayout.cc | 4 +- src/UiFontButton.cc | 4 +- src/ui-node.h | 56 +++---- 13 files changed, 384 insertions(+), 384 deletions(-) create mode 100644 src/Font/AttributedString.cc create mode 100644 src/Font/FontAttribute.cc rename src/Font/{UiFontDescriptor.cc => FontDescriptor.cc} (61%) create mode 100644 src/Font/OpenTypeFeatures.cc delete mode 100644 src/Font/UiAttributedString.cc delete mode 100644 src/Font/UiFontAttribute.cc delete mode 100644 src/Font/UiOpenTypeFeatures.cc diff --git a/binding.gyp b/binding.gyp index 27a4af5..7fd9d0b 100644 --- a/binding.gyp +++ b/binding.gyp @@ -8,10 +8,10 @@ "sources": [ "src/EventLoop.cc", "src/UiFontButton.cc", - "src/Font/UiFontDescriptor.cc", - "src/Font/UiFontAttribute.cc", - "src/Font/UiAttributedString.cc", - "src/Font/UiOpenTypeFeatures.cc", + "src/Font/FontDescriptor.cc", + "src/Font/FontAttribute.cc", + "src/Font/AttributedString.cc", + "src/Font/OpenTypeFeatures.cc", "src/UiArea/DrawTextLayout.cc", "src/UiArea/UiArea.cc", "src/UiArea/DrawStrokeParams.cc", diff --git a/examples/text.js b/examples/text.js index 88ea88f..f4dc5d3 100644 --- a/examples/text.js +++ b/examples/text.js @@ -2,7 +2,7 @@ /* eslint-disable unicorn/number-literal-case */ const libui = require('..'); -const {UiFontAttribute} = libui; +const {FontAttribute} = libui; let mainwin; let textDrawArea; @@ -10,59 +10,59 @@ let fontButton; let align; let checkbox; -const str = new libui.UiAttributedString( +const str = new libui.AttributedString( 'Drawing strings with libui is done with the uiAttributedString and uiDrawTextLayout objects.\n' + 'uiAttributedString lets you have a variety of attributes: '); -str.appendAttributed('font family', UiFontAttribute.newFamily('Courier New')); +str.appendAttributed('font family', FontAttribute.newFamily('Courier New')); str.appendUnattributed(', '); -str.appendAttributed('font size', UiFontAttribute.newSize(18)); +str.appendAttributed('font size', FontAttribute.newSize(18)); str.appendUnattributed(', '); -str.appendAttributed('font weight', UiFontAttribute.newWeight(libui.textWeight.bold)); +str.appendAttributed('font weight', FontAttribute.newWeight(libui.textWeight.bold)); str.appendUnattributed(', '); -str.appendAttributed('font italicness', UiFontAttribute.newItalic(libui.textItalic.italic)); +str.appendAttributed('font italicness', FontAttribute.newItalic(libui.textItalic.italic)); str.appendUnattributed(', '); -str.appendAttributed('font stretch', UiFontAttribute.newStretch(libui.textStretch.condensed)); +str.appendAttributed('font stretch', FontAttribute.newStretch(libui.textStretch.condensed)); str.appendUnattributed(', '); -str.appendAttributed('text color', UiFontAttribute.newColor(new libui.Color(0.75, 0.25, 0.5, 0.75))); +str.appendAttributed('text color', FontAttribute.newColor(new libui.Color(0.75, 0.25, 0.5, 0.75))); str.appendUnattributed(', '); -str.appendAttributed('text background color', UiFontAttribute.newBackground(new libui.Color(0.5, 0.5, 0.25, 0.5))); +str.appendAttributed('text background color', FontAttribute.newBackground(new libui.Color(0.5, 0.5, 0.25, 0.5))); str.appendUnattributed(', '); -str.appendAttributed('underline style', UiFontAttribute.newUnderline(libui.textUnderline.single)); +str.appendAttributed('underline style', FontAttribute.newUnderline(libui.textUnderline.single)); str.appendUnattributed(', '); str.appendUnattributed('and '); str.appendAttributed('underline color', - UiFontAttribute.newUnderline(libui.textUnderline.double), - UiFontAttribute.newUnderlineColor(libui.textUnderlineColor.custom, new libui.Color(1.0, 0.0, 0.5, 1.0))); + FontAttribute.newUnderline(libui.textUnderline.double), + FontAttribute.newUnderlineColor(libui.textUnderlineColor.custom, new libui.Color(1.0, 0.0, 0.5, 1.0))); str.appendUnattributed('. '); str.appendUnattributed('Furthermore, there are attributes allowing for '); str.appendAttributed('special underlines for indicating spelling errors', - UiFontAttribute.newUnderline(libui.textUnderline.suggestion), - UiFontAttribute.newUnderlineColor(libui.textUnderlineColor.spelling)); + FontAttribute.newUnderline(libui.textUnderline.suggestion), + FontAttribute.newUnderlineColor(libui.textUnderlineColor.spelling)); str.appendUnattributed(' (and '); str.appendAttributed('other types of errors', - UiFontAttribute.newUnderline(libui.textUnderline.suggestion), - UiFontAttribute.newUnderlineColor(libui.textUnderlineColor.grammar)); + FontAttribute.newUnderline(libui.textUnderline.suggestion), + FontAttribute.newUnderlineColor(libui.textUnderlineColor.grammar)); str.appendUnattributed(') '); str.appendUnattributed('and control over OpenType features such as ligatures (with a suitable font - for instance, '); -const otf = new libui.UiOpenTypeFeatures(); +const otf = new libui.OpenTypeFeatures(); otf.add('liga', 0); -str.appendAttributed('affix', UiFontAttribute.newOTFeatures(otf)); +str.appendAttributed('affix', FontAttribute.newOTFeatures(otf)); str.appendUnattributed(' vs. '); otf.add('liga', 1); -str.appendAttributed('affix', UiFontAttribute.newOTFeatures(otf)); +str.appendAttributed('affix', FontAttribute.newOTFeatures(otf)); otf.forEach((feat, str, val) => { console.log({feat, str, val}); @@ -79,7 +79,7 @@ str.forEach((str, attr, start, end) => { function handlerDraw(area, p) { const font = checkbox.checked ? - new libui.UiFontDescriptor('Georgia', 14, libui.textWeight.normal, libui.textItalic.normal, libui.textStretch.normal) : + new libui.FontDescriptor('Georgia', 14, libui.textWeight.normal, libui.textItalic.normal, libui.textStretch.normal) : fontButton.getFont(); const layout = new libui.DrawTextLayout(str, font, p.getAreaWidth(), align.getSelected()); diff --git a/index.js b/index.js index 3e863de..315b66d 100755 --- a/index.js +++ b/index.js @@ -149,20 +149,20 @@ const forEach = { stop: 1 }; -binding.lib.UiAttributedString.prototype.appendAttributed = function (str, attr, attr2) { +binding.lib.AttributedString.prototype.appendAttributed = function (str, attr, attr2) { if (attr2) { return this.appendAttributed2(str, attr, attr2); } return this.appendAttributed1(str, attr); }; -binding.lib.UiFontAttribute.newUnderlineColor = function (type, color){ - if(type === textUnderlineColor.custom && !color){ - console.error("With textUnderlineColor.custom a color needs to passed"); +binding.lib.FontAttribute.newUnderlineColor = function (type, color) { + if (type === textUnderlineColor.custom && !color) { + console.error('With textUnderlineColor.custom a color needs to passed'); } color = color || new Color(0, 0, 0, 0); - return binding.lib.UiFontAttribute.newUnderlineColor2(type, color); -} + return binding.lib.FontAttribute.newUnderlineColor2(type, color); +}; module.exports.textWeight = textWeight; module.exports.textItalic = textItalic; diff --git a/src/Font/AttributedString.cc b/src/Font/AttributedString.cc new file mode 100644 index 0000000..62107ab --- /dev/null +++ b/src/Font/AttributedString.cc @@ -0,0 +1,107 @@ +#include "../../ui.h" +#include "../ui-node.h" +#include "nbind/nbind.h" + +AttributedString::AttributedString(uiAttributedString *str) { + s = str; +} + +AttributedString::AttributedString(const char *str) { + s = uiNewAttributedString(str); +} + +void AttributedString::free() { + uiFreeAttributedString(s); +} + +uiAttributedString *AttributedString::getHandle() { + return s; +} + +const char * AttributedString::toString() { + return uiAttributedStringString(s); +} + +size_t AttributedString::toStringLen() { + return uiAttributedStringLen(s); +} + +void AttributedString::appendUnattributed(const char *str) { + uiAttributedStringAppendUnattributed(s, str); +} + +void AttributedString::insertUnattributed(const char *str, size_t at) { + uiAttributedStringInsertAtUnattributed(s, str, at); +} + +void AttributedString::deleteString(size_t start, size_t end) { + uiAttributedStringDelete(s, start, end); +} + +void AttributedString::setAttribute(FontAttribute *attr, size_t start, size_t end) { + uiAttributedStringSetAttribute(s, attr->getHandle(), start, end); + attr->setAppended(); +} + +static unsigned int AttributedString__forEach(const uiAttributedString *s, const uiAttribute *a, size_t start, size_t end, void *data) { + nbind::cbFunction *cb = (nbind::cbFunction *) data; + + return cb->call( + AttributedString((uiAttributedString*)s), + FontAttribute((uiAttribute*)a), + start, end); +} + +void AttributedString::forEach(nbind::cbFunction& cb) { + uiAttributedStringForEachAttribute(s, AttributedString__forEach, &cb); +} + + + +void AttributedString::appendAttributed(const char *str, FontAttribute *attr) { + this->appendAttributed(str, attr, nullptr); +} + + +void AttributedString::appendAttributed(const char *str, FontAttribute *attr, FontAttribute *attr2) { + size_t start = this->toStringLen(); + // TODO how this (and strlen) work with unicode? + size_t end = start + strlen(str); + + this->appendUnattributed(str); + this->setAttribute(attr, start, end); + if(attr2 != nullptr){ + this->setAttribute(attr2, start, end); + } +} + + +size_t AttributedString::numGraphemes() { + return uiAttributedStringNumGraphemes(s); +} + +size_t AttributedString::byteIndexToGrapheme(size_t pos) { + return uiAttributedStringByteIndexToGrapheme(s, pos); +} + +size_t AttributedString::graphemeToByteIndex(size_t pos) { + return uiAttributedStringGraphemeToByteIndex(s, pos); +} + +NBIND_CLASS(AttributedString) { + construct(); + method(free); + method(toString); + method(toStringLen); + method(appendUnattributed); + method(insertUnattributed); + method(forEach); + multimethod(appendAttributed, args(const char *, FontAttribute *), "appendAttributed1"); + multimethod(appendAttributed, args(const char *, FontAttribute *, FontAttribute *), "appendAttributed2"); + method(deleteString); + method(setAttribute); + + method(numGraphemes); + method(byteIndexToGrapheme); + method(graphemeToByteIndex); +} diff --git a/src/Font/FontAttribute.cc b/src/Font/FontAttribute.cc new file mode 100644 index 0000000..e01a93d --- /dev/null +++ b/src/Font/FontAttribute.cc @@ -0,0 +1,148 @@ +#include "../../ui.h" +#include "../ui-node.h" +#include "nbind/nbind.h" + +FontAttribute::FontAttribute(uiAttribute *attr){ + a = attr; +} + +int FontAttribute::getAttributeType() { + return uiAttributeGetType(a); +} + +uiAttribute *FontAttribute::getHandle() { + return a; +} + +void FontAttribute::free(){ + if(!appended){ + uiFreeAttribute(a); + } +} + +void FontAttribute::setAppended(){ + appended = 1; +} + +const char *FontAttribute::getFamily() { + return uiAttributeFamily(a); +} + +double FontAttribute::getSize() { + return uiAttributeSize(a); +} + +int FontAttribute::getWeight() { + return uiAttributeWeight(a); +} + +int FontAttribute::getItalic() { + return uiAttributeItalic(a); +} + +int FontAttribute::getStretch() { + return uiAttributeStretch(a); +} + +Color FontAttribute::getColor() { + double r; + double g; + double b; + double alpha; + + uiAttributeColor(a, &r, &g, &b, &alpha); + + return Color(r, g, b, alpha); +} + +int FontAttribute::getUnderline() { + return uiAttributeUnderline(a); +} + +int FontAttribute::getUnderlineColor(Color *c) { + double r; + double g; + double b; + double alpha; + + uiUnderlineColor type; + uiAttributeUnderlineColor(a, &type, &r, &g, &b, &alpha); + c->setR(r); + c->setG(g); + c->setB(b); + c->setA(alpha); + + return type; +} + +OpenTypeFeatures *FontAttribute::getOTFeatures() { + return new OpenTypeFeatures((uiOpenTypeFeatures*) uiAttributeFeatures(a)); +} + + + +FontAttribute *FontAttribute::newFamily(const char *family) { + return new FontAttribute(uiNewFamilyAttribute(family)); +} + +FontAttribute *FontAttribute::newSize(double size) { + return new FontAttribute(uiNewSizeAttribute(size)); +} + +FontAttribute *FontAttribute::newWeight(int weightAttribute) { + return new FontAttribute(uiNewWeightAttribute(weightAttribute)); +} + +FontAttribute *FontAttribute::newItalic(int italicAttribute) { + return new FontAttribute(uiNewItalicAttribute(italicAttribute)); +} + +FontAttribute *FontAttribute::newStretch(int stretchAttribute) { + return new FontAttribute(uiNewStretchAttribute(stretchAttribute)); +} + +FontAttribute *FontAttribute::newColor(Color c) { + return new FontAttribute(uiNewColorAttribute(c.getR(), c.getG(), c.getB(), c.getA())); +} + +FontAttribute *FontAttribute::newBackground(Color c) { + return new FontAttribute(uiNewBackgroundAttribute(c.getR(), c.getG(), c.getB(), c.getA())); +} + +FontAttribute *FontAttribute::newUnderline(int underlineAttr) { + return new FontAttribute(uiNewUnderlineAttribute(underlineAttr)); +} + +FontAttribute *FontAttribute::newUnderlineColor2(int underlineColorAttr, Color c) { + return new FontAttribute(uiNewUnderlineColorAttribute(underlineColorAttr, c.getR(), c.getG(), c.getB(), c.getA())); +} + +FontAttribute *FontAttribute::newOTFeatures(OpenTypeFeatures *otf) { + return new FontAttribute(uiNewFeaturesAttribute(otf->getHandle())); +} + + +NBIND_CLASS(FontAttribute) { + method(free); + method(getAttributeType); + + method(getFamily); + method(getSize); + method(getWeight); + method(getItalic); + method(getStretch); + method(getColor); + method(getUnderline); + method(getUnderlineColor); + + method(newFamily); + method(newSize); + method(newWeight); + method(newItalic); + method(newStretch); + method(newColor); + method(newBackground); + method(newUnderline); + method(newUnderlineColor2); + method(newOTFeatures); +} diff --git a/src/Font/UiFontDescriptor.cc b/src/Font/FontDescriptor.cc similarity index 61% rename from src/Font/UiFontDescriptor.cc rename to src/Font/FontDescriptor.cc index 81b569e..53fe453 100644 --- a/src/Font/UiFontDescriptor.cc +++ b/src/Font/FontDescriptor.cc @@ -3,12 +3,12 @@ #include "nbind/nbind.h" #include -UiFontDescriptor::UiFontDescriptor(uiFontDescriptor * desc) { +FontDescriptor::FontDescriptor(uiFontDescriptor * desc) { d = desc; buttonCleanup = 1; } -UiFontDescriptor::UiFontDescriptor(const char *family, double size, int weight, int italic, int stretch) { +FontDescriptor::FontDescriptor(const char *family, double size, int weight, int italic, int stretch) { d = new uiFontDescriptor(); d->Family = new char[std::strlen(family) + 1]; @@ -19,7 +19,7 @@ UiFontDescriptor::UiFontDescriptor(const char *family, double size, int weight, d->Stretch = stretch; } -void UiFontDescriptor::free() { +void FontDescriptor::free() { if(buttonCleanup){ uiFreeFontButtonFont(d); } else { @@ -28,32 +28,32 @@ void UiFontDescriptor::free() { delete d; } -char *UiFontDescriptor::getFamily() { +char *FontDescriptor::getFamily() { return d->Family; } -double UiFontDescriptor::getSize() { +double FontDescriptor::getSize() { return d->Size; } -int UiFontDescriptor::getWeight() { +int FontDescriptor::getWeight() { return d->Weight; } -int UiFontDescriptor::getItalic() { +int FontDescriptor::getItalic() { return d->Italic; } -int UiFontDescriptor::getStretch() { +int FontDescriptor::getStretch() { return d->Stretch; } -uiFontDescriptor *UiFontDescriptor::getHandle(){ +uiFontDescriptor *FontDescriptor::getHandle(){ return d; } -NBIND_CLASS(UiFontDescriptor) { +NBIND_CLASS(FontDescriptor) { construct(); method(free); method(getFamily); diff --git a/src/Font/OpenTypeFeatures.cc b/src/Font/OpenTypeFeatures.cc new file mode 100644 index 0000000..720fd4f --- /dev/null +++ b/src/Font/OpenTypeFeatures.cc @@ -0,0 +1,57 @@ +#include "../../ui.h" +#include "../ui-node.h" +#include "nbind/nbind.h" + +OpenTypeFeatures::OpenTypeFeatures(uiOpenTypeFeatures *feat) { + f = feat; +} + +OpenTypeFeatures::OpenTypeFeatures() { + f = uiNewOpenTypeFeatures(); +} + +void OpenTypeFeatures::free() { + uiFreeOpenTypeFeatures(f); +} + +uiOpenTypeFeatures *OpenTypeFeatures::getHandle() { + return f; +} + +OpenTypeFeatures *OpenTypeFeatures::clone(OpenTypeFeatures *f2) { + return new OpenTypeFeatures(uiOpenTypeFeaturesClone(f2->f)); +} + +void OpenTypeFeatures::add(const char *tag, uint32_t value) { + uiOpenTypeFeaturesAdd(f, tag[0], tag[1], tag[2], tag[3], value); +} + +void OpenTypeFeatures::remove(const char *tag) { + uiOpenTypeFeaturesRemove(f, tag[0], tag[1], tag[2], tag[3]); +} + +int OpenTypeFeatures::get(const char *tag, uint32_t *value) { + return uiOpenTypeFeaturesGet(f, tag[0], tag[1], tag[2], tag[3], value); +} + +static unsigned int OpenTypeFeatures__forEach(const uiOpenTypeFeatures *otf, char a, char b, char c, char d, uint32_t value, void *data) { + const char tag[5] = {a, b, c, d, '\0'}; + nbind::cbFunction *cb = (nbind::cbFunction *) data; + return cb->call( + OpenTypeFeatures((uiOpenTypeFeatures*)otf), + &tag[0], value); +} + +void OpenTypeFeatures::forEach(nbind::cbFunction& cb) { + uiOpenTypeFeaturesForEach(f, OpenTypeFeatures__forEach, &cb); +} + +NBIND_CLASS(OpenTypeFeatures) { + construct<>(); + method(free); + method(clone); + method(add); + method(remove); + method(get); + method(forEach); +} diff --git a/src/Font/UiAttributedString.cc b/src/Font/UiAttributedString.cc deleted file mode 100644 index 881ff3c..0000000 --- a/src/Font/UiAttributedString.cc +++ /dev/null @@ -1,107 +0,0 @@ -#include "../../ui.h" -#include "../ui-node.h" -#include "nbind/nbind.h" - -UiAttributedString::UiAttributedString(uiAttributedString *str) { - s = str; -} - -UiAttributedString::UiAttributedString(const char *str) { - s = uiNewAttributedString(str); -} - -void UiAttributedString::free() { - uiFreeAttributedString(s); -} - -uiAttributedString *UiAttributedString::getHandle() { - return s; -} - -const char * UiAttributedString::toString() { - return uiAttributedStringString(s); -} - -size_t UiAttributedString::toStringLen() { - return uiAttributedStringLen(s); -} - -void UiAttributedString::appendUnattributed(const char *str) { - uiAttributedStringAppendUnattributed(s, str); -} - -void UiAttributedString::insertUnattributed(const char *str, size_t at) { - uiAttributedStringInsertAtUnattributed(s, str, at); -} - -void UiAttributedString::deleteString(size_t start, size_t end) { - uiAttributedStringDelete(s, start, end); -} - -void UiAttributedString::setAttribute(UiFontAttribute *attr, size_t start, size_t end) { - uiAttributedStringSetAttribute(s, attr->getHandle(), start, end); - attr->setAppended(); -} - -static unsigned int UiAttributedString__forEach(const uiAttributedString *s, const uiAttribute *a, size_t start, size_t end, void *data) { - nbind::cbFunction *cb = (nbind::cbFunction *) data; - - return cb->call( - UiAttributedString((uiAttributedString*)s), - UiFontAttribute((uiAttribute*)a), - start, end); -} - -void UiAttributedString::forEach(nbind::cbFunction& cb) { - uiAttributedStringForEachAttribute(s, UiAttributedString__forEach, &cb); -} - - - -void UiAttributedString::appendAttributed(const char *str, UiFontAttribute *attr) { - this->appendAttributed(str, attr, nullptr); -} - - -void UiAttributedString::appendAttributed(const char *str, UiFontAttribute *attr, UiFontAttribute *attr2) { - size_t start = this->toStringLen(); - // TODO how this (and strlen) work with unicode? - size_t end = start + strlen(str); - - this->appendUnattributed(str); - this->setAttribute(attr, start, end); - if(attr2 != nullptr){ - this->setAttribute(attr2, start, end); - } -} - - -size_t UiAttributedString::numGraphemes() { - return uiAttributedStringNumGraphemes(s); -} - -size_t UiAttributedString::byteIndexToGrapheme(size_t pos) { - return uiAttributedStringByteIndexToGrapheme(s, pos); -} - -size_t UiAttributedString::graphemeToByteIndex(size_t pos) { - return uiAttributedStringGraphemeToByteIndex(s, pos); -} - -NBIND_CLASS(UiAttributedString) { - construct(); - method(free); - method(toString); - method(toStringLen); - method(appendUnattributed); - method(insertUnattributed); - method(forEach); - multimethod(appendAttributed, args(const char *, UiFontAttribute *), "appendAttributed1"); - multimethod(appendAttributed, args(const char *, UiFontAttribute *, UiFontAttribute *), "appendAttributed2"); - method(deleteString); - method(setAttribute); - - method(numGraphemes); - method(byteIndexToGrapheme); - method(graphemeToByteIndex); -} diff --git a/src/Font/UiFontAttribute.cc b/src/Font/UiFontAttribute.cc deleted file mode 100644 index cae10d7..0000000 --- a/src/Font/UiFontAttribute.cc +++ /dev/null @@ -1,148 +0,0 @@ -#include "../../ui.h" -#include "../ui-node.h" -#include "nbind/nbind.h" - -UiFontAttribute::UiFontAttribute(uiAttribute *attr){ - a = attr; -} - -int UiFontAttribute::getAttributeType() { - return uiAttributeGetType(a); -} - -uiAttribute *UiFontAttribute::getHandle() { - return a; -} - -void UiFontAttribute::free(){ - if(!appended){ - uiFreeAttribute(a); - } -} - -void UiFontAttribute::setAppended(){ - appended = 1; -} - -const char *UiFontAttribute::getFamily() { - return uiAttributeFamily(a); -} - -double UiFontAttribute::getSize() { - return uiAttributeSize(a); -} - -int UiFontAttribute::getWeight() { - return uiAttributeWeight(a); -} - -int UiFontAttribute::getItalic() { - return uiAttributeItalic(a); -} - -int UiFontAttribute::getStretch() { - return uiAttributeStretch(a); -} - -Color UiFontAttribute::getColor() { - double r; - double g; - double b; - double alpha; - - uiAttributeColor(a, &r, &g, &b, &alpha); - - return Color(r, g, b, alpha); -} - -int UiFontAttribute::getUnderline() { - return uiAttributeUnderline(a); -} - -int UiFontAttribute::getUnderlineColor(Color *c) { - double r; - double g; - double b; - double alpha; - - uiUnderlineColor type; - uiAttributeUnderlineColor(a, &type, &r, &g, &b, &alpha); - c->setR(r); - c->setG(g); - c->setB(b); - c->setA(alpha); - - return type; -} - -UiOpenTypeFeatures *UiFontAttribute::getOTFeatures() { - return new UiOpenTypeFeatures((uiOpenTypeFeatures*) uiAttributeFeatures(a)); -} - - - -UiFontAttribute *UiFontAttribute::newFamily(const char *family) { - return new UiFontAttribute(uiNewFamilyAttribute(family)); -} - -UiFontAttribute *UiFontAttribute::newSize(double size) { - return new UiFontAttribute(uiNewSizeAttribute(size)); -} - -UiFontAttribute *UiFontAttribute::newWeight(int weightAttribute) { - return new UiFontAttribute(uiNewWeightAttribute(weightAttribute)); -} - -UiFontAttribute *UiFontAttribute::newItalic(int italicAttribute) { - return new UiFontAttribute(uiNewItalicAttribute(italicAttribute)); -} - -UiFontAttribute *UiFontAttribute::newStretch(int stretchAttribute) { - return new UiFontAttribute(uiNewStretchAttribute(stretchAttribute)); -} - -UiFontAttribute *UiFontAttribute::newColor(Color c) { - return new UiFontAttribute(uiNewColorAttribute(c.getR(), c.getG(), c.getB(), c.getA())); -} - -UiFontAttribute *UiFontAttribute::newBackground(Color c) { - return new UiFontAttribute(uiNewBackgroundAttribute(c.getR(), c.getG(), c.getB(), c.getA())); -} - -UiFontAttribute *UiFontAttribute::newUnderline(int underlineAttr) { - return new UiFontAttribute(uiNewUnderlineAttribute(underlineAttr)); -} - -UiFontAttribute *UiFontAttribute::newUnderlineColor2(int underlineColorAttr, Color c) { - return new UiFontAttribute(uiNewUnderlineColorAttribute(underlineColorAttr, c.getR(), c.getG(), c.getB(), c.getA())); -} - -UiFontAttribute *UiFontAttribute::newOTFeatures(UiOpenTypeFeatures *otf) { - return new UiFontAttribute(uiNewFeaturesAttribute(otf->getHandle())); -} - - -NBIND_CLASS(UiFontAttribute) { - method(free); - method(getAttributeType); - - method(getFamily); - method(getSize); - method(getWeight); - method(getItalic); - method(getStretch); - method(getColor); - method(getUnderline); - method(getUnderlineColor); - - method(newFamily); - method(newSize); - method(newWeight); - method(newItalic); - method(newStretch); - method(newColor); - method(newBackground); - method(newUnderline); - method(newUnderlineColor2); - method(newOTFeatures); -} diff --git a/src/Font/UiOpenTypeFeatures.cc b/src/Font/UiOpenTypeFeatures.cc deleted file mode 100644 index 4cce17b..0000000 --- a/src/Font/UiOpenTypeFeatures.cc +++ /dev/null @@ -1,57 +0,0 @@ -#include "../../ui.h" -#include "../ui-node.h" -#include "nbind/nbind.h" - -UiOpenTypeFeatures::UiOpenTypeFeatures(uiOpenTypeFeatures *feat) { - f = feat; -} - -UiOpenTypeFeatures::UiOpenTypeFeatures() { - f = uiNewOpenTypeFeatures(); -} - -void UiOpenTypeFeatures::free() { - uiFreeOpenTypeFeatures(f); -} - -uiOpenTypeFeatures *UiOpenTypeFeatures::getHandle() { - return f; -} - -UiOpenTypeFeatures *UiOpenTypeFeatures::clone(UiOpenTypeFeatures *f2) { - return new UiOpenTypeFeatures(uiOpenTypeFeaturesClone(f2->f)); -} - -void UiOpenTypeFeatures::add(const char *tag, uint32_t value) { - uiOpenTypeFeaturesAdd(f, tag[0], tag[1], tag[2], tag[3], value); -} - -void UiOpenTypeFeatures::remove(const char *tag) { - uiOpenTypeFeaturesRemove(f, tag[0], tag[1], tag[2], tag[3]); -} - -int UiOpenTypeFeatures::get(const char *tag, uint32_t *value) { - return uiOpenTypeFeaturesGet(f, tag[0], tag[1], tag[2], tag[3], value); -} - -static unsigned int UiOpenTypeFeatures__forEach(const uiOpenTypeFeatures *otf, char a, char b, char c, char d, uint32_t value, void *data) { - const char tag[5] = {a, b, c, d, '\0'}; - nbind::cbFunction *cb = (nbind::cbFunction *) data; - return cb->call( - UiOpenTypeFeatures((uiOpenTypeFeatures*)otf), - &tag[0], value); -} - -void UiOpenTypeFeatures::forEach(nbind::cbFunction& cb) { - uiOpenTypeFeaturesForEach(f, UiOpenTypeFeatures__forEach, &cb); -} - -NBIND_CLASS(UiOpenTypeFeatures) { - construct<>(); - method(free); - method(clone); - method(add); - method(remove); - method(get); - method(forEach); -} diff --git a/src/UiArea/DrawTextLayout.cc b/src/UiArea/DrawTextLayout.cc index 168c6a3..8d91c7c 100644 --- a/src/UiArea/DrawTextLayout.cc +++ b/src/UiArea/DrawTextLayout.cc @@ -2,7 +2,7 @@ #include "../ui-node.h" #include "nbind/nbind.h" -DrawTextLayout::DrawTextLayout(UiAttributedString *str, UiFontDescriptor *defaultFont, double width, int align) { +DrawTextLayout::DrawTextLayout(AttributedString *str, FontDescriptor *defaultFont, double width, int align) { uiDrawTextLayoutParams params = { str->getHandle(), defaultFont->getHandle(), @@ -29,7 +29,7 @@ SizeDouble DrawTextLayout::getExtents() { } NBIND_CLASS(DrawTextLayout) { - construct(); + construct(); method(free); method(getExtents); } diff --git a/src/UiFontButton.cc b/src/UiFontButton.cc index b27ab7b..86f8f1d 100644 --- a/src/UiFontButton.cc +++ b/src/UiFontButton.cc @@ -9,10 +9,10 @@ INHERITS_CONTROL_METHODS(UiFontButton) IMPLEMENT_EVENT(UiFontButton, uiFontButton, onChanged, uiFontButtonOnChanged) -UiFontDescriptor* UiFontButton::getFont() { +FontDescriptor* UiFontButton::getFont() { uiFontDescriptor *desc = new uiFontDescriptor(); uiFontButtonFont((uiFontButton*)getHandle(), desc); - return new UiFontDescriptor(desc); + return new FontDescriptor(desc); } NBIND_CLASS(UiFontButton) { diff --git a/src/ui-node.h b/src/ui-node.h index 35165ba..9a7e119 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -635,16 +635,16 @@ class UiDrawPath { void end(); }; -class UiOpenTypeFeatures { +class OpenTypeFeatures { private: uiOpenTypeFeatures *f; public: - UiOpenTypeFeatures(); - UiOpenTypeFeatures(uiOpenTypeFeatures *feat); + OpenTypeFeatures(); + OpenTypeFeatures(uiOpenTypeFeatures *feat); void free(); uiOpenTypeFeatures *getHandle(); - static UiOpenTypeFeatures *clone(UiOpenTypeFeatures *f2); + static OpenTypeFeatures *clone(OpenTypeFeatures *f2); void add(const char *tag, uint32_t value); void remove(const char *tag); int get(const char *tag, uint32_t *value); @@ -653,13 +653,13 @@ class UiOpenTypeFeatures { }; -class UiFontAttribute { +class FontAttribute { private: uiAttribute* a; int appended = 0; public: - UiFontAttribute(uiAttribute *a); + FontAttribute(uiAttribute *a); void free(); void setAppended(); int getAttributeType(); @@ -675,27 +675,27 @@ class UiFontAttribute { Color getColor(); int getUnderline(); int getUnderlineColor(Color *c); - UiOpenTypeFeatures *getOTFeatures(); + OpenTypeFeatures *getOTFeatures(); - static UiFontAttribute *newFamily(const char *family); - static UiFontAttribute *newSize(double size); - static UiFontAttribute *newWeight(int weightAttribute); - static UiFontAttribute *newItalic(int italicAttribute); - static UiFontAttribute *newStretch(int stretchAttribute); - static UiFontAttribute *newColor(Color c); - static UiFontAttribute *newBackground(Color c); - static UiFontAttribute *newUnderline(int underlineAttr); - static UiFontAttribute *newUnderlineColor2(int underlineColorAttr, Color c); - static UiFontAttribute *newOTFeatures(UiOpenTypeFeatures *otf); + static FontAttribute *newFamily(const char *family); + static FontAttribute *newSize(double size); + static FontAttribute *newWeight(int weightAttribute); + static FontAttribute *newItalic(int italicAttribute); + static FontAttribute *newStretch(int stretchAttribute); + static FontAttribute *newColor(Color c); + static FontAttribute *newBackground(Color c); + static FontAttribute *newUnderline(int underlineAttr); + static FontAttribute *newUnderlineColor2(int underlineColorAttr, Color c); + static FontAttribute *newOTFeatures(OpenTypeFeatures *otf); }; -class UiAttributedString { +class AttributedString { private: uiAttributedString* s; public: - UiAttributedString(uiAttributedString *str); - UiAttributedString(const char *str); + AttributedString(uiAttributedString *str); + AttributedString(const char *str); void free(); uiAttributedString *getHandle(); const char * toString(); @@ -704,10 +704,10 @@ class UiAttributedString { void appendUnattributed(const char *str); void insertUnattributed(const char *str, size_t at); void deleteString(size_t start, size_t end); - void setAttribute(UiFontAttribute *attr, size_t start, size_t end); + void setAttribute(FontAttribute *attr, size_t start, size_t end); - void appendAttributed(const char *str, UiFontAttribute *attr); - void appendAttributed(const char *str, UiFontAttribute *attr, UiFontAttribute *attr2); + void appendAttributed(const char *str, FontAttribute *attr); + void appendAttributed(const char *str, FontAttribute *attr, FontAttribute *attr2); // TODO multiple attr? does nbind support variadic arguments? or use array? void forEach(nbind::cbFunction& cb); @@ -718,13 +718,13 @@ class UiAttributedString { }; -class UiFontDescriptor { +class FontDescriptor { private: uiFontDescriptor *d; int buttonCleanup = 0; public: - UiFontDescriptor(uiFontDescriptor *d); - UiFontDescriptor(const char *family, double size, int weight, int italic, int stretch); + FontDescriptor(uiFontDescriptor *d); + FontDescriptor(const char *family, double size, int weight, int italic, int stretch); void free(); char *getFamily(); double getSize(); @@ -739,7 +739,7 @@ class UiFontButton : public UiControl { public: UiFontButton(); - UiFontDescriptor* getFont(); + FontDescriptor* getFont(); DEFINE_CONTROL_METHODS() }; @@ -749,7 +749,7 @@ class DrawTextLayout { uiDrawTextLayout* handle; public: - DrawTextLayout(UiAttributedString *s, UiFontDescriptor *defaultFont, double width, int align); + DrawTextLayout(AttributedString *s, FontDescriptor *defaultFont, double width, int align); void free(); SizeDouble getExtents(); uiDrawTextLayout* getHandle(); From 2b3a9581719b031a14b89dfdd93cbffd1df30dc1 Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Mon, 9 Apr 2018 23:52:34 +0200 Subject: [PATCH 075/190] Fix memory leaks --- docs/attributedstring.md | 52 ++++++++++++++++++------------------ src/Font/FontAttribute.cc | 44 +++++++++++++++--------------- src/Font/OpenTypeFeatures.cc | 4 +-- src/UiFontButton.cc | 4 +-- src/ui-node.h | 26 +++++++++--------- 5 files changed, 65 insertions(+), 65 deletions(-) diff --git a/docs/attributedstring.md b/docs/attributedstring.md index 874bf09..31409d3 100644 --- a/docs/attributedstring.md +++ b/docs/attributedstring.md @@ -1,12 +1,12 @@ # AttributedString ```cpp -class UiOpenTypeFeatures { +class OpenTypeFeatures { public: - UiOpenTypeFeatures(); + OpenTypeFeatures(); void free(); - static UiOpenTypeFeatures *clone(UiOpenTypeFeatures *f2); + static OpenTypeFeatures clone(OpenTypeFeatures *f2); void add(const char *tag, uint32_t value); void remove(const char *tag); // uiOpenTypeFeaturesGet() determines whether the given feature @@ -23,11 +23,11 @@ class UiOpenTypeFeatures { // be treated as having some unspecified default value. int get(const char *tag, uint32_t *value); - // cb(UiOpenTypeFeatures, tag, value) + // cb(OpenTypeFeatures, tag, value) void forEach(nbind::cbFunction& cb); }; -class UiFontAttribute { +class FontAttribute { public: // doesn't need to be called when appended void free(); @@ -42,23 +42,23 @@ class UiFontAttribute { Color getColor(); int getUnderline(); int getUnderlineColor(Color *c); - UiOpenTypeFeatures *getOTFeatures(); - - static UiFontAttribute *newFamily(const char *family); - static UiFontAttribute *newSize(double size); - static UiFontAttribute *newWeight(int weightAttribute); - static UiFontAttribute *newItalic(int italicAttribute); - static UiFontAttribute *newStretch(int stretchAttribute); - static UiFontAttribute *newColor(Color c); - static UiFontAttribute *newBackground(Color c); - static UiFontAttribute *newUnderline(int underlineAttr); - static UiFontAttribute *newUnderlineColor(int underlineColorAttr, Color c); - static UiFontAttribute *newOTFeatures(UiOpenTypeFeatures *otf); + OpenTypeFeatures *getOTFeatures(); + + static FontAttribute newFamily(const char *family); + static FontAttribute newSize(double size); + static FontAttribute newWeight(int weightAttribute); + static FontAttribute newItalic(int italicAttribute); + static FontAttribute newStretch(int stretchAttribute); + static FontAttribute newColor(Color c); + static FontAttribute newBackground(Color c); + static FontAttribute newUnderline(int underlineAttr); + static FontAttribute newUnderlineColor(int underlineColorAttr, Color c); + static FontAttribute newOTFeatures(OpenTypeFeatures *otf); }; -class UiAttributedString { - UiAttributedString(const char *str); +class AttributedString { + AttributedString(const char *str); void free(); const char * toString(); size_t toStringLen(); @@ -66,10 +66,10 @@ class UiAttributedString { void appendUnattributed(const char *str); void insertUnattributed(const char *str, size_t at); void deleteString(size_t start, size_t end); - void setAttribute(UiFontAttribute *attr, size_t start, size_t end); + void setAttribute(FontAttribute *attr, size_t start, size_t end); - void appendAttributed(const char *str, UiFontAttribute *attr); - void appendAttributed(const char *str, UiFontAttribute *attr, UiFontAttribute *attr2); + void appendAttributed(const char *str, FontAttribute *attr); + void appendAttributed(const char *str, FontAttribute *attr, FontAttribute *attr2); void forEach(nbind::cbFunction& cb); @@ -78,8 +78,8 @@ class UiAttributedString { size_t graphemeToByteIndex(size_t pos); }; -class UiFontDescriptor { - UiFontDescriptor(const char *family, double size, int weight, int italic, int stretch); +class FontDescriptor { + FontDescriptor(const char *family, double size, int weight, int italic, int stretch); void free(); char *getFamily(); double getSize(); @@ -91,14 +91,14 @@ class UiFontDescriptor { class UiFontButton : public UiControl { UiFontButton(); - UiFontDescriptor* getFont(); + FontDescriptor getFont(); // onChanged, default button }; class DrawTextLayout { public: - DrawTextLayout(UiAttributedString *s, UiFontDescriptor *defaultFont, double width, int align); + DrawTextLayout(AttributedString *s, FontDescriptor *defaultFont, double width, int align); void free(); SizeDouble getExtents(); uiDrawTextLayout* getHandle(); diff --git a/src/Font/FontAttribute.cc b/src/Font/FontAttribute.cc index e01a93d..c90a11e 100644 --- a/src/Font/FontAttribute.cc +++ b/src/Font/FontAttribute.cc @@ -75,50 +75,50 @@ int FontAttribute::getUnderlineColor(Color *c) { return type; } -OpenTypeFeatures *FontAttribute::getOTFeatures() { - return new OpenTypeFeatures((uiOpenTypeFeatures*) uiAttributeFeatures(a)); +OpenTypeFeatures FontAttribute::getOTFeatures() { + return OpenTypeFeatures((uiOpenTypeFeatures*) uiAttributeFeatures(a)); } -FontAttribute *FontAttribute::newFamily(const char *family) { - return new FontAttribute(uiNewFamilyAttribute(family)); +FontAttribute FontAttribute::newFamily(const char *family) { + return FontAttribute(uiNewFamilyAttribute(family)); } -FontAttribute *FontAttribute::newSize(double size) { - return new FontAttribute(uiNewSizeAttribute(size)); +FontAttribute FontAttribute::newSize(double size) { + return FontAttribute(uiNewSizeAttribute(size)); } -FontAttribute *FontAttribute::newWeight(int weightAttribute) { - return new FontAttribute(uiNewWeightAttribute(weightAttribute)); +FontAttribute FontAttribute::newWeight(int weightAttribute) { + return FontAttribute(uiNewWeightAttribute(weightAttribute)); } -FontAttribute *FontAttribute::newItalic(int italicAttribute) { - return new FontAttribute(uiNewItalicAttribute(italicAttribute)); +FontAttribute FontAttribute::newItalic(int italicAttribute) { + return FontAttribute(uiNewItalicAttribute(italicAttribute)); } -FontAttribute *FontAttribute::newStretch(int stretchAttribute) { - return new FontAttribute(uiNewStretchAttribute(stretchAttribute)); +FontAttribute FontAttribute::newStretch(int stretchAttribute) { + return FontAttribute(uiNewStretchAttribute(stretchAttribute)); } -FontAttribute *FontAttribute::newColor(Color c) { - return new FontAttribute(uiNewColorAttribute(c.getR(), c.getG(), c.getB(), c.getA())); +FontAttribute FontAttribute::newColor(Color c) { + return FontAttribute(uiNewColorAttribute(c.getR(), c.getG(), c.getB(), c.getA())); } -FontAttribute *FontAttribute::newBackground(Color c) { - return new FontAttribute(uiNewBackgroundAttribute(c.getR(), c.getG(), c.getB(), c.getA())); +FontAttribute FontAttribute::newBackground(Color c) { + return FontAttribute(uiNewBackgroundAttribute(c.getR(), c.getG(), c.getB(), c.getA())); } -FontAttribute *FontAttribute::newUnderline(int underlineAttr) { - return new FontAttribute(uiNewUnderlineAttribute(underlineAttr)); +FontAttribute FontAttribute::newUnderline(int underlineAttr) { + return FontAttribute(uiNewUnderlineAttribute(underlineAttr)); } -FontAttribute *FontAttribute::newUnderlineColor2(int underlineColorAttr, Color c) { - return new FontAttribute(uiNewUnderlineColorAttribute(underlineColorAttr, c.getR(), c.getG(), c.getB(), c.getA())); +FontAttribute FontAttribute::newUnderlineColor2(int underlineColorAttr, Color c) { + return FontAttribute(uiNewUnderlineColorAttribute(underlineColorAttr, c.getR(), c.getG(), c.getB(), c.getA())); } -FontAttribute *FontAttribute::newOTFeatures(OpenTypeFeatures *otf) { - return new FontAttribute(uiNewFeaturesAttribute(otf->getHandle())); +FontAttribute FontAttribute::newOTFeatures(OpenTypeFeatures *otf) { + return FontAttribute(uiNewFeaturesAttribute(otf->getHandle())); } diff --git a/src/Font/OpenTypeFeatures.cc b/src/Font/OpenTypeFeatures.cc index 720fd4f..4ad0e98 100644 --- a/src/Font/OpenTypeFeatures.cc +++ b/src/Font/OpenTypeFeatures.cc @@ -18,8 +18,8 @@ uiOpenTypeFeatures *OpenTypeFeatures::getHandle() { return f; } -OpenTypeFeatures *OpenTypeFeatures::clone(OpenTypeFeatures *f2) { - return new OpenTypeFeatures(uiOpenTypeFeaturesClone(f2->f)); +OpenTypeFeatures OpenTypeFeatures::clone(OpenTypeFeatures *f2) { + return OpenTypeFeatures(uiOpenTypeFeaturesClone(f2->f)); } void OpenTypeFeatures::add(const char *tag, uint32_t value) { diff --git a/src/UiFontButton.cc b/src/UiFontButton.cc index 86f8f1d..4f8d9de 100644 --- a/src/UiFontButton.cc +++ b/src/UiFontButton.cc @@ -9,10 +9,10 @@ INHERITS_CONTROL_METHODS(UiFontButton) IMPLEMENT_EVENT(UiFontButton, uiFontButton, onChanged, uiFontButtonOnChanged) -FontDescriptor* UiFontButton::getFont() { +FontDescriptor UiFontButton::getFont() { uiFontDescriptor *desc = new uiFontDescriptor(); uiFontButtonFont((uiFontButton*)getHandle(), desc); - return new FontDescriptor(desc); + return FontDescriptor(desc); } NBIND_CLASS(UiFontButton) { diff --git a/src/ui-node.h b/src/ui-node.h index 9a7e119..f62dd9c 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -644,7 +644,7 @@ class OpenTypeFeatures { void free(); uiOpenTypeFeatures *getHandle(); - static OpenTypeFeatures *clone(OpenTypeFeatures *f2); + static OpenTypeFeatures clone(OpenTypeFeatures *f2); void add(const char *tag, uint32_t value); void remove(const char *tag); int get(const char *tag, uint32_t *value); @@ -675,18 +675,18 @@ class FontAttribute { Color getColor(); int getUnderline(); int getUnderlineColor(Color *c); - OpenTypeFeatures *getOTFeatures(); + OpenTypeFeatures getOTFeatures(); - static FontAttribute *newFamily(const char *family); - static FontAttribute *newSize(double size); - static FontAttribute *newWeight(int weightAttribute); - static FontAttribute *newItalic(int italicAttribute); - static FontAttribute *newStretch(int stretchAttribute); - static FontAttribute *newColor(Color c); - static FontAttribute *newBackground(Color c); - static FontAttribute *newUnderline(int underlineAttr); - static FontAttribute *newUnderlineColor2(int underlineColorAttr, Color c); - static FontAttribute *newOTFeatures(OpenTypeFeatures *otf); + static FontAttribute newFamily(const char *family); + static FontAttribute newSize(double size); + static FontAttribute newWeight(int weightAttribute); + static FontAttribute newItalic(int italicAttribute); + static FontAttribute newStretch(int stretchAttribute); + static FontAttribute newColor(Color c); + static FontAttribute newBackground(Color c); + static FontAttribute newUnderline(int underlineAttr); + static FontAttribute newUnderlineColor2(int underlineColorAttr, Color c); + static FontAttribute newOTFeatures(OpenTypeFeatures *otf); }; @@ -739,7 +739,7 @@ class UiFontButton : public UiControl { public: UiFontButton(); - FontDescriptor* getFont(); + FontDescriptor getFont(); DEFINE_CONTROL_METHODS() }; From 8e21f34afdd19894a72ccd6fa9e71717ea295940 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Tue, 10 Apr 2018 23:04:33 +0200 Subject: [PATCH 076/190] [WIP] fixing leaks within container widgets --- examples/widgets/showUiSpinbox.js | 30 ++++++++++++++++++++---------- src/UiControl.cc | 10 +++++++++- src/UiSpinbox.cc | 21 +++++++++++++++++++++ src/UiWindow.cc | 13 ++++++++++--- src/includes/control.h | 4 +++- 5 files changed, 63 insertions(+), 15 deletions(-) diff --git a/examples/widgets/showUiSpinbox.js b/examples/widgets/showUiSpinbox.js index f9533bf..8b0eafd 100644 --- a/examples/widgets/showUiSpinbox.js +++ b/examples/widgets/showUiSpinbox.js @@ -1,19 +1,29 @@ /* eslint-disable unicorn/filename-case */ const libui = require('../..'); +function createWindow() { + const win = new libui.UiWindow('UiSpinbox example', 320, 60, true); -const win = new libui.UiWindow('UiSpinbox example', 320, 60, true); -win.margined = true; + win.margined = true; -const widget = new libui.UiSpinbox(); -widget.text = 'sample text'; -win.setChild(widget); + const widget = new libui.UiSpinbox(); + widget.value = 42; + widget.onChanged(() => { + console.log(`value changed`); + }); + win.setChild(widget); -win.onClosing(() => { - win.close(); - libui.Ui.quit(); -}); + win.onClosing(() => { + win.close(); + global.gc(); + libui.stopLoop(); + }); + return win; +} + +const win = createWindow(); win.show(); +global.gc(); -libui.Ui.main(); +libui.startLoop(); diff --git a/src/UiControl.cc b/src/UiControl.cc index 04f3626..eb30588 100644 --- a/src/UiControl.cc +++ b/src/UiControl.cc @@ -14,10 +14,18 @@ static void _uicontrol_onDestroy(uiControl *control) { wrapper->onDestroy(control); wrapper->originalDestroy(control); wrapper->destroyed = true; + controlsMap.erase(control); } void UiControl::onDestroy(uiControl *control) { - printf("Control %p destroyed with wrapper %p.\n", control, this); + // this method should be overriden + // in control classes to perform + // specific cleanup when natove control + // is destroyed by libui +} + +UiControl::~UiControl() { + // printf("Control %p destroyed with wrapper %p.\n", getHandle(), this); } UiControl::UiControl(uiControl *hnd) { diff --git a/src/UiSpinbox.cc b/src/UiSpinbox.cc index 11e9571..ae441ad 100644 --- a/src/UiSpinbox.cc +++ b/src/UiSpinbox.cc @@ -8,11 +8,32 @@ class UiSpinbox : public UiControl { public: UiSpinbox(int min, int max); UiSpinbox(); + ~UiSpinbox(); DEFINE_CONTROL_METHODS() int getValue(); void setValue(int value); + void onDestroy(uiControl *control) override; }; + +UiSpinbox::~UiSpinbox() { + printf("UiSpinbox %p destroyed with wrapper %p.\n", getHandle(), this); +} + +void UiSpinbox::onDestroy(uiControl *control) { + /* + freeing event callbacks to allow JS to garbage collect this class + when there are no references to it left in JS code. + */ + + printf("onDestroy called\n"); + if (onChangedCallback != nullptr) { + printf("free cb\n"); + delete onChangedCallback; + onChangedCallback = nullptr; + } +} + UiSpinbox::UiSpinbox(int min, int max) : UiControl((uiControl *)uiNewSpinbox(min, max)) {} diff --git a/src/UiWindow.cc b/src/UiWindow.cc index cf4faa3..3c3d68f 100644 --- a/src/UiWindow.cc +++ b/src/UiWindow.cc @@ -10,6 +10,10 @@ class UiWindow { private: uiWindow *win; + // this hold a reference to child control + // to avoid it being garbage collected + // until not destroyed. + std::shared_ptr child; public: UiWindow(std::string title, int width, int height, bool hasMenubar); @@ -18,7 +22,7 @@ class UiWindow { void close(); void setMargined(bool margined); bool getMargined(); - void setChild(UiControl *control); + void setChild(std::shared_ptr control); void setTitle(std::string title); std::string getTitle(); bool getFullscreen(); @@ -80,6 +84,8 @@ void UiWindow::close() { delete onContentSizeChangedCallback; onContentSizeChangedCallback = nullptr; } + + child = nullptr; } void UiWindow::setMargined(bool margined) { @@ -90,8 +96,9 @@ bool UiWindow::getMargined() { return uiWindowMargined(win); } -void UiWindow::setChild(UiControl *control) { - uiWindowSetChild(win, control->getHandle()); +void UiWindow::setChild(std::shared_ptr control) { + child = control; + uiWindowSetChild(win, control.get()->getHandle()); } void UiWindow::setTitle(std::string title) { diff --git a/src/includes/control.h b/src/includes/control.h index 755fd06..d4e0d5b 100644 --- a/src/includes/control.h +++ b/src/includes/control.h @@ -84,10 +84,12 @@ class UiControl { public: DestroyCb originalDestroy; bool destroyed; - void onDestroy(uiControl *); + virtual void onDestroy(uiControl *); uiControl *getHandle(); UiControl(uiControl *hnd); + ~UiControl(); + DEFINE_CONTROL_METHODS() }; From 7c06f926fd7fe1d7abb2c9c44de227ead0aa414d Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Tue, 10 Apr 2018 21:15:09 +0200 Subject: [PATCH 077/190] new example to check destroing of controls --- examples/check-control-destroy.js | 29 +++++++++++++++++++++++++++++ examples/widgets/showUiSpinbox.js | 28 +++++++++------------------- 2 files changed, 38 insertions(+), 19 deletions(-) create mode 100644 examples/check-control-destroy.js diff --git a/examples/check-control-destroy.js b/examples/check-control-destroy.js new file mode 100644 index 0000000..8b0eafd --- /dev/null +++ b/examples/check-control-destroy.js @@ -0,0 +1,29 @@ +/* eslint-disable unicorn/filename-case */ + +const libui = require('../..'); +function createWindow() { + const win = new libui.UiWindow('UiSpinbox example', 320, 60, true); + + win.margined = true; + + const widget = new libui.UiSpinbox(); + widget.value = 42; + widget.onChanged(() => { + console.log(`value changed`); + }); + win.setChild(widget); + + win.onClosing(() => { + win.close(); + global.gc(); + libui.stopLoop(); + }); + + return win; +} + +const win = createWindow(); +win.show(); +global.gc(); + +libui.startLoop(); diff --git a/examples/widgets/showUiSpinbox.js b/examples/widgets/showUiSpinbox.js index 8b0eafd..58ea9a1 100644 --- a/examples/widgets/showUiSpinbox.js +++ b/examples/widgets/showUiSpinbox.js @@ -1,29 +1,19 @@ /* eslint-disable unicorn/filename-case */ const libui = require('../..'); -function createWindow() { - const win = new libui.UiWindow('UiSpinbox example', 320, 60, true); - win.margined = true; +const win = new libui.UiWindow('UiSpinbox example', 320, 60, true); +win.margined = true; - const widget = new libui.UiSpinbox(); - widget.value = 42; - widget.onChanged(() => { - console.log(`value changed`); - }); - win.setChild(widget); +const widget = new libui.UiSpinbox(); +widget.value = 'sample text'; +win.setChild(widget); - win.onClosing(() => { - win.close(); - global.gc(); - libui.stopLoop(); - }); +win.onClosing(() => { + win.close(); + libui.stopLoop(); +}); - return win; -} - -const win = createWindow(); win.show(); -global.gc(); libui.startLoop(); From e4b1f05d57c9c6e826b74e6581fb56bf8ae4a6ae Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Wed, 11 Apr 2018 21:48:16 +0200 Subject: [PATCH 078/190] [WIP] working on callbacks --- examples/check-control-destroy.js | 4 ++-- src/UiBox.cc | 20 +++++++++++++++++++ src/UiSpinbox.cc | 32 +++++++++++++++++++++++-------- src/UiWindow.cc | 1 + 4 files changed, 47 insertions(+), 10 deletions(-) diff --git a/examples/check-control-destroy.js b/examples/check-control-destroy.js index 8b0eafd..ec00e1a 100644 --- a/examples/check-control-destroy.js +++ b/examples/check-control-destroy.js @@ -1,6 +1,6 @@ /* eslint-disable unicorn/filename-case */ -const libui = require('../..'); +const libui = require('..'); function createWindow() { const win = new libui.UiWindow('UiSpinbox example', 320, 60, true); @@ -9,7 +9,7 @@ function createWindow() { const widget = new libui.UiSpinbox(); widget.value = 42; widget.onChanged(() => { - console.log(`value changed`); + console.log(`value changed to ${widget.value}`); }); win.setChild(widget); diff --git a/src/UiBox.cc b/src/UiBox.cc index 15a68d1..7b82512 100644 --- a/src/UiBox.cc +++ b/src/UiBox.cc @@ -6,6 +6,9 @@ class UiBox : public UiControl { public: UiBox(uiControl *hnd); + ~UiBox(); + void onDestroy(uiControl *control) override; + DEFINE_BOX_METHODS() }; @@ -23,6 +26,23 @@ class UiHorizontalBox : public UiBox { DEFINE_CONTROL_METHODS() }; +UiBox::~UiBox() { + printf("UiBox %p destroyed with wrapper %p.\n", getHandle(), this); +} + +void UiBox::onDestroy(uiControl *control) { + /* + freeing event callbacks to allow JS to garbage collect this class + when there are no references to it left in JS code. + */ + /* + printf("onDestroy called\n"); + if (onChangedCallback != nullptr) { + printf("free cb\n"); + delete onChangedCallback; + onChangedCallback = nullptr; + }*/ +} UiBox::UiBox(uiControl *control) : UiControl(control) {} void UiBox::append(UiControl *control, bool stretchy) { diff --git a/src/UiSpinbox.cc b/src/UiSpinbox.cc index ae441ad..73b1082 100644 --- a/src/UiSpinbox.cc +++ b/src/UiSpinbox.cc @@ -1,11 +1,13 @@ +#include #include "nbind/api.h" #include "control.h" #include "ui.h" class UiSpinbox : public UiControl { - DEFINE_EVENT(onChanged) public: + std::unique_ptr onChangedCallback; + void onChanged(nbind::cbFunction cb); UiSpinbox(int min, int max); UiSpinbox(); ~UiSpinbox(); @@ -27,11 +29,8 @@ void UiSpinbox::onDestroy(uiControl *control) { */ printf("onDestroy called\n"); - if (onChangedCallback != nullptr) { - printf("free cb\n"); - delete onChangedCallback; - onChangedCallback = nullptr; - } + nbind::cbFunction *cb = onChangedCallback.release(); + delete cb; } UiSpinbox::UiSpinbox(int min, int max) @@ -45,12 +44,29 @@ int UiSpinbox::getValue() { void UiSpinbox::setValue(int value) { uiSpinboxSetValue((uiSpinbox *)getHandle(), value); - if (onChangedCallback != NULL) { + if (onChangedCallback != nullptr) { (*onChangedCallback)(); } } -IMPLEMENT_EVENT(UiSpinbox, uiSpinbox, onChanged, uiSpinboxOnChanged) +namespace std { +template +std::unique_ptr make_unique(Args &&... args) { + return std::unique_ptr(new T(std::forward(args)...)); +} +} // namespace std + +static void UiSpinbox_onChanged(uiSpinbox *w, void *data) { + UiSpinbox *ctrl = (UiSpinbox *)data; + nbind::cbFunction cb = *(ctrl->onChangedCallback); + cb(); +} + +void UiSpinbox::onChanged(nbind::cbFunction cb) { + // nbind::cbFunction *cba = new nbind::cbFunction(cb); + onChangedCallback = std::make_unique(cb); + uiSpinboxOnChanged((uiSpinbox *)getHandle(), UiSpinbox_onChanged, this); +} INHERITS_CONTROL_METHODS(UiSpinbox) diff --git a/src/UiWindow.cc b/src/UiWindow.cc index 3c3d68f..b0b750d 100644 --- a/src/UiWindow.cc +++ b/src/UiWindow.cc @@ -1,3 +1,4 @@ +#include #include #include "nbind/api.h" #include "control.h" From 6b8cadcdc34c70717e8bd90396b04bc70a1cbd83 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Fri, 13 Apr 2018 09:04:10 +0200 Subject: [PATCH 079/190] Fixed events leak --- examples/check-control-destroy.js | 13 ++++++++++--- src/UiSpinbox.cc | 13 +++++++------ src/includes/control.h | 2 +- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/examples/check-control-destroy.js b/examples/check-control-destroy.js index ec00e1a..1a23878 100644 --- a/examples/check-control-destroy.js +++ b/examples/check-control-destroy.js @@ -22,8 +22,15 @@ function createWindow() { return win; } -const win = createWindow(); -win.show(); -global.gc(); +function op() { + global.gc(); + const win = createWindow(); + win.show(); + setTimeout(() => { + win.close(); + op(); + }, 100); +} libui.startLoop(); +op(); diff --git a/src/UiSpinbox.cc b/src/UiSpinbox.cc index 73b1082..787ea6d 100644 --- a/src/UiSpinbox.cc +++ b/src/UiSpinbox.cc @@ -6,8 +6,8 @@ class UiSpinbox : public UiControl { public: - std::unique_ptr onChangedCallback; - void onChanged(nbind::cbFunction cb); + nbind::cbFunction *onChangedCallback = nullptr; + void onChanged(nbind::cbFunction &cb); UiSpinbox(int min, int max); UiSpinbox(); ~UiSpinbox(); @@ -28,9 +28,9 @@ void UiSpinbox::onDestroy(uiControl *control) { when there are no references to it left in JS code. */ + delete onChangedCallback; + onChangedCallback = nullptr; printf("onDestroy called\n"); - nbind::cbFunction *cb = onChangedCallback.release(); - delete cb; } UiSpinbox::UiSpinbox(int min, int max) @@ -62,9 +62,10 @@ static void UiSpinbox_onChanged(uiSpinbox *w, void *data) { cb(); } -void UiSpinbox::onChanged(nbind::cbFunction cb) { +void UiSpinbox::onChanged(nbind::cbFunction &cb) { + onChangedCallback = new nbind::cbFunction(cb); // nbind::cbFunction *cba = new nbind::cbFunction(cb); - onChangedCallback = std::make_unique(cb); + // onChangedCallback = std::make_unique(std::move(cb)); uiSpinboxOnChanged((uiSpinbox *)getHandle(), UiSpinbox_onChanged, this); } diff --git a/src/includes/control.h b/src/includes/control.h index d4e0d5b..c0dae20 100644 --- a/src/includes/control.h +++ b/src/includes/control.h @@ -88,7 +88,7 @@ class UiControl { uiControl *getHandle(); UiControl(uiControl *hnd); - ~UiControl(); + virtual ~UiControl(); DEFINE_CONTROL_METHODS() }; From 7dfa8a7060152f8e4833a4a3781f877da9d53d1f Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Fri, 13 Apr 2018 09:12:24 +0200 Subject: [PATCH 080/190] UiSpinbox --- src/UiSpinbox.cc | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/src/UiSpinbox.cc b/src/UiSpinbox.cc index 787ea6d..8b0e81d 100644 --- a/src/UiSpinbox.cc +++ b/src/UiSpinbox.cc @@ -6,8 +6,8 @@ class UiSpinbox : public UiControl { public: - nbind::cbFunction *onChangedCallback = nullptr; - void onChanged(nbind::cbFunction &cb); + DEFINE_EVENT(onChanged) + UiSpinbox(int min, int max); UiSpinbox(); ~UiSpinbox(); @@ -18,10 +18,6 @@ class UiSpinbox : public UiControl { void onDestroy(uiControl *control) override; }; -UiSpinbox::~UiSpinbox() { - printf("UiSpinbox %p destroyed with wrapper %p.\n", getHandle(), this); -} - void UiSpinbox::onDestroy(uiControl *control) { /* freeing event callbacks to allow JS to garbage collect this class @@ -30,7 +26,6 @@ void UiSpinbox::onDestroy(uiControl *control) { delete onChangedCallback; onChangedCallback = nullptr; - printf("onDestroy called\n"); } UiSpinbox::UiSpinbox(int min, int max) @@ -49,25 +44,7 @@ void UiSpinbox::setValue(int value) { } } -namespace std { -template -std::unique_ptr make_unique(Args &&... args) { - return std::unique_ptr(new T(std::forward(args)...)); -} -} // namespace std - -static void UiSpinbox_onChanged(uiSpinbox *w, void *data) { - UiSpinbox *ctrl = (UiSpinbox *)data; - nbind::cbFunction cb = *(ctrl->onChangedCallback); - cb(); -} - -void UiSpinbox::onChanged(nbind::cbFunction &cb) { - onChangedCallback = new nbind::cbFunction(cb); - // nbind::cbFunction *cba = new nbind::cbFunction(cb); - // onChangedCallback = std::make_unique(std::move(cb)); - uiSpinboxOnChanged((uiSpinbox *)getHandle(), UiSpinbox_onChanged, this); -} +IMPLEMENT_EVENT(UiSpinbox, uiSpinbox, onChanged, uiSpinboxOnChanged) INHERITS_CONTROL_METHODS(UiSpinbox) From a3713f139841012d65d1e7e2e6a1b8cfc64de1fb Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Fri, 13 Apr 2018 10:42:42 +0200 Subject: [PATCH 081/190] Fixed events leak -> UiBox & UiButton --- examples/check-control-destroy.js | 20 +++++++++++++++----- src/UiBox.cc | 20 ++++++++++++-------- src/UiButton.cc | 15 +++++++++++++++ src/UiSpinbox.cc | 5 ++++- src/includes/box.h | 4 ++-- 5 files changed, 48 insertions(+), 16 deletions(-) diff --git a/examples/check-control-destroy.js b/examples/check-control-destroy.js index 1a23878..31ab55c 100644 --- a/examples/check-control-destroy.js +++ b/examples/check-control-destroy.js @@ -6,12 +6,22 @@ function createWindow() { win.margined = true; - const widget = new libui.UiSpinbox(); - widget.value = 42; - widget.onChanged(() => { - console.log(`value changed to ${widget.value}`); + const widget1 = new libui.UiSpinbox(); + widget1.value = 42; + widget1.onChanged(() => { + console.log(`value1 changed to $ {widget1.value}`); }); - win.setChild(widget); + + const widget2 = new libui.UiButton('btn1'); + widget2.onClicked(() => { + console.log(`${widget2.text} clicked`); + }); + + const box = new libui.UiVerticalBox(); + box.append(widget1, true); + box.append(widget2, true); + + win.setChild(box); win.onClosing(() => { win.close(); diff --git a/src/UiBox.cc b/src/UiBox.cc index 7b82512..2b5b3b4 100644 --- a/src/UiBox.cc +++ b/src/UiBox.cc @@ -1,3 +1,5 @@ +#include +#include #include "nbind/api.h" #include "box.h" #include "control.h" @@ -9,6 +11,11 @@ class UiBox : public UiControl { ~UiBox(); void onDestroy(uiControl *control) override; + // this hold a reference to children controls + // to avoid them being garbage collected + // until not destroyed. + std::vector> children; + DEFINE_BOX_METHODS() }; @@ -35,21 +42,18 @@ void UiBox::onDestroy(uiControl *control) { freeing event callbacks to allow JS to garbage collect this class when there are no references to it left in JS code. */ - /* - printf("onDestroy called\n"); - if (onChangedCallback != nullptr) { - printf("free cb\n"); - delete onChangedCallback; - onChangedCallback = nullptr; - }*/ + + children.clear(); } UiBox::UiBox(uiControl *control) : UiControl(control) {} -void UiBox::append(UiControl *control, bool stretchy) { +void UiBox::append(std::shared_ptr control, bool stretchy) { + children.push_back(control); uiBoxAppend((uiBox *)getHandle(), control->getHandle(), stretchy); } void UiBox::deleteAt(int index) { + children.erase(children.begin() + index); uiBoxDelete((uiBox *)getHandle(), index); } diff --git a/src/UiButton.cc b/src/UiButton.cc index c0803de..f677685 100644 --- a/src/UiButton.cc +++ b/src/UiButton.cc @@ -9,11 +9,26 @@ class UiButton : public UiControl { public: UiButton(std::string text); UiButton(); + ~UiButton(); DEFINE_CONTROL_METHODS() void setText(std::string text); std::string getText(); + void onDestroy(uiControl *control) override; }; +void UiButton::onDestroy(uiControl *control) { + /* + freeing event callbacks to allow JS to garbage collect this class + when there are no references to it left in JS code. + */ + delete onClickedCallback; + onClickedCallback = nullptr; +} + +UiButton::~UiButton() { + printf("UiButton %p destroyed with wrapper %p.\n", getHandle(), this); +} + UiButton::UiButton(std::string text) : UiControl(uiControl(uiNewButton(text.c_str()))) {} UiButton::UiButton() : UiControl(uiControl(uiNewButton(""))) {} diff --git a/src/UiSpinbox.cc b/src/UiSpinbox.cc index 8b0e81d..2146168 100644 --- a/src/UiSpinbox.cc +++ b/src/UiSpinbox.cc @@ -18,12 +18,15 @@ class UiSpinbox : public UiControl { void onDestroy(uiControl *control) override; }; +UiSpinbox::~UiSpinbox() { + printf("UiSpinbox %p destroyed with wrapper %p.\n", getHandle(), this); +} + void UiSpinbox::onDestroy(uiControl *control) { /* freeing event callbacks to allow JS to garbage collect this class when there are no references to it left in JS code. */ - delete onChangedCallback; onChangedCallback = nullptr; } diff --git a/src/includes/box.h b/src/includes/box.h index a3db858..80b0d99 100644 --- a/src/includes/box.h +++ b/src/includes/box.h @@ -2,13 +2,13 @@ #define UI_NODE_BOX 1 #define DEFINE_BOX_METHODS() \ - void append(UiControl *control, bool stretchy); \ + void append(std::shared_ptr, bool stretchy); \ void deleteAt(int index); \ bool getPadded(); \ void setPadded(bool padded); #define INHERITS_BOX_METHODS(CLASS) \ - void CLASS::append(UiControl *control, bool stretchy) { \ + void CLASS::append(std::shared_ptr control, bool stretchy) { \ UiBox::append(control, stretchy); \ } \ void CLASS::deleteAt(int index) { \ From 975bf7c411e079a5bef953d2ac4ecf645641a827 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Fri, 13 Apr 2018 11:11:48 +0200 Subject: [PATCH 082/190] Fixed events leak -> UiButton --- src/UiButton.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/UiButton.cc b/src/UiButton.cc index f677685..8295e94 100644 --- a/src/UiButton.cc +++ b/src/UiButton.cc @@ -21,8 +21,10 @@ void UiButton::onDestroy(uiControl *control) { freeing event callbacks to allow JS to garbage collect this class when there are no references to it left in JS code. */ - delete onClickedCallback; - onClickedCallback = nullptr; + if (onClickedCallback != nullptr) { + delete onClickedCallback; + onClickedCallback = nullptr; + } } UiButton::~UiButton() { From 077fb17c41cb09b28d4c9ec1f70bfda1a5683887 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Fri, 13 Apr 2018 11:20:53 +0200 Subject: [PATCH 083/190] Fixed events leak -> UiCheckbox --- examples/check-control-destroy.js | 8 +++++++- src/UiBox.cc | 2 +- src/UiButton.cc | 4 ++-- src/UiCheckbox.cc | 13 +++++++++++++ src/UiSpinbox.cc | 2 +- src/includes/control.h | 6 ++++++ 6 files changed, 30 insertions(+), 5 deletions(-) diff --git a/examples/check-control-destroy.js b/examples/check-control-destroy.js index 31ab55c..cdd0f61 100644 --- a/examples/check-control-destroy.js +++ b/examples/check-control-destroy.js @@ -9,7 +9,7 @@ function createWindow() { const widget1 = new libui.UiSpinbox(); widget1.value = 42; widget1.onChanged(() => { - console.log(`value1 changed to $ {widget1.value}`); + console.log(`value1 changed to ${widget1.value}`); }); const widget2 = new libui.UiButton('btn1'); @@ -17,9 +17,15 @@ function createWindow() { console.log(`${widget2.text} clicked`); }); + const widget3 = new libui.UiCheckbox('chk1'); + widget3.onToggled(() => { + console.log(`${widget3.text} toggled`); + }); + const box = new libui.UiVerticalBox(); box.append(widget1, true); box.append(widget2, true); + box.append(widget3, true); win.setChild(box); diff --git a/src/UiBox.cc b/src/UiBox.cc index 2b5b3b4..57339a9 100644 --- a/src/UiBox.cc +++ b/src/UiBox.cc @@ -34,7 +34,7 @@ class UiHorizontalBox : public UiBox { }; UiBox::~UiBox() { - printf("UiBox %p destroyed with wrapper %p.\n", getHandle(), this); + // printf("UiBox %p destroyed with wrapper %p.\n", getHandle(), this); } void UiBox::onDestroy(uiControl *control) { diff --git a/src/UiButton.cc b/src/UiButton.cc index 8295e94..86f082d 100644 --- a/src/UiButton.cc +++ b/src/UiButton.cc @@ -9,10 +9,10 @@ class UiButton : public UiControl { public: UiButton(std::string text); UiButton(); - ~UiButton(); DEFINE_CONTROL_METHODS() void setText(std::string text); std::string getText(); + ~UiButton(); void onDestroy(uiControl *control) override; }; @@ -28,7 +28,7 @@ void UiButton::onDestroy(uiControl *control) { } UiButton::~UiButton() { - printf("UiButton %p destroyed with wrapper %p.\n", getHandle(), this); + // printf("UiButton %p destroyed with wrapper %p.\n", getHandle(), this); } UiButton::UiButton(std::string text) diff --git a/src/UiCheckbox.cc b/src/UiCheckbox.cc index 1157a12..5369779 100644 --- a/src/UiCheckbox.cc +++ b/src/UiCheckbox.cc @@ -14,8 +14,21 @@ class UiCheckbox : public UiControl { std::string getText(); void setChecked(bool checked); bool getChecked(); + ~UiCheckbox(); + void onDestroy(uiControl *control) override; }; +void UiCheckbox::onDestroy(uiControl *control){ + /* + freeing event callbacks to allow JS to garbage collect this class + when there are no references to it left in JS code. + */ + DISPOSE_EVENT(onToggled)} + +UiCheckbox::~UiCheckbox() { + printf("UiCheckbox %p destroyed with wrapper %p.\n", getHandle(), this); +} + IMPLEMENT_EVENT(UiCheckbox, uiCheckbox, onToggled, uiCheckboxOnToggled) UiCheckbox::UiCheckbox(std::string text) diff --git a/src/UiSpinbox.cc b/src/UiSpinbox.cc index 2146168..5d717b4 100644 --- a/src/UiSpinbox.cc +++ b/src/UiSpinbox.cc @@ -19,7 +19,7 @@ class UiSpinbox : public UiControl { }; UiSpinbox::~UiSpinbox() { - printf("UiSpinbox %p destroyed with wrapper %p.\n", getHandle(), this); + // printf("UiSpinbox %p destroyed with wrapper %p.\n", getHandle(), this); } void UiSpinbox::onDestroy(uiControl *control) { diff --git a/src/includes/control.h b/src/includes/control.h index c0dae20..0b043dd 100644 --- a/src/includes/control.h +++ b/src/includes/control.h @@ -20,6 +20,12 @@ LIBUI_FUN((WIDGET *)getHandle(), CLASS##_##NAME, NAME##Callback); \ } +#define DISPOSE_EVENT(NAME) \ + if (NAME##Callback != nullptr) { \ + delete NAME##Callback; \ + NAME##Callback = nullptr; \ + } + #define DEFINE_CONTROL_METHODS() \ void destroy(); \ void setParent(UiControl *parent); \ From af9650a01e8ea181e9dd7c9d19ff2fcd84d1282b Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Fri, 13 Apr 2018 11:21:09 +0200 Subject: [PATCH 084/190] Fixed events leak -> UiCheckbox --- src/UiCheckbox.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/UiCheckbox.cc b/src/UiCheckbox.cc index 5369779..0a9c69f 100644 --- a/src/UiCheckbox.cc +++ b/src/UiCheckbox.cc @@ -18,12 +18,13 @@ class UiCheckbox : public UiControl { void onDestroy(uiControl *control) override; }; -void UiCheckbox::onDestroy(uiControl *control){ +void UiCheckbox::onDestroy(uiControl *control) { /* freeing event callbacks to allow JS to garbage collect this class when there are no references to it left in JS code. */ - DISPOSE_EVENT(onToggled)} + DISPOSE_EVENT(onToggled); +} UiCheckbox::~UiCheckbox() { printf("UiCheckbox %p destroyed with wrapper %p.\n", getHandle(), this); From e6c54cddb1f8a938824d5dab194b1d2bcb7d759a Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Fri, 13 Apr 2018 11:27:30 +0200 Subject: [PATCH 085/190] USe macro to free events --- src/UiBox.cc | 7 +++---- src/UiButton.cc | 5 +---- src/UiSpinbox.cc | 4 +--- src/UiWindow.cc | 11 ++--------- 4 files changed, 7 insertions(+), 20 deletions(-) diff --git a/src/UiBox.cc b/src/UiBox.cc index 57339a9..b311da3 100644 --- a/src/UiBox.cc +++ b/src/UiBox.cc @@ -11,7 +11,7 @@ class UiBox : public UiControl { ~UiBox(); void onDestroy(uiControl *control) override; - // this hold a reference to children controls + // this hold references to children controls // to avoid them being garbage collected // until not destroyed. std::vector> children; @@ -39,10 +39,9 @@ UiBox::~UiBox() { void UiBox::onDestroy(uiControl *control) { /* - freeing event callbacks to allow JS to garbage collect this class - when there are no references to it left in JS code. + freeing children to allow JS to garbage collect their wrapper classes + when there are no references to them left in JS code. */ - children.clear(); } UiBox::UiBox(uiControl *control) : UiControl(control) {} diff --git a/src/UiButton.cc b/src/UiButton.cc index 86f082d..696b415 100644 --- a/src/UiButton.cc +++ b/src/UiButton.cc @@ -21,10 +21,7 @@ void UiButton::onDestroy(uiControl *control) { freeing event callbacks to allow JS to garbage collect this class when there are no references to it left in JS code. */ - if (onClickedCallback != nullptr) { - delete onClickedCallback; - onClickedCallback = nullptr; - } + DISPOSE_EVENT(onClicked); } UiButton::~UiButton() { diff --git a/src/UiSpinbox.cc b/src/UiSpinbox.cc index 5d717b4..4d3b99a 100644 --- a/src/UiSpinbox.cc +++ b/src/UiSpinbox.cc @@ -4,7 +4,6 @@ #include "ui.h" class UiSpinbox : public UiControl { - public: DEFINE_EVENT(onChanged) @@ -27,8 +26,7 @@ void UiSpinbox::onDestroy(uiControl *control) { freeing event callbacks to allow JS to garbage collect this class when there are no references to it left in JS code. */ - delete onChangedCallback; - onChangedCallback = nullptr; + DISPOSE_EVENT(onChanged); } UiSpinbox::UiSpinbox(int min, int max) diff --git a/src/UiWindow.cc b/src/UiWindow.cc index b0b750d..b42c94b 100644 --- a/src/UiWindow.cc +++ b/src/UiWindow.cc @@ -76,15 +76,8 @@ void UiWindow::close() { freeing event callbacks to allow JS to garbage collect this class when there are no references to it left in JS code. */ - if (onClosingCallback != nullptr) { - delete onClosingCallback; - onClosingCallback = nullptr; - } - - if (onContentSizeChangedCallback != nullptr) { - delete onContentSizeChangedCallback; - onContentSizeChangedCallback = nullptr; - } + DISPOSE_EVENT(onClosing); + DISPOSE_EVENT(onContentSizeChanged); child = nullptr; } From 4ed663cf9cdf867462b290e4da76c624030b987c Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Fri, 13 Apr 2018 11:30:06 +0200 Subject: [PATCH 086/190] Fixed events leak -> UiColorButton --- examples/check-control-destroy.js | 8 +++++++- src/UiColorButton.cc | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/examples/check-control-destroy.js b/examples/check-control-destroy.js index cdd0f61..eeda5da 100644 --- a/examples/check-control-destroy.js +++ b/examples/check-control-destroy.js @@ -9,7 +9,7 @@ function createWindow() { const widget1 = new libui.UiSpinbox(); widget1.value = 42; widget1.onChanged(() => { - console.log(`value1 changed to ${widget1.value}`); + console.log(`widget1 changed to ${widget1.value}`); }); const widget2 = new libui.UiButton('btn1'); @@ -22,10 +22,16 @@ function createWindow() { console.log(`${widget3.text} toggled`); }); + const widget4 = new libui.UiColorButton(); + widget4.onChanged(() => { + console.log(`widget4 changed to ${widget4.color}`); + }); + const box = new libui.UiVerticalBox(); box.append(widget1, true); box.append(widget2, true); box.append(widget3, true); + box.append(widget4, true); win.setChild(box); diff --git a/src/UiColorButton.cc b/src/UiColorButton.cc index 3d110e2..49c88e4 100644 --- a/src/UiColorButton.cc +++ b/src/UiColorButton.cc @@ -11,8 +11,22 @@ class UiColorButton : public UiControl { Color getColor(); void setColor(Color value); DEFINE_CONTROL_METHODS() + ~UiColorButton(); + void onDestroy(uiControl *control) override; }; +void UiColorButton::onDestroy(uiControl *control) { + /* + freeing event callbacks to allow JS to garbage collect this class + when there are no references to it left in JS code. + */ + DISPOSE_EVENT(onChanged); +} + +UiColorButton::~UiColorButton() { + printf("UiColorButton %p destroyed with wrapper %p.\n", getHandle(), this); +} + UiColorButton::UiColorButton() : UiControl((uiControl *)uiNewColorButton()) {} INHERITS_CONTROL_METHODS(UiColorButton) From 85384c5e6c322692476c4350423cd34c94339f3d Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Fri, 13 Apr 2018 11:33:53 +0200 Subject: [PATCH 087/190] Fixed events leak -> UiCombobox --- examples/check-control-destroy.js | 8 ++++++++ src/UiCombobox.cc | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/examples/check-control-destroy.js b/examples/check-control-destroy.js index eeda5da..c7c982d 100644 --- a/examples/check-control-destroy.js +++ b/examples/check-control-destroy.js @@ -27,11 +27,19 @@ function createWindow() { console.log(`widget4 changed to ${widget4.color}`); }); + const widget5 = new libui.UiCombobox(); + widget5.append('a'); + widget5.append('b'); + widget5.onSelected(() => { + console.log(`widget5 changed to ${widget5.selected}`); + }); + const box = new libui.UiVerticalBox(); box.append(widget1, true); box.append(widget2, true); box.append(widget3, true); box.append(widget4, true); + box.append(widget5, true); win.setChild(box); diff --git a/src/UiCombobox.cc b/src/UiCombobox.cc index d51fcab..ad58a30 100644 --- a/src/UiCombobox.cc +++ b/src/UiCombobox.cc @@ -12,8 +12,22 @@ class UiCombobox : public UiControl { void append(std::string text); int getSelected(); void setSelected(int n); + ~UiCombobox(); + void onDestroy(uiControl *control) override; }; +void UiCombobox::onDestroy(uiControl *control) { + /* + freeing event callbacks to allow JS to garbage collect this class + when there are no references to it left in JS code. + */ + DISPOSE_EVENT(onSelected); +} + +UiCombobox::~UiCombobox() { + printf("UiCombobox %p destroyed with wrapper %p.\n", getHandle(), this); +} + UiCombobox::UiCombobox() : UiControl((uiControl *)uiNewCombobox()) {} INHERITS_CONTROL_METHODS(UiCombobox) From 3e9d2df73677a3e73b011d6ad653e449724769f5 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Fri, 13 Apr 2018 11:39:18 +0200 Subject: [PATCH 088/190] Fixed events leak -> UiEditableCombobox --- examples/check-control-destroy.js | 6 ++++++ src/UiEditableCombobox.cc | 15 +++++++++++++++ src/UiSpinbox.cc | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/examples/check-control-destroy.js b/examples/check-control-destroy.js index c7c982d..72569eb 100644 --- a/examples/check-control-destroy.js +++ b/examples/check-control-destroy.js @@ -34,12 +34,18 @@ function createWindow() { console.log(`widget5 changed to ${widget5.selected}`); }); + const widget6 = new libui.UiEditableCombobox(); + widget6.onChanged(() => { + console.log(`widget6 changed to ${widget6.text}`); + }); + const box = new libui.UiVerticalBox(); box.append(widget1, true); box.append(widget2, true); box.append(widget3, true); box.append(widget4, true); box.append(widget5, true); + box.append(widget6, true); win.setChild(box); diff --git a/src/UiEditableCombobox.cc b/src/UiEditableCombobox.cc index 12bf3b2..0482678 100644 --- a/src/UiEditableCombobox.cc +++ b/src/UiEditableCombobox.cc @@ -12,8 +12,23 @@ class UiEditableCombobox : public UiControl { void append(std::string text); std::string getText(); void setText(std::string text); + ~UiEditableCombobox(); + void onDestroy(uiControl *control) override; }; +UiEditableCombobox::~UiEditableCombobox() { + printf("UiEditableCombobox %p destroyed with wrapper %p.\n", getHandle(), + this); +} + +void UiEditableCombobox::onDestroy(uiControl *control) { + /* + freeing event callbacks to allow JS to garbage collect this class + when there are no references to it left in JS code. + */ + DISPOSE_EVENT(onChanged); +} + UiEditableCombobox::UiEditableCombobox() : UiControl(uiControl(uiNewEditableCombobox())) {} diff --git a/src/UiSpinbox.cc b/src/UiSpinbox.cc index 4d3b99a..ae0bde6 100644 --- a/src/UiSpinbox.cc +++ b/src/UiSpinbox.cc @@ -9,11 +9,11 @@ class UiSpinbox : public UiControl { UiSpinbox(int min, int max); UiSpinbox(); - ~UiSpinbox(); DEFINE_CONTROL_METHODS() int getValue(); void setValue(int value); + ~UiSpinbox(); void onDestroy(uiControl *control) override; }; From 2788d2f64aca5820e94673bd06c50ca129c79b1c Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Fri, 13 Apr 2018 11:47:04 +0200 Subject: [PATCH 089/190] [TEST] removed macro to inherit UiControl, they are not needed anymore --- examples/check-control-destroy.js | 2 ++ src/UiEditableCombobox.cc | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/check-control-destroy.js b/examples/check-control-destroy.js index 72569eb..3da561e 100644 --- a/examples/check-control-destroy.js +++ b/examples/check-control-destroy.js @@ -14,6 +14,7 @@ function createWindow() { const widget2 = new libui.UiButton('btn1'); widget2.onClicked(() => { + widget6.setEnabled(false); console.log(`${widget2.text} clicked`); }); @@ -62,6 +63,7 @@ function op() { global.gc(); const win = createWindow(); win.show(); + return; setTimeout(() => { win.close(); op(); diff --git a/src/UiEditableCombobox.cc b/src/UiEditableCombobox.cc index 0482678..0cc3d2c 100644 --- a/src/UiEditableCombobox.cc +++ b/src/UiEditableCombobox.cc @@ -8,7 +8,7 @@ class UiEditableCombobox : public UiControl { public: UiEditableCombobox(); - DEFINE_CONTROL_METHODS() + // DEFINE_CONTROL_METHODS() void append(std::string text); std::string getText(); void setText(std::string text); @@ -32,7 +32,7 @@ void UiEditableCombobox::onDestroy(uiControl *control) { UiEditableCombobox::UiEditableCombobox() : UiControl(uiControl(uiNewEditableCombobox())) {} -INHERITS_CONTROL_METHODS(UiEditableCombobox) +// INHERITS_CONTROL_METHODS(UiEditableCombobox) IMPLEMENT_EVENT(UiEditableCombobox, uiEditableCombobox, onChanged, uiEditableComboboxOnChanged) @@ -57,7 +57,7 @@ std::string UiEditableCombobox::getText() { NBIND_CLASS(UiEditableCombobox) { construct<>(); - DECLARE_CHILD_CONTROL_METHODS() + inherit(UiControl); method(append); getset(getText, setText); method(getText); From d43c468e4e1797cd6e2a1b57966d89b62e71c803 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Fri, 13 Apr 2018 12:35:39 +0200 Subject: [PATCH 090/190] Fixed events leak -> UiEntry & friends --- examples/check-control-destroy.js | 21 ++++++++++++++++++++- src/UiEntry.cc | 28 +++++++++++++++++++++++----- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/examples/check-control-destroy.js b/examples/check-control-destroy.js index 3da561e..fcfff4e 100644 --- a/examples/check-control-destroy.js +++ b/examples/check-control-destroy.js @@ -40,6 +40,21 @@ function createWindow() { console.log(`widget6 changed to ${widget6.text}`); }); + const widget7 = new libui.UiSearchEntry(); + widget7.onChanged(() => { + console.log(`${widget7.text} changed`); + }); + + const widget8 = new libui.UiPasswordEntry(); + widget8.onChanged(() => { + console.log(`${widget8.text} changed`); + }); + + const widget9 = new libui.UiEntry(); + widget9.onChanged(() => { + console.log(`${widget9.text} changed`); + }); + const box = new libui.UiVerticalBox(); box.append(widget1, true); box.append(widget2, true); @@ -48,6 +63,10 @@ function createWindow() { box.append(widget5, true); box.append(widget6, true); + box.append(widget7, true); + box.append(widget8, true); + box.append(widget9, true); + win.setChild(box); win.onClosing(() => { @@ -63,7 +82,7 @@ function op() { global.gc(); const win = createWindow(); win.show(); - return; + // return; setTimeout(() => { win.close(); op(); diff --git a/src/UiEntry.cc b/src/UiEntry.cc index fee88d7..f401b7d 100644 --- a/src/UiEntry.cc +++ b/src/UiEntry.cc @@ -6,13 +6,28 @@ class UiEntryBase : public UiControl { DEFINE_EVENT(onChanged) + const char *n; public: - UiEntryBase(uiControl *); + UiEntryBase(uiControl *, const char *name); DEFINE_CONTROL_METHODS() DEFINE_ENTRY_METHODS() + ~UiEntryBase(); + void onDestroy(uiControl *control) override; }; +UiEntryBase::~UiEntryBase() { + printf("%s %p destroyed with wrapper %p.\n", n, getHandle(), this); +} + +void UiEntryBase::onDestroy(uiControl *control) { + /* + freeing event callbacks to allow JS to garbage collect this class + when there are no references to it left in JS code. + */ + DISPOSE_EVENT(onChanged); +} + class UiEntry : public UiEntryBase { public: UiEntry(); @@ -37,7 +52,9 @@ class UiSearchEntry : public UiEntryBase { void onChanged(nbind::cbFunction &cb); }; -UiEntryBase::UiEntryBase(uiControl *hnd) : UiControl(hnd) {} +UiEntryBase::UiEntryBase(uiControl *hnd, const char *name) : UiControl(hnd) { + n = name; +} void UiEntryBase::setText(std::string text) { uiEntrySetText(uiEntry(getHandle()), text.c_str()); @@ -63,18 +80,19 @@ bool UiEntryBase::getReadOnly() { IMPLEMENT_EVENT(UiEntryBase, uiEntry, onChanged, uiEntryOnChanged) -UiEntry::UiEntry() : UiEntryBase(uiControl(uiNewEntry())) {} +UiEntry::UiEntry() : UiEntryBase(uiControl(uiNewEntry()), "UiEntry") {} INHERITS_CONTROL_METHODS(UiEntry) INHERITS_ENTRY_METHODS(UiEntry) UiPasswordEntry::UiPasswordEntry() - : UiEntryBase(uiControl(uiNewPasswordEntry())) {} + : UiEntryBase(uiControl(uiNewPasswordEntry()), "UiPasswordEntry") {} INHERITS_CONTROL_METHODS(UiPasswordEntry) INHERITS_ENTRY_METHODS(UiPasswordEntry) -UiSearchEntry::UiSearchEntry() : UiEntryBase(uiControl(uiNewSearchEntry())) {} +UiSearchEntry::UiSearchEntry() + : UiEntryBase(uiControl(uiNewSearchEntry()), "UiSearchEntry") {} INHERITS_CONTROL_METHODS(UiSearchEntry) INHERITS_ENTRY_METHODS(UiSearchEntry) From 8749429c60411d2ed5db78419787e1d0ac2fff9c Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Fri, 13 Apr 2018 12:37:05 +0200 Subject: [PATCH 091/190] Fixed events leak -> UiFontButton --- examples/check-control-destroy.js | 6 ++++++ src/UiFontButton.cc | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/examples/check-control-destroy.js b/examples/check-control-destroy.js index fcfff4e..db36fc7 100644 --- a/examples/check-control-destroy.js +++ b/examples/check-control-destroy.js @@ -55,6 +55,11 @@ function createWindow() { console.log(`${widget9.text} changed`); }); + const widget10 = new libui.UiFontButton(); + widget10.onChanged(() => { + console.log(`${widget10.text} changed`); + }); + const box = new libui.UiVerticalBox(); box.append(widget1, true); box.append(widget2, true); @@ -66,6 +71,7 @@ function createWindow() { box.append(widget7, true); box.append(widget8, true); box.append(widget9, true); + box.append(widget10, true); win.setChild(box); diff --git a/src/UiFontButton.cc b/src/UiFontButton.cc index 6151f71..751f42b 100644 --- a/src/UiFontButton.cc +++ b/src/UiFontButton.cc @@ -11,8 +11,22 @@ class UiFontButton : public UiControl { UiFontButton(); DrawTextFont *getFont(); DEFINE_CONTROL_METHODS() + ~UiFontButton(); + void onDestroy(uiControl *control) override; }; +UiFontButton::~UiFontButton() { + printf("UiFontButton %p destroyed with wrapper %p.\n", getHandle(), this); +} + +void UiFontButton::onDestroy(uiControl *control) { + /* + freeing event callbacks to allow JS to garbage collect this class + when there are no references to it left in JS code. + */ + DISPOSE_EVENT(onChanged); +} + UiFontButton::UiFontButton() : UiControl((uiControl *)uiNewFontButton()) {} INHERITS_CONTROL_METHODS(UiFontButton) From 394957a5ee8c9fd6c6681916e9ed593b8f914f27 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Fri, 13 Apr 2018 12:41:15 +0200 Subject: [PATCH 092/190] Fixed events leak -> UiMultilineEntry --- examples/check-control-destroy.js | 6 ++++++ src/UiCheckbox.cc | 2 +- src/UiColorButton.cc | 3 ++- src/UiCombobox.cc | 2 +- src/UiEditableCombobox.cc | 4 ++-- src/UiEntry.cc | 2 +- src/UiFontButton.cc | 3 ++- src/UiMultilineEntry.cc | 14 ++++++++++++++ 8 files changed, 29 insertions(+), 7 deletions(-) diff --git a/examples/check-control-destroy.js b/examples/check-control-destroy.js index db36fc7..6daf5a0 100644 --- a/examples/check-control-destroy.js +++ b/examples/check-control-destroy.js @@ -60,6 +60,11 @@ function createWindow() { console.log(`${widget10.text} changed`); }); + const widget11 = new libui.UiMultilineEntry(); + widget11.onChanged(() => { + console.log(`${widget11.text} changed`); + }); + const box = new libui.UiVerticalBox(); box.append(widget1, true); box.append(widget2, true); @@ -72,6 +77,7 @@ function createWindow() { box.append(widget8, true); box.append(widget9, true); box.append(widget10, true); + box.append(widget11, true); win.setChild(box); diff --git a/src/UiCheckbox.cc b/src/UiCheckbox.cc index 0a9c69f..6de340e 100644 --- a/src/UiCheckbox.cc +++ b/src/UiCheckbox.cc @@ -27,7 +27,7 @@ void UiCheckbox::onDestroy(uiControl *control) { } UiCheckbox::~UiCheckbox() { - printf("UiCheckbox %p destroyed with wrapper %p.\n", getHandle(), this); + // printf("UiCheckbox %p destroyed with wrapper %p.\n", getHandle(), this); } IMPLEMENT_EVENT(UiCheckbox, uiCheckbox, onToggled, uiCheckboxOnToggled) diff --git a/src/UiColorButton.cc b/src/UiColorButton.cc index 49c88e4..2b74ddd 100644 --- a/src/UiColorButton.cc +++ b/src/UiColorButton.cc @@ -24,7 +24,8 @@ void UiColorButton::onDestroy(uiControl *control) { } UiColorButton::~UiColorButton() { - printf("UiColorButton %p destroyed with wrapper %p.\n", getHandle(), this); + // printf("UiColorButton %p destroyed with wrapper %p.\n", getHandle(), + // this); } UiColorButton::UiColorButton() : UiControl((uiControl *)uiNewColorButton()) {} diff --git a/src/UiCombobox.cc b/src/UiCombobox.cc index ad58a30..87095e4 100644 --- a/src/UiCombobox.cc +++ b/src/UiCombobox.cc @@ -25,7 +25,7 @@ void UiCombobox::onDestroy(uiControl *control) { } UiCombobox::~UiCombobox() { - printf("UiCombobox %p destroyed with wrapper %p.\n", getHandle(), this); + // printf("UiCombobox %p destroyed with wrapper %p.\n", getHandle(), this); } UiCombobox::UiCombobox() : UiControl((uiControl *)uiNewCombobox()) {} diff --git a/src/UiEditableCombobox.cc b/src/UiEditableCombobox.cc index 0cc3d2c..d6f638a 100644 --- a/src/UiEditableCombobox.cc +++ b/src/UiEditableCombobox.cc @@ -17,8 +17,8 @@ class UiEditableCombobox : public UiControl { }; UiEditableCombobox::~UiEditableCombobox() { - printf("UiEditableCombobox %p destroyed with wrapper %p.\n", getHandle(), - this); + // printf("UiEditableCombobox %p destroyed with wrapper %p.\n", getHandle(), + // this); } void UiEditableCombobox::onDestroy(uiControl *control) { diff --git a/src/UiEntry.cc b/src/UiEntry.cc index f401b7d..e1b27e0 100644 --- a/src/UiEntry.cc +++ b/src/UiEntry.cc @@ -17,7 +17,7 @@ class UiEntryBase : public UiControl { }; UiEntryBase::~UiEntryBase() { - printf("%s %p destroyed with wrapper %p.\n", n, getHandle(), this); + // printf("%s %p destroyed with wrapper %p.\n", n, getHandle(), this); } void UiEntryBase::onDestroy(uiControl *control) { diff --git a/src/UiFontButton.cc b/src/UiFontButton.cc index 751f42b..b463e88 100644 --- a/src/UiFontButton.cc +++ b/src/UiFontButton.cc @@ -16,7 +16,8 @@ class UiFontButton : public UiControl { }; UiFontButton::~UiFontButton() { - printf("UiFontButton %p destroyed with wrapper %p.\n", getHandle(), this); + // printf("UiFontButton %p destroyed with wrapper %p.\n", getHandle(), + // this); } void UiFontButton::onDestroy(uiControl *control) { diff --git a/src/UiMultilineEntry.cc b/src/UiMultilineEntry.cc index e6ddca1..1aa19c9 100644 --- a/src/UiMultilineEntry.cc +++ b/src/UiMultilineEntry.cc @@ -14,8 +14,22 @@ class UiMultilineEntry : public UiControl { void setReadOnly(bool readOnly); bool getReadOnly(); void append(std::string text); + ~UiMultilineEntry(); + void onDestroy(uiControl *control) override; }; +UiMultilineEntry::~UiMultilineEntry() { + // printf("UiMultilineEntry %p destroyed with wrapper %p.\n", getHandle(), + this); +} + +void UiMultilineEntry::onDestroy(uiControl *control) { + /* + freeing event callbacks to allow JS to garbage collect this class + when there are no references to it left in JS code. + */ + DISPOSE_EVENT(onChanged); +} UiMultilineEntry::UiMultilineEntry() : UiControl(uiControl(uiNewNonWrappingMultilineEntry())) {} From 1acfb8cd1eb2b8075e81e7454e0a9c152624b77e Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Fri, 13 Apr 2018 13:31:28 +0200 Subject: [PATCH 093/190] [WIP] other containers --- examples/check-control-destroy.js | 20 ++++++++++++ src/UiForm.cc | 29 ++++++++++++++++-- src/UiGrid.cc | 51 +++++++++++++++++++++++-------- src/UiGroup.cc | 27 ++++++++++++++-- src/UiMultilineEntry.cc | 2 +- src/UiRadioButtons.cc | 15 +++++++++ src/UiSlider.cc | 15 +++++++++ src/UiTab.cc | 37 ++++++++++++++++++---- 8 files changed, 170 insertions(+), 26 deletions(-) diff --git a/examples/check-control-destroy.js b/examples/check-control-destroy.js index 6daf5a0..dbc17d5 100644 --- a/examples/check-control-destroy.js +++ b/examples/check-control-destroy.js @@ -1,6 +1,12 @@ /* eslint-disable unicorn/filename-case */ const libui = require('..'); +const mnu = new libui.UiMenu('mnu'); +const mnuItem = mnu.appendItem('click me'); +mnuItem.onClicked(() => { + console.log(`menu clicked ${mnuItem}`); +}); + function createWindow() { const win = new libui.UiWindow('UiSpinbox example', 320, 60, true); @@ -65,6 +71,18 @@ function createWindow() { console.log(`${widget11.text} changed`); }); + const widget12 = new libui.UiRadioButtons(); + widget12.append('a'); + widget12.append('b'); + widget12.onSelected(() => { + console.log(`widget12 changed to ${widget12.selected}`); + }); + + const widget13 = new libui.UiSlider(); + widget13.onChanged(() => { + console.log(`widget13 changed to ${widget13.value}`); + }); + const box = new libui.UiVerticalBox(); box.append(widget1, true); box.append(widget2, true); @@ -78,6 +96,8 @@ function createWindow() { box.append(widget9, true); box.append(widget10, true); box.append(widget11, true); + box.append(widget12, true); + box.append(widget13, true); win.setChild(box); diff --git a/src/UiForm.cc b/src/UiForm.cc index 0136b27..6d4422c 100644 --- a/src/UiForm.cc +++ b/src/UiForm.cc @@ -8,19 +8,42 @@ class UiForm : public UiControl { public: UiForm(); DEFINE_CONTROL_METHODS() - void append(std::string label, UiControl *c, bool stretchy); + void append(std::string label, std::shared_ptr c, bool stretchy); void deleteAt(int index); bool getPadded(); void setPadded(bool padded); + ~UiForm(); + void onDestroy(uiControl *control) override; + + private: + // this hold references to children controls + // to avoid them being garbage collected + // until not destroyed. + std::vector> children; }; +UiForm::~UiForm() { + printf("UiForm %p destroyed with wrapper %p.\n", getHandle(), this); +} +void UiForm::onDestroy(uiControl *control) { + /* + freeing children to allow JS to garbage collect their wrapper classes + when there are no references to them left in JS code. + */ + children.clear(); +} UiForm::UiForm() : UiControl(uiControl(uiNewForm())) {} -void UiForm::append(std::string label, UiControl *c, bool stretchy) { - uiFormAppend(uiForm(getHandle()), label.c_str(), c->getHandle(), stretchy); +void UiForm::append(std::string label, std::shared_ptr c, + bool stretchy) { + children.push_back(c); + + uiFormAppend(uiForm(getHandle()), label.c_str(), c.get()->getHandle(), + stretchy); } void UiForm::deleteAt(int index) { + children.erase(children.begin() + index); uiFormDelete(uiForm(getHandle()), index); } diff --git a/src/UiGrid.cc b/src/UiGrid.cc index 937e596..2019bf7 100644 --- a/src/UiGrid.cc +++ b/src/UiGrid.cc @@ -8,14 +8,34 @@ class UiGrid : public UiControl { UiGrid(); bool getPadded(); void setPadded(bool value); - void append(UiControl *c, int left, int top, int xspan, int yspan, - int hexpand, int halign, int vexpand, int valign); - void insertAt(UiControl *c, UiControl *existing, int at, int xspan, - int yspan, int hexpand, int halign, int vexpand, int valign); + void append(std::shared_ptr c, int left, int top, int xspan, + int yspan, int hexpand, int halign, int vexpand, int valign); + void insertAt(std::shared_ptr c, UiControl *existing, int at, + int xspan, int yspan, int hexpand, int halign, int vexpand, + int valign); DEFINE_CONTROL_METHODS() + ~UiGrid(); + void onDestroy(uiControl *control) override; + + private: + // this hold references to children controls + // to avoid them being garbage collected + // until not destroyed. + std::vector> children; }; +UiGrid::~UiGrid() { + printf("UiGrid %p destroyed with wrapper %p.\n", getHandle(), this); +} + +void UiGrid::onDestroy(uiControl *control) { + /* + freeing children to allow JS to garbage collect their wrapper classes + when there are no references to them left in JS code. + */ + children.clear(); +} UiGrid::UiGrid() : UiControl((uiControl *)uiNewGrid()) {} bool UiGrid::getPadded() { @@ -26,17 +46,22 @@ void UiGrid::setPadded(bool value) { uiGridSetPadded((uiGrid *)getHandle(), value); } -void UiGrid::append(UiControl *c, int left, int top, int xspan, int yspan, - int hexpand, int halign, int vexpand, int valign) { - uiGridAppend((uiGrid *)getHandle(), c->getHandle(), left, top, xspan, yspan, - hexpand, halign, vexpand, valign); +void UiGrid::append(std::shared_ptr c, int left, int top, int xspan, + int yspan, int hexpand, int halign, int vexpand, + int valign) { + children.push_back(c); + + uiGridAppend((uiGrid *)getHandle(), c.get()->getHandle(), left, top, xspan, + yspan, hexpand, halign, vexpand, valign); } -void UiGrid::insertAt(UiControl *c, UiControl *existing, int at, int xspan, - int yspan, int hexpand, int halign, int vexpand, - int valign) { - uiGridInsertAt((uiGrid *)getHandle(), c->getHandle(), existing->getHandle(), - at, xspan, yspan, hexpand, halign, vexpand, valign); +void UiGrid::insertAt(std::shared_ptr c, UiControl *existing, int at, + int xspan, int yspan, int hexpand, int halign, + int vexpand, int valign) { + children.push_back(c); + uiGridInsertAt((uiGrid *)getHandle(), c.get()->getHandle(), + existing->getHandle(), at, xspan, yspan, hexpand, halign, + vexpand, valign); } INHERITS_CONTROL_METHODS(UiGrid) diff --git a/src/UiGroup.cc b/src/UiGroup.cc index 3a57120..33b9668 100644 --- a/src/UiGroup.cc +++ b/src/UiGroup.cc @@ -4,23 +4,44 @@ #include "ui.h" class UiGroup : public UiControl { + private: + // this hold a reference to child control + // to avoid it being garbage collected + // until not destroyed. + std::shared_ptr child; + public: UiGroup(std::string text); UiGroup(); - void setChild(UiControl *control); + ~UiGroup(); + void onDestroy(uiControl *control) override; + void setChild(std::shared_ptr control); bool getMargined(); void setMargined(bool margined); std::string getTitle(); void setTitle(std::string title); + DEFINE_CONTROL_METHODS() }; +UiGroup::~UiGroup() { + printf("UiGroup %p destroyed with wrapper %p.\n", getHandle(), this); +} + +void UiGroup::onDestroy(uiControl *control) { + /* + freeing children to allow JS to garbage collect their wrapper classes + when there are no references to them left in JS code. + */ + child = nullptr; +} UiGroup::UiGroup(std::string text) : UiControl(uiControl(uiNewGroup(text.c_str()))) {} UiGroup::UiGroup() : UiControl(uiControl(uiNewGroup(""))) {} -void UiGroup::setChild(UiControl *control) { - uiGroupSetChild(uiGroup(getHandle()), control->getHandle()); +void UiGroup::setChild(std::shared_ptr control) { + child = control; + uiGroupSetChild(uiGroup(getHandle()), control.get()->getHandle()); } bool UiGroup::getMargined() { diff --git a/src/UiMultilineEntry.cc b/src/UiMultilineEntry.cc index 1aa19c9..6ed16e4 100644 --- a/src/UiMultilineEntry.cc +++ b/src/UiMultilineEntry.cc @@ -20,7 +20,7 @@ class UiMultilineEntry : public UiControl { UiMultilineEntry::~UiMultilineEntry() { // printf("UiMultilineEntry %p destroyed with wrapper %p.\n", getHandle(), - this); + // this); } void UiMultilineEntry::onDestroy(uiControl *control) { diff --git a/src/UiRadioButtons.cc b/src/UiRadioButtons.cc index 7a228d2..fa2e1bb 100644 --- a/src/UiRadioButtons.cc +++ b/src/UiRadioButtons.cc @@ -13,8 +13,23 @@ class UiRadioButtons : public UiControl { void setSelected(int n); DEFINE_CONTROL_METHODS() + ~UiRadioButtons(); + void onDestroy(uiControl *control) override; }; +UiRadioButtons::~UiRadioButtons() { + // printf("UiRadioButtons %p destroyed with wrapper %p.\n", getHandle(), + // this); +} + +void UiRadioButtons::onDestroy(uiControl *control) { + /* + freeing event callbacks to allow JS to garbage collect this class + when there are no references to it left in JS code. + */ + DISPOSE_EVENT(onSelected); +} + UiRadioButtons::UiRadioButtons() : UiControl((uiControl *)uiNewRadioButtons()) {} diff --git a/src/UiSlider.cc b/src/UiSlider.cc index a92dc55..bceb421 100644 --- a/src/UiSlider.cc +++ b/src/UiSlider.cc @@ -12,8 +12,23 @@ class UiSlider : public UiControl { int getValue(); void setValue(int value); + ~UiSlider(); + void onDestroy(uiControl *control) override; }; +UiSlider::~UiSlider() { + // printf("UiSlider %p destroyed with wrapper %p.\n", getHandle(), + // this); +} + +void UiSlider::onDestroy(uiControl *control) { + /* + freeing event callbacks to allow JS to garbage collect this class + when there are no references to it left in JS code. + */ + DISPOSE_EVENT(onChanged); +} + UiSlider::UiSlider(int min, int max) : UiControl((uiControl *)uiNewSlider(min, max)) {} diff --git a/src/UiTab.cc b/src/UiTab.cc index 4730037..52b1fc7 100644 --- a/src/UiTab.cc +++ b/src/UiTab.cc @@ -6,29 +6,54 @@ class UiTab : public UiControl { public: UiTab(); - void append(std::string text, UiControl *child); - void insertAt(std::string name, int before, UiControl *child); + void append(std::string text, std::shared_ptr child); + void insertAt(std::string name, int before, + std::shared_ptr child); void deleteAt(int index); int numPages(); bool getMargined(int page); void setMargined(int page, bool margined); DEFINE_CONTROL_METHODS() + ~UiTab(); + void onDestroy(uiControl *control) override; + + private: + // this hold references to children controls + // to avoid them being garbage collected + // until not destroyed. + std::vector> children; }; +UiTab::~UiTab() { + printf("UiTab %p destroyed with wrapper %p.\n", getHandle(), this); +} + +void UiTab::onDestroy(uiControl *control) { + /* + freeing children to allow JS to garbage collect their wrapper classes + when there are no references to them left in JS code. + */ + children.clear(); +} UiTab::UiTab() : UiControl((uiControl *)uiNewTab()) {} INHERITS_CONTROL_METHODS(UiTab) -void UiTab::append(std::string text, UiControl *child) { - uiTabAppend(uiTab(getHandle()), text.c_str(), child->getHandle()); +void UiTab::append(std::string text, std::shared_ptr child) { + children.push_back(child); + uiTabAppend(uiTab(getHandle()), text.c_str(), child.get()->getHandle()); } -void UiTab::insertAt(std::string name, int before, UiControl *child) { - uiTabInsertAt(uiTab(getHandle()), name.c_str(), before, child->getHandle()); +void UiTab::insertAt(std::string name, int before, + std::shared_ptr child) { + children.insert(children.begin() + before, child); + uiTabInsertAt(uiTab(getHandle()), name.c_str(), before, + child.get()->getHandle()); } void UiTab::deleteAt(int index) { + children.erase(children.begin() + index); uiTabDelete(uiTab(getHandle()), index); } From d544dd39792e0099f2f2e8ff979fa159aaca91c3 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Fri, 13 Apr 2018 21:01:57 +0200 Subject: [PATCH 094/190] [WIP] other containers --- examples/check-control-destroy.js | 35 ++++++++++++++++++++++++------- src/UiEntry.cc | 2 +- src/UiGrid.cc | 1 - 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/examples/check-control-destroy.js b/examples/check-control-destroy.js index dbc17d5..fd99986 100644 --- a/examples/check-control-destroy.js +++ b/examples/check-control-destroy.js @@ -86,20 +86,41 @@ function createWindow() { const box = new libui.UiVerticalBox(); box.append(widget1, true); box.append(widget2, true); + box.append(widget3, true); box.append(widget4, true); box.append(widget5, true); box.append(widget6, true); - box.append(widget7, true); box.append(widget8, true); - box.append(widget9, true); - box.append(widget10, true); - box.append(widget11, true); - box.append(widget12, true); - box.append(widget13, true); - win.setChild(box); + const box2 = new libui.UiVerticalBox(); + box2.append(widget9, true); + box2.append(widget10, true); + box2.append(widget11, true); + box2.append(widget12, true); + box2.append(widget13, true); + /* + const widget14 = new libui.UiGroup(); + widget14.child = new libui.UiEntry(); + + const widget15 = new libui.UiTab(); + widget15.append('xxx',new libui.UiEntry()); + widget15.append('yyy',new libui.UiEntry()); + + const widget16 = new libui.UiForm(); + widget16.append('xxx',new libui.UiEntry(), true); + widget16.append('yyy',new libui.UiEntry(), true); + + box2.append(widget14, true); + box2.append(widget15, true); + box2.append(widget16, true); +*/ + const horz = new libui.UiHorizontalBox(); + horz.append(box, true); + horz.append(box2, true); + + win.setChild(horz); win.onClosing(() => { win.close(); diff --git a/src/UiEntry.cc b/src/UiEntry.cc index e1b27e0..f401b7d 100644 --- a/src/UiEntry.cc +++ b/src/UiEntry.cc @@ -17,7 +17,7 @@ class UiEntryBase : public UiControl { }; UiEntryBase::~UiEntryBase() { - // printf("%s %p destroyed with wrapper %p.\n", n, getHandle(), this); + printf("%s %p destroyed with wrapper %p.\n", n, getHandle(), this); } void UiEntryBase::onDestroy(uiControl *control) { diff --git a/src/UiGrid.cc b/src/UiGrid.cc index 2019bf7..ac89424 100644 --- a/src/UiGrid.cc +++ b/src/UiGrid.cc @@ -50,7 +50,6 @@ void UiGrid::append(std::shared_ptr c, int left, int top, int xspan, int yspan, int hexpand, int halign, int vexpand, int valign) { children.push_back(c); - uiGridAppend((uiGrid *)getHandle(), c.get()->getHandle(), left, top, xspan, yspan, hexpand, halign, vexpand, valign); } From 1d1f754cb67a99865b2f902e4da2adb46fda8395 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Fri, 13 Apr 2018 21:47:01 +0200 Subject: [PATCH 095/190] [WIP] valgrind --- examples/check-control-destroy.js | 15 +++++++-------- src/UiWindow.cc | 6 ++++++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/examples/check-control-destroy.js b/examples/check-control-destroy.js index fd99986..8c3fa4c 100644 --- a/examples/check-control-destroy.js +++ b/examples/check-control-destroy.js @@ -86,7 +86,6 @@ function createWindow() { const box = new libui.UiVerticalBox(); box.append(widget1, true); box.append(widget2, true); - box.append(widget3, true); box.append(widget4, true); box.append(widget5, true); @@ -100,22 +99,22 @@ function createWindow() { box2.append(widget11, true); box2.append(widget12, true); box2.append(widget13, true); - /* + const widget14 = new libui.UiGroup(); widget14.child = new libui.UiEntry(); const widget15 = new libui.UiTab(); - widget15.append('xxx',new libui.UiEntry()); - widget15.append('yyy',new libui.UiEntry()); + widget15.append('xxx', new libui.UiEntry()); + widget15.append('yyy', new libui.UiEntry()); const widget16 = new libui.UiForm(); - widget16.append('xxx',new libui.UiEntry(), true); - widget16.append('yyy',new libui.UiEntry(), true); + widget16.append('xxx', new libui.UiEntry(), true); + widget16.append('yyy', new libui.UiEntry(), true); box2.append(widget14, true); box2.append(widget15, true); box2.append(widget16, true); -*/ + const horz = new libui.UiHorizontalBox(); horz.append(box, true); horz.append(box2, true); @@ -135,7 +134,7 @@ function op() { global.gc(); const win = createWindow(); win.show(); - // return; + return; setTimeout(() => { win.close(); op(); diff --git a/src/UiWindow.cc b/src/UiWindow.cc index b42c94b..e57aade 100644 --- a/src/UiWindow.cc +++ b/src/UiWindow.cc @@ -18,6 +18,7 @@ class UiWindow { public: UiWindow(std::string title, int width, int height, bool hasMenubar); + ~UiWindow(); uiWindow *getHandle(); void show(); void close(); @@ -70,6 +71,10 @@ void UiWindow::show() { uiControlShow(uiControl(win)); } +UiWindow::~UiWindow() { + printf("UiWindow %p destroyed with wrapper %p.\n", getHandle(), win); +} + void UiWindow::close() { uiControlDestroy(uiControl(win)); /* @@ -80,6 +85,7 @@ void UiWindow::close() { DISPOSE_EVENT(onContentSizeChanged); child = nullptr; + printf("UiWindow closed.\n"); } void UiWindow::setMargined(bool margined) { From 9c262e6beaeef5531e313773eada7d7b0bbd7cbd Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 14 Apr 2018 07:13:51 +0200 Subject: [PATCH 096/190] Comment log lines --- src/UiEntry.cc | 2 +- src/UiForm.cc | 2 +- src/UiGrid.cc | 2 +- src/UiGroup.cc | 2 +- src/UiTab.cc | 2 +- src/UiWindow.cc | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/UiEntry.cc b/src/UiEntry.cc index f401b7d..9e07a39 100644 --- a/src/UiEntry.cc +++ b/src/UiEntry.cc @@ -17,7 +17,7 @@ class UiEntryBase : public UiControl { }; UiEntryBase::~UiEntryBase() { - printf("%s %p destroyed with wrapper %p.\n", n, getHandle(), this); + // printf("%s %p destroyed with wrapper %p.\n", n, getHandle(), this); } void UiEntryBase::onDestroy(uiControl *control) { diff --git a/src/UiForm.cc b/src/UiForm.cc index 6d4422c..9747e0c 100644 --- a/src/UiForm.cc +++ b/src/UiForm.cc @@ -22,7 +22,7 @@ class UiForm : public UiControl { std::vector> children; }; UiForm::~UiForm() { - printf("UiForm %p destroyed with wrapper %p.\n", getHandle(), this); + // printf("UiForm %p destroyed with wrapper %p.\n", getHandle(), this); } void UiForm::onDestroy(uiControl *control) { diff --git a/src/UiGrid.cc b/src/UiGrid.cc index ac89424..6433237 100644 --- a/src/UiGrid.cc +++ b/src/UiGrid.cc @@ -26,7 +26,7 @@ class UiGrid : public UiControl { }; UiGrid::~UiGrid() { - printf("UiGrid %p destroyed with wrapper %p.\n", getHandle(), this); + // printf("UiGrid %p destroyed with wrapper %p.\n", getHandle(), this); } void UiGrid::onDestroy(uiControl *control) { diff --git a/src/UiGroup.cc b/src/UiGroup.cc index 33b9668..054a97b 100644 --- a/src/UiGroup.cc +++ b/src/UiGroup.cc @@ -25,7 +25,7 @@ class UiGroup : public UiControl { }; UiGroup::~UiGroup() { - printf("UiGroup %p destroyed with wrapper %p.\n", getHandle(), this); + // printf("UiGroup %p destroyed with wrapper %p.\n", getHandle(), this); } void UiGroup::onDestroy(uiControl *control) { diff --git a/src/UiTab.cc b/src/UiTab.cc index 52b1fc7..3766e8c 100644 --- a/src/UiTab.cc +++ b/src/UiTab.cc @@ -26,7 +26,7 @@ class UiTab : public UiControl { }; UiTab::~UiTab() { - printf("UiTab %p destroyed with wrapper %p.\n", getHandle(), this); + // printf("UiTab %p destroyed with wrapper %p.\n", getHandle(), this); } void UiTab::onDestroy(uiControl *control) { diff --git a/src/UiWindow.cc b/src/UiWindow.cc index e57aade..d6ed484 100644 --- a/src/UiWindow.cc +++ b/src/UiWindow.cc @@ -72,7 +72,7 @@ void UiWindow::show() { } UiWindow::~UiWindow() { - printf("UiWindow %p destroyed with wrapper %p.\n", getHandle(), win); + // printf("UiWindow %p destroyed with wrapper %p.\n", getHandle(), win); } void UiWindow::close() { @@ -85,7 +85,7 @@ void UiWindow::close() { DISPOSE_EVENT(onContentSizeChanged); child = nullptr; - printf("UiWindow closed.\n"); + // printf("UiWindow closed.\n"); } void UiWindow::setMargined(bool margined) { From 19450423e4b550881f7a66bc5de8bf16bae64c0b Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 14 Apr 2018 08:37:31 +0200 Subject: [PATCH 097/190] removed macro -> UiEditableCombobox --- examples/check-control-destroy.js | 3 +++ src/UiEditableCombobox.cc | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/check-control-destroy.js b/examples/check-control-destroy.js index 8c3fa4c..5085623 100644 --- a/examples/check-control-destroy.js +++ b/examples/check-control-destroy.js @@ -42,6 +42,9 @@ function createWindow() { }); const widget6 = new libui.UiEditableCombobox(); + widget6.append('sally'); + widget6.append('tati'); + widget6.append('parro'); widget6.onChanged(() => { console.log(`widget6 changed to ${widget6.text}`); }); diff --git a/src/UiEditableCombobox.cc b/src/UiEditableCombobox.cc index d6f638a..5ba80d0 100644 --- a/src/UiEditableCombobox.cc +++ b/src/UiEditableCombobox.cc @@ -8,7 +8,6 @@ class UiEditableCombobox : public UiControl { public: UiEditableCombobox(); - // DEFINE_CONTROL_METHODS() void append(std::string text); std::string getText(); void setText(std::string text); @@ -32,8 +31,6 @@ void UiEditableCombobox::onDestroy(uiControl *control) { UiEditableCombobox::UiEditableCombobox() : UiControl(uiControl(uiNewEditableCombobox())) {} -// INHERITS_CONTROL_METHODS(UiEditableCombobox) - IMPLEMENT_EVENT(UiEditableCombobox, uiEditableCombobox, onChanged, uiEditableComboboxOnChanged) From 1ecb48e4972714d67cebbcf511ebfe8320bf6b1a Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 14 Apr 2018 08:41:15 +0200 Subject: [PATCH 098/190] removed macro -> UiBox --- src/UiBox.cc | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/UiBox.cc b/src/UiBox.cc index b311da3..e0aa851 100644 --- a/src/UiBox.cc +++ b/src/UiBox.cc @@ -23,14 +23,12 @@ class UiVerticalBox : public UiBox { public: UiVerticalBox(); DEFINE_BOX_METHODS() - DEFINE_CONTROL_METHODS() }; class UiHorizontalBox : public UiBox { public: UiHorizontalBox(); DEFINE_BOX_METHODS() - DEFINE_CONTROL_METHODS() }; UiBox::~UiBox() { @@ -66,22 +64,20 @@ bool UiBox::getPadded() { UiVerticalBox::UiVerticalBox() : UiBox((uiControl *)uiNewVerticalBox()) {} -INHERITS_CONTROL_METHODS(UiVerticalBox) INHERITS_BOX_METHODS(UiVerticalBox) UiHorizontalBox::UiHorizontalBox() : UiBox((uiControl *)uiNewHorizontalBox()) {} -INHERITS_CONTROL_METHODS(UiHorizontalBox) INHERITS_BOX_METHODS(UiHorizontalBox) NBIND_CLASS(UiVerticalBox) { + inherit(UiControl); construct<>(); - DECLARE_CHILD_CONTROL_METHODS() DECLARE_BOX_METHODS() } NBIND_CLASS(UiHorizontalBox) { + inherit(UiControl); construct<>(); - DECLARE_CHILD_CONTROL_METHODS() DECLARE_BOX_METHODS() } From 5c77126792a974d7e776c7fc8742e56ec67a61a8 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 14 Apr 2018 08:42:34 +0200 Subject: [PATCH 099/190] removed macro -> UiButton --- src/UiButton.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/UiButton.cc b/src/UiButton.cc index 696b415..dd5550f 100644 --- a/src/UiButton.cc +++ b/src/UiButton.cc @@ -9,7 +9,6 @@ class UiButton : public UiControl { public: UiButton(std::string text); UiButton(); - DEFINE_CONTROL_METHODS() void setText(std::string text); std::string getText(); ~UiButton(); @@ -30,9 +29,8 @@ UiButton::~UiButton() { UiButton::UiButton(std::string text) : UiControl(uiControl(uiNewButton(text.c_str()))) {} -UiButton::UiButton() : UiControl(uiControl(uiNewButton(""))) {} -INHERITS_CONTROL_METHODS(UiButton) +UiButton::UiButton() : UiControl(uiControl(uiNewButton(""))) {} void UiButton::setText(std::string text) { uiButtonSetText(uiButton(getHandle()), text.c_str()); @@ -48,9 +46,9 @@ std::string UiButton::getText() { IMPLEMENT_EVENT(UiButton, uiButton, onClicked, uiButtonOnClicked) NBIND_CLASS(UiButton) { + inherit(UiControl); construct(); construct<>(); - DECLARE_CHILD_CONTROL_METHODS() getset(getText, setText); method(getText); method(setText); From 88c7ccd21c117003086c65d4d2d868007c0c2eb8 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 14 Apr 2018 08:44:46 +0200 Subject: [PATCH 100/190] removed macro -> UiCheckbox --- src/UiCheckbox.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/UiCheckbox.cc b/src/UiCheckbox.cc index 6de340e..ea35a59 100644 --- a/src/UiCheckbox.cc +++ b/src/UiCheckbox.cc @@ -9,7 +9,6 @@ class UiCheckbox : public UiControl { public: UiCheckbox(std::string text); UiCheckbox(); - DEFINE_CONTROL_METHODS() void setText(std::string text); std::string getText(); void setChecked(bool checked); @@ -36,8 +35,6 @@ UiCheckbox::UiCheckbox(std::string text) : UiControl(uiControl(uiNewCheckbox(text.c_str()))) {} UiCheckbox::UiCheckbox() : UiControl(uiControl(uiNewCheckbox(""))) {} -INHERITS_CONTROL_METHODS(UiCheckbox) - void UiCheckbox::setText(std::string text) { uiCheckboxSetText(uiCheckbox(getHandle()), text.c_str()); } @@ -61,9 +58,9 @@ bool UiCheckbox::getChecked() { } NBIND_CLASS(UiCheckbox) { + inherit(UiControl); construct(); construct<>(); - DECLARE_CHILD_CONTROL_METHODS() getset(getChecked, setChecked); getset(getText, setText); method(getChecked); From 27b93a9549b02a0a819785960038df1abc2e0f57 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 14 Apr 2018 08:46:28 +0200 Subject: [PATCH 101/190] removed macro -> UiColorButton --- src/UiColorButton.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/UiColorButton.cc b/src/UiColorButton.cc index 2b74ddd..b105028 100644 --- a/src/UiColorButton.cc +++ b/src/UiColorButton.cc @@ -10,7 +10,6 @@ class UiColorButton : public UiControl { UiColorButton(); Color getColor(); void setColor(Color value); - DEFINE_CONTROL_METHODS() ~UiColorButton(); void onDestroy(uiControl *control) override; }; @@ -30,8 +29,6 @@ UiColorButton::~UiColorButton() { UiColorButton::UiColorButton() : UiControl((uiControl *)uiNewColorButton()) {} -INHERITS_CONTROL_METHODS(UiColorButton) - IMPLEMENT_EVENT(UiColorButton, uiColorButton, onChanged, uiColorButtonOnChanged) void UiColorButton::setColor(Color color) { @@ -54,8 +51,8 @@ Color UiColorButton::getColor() { } NBIND_CLASS(UiColorButton) { + inherit(UiControl); construct<>(); - DECLARE_CHILD_CONTROL_METHODS() method(setColor); method(getColor); method(onChanged); From c112beabd55bd3ca6427c45076feefe8de3f70db Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 14 Apr 2018 08:51:10 +0200 Subject: [PATCH 102/190] removed macro -> UiCombobox --- src/UiCombobox.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/UiCombobox.cc b/src/UiCombobox.cc index 87095e4..cb94add 100644 --- a/src/UiCombobox.cc +++ b/src/UiCombobox.cc @@ -8,7 +8,7 @@ class UiCombobox : public UiControl { public: UiCombobox(); - DEFINE_CONTROL_METHODS() + void append(std::string text); int getSelected(); void setSelected(int n); @@ -30,8 +30,6 @@ UiCombobox::~UiCombobox() { UiCombobox::UiCombobox() : UiControl((uiControl *)uiNewCombobox()) {} -INHERITS_CONTROL_METHODS(UiCombobox) - IMPLEMENT_EVENT(UiCombobox, uiCombobox, onSelected, uiComboboxOnSelected) void UiCombobox::append(std::string text) { @@ -50,8 +48,8 @@ void UiCombobox::setSelected(int n) { } NBIND_CLASS(UiCombobox) { + inherit(UiControl); construct<>(); - DECLARE_CHILD_CONTROL_METHODS() method(append); getset(getSelected, setSelected); method(getSelected); From 21e259746bde3e035a842b5ea0ddad2c50fb2139 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 14 Apr 2018 09:04:36 +0200 Subject: [PATCH 103/190] removed macro -> UiDateTimePicker --- src/UiDateTimePicker.cc | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/UiDateTimePicker.cc b/src/UiDateTimePicker.cc index 586d85c..2baf525 100644 --- a/src/UiDateTimePicker.cc +++ b/src/UiDateTimePicker.cc @@ -5,45 +5,36 @@ class UiDateTimePicker : public UiControl { public: UiDateTimePicker(); - DEFINE_CONTROL_METHODS() }; UiDateTimePicker::UiDateTimePicker() : UiControl((uiControl *)uiNewDateTimePicker()) {} -INHERITS_CONTROL_METHODS(UiDateTimePicker) - NBIND_CLASS(UiDateTimePicker) { + inherit(UiControl); construct<>(); - DECLARE_CHILD_CONTROL_METHODS() } class UiTimePicker : public UiControl { public: UiTimePicker(); - DEFINE_CONTROL_METHODS() }; UiTimePicker::UiTimePicker() : UiControl((uiControl *)uiNewTimePicker()) {} -INHERITS_CONTROL_METHODS(UiTimePicker) - NBIND_CLASS(UiTimePicker) { + inherit(UiControl); construct<>(); - DECLARE_CHILD_CONTROL_METHODS() } class UiDatePicker : public UiControl { public: UiDatePicker(); - DEFINE_CONTROL_METHODS() }; UiDatePicker::UiDatePicker() : UiControl((uiControl *)uiNewDatePicker()) {} -INHERITS_CONTROL_METHODS(UiDatePicker) - NBIND_CLASS(UiDatePicker) { + inherit(UiControl); construct<>(); - DECLARE_CHILD_CONTROL_METHODS() } From d52a9a392efcb3921f9aa6e50838e6d36d95130b Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 14 Apr 2018 10:04:42 +0200 Subject: [PATCH 104/190] removed macro -> UiEntry & friends --- src/UiEditableCombobox.cc | 2 +- src/UiEntry.cc | 13 +++---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/UiEditableCombobox.cc b/src/UiEditableCombobox.cc index 5ba80d0..baf8a82 100644 --- a/src/UiEditableCombobox.cc +++ b/src/UiEditableCombobox.cc @@ -53,9 +53,9 @@ std::string UiEditableCombobox::getText() { } NBIND_CLASS(UiEditableCombobox) { - construct<>(); inherit(UiControl); method(append); + construct<>(); getset(getText, setText); method(getText); method(setText); diff --git a/src/UiEntry.cc b/src/UiEntry.cc index 9e07a39..695be08 100644 --- a/src/UiEntry.cc +++ b/src/UiEntry.cc @@ -10,7 +10,6 @@ class UiEntryBase : public UiControl { public: UiEntryBase(uiControl *, const char *name); - DEFINE_CONTROL_METHODS() DEFINE_ENTRY_METHODS() ~UiEntryBase(); void onDestroy(uiControl *control) override; @@ -31,7 +30,6 @@ void UiEntryBase::onDestroy(uiControl *control) { class UiEntry : public UiEntryBase { public: UiEntry(); - DEFINE_CONTROL_METHODS() DEFINE_ENTRY_METHODS() void onChanged(nbind::cbFunction &cb); }; @@ -39,7 +37,6 @@ class UiEntry : public UiEntryBase { class UiPasswordEntry : public UiEntryBase { public: UiPasswordEntry(); - DEFINE_CONTROL_METHODS() DEFINE_ENTRY_METHODS() void onChanged(nbind::cbFunction &cb); }; @@ -47,7 +44,6 @@ class UiPasswordEntry : public UiEntryBase { class UiSearchEntry : public UiEntryBase { public: UiSearchEntry(); - DEFINE_CONTROL_METHODS() DEFINE_ENTRY_METHODS() void onChanged(nbind::cbFunction &cb); }; @@ -82,35 +78,32 @@ IMPLEMENT_EVENT(UiEntryBase, uiEntry, onChanged, uiEntryOnChanged) UiEntry::UiEntry() : UiEntryBase(uiControl(uiNewEntry()), "UiEntry") {} -INHERITS_CONTROL_METHODS(UiEntry) INHERITS_ENTRY_METHODS(UiEntry) UiPasswordEntry::UiPasswordEntry() : UiEntryBase(uiControl(uiNewPasswordEntry()), "UiPasswordEntry") {} -INHERITS_CONTROL_METHODS(UiPasswordEntry) INHERITS_ENTRY_METHODS(UiPasswordEntry) UiSearchEntry::UiSearchEntry() : UiEntryBase(uiControl(uiNewSearchEntry()), "UiSearchEntry") {} -INHERITS_CONTROL_METHODS(UiSearchEntry) INHERITS_ENTRY_METHODS(UiSearchEntry) NBIND_CLASS(UiSearchEntry) { + inherit(UiControl); construct<>(); - DECLARE_CHILD_CONTROL_METHODS() DECLARE_ENTRY_METHODS() } NBIND_CLASS(UiPasswordEntry) { + inherit(UiControl); construct<>(); - DECLARE_CHILD_CONTROL_METHODS() DECLARE_ENTRY_METHODS() } NBIND_CLASS(UiEntry) { + inherit(UiControl); construct<>(); - DECLARE_CHILD_CONTROL_METHODS() DECLARE_ENTRY_METHODS() } From 5f51f2263c58ef7b1b521f213a643899a734fda8 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 14 Apr 2018 10:05:26 +0200 Subject: [PATCH 105/190] removed macro -> UiFontButton --- src/UiFontButton.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/UiFontButton.cc b/src/UiFontButton.cc index b463e88..c2eb8b1 100644 --- a/src/UiFontButton.cc +++ b/src/UiFontButton.cc @@ -10,7 +10,6 @@ class UiFontButton : public UiControl { public: UiFontButton(); DrawTextFont *getFont(); - DEFINE_CONTROL_METHODS() ~UiFontButton(); void onDestroy(uiControl *control) override; }; @@ -30,8 +29,6 @@ void UiFontButton::onDestroy(uiControl *control) { UiFontButton::UiFontButton() : UiControl((uiControl *)uiNewFontButton()) {} -INHERITS_CONTROL_METHODS(UiFontButton) - IMPLEMENT_EVENT(UiFontButton, uiFontButton, onChanged, uiFontButtonOnChanged) DrawTextFont *UiFontButton::getFont() { @@ -39,8 +36,8 @@ DrawTextFont *UiFontButton::getFont() { } NBIND_CLASS(UiFontButton) { + inherit(UiControl); construct<>(); - DECLARE_CHILD_CONTROL_METHODS() method(getFont); method(onChanged); } From c98f38e88c4f2c7be27c7c1a157ca443b9f42652 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 14 Apr 2018 10:09:54 +0200 Subject: [PATCH 106/190] removed macro -> UiForm --- src/UiForm.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/UiForm.cc b/src/UiForm.cc index 9747e0c..ce29fcc 100644 --- a/src/UiForm.cc +++ b/src/UiForm.cc @@ -7,7 +7,6 @@ class UiForm : public UiControl { public: UiForm(); - DEFINE_CONTROL_METHODS() void append(std::string label, std::shared_ptr c, bool stretchy); void deleteAt(int index); bool getPadded(); @@ -55,14 +54,12 @@ void UiForm::setPadded(bool padded) { uiFormSetPadded(uiForm(getHandle()), padded); } -INHERITS_CONTROL_METHODS(UiForm) - NBIND_CLASS(UiForm) { + inherit(UiControl); construct<>(); method(append); method(deleteAt); method(getPadded); method(setPadded); getset(getPadded, setPadded); - DECLARE_CHILD_CONTROL_METHODS() } From 0a6b144631e87de8016d32676a7e60755acb8d4c Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 14 Apr 2018 10:10:47 +0200 Subject: [PATCH 107/190] removed macro -> UiGrid --- src/UiGrid.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/UiGrid.cc b/src/UiGrid.cc index 6433237..28231d5 100644 --- a/src/UiGrid.cc +++ b/src/UiGrid.cc @@ -14,7 +14,6 @@ class UiGrid : public UiControl { int xspan, int yspan, int hexpand, int halign, int vexpand, int valign); - DEFINE_CONTROL_METHODS() ~UiGrid(); void onDestroy(uiControl *control) override; @@ -63,14 +62,12 @@ void UiGrid::insertAt(std::shared_ptr c, UiControl *existing, int at, vexpand, valign); } -INHERITS_CONTROL_METHODS(UiGrid) - NBIND_CLASS(UiGrid) { + inherit(UiControl); construct<>(); method(append); method(insertAt); method(getPadded); method(setPadded); getset(getPadded, setPadded); - DECLARE_CHILD_CONTROL_METHODS() } From 4e1e8b85e2264ec0089ee2d5d00ca83c541bb2d6 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 14 Apr 2018 10:11:30 +0200 Subject: [PATCH 108/190] removed macro -> UiGroup --- src/UiGroup.cc | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/UiGroup.cc b/src/UiGroup.cc index 054a97b..5bd8b5e 100644 --- a/src/UiGroup.cc +++ b/src/UiGroup.cc @@ -20,8 +20,6 @@ class UiGroup : public UiControl { void setMargined(bool margined); std::string getTitle(); void setTitle(std::string title); - - DEFINE_CONTROL_METHODS() }; UiGroup::~UiGroup() { @@ -63,8 +61,6 @@ void UiGroup::setTitle(std::string title) { uiGroupSetTitle(uiGroup(getHandle()), title.c_str()); } -INHERITS_CONTROL_METHODS(UiGroup) - NBIND_CLASS(UiGroup) { construct(); construct<>(); @@ -75,5 +71,4 @@ NBIND_CLASS(UiGroup) { method(setMargined); getset(getTitle, setTitle); getset(getMargined, setMargined); - DECLARE_CHILD_CONTROL_METHODS() } From 47428ef3bce73d28fe60b4b721495a5f002f1831 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 14 Apr 2018 10:12:38 +0200 Subject: [PATCH 109/190] removed macro -> UiLabel --- src/UiGroup.cc | 1 + src/UiLabel.cc | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/UiGroup.cc b/src/UiGroup.cc index 5bd8b5e..f3265ec 100644 --- a/src/UiGroup.cc +++ b/src/UiGroup.cc @@ -62,6 +62,7 @@ void UiGroup::setTitle(std::string title) { } NBIND_CLASS(UiGroup) { + inherit(UiControl); construct(); construct<>(); method(setChild); diff --git a/src/UiLabel.cc b/src/UiLabel.cc index c6e506a..bb86e06 100644 --- a/src/UiLabel.cc +++ b/src/UiLabel.cc @@ -7,7 +7,6 @@ class UiLabel : public UiControl { public: UiLabel(); UiLabel(std::string text); - DEFINE_CONTROL_METHODS() void setText(std::string text); std::string getText(); }; @@ -16,8 +15,6 @@ UiLabel::UiLabel(std::string text) : UiControl(uiControl(uiNewLabel(text.c_str()))) {} UiLabel::UiLabel() : UiControl(uiControl(uiNewLabel(""))) {} -INHERITS_CONTROL_METHODS(UiLabel) - void UiLabel::setText(std::string text) { uiLabelSetText(uiLabel(getHandle()), text.c_str()); } @@ -30,9 +27,9 @@ std::string UiLabel::getText() { } NBIND_CLASS(UiLabel) { + inherit(UiControl); construct(); construct<>(); - DECLARE_CHILD_CONTROL_METHODS() getset(getText, setText); method(getText); method(setText); From 022931eab73df885ab52da678e723e09537ae2ff Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 14 Apr 2018 10:14:08 +0200 Subject: [PATCH 110/190] removed macro -> UiMultilineEntry --- src/UiMultilineEntry.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/UiMultilineEntry.cc b/src/UiMultilineEntry.cc index 6ed16e4..a0b29de 100644 --- a/src/UiMultilineEntry.cc +++ b/src/UiMultilineEntry.cc @@ -8,7 +8,6 @@ class UiMultilineEntry : public UiControl { public: UiMultilineEntry(); - DEFINE_CONTROL_METHODS() void setText(std::string text); std::string getText(); void setReadOnly(bool readOnly); @@ -33,8 +32,6 @@ void UiMultilineEntry::onDestroy(uiControl *control) { UiMultilineEntry::UiMultilineEntry() : UiControl(uiControl(uiNewNonWrappingMultilineEntry())) {} -INHERITS_CONTROL_METHODS(UiMultilineEntry) - IMPLEMENT_EVENT(UiMultilineEntry, uiMultilineEntry, onChanged, uiMultilineEntryOnChanged) @@ -65,8 +62,8 @@ void UiMultilineEntry::append(std::string text) { } NBIND_CLASS(UiMultilineEntry) { + inherit(UiControl); construct<>(); - DECLARE_CHILD_CONTROL_METHODS() getset(getText, setText); getset(getReadOnly, setReadOnly); method(getText); From 05fbd158ebb4940e820660c3f4a8cd6c3fbb907f Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 14 Apr 2018 10:14:53 +0200 Subject: [PATCH 111/190] removed macro -> UiProgressBar --- src/UiProgressBar.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/UiProgressBar.cc b/src/UiProgressBar.cc index 33a452b..49e2b1e 100644 --- a/src/UiProgressBar.cc +++ b/src/UiProgressBar.cc @@ -8,15 +8,12 @@ class UiProgressBar : public UiControl { public: UiProgressBar(); - DEFINE_CONTROL_METHODS() int getValue(); void setValue(int value); }; UiProgressBar::UiProgressBar() : UiControl((uiControl *)uiNewProgressBar()) {} -INHERITS_CONTROL_METHODS(UiProgressBar) - void UiProgressBar::setValue(int val) { value = val; uiProgressBarSetValue((uiProgressBar *)getHandle(), value); @@ -27,8 +24,8 @@ int UiProgressBar::getValue() { } NBIND_CLASS(UiProgressBar) { + inherit(UiControl); construct<>(); - DECLARE_CHILD_CONTROL_METHODS() getset(getValue, setValue); method(getValue); method(setValue); From 15e500d49f2c86822ae966f5a9f8941749ff3194 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 14 Apr 2018 10:15:46 +0200 Subject: [PATCH 112/190] removed macro -> UiRadioButtons --- src/UiRadioButtons.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/UiRadioButtons.cc b/src/UiRadioButtons.cc index fa2e1bb..0615eab 100644 --- a/src/UiRadioButtons.cc +++ b/src/UiRadioButtons.cc @@ -12,7 +12,6 @@ class UiRadioButtons : public UiControl { int getSelected(); void setSelected(int n); - DEFINE_CONTROL_METHODS() ~UiRadioButtons(); void onDestroy(uiControl *control) override; }; @@ -33,8 +32,6 @@ void UiRadioButtons::onDestroy(uiControl *control) { UiRadioButtons::UiRadioButtons() : UiControl((uiControl *)uiNewRadioButtons()) {} -INHERITS_CONTROL_METHODS(UiRadioButtons) - IMPLEMENT_EVENT(UiRadioButtons, uiRadioButtons, onSelected, uiRadioButtonsOnSelected) @@ -54,8 +51,8 @@ void UiRadioButtons::append(std::string text) { } NBIND_CLASS(UiRadioButtons) { + inherit(UiControl); construct<>(); - DECLARE_CHILD_CONTROL_METHODS() method(append); getset(getSelected, setSelected); method(getSelected); From edf724b6ce98a19456da91169e358887f2093621 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 14 Apr 2018 10:16:42 +0200 Subject: [PATCH 113/190] removed macro -> UiSeparator --- src/UiSeparator.cc | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/UiSeparator.cc b/src/UiSeparator.cc index 9395b4e..5e6b1f4 100644 --- a/src/UiSeparator.cc +++ b/src/UiSeparator.cc @@ -5,30 +5,24 @@ class UiHorizontalSeparator : public UiControl { public: UiHorizontalSeparator(); - DEFINE_CONTROL_METHODS() }; class UiVerticalSeparator : public UiControl { public: UiVerticalSeparator(); - DEFINE_CONTROL_METHODS() }; UiHorizontalSeparator::UiHorizontalSeparator() : UiControl((uiControl *)uiNewHorizontalSeparator()) {} -INHERITS_CONTROL_METHODS(UiHorizontalSeparator) - NBIND_CLASS(UiHorizontalSeparator) { + inherit(UiControl); construct<>(); - DECLARE_CHILD_CONTROL_METHODS() } UiVerticalSeparator::UiVerticalSeparator() : UiControl((uiControl *)uiNewVerticalSeparator()) {} -INHERITS_CONTROL_METHODS(UiVerticalSeparator) - NBIND_CLASS(UiVerticalSeparator) { + inherit(UiControl); construct<>(); - DECLARE_CHILD_CONTROL_METHODS() } From c79e5eadb24f30061be88a1bcc4e68102069e5fd Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 14 Apr 2018 10:26:14 +0200 Subject: [PATCH 114/190] removed macro -> UiSlider --- src/UiSlider.cc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/UiSlider.cc b/src/UiSlider.cc index bceb421..811a54f 100644 --- a/src/UiSlider.cc +++ b/src/UiSlider.cc @@ -8,8 +8,6 @@ class UiSlider : public UiControl { public: UiSlider(int min, int max); UiSlider(); - DEFINE_CONTROL_METHODS() - int getValue(); void setValue(int value); ~UiSlider(); @@ -47,12 +45,10 @@ void UiSlider::setValue(int value) { IMPLEMENT_EVENT(UiSlider, uiSlider, onChanged, uiSliderOnChanged) -INHERITS_CONTROL_METHODS(UiSlider) - NBIND_CLASS(UiSlider) { + inherit(UiControl); construct(); construct<>(); - DECLARE_CHILD_CONTROL_METHODS() getset(getValue, setValue); method(getValue); method(setValue); From eaf72a365a99d6f3d986397af83fd77f81b2dd99 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 14 Apr 2018 10:27:04 +0200 Subject: [PATCH 115/190] removed macro -> UiSpinbox --- src/UiSpinbox.cc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/UiSpinbox.cc b/src/UiSpinbox.cc index ae0bde6..46c8608 100644 --- a/src/UiSpinbox.cc +++ b/src/UiSpinbox.cc @@ -9,8 +9,6 @@ class UiSpinbox : public UiControl { UiSpinbox(int min, int max); UiSpinbox(); - DEFINE_CONTROL_METHODS() - int getValue(); void setValue(int value); ~UiSpinbox(); @@ -47,12 +45,10 @@ void UiSpinbox::setValue(int value) { IMPLEMENT_EVENT(UiSpinbox, uiSpinbox, onChanged, uiSpinboxOnChanged) -INHERITS_CONTROL_METHODS(UiSpinbox) - NBIND_CLASS(UiSpinbox) { + inherit(UiControl); construct(); construct<>(); - DECLARE_CHILD_CONTROL_METHODS() getset(getValue, setValue); method(getValue); method(setValue); From f5bddd655fd643648917aff7fb4407c29d76c27f Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 14 Apr 2018 10:27:52 +0200 Subject: [PATCH 116/190] removed macro -> UiTab --- src/UiTab.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/UiTab.cc b/src/UiTab.cc index 3766e8c..7b478c1 100644 --- a/src/UiTab.cc +++ b/src/UiTab.cc @@ -14,7 +14,6 @@ class UiTab : public UiControl { bool getMargined(int page); void setMargined(int page, bool margined); - DEFINE_CONTROL_METHODS() ~UiTab(); void onDestroy(uiControl *control) override; @@ -38,8 +37,6 @@ void UiTab::onDestroy(uiControl *control) { } UiTab::UiTab() : UiControl((uiControl *)uiNewTab()) {} -INHERITS_CONTROL_METHODS(UiTab) - void UiTab::append(std::string text, std::shared_ptr child) { children.push_back(child); uiTabAppend(uiTab(getHandle()), text.c_str(), child.get()->getHandle()); @@ -70,8 +67,8 @@ void UiTab::setMargined(int page, bool margined) { } NBIND_CLASS(UiTab) { + inherit(UiControl); construct<>(); - DECLARE_CHILD_CONTROL_METHODS() method(append); method(numPages); method(deleteAt); From f8943ad25fe1c2f9e3120017a57403ff04802d6e Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 14 Apr 2018 10:30:22 +0200 Subject: [PATCH 117/190] removed macro -> UiArea --- src/UiArea/UiArea.cc | 4 +--- src/includes/area.h | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/UiArea/UiArea.cc b/src/UiArea/UiArea.cc index 2c80be8..6399324 100644 --- a/src/UiArea/UiArea.cc +++ b/src/UiArea/UiArea.cc @@ -4,8 +4,6 @@ std::map areasMap; -INHERITS_CONTROL_METHODS(UiArea) - void UiArea::setSize(int width, int height) { uiAreaSetSize((uiArea *)getHandle(), width, height); } @@ -45,12 +43,12 @@ UiArea::UiArea(int dummy) : UiControl(NULL) {} #include "nbind/api.h" NBIND_CLASS(UiArea) { + inherit(UiControl); construct(); construct(); construct(); - DECLARE_CHILD_CONTROL_METHODS() method(setSize); method(queueRedrawAll); method(scrollTo); diff --git a/src/includes/area.h b/src/includes/area.h index 5d11d7b..e7de8f9 100644 --- a/src/includes/area.h +++ b/src/includes/area.h @@ -25,7 +25,6 @@ class UiArea : public UiControl { void setSize(int width, int height); void queueRedrawAll(); void scrollTo(double x, double y, double width, double height); - DEFINE_CONTROL_METHODS() }; extern std::map areasMap; From 39a44c64fb9f4ff41227449c31ae14cbaac07160 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 14 Apr 2018 10:40:00 +0200 Subject: [PATCH 118/190] Removed macro from header --- src/UiControl.cc | 10 ++++++- src/includes/control.h | 64 +++++------------------------------------- 2 files changed, 16 insertions(+), 58 deletions(-) diff --git a/src/UiControl.cc b/src/UiControl.cc index eb30588..85db9e6 100644 --- a/src/UiControl.cc +++ b/src/UiControl.cc @@ -73,5 +73,13 @@ void UiControl::setEnabled(bool enabled) { } NBIND_CLASS(UiControl) { - DECLARE_CONTROL_METHODS() + method(destroy); + method(setParent); + method(toplevel); + method(getVisible); + method(setVisible); + method(getEnabled); + method(setEnabled); + getset(getVisible, setVisible); + getset(getEnabled, setEnabled); } diff --git a/src/includes/control.h b/src/includes/control.h index 0b043dd..85c33b8 100644 --- a/src/includes/control.h +++ b/src/includes/control.h @@ -26,61 +26,6 @@ NAME##Callback = nullptr; \ } -#define DEFINE_CONTROL_METHODS() \ - void destroy(); \ - void setParent(UiControl *parent); \ - bool toplevel(); \ - bool getVisible(); \ - void setVisible(bool visible); \ - bool getEnabled(); \ - void setEnabled(bool enabled); - -#define INHERITS_CONTROL_METHODS(CLASS) \ - void CLASS::destroy() { \ - UiControl::destroy(); \ - } \ - void CLASS::setParent(UiControl *parent) { \ - UiControl::setParent(parent); \ - } \ - bool CLASS::toplevel() { \ - return UiControl::toplevel(); \ - } \ - bool CLASS::getVisible() { \ - return UiControl::getVisible(); \ - } \ - void CLASS::setVisible(bool visible) { \ - UiControl::setVisible(visible); \ - } \ - bool CLASS::getEnabled() { \ - return UiControl::getEnabled(); \ - } \ - void CLASS::setEnabled(bool enabled) { \ - UiControl::setEnabled(enabled); \ - } - -#define DECLARE_CHILD_CONTROL_METHODS() \ - inherit(UiControl); \ - method(destroy); \ - method(setParent); \ - method(toplevel); \ - method(getVisible); \ - method(setVisible); \ - method(getEnabled); \ - method(setEnabled); \ - getset(getVisible, setVisible); \ - getset(getEnabled, setEnabled); - -#define DECLARE_CONTROL_METHODS() \ - method(destroy); \ - method(setParent); \ - method(toplevel); \ - method(getVisible); \ - method(setVisible); \ - method(getEnabled); \ - method(setEnabled); \ - getset(getVisible, setVisible); \ - getset(getEnabled, setEnabled); - typedef void (*DestroyCb)(uiControl *); class UiControl { @@ -95,8 +40,13 @@ class UiControl { uiControl *getHandle(); UiControl(uiControl *hnd); virtual ~UiControl(); - - DEFINE_CONTROL_METHODS() + void destroy(); + void setParent(UiControl *parent); + bool toplevel(); + bool getVisible(); + void setVisible(bool visible); + bool getEnabled(); + void setEnabled(bool enabled); }; // This is included at end of file From ae1d2620d5e4b0b75849a6d61414fd627188ccc0 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 14 Apr 2018 10:43:34 +0200 Subject: [PATCH 119/190] UiBox --- src/UiBox.cc | 25 ++++++++++++++----------- src/includes/box.h | 31 ------------------------------- 2 files changed, 14 insertions(+), 42 deletions(-) delete mode 100644 src/includes/box.h diff --git a/src/UiBox.cc b/src/UiBox.cc index e0aa851..7e59584 100644 --- a/src/UiBox.cc +++ b/src/UiBox.cc @@ -1,7 +1,6 @@ #include #include #include "nbind/api.h" -#include "box.h" #include "control.h" #include "ui.h" @@ -16,19 +15,20 @@ class UiBox : public UiControl { // until not destroyed. std::vector> children; - DEFINE_BOX_METHODS() + void append(std::shared_ptr, bool stretchy); + void deleteAt(int index); + bool getPadded(); + void setPadded(bool padded); }; class UiVerticalBox : public UiBox { public: UiVerticalBox(); - DEFINE_BOX_METHODS() }; class UiHorizontalBox : public UiBox { public: UiHorizontalBox(); - DEFINE_BOX_METHODS() }; UiBox::~UiBox() { @@ -64,20 +64,23 @@ bool UiBox::getPadded() { UiVerticalBox::UiVerticalBox() : UiBox((uiControl *)uiNewVerticalBox()) {} -INHERITS_BOX_METHODS(UiVerticalBox) - UiHorizontalBox::UiHorizontalBox() : UiBox((uiControl *)uiNewHorizontalBox()) {} -INHERITS_BOX_METHODS(UiHorizontalBox) +NBIND_CLASS(UiBox) { + inherit(UiControl); + getset(getPadded, setPadded); + method(getPadded); + method(setPadded); + method(append); + method(deleteAt); +} NBIND_CLASS(UiVerticalBox) { - inherit(UiControl); + inherit(UiBox); construct<>(); - DECLARE_BOX_METHODS() } NBIND_CLASS(UiHorizontalBox) { - inherit(UiControl); + inherit(UiBox); construct<>(); - DECLARE_BOX_METHODS() } diff --git a/src/includes/box.h b/src/includes/box.h deleted file mode 100644 index 80b0d99..0000000 --- a/src/includes/box.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef UI_NODE_BOX -#define UI_NODE_BOX 1 - -#define DEFINE_BOX_METHODS() \ - void append(std::shared_ptr, bool stretchy); \ - void deleteAt(int index); \ - bool getPadded(); \ - void setPadded(bool padded); - -#define INHERITS_BOX_METHODS(CLASS) \ - void CLASS::append(std::shared_ptr control, bool stretchy) { \ - UiBox::append(control, stretchy); \ - } \ - void CLASS::deleteAt(int index) { \ - UiBox::deleteAt(index); \ - } \ - bool CLASS::getPadded() { \ - return UiBox::getPadded(); \ - } \ - void CLASS::setPadded(bool padded) { \ - UiBox::setPadded(padded); \ - } - -#define DECLARE_BOX_METHODS() \ - getset(getPadded, setPadded); \ - method(getPadded); \ - method(setPadded); \ - method(append); \ - method(deleteAt); - -#endif From a196d64e241f33d11eb6673279dbd81e35b87dc6 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 14 Apr 2018 10:49:34 +0200 Subject: [PATCH 120/190] UiEntry --- src/UiEntry.cc | 33 +++++++++++++++++---------------- src/includes/entry.h | 36 ------------------------------------ 2 files changed, 17 insertions(+), 52 deletions(-) delete mode 100644 src/includes/entry.h diff --git a/src/UiEntry.cc b/src/UiEntry.cc index 695be08..4f5bcd5 100644 --- a/src/UiEntry.cc +++ b/src/UiEntry.cc @@ -1,7 +1,6 @@ #include #include "nbind/api.h" #include "control.h" -#include "entry.h" #include "ui.h" class UiEntryBase : public UiControl { @@ -10,7 +9,10 @@ class UiEntryBase : public UiControl { public: UiEntryBase(uiControl *, const char *name); - DEFINE_ENTRY_METHODS() + void setText(std::string text); + std::string getText(); + void setReadOnly(bool readOnly); + bool getReadOnly(); ~UiEntryBase(); void onDestroy(uiControl *control) override; }; @@ -30,21 +32,18 @@ void UiEntryBase::onDestroy(uiControl *control) { class UiEntry : public UiEntryBase { public: UiEntry(); - DEFINE_ENTRY_METHODS() void onChanged(nbind::cbFunction &cb); }; class UiPasswordEntry : public UiEntryBase { public: UiPasswordEntry(); - DEFINE_ENTRY_METHODS() void onChanged(nbind::cbFunction &cb); }; class UiSearchEntry : public UiEntryBase { public: UiSearchEntry(); - DEFINE_ENTRY_METHODS() void onChanged(nbind::cbFunction &cb); }; @@ -78,32 +77,34 @@ IMPLEMENT_EVENT(UiEntryBase, uiEntry, onChanged, uiEntryOnChanged) UiEntry::UiEntry() : UiEntryBase(uiControl(uiNewEntry()), "UiEntry") {} -INHERITS_ENTRY_METHODS(UiEntry) - UiPasswordEntry::UiPasswordEntry() : UiEntryBase(uiControl(uiNewPasswordEntry()), "UiPasswordEntry") {} -INHERITS_ENTRY_METHODS(UiPasswordEntry) - UiSearchEntry::UiSearchEntry() : UiEntryBase(uiControl(uiNewSearchEntry()), "UiSearchEntry") {} -INHERITS_ENTRY_METHODS(UiSearchEntry) +NBIND_CLASS(UiEntryBase) { + inherit(UiControl); + getset(getText, setText); + getset(getReadOnly, setReadOnly); + method(onChanged); + method(getText); + method(setText); + method(getReadOnly); + method(setReadOnly); +} NBIND_CLASS(UiSearchEntry) { - inherit(UiControl); + inherit(UiEntryBase); construct<>(); - DECLARE_ENTRY_METHODS() } NBIND_CLASS(UiPasswordEntry) { - inherit(UiControl); + inherit(UiEntryBase); construct<>(); - DECLARE_ENTRY_METHODS() } NBIND_CLASS(UiEntry) { - inherit(UiControl); + inherit(UiEntryBase); construct<>(); - DECLARE_ENTRY_METHODS() } diff --git a/src/includes/entry.h b/src/includes/entry.h deleted file mode 100644 index 37af491..0000000 --- a/src/includes/entry.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef UI_NODE_ENTRY -#define UI_NODE_ENTRY 1 - -#define DEFINE_ENTRY_METHODS() \ - void setText(std::string text); \ - std::string getText(); \ - void setReadOnly(bool readOnly); \ - bool getReadOnly(); - -#define INHERITS_ENTRY_METHODS(CLASS) \ - void CLASS::setText(std::string text) { \ - UiEntryBase::setText(text); \ - } \ - std::string CLASS::getText() { \ - return UiEntryBase::getText(); \ - } \ - void CLASS::setReadOnly(bool readOnly) { \ - UiEntryBase::setReadOnly(readOnly); \ - } \ - bool CLASS::getReadOnly() { \ - return UiEntryBase::getReadOnly(); \ - } \ - void CLASS::onChanged(nbind::cbFunction &cb) { \ - UiEntryBase::onChanged(cb); \ - } - -#define DECLARE_ENTRY_METHODS() \ - getset(getText, setText); \ - getset(getReadOnly, setReadOnly); \ - method(onChanged); \ - method(getText); \ - method(setText); \ - method(getReadOnly); \ - method(setReadOnly); - -#endif From eb61e12bc1d9994d4c9099bd077e327dfe912ed1 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 14 Apr 2018 11:58:07 +0200 Subject: [PATCH 121/190] Replaces areasMap and removed now unneeded constructor from UiArea --- src/UiArea/UiArea.cc | 14 ++------------ src/UiArea/UiAreaHandler.cc | 10 +++++----- src/includes/area.h | 7 ------- src/includes/control.h | 3 +++ 4 files changed, 10 insertions(+), 24 deletions(-) diff --git a/src/UiArea/UiArea.cc b/src/UiArea/UiArea.cc index 6399324..ab62f09 100644 --- a/src/UiArea/UiArea.cc +++ b/src/UiArea/UiArea.cc @@ -2,8 +2,6 @@ #include "control.h" #include "ui.h" -std::map areasMap; - void UiArea::setSize(int width, int height) { uiAreaSetSize((uiArea *)getHandle(), width, height); } @@ -22,9 +20,7 @@ UiArea::UiArea(nbind::cbFunction &drawCb, nbind::cbFunction &mouseEventCb, : UiControl( (uiControl *)uiNewArea((uiAreaHandler *)UiAreaHandlerFactory::build( drawCb, mouseEventCb, mouseCrossedCb, dragBrokenCb, - keyEventCb))) { - areasMap[(uiArea *)getHandle()] = this; -} + keyEventCb))) {} UiArea::UiArea(nbind::cbFunction &drawCb, nbind::cbFunction &mouseEventCb, nbind::cbFunction &mouseCrossedCb, @@ -33,18 +29,12 @@ UiArea::UiArea(nbind::cbFunction &drawCb, nbind::cbFunction &mouseEventCb, : UiControl((uiControl *)uiNewScrollingArea( (uiAreaHandler *)UiAreaHandlerFactory::build( drawCb, mouseEventCb, mouseCrossedCb, dragBrokenCb, keyEventCb), - width, height)) { - areasMap[(uiArea *)getHandle()] = this; -} - -// Workaround for nbind bug solved in 0.3 -UiArea::UiArea(int dummy) : UiControl(NULL) {} + width, height)) {} #include "nbind/api.h" NBIND_CLASS(UiArea) { inherit(UiControl); - construct(); construct(); constructdraw)(areasMap[area], pp); + (*self->draw)(controlsMap[uiControl(area)], pp); } void MouseEvent(UiAreaHandler *self, uiArea *area, uiAreaMouseEvent *event) { UiAreaMouseEvent *ev = new UiAreaMouseEvent(event); - (*(self->mouseEvent))(areasMap[area], ev); + (*(self->mouseEvent))(controlsMap[uiControl(area)], ev); } void MouseCrossed(UiAreaHandler *self, uiArea *area, int left) { - (*(self->mouseCrossed))(areasMap[area], left); + (*(self->mouseCrossed))(controlsMap[uiControl(area)], left); } void DragBroken(UiAreaHandler *self, uiArea *area) { - (*(self->dragBroken))(areasMap[area]); + (*(self->dragBroken))(controlsMap[uiControl(area)]); } int KeyEvent(UiAreaHandler *self, uiArea *area, uiAreaKeyEvent *event) { UiAreaKeyEvent *ev = new UiAreaKeyEvent(event); - return (self->keyEvent)->call(areasMap[area], ev); + return (self->keyEvent)->call(controlsMap[uiControl(area)], ev); } UiAreaHandler *UiAreaHandlerFactory::build(nbind::cbFunction &drawCb, diff --git a/src/includes/area.h b/src/includes/area.h index e7de8f9..5e04ee8 100644 --- a/src/includes/area.h +++ b/src/includes/area.h @@ -8,14 +8,9 @@ #include "ui.h" #include "values.h" -// UIArea - // TODO - document class UiArea : public UiControl { public: - // Workaround for nbind bug solved in 0.3 - UiArea(int dummy); - UiArea(nbind::cbFunction &drawCb, nbind::cbFunction &mouseEventCb, nbind::cbFunction &mouseCrossedCb, nbind::cbFunction &dragBrokenCb, nbind::cbFunction &keyEventCb); @@ -27,8 +22,6 @@ class UiArea : public UiControl { void scrollTo(double x, double y, double width, double height); }; -extern std::map areasMap; - class DrawStrokeParams { private: uiDrawStrokeParams *sp; diff --git a/src/includes/control.h b/src/includes/control.h index 85c33b8..14ae6a9 100644 --- a/src/includes/control.h +++ b/src/includes/control.h @@ -1,6 +1,7 @@ #ifndef UI_NODE_CONTROL #define UI_NODE_CONTROL 1 +#include #include "ui.h" #define DEFINE_EVENT(NAME) \ @@ -49,6 +50,8 @@ class UiControl { void setEnabled(bool enabled); }; +extern std::map controlsMap; + // This is included at end of file // to minimize conflicts with existing // symbols from other headers. From 014a04f72bb524bd182e85885c7f882ddc2d2011 Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Sat, 14 Apr 2018 12:29:33 +0200 Subject: [PATCH 122/190] Emoji example --- examples/text.js | 8 ++++++-- src/Font/AttributedString.cc | 1 - 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/text.js b/examples/text.js index f4dc5d3..fcb9b6e 100644 --- a/examples/text.js +++ b/examples/text.js @@ -11,9 +11,11 @@ let align; let checkbox; const str = new libui.AttributedString( - 'Drawing strings with libui is done with the uiAttributedString and uiDrawTextLayout objects.\n' + + '👨🏻 Drawing strings with libui is done with the uiAttributedString and uiDrawTextLayout objects.\n' + 'uiAttributedString lets you have a variety of attributes: '); +str.setAttribute(FontAttribute.newBackground(new libui.Color(0,0,1,1)), 0, Buffer.from("👨🏻").length); + str.appendAttributed('font family', FontAttribute.newFamily('Courier New')); str.appendUnattributed(', '); @@ -71,7 +73,9 @@ otf.forEach((feat, str, val) => { otf.free(); str.appendUnattributed(').\n'); -str.appendUnattributed('Use the controls opposite to the text to control properties of the text.'); +str.appendUnattributed('Use the controls opposite to the text to control properties of the text.\n'); +str.appendAttributed('👨🏾', FontAttribute.newBackground(new libui.Color(0, 1, 0, 1))); + str.forEach((str, attr, start, end) => { console.log({str, attr, start, end}); diff --git a/src/Font/AttributedString.cc b/src/Font/AttributedString.cc index 62107ab..ba414f7 100644 --- a/src/Font/AttributedString.cc +++ b/src/Font/AttributedString.cc @@ -65,7 +65,6 @@ void AttributedString::appendAttributed(const char *str, FontAttribute *attr) { void AttributedString::appendAttributed(const char *str, FontAttribute *attr, FontAttribute *attr2) { size_t start = this->toStringLen(); - // TODO how this (and strlen) work with unicode? size_t end = start + strlen(str); this->appendUnattributed(str); From c5a3a490edc6390ef7c62c9f385df4e83c195e36 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 14 Apr 2018 12:41:27 +0200 Subject: [PATCH 123/190] Removed high limit on node timeout --- src/EventLoop.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EventLoop.cc b/src/EventLoop.cc index 0ee0eb3..7433485 100644 --- a/src/EventLoop.cc +++ b/src/EventLoop.cc @@ -18,8 +18,8 @@ static void backgroundNodeEventsPoller(void *arg) { int timeout = uv_backend_timeout(uv_default_loop()); /* wait for 1s by default */ - if (timeout == 0 || timeout > 100) { - timeout = 100; + if (timeout == 0) { + timeout = 1000; } int pendingEvents = 1; From 4e19dd67403fec9fad5adba8eaba40b217468a5a Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Sat, 14 Apr 2018 13:35:11 +0200 Subject: [PATCH 124/190] AttributedString: destructor --- src/Font/AttributedString.cc | 24 +++++++++++++++--------- src/ui-node.h | 2 +- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/Font/AttributedString.cc b/src/Font/AttributedString.cc index ba414f7..fed81e1 100644 --- a/src/Font/AttributedString.cc +++ b/src/Font/AttributedString.cc @@ -10,7 +10,7 @@ AttributedString::AttributedString(const char *str) { s = uiNewAttributedString(str); } -void AttributedString::free() { +AttributedString::~AttributedString() { uiFreeAttributedString(s); } @@ -43,26 +43,33 @@ void AttributedString::setAttribute(FontAttribute *attr, size_t start, size_t en attr->setAppended(); } -static unsigned int AttributedString__forEach(const uiAttributedString *s, const uiAttribute *a, size_t start, size_t end, void *data) { - nbind::cbFunction *cb = (nbind::cbFunction *) data; +typedef struct { + AttributedString *str; + nbind::cbFunction *cb; +} ForEachData; - return cb->call( - AttributedString((uiAttributedString*)s), +static unsigned int AttributedString__forEach(const uiAttributedString *s, const uiAttribute *a, size_t start, size_t end, void *d) { + ForEachData *data = (ForEachData*) d; + + FontAttribute f = FontAttribute((uiAttribute*)a); + f.setAppended(); + + return data->cb->call( + data->str, FontAttribute((uiAttribute*)a), start, end); } void AttributedString::forEach(nbind::cbFunction& cb) { - uiAttributedStringForEachAttribute(s, AttributedString__forEach, &cb); + ForEachData d = {this, &cb}; + uiAttributedStringForEachAttribute(s, AttributedString__forEach, &d); } - void AttributedString::appendAttributed(const char *str, FontAttribute *attr) { this->appendAttributed(str, attr, nullptr); } - void AttributedString::appendAttributed(const char *str, FontAttribute *attr, FontAttribute *attr2) { size_t start = this->toStringLen(); size_t end = start + strlen(str); @@ -89,7 +96,6 @@ size_t AttributedString::graphemeToByteIndex(size_t pos) { NBIND_CLASS(AttributedString) { construct(); - method(free); method(toString); method(toStringLen); method(appendUnattributed); diff --git a/src/ui-node.h b/src/ui-node.h index f62dd9c..c6675eb 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -696,7 +696,7 @@ class AttributedString { public: AttributedString(uiAttributedString *str); AttributedString(const char *str); - void free(); + ~AttributedString(); uiAttributedString *getHandle(); const char * toString(); size_t toStringLen(); From 9a357e467e9f4e51a8cc6148ca5cf5ac718a3848 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 14 Apr 2018 13:50:21 +0200 Subject: [PATCH 125/190] timer with basic syntax [unix] --- binding.gyp | 2 +- examples/event-loop.js | 33 +++++++++++++++++++ src/arch/unix/timer.cc | 75 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 src/arch/unix/timer.cc diff --git a/binding.gyp b/binding.gyp index 7372b2e..cadb01e 100644 --- a/binding.gyp +++ b/binding.gyp @@ -27,7 +27,7 @@ "sources": [ " { + const now = Date.now(); + const longTimeout = libui.setTimeout(() => { + logAppend(`THIS HOULD NOT HAPPEN!`); + }, 200); + + libui.setTimeout(() => { + libui.clearTimeout(longTimeout); + const elapsed = Date.now() - now; + logAppend(`Custom setTimeout: ${now} - elapsed ${elapsed} ms`); + }, 10); + }); + toolbar.append(btnCustom, false); + + const btnCustomSetInterval = new libui.UiButton('Custom setInterval'); + let intervalHandler = null; + btnCustomSetInterval.onClicked(() => { + if (intervalHandler) { + libui.clearInterval(intervalHandler); + intervalHandler = null; + return; + } + let now = Date.now(); + intervalHandler = libui.setInterval(() => { + const elapsed = Date.now() - now; + logAppend(`Custom setInterval: ${now} - elapsed ${elapsed} ms`); + now = Date.now(); + }, 10); + }); + + toolbar.append(btnCustomSetInterval, false); + const btnNextTick = new libui.UiButton('NextTick'); btnNextTick.onClicked(() => { const now = Date.now(); diff --git a/src/arch/unix/timer.cc b/src/arch/unix/timer.cc new file mode 100644 index 0000000..a74bc54 --- /dev/null +++ b/src/arch/unix/timer.cc @@ -0,0 +1,75 @@ +#include +#include +#include "nbind/api.h" + +class TimeoutHandle { + public: + unsigned int handle; + nbind::cbFunction *callbackJs; + bool destroyed; + + TimeoutHandle(nbind::cbFunction *callbackJs) { + this->callbackJs = callbackJs; + this->destroyed = false; + } + + void destroy() { + if (this->destroyed) { + return; + } + + delete this->callbackJs; + this->destroyed = true; + } +}; + +#define CALL_JSCB(timeoutHandle) (*(timeoutHandle->callbackJs))() + +gboolean glib_timeout_cb(TimeoutHandle *timeoutHandle) { + CALL_JSCB(timeoutHandle); + timeoutHandle->destroy(); + return FALSE; +} + +gboolean glib_interval_cb(TimeoutHandle *timeoutHandle) { + CALL_JSCB(timeoutHandle); + return TRUE; +} + +TimeoutHandle *setTimeout(nbind::cbFunction &cb, unsigned int timeout) { + nbind::cbFunction *callbackJs = new nbind::cbFunction(cb); + TimeoutHandle *timeoutHandle = new TimeoutHandle(callbackJs); + timeoutHandle->handle = + g_timeout_add(timeout, (GSourceFunc)glib_timeout_cb, timeoutHandle); + return timeoutHandle; +} + +void clearTimeout(TimeoutHandle *timeoutHandle) { + g_source_remove(timeoutHandle->handle); + timeoutHandle->destroy(); +} + +TimeoutHandle *setInterval(nbind::cbFunction &cb, unsigned int timeout) { + nbind::cbFunction *callbackJs = new nbind::cbFunction(cb); + TimeoutHandle *timeoutHandle = new TimeoutHandle(callbackJs); + timeoutHandle->handle = + g_timeout_add(timeout, (GSourceFunc)glib_interval_cb, timeoutHandle); + return timeoutHandle; +} + +void clearInterval(TimeoutHandle *timeoutHandle) { + printf("clearInterval called\n"); + g_source_remove(timeoutHandle->handle); + timeoutHandle->destroy(); +} + +#include "nbind/nbind.h" + +NBIND_GLOBAL() { + function(setTimeout); + function(clearTimeout); + function(setInterval); + function(clearInterval); +} + +NBIND_CLASS(TimeoutHandle) {} From 4434e42912b4224c480b54af34ef07080e56dffc Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 14 Apr 2018 14:03:40 +0200 Subject: [PATCH 126/190] use new timer --- examples/check-control-destroy.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/check-control-destroy.js b/examples/check-control-destroy.js index 5085623..cc0e602 100644 --- a/examples/check-control-destroy.js +++ b/examples/check-control-destroy.js @@ -137,8 +137,7 @@ function op() { global.gc(); const win = createWindow(); win.show(); - return; - setTimeout(() => { + libui.setTimeout(() => { win.close(); op(); }, 100); From b230e286041a892601e11c83a4f8bd3720d7a32d Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Sat, 14 Apr 2018 13:47:43 +0200 Subject: [PATCH 127/190] OpenTypeFeatures: destructor and fix get --- docs/attributedstring.md | 16 +++------------- index.js | 9 +++++++++ src/Font/OpenTypeFeatures.cc | 29 +++++++++++++++++++---------- src/ui-node.h | 4 ++-- 4 files changed, 33 insertions(+), 25 deletions(-) diff --git a/docs/attributedstring.md b/docs/attributedstring.md index 31409d3..81bb177 100644 --- a/docs/attributedstring.md +++ b/docs/attributedstring.md @@ -9,19 +9,9 @@ class OpenTypeFeatures { static OpenTypeFeatures clone(OpenTypeFeatures *f2); void add(const char *tag, uint32_t value); void remove(const char *tag); - // uiOpenTypeFeaturesGet() determines whether the given feature - // tag is present in otf. If it is, *value is set to the tag's value and - // nonzero is returned. Otherwise, zero is returned. - // - // Note that if uiOpenTypeFeaturesGet() returns zero, value isn't - // changed. This is important: if a feature is not present in a - // uiOpenTypeFeatures, the feature is NOT treated as if its - // value was zero anyway. Script-specific font shaping rules and - // font-specific feature settings may use a different default value - // for a feature. You should likewise not treat a missing feature as - // having a value of zero either. Instead, a missing feature should - // be treated as having some unspecified default value. - int get(const char *tag, uint32_t *value); + + // value or `null` if not set + get(const char *tag); // cb(OpenTypeFeatures, tag, value) void forEach(nbind::cbFunction& cb); diff --git a/index.js b/index.js index 315b66d..c4a9bec 100755 --- a/index.js +++ b/index.js @@ -164,6 +164,15 @@ binding.lib.FontAttribute.newUnderlineColor = function (type, color) { return binding.lib.FontAttribute.newUnderlineColor2(type, color); }; +binding.lib.OpenTypeFeatures.prototype.get = function (str) { + const value = this.getInternal(str); + if (value[1]){ + return value[0]; + } else { + return null; + } +} + module.exports.textWeight = textWeight; module.exports.textItalic = textItalic; module.exports.textStretch = textStretch; diff --git a/src/Font/OpenTypeFeatures.cc b/src/Font/OpenTypeFeatures.cc index 4ad0e98..e68af07 100644 --- a/src/Font/OpenTypeFeatures.cc +++ b/src/Font/OpenTypeFeatures.cc @@ -10,8 +10,9 @@ OpenTypeFeatures::OpenTypeFeatures() { f = uiNewOpenTypeFeatures(); } -void OpenTypeFeatures::free() { +OpenTypeFeatures::~OpenTypeFeatures() { uiFreeOpenTypeFeatures(f); + printf("freed OpenTypeFeatures\n"); } uiOpenTypeFeatures *OpenTypeFeatures::getHandle() { @@ -30,28 +31,36 @@ void OpenTypeFeatures::remove(const char *tag) { uiOpenTypeFeaturesRemove(f, tag[0], tag[1], tag[2], tag[3]); } -int OpenTypeFeatures::get(const char *tag, uint32_t *value) { - return uiOpenTypeFeaturesGet(f, tag[0], tag[1], tag[2], tag[3], value); +std::array OpenTypeFeatures::getInternal(const char *tag) { + unsigned int value = 0; + unsigned int exists = uiOpenTypeFeaturesGet(f, tag[0], tag[1], tag[2], tag[3], &value); + return std::array {{value, exists}}; } -static unsigned int OpenTypeFeatures__forEach(const uiOpenTypeFeatures *otf, char a, char b, char c, char d, uint32_t value, void *data) { +typedef struct { + OpenTypeFeatures *otf; + nbind::cbFunction *cb; +} ForEachData; + +static unsigned int OpenTypeFeatures__forEach(const uiOpenTypeFeatures *otf, char a, char b, char c, char d, uint32_t value, void *dat) { + ForEachData *data = (ForEachData*) dat; const char tag[5] = {a, b, c, d, '\0'}; - nbind::cbFunction *cb = (nbind::cbFunction *) data; - return cb->call( - OpenTypeFeatures((uiOpenTypeFeatures*)otf), + + return data->cb->call( + data->otf, &tag[0], value); } void OpenTypeFeatures::forEach(nbind::cbFunction& cb) { - uiOpenTypeFeaturesForEach(f, OpenTypeFeatures__forEach, &cb); + ForEachData d = {this, &cb}; + uiOpenTypeFeaturesForEach(f, OpenTypeFeatures__forEach, &d); } NBIND_CLASS(OpenTypeFeatures) { construct<>(); - method(free); method(clone); method(add); method(remove); - method(get); + method(getInternal); method(forEach); } diff --git a/src/ui-node.h b/src/ui-node.h index c6675eb..d361be3 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -641,13 +641,13 @@ class OpenTypeFeatures { public: OpenTypeFeatures(); OpenTypeFeatures(uiOpenTypeFeatures *feat); - void free(); + ~OpenTypeFeatures(); uiOpenTypeFeatures *getHandle(); static OpenTypeFeatures clone(OpenTypeFeatures *f2); void add(const char *tag, uint32_t value); void remove(const char *tag); - int get(const char *tag, uint32_t *value); + std::array getInternal(const char *tag); void forEach(nbind::cbFunction& cb); From e12a1a6d64e290ccffbfe4d7cfd2b6b3e7dc99af Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Sat, 14 Apr 2018 14:49:52 +0200 Subject: [PATCH 128/190] FontDescriptor: destructor --- src/Font/FontDescriptor.cc | 21 ++++++++++++++------- src/ui-node.h | 3 ++- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/Font/FontDescriptor.cc b/src/Font/FontDescriptor.cc index 53fe453..36bff3d 100644 --- a/src/Font/FontDescriptor.cc +++ b/src/Font/FontDescriptor.cc @@ -3,6 +3,12 @@ #include "nbind/nbind.h" #include +// needed because of UiFontButton::getFont +FontDescriptor::FontDescriptor(FontDescriptor&& other){ + d = other.d; + other.d = nullptr; +} + FontDescriptor::FontDescriptor(uiFontDescriptor * desc) { d = desc; buttonCleanup = 1; @@ -19,13 +25,15 @@ FontDescriptor::FontDescriptor(const char *family, double size, int weight, int d->Stretch = stretch; } -void FontDescriptor::free() { - if(buttonCleanup){ - uiFreeFontButtonFont(d); - } else { - delete[] d->Family; +FontDescriptor::~FontDescriptor() { + if(d != nullptr){ + if(buttonCleanup){ + uiFreeFontButtonFont(d); + } else { + delete[] d->Family; + } + delete d; } - delete d; } char *FontDescriptor::getFamily() { @@ -55,7 +63,6 @@ uiFontDescriptor *FontDescriptor::getHandle(){ NBIND_CLASS(FontDescriptor) { construct(); - method(free); method(getFamily); method(getSize); method(getWeight); diff --git a/src/ui-node.h b/src/ui-node.h index d361be3..e4bceb3 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -723,9 +723,10 @@ class FontDescriptor { uiFontDescriptor *d; int buttonCleanup = 0; public: + FontDescriptor(FontDescriptor&& other); FontDescriptor(uiFontDescriptor *d); FontDescriptor(const char *family, double size, int weight, int italic, int stretch); - void free(); + ~FontDescriptor(); char *getFamily(); double getSize(); int getWeight(); From 7b2df26142fb3cd8cefe2fce00982a37a77e1859 Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Sat, 14 Apr 2018 15:07:34 +0200 Subject: [PATCH 129/190] FontAttribute: destructor --- examples/text.js | 2 +- src/Font/FontAttribute.cc | 19 +++++++++++++------ src/Font/OpenTypeFeatures.cc | 1 - src/ui-node.h | 3 ++- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/examples/text.js b/examples/text.js index fcb9b6e..3155de6 100644 --- a/examples/text.js +++ b/examples/text.js @@ -132,7 +132,7 @@ function main() { vbox.append(checkbox, false); align = new libui.UiCombobox(); - // Note that the items match with the valueorder of libui.textAlign + // Note that the items match with the value order of libui.textAlign align.append('Left'); align.append('Center'); align.append('Right'); diff --git a/src/Font/FontAttribute.cc b/src/Font/FontAttribute.cc index c90a11e..6048edb 100644 --- a/src/Font/FontAttribute.cc +++ b/src/Font/FontAttribute.cc @@ -2,10 +2,23 @@ #include "../ui-node.h" #include "nbind/nbind.h" +FontAttribute::FontAttribute(FontAttribute&& other){ + a = other.a; + other.a = nullptr; +} + FontAttribute::FontAttribute(uiAttribute *attr){ a = attr; } +FontAttribute::~FontAttribute(){ + if(a != nullptr){ + if(!appended){ + uiFreeAttribute(a); + } + } +} + int FontAttribute::getAttributeType() { return uiAttributeGetType(a); } @@ -14,11 +27,6 @@ uiAttribute *FontAttribute::getHandle() { return a; } -void FontAttribute::free(){ - if(!appended){ - uiFreeAttribute(a); - } -} void FontAttribute::setAppended(){ appended = 1; @@ -123,7 +131,6 @@ FontAttribute FontAttribute::newOTFeatures(OpenTypeFeatures *otf) { NBIND_CLASS(FontAttribute) { - method(free); method(getAttributeType); method(getFamily); diff --git a/src/Font/OpenTypeFeatures.cc b/src/Font/OpenTypeFeatures.cc index e68af07..64ba537 100644 --- a/src/Font/OpenTypeFeatures.cc +++ b/src/Font/OpenTypeFeatures.cc @@ -12,7 +12,6 @@ OpenTypeFeatures::OpenTypeFeatures() { OpenTypeFeatures::~OpenTypeFeatures() { uiFreeOpenTypeFeatures(f); - printf("freed OpenTypeFeatures\n"); } uiOpenTypeFeatures *OpenTypeFeatures::getHandle() { diff --git a/src/ui-node.h b/src/ui-node.h index e4bceb3..fd7039f 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -659,8 +659,9 @@ class FontAttribute { int appended = 0; public: + FontAttribute(FontAttribute&& other); FontAttribute(uiAttribute *a); - void free(); + ~FontAttribute(); void setAppended(); int getAttributeType(); uiAttribute *getHandle(); From ee7ee3ca9a8e221621d3feb79b22b436307eed82 Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Sat, 14 Apr 2018 15:13:02 +0200 Subject: [PATCH 130/190] Lint --- examples/text.js | 5 +++-- index.js | 9 ++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/text.js b/examples/text.js index 3155de6..2732f6f 100644 --- a/examples/text.js +++ b/examples/text.js @@ -14,7 +14,7 @@ const str = new libui.AttributedString( '👨🏻 Drawing strings with libui is done with the uiAttributedString and uiDrawTextLayout objects.\n' + 'uiAttributedString lets you have a variety of attributes: '); -str.setAttribute(FontAttribute.newBackground(new libui.Color(0,0,1,1)), 0, Buffer.from("👨🏻").length); +str.setAttribute(FontAttribute.newBackground(new libui.Color(0, 0, 1, 1)), 0, Buffer.from('👨🏻').length); str.appendAttributed('font family', FontAttribute.newFamily('Courier New')); str.appendUnattributed(', '); @@ -70,13 +70,14 @@ otf.forEach((feat, str, val) => { console.log({feat, str, val}); }); +console.log('liga:', otf.get('liga')); + otf.free(); str.appendUnattributed(').\n'); str.appendUnattributed('Use the controls opposite to the text to control properties of the text.\n'); str.appendAttributed('👨🏾', FontAttribute.newBackground(new libui.Color(0, 1, 0, 1))); - str.forEach((str, attr, start, end) => { console.log({str, attr, start, end}); }); diff --git a/index.js b/index.js index c4a9bec..c95b657 100755 --- a/index.js +++ b/index.js @@ -165,13 +165,12 @@ binding.lib.FontAttribute.newUnderlineColor = function (type, color) { }; binding.lib.OpenTypeFeatures.prototype.get = function (str) { - const value = this.getInternal(str); - if (value[1]){ + const value = this.getInternal(str); + if (value[1]) { return value[0]; - } else { - return null; } -} + return null; +}; module.exports.textWeight = textWeight; module.exports.textItalic = textItalic; From 4cc3e02f6ff0f3ffe58d3149f10a2085b561b2fc Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Sat, 14 Apr 2018 15:25:37 +0200 Subject: [PATCH 131/190] Fixup --- src/Font/FontAttribute.cc | 2 ++ src/Font/FontDescriptor.cc | 1 + 2 files changed, 3 insertions(+) diff --git a/src/Font/FontAttribute.cc b/src/Font/FontAttribute.cc index 6048edb..f69da75 100644 --- a/src/Font/FontAttribute.cc +++ b/src/Font/FontAttribute.cc @@ -2,8 +2,10 @@ #include "../ui-node.h" #include "nbind/nbind.h" +// because we're returning the objects in FontAttribute::new... FontAttribute::FontAttribute(FontAttribute&& other){ a = other.a; + appended = other.appended; other.a = nullptr; } diff --git a/src/Font/FontDescriptor.cc b/src/Font/FontDescriptor.cc index 36bff3d..bbc1239 100644 --- a/src/Font/FontDescriptor.cc +++ b/src/Font/FontDescriptor.cc @@ -6,6 +6,7 @@ // needed because of UiFontButton::getFont FontDescriptor::FontDescriptor(FontDescriptor&& other){ d = other.d; + buttonCleanup = other.buttonCleanup; other.d = nullptr; } From e89b573ecaf02443c80e1ea72652140b717975f7 Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Sat, 14 Apr 2018 17:10:00 +0200 Subject: [PATCH 132/190] setTimeout and setInterval for macos --- binding.gyp | 2 +- package.json | 2 +- src/arch/darwin/libui_loop.mm | 76 +++++++++++++++++------------------ src/arch/darwin/timer.mm | 71 ++++++++++++++++++++++++++++++++ 4 files changed, 111 insertions(+), 40 deletions(-) create mode 100644 src/arch/darwin/timer.mm diff --git a/binding.gyp b/binding.gyp index cadb01e..95136cb 100644 --- a/binding.gyp +++ b/binding.gyp @@ -44,7 +44,7 @@ "sources": [ "timer_heap; - struct heap_node* timer_node = timer_heap->min; - if (timer_node != NULL) { - return 1; - } - - return ret; + struct kevent event; + struct timespec ts; + ts.tv_sec = timeout / 1000; + ts.tv_nsec = (timeout % 1000) * 1000000; + + int ret = kevent(nodeBackendFd, NULL, 0, &event, 1, &ts); + + struct heap *timer_heap = (struct heap *)&loop->timer_heap; + struct heap_node *timer_node = timer_heap->min; + if (timer_node != NULL) { + return 1; + } + + return ret; } diff --git a/src/arch/darwin/timer.mm b/src/arch/darwin/timer.mm new file mode 100644 index 0000000..d97e28d --- /dev/null +++ b/src/arch/darwin/timer.mm @@ -0,0 +1,71 @@ +#include "../../includes/event-loop-darwin.h" +#include "nbind/api.h" + +class TimeoutHandle { + public: + NSTimer *handle; + nbind::cbFunction *callbackJs; + bool destroyed; + + TimeoutHandle(nbind::cbFunction *callbackJs) { + this->callbackJs = callbackJs; + this->destroyed = false; + } + + void destroy() { + if (this->destroyed) { + return; + } + + delete this->callbackJs; + this->destroyed = true; + } +}; + +#define CALL_JSCB(timeoutHandle) (*(timeoutHandle->callbackJs))() + +TimeoutHandle *setTimeout(nbind::cbFunction &cb, unsigned int timeout) { + nbind::cbFunction *callbackJs = new nbind::cbFunction(cb); + TimeoutHandle *timeoutHandle = new TimeoutHandle(callbackJs); + timeoutHandle->handle = + [NSTimer scheduledTimerWithTimeInterval:timeout / 1000.0 + repeats:NO + block:^(NSTimer *timer) { + CALL_JSCB(timeoutHandle); + timeoutHandle->destroy(); + }]; + return timeoutHandle; +} + +void clearTimeout(TimeoutHandle *timeoutHandle) { + [timeoutHandle->handle invalidate]; + timeoutHandle->destroy(); +} + +TimeoutHandle *setInterval(nbind::cbFunction &cb, unsigned int timeout) { + nbind::cbFunction *callbackJs = new nbind::cbFunction(cb); + TimeoutHandle *timeoutHandle = new TimeoutHandle(callbackJs); + timeoutHandle->handle = + [NSTimer scheduledTimerWithTimeInterval:timeout / 1000.0 + repeats:YES + block:^(NSTimer *timer) { + CALL_JSCB(timeoutHandle); + }]; + return timeoutHandle; +} + +void clearInterval(TimeoutHandle *timeoutHandle) { + [timeoutHandle->handle invalidate]; + timeoutHandle->destroy(); +} + +#include "nbind/nbind.h" + +NBIND_GLOBAL() { + function(setTimeout); + function(clearTimeout); + function(setInterval); + function(clearInterval); +} + +NBIND_CLASS(TimeoutHandle) {} From 034de54cd3cbcd74ad2a91a0c95917f5fb6be9e9 Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Sat, 14 Apr 2018 18:23:58 +0200 Subject: [PATCH 133/190] Resync docs.js with readme, add FontButton --- examples/docs.js => docs.js | 375 ++++++++++++++++++------------------ docs/attributedstring.md | 6 - docs/colorbutton.md | 2 +- docs/fontbutton.md | 99 ++++++++++ docs/media/UiFontButton.png | Bin 0 -> 25193 bytes docs/readme.md | 17 +- src/UiFontButton.cc | 1 + 7 files changed, 300 insertions(+), 200 deletions(-) rename examples/docs.js => docs.js (94%) create mode 100644 docs/fontbutton.md create mode 100644 docs/media/UiFontButton.png diff --git a/examples/docs.js b/docs.js similarity index 94% rename from examples/docs.js rename to docs.js index 1cc3ebb..f4dd33e 100644 --- a/examples/docs.js +++ b/docs.js @@ -3,7 +3,6 @@ const resolve = require('path').resolve; const writeFileSync = require('fs').writeFileSync; const existsSync = require('fs').existsSync; -const libui = require('..'); const bs = '```js'; const be = '```'; @@ -11,23 +10,23 @@ const t = '`'; let readme = `# libui-node These pages document the ${t}libui-node${t} classes. + If you are new to the framework, you should start reading basic documentation on how it work: -* [initialization & event loop](initialization.md) - explains how to initialize the framework and how the event loop works. -* [properties](properties.md) - explains how widgets properties are implemented by ${t}libui-node${t}. -* [events](events.md) - explains how widgets events are implemented by ${t}libui-node${t}. -* [UiWindow](window.md) - explains how to create and manage OS windows. +* [Initialization & Event Loop](initialization.md) - explains how to initialize the framework and how the event loop works. +* [Properties](properties.md) - explains how widgets properties are implemented by ${t}libui-node${t}. +* [Events](events.md) - explains how widgets events are implemented by ${t}libui-node${t}. * [Containers](containers.md) - explains how you can group widgets in tree hierarchies using different layout strategies. - +* [Attributed Strings](attributedstring.md) - explains how you can style text (font, color, underline, ...) `; -const readmePath = resolve(__dirname, '../docs/readme.md'); +const readmePath = resolve(__dirname, 'docs/readme.md'); function writeFile(name, description, ...contents) { const filename = name.slice(2).toLowerCase() + '.md'; - const path = resolve(__dirname, '../docs', filename); - const imagePath = resolve(__dirname, '../docs/media/', name + '.png'); + const path = resolve(__dirname, 'docs', filename); + const imagePath = resolve(__dirname, 'docs/media/', name + '.png'); const imageMd = `![${name} example](media/${name}.png)`; const image = existsSync(imagePath) ? imageMd : ''; readme += ` @@ -113,20 +112,20 @@ ${contents // ? require('./show' + name + '.js'); } -function property(name, type, description) { +function property(name, type, description, onlyGetter) { const getterName = 'get' + name[0].toUpperCase() + name.slice(1); const setterName = 'set' + name[0].toUpperCase() + name.slice(1); return { type: 'property', methods: ` -## ${setterName} +${!onlyGetter ? `## ${setterName} Set the value of property ${t}${name}${t} **Arguments** * value: ${type} - The new value for ${t}${name}${t} property. - +` : ""} ## ${getterName} Return the value of property ${t}${name}${t} @@ -174,6 +173,11 @@ ${args }; } +readme += '## Containers widgets\n'; + +readme += '* [UiWindow](window.md) - explains how to create and manage OS windows.'; + + writeFile( 'UiForm', 'A container that organize children as labeled fields.', @@ -240,8 +244,8 @@ writeFile( ); writeFile( - 'UiEntry', - 'A simple, single line text entry widget.', + 'UiVerticalBox', + 'A container that stack its chidren vertically.', property( 'visible', 'Boolean', @@ -253,12 +257,17 @@ writeFile( 'Whether the widget should be enabled or disabled. \nRead write.\nDefaults to `true`.' ), property( - 'readOnly', + 'padded', 'Boolean', - 'Whether the user is allowed to change the entry text. \nRead write.\nDefaults to `true`.' + 'If true, the container insert some space between children. \nDefaults to false.' ), - property('text', 'String', 'The current text of the entry.\nRead write.'), - event('onChanged', 'text'), + method('append', 'Append a new child widget as last one.', [ + 'control: UiControl - the control to append.', + 'stretchy: Boolean - whether the child should expand to use all available size.' + ]), + method('deleteAt', 'Remove a child widget at specified position.', [ + 'index: Number - the index of the control to remove.' + ]), method('destroy', 'Destroy and free the control.'), method('setParent', 'Change the parent of the control', [ @@ -268,8 +277,8 @@ writeFile( ); writeFile( - 'UiPasswordEntry', - 'A single line text entry widget that mask the input, useful to edit passwords or other sensible data.', + 'UiTab', + 'A container that show each chidren in a separate tab.', property( 'visible', 'Boolean', @@ -280,13 +289,39 @@ writeFile( 'Boolean', 'Whether the widget should be enabled or disabled. \nRead write.\nDefaults to `true`.' ), - property( - 'readOnly', - 'Boolean', - 'Whether the user is allowed to change the entry text. \nRead write.\nDefaults to `true`.' + method('append', 'Append a new child widget as last tab.', [ + 'label: String - the text to show in the new tab caption.', + 'control: UiControl - the control to append.' + ]), + method('insertAt', 'Insert a new child widget before specified position.', [ + 'label: String - the text to show in the new tab caption.', + 'before: Number - the control will be inserted before this position', + 'control: UiControl - the control to insert.' + ]), + + method('deleteAt', 'Remove the tab and widget at specified position.', [ + 'index: Number - the index of the tab to remove.' + ]), + + method( + 'setMargined', + 'Specifies that a tab should use a margin around its content.', + [ + 'page: Number - the index of the tab.', + 'margined: Boolean - whether to display a margin or not.' + ] + ), + + method( + 'getMargined', + 'Return a boolean that indicate if a tab is displaying a margin around its content.', + ['page: Number - the index of the tab.'] + ), + + method( + 'numPages', + 'Return the total number of tab pages contained in the widgets.' ), - property('text', 'String', 'The current text of the entry.\nRead write.'), - event('onChanged', 'text'), method('destroy', 'Destroy and free the control.'), method('setParent', 'Change the parent of the control', [ @@ -296,8 +331,8 @@ writeFile( ); writeFile( - 'UiSearchEntry', - 'A single line text entry widget to search text.', + 'UiHorizontalBox', + 'A container that stack its chidren horizontally.', property( 'visible', 'Boolean', @@ -309,12 +344,17 @@ writeFile( 'Whether the widget should be enabled or disabled. \nRead write.\nDefaults to `true`.' ), property( - 'readOnly', + 'padded', 'Boolean', - 'Whether the user is allowed to change the entry text. \nRead write.\nDefaults to `true`.' + 'If true, the container insert some space between children. \nDefaults to false.' ), - property('text', 'String', 'The current text of the entry.\nRead write.'), - event('onChanged', 'text'), + method('append', 'Append a new child widget as last one.', [ + 'control: UiControl - the control to append.', + 'stretchy: Boolean - whether the child should expand to use all available size.' + ]), + method('deleteAt', 'Remove a child widget at specified position.', [ + 'index: Number - the index of the control to remove.' + ]), method('destroy', 'Destroy and free the control.'), method('setParent', 'Change the parent of the control', [ @@ -324,8 +364,8 @@ writeFile( ); writeFile( - 'UiMultilineEntry', - 'A multiline text entry widget.', + 'UiGroup', + `A container for a single widget that provide a caption and visually group it's children.`, property( 'visible', 'Boolean', @@ -337,19 +377,19 @@ writeFile( 'Whether the widget should be enabled or disabled. \nRead write.\nDefaults to `true`.' ), property( - 'readOnly', + 'margined', 'Boolean', - 'Whether the user is allowed to change the entry text. \nRead write.\nDefaults to `true`.' + 'This property specify if the group content area should have a margin or not.\nDefaults to false.' ), property( - 'text', + 'title', 'String', - 'The current text of the multiline entry.\nRead write.' + 'This property specify the caption of the group.\nDefaults to empty string.' ), - event('onChanged', 'text'), - method('append', 'Append specified text to the entry content.', [ - 'text: String - the text to append.' + method('setChild', 'Set the child widget of the group.', [ + 'control: UiControl - the control to append.' ]), + method('destroy', 'Destroy and free the control.'), method('setParent', 'Change the parent of the control', [ 'parent: UiControl - the new parent of the widget or null to detach it.' @@ -357,9 +397,13 @@ writeFile( method('toplevel', 'Return whether the control is a top level one or not.') ); + +readme += '\n## Data entry widgets\n'; + + writeFile( - 'UiLabel', - 'A static text label.', + 'UiEntry', + 'A simple, single line text entry widget.', property( 'visible', 'Boolean', @@ -370,7 +414,13 @@ writeFile( 'Boolean', 'Whether the widget should be enabled or disabled. \nRead write.\nDefaults to `true`.' ), - property('text', 'String', 'The static text of the label.\nRead write.'), + property( + 'readOnly', + 'Boolean', + 'Whether the user is allowed to change the entry text. \nRead write.\nDefaults to `true`.' + ), + property('text', 'String', 'The current text of the entry.\nRead write.'), + event('onChanged', 'text'), method('destroy', 'Destroy and free the control.'), method('setParent', 'Change the parent of the control', [ @@ -380,8 +430,8 @@ writeFile( ); writeFile( - 'UiVerticalSeparator', - 'A vertical line to visually separate widgets.', + 'UiPasswordEntry', + 'A single line text entry widget that mask the input, useful to edit passwords or other sensible data.', property( 'visible', 'Boolean', @@ -392,6 +442,13 @@ writeFile( 'Boolean', 'Whether the widget should be enabled or disabled. \nRead write.\nDefaults to `true`.' ), + property( + 'readOnly', + 'Boolean', + 'Whether the user is allowed to change the entry text. \nRead write.\nDefaults to `true`.' + ), + property('text', 'String', 'The current text of the entry.\nRead write.'), + event('onChanged', 'text'), method('destroy', 'Destroy and free the control.'), method('setParent', 'Change the parent of the control', [ @@ -401,8 +458,8 @@ writeFile( ); writeFile( - 'UiHorizontalSeparator', - 'An horizontal line to visually separate widgets.', + 'UiSearchEntry', + 'A single line text entry widget to search text.', property( 'visible', 'Boolean', @@ -413,6 +470,13 @@ writeFile( 'Boolean', 'Whether the widget should be enabled or disabled. \nRead write.\nDefaults to `true`.' ), + property( + 'readOnly', + 'Boolean', + 'Whether the user is allowed to change the entry text. \nRead write.\nDefaults to `true`.' + ), + property('text', 'String', 'The current text of the entry.\nRead write.'), + event('onChanged', 'text'), method('destroy', 'Destroy and free the control.'), method('setParent', 'Change the parent of the control', [ @@ -422,8 +486,8 @@ writeFile( ); writeFile( - 'UiDatePicker', - 'A widgets to edit dates.', + 'UiMultilineEntry', + 'A multiline text entry widget.', property( 'visible', 'Boolean', @@ -434,7 +498,20 @@ writeFile( 'Boolean', 'Whether the widget should be enabled or disabled. \nRead write.\nDefaults to `true`.' ), - + property( + 'readOnly', + 'Boolean', + 'Whether the user is allowed to change the entry text. \nRead write.\nDefaults to `true`.' + ), + property( + 'text', + 'String', + 'The current text of the multiline entry.\nRead write.' + ), + event('onChanged', 'text'), + method('append', 'Append specified text to the entry content.', [ + 'text: String - the text to append.' + ]), method('destroy', 'Destroy and free the control.'), method('setParent', 'Change the parent of the control', [ 'parent: UiControl - the new parent of the widget or null to detach it.' @@ -443,8 +520,8 @@ writeFile( ); writeFile( - 'UiTimePicker', - 'A widgets to edit times.', + 'UiDatePicker', + 'A widgets to edit dates.', property( 'visible', 'Boolean', @@ -464,8 +541,8 @@ writeFile( ); writeFile( - 'UiDateTimePicker', - 'A widgets to edit date/times.', + 'UiTimePicker', + 'A widgets to edit times.', property( 'visible', 'Boolean', @@ -485,8 +562,8 @@ writeFile( ); writeFile( - 'UiButton', - 'A simple button.', + 'UiDateTimePicker', + 'A widgets to edit date/times.', property( 'visible', 'Boolean', @@ -497,15 +574,12 @@ writeFile( 'Boolean', 'Whether the widget should be enabled or disabled. \nRead write.\nDefaults to `true`.' ), - property('text', 'String', 'The static text of the button.\nRead write.'), method('destroy', 'Destroy and free the control.'), method('setParent', 'Change the parent of the control', [ 'parent: UiControl - the new parent of the widget or null to detach it.' ]), - method('toplevel', 'Return whether the control is a top level one or not.'), - - event('onClicked', null, 'Emitted when the button is clicked') + method('toplevel', 'Return whether the control is a top level one or not.') ); writeFile( @@ -590,32 +664,6 @@ writeFile( method('toplevel', 'Return whether the control is a top level one or not.') ); -writeFile( - 'UiProgressBar', - 'Progress bar widget.', - property( - 'visible', - 'Boolean', - 'Whether the widget should be visible or hidden. \nRead write.\nDefaults to `true`.' - ), - property( - 'enabled', - 'Boolean', - 'Whether the widget should be enabled or disabled. \nRead write.\nDefaults to `true`.' - ), - property( - 'value', - 'Number', - 'The current position of the progress bar. Could be setted to -1 to create an indeterminate progress bar.\nRead write.' - ), - - method('destroy', 'Destroy and free the control.'), - method('setParent', 'Change the parent of the control', [ - 'parent: UiControl - the new parent of the widget or null to detach it.' - ]), - method('toplevel', 'Return whether the control is a top level one or not.') -); - writeFile( 'UiCombobox', 'A drop down combo box that allow list selection only.', @@ -705,11 +753,22 @@ writeFile( method('toplevel', 'Return whether the control is a top level one or not.') ); +readme += '\n\n## Static widgets\n'; + writeFile( - 'UiColorButton', - 'A button that open a color palette popup.', - property('color', 'Color', 'Return or set the currently selected color'), - event('onChanged', 'color'), + 'UiLabel', + 'A static text label.', + property( + 'visible', + 'Boolean', + 'Whether the widget should be visible or hidden. \nRead write.\nDefaults to `true`.' + ), + property( + 'enabled', + 'Boolean', + 'Whether the widget should be enabled or disabled. \nRead write.\nDefaults to `true`.' + ), + property('text', 'String', 'The static text of the label.\nRead write.'), method('destroy', 'Destroy and free the control.'), method('setParent', 'Change the parent of the control', [ @@ -719,8 +778,8 @@ writeFile( ); writeFile( - 'UiVerticalBox', - 'A container that stack its chidren vertically.', + 'UiVerticalSeparator', + 'A vertical line to visually separate widgets.', property( 'visible', 'Boolean', @@ -731,18 +790,6 @@ writeFile( 'Boolean', 'Whether the widget should be enabled or disabled. \nRead write.\nDefaults to `true`.' ), - property( - 'padded', - 'Boolean', - 'If true, the container insert some space between children. \nDefaults to false.' - ), - method('append', 'Append a new child widget as last one.', [ - 'control: UiControl - the control to append.', - 'stretchy: Boolean - whether the child should expand to use all available size.' - ]), - method('deleteAt', 'Remove a child widget at specified position.', [ - 'index: Number - the index of the control to remove.' - ]), method('destroy', 'Destroy and free the control.'), method('setParent', 'Change the parent of the control', [ @@ -752,8 +799,8 @@ writeFile( ); writeFile( - 'UiTab', - 'A container that show each chidren in a separate tab.', + 'UiHorizontalSeparator', + 'An horizontal line to visually separate widgets.', property( 'visible', 'Boolean', @@ -764,39 +811,6 @@ writeFile( 'Boolean', 'Whether the widget should be enabled or disabled. \nRead write.\nDefaults to `true`.' ), - method('append', 'Append a new child widget as last tab.', [ - 'label: String - the text to show in the new tab caption.', - 'control: UiControl - the control to append.' - ]), - method('insertAt', 'Insert a new child widget before specified position.', [ - 'label: String - the text to show in the new tab caption.', - 'before: Number - the control will be inserted before this position', - 'control: UiControl - the control to insert.' - ]), - - method('deleteAt', 'Remove the tab and widget at specified position.', [ - 'index: Number - the index of the tab to remove.' - ]), - - method( - 'setMargined', - 'Specifies that a tab should use a margin around its content.', - [ - 'page: Number - the index of the tab.', - 'margined: Boolean - whether to display a margin or not.' - ] - ), - - method( - 'getMargined', - 'Return a boolean that indicate if a tab is displaying a margin around its content.', - ['page: Number - the index of the tab.'] - ), - - method( - 'numPages', - 'Return the total number of tab pages contained in the widgets.' - ), method('destroy', 'Destroy and free the control.'), method('setParent', 'Change the parent of the control', [ @@ -806,8 +820,8 @@ writeFile( ); writeFile( - 'UiHorizontalBox', - 'A container that stack its chidren horizontally.', + 'UiProgressBar', + 'Progress bar widget.', property( 'visible', 'Boolean', @@ -819,17 +833,10 @@ writeFile( 'Whether the widget should be enabled or disabled. \nRead write.\nDefaults to `true`.' ), property( - 'padded', - 'Boolean', - 'If true, the container insert some space between children. \nDefaults to false.' + 'value', + 'Number', + 'The current position of the progress bar. Could be setted to -1 to create an indeterminate progress bar.\nRead write.' ), - method('append', 'Append a new child widget as last one.', [ - 'control: UiControl - the control to append.', - 'stretchy: Boolean - whether the child should expand to use all available size.' - ]), - method('deleteAt', 'Remove a child widget at specified position.', [ - 'index: Number - the index of the control to remove.' - ]), method('destroy', 'Destroy and free the control.'), method('setParent', 'Change the parent of the control', [ @@ -838,9 +845,13 @@ writeFile( method('toplevel', 'Return whether the control is a top level one or not.') ); + +readme += '\n\n## Buttons\n'; + + writeFile( - 'UiGroup', - `A container for a single widget that provide a caption and visually group it's children.`, + 'UiButton', + 'A simple button.', property( 'visible', 'Boolean', @@ -851,43 +862,41 @@ writeFile( 'Boolean', 'Whether the widget should be enabled or disabled. \nRead write.\nDefaults to `true`.' ), - property( - 'margined', - 'Boolean', - 'This property specify if the group content area should have a margin or not.\nDefaults to false.' - ), - property( - 'title', - 'String', - 'This property specify the caption of the group.\nDefaults to empty string.' - ), - method('setChild', 'Set the child widget of the group.', [ - 'control: UiControl - the control to append.' - ]), + property('text', 'String', 'The static text of the button.\nRead write.'), method('destroy', 'Destroy and free the control.'), method('setParent', 'Change the parent of the control', [ 'parent: UiControl - the new parent of the widget or null to detach it.' ]), - method('toplevel', 'Return whether the control is a top level one or not.') -); - -writeFileSync(readmePath, readme); + method('toplevel', 'Return whether the control is a top level one or not.'), -const win = new libui.UiWindow('Example window', 640, 480, true); -win.borderless = true; -const box = new libui.UiVerticalBox(); -const entry = new libui.UiMultilineEntry(); -entry.text = 'This is some text'; + event('onClicked', null, 'Emitted when the button is clicked') +); -box.append(entry, 1); +writeFile( + 'UiColorButton', + 'A button that opens a color palette popup.', + property('color', 'Color', 'Return or set the currently selected color'), + event('onChanged', 'color'), -win.setChild(box); + method('destroy', 'Destroy and free the control.'), + method('setParent', 'Change the parent of the control', [ + 'parent: UiControl - the new parent of the widget or null to detach it.' + ]), + method('toplevel', 'Return whether the control is a top level one or not.') +); -win.onClosing(() => { - libui.stopLoop(); -}); +writeFile( + 'UiFontButton', + 'A button that opens a font chooser.', + property('font', 'FontDescriptor', 'Return or set the currently selected font', true), + event('onChanged', 'font'), -win.show(); + method('destroy', 'Destroy and free the control.'), + method('setParent', 'Change the parent of the control', [ + 'parent: UiControl - the new parent of the widget or null to detach it.' + ]), + method('toplevel', 'Return whether the control is a top level one or not.') +); -libui.startLoop(); +writeFileSync(readmePath, readme+'\n'); diff --git a/docs/attributedstring.md b/docs/attributedstring.md index 81bb177..db609f9 100644 --- a/docs/attributedstring.md +++ b/docs/attributedstring.md @@ -79,12 +79,6 @@ class FontDescriptor { uiFontDescriptor *getHandle(); }; -class UiFontButton : public UiControl { - UiFontButton(); - FontDescriptor getFont(); - // onChanged, default button -}; - class DrawTextLayout { public: diff --git a/docs/colorbutton.md b/docs/colorbutton.md index 7cd86d2..c9b9719 100644 --- a/docs/colorbutton.md +++ b/docs/colorbutton.md @@ -1,7 +1,7 @@ # ColorButton -> A button that open a color palette popup. +> A button that opens a color palette popup. ![UiColorButton example](media/UiColorButton.png) diff --git a/docs/fontbutton.md b/docs/fontbutton.md new file mode 100644 index 0000000..942ca13 --- /dev/null +++ b/docs/fontbutton.md @@ -0,0 +1,99 @@ + +# FontButton + +> A button that opens a font chooser. + +![UiFontButton example](media/UiFontButton.png) + +```js +var libui = require('libui'); + +var win = new libui.UiWindow('UiFontButton example', 640, 480, true); + +var widget = new libui.UiFontButton(); +win.setChild(widget); + +win.onClosing(function () { + win.close(); + libui.stopLoop(); +}); + +win.show(); + +libui.startLoop(); + +``` + +--- + +# Constructor + +> new libui.UiFontButton() + +Create a new UiFontButton object. + +--- + +# Properties + +See [properties implementation](properties.md) for generic details on how properties are implemented. + + +### font: FontDescriptor + +Return or set the currently selected font + + + + +--- + +# Methods + + +## destroy + +Destroy and free the control. + + + + +## setParent + +Change the parent of the control + + +**Arguments** + +* parent: UiControl - the new parent of the widget or null to detach it. + + + +## toplevel + +Return whether the control is a top level one or not. + + + + + +## getFont + +Return the value of property `font` + + + +--- + +# Events + +See [events implementation](events.md) for generic details on how events are implemented. + + +### onChanged + +Emitted whenever property `font` change. + + + + diff --git a/docs/media/UiFontButton.png b/docs/media/UiFontButton.png new file mode 100644 index 0000000000000000000000000000000000000000..94005520101e2cd0470000387757e2521c5e35d1 GIT binary patch literal 25193 zcmbTdWmFs8_clyR3vIEsl;ZC04xz;<-r^RDy9bAqQrz94cqvv~gA{isxCSR!fB-=r z?)&$*wcc-UR#xWB%(=Fmedf&UYZ9iWB8T&eEv)U#(a>~)l5}4RX)Z%ocb4J~NGiOtcmDYfi^&)u_**P^ z80ZW0%tAlC{hS`DAYT|S9VQ$1YnnBP&NpNlb-#M-({_A)iO6*IpEdG<*InxQz##@` zjk^646YE^GXm8@2HRN1rpLpP@K3RJ94GlZ=8{v4|ooPM}9Bz*`=?{LWVUMO-k|#}G zj=fk#JwSWky(T)qLoK(TpcZ zg{}y<=Q{k`{|qz4)Z}x2$3g3uiW`_VM%xuUe=mQ6Ckq>=6){nWdy**sgCD=s`<@zx zhSu2pnj$SU^cRj;gz?LEaR1ADyflBXS^PjJ_=HnmfOO@@TT*frm3uHp-@`J^-%aos z^$#&OY7MMDoQyb7DNaQ7N{8EvqtNr3#bD#N-%(6YGHyw)bmd!vhTcDvfy=n7ExzGU zjp9;e=+LHOcG{hO3zpY%dlLmFLLbV60FJJsk;}m9ovZk8OBz#+1uHp5ET~lIu2` zz&4z}Q_pzhPdxbiM6MQBj)LXqEgqjOj5JiIAy*ORNP3?f;uYfcBdtTMGt#v88>?pv zvw6f&NWAi0%J$Qa_mQ-d!}VndR58ekTiRB$_KhCl1my(zNbvU4YAb^7w^FqLlMEKg zyW-$eup7#U{Xu*+c=n;zGD3w@rn0#(Xq9q|=wbb);oT;%DHPEK7 z-)xMuTL;jh)wWAd62n*ds+RlRWzLQbfe)TGe>oRqMKFjyU=hU{cD}s&#ufYFQ2nXR z2T~%mFUHU7pIELvai?OXcuMm+3%^q(_PNVPfY7t(?>tUVGcoGc#2T^nK49)*G<5oL zy~zHyBX6J-5MzwX_MPCxcc<5HOoD}|{pH`q2PabD$m8(@*-^>$qn`zR&y{DQSa=El zewHiw3tQy*%*T|U0>4O`vBbak{uCVdv7)$nl5Z@M`g}X6$Jk2;UEoLgSIaq4++fqS zcS4vP-xSwa8lN}>x2&U1@IA@yUvU0J3;$*!^)k;)orKABS|E{;<%Nt)Vg6-qxVq*q ztY7ZkV_m$UpI#(k7(tVF{=_$9KWlkckoHOk^uO=yqF{GSaSkQvb1SgNXI?r!dt9c?`p>V;^S zVaK{trjT_ehXZMJWJK52#wTZ-M$$&=rFTc7kCEwPT^~8gzLNJ9Xd?o~9Czcb7oW27 zMe^nG>G3UEJ++Fr#+}rds+|%mNXygBHP0g`o+$(s;S`SKvFAcQ_(WVjhig9#ppqV^ z6MD_`LrL=GI!$iON$?*fxx9ot-XcU^L^116QAMbXpe!;;o-X_iPH1+wkjay(XwQVJ z@T;usG^6O1c)&M6U|VKent$j$FFH;jQy_I0Zt%NclVDbCJYoxCYoZ>aDB^+0y~wRd z`$$z{!qn8XcWL$9GF))W-UB%BMGOA%@m#uj=ieCf>RBDQ|j$=qQ*NZjj{S`&nzCrnoi9|~ZND~&&R4`ma? zY7l6UKmv}2mc~4dDVQnbvNf`&#O}nfT76r$TPIozTLrx=ujj6?uOzRdPe5mo9m{R# zX7LH-dVA-?$8VY)YE%Y4rGIK0tHjEUOL7^VB(8m13y*D#jZmvs%O6+#s`nLVoob!- zulQeAnp>KB8c~_iFfshXH#4ts-iR}J%eg5i84N4i#pp!LMGA#97J7zX37-Av(6_?7U|yx`?-8<8>Ck-vFL7k(e9!_^Hnzi8+GHdOPe$++W>MY&5K~F)yK@6ZEw}Iwjx4w&K=e`#z`%wp2 z`w17N=Zx4taGqk@U>D)g<4ECNh?h+PWR9?W-DXI)fcOS)txt#)nwLuZunHQUsqJ)Ud>UH{U@$EccFIi zZ@pH%Og-nJG@J&mS07-Xyck{&sU>WPscPT;2KwW{>i z>!cI!6~eJ24x=_AK81U~V<*od6{pB2aOJazwoxt*3o?P2>Tl}A+NywCrEia}1Ydf; z+$4xK8aKWfZzeBHDoLZQvAX9u(e0lh8DXk8noc?v8#Eog06T&DZM9XN( zG9^|c5FxNra$#4SE%N z*`l6aE)Qw?_cMZy7Kc0F8OD@n__*4Xim*%8rYg7 z8b(5$J~R*AF$swY`NhMk{Muof1UbFgDnfS^3w1Z6#8JE;egpn%{!&ZYv1q8s?B#3; zbY=!IO(}+%6Cr_Y>n#0x(mHTGi&agi!e7n54SYtp$?4w+^Rb3iUuT1ZplW#$FD=7~P;KO?c?Qt%qxvb5$ z^`ebF)qTY~*UHF@7$0(POb6Z7{T6$7)HZpSsNjtoO6169*}kRNxpJ#*;cnZ1=DrB? zH(ol%G)6k*ZwWi{X)-%-0pgddJouN-oY~c-=};dsXHMLUZ-a;DX8K_7%Bo{`Sm$ak z#q#BtR<>nZN9!Ci{?z=GHCtP=k{&1+T^a=ho1PVc|5|Tc7d*iF8mb(@DqF3zZLHbb zITab|>3g1zm;NVRmv~<&^Cc>VxBX3S+-_^ScS^y;w=)tu0Kto(8*@MZ2kp^H%k~oA z1KmGB&pM*2#_HN*(H-Q1dDNDu#FD>KCEb1Z9h+{FfjzLs$ft^;s*OUqC|1>T4M4UeyPDI0t_V^k-&Ka}pKXRz>Dgru3l+x;dRgF5)7 zY*TL!LtPQv0y&(cJFLT@n{Q8K?{(PSz`S59OeCx)GA}IJ+}POM)YRhR>FMq5fIL4t zzg${B+T1^oufO0$K(W+t5?^iLS>SdCm8k(j+FtsQ`D4x}?c}lK;dRq}8K??&&UDV% zY{8GFm!;RG$6~B35>vKcY7!g~G!ze{nAe9^zp9aP-`nQe89qE3W?#Us)@F=hcjTvp z0FOJa14%+SD2>=RBxw9JDss( zD9~`^By_U3F8u+*zu9wr>kHGONl|9Np)yry!E^v;+w7t4U zO@CBpmY|<2@()r5HA49eyBmN_>E=}c=oVBGZN2q88wiXeRb7-5?R5}4@L##kJKb8> zUaySm74F+v#a5|Ro^4~#5jl52x}7O?`>f*CQzls|)KE$+-y7U%9~tZtws<8~O0Loo zwi1fAv$9cMpWZO;{6^_r+}y}!qCH)cbqI@=&zeG8`M9C>Zu+@v*ZheX3&{mJgpfA0 zDJZIIV7+a_$BM;j>ctbcBWXr&4-AQ3&m!N?>@3^rzAv zF>|~A2If8E{&M;(jATIW^Qsw9e^QGTF&g#$O$srHWO}3VRL?)WydLNpNR?^{W!m9sWRI6ffd~` znT4b-oXyLgyCAuoog_G8>shO*hbJoaW-vBwVD--E#sgCW^9bh^Ry|H!F_(HMLwK+~`e#Ujir)w!vh>(;BCpn?$Pwz@8d6}y?myO;V zsEB84RTWpCbe|?zs@7@YWElZybvHo*?e!%`x_5ekYhF`W)KQom^#(V-G8g+tMRM%j zTFU~TeD>;44EZUHWt?ejOvG-ZK{+bWNbP^fPIEzE56c|1~#9Ne!VniMFp z0pb$>1<{)$Vz}!y;V5SUP_wO#w~a4XNWss?+{Rzeg5m0J53ka)Numi1xQ8yK{HUzP zDxhC5zv}DDfzC4N-xohW{D7fDH8aZXg!fl+d;F`_+u0!1+|XakR%FeuX@mFvVywwG zwp>B@+-q-Zhko?Am3Q-=7h(rRVy3-PFdw$mN!LZq8C7w*#y6TZjd=FAie5*b0$=aG z@nz$qzf~|Za>H%nkNR{jpB=YA4`-(3#2UaI&>Ui9(P4hY#KDZi1pQS|+Wc$aSJ!?% z$qs)_ok3k;tu_b)q<- z+=()K6?vB`6=+(NkWljrk*Anro2H-IQjgiW*|gIHXEu7jVz=VxVQ@BZQpZq}z<9@T zRs1aVInQ$d-tU*uFDHtAGNb4A{q^ml?`oH>m9>yflbMo6_8k`M^=z0r_L%n_^is-#s~iu@kJa{XjOYzetj?skT6=gojAn;ID!jZ=-DhFf zSSTP_qplkGq(8T;D=cU_Z9F(S%i@NR6?TXOkIz8_ zVsb9{0epw&kpFcCO~@4E+rb;OOujb;Xy2^ZUHo^^j8&g?=;C)|7NRv%;81afN$g-! za!HRy8~!9&lB~vjKR}tRM&yQOBW(k53O2vhi^y{=SixC#P0h%RsK+# zJFttsD{#&iOkf%wCilBSosE3GL! zr*W?pi1Ma>iptQv#t%(6$30)h{)9afnHd?9YL)7qVEkEtH&{3(D6TM3Gx6e8#>+(} zpLdwq`RP-s2zDrigYFTd7;!64E9cd#E9EQg=L^rj{5b!?{TELrIwCl1FFc`JLjL@d zmV&t==HOhv&EUYm5bG{;GgA=jvE*m}goQshc?^}wP43@SvW{&1RL}*xKIcOj-WHu& zG_W_a1(rwaQPwE@;s0aUaIjLp3YZSqNZoXsxGrZ+$w=@Ckb7{?O9}KijaCO@R9ELT zwJU!3U@SY{v_>3mVx=|b^yArEuQ8M9lAfy7&E>ZwZzbq!ikS*X;OFu~@{U6Vj}H_6 zvHA5aHh5ht=dF9bU3bEm>92b6CMfG!TRo+>cFRrO>G1~H1|7A9H2fvzwP$qwnznW9 zKZzH9MLq9|C`(x}5ME83sLmfjEQ}to3nu&U`OrEXAFx8Smsf?xg|DovZeHG(9L)vn ztQvVm3o5@Y>YsvBp44pQbOH&0SKEqhr)+$jGHj*ySJyROBbL12P&C`u=;0qRQ@@?W zlEJVGKWNGqK0M$45w*s3#kBMsEN$a%3gavJaFMSyK5512_N18<@-6OfEH{0soX*o( zvKG?Ch^~z?Crsyj&&TV+{d*idWtx!}o0*nkc*&>EBYi!Qk^$V>A%zYIG)t+{>@{CC{r0?to@#}BR5 zbjx$&+#MmcBH1Rw$q3D`NEL4wuP^(fS69`*Uft3FFAmH!{r060!Q0(ubW|(`u+zR+ z*b+aa-6vH%I?=}($5F!C$IZ=c49 zJC=u0EO(R`DtHc*CM0dA-4Dz}?BJs7+pQt-%A{VP>LIvPoL|)NdgZ9=@8OE-5LkB< ze(z%KzjiR(a3K>-zjZu1BnqCc^wpWs5pCWBE39Gjd>|*nu#KhLxKsM|ge0iy&#OaB z%HWnb{U2O|1W6&y(Kq4A(x^Pei7q0HNE`-AS4zch5fjBKd?8%}k|Sy(?3^I5l&Okq zn%0l{%nn(hPkpl5vM|Qkan^AUt~st&*&|YHB^)~aNy6>V@9~qpW~b~b4xe2*M88wv zAC;*PIKrk-G;;5TLa$?9sl}0ohI6I7AQARq=;`eap`)Nly2jtr=AkqP4<@`bdsiMy zZdfo`a-(4Qp-Z_&%~n1{6RKZn1nwDM`L*(+m+$XkNl?<3y)9{mx@fq#6O+fJbG8$^ z6BMa4=Rc6KpT8}7tW7~h?g`LgDPYiGE8~y^RI@LLS?~$aP-LhjnWf%}@H69N7{w06 zYc?w~?f6z)W@CEYUyt9rJ~s;a6EYNW6-~z8ORmV4#(`j?tZ=Hlb+4{q`9tDi0UR+Y z_c5FjP7ZEF&_<;bvT~YMNE?yc3OHKZezB@Ne%)l`AK1oPj_OiwSXo*8qb#6g)V9(x(dzXlxnsK%uKC^8>~nFN zenMgnzg<{r9`v5Psl$2b!(e8$r=WbD^#(0f```fBgVsUt^pCfvpI@PkpWg-FXR}tc zpRBjgW04F?99pzKM~9z_%n4}^_kLULXe<~#N{yk`#g8OHmbHeCn~t)Qh^eDJ$5%5) z6LStvd#6WE0S!&eQ{=H}Z|?S$%G2J?!BxaloaWyiB9HBV4s+5_{oBROR-8shS&d4{ z(Z!sKpM#Hsiw5wDii%3i#mqwFv$X7g!5{a;X{_AboJ2S|Jv=-(Ja{=AT`W1dg@uJV zxp+8vc-S9%u)BIWxPA3xcW|ZskC6YCBW><#>SFEWX6@)e^^e@ICXOICaT=O`6#dWV zKX#gXTK}&m2iN~{>(N2Zf6j1nb8vC~kL*XN*gr=_)T}+t?R2EA?adurA9VouxP-+1 z?f?Hd^S>JZ4^sDkkv!bO{}=gx&iofrjPoA{{*OcdiPpbIAHxNBCC2$bp$EL`b+mko zhV}tXLHeVH=M%W!%WqklpocX2v_qdcI=i0Z&(FuhNb#L{8cdoGjvDpav5)Px{W zMq2HP_A}v+-)wc$T7}gtq0e)}an$WtUWC6+{vaQ37%x#QKgx>q@|L3Noe(1wueal5Kd`ZZjs7`B+$Vv!3 z5GUs=X?jQc*Rv4;hxjJ$m`C9nyvCSc_$lM+*aau-y^aGYp9e-hG5r~UZI^&KUO#Ep zkmM(Dg6#T4ir)KS06P*TW!WmQa@t%O4{j^Ze8ktjM&CT@AXbg?6oVHA`ET1ZKibUo z3j47LY*8k-RrTk->QArw)m;^HR6w$^F&p36f)^D~4lwz(0t6>`2)u z$|&Ij8gDlK5sR`qV%KR<7u!4$7lvMTfCbsJk<@&Lygo@O`)LwV&4!~4ljo0i8ZU8= z|3c4I2Prl^DPJ-pt*V!uhDBMK*^hpmd_<;qeV`@vptTXqvshMYu=&DfYgn#Td_-#T z5B8@y5mRYNgI?C;3y#t!DRn=2X1}OLdArzd8S`zIfy$FDu_O6025nYkE)B;rFJLZF z=F`UI&1S6p4c^etivH}v=_lR@5c^crqbz>nUkzWO@j%6Bi^>&W!%_pN8Qo?mxY5}EvcS3VrPV1bd*uh z(NAK`&a{Kb$`8ZFe%uQ&7>&i9?h&o#U^r(b(5JUEnxL(P-9Pe$^;nsyMr%cwee}`U z-^5Hc>)Yi?j1^_6`^&vr*$cU?&3`6rJnM!t7#UfMjM^DQOOvDdmmmA~3ZTo7xM|rz z{JGLJX}jIog>yxksw@Nt^mc{@6%o*V+A!M4~2{v;-6 z^qQ1=S@Q?BSqOCLZ4VAAAQ-RXon9wy4{hSb8$7A8Dc(vSdsH)M{xh2)BPnBB^^AUf z4wTLrBhhW3HKL~SwMp?nxT(dkru@qTpRaO!kLyvxx$)Jdn;lcG zBb|R1F|87TbM4DE5{#$a!uT;VNBfy#`17NfaWVhM`9}%k1{h}ovjvT>vx7SY*ErZg zt+Sod$>iZrde?XG@dh5#=9X&qSFd(~!)Ln}$SN@b+~k)>`!3M#@RfBs7f{=57AuKY zRjudEq?uKAttW!`arO$J*9nZ&w#IT|1yX9ax70V6LJh?UvM{50LxO>vL$Z04T_y@b zcY5!`X1v0@X-V|s(iN(xm-;5{Zk!t3MzY0ydhd{{4~1TcZAh-I3G}wUUSLh&aj+iq zlmtC6Fc4iFB3`OhY2=6eh)I4vP-hFR@JQJF*-0IkOWHc?2kck*JLz!AX^?oojCV zllfYNG|7QgPtGVgiU?bRLzeVhZ}v%`3{>QHi7x~2X;>jEp2$J37`0UB2YV8zw!-_P zrOGC$_HN(b8a3ir06&$G8DBf{>0i4?4XxSYzD>Q_bYPP@8ebC7i z+AKVh8=P4@qO#72Z>NaYw$o*AfSj;4`M@2`=8O9By(5Z_I2=rRPl_^CY3x&n$&FpBvV(7sw0NoehV^&%$jQrmQu7sjaD0XJ7a0cX znJ9Mg$r|T`vXv2XK1Xp`4CIPv?**%+JJC!hsA46@AyL>5Zy>QG!9d(sbRmizG6}Jc zXdQ2g!9H@1tQ~nZ9YI@al;Yqi-FAN-1B4$HPqkazNGMw$8wB&v|klB1>@# z&*u@Us&-77T3lomSFivtGMq3Ue8U73!Ud5(j%Efno_RZ=2Y0AY=FT0RS)O#~o zxrO=yug*69%;-ES*1qQ-Szm&Bi?|^=%(XTC02W4HU(tblT3B8`i{H@-wQJ9E6#*#h zO*2pOgKS_vy*=2&;*SNas{wR;8hfXjQsi7z_0$guc~s{7k$P}Xrt2A<$C^^I!odR- ztHE%`kZOGWz`8ew2nnmV)(|wuC1eP;MZ>$T#ZV$ttmF(dO{MWD^8gScn#5NaML|g@ zI$ohUP7fo`lEdpDR`X6a4;`)EHRH}2fvpFpL^pFX9zXr;1hDV1waaj!_7HW;Xt<4o=k^n?hdsgmEvO+IXIiU0zwXj; zXD4VvkiF)ft8@=TZ}K%dfq#g%W=}wHr+Xg#5;dh$@5jCqI8nL(2>zEW^+3(z$N4oY zGU>9H-%U1+=+8|p1I91I?MZhI)Mrbc123UwE>(Bht zrXFHz$I8h#u0EZ|PCai%RQUDsr6F#ms(X8Ik3_1ov)AhR+v7zSmJ_h>2+4GA)A`da zTUrbtqTUoqfd+>Pq7;Qw2eX|(=&;J3)9S#Kfn-jrar|&jC}pn7JSsNdtny_7xuJs} z9N*y37y6Tva^k0MzT=R$*L_gbKvpL@3lA* zoh^Hl>3ES&Xr_FuH{WQTpmgY>su9qXZE!<-ebv)2IGBK!lC?~{1j*HAP|4vrm!4XL z4ES-neHYDO9NZ>^4p=m75je@K{Jf>=Y` zl+rltGoVBJpbWFWurwZUz0X?}V$#`)c$|!eW(i}9p`|oW9s&i5u3FzfB&H91>%+Z^~h#S2H0n6o@Bd(34s>xOD8p6FiOida_;ON>L= zZ8MhzovZC69No_W*rvs*d$EK-9Ztwmi{jK0rDRzUDxY(jvPtWwz$X(lIC>yYy=+@v z1XXWJ=roZXm}{&LF?Ruz1v_o06=bKrb_NvLm%AF7c+r^zSClcPj;@LkwX+BN{8;>f zAlk(Yv3}|RK0k}p^Kb;E4-DU-DsI})spcdy$vY}W8G=f zb+{QHILkRWQN{3QWL%;g|rgOdzd z9k0dQhP+%1kE>iJ^mm3rB;2&lyIn7KMq^92xS9_0#J3_{+rq53TBlT!w6mNle0#;& z>C1`n#3inFF}tThDHezmd(&Fqj5;ewuYr^ zRm*-*yMLJPCQyRbRTKpa+3}UXha*u#4QQv51Ud1F*wqf8?o)D00RJgy^K<-IVG8ydhjXTGG6}N}0o=^7}UujnI4>R~GwO&f3 zijVm0i7QxblY%}*0NE7LYK9tQRu3~*Ilm0=I-%PHqaBu6XnxD(4(XUgt0KHA4sjct9kD;M{ej45WUXj--SAD@zOUcUtgbP*9!u#jVf2$! zx&5oX6@_)`Zr z#jNOmh0_FMePEGm+ver5e0ncDd*XT2AdytLdRyyzSzQWC!m=2cYHv{lxUXEhbmTb> z0kizuZvR3IJx1U|usQMU1X2nkPC|c#S;MSR(@s&wV?6vN0q6DFip4(PQ8zv+Nw!D+ zd?L3S#f=}YJ1pDSz^8+7^S$!bWKJWWtk#_`DgDne4;hBQ7k<~ULJ1dDH^)R`cmf%a z)coF7f*A^|*1?!%PZ^SMDl)hlL-s>eB-n1Q*Tt3e5AH=1QMwCUQj3}IFPIx_<=wF5 z#Y4B^`c27!c=HNGC!b}-F(Xx_*|8@1B}J-YhySjPi5Z7;q$|JjIy{!K-Ssq7-F$p( z`9&z0S^v9>wfFa`N=dK4V2`DrfxYQ(1NV^`9={ov`CXFxRSK_fN*DoO8d6ME??kUl zY^IvU> z&#^D1=Q#cSb6T(0f_NJ8y`yy0fEt{=i%acg*_(&BNUdcmTrg5}WpCxP_rnd zXhcqNtf>4f+;nvlmk{ZnN$S(SZA{#{t~Wn7#aYAZXext?+`T#B1k)tEZcRw?5Zvx`h3lhJUMauHxC;R6#^?51Zzbi;xw+wu`d! z^NYbUNKq4{*M}%n$R~=d@i>~J+R&(e)t|?6#Br;`&*<%G?UYf(62SjGoPOIj;C5sJ zCG+qVkXBbp=CPpevQ5w)Uq=bh5MklR#Jrh;Hv4VG{IUXFe#S&s&vCg5}>Q% z3v0Z>B-X2=pzV2_0+RD}6kMrXwm(cHiT15Bz0#D)}4n zhVqNCmZbRFa@XBbk4Vi!%^?L{=1vO~9G82$=yy!2n39&($S9uf>XmV~?CN9KGHgdb z+ru%S>7wdA9j2|r(VK3I8B;x@u!g@POZsN25-qcEaIYH4iF=6SXUCkcN9(qaYo|T( z*=q>=ZE;;g!%&2M7Dun2(K-n+bV0z{rA+%w)WVJvpY{HuN9v(izEr)IZ{l#&P6p$H z(`;I`)VWuz=!fQ<1T0lC<@>u8=s*b=0O3(>6(}nxx5+YaT^;uhM!rU2e1Vc3qvw2e zQufnFm0n6so?OnI$;}QHF)r)>plq#q+QJz(oW0j(vE$#i)NFCo)=styyE|h413hf{ z@&l(?3b6wm3STddO%XRv?-H8t~*$^x~M;pX`uN4y(Qi{5ER?_gC#l-AaOW!MusXD~8u?O$&qc%QC^VZ4$ zwU2z3b6RWyopUHT)C(`h4C$6RZ@F*ki2%0FUVLdW#D3~0k-3$jvLaPt8 z>mwvxdN?afVs4*fOw`N8rWP5S)(ss5{ zEaI1e8=MoyN_p$LcWlJG+OqXg`0@)dxq}LQ-&;9(p89{Avu+eiQ zPzYTVv8*byaRt9=c6=tYda^ls-xygKUHQ0ygkrjLRZ_$`Cu}`QS&?A?(W91Du36$lkEZSi0QMMbY*k&~%@B zaa7)T1*rE>PJm?I=ePK;U(S-xbb;-BoQ#{q&QCV09l9(O3~NxCA+|%bK=%{w>ib+$ zn2!XiuC;Mp#%ni4aIoqaV3Z8F$g?xL3(Y(&1SjB2pfs;%&2u7!9x6j}JhD0=nme;s z=ToW!ddOATTliR;c3p@VLaVPV(Us*^;u?$`kkMXduk_sM+{k7Px%}>vQa`)zz1NQa zK4Vz5uz0;eXwRjB`mqeLjW_-Gr_xmZ2hL=jbZBPrdgN^SOGE!HdrbE# z6XHI1i)CKXo3K?E!_ZC(Le4N8_oZI+li8NNi*^j^X~2C*@{v9Ft<+FgeVc~L{5{i0 zwiQ!OpTo;$kHPt)uCp;9D9v`ItS!QKKfWe!?8Qk8w`I#Qxi;4&En?>9qNd7U%1o4!OIWr4bI2z8_7(_4oyb9e&AkEYI>rX!3lWErltg#^RNe z((UcPY>g+x#E%*JCHbyxGj1&$LsX0G8j8sv$jh@jEC4-hjymsYL)I#AI!gjf(vgNj^75+y&cpKZfXlF-+YIDrih#Gu7 znH2r-C6D0HyWeN)yrFT-KC^w~?(}-N?*x@|Z!n)qjTY2Mq4Q_?u^;oeL;A1I7U5nTm=}3T<_L2K`8r2c$A`BKP6EUWCGCH+j1Q<{@FOugWUw z$9GrN8j*X;U{?c%mcWWOFtY@eeuD$ZQ3v!X1*u%Rpp}x%Ki95#v!tJlZ-A)uOKh+x zD~7WFT88i^BPA;FcN!@VD;AJ{9IpM&*2g$gY%9GRYFjw5&T(ojXG_h?>s(vy&5vr1 z0ho>CEqJ;i_YZ#`-*%?{XsGyFTJ*nN#~vluUx$iut22?U)di?xlB)_QcvrTu&CV##qa>_10cyGFQv-<;|34zG54Det@*C0DX?=;NFl|SuF@cbi1*z0_X>VU1bWNpA7xlX-c za;~~R7Q&D9+Sr6A?I~MIq#{&vv|h#?mmrhGRH=jeOlyFIzzhfC+bQE;8U!wRDG1iZ z;d09PUB2xyHV{$K`41EDSX>rB-?eYHB=8#w3VAsjrB_>r3tV7&o1ta-1CP{pyF-@C zw}g8?^eY(`c$_l6^{e%@zj)1~;r}8Jfz6h0rg*FkbBT<}ru`JaQs(*D#*JxW5zwmf zx+q_hHZyxlq4E)g?a3tV7o$;Sm|oiv7bo**|0WIN(<)9u6GoybzjO z0ZsZr8w^S~dyRkggp$OIgo}~n({J^!VUpi3u*CU~q^@RYVf z@lF18)$jloI8b7-#2P62S+U(I1KRPgz|yfnJX-q542C^v2Tt^ol+?sb;9lQ~@9Es=ga{P&)~SF; zs)-%roI4YB%4VB9jqhbB>0ED9+4P}Y|IlBN0a_*<$3PuY?tQ&8IL}=&;l^F=-3fIt z5$Kad17FJ_W9sC4E#_xWJ)eA!&ZWOo;2Hg+{U41n0R?S^&SfM5!O4+f;_O!oW$3aA zk|dIk$$xIjPca#0JwU?npFr|sxK*Bk%92uN`ICcfDc!JPCThJ}fkvdD4yV&Z>mfPp zO0`U2U{&|jp)8!UR;BCTbY~hw^VZPAlM-JY6P`o2{=(2RRY`BFW&>RIPQwv8ev0V* z>KYjYlgV^XmTtxQk5O>}W%q@5I^h1%7EahUvDYS#ZIV}qnM%>qc!8e-rb_YB!o4+o z_UwDS|D9hyeF#7m+-6;vWKxQ~ZzE`ffe9z;p%_+=&qGT};);{}wH3BE1>={S)*%HI zmd%f8MTB17{o$A8n@y2A97DX-;ISCIo?Q~%=86;o{jJK2ZzU}8Q}PRD6b5~}BcGA< z$!#Bg3e@K>$i=UIhJkWb{+>3rhrhQZ~oc}+F z2@@*S%2z#f7xi?$8kf+1@Ia+tdclG60nu7*UBRf>oGziMVjObC$B`LS7WxlEB93A7 za05+&?3Ud>mw0#%*tQVkx?x)Xw}RUXikv0Z54VFoNvQu|_o6F>TjZ@JnX575*K_r1 z3u~9tjh@1pYRP}dC;=kRwE#?#Dz(d!SeWlZUl)c>wp4G7=}1vO4=$12&*V8@( zN|vHX^rGKCEuG>hGOhMK_Y;-Ak6=A!DP^GHzLjm4#((&?Ul~s>*#!vfL%5bt){%Ix zO}q%T_yCT}OcfKDN^w20N-#BKAuz^&d{H$Nwx!uv8zS_c9g_E9VMuPH!1>TO9~XrCve{7V(voYjxxQ37i?#bpCC2FHuwo zZdTk(1Z`@5?ZU_{R{&j5eVLygUe8lgZ2C>(gNVlenx#qqs=+z9JRLW3i=4fi`I2+{8@xauY^vex)#+BG9tz^i;*FQ}m(}KfF%sF)SYH9`ZON}|sV`(Gx#x&#skxaqm;g*cBvyjv$_z>;p{$GYanhsDdhpKkZp)}cB2fg-&C&4HDqkYh>qE{3*Y6K z+@l{|)lTir+J{#g72WgD?MZ!=!=QG{RI z@y|zz7+1f~S9sAgyMc7|73EV^CISRjl@gO-_s8>&#R1Eg_D`2t6;&nVMh&VbyQFOQ zQ#2pBFgRuZ8`8m;s+FyV!H<}C`C<#CiwWBhgZukbkAaUq!)2uv53aS_9u0#&xDqO( zVmo9_w{489b(pZWN-`G4>}wg_hUIJ?+vPD>S;D<+n`htI=bcNaiTlNvl=27-Fn+bv zmsC?SwZfvp-xtj%CF3r`;Gajl zTHKnz2hE<7-7LOvSJnRXC_f(SZIx=oE%RwByh1^!98zvr@8GRIiv$ha&J*Nx`3RIH zIi%6l6!$rTE*y2}Rm*+VZ$yd*zAwASzJMRc@!J}?O(6SgSfTx+izBgnyg-IyA$Z^< zzhC%CW$pcu=GoON!W|b6m!__o#_6NFv+i*I4K2pS5W2aO>@B1q$;hTa8n0?ND zE1CO_r5Q64iumP=z=-nzI%oJEu3d8+NDDhbJ%&Omfi%VBO(9Ci{Z!#1BIB4zKP=J{ zI8BCR#r@BfhKT9ktnPexsRcoS*y6SDg9X`W#{-eVy{n;7SzaQvF?$|oN$vBLo0G@{ zv%D^#o3=0K?2sW)R1*Lip$w6XzCHJVEj7Sd$s4sN=+Dko$KpK<&v}}>28gSr-Zg36 zZ~bXcbj-da*LC^ZcD59M0IQU^Rh8n0eVc;yR%TMUQapHgEy~?9ryqPd7Sp@Dy}EGe z(w9~N970@R7ajvIea48=SRZLrk4#q7$Wg3j#gTe*1;VfI`Vs^X$6z?5%X#Q!Khv(v z<`i7L*4_Di==fI=cIbFpWA`u!&nu_095q0~o;_EciWPXgVZDd{DCY(`h6U1v`QD!< z!8p;OKc@9mq2DU(XX#`m>~EB#KVmS9zH34;3J%6NK5_vS1`=)860qz-no)u%&Gyz6 zat<28Ri_j--D+uv+Z$^al+1C0Ximlbp~V<9XLrLfmR_|xr|(<>X?tBH#R1sZqB)>U zL@ZG|4GXWvp$wu>4yb6dn)4jk@bO)a(md)})23)~Q$PAru5Z}hMzwiMq>UZpm+8@@7}aXv`t|wqNcE)ww1`i9w0?PT2m4_6jHhTP ztJ8uiEW|s_?CD@g?$udR#m84vL>m4$sB#4{mvVP5w^`FD9=FI9jl7-LDB+nI@L2*e z-FrKd#;&e{qkP&A1FI3Ry0bac(gN4fBbQ%@hrfQW{b8h=?I-zT`1Ombqaep}Kjcc^ z7JJJvtLp8Bdz`ogHRjPAa|ZY!w2@bFrPa7v3^`{?lfW><8uPB{^m26|7@tshioN^J zkk{+8PB9P)%aj3kbckV0IRtS|de*b{C z%c<$DiLSpy8$*jOrjl}mtAYaTz*~et0eT8LaPOE_{yO^9z8VzNFUQ#`sj`#+ZlkS} za}c?xb16lgTG<{X6U2z@2C#04gI&!Fk0f5PL&XlR+r;9P2~yw z&EjoH$jXa!xW3kwV4y^eqQ`ChmOaC%lqJ90)N_{md(8w=dYE##Q0N=L+wwaLWL=?m zjh_TDPxU=Tzfob>Q$T%a1=z)J$Ub+hd%Q=>ka=MO@|B0`XhD|lVZE^}Kb~)!P&w4v z`#~y*RX-D>A9cA1E-l;JW-wy`_s*?%2I7ZSzI#;U{l8YeJRHjQ?LW=)jCz_VmByY> zRF<&}#uBD5S)*iMX6#$mLdNnXLyaYbtjS)Dbx86sF%7aahDMg~3`4T-)O(M<-`{(@ zzdzsO{mXHYW0YLMAPtm|)Sb_e_I80a|;(eGA&FR^=mPslI!>uUYp+oJ0UJRyrAFZRdw&VLrm z1G?W9mr}7;gwXn5rtO12>}wh}PJ(x)Ydrq>a(!GRZ>J{epQJb80!0r341HF;EvnZY zf**JVj!8&A^*7oj4^@Ac*pehVU4L%WxOhW(BX{s*_SxBHCZ&VRmt znC`tFLrZ<>6aE7!`2L`U^Rt-L()Ni7QEa&7rOq_Tl!u(v3SOVIL!Y*jNrf zm434DwRnNB`9})w$SKv=qCh&5J91Sz*gTlEyWDmyATM%VKWUL4?yJSW(1g6U_v@3&%_eMqcGx=l#aXq4`UupA zP98<90lfJik=35juivIAE${Lq6|s|~xj3f*DfZ9I`vL5O6GGCzf_DQ~m)ZljT0p|d3aczun z4pdZ{T4>mDSzOm%_&8o^oGsq~K)p#RW3>nKLvQZ;R1+hAC8pto!h+m3-Wtb2>ccAr z#s;MYeh{jp_Wz*D?-rG?-zNp$y7%p(#QT2wjpC7T%i`h>1An0&jt7^d9{lR}8*dC= z@_S^(Ebso&vNjiy+{BRu<=~|!5wT3`+x$LQHqI|(Vc4nG{0(`$`j(aaE{I((_u09U z1FFOt^<73)kA_aV$K;0htAd!Q$Nt4LY1Qx^j2}OYBzQB9;HE~ryN&D~PweKKoqg{7 zu7$0&+ws}w`fCama=8o2Hj+r5@%QFSi$)YxZsNZq|? z$Lme5-rk7Chz^72fASuR;TrC_sj0~QcqSQKZ@)qaBh3icGhx?%t|Vruml(LRkSWO= zWB*n_MrrJ6_VP`%|JaA>=Hd(wlM}MQQ&v7}JQKW2{1uOIA#4kW3z}4W-%7jQ%g>GZ zH>Pc$x3Ku>OsMHo#cV|MXNj()(*F&kF!5}gvY)H!01i0;2Xc0mJLl9jaW)+33`lHA z@Q799y~ zsQ$Q@)FBoo{byfVfr~tWEuL(LF9HSaKwURL#qG=lfrTK#ET;9*U#pYVN<@bq_tYvS=HdO)-?s18c&0w= zcToA9Bcr-q;*FuluaPhFz%Sc3!i>$9uDmfE+plY3OG(GSRaz`Dv{1Zl#^NpTkzg6t zsgNKFX3BQJ!lW)6K`?sh z1y~ZbI$s{G^SsLvj$sjO_7HJ!a)`O*gej9yR5#C-qU{%}DNwOt{MO<3HeLiZJan_E zs1+~w&nkaMXG^(Z8w(}RZzq*k8K3;kJ3tKpTq9n^Z8!XYX89B-g}ok~aA(Ii=c_t0 zGepNKJpS!%EgB{h13?3pYh=-X;QaS#Y$-Rj+Ltg*gboxdgBlJv+y?EZk%fZKqcJ&6 zz3-5)pFg#f!}P}<$Z=%I!e4o448u_uw6BXD{6C^(q(r<*eeP#p*tQld%rMPHJD#eX z=}RhF9))A$1d(S6%GGsmuxrPzT#!$a%a6? z)jm`F-8kD%O`n+9EI`?@Cp?8!F^V@q zYcE7}(0wGsazFx#gxT>&O9vAs8PyjL4Vc=lQKYz0pR8(cZnISlguixU!_&x^w(-U+pyMYd^{RSEAUsQfVZUH-^!G~xuHUCq;chrfk~gSN&V zPH>L@`nffsq@+~ePx#XawqF2EKF=vgZz97Z9JXbnVV7<#+YW@eVY>% zuerrOPiJ|z49M-I>0T+Wkn$2IHMU;naXjbzY8i4WD%3j2TB)$S6j**=49iN zne-##ai)G!l30PdaAnsy`&XP$uxEm(+RSCRXn$xYzqx(^??u!kzvV#N-+eLU_({9t z^;IJ^;g!oWD`J~k`a%~-p`)62p~3e22T9QNy^wZrF|KE*o=G7EIUi~6b!*-7P$>k7 z80K)Ty?odg1NlO}P$R|9rDQDrqEk8hDlb485DTR@Q-6Jaf2+)Tlg+gERV55=IN!9s zu;)mkou6`;)}Er6%;tZL0dJRzm$c5c;1UPul)NXh$ zI8Zh47NeE%m`;`8VMpP)6fI^+6cQU-4i_}WRwV%VcfsTnI}BA=xzzONFk)JKFcc5) z#hz~?b;81k=-;lP zCOH>uDQvBOa(hL$BRRy*&yDhKVJm%^n%6{6pKpo##(oqB@uHl;5due`q~y&+%XQ|# z(Y6cR02@5*0F&yd@EwegT8Xi+n|+xF zcRW@gq^{;_>TZ{2tJf2o>BKK1@`Q1uG6-%a`682nOFYj9Ta=HZyM=Ab1VFrW_a~PL zGIJSOxYNEfM`s&K&ukT)h-XBR?FFZlV*6vLVewhs5Kj+CblCX;nO&m(z{;b9Z$i9H z@%tCgyEEc+_+t{{pM4WNA_R8wJUL31VBTjjcu^;-lrJ$uQV?JzFUc}F&Ih?qH*OBzgrvHKNWiWGrOe8M_ zw{rk$^|hCnZS!OSowf?RLsJ?agQchP8V&rW3r#zZR=JG@Ss(#|@-g~Ff!K74D4N;I z364>>j#x2{S|Kza;?pi`}d&@xb?Y^Wy(rKPz106&=Q%PThqg)TuH4{UvYAq*Fm z2WhefzbLIN-86Xi^=TZlgN#h|c zndatC6BDfI!ey{I)cM_`fSf(jBgZ#&xoC%{q)3k^lM?~n|8JTYproyX)Zz_?`x?ff zK5Fb7p@pq3#a+Qc`AJ1lS;VQ>5 zVS>%9W*(?CWci`0+jZgQL^nQ!mt@=?bT?vCa~K+^JCE;&dqm6ZY7IOmWCEu#H!?F= zd%V8O(n(MzME2UL_!NM4wYh(Z>UqG6zs%9`)PEp`+z0o*!pS{JkLgj+*u|ajgix5~ zbB(78u)=&$@HF~r*hvTaeO5sL?-$zjDcGj-V?+3 zSgPI;kNcPyQn~S`^=Ka~xp4Dlp z2in?mnTlm=0cIOyM6VEphQ|T|y1{vN&JBw+Yh>z1GueLjcu?Dj25O>_ZrOEdyM0H>z2=iFUDRRpV6n{@ zb2Y8^bWWRDh(1EJ|YdVpy>`#Ov3%;PSU|ALuX^C z>;~;%N@p4H6@pCYT=O%th3a*^i$fOg1Y`qW#k%$*;j_p`TUZp_R~Jw!;-l6%|Dvbj ziwsbzcR|1?D_G34ms?wKZL; zOE#@Wh752$ceHDOg3PJz;q(!C#a;#kA|jdgQ@oPv4Gb96!fko+(oE}DeAJJMn;2^C z4I4VOR)6r@v_`zD$bIWvO90v7&w)p-R@1W1maHThLI#H8c9eFH$AtU1W+BAffeK6R zWmMv&0O=4(viOTPUUP2Bcu52J6mYypj@0Hp>=!+vkYNN-2=Jm6=5Z+ne$@~ZOoH+v z)pqmu;OID&KwVCUb&s;ZnQaki#_S6gdK&_cwrzo1#^&wefnkTs4y0gn8N*Rw8%!4} z`D@B1C@Nl4wQjXpHcw&Ig%R83PqJsrzm!oBdiU6ZaSL;SwEzB8D_dS&q=){V&sxyS zQ|vK8*q5#X>ef)IM2*ZYU@mC3NZs$+pLr($%z>xkoxt0VvTJdLNr{Wzl}sV z&5`;tXfHr7qH&C6*homF6l{c_DiJq)MQ&k6*we=pK)oVtLH(0*e!qVTc<;!+`~RYM&|8?01Sr)0>3>jHsC3Qh^n44Uh* zYpWLSsZ(C21NPi>QZk3Ag3ExzPE5lC85{xP93JfKkoD0uH*LM4kyhWdJ}3-0fq2ud|BW$TSLl@BxbTs=C1;)e>; zfnu}dk*9_pY3u&}u|)}V#J%a|$J%qJP>28}MaHr;l?Gi@HEGjm>)VTc_H9^x!Y9>@ zwGR{x%kX6^y*O9rqIO$9jmv`y-*|;PzP6qlr-|+>7K}VD-G%Z=XII>f_^7RAkP?(k z=3o|ZbbQQ=m5|lKaky6ry8GHrC6OmD8>)#aFcvCd>)9}_ux`HdJ#Z=%IsutkWXo3q zgo~Oc95 zhT&;5UrP(5g>(dZJ}C)B#eY;{*+3@15I^z;_ySTpBPOKHd)sOS07-+pz(%Z_HO8%8 zXm&K@Z~E-CHM{Sv9s?DL@>shz=XpS^lYhLb!x*&TOK-YiU=J+?vX3j$sQLs48}j^9 zSd-motR@H8zf8yePgXc_oWHQ{FDN92?gbeVt}|PPzolQvd@c4 zh*X8xQRZX}vyxYcdg(Vgp;F?6;}?rd^OT#&F$&bM17-V@)xo|(3nGh6^7 zS_wwJc;gWE#;?C(?}|OD%yvzcdKRe!^X3jF%j6`2SOT-6=4!#=LN7v%l!r$Lk9kzG z@;dH&qq@K$`E}MM;^1N`bB}0{!?i=L?RvB4Te*hL&RQW##F-wQJ?5}1_O0vcP56Ao z$Em>9PiO`10fk~k9e%DTgYjXJlC2i&7UKIlQLAaHa$cIHi$TwGCpkmC>pFY-iU8^i z1%MFTV;hF5qmsfTRQ^ z0X=;^f}9zq4@Q*MZh>M^vUe^^(0o`S;$<3x=kp58%e3T=HY!r~#Nba=#Oz=dS<3`K zc8GSqC0muGrq9sEP zOyL9F=Z%5 zgdw7AMr+S>ugAOxoUW&Z$%*O_SmkkscrHMw1N+H-q1L0qY9|XgO&03y=rjaY7~cd0 zwkE;q6q(5oA2r@iKqROs{7-6w-TUz*)6ck1>&g( zIqMdUs!}gsyq5D*Rn`dd!^X@SARzi+=9lZHhEEkAP}eB1Fx|BN_EoCxlm2>Im4=t; zR#Czlwi0P>Y1p0~?Z%G)&pst=D@40B)1H#&Raq&beMaQPld!W37?vlPq7{JFySEv{ z5IVa+)JCWpkPZdlDYdzmwcGA7o#cs)3R=GEY0iT>aq-5|SJr0cGgy|SOlG1zW<1iu z9b<%nNM(E#WDze5R0_RZnCp973tLr<55(`WRx15J+bT1y#}WBTLV7ho&mW`IGzL(V z45EqB23xHB8JC-t!O}!P1;7KmB};lWwbF%W3dr7NmphF0xxv@L9u%6c%Gp+PyWQH* z@M0V1!A{ew5|p+<&&2}6xRa(OZ~q)rW;sMiIW*2L#YdoEp!-dC6MU>U~*w#J;v?#tGNWcz? zSu-A{dD`7`g~I`#wFm*G0~C79RCT=0)A^bnJiXs|MTIK*=ICF%!3$!ac7ifS z5Uzc-x_Za-o;Vq1>c37;!>9uhxL-vVT1PIC?52PIyFy{4p-kk;O({m&|b zr?s6!bVYbA$1_pBK#MuiCXoY?yn5Io9^pT?OFraMJYyhJCD&1xhV-5& zvV=vea>gF5`ky_bWheKKC zPYSdlKm7Kqe0Z|-@wW28(BOSxMzwp4-(Q$+?~vM_^yle}iXk1@!Bw6DU^zJ+hX_>) z2!Qu9k*x*nf~*mtF*@Di>QXj0t5`AwN&VuwM*Do`o|*oJH|DC* zqOmP7pF^=RgwdO2^&s0QXndDN3jjryT?mz)vBr2Va2_qc#Gn7Qq0-DXVWT`>H|&}D zDJ%J=@+{b2YeOGwI~Bo}&mx@_sjt?~#YuDVHJsmI;M^IM%rT8YZnGsz_l^oNouzzW zz(^;HW_L9J&wCBj&I~6Pe0ig2H~iY-el6I75;9+Q+sL~=tFP<*lk)B`{Rp_^#>P=uaU(iLiKt-`BI>0jIF z*{y}FgM^E$&J1&{jV~RG&CIVo-$Kzc^*kKK(s#1b9$3uCC8#Tvt*^A9=xb^f)iJAz z=G=Arb9@bpK<}%D$QLjbF$oRF1>c+uJRJN&!$uJf<*Lz<{jSReFc+Jd_>E#^ZrXKj zn)xv2Gci68CL^+{kJ#428+HBYblFaP$=`q6Ph(AssqB`KappXS#Zf#=1uOOjwt86R zfZ735XOK51lD&#f-@m#?-2&2Yz(`(T%2?#o;NOypdo|w zeGZlT?`b%d27(uc&f#I+M2WwGYb92SoLcYo}yVavbR ZgmsRcua}e8VoiHO-88&Wu4VtP{{ozt>tg@_ literal 0 HcmV?d00001 diff --git a/docs/readme.md b/docs/readme.md index 099dfec..0f1e530 100644 --- a/docs/readme.md +++ b/docs/readme.md @@ -1,28 +1,24 @@ - # libui-node These pages document the `libui-node` classes. If you are new to the framework, you should start reading basic documentation on how it work: -* [initialization & event loop](initialization.md) - explains how to initialize the framework and how the event loop works. -* [properties](properties.md) - explains how widgets properties are implemented by `libui-node`. -* [events](events.md) - explains how widgets events are implemented by `libui-node`. -* [UiWindow](window.md) - explains how to create and manage OS windows. +* [Initialization & Event Loop](initialization.md) - explains how to initialize the framework and how the event loop works. +* [Properties](properties.md) - explains how widgets properties are implemented by `libui-node`. +* [Events](events.md) - explains how widgets events are implemented by `libui-node`. * [Containers](containers.md) - explains how you can group widgets in tree hierarchies using different layout strategies. - +* [Attributed Strings](attributedstring.md) - explains how you can style text (font, color, underline, ...) ## Containers widgets - +* [UiWindow](window.md) - explains how to create and manage OS windows. * [UiForm](form.md) - A container that organize children as labeled fields. * [UiGrid](grid.md) - A powerful container that allow to specify size and position of each children. * [UiVerticalBox](verticalbox.md) - A container that stack its chidren vertically. * [UiTab](tab.md) - A container that show each chidren in a separate tab. * [UiHorizontalBox](horizontalbox.md) - A container that stack its chidren horizontally. * [UiGroup](group.md) - A container for a single widget that provide a caption and visually group it's children. -* [UiWindow](window.md) - Create and control OS windows. - ## Data entry widgets * [UiEntry](entry.md) - A simple, single line text entry widget. @@ -49,4 +45,5 @@ If you are new to the framework, you should start reading basic documentation on ## Buttons * [UiButton](button.md) - A simple button. -* [UiColorButton](colorbutton.md) - A button that open a color palette popup. +* [UiColorButton](colorbutton.md) - A button that opens a color palette popup. +* [UiFontButton](fontbutton.md) - A button that opens a font chooser. diff --git a/src/UiFontButton.cc b/src/UiFontButton.cc index 4f8d9de..28a9863 100644 --- a/src/UiFontButton.cc +++ b/src/UiFontButton.cc @@ -18,6 +18,7 @@ FontDescriptor UiFontButton::getFont() { NBIND_CLASS(UiFontButton) { construct<>(); DECLARE_CHILD_CONTROL_METHODS() + getter(getFont); method(getFont); method(onChanged); } From e7ec52e7cf93e74beba1ffd279555b82a1010038 Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Sat, 14 Apr 2018 20:13:35 +0200 Subject: [PATCH 134/190] DrawTextLayout: destructor --- docs.js | 16 ++++++---------- examples/text.js | 10 +++++----- src/UiArea/DrawTextLayout.cc | 3 +-- src/ui-node.h | 2 +- 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/docs.js b/docs.js index f4dd33e..b41ee41 100644 --- a/docs.js +++ b/docs.js @@ -112,20 +112,21 @@ ${contents // ? require('./show' + name + '.js'); } -function property(name, type, description, onlyGetter) { +function property(name, type, description, addSetter) { + addSetter = addSetter === undefined ? true : addSetter; const getterName = 'get' + name[0].toUpperCase() + name.slice(1); const setterName = 'set' + name[0].toUpperCase() + name.slice(1); return { type: 'property', methods: ` -${!onlyGetter ? `## ${setterName} +${addSetter ? `## ${setterName} Set the value of property ${t}${name}${t} **Arguments** * value: ${type} - The new value for ${t}${name}${t} property. -` : ""} +` : ''} ## ${getterName} Return the value of property ${t}${name}${t} @@ -177,7 +178,6 @@ readme += '## Containers widgets\n'; readme += '* [UiWindow](window.md) - explains how to create and manage OS windows.'; - writeFile( 'UiForm', 'A container that organize children as labeled fields.', @@ -397,10 +397,8 @@ writeFile( method('toplevel', 'Return whether the control is a top level one or not.') ); - readme += '\n## Data entry widgets\n'; - writeFile( 'UiEntry', 'A simple, single line text entry widget.', @@ -845,10 +843,8 @@ writeFile( method('toplevel', 'Return whether the control is a top level one or not.') ); - readme += '\n\n## Buttons\n'; - writeFile( 'UiButton', 'A simple button.', @@ -889,7 +885,7 @@ writeFile( writeFile( 'UiFontButton', 'A button that opens a font chooser.', - property('font', 'FontDescriptor', 'Return or set the currently selected font', true), + property('font', 'FontDescriptor', 'Return or set the currently selected font', false), event('onChanged', 'font'), method('destroy', 'Destroy and free the control.'), @@ -899,4 +895,4 @@ writeFile( method('toplevel', 'Return whether the control is a top level one or not.') ); -writeFileSync(readmePath, readme+'\n'); +writeFileSync(readmePath, readme + '\n'); diff --git a/examples/text.js b/examples/text.js index 2732f6f..ab73a64 100644 --- a/examples/text.js +++ b/examples/text.js @@ -25,6 +25,10 @@ str.appendUnattributed(', '); str.appendAttributed('font weight', FontAttribute.newWeight(libui.textWeight.bold)); str.appendUnattributed(', '); +str.forEach((str, attr, start, end) => { + console.log({str, attr, start, end}); +}); + str.appendAttributed('font italicness', FontAttribute.newItalic(libui.textItalic.italic)); str.appendUnattributed(', '); @@ -78,10 +82,6 @@ str.appendUnattributed(').\n'); str.appendUnattributed('Use the controls opposite to the text to control properties of the text.\n'); str.appendAttributed('👨🏾', FontAttribute.newBackground(new libui.Color(0, 1, 0, 1))); -str.forEach((str, attr, start, end) => { - console.log({str, attr, start, end}); -}); - function handlerDraw(area, p) { const font = checkbox.checked ? new libui.FontDescriptor('Georgia', 14, libui.textWeight.normal, libui.textItalic.normal, libui.textStretch.normal) : @@ -91,8 +91,8 @@ function handlerDraw(area, p) { p.getContext().text(0, 0, layout); - layout.free(); font.free(); + layout.free(); } function noop() {} diff --git a/src/UiArea/DrawTextLayout.cc b/src/UiArea/DrawTextLayout.cc index 8d91c7c..76339a5 100644 --- a/src/UiArea/DrawTextLayout.cc +++ b/src/UiArea/DrawTextLayout.cc @@ -13,7 +13,7 @@ DrawTextLayout::DrawTextLayout(AttributedString *str, FontDescriptor *defaultFon handle = uiDrawNewTextLayout(¶ms); } -void DrawTextLayout::free() { +DrawTextLayout::~DrawTextLayout() { uiDrawFreeTextLayout(handle); } @@ -30,7 +30,6 @@ SizeDouble DrawTextLayout::getExtents() { NBIND_CLASS(DrawTextLayout) { construct(); - method(free); method(getExtents); } diff --git a/src/ui-node.h b/src/ui-node.h index fd7039f..bf350b7 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -752,7 +752,7 @@ class DrawTextLayout { public: DrawTextLayout(AttributedString *s, FontDescriptor *defaultFont, double width, int align); - void free(); + ~DrawTextLayout(); SizeDouble getExtents(); uiDrawTextLayout* getHandle(); }; From 519f4ce6789e44702b3f9bf431e20209f63b944c Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sun, 15 Apr 2018 10:07:45 +0200 Subject: [PATCH 135/190] Refactors timer - unix --- src/arch/unix/timer.cc | 36 +----------------------------------- src/includes/timer.h | 21 +++++++++++++++++++++ src/timer.cc | 27 +++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 35 deletions(-) create mode 100644 src/includes/timer.h create mode 100644 src/timer.cc diff --git a/src/arch/unix/timer.cc b/src/arch/unix/timer.cc index a74bc54..192840a 100644 --- a/src/arch/unix/timer.cc +++ b/src/arch/unix/timer.cc @@ -1,29 +1,7 @@ #include #include #include "nbind/api.h" - -class TimeoutHandle { - public: - unsigned int handle; - nbind::cbFunction *callbackJs; - bool destroyed; - - TimeoutHandle(nbind::cbFunction *callbackJs) { - this->callbackJs = callbackJs; - this->destroyed = false; - } - - void destroy() { - if (this->destroyed) { - return; - } - - delete this->callbackJs; - this->destroyed = true; - } -}; - -#define CALL_JSCB(timeoutHandle) (*(timeoutHandle->callbackJs))() +#include "timer.h" gboolean glib_timeout_cb(TimeoutHandle *timeoutHandle) { CALL_JSCB(timeoutHandle); @@ -58,18 +36,6 @@ TimeoutHandle *setInterval(nbind::cbFunction &cb, unsigned int timeout) { } void clearInterval(TimeoutHandle *timeoutHandle) { - printf("clearInterval called\n"); g_source_remove(timeoutHandle->handle); timeoutHandle->destroy(); } - -#include "nbind/nbind.h" - -NBIND_GLOBAL() { - function(setTimeout); - function(clearTimeout); - function(setInterval); - function(clearInterval); -} - -NBIND_CLASS(TimeoutHandle) {} diff --git a/src/includes/timer.h b/src/includes/timer.h new file mode 100644 index 0000000..3b3815a --- /dev/null +++ b/src/includes/timer.h @@ -0,0 +1,21 @@ +#ifndef UI_NODE_CONTROL +#define UI_NODE_CONTROL 1 + +class TimeoutHandle { + public: + unsigned int handle; + nbind::cbFunction *callbackJs; + bool destroyed; + + TimeoutHandle(nbind::cbFunction *callbackJs); + void destroy(); +}; + +#define CALL_JSCB(timeoutHandle) (*(timeoutHandle->callbackJs))() + +TimeoutHandle *setInterval(nbind::cbFunction &cb, unsigned int timeout); +void clearInterval(TimeoutHandle *timeoutHandle); +TimeoutHandle *setTimeout(nbind::cbFunction &cb, unsigned int timeout); +void clearTimeout(TimeoutHandle *timeoutHandle); + +#endif diff --git a/src/timer.cc b/src/timer.cc new file mode 100644 index 0000000..d150000 --- /dev/null +++ b/src/timer.cc @@ -0,0 +1,27 @@ +#include "timer.h" +#include "nbind/api.h" + +TimeoutHandle::TimeoutHandle(nbind::cbFunction *callbackJs) { + this->callbackJs = callbackJs; + this->destroyed = false; +} + +void TimeoutHandle::destroy() { + if (this->destroyed) { + return; + } + + delete this->callbackJs; + this->destroyed = true; +} + +#include "nbind/nbind.h" + +NBIND_GLOBAL() { + function(setTimeout); + function(clearTimeout); + function(setInterval); + function(clearInterval); +} + +NBIND_CLASS(TimeoutHandle) {} From cc3eaaa226b9dd9e400c0a70a93b21d7a3bd27d1 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sun, 15 Apr 2018 10:10:30 +0200 Subject: [PATCH 136/190] Refactors timer - macOS --- src/arch/darwin/timer.mm | 36 +----------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/src/arch/darwin/timer.mm b/src/arch/darwin/timer.mm index d97e28d..22b0ae9 100644 --- a/src/arch/darwin/timer.mm +++ b/src/arch/darwin/timer.mm @@ -1,29 +1,6 @@ -#include "../../includes/event-loop-darwin.h" +#include "timer.h" #include "nbind/api.h" -class TimeoutHandle { - public: - NSTimer *handle; - nbind::cbFunction *callbackJs; - bool destroyed; - - TimeoutHandle(nbind::cbFunction *callbackJs) { - this->callbackJs = callbackJs; - this->destroyed = false; - } - - void destroy() { - if (this->destroyed) { - return; - } - - delete this->callbackJs; - this->destroyed = true; - } -}; - -#define CALL_JSCB(timeoutHandle) (*(timeoutHandle->callbackJs))() - TimeoutHandle *setTimeout(nbind::cbFunction &cb, unsigned int timeout) { nbind::cbFunction *callbackJs = new nbind::cbFunction(cb); TimeoutHandle *timeoutHandle = new TimeoutHandle(callbackJs); @@ -58,14 +35,3 @@ void clearInterval(TimeoutHandle *timeoutHandle) { [timeoutHandle->handle invalidate]; timeoutHandle->destroy(); } - -#include "nbind/nbind.h" - -NBIND_GLOBAL() { - function(setTimeout); - function(clearTimeout); - function(setInterval); - function(clearInterval); -} - -NBIND_CLASS(TimeoutHandle) {} From 5dbd532b98788c99bb5593050c0218f466cceb30 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sun, 15 Apr 2018 10:32:30 +0200 Subject: [PATCH 137/190] Fix timer header --- src/includes/timer.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/includes/timer.h b/src/includes/timer.h index 3b3815a..287180d 100644 --- a/src/includes/timer.h +++ b/src/includes/timer.h @@ -1,9 +1,23 @@ #ifndef UI_NODE_CONTROL #define UI_NODE_CONTROL 1 +#include "nbind/api.h" + +#ifdef WIN32 +typedef UINT_PTR TIMER_HANDLE; +#endif + +#ifdef __APPLE__ +typedef NSTimer *TIMER_HANDLE; +#endif + +#ifdef __linux__ +typedef unsigned int TIMER_HANDLE; +#endif + class TimeoutHandle { public: - unsigned int handle; + TIMER_HANDLE handle; nbind::cbFunction *callbackJs; bool destroyed; From bcbe5c176b45109884a5a7b3505ed934684b87e1 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sun, 15 Apr 2018 10:50:21 +0200 Subject: [PATCH 138/190] cocoa headers --- src/arch/darwin/timer.mm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/arch/darwin/timer.mm b/src/arch/darwin/timer.mm index 22b0ae9..2f1cef8 100644 --- a/src/arch/darwin/timer.mm +++ b/src/arch/darwin/timer.mm @@ -1,5 +1,7 @@ #include "timer.h" #include "nbind/api.h" +#import +#import TimeoutHandle *setTimeout(nbind::cbFunction &cb, unsigned int timeout) { nbind::cbFunction *callbackJs = new nbind::cbFunction(cb); From 8bdb3e0cc70e4f69e71f454f40e07bdece4a6f54 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sun, 15 Apr 2018 11:03:51 +0200 Subject: [PATCH 139/190] moved includes to header --- src/arch/darwin/timer.mm | 2 -- src/arch/unix/timer.cc | 4 +--- src/includes/timer.h | 5 +++++ 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/arch/darwin/timer.mm b/src/arch/darwin/timer.mm index 2f1cef8..22b0ae9 100644 --- a/src/arch/darwin/timer.mm +++ b/src/arch/darwin/timer.mm @@ -1,7 +1,5 @@ #include "timer.h" #include "nbind/api.h" -#import -#import TimeoutHandle *setTimeout(nbind::cbFunction &cb, unsigned int timeout) { nbind::cbFunction *callbackJs = new nbind::cbFunction(cb); diff --git a/src/arch/unix/timer.cc b/src/arch/unix/timer.cc index 192840a..5b0347d 100644 --- a/src/arch/unix/timer.cc +++ b/src/arch/unix/timer.cc @@ -1,7 +1,5 @@ -#include -#include -#include "nbind/api.h" #include "timer.h" +#include "nbind/api.h" gboolean glib_timeout_cb(TimeoutHandle *timeoutHandle) { CALL_JSCB(timeoutHandle); diff --git a/src/includes/timer.h b/src/includes/timer.h index 287180d..32ce60c 100644 --- a/src/includes/timer.h +++ b/src/includes/timer.h @@ -4,14 +4,19 @@ #include "nbind/api.h" #ifdef WIN32 +#include typedef UINT_PTR TIMER_HANDLE; #endif #ifdef __APPLE__ +#import +#import typedef NSTimer *TIMER_HANDLE; #endif #ifdef __linux__ +#include +#include typedef unsigned int TIMER_HANDLE; #endif From a2abf8861d02b07d7eb78cd4db36d442d035317c Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sun, 15 Apr 2018 11:22:37 +0200 Subject: [PATCH 140/190] Switched to voi* on macOS --- src/arch/darwin/timer.mm | 7 +++++-- src/includes/timer.h | 5 ++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/arch/darwin/timer.mm b/src/arch/darwin/timer.mm index 22b0ae9..43537b6 100644 --- a/src/arch/darwin/timer.mm +++ b/src/arch/darwin/timer.mm @@ -1,5 +1,6 @@ #include "timer.h" #include "nbind/api.h" +#import TimeoutHandle *setTimeout(nbind::cbFunction &cb, unsigned int timeout) { nbind::cbFunction *callbackJs = new nbind::cbFunction(cb); @@ -15,7 +16,8 @@ } void clearTimeout(TimeoutHandle *timeoutHandle) { - [timeoutHandle->handle invalidate]; + NSTimer *handle = (NSTimer *)timeoutHandle->handle; + [handle invalidate]; timeoutHandle->destroy(); } @@ -32,6 +34,7 @@ void clearTimeout(TimeoutHandle *timeoutHandle) { } void clearInterval(TimeoutHandle *timeoutHandle) { - [timeoutHandle->handle invalidate]; + NSTimer *handle = (NSTimer *)timeoutHandle->handle; + [handle invalidate]; timeoutHandle->destroy(); } diff --git a/src/includes/timer.h b/src/includes/timer.h index 32ce60c..40ffc4c 100644 --- a/src/includes/timer.h +++ b/src/includes/timer.h @@ -6,12 +6,11 @@ #ifdef WIN32 #include typedef UINT_PTR TIMER_HANDLE; +extern HWND utilWindow; #endif #ifdef __APPLE__ -#import -#import -typedef NSTimer *TIMER_HANDLE; +typedef void *TIMER_HANDLE; #endif #ifdef __linux__ From e10094ba5421b69acd1cd6611c561a78beb8fa01 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sun, 15 Apr 2018 11:40:36 +0200 Subject: [PATCH 141/190] timer with basic syntax [win32] --- src/arch/win32/timer.cc | 49 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/arch/win32/timer.cc diff --git a/src/arch/win32/timer.cc b/src/arch/win32/timer.cc new file mode 100644 index 0000000..e26a242 --- /dev/null +++ b/src/arch/win32/timer.cc @@ -0,0 +1,49 @@ +#include +#include "nbind/api.h" +#include "timer.h" + +static std::map timersMap; + +void CALLBACK win_timeout_cb(HWND hwnd, UINT uMsg, UINT_PTR idEvent, + DWORD dwTime) { + CALL_JSCB(timeoutHandle); + KillTimer(utilWindow, timeoutHandle->handle); + timersMap.erase(timeoutHandle->handle); + timeoutHandle->destroy(); +} + +void CALLBACK win_interval_cb(HWND hwnd, UINT uMsg, UINT_PTR idEvent, + DWORD dwTime) { + CALL_JSCB(timeoutHandle); +} + +TimeoutHandle *setTimeout(nbind::cbFunction &cb, unsigned int timeout) { + nbind::cbFunction *callbackJs = new nbind::cbFunction(cb); + TimeoutHandle *timeoutHandle = new TimeoutHandle(callbackJs); + timeoutHandle->handle = SetTimer(utilWindow, NULL, timeout, win_timeout_cb); + timersMap[timeoutHandle->handle] = timeoutHandle; + return timeoutHandle; +} + +void clearTimeout(TimeoutHandle *timeoutHandle) { + if (!timeoutHandle->destroyed) { + KillTimer(utilWindow, timeoutHandle->handle); + timersMap.erase(timeoutHandle->handle); + timeoutHandle->destroy(); + } +} + +TimeoutHandle *setInterval(nbind::cbFunction &cb, unsigned int timeout) { + nbind::cbFunction *callbackJs = new nbind::cbFunction(cb); + TimeoutHandle *timeoutHandle = new TimeoutHandle(callbackJs); + timeoutHandle->handle = + SetTimer(utilWindow, NULL, timeout, win_interval_cb); + timersMap[timeoutHandle->handle] = timeoutHandle; + return timeoutHandle; +} + +void clearInterval(TimeoutHandle *timeoutHandle) { + KillTimer(utilWindow, timeoutHandle->handle); + timersMap.erase(timeoutHandle->handle); + timeoutHandle->destroy(); +} From 6dca74e6cd4c41d7b0dafccd7da47ed4c019d08f Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sun, 15 Apr 2018 11:46:39 +0200 Subject: [PATCH 142/190] Read handler from map [win32] --- src/arch/win32/timer.cc | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/arch/win32/timer.cc b/src/arch/win32/timer.cc index e26a242..218331c 100644 --- a/src/arch/win32/timer.cc +++ b/src/arch/win32/timer.cc @@ -4,16 +4,22 @@ static std::map timersMap; -void CALLBACK win_timeout_cb(HWND hwnd, UINT uMsg, UINT_PTR idEvent, - DWORD dwTime) { - CALL_JSCB(timeoutHandle); +void killTimer(TimeoutHandle *timeoutHandle) { KillTimer(utilWindow, timeoutHandle->handle); timersMap.erase(timeoutHandle->handle); timeoutHandle->destroy(); } +void CALLBACK win_timeout_cb(HWND hwnd, UINT uMsg, UINT_PTR idEvent, + DWORD dwTime) { + TimeoutHandle *timeoutHandle = timersMap[idEvent]; + CALL_JSCB(timeoutHandle); + killTimer(timeoutHandle); +} + void CALLBACK win_interval_cb(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) { + TimeoutHandle *timeoutHandle = timersMap[idEvent]; CALL_JSCB(timeoutHandle); } @@ -27,9 +33,7 @@ TimeoutHandle *setTimeout(nbind::cbFunction &cb, unsigned int timeout) { void clearTimeout(TimeoutHandle *timeoutHandle) { if (!timeoutHandle->destroyed) { - KillTimer(utilWindow, timeoutHandle->handle); - timersMap.erase(timeoutHandle->handle); - timeoutHandle->destroy(); + killTimer(timeoutHandle); } } @@ -43,7 +47,5 @@ TimeoutHandle *setInterval(nbind::cbFunction &cb, unsigned int timeout) { } void clearInterval(TimeoutHandle *timeoutHandle) { - KillTimer(utilWindow, timeoutHandle->handle); - timersMap.erase(timeoutHandle->handle); - timeoutHandle->destroy(); + killTimer(timeoutHandle); } From 196ab4903debed1ae631759acfe6dbb031880442 Mon Sep 17 00:00:00 2001 From: andrea parodi Date: Sun, 15 Apr 2018 12:41:23 +0200 Subject: [PATCH 143/190] Fixed timers on Windows by renaming timer-common and using a NULL window. --- src/arch/win32/timer.cc | 8 +++++--- src/includes/timer.h | 1 - src/{timer.cc => timer-common.cc} | 0 3 files changed, 5 insertions(+), 4 deletions(-) rename src/{timer.cc => timer-common.cc} (100%) diff --git a/src/arch/win32/timer.cc b/src/arch/win32/timer.cc index 218331c..c46895c 100644 --- a/src/arch/win32/timer.cc +++ b/src/arch/win32/timer.cc @@ -5,7 +5,7 @@ static std::map timersMap; void killTimer(TimeoutHandle *timeoutHandle) { - KillTimer(utilWindow, timeoutHandle->handle); + KillTimer(NULL, timeoutHandle->handle); timersMap.erase(timeoutHandle->handle); timeoutHandle->destroy(); } @@ -26,7 +26,9 @@ void CALLBACK win_interval_cb(HWND hwnd, UINT uMsg, UINT_PTR idEvent, TimeoutHandle *setTimeout(nbind::cbFunction &cb, unsigned int timeout) { nbind::cbFunction *callbackJs = new nbind::cbFunction(cb); TimeoutHandle *timeoutHandle = new TimeoutHandle(callbackJs); - timeoutHandle->handle = SetTimer(utilWindow, NULL, timeout, win_timeout_cb); + // SetTimer could work with a NULL window. + // https://stackoverflow.com/questions/7531650/can-i-use-a-settimer-api-in-a-console-c-application + timeoutHandle->handle = SetTimer(NULL, NULL, timeout, win_timeout_cb); timersMap[timeoutHandle->handle] = timeoutHandle; return timeoutHandle; } @@ -41,7 +43,7 @@ TimeoutHandle *setInterval(nbind::cbFunction &cb, unsigned int timeout) { nbind::cbFunction *callbackJs = new nbind::cbFunction(cb); TimeoutHandle *timeoutHandle = new TimeoutHandle(callbackJs); timeoutHandle->handle = - SetTimer(utilWindow, NULL, timeout, win_interval_cb); + SetTimer(NULL, NULL, timeout, win_interval_cb); timersMap[timeoutHandle->handle] = timeoutHandle; return timeoutHandle; } diff --git a/src/includes/timer.h b/src/includes/timer.h index 40ffc4c..e3ad408 100644 --- a/src/includes/timer.h +++ b/src/includes/timer.h @@ -6,7 +6,6 @@ #ifdef WIN32 #include typedef UINT_PTR TIMER_HANDLE; -extern HWND utilWindow; #endif #ifdef __APPLE__ diff --git a/src/timer.cc b/src/timer-common.cc similarity index 100% rename from src/timer.cc rename to src/timer-common.cc From e6387d81f64da3477822da86f4d5ae36acc82af6 Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Sun, 15 Apr 2018 12:50:51 +0200 Subject: [PATCH 144/190] Overwrite node's setTimeout --- examples/event-loop.js | 19 ++++++++++--------- index.js | 40 ++++++++++++++++++++++++++++++++++++++++ src/arch/win32/timer.cc | 3 +-- src/timer-common.cc | 2 +- 4 files changed, 52 insertions(+), 12 deletions(-) diff --git a/examples/event-loop.js b/examples/event-loop.js index dca759c..25d8695 100644 --- a/examples/event-loop.js +++ b/examples/event-loop.js @@ -32,6 +32,7 @@ win.onClosing(() => { } win.close(); libui.stopLoop(); + setTimeout(() => console.log('after stopLoop'), 100); }); win.show(); @@ -96,15 +97,15 @@ function makeToolbar() { const btnCustom = new libui.UiButton('Custom setTimeout'); btnCustom.onClicked(() => { const now = Date.now(); - const longTimeout = libui.setTimeout(() => { + const longTimeout = setTimeout((a, b, c) => { logAppend(`THIS HOULD NOT HAPPEN!`); }, 200); - libui.setTimeout(() => { - libui.clearTimeout(longTimeout); + setTimeout((a, b, c) => { + clearTimeout(longTimeout); const elapsed = Date.now() - now; - logAppend(`Custom setTimeout: ${now} - elapsed ${elapsed} ms`); - }, 10); + logAppend(`Custom setTimeout: ${now} - elapsed ${elapsed} ms. Args: ${a} ${b} ${c}`); + }, 10, 'custom', 'args', 2); }); toolbar.append(btnCustom, false); @@ -112,16 +113,16 @@ function makeToolbar() { let intervalHandler = null; btnCustomSetInterval.onClicked(() => { if (intervalHandler) { - libui.clearInterval(intervalHandler); + clearInterval(intervalHandler); intervalHandler = null; return; } let now = Date.now(); - intervalHandler = libui.setInterval(() => { + intervalHandler = setInterval((a, b, c) => { const elapsed = Date.now() - now; - logAppend(`Custom setInterval: ${now} - elapsed ${elapsed} ms`); + logAppend(`Custom setInterval: ${now} - elapsed ${elapsed} ms. Args: ${a} ${b} ${c}`); now = Date.now(); - }, 10); + }, 50, 'my', 'args', 2); }); toolbar.append(btnCustomSetInterval, false); diff --git a/index.js b/index.js index 5d15e9c..fe09025 100644 --- a/index.js +++ b/index.js @@ -6,12 +6,52 @@ module.exports = binding.lib; binding.lib.Ui.init(); +var setTimeoutNode; +var clearTimeoutNode; +var setIntervalNode; +var clearIntervalNode; + function stopLoop() { binding.lib.EventLoop.stop(); + + if (setTimeoutNode) + global.setTimeout = setTimeoutNode; + if (clearTimeoutNode) + global.clearTimeout = clearTimeoutNode; + if (setIntervalNode) + global.setInterval = setIntervalNode; + if (clearIntervalNode) + global.clearInterval = clearIntervalNode; } function startLoop() { binding.lib.EventLoop.start(); + + if (!setTimeoutNode) + setTimeoutNode = global.setTimeout; + global.setTimeout = function(cb, t) { + const args = Array.prototype.slice.call(arguments, 2); + return binding.lib.setTimeout(function() { + cb.apply(null, args); + }, t); + }; + + if (!clearTimeoutNode) + clearTimeoutNode = global.clearTimeout; + global.clearTimeout = binding.lib.clearTimeout; + + if (!setIntervalNode) + setIntervalNode = global.setInterval; + global.setInterval = function(cb, t) { + const args = Array.prototype.slice.call(arguments, 2); + return binding.lib.setInterval(function() { + cb.apply(null, args); + }, t); + }; + + if (!clearIntervalNode) + clearIntervalNode = global.clearInterval; + global.clearInterval = binding.lib.clearInterval; } function Color(r, g, b, a) { diff --git a/src/arch/win32/timer.cc b/src/arch/win32/timer.cc index c46895c..af8fd90 100644 --- a/src/arch/win32/timer.cc +++ b/src/arch/win32/timer.cc @@ -42,8 +42,7 @@ void clearTimeout(TimeoutHandle *timeoutHandle) { TimeoutHandle *setInterval(nbind::cbFunction &cb, unsigned int timeout) { nbind::cbFunction *callbackJs = new nbind::cbFunction(cb); TimeoutHandle *timeoutHandle = new TimeoutHandle(callbackJs); - timeoutHandle->handle = - SetTimer(NULL, NULL, timeout, win_interval_cb); + timeoutHandle->handle = SetTimer(NULL, NULL, timeout, win_interval_cb); timersMap[timeoutHandle->handle] = timeoutHandle; return timeoutHandle; } diff --git a/src/timer-common.cc b/src/timer-common.cc index d150000..1bf5954 100644 --- a/src/timer-common.cc +++ b/src/timer-common.cc @@ -1,5 +1,5 @@ -#include "timer.h" #include "nbind/api.h" +#include "timer.h" TimeoutHandle::TimeoutHandle(nbind::cbFunction *callbackJs) { this->callbackJs = callbackJs; From 5448fea3ef5717aaed0b0341c97be3e5c114757e Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sun, 15 Apr 2018 15:02:40 +0200 Subject: [PATCH 145/190] Forgotten {} --- index.js | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/index.js b/index.js index fe09025..45c6266 100644 --- a/index.js +++ b/index.js @@ -27,31 +27,35 @@ function stopLoop() { function startLoop() { binding.lib.EventLoop.start(); - if (!setTimeoutNode) + if (!setTimeoutNode) { setTimeoutNode = global.setTimeout; - global.setTimeout = function(cb, t) { - const args = Array.prototype.slice.call(arguments, 2); - return binding.lib.setTimeout(function() { - cb.apply(null, args); - }, t); - }; - - if (!clearTimeoutNode) + global.setTimeout = function(cb, t) { + const args = Array.prototype.slice.call(arguments, 2); + return binding.lib.setTimeout(function() { + cb.apply(null, args); + }, t); + }; + } + + if (!clearTimeoutNode) { clearTimeoutNode = global.clearTimeout; - global.clearTimeout = binding.lib.clearTimeout; + global.clearTimeout = binding.lib.clearTimeout; + } - if (!setIntervalNode) + if (!setIntervalNode) { setIntervalNode = global.setInterval; - global.setInterval = function(cb, t) { - const args = Array.prototype.slice.call(arguments, 2); - return binding.lib.setInterval(function() { - cb.apply(null, args); - }, t); - }; - - if (!clearIntervalNode) + global.setInterval = function(cb, t) { + const args = Array.prototype.slice.call(arguments, 2); + return binding.lib.setInterval(function() { + cb.apply(null, args); + }, t); + }; + } + + if (!clearIntervalNode) { clearIntervalNode = global.clearInterval; - global.clearInterval = binding.lib.clearInterval; + global.clearInterval = binding.lib.clearInterval; + } } function Color(r, g, b, a) { From d96e3f107e4cc1ee9685118143c662a0a6306df1 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sun, 15 Apr 2018 13:12:49 +0200 Subject: [PATCH 146/190] Fix global timers fn patching --- index.js | 71 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/index.js b/index.js index 45c6266..f78b883 100644 --- a/index.js +++ b/index.js @@ -14,48 +14,49 @@ var clearIntervalNode; function stopLoop() { binding.lib.EventLoop.stop(); - if (setTimeoutNode) - global.setTimeout = setTimeoutNode; - if (clearTimeoutNode) - global.clearTimeout = clearTimeoutNode; - if (setIntervalNode) - global.setInterval = setIntervalNode; - if (clearIntervalNode) - global.clearInterval = clearIntervalNode; + if (!setTimeoutNode) { + return; + } + + global.setTimeout = setTimeoutNode; + global.clearTimeout = clearTimeoutNode; + global.setInterval = setIntervalNode; + global.clearInterval = clearIntervalNode; + + setTimeoutNode = null; + clearTimeoutNode = null; + setIntervalNode = null; + clearIntervalNode = null; } function startLoop() { binding.lib.EventLoop.start(); - if (!setTimeoutNode) { - setTimeoutNode = global.setTimeout; - global.setTimeout = function(cb, t) { - const args = Array.prototype.slice.call(arguments, 2); - return binding.lib.setTimeout(function() { - cb.apply(null, args); - }, t); - }; - } - - if (!clearTimeoutNode) { - clearTimeoutNode = global.clearTimeout; - global.clearTimeout = binding.lib.clearTimeout; + if (setTimeoutNode) { + return; } - if (!setIntervalNode) { - setIntervalNode = global.setInterval; - global.setInterval = function(cb, t) { - const args = Array.prototype.slice.call(arguments, 2); - return binding.lib.setInterval(function() { - cb.apply(null, args); - }, t); - }; - } - - if (!clearIntervalNode) { - clearIntervalNode = global.clearInterval; - global.clearInterval = binding.lib.clearInterval; - } + setTimeoutNode = global.setTimeout; + global.setTimeout = function(cb, t) { + const args = Array.prototype.slice.call(arguments, 2); + return binding.lib.setTimeout(function() { + cb.apply(null, args); + }, t); + }; + + clearTimeoutNode = global.clearTimeout; + global.clearTimeout = binding.lib.clearTimeout; + + setIntervalNode = global.setInterval; + global.setInterval = function(cb, t) { + const args = Array.prototype.slice.call(arguments, 2); + return binding.lib.setInterval(function() { + cb.apply(null, args); + }, t); + }; + + clearIntervalNode = global.clearInterval; + global.clearInterval = binding.lib.clearInterval; } function Color(r, g, b, a) { From 46f7907f45090d37af6d3df6054edecb2ec388f4 Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Sun, 15 Apr 2018 14:11:17 +0200 Subject: [PATCH 147/190] Fix OpenTypeFeatures:clone, docs --- docs/area.md | 2 +- docs/attributedstring.md | 188 +++++++++++++++++++++++++---------- src/Font/OpenTypeFeatures.cc | 9 +- src/ui-node.h | 1 + 4 files changed, 143 insertions(+), 57 deletions(-) diff --git a/docs/area.md b/docs/area.md index ac8cc7b..223225e 100644 --- a/docs/area.md +++ b/docs/area.md @@ -192,7 +192,7 @@ Draws a given text at the given (x,y) position. * x: Number - the horizontal position at which to draw the text. * y: Number - the vertical position at which to draw the text. -* layout: DrawTextLayout (see [AttributedString](Attributedstring.md)) - the text to draw, complete with font, width and alignment information. +* layout: DrawTextLayout (see [AttributedString](attributedstring.md#drawtextlayout)) - the text to draw, complete with font, width and alignment information. # UiDrawPath diff --git a/docs/attributedstring.md b/docs/attributedstring.md index db609f9..25d9d6e 100644 --- a/docs/attributedstring.md +++ b/docs/attributedstring.md @@ -1,20 +1,25 @@ # AttributedString ```cpp -class OpenTypeFeatures { - public: - OpenTypeFeatures(); +class AttributedString { + AttributedString(const char *str); void free(); + const char * toString(); + size_t toStringLen(); - static OpenTypeFeatures clone(OpenTypeFeatures *f2); - void add(const char *tag, uint32_t value); - void remove(const char *tag); + void appendUnattributed(const char *str); + void insertUnattributed(const char *str, size_t at); + void deleteString(size_t start, size_t end); + void setAttribute(FontAttribute *attr, size_t start, size_t end); - // value or `null` if not set - get(const char *tag); + void appendAttributed(const char *str, FontAttribute *attr); + void appendAttributed(const char *str, FontAttribute *attr, FontAttribute *attr2); - // cb(OpenTypeFeatures, tag, value) void forEach(nbind::cbFunction& cb); + + size_t numGraphemes(); + size_t byteIndexToGrapheme(size_t pos); + size_t graphemeToByteIndex(size_t pos); }; class FontAttribute { @@ -46,50 +51,134 @@ class FontAttribute { static FontAttribute newOTFeatures(OpenTypeFeatures *otf); }; + // cb(OpenTypeFeatures, tag, value) + void forEach(nbind::cbFunction& cb); +}; -class AttributedString { - AttributedString(const char *str); - void free(); - const char * toString(); - size_t toStringLen(); +``` - void appendUnattributed(const char *str); - void insertUnattributed(const char *str, size_t at); - void deleteString(size_t start, size_t end); - void setAttribute(FontAttribute *attr, size_t start, size_t end); +# Classes - void appendAttributed(const char *str, FontAttribute *attr); - void appendAttributed(const char *str, FontAttribute *attr, FontAttribute *attr2); +--- - void forEach(nbind::cbFunction& cb); +# OpenTypeFeatures - size_t numGraphemes(); - size_t byteIndexToGrapheme(size_t pos); - size_t graphemeToByteIndex(size_t pos); -}; +Defines font glyph settings (if supported by the font). -class FontDescriptor { - FontDescriptor(const char *family, double size, int weight, int italic, int stretch); - void free(); - char *getFamily(); - double getSize(); - int getWeight(); - int getItalic(); - int getStretch(); - uiFontDescriptor *getHandle(); -}; +See [here](https://docs.microsoft.com/de-de/typography/opentype/spec/featuretags) for more information and a list of feature tags. +Example: Setting `liga` to `1` enables ligatures (not supported by every font): -class DrawTextLayout { - public: - DrawTextLayout(AttributedString *s, FontDescriptor *defaultFont, double width, int align); - void free(); - SizeDouble getExtents(); - uiDrawTextLayout* getHandle(); -}; +```js +const otf = new libui.OpenTypeFeatures(); +otf.add('liga', 1) + +str.appendAttributed('affix', FontAttribute.newOTFeatures(otf)); ``` -for drawing: see Area: `UiDrawContext.text` + +## Static Functions + +### clone + +Returns a new object containg all tags from f2. + +**Arguments** + +* f2: OpenTypeFeatures + +## Methods + +### add + +Adds/overwrites a `tag` with `value`. + +**Arguments** + +* tag: String +* value: Number + + +### remove + +Remove a tag (and use the default). + +**Arguments** + +* tag: String + +### get + +Returns the value of `tag` or `null` if not set. + +**Arguments** + +* tag: String + +### forEach + +Iterates over all tags. Return `libui.forEach.stop` in the callback to break. + +**Arguments** + +* cb: `function(OpenTypeFeatures, tag, value)` + +### free + +Frees the object immediately. + +# FontDescriptor + +Defines a font. + +## Constructor + +**Arguments** + +* family: String +* size: Number +* weight: +* italic: +* stretch: + +## Methods + +### getFamily +### getSize +### getWeight +### getItalic +### getStretch + +### free + +Frees the object immediately. + +# DrawTextLayout + +Defines how an attributed string should get drawn onto an area. (See [Area UiDrawContext.text](area.md#text)) + +## Constructor + +**Arguments** + +* str: [AttributedString](#attributedstring) +* defaultFont: [FontDescriptor](#fontdescriptor) +* width: Number (i.e. `params.getAreaWidth()`) +* align: + - `libui.textAlign.left` + - `libui.textAlign.center` + - `libui.textAlign.right` + + +## Methods + +### getExtends + +Returns a [SizeDouble](size.md) containing the actual width and height of the text. + +### free + +Frees the object immediately. ```js @@ -153,15 +242,4 @@ libui.textUnderlineColor = { grammar: 2, auxiliary: 3 }; - -libui.textAlign = { - left: 0, - center: 1, - right: 2 -}; - -libui.forEach = { - continue: 0, - stop: 1 -}; -``` \ No newline at end of file +``` diff --git a/src/Font/OpenTypeFeatures.cc b/src/Font/OpenTypeFeatures.cc index 64ba537..83c4731 100644 --- a/src/Font/OpenTypeFeatures.cc +++ b/src/Font/OpenTypeFeatures.cc @@ -2,6 +2,11 @@ #include "../ui-node.h" #include "nbind/nbind.h" +OpenTypeFeatures::OpenTypeFeatures(OpenTypeFeatures&& other) { + f = other.f; + other.f = nullptr; +} + OpenTypeFeatures::OpenTypeFeatures(uiOpenTypeFeatures *feat) { f = feat; } @@ -11,7 +16,9 @@ OpenTypeFeatures::OpenTypeFeatures() { } OpenTypeFeatures::~OpenTypeFeatures() { - uiFreeOpenTypeFeatures(f); + if(f != nullptr){ + uiFreeOpenTypeFeatures(f); + } } uiOpenTypeFeatures *OpenTypeFeatures::getHandle() { diff --git a/src/ui-node.h b/src/ui-node.h index bf350b7..a4c1c57 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -640,6 +640,7 @@ class OpenTypeFeatures { uiOpenTypeFeatures *f; public: OpenTypeFeatures(); + OpenTypeFeatures(OpenTypeFeatures&& other); OpenTypeFeatures(uiOpenTypeFeatures *feat); ~OpenTypeFeatures(); uiOpenTypeFeatures *getHandle(); From 396875dc09fc89887a700086f1e891dc00e99174 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sun, 15 Apr 2018 14:22:50 +0200 Subject: [PATCH 148/190] onShouldQuit exposed directly, new init example, and docs --- docs/initialization.md | 60 +++++++++++++++----------------------- examples/initialization.js | 20 +++++++++++++ index.js | 1 + 3 files changed, 44 insertions(+), 37 deletions(-) create mode 100644 examples/initialization.js diff --git a/docs/initialization.md b/docs/initialization.md index 1d1828e..5936da5 100644 --- a/docs/initialization.md +++ b/docs/initialization.md @@ -1,53 +1,39 @@ # Event loop -`libui-node` has an event loop independent of the Node.js one that take care of processing GUI events. It process events one tick at a time, so it can run seamlessy with Node.js loop. +`libui-node` run an event loop independent of that of Node.js that takes care of processing GUI events. This event loop can run seamlessy together with the Node.js one, so you can still use any asynchronous Node.js method. -Each bit of GUI event loop is executed by a call to `libui.Ui.mainStep` method. This method could be used directly by your code, or you can leverage the `startLoop` event that continuosly schedules calls to `mainStep` using Node.js `setImmediate` function. +You are responsible to start and stop the loop, by calling the `startLoop` and `stopLoop` methods. +The `startLoop` return immediately after it start the event loop, but it keeps +a Node.js handle active, so it prevents your process to terminate, until +you call `stopLoop` later. -## Start the event loop - -To start the event loop, you simply call the `startLoop` method. The function return immediately, and optionally accept a callback arguments that is called when `libui-node` event loop terminates. - - -```js -var libui = require('libui'); - -libui.startLoop(function () { - console.log('event loop terminated.'); -}); -``` +# Quit handler -## Stop the event loop +`libui.Ui.onShouldQuit` method allow you to register a callback that is called when a "Quit" menu item is clicked. You are responsible to terminate the application in response to this event, usually by just calling `stopLoop` method. -To stop the event loop, you simply call the `stopLoop` method. The function return immediately. +# Example ```js -libui.stopLoop(); -``` - -## Main method - -The `main` method is an alternative way to start GUI event loop. It defers event loop execution to the underlyng native GUI framework. - -This is a blocking call, so Node.js event loop is stopped until `libui-node` event loop terminate. -This mean that your GUI events callbacks are executed because they are called by the native GUI event loop, but Node.js callbacks doesn't. +const { + UiWindow, + UiMenu, + startLoop, + stopLoop, + onShouldQuit +} = require('libui'); -To stop the loop and allow `main` method to return, you have to call `libui.Ui.quit` method. -# Quit handler - -`libui.Ui.onShouldQuit` is emitted when "Quit" was clicked in the menu. You are responsible to close the application in response to this event: - -```js -var libui = require('libui'); +const menu = new UiMenu('File'); +menu.appendQuitItem(); -var window = libui.UiWindow(title, width, height, hasMenubar); +const window = UiWindow('Initialization Example', 400, 300, true); -libui.Ui.onShouldQuit(() => { - window.close(); - libui.stopLoop(); +onShouldQuit(() => { + window.close(); + stopLoop(); }); -//... +window.show(); +startLoop(); ``` diff --git a/examples/initialization.js b/examples/initialization.js new file mode 100644 index 0000000..01a5a8b --- /dev/null +++ b/examples/initialization.js @@ -0,0 +1,20 @@ +const { + UiWindow, + UiMenu, + startLoop, + stopLoop, + onShouldQuit +} = require('..'); + +const menu = new UiMenu('File'); +menu.appendQuitItem(); + +const window = UiWindow('Initialization Example', 400, 300, true); + +onShouldQuit(() => { + window.close(); + stopLoop(); +}); + +window.show(); +startLoop(); diff --git a/index.js b/index.js index f78b883..1fb578e 100644 --- a/index.js +++ b/index.js @@ -256,3 +256,4 @@ module.exports.modifierKeys = modifierKeys; module.exports.extKeys = extKeys; module.exports.startLoop = startLoop; module.exports.stopLoop = stopLoop; +module.exports.onShouldQuit = binding.lib.Ui.onShouldQuit; From b063ecafeaf872667e8b7e26566fb24e5d4cde5b Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Sun, 15 Apr 2018 14:53:33 +0200 Subject: [PATCH 149/190] Rewording --- docs/initialization.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/initialization.md b/docs/initialization.md index 5936da5..893d21b 100644 --- a/docs/initialization.md +++ b/docs/initialization.md @@ -1,16 +1,16 @@ # Event loop -`libui-node` run an event loop independent of that of Node.js that takes care of processing GUI events. This event loop can run seamlessy together with the Node.js one, so you can still use any asynchronous Node.js method. +`libui-node` runs an event loop independent of that of Node.js that takes care of processing GUI events. This event loop can run seamlessy together with the Node.js one, so you can still use any asynchronous Node.js function. -You are responsible to start and stop the loop, by calling the `startLoop` and `stopLoop` methods. +You are responsible to start and stop the loop, by calling the `startLoop` and `stopLoop` functions. -The `startLoop` return immediately after it start the event loop, but it keeps +`startLoop` returns immediately after it started the event loop. It keeps a Node.js handle active, so it prevents your process to terminate, until you call `stopLoop` later. # Quit handler -`libui.Ui.onShouldQuit` method allow you to register a callback that is called when a "Quit" menu item is clicked. You are responsible to terminate the application in response to this event, usually by just calling `stopLoop` method. +The `onShouldQuit` function allows you to register a callback that is called when a "Quit" menu item is clicked. You are responsible to terminate the application in response to this event, usually by calling `stopLoop` method. # Example From 4da95ab09e7782393119913f453cb4689f6f4fae Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Sun, 15 Apr 2018 14:59:07 +0200 Subject: [PATCH 150/190] newBackground_Color_, docs --- docs/attributedstring.md | 247 +++++++++++++++++++++++++------------- examples/text.js | 10 +- src/Font/FontAttribute.cc | 4 +- src/ui-node.h | 2 +- 4 files changed, 172 insertions(+), 91 deletions(-) diff --git a/docs/attributedstring.md b/docs/attributedstring.md index 25d9d6e..e358c3f 100644 --- a/docs/attributedstring.md +++ b/docs/attributedstring.md @@ -24,10 +24,6 @@ class AttributedString { class FontAttribute { public: - // doesn't need to be called when appended - void free(); - int getAttributeType(); - // It is an error to call this on a uiAttribute that does not hold the corresponding type const char *getFamily(); double getSize(); @@ -38,21 +34,6 @@ class FontAttribute { int getUnderline(); int getUnderlineColor(Color *c); OpenTypeFeatures *getOTFeatures(); - - static FontAttribute newFamily(const char *family); - static FontAttribute newSize(double size); - static FontAttribute newWeight(int weightAttribute); - static FontAttribute newItalic(int italicAttribute); - static FontAttribute newStretch(int stretchAttribute); - static FontAttribute newColor(Color c); - static FontAttribute newBackground(Color c); - static FontAttribute newUnderline(int underlineAttr); - static FontAttribute newUnderlineColor(int underlineColorAttr, Color c); - static FontAttribute newOTFeatures(OpenTypeFeatures *otf); -}; - - // cb(OpenTypeFeatures, tag, value) - void forEach(nbind::cbFunction& cb); }; ``` @@ -61,9 +42,169 @@ class FontAttribute { --- +# AttributedString + +## Constructor + +## Methods + +### forEach + +Iterates over all tags. Return `libui.forEach.stop` in the callback to break. + +**Arguments** + +* cb: `function(OpenTypeFeatures, tag, value)` + + +# FontAttribute + +not every font supports every style + + +## Static Functions + +### newFamily + +Returns a new FontAttribute for the font `family`. + +**Arguments** + +* family: String + +### newSize + +Returns a new FontAttribute for the font size `size`. + +**Arguments** + +* size: Number + +### newWeight(int weightAttribute) + +Returns a new FontAttribute for the font weight `weight`. + +**Arguments** + +* weight: Number. Possible values: + * `libui.textWeight.minimum` + * `libui.textWeight.thin` + * `libui.textWeight.ultraLight` + * `libui.textWeight.light` + * `libui.textWeight.book` + * `libui.textWeight.normal` + * `libui.textWeight.medium` + * `libui.textWeight.semiBold` + * `libui.textWeight.bold` + * `libui.textWeight.ultraBold` + * `libui.textWeight.heavy` + * `libui.textWeight.ultraHeavy` + * `libui.textWeight.maximum` + * any number between `minimum` and `maximum` + +### newItalic + +Returns a new FontAttribute for the italic style `style`. + +**Arguments** + +* style: + * `libui.textItalic.normal` + * `libui.textItalic.oblique` ("slanted version of normal") + * `libui.textItalic.italic` ("true italics") + +### newStretch + +Returns a new FontAttribute for the stretch (or width) style `style`. + +**Arguments** + +* style: + * `libui.textStretch.ultraCondensed` + * `libui.textStretch.extraCondensed` + * `libui.textStretch.condensed` + * `libui.textStretch.semiCondensed` + * `libui.textStretch.normal` + * `libui.textStretch.semiExpanded` + * `libui.textStretch.expanded` + * `libui.textStretch.extraExpanded` + * `libui.textStretch.ultraExpanded` + +### newColor + +Returns a new FontAttribute for the text color `color`. + +**Arguments** + +* color: Color + +### newBackgroundColor + +Returns a new FontAttribute for the background color `color`. + +**Arguments** + +* color: Color + +### newUnderline + +Returns a new FontAttribute for the underline style `style`. + +**Arguments** + +* style: + * `libui.textUnderline.none` + * `libui.textUnderline.single` + * `libui.textUnderline.double` + * `libui.textUnderline.suggestion` + +### newUnderlineColor + +Returns a new FontAttribute for the underline color. + +**Arguments** + +* colorAttr: + * `libui.textUnderlineColor.custom` + * `libui.textUnderlineColor.spelling` + * `libui.textUnderlineColor.grammar` + * `libui.textUnderlineColor.auxiliary` +* color: Color (required only with `textUnderlineColor.custom`) + +### newOTFeatures(OpenTypeFeatures *otf); + +Returns a new FontAttribute with the OpenTypeFeatures `otf`. + +**Arguments** + +* otf: [OpenTypeFeatures](#opentypefeatures) + + +## Methods + +### getAttributeType + +Returns the type of the attribute. Possible values: + +* `libui.textAttributeType.family` +* `libui.textAttributeType.size` +* `libui.textAttributeType.weight` +* `libui.textAttributeType.italic` +* `libui.textAttributeType.stretch` +* `libui.textAttributeType.color` +* `libui.textAttributeType.background` +* `libui.textAttributeType.underline` +* `libui.textAttributeType.underlineColor` +* `libui.textAttributeType.features` + + +### free + +Frees the object immediately. + # OpenTypeFeatures -Defines font glyph settings (if supported by the font). +Defines font glyph settings (ignored if not supported by the font). See [here](https://docs.microsoft.com/de-de/typography/opentype/spec/featuretags) for more information and a list of feature tags. @@ -174,72 +315,8 @@ Defines how an attributed string should get drawn onto an area. (See [Area UiDra ### getExtends -Returns a [SizeDouble](size.md) containing the actual width and height of the text. +Returns a SizeDouble containing the actual width and height of the text. ### free Frees the object immediately. - - -```js -libui.textWeight = { - minimum: 0, - thin: 100, - ultraLight: 200, - light: 300, - book: 350, - normal: 400, - medium: 500, - semiBold: 600, - bold: 700, - ultraBold: 800, - heavy: 900, - ultraHeavy: 950, - maximum: 1000 -}; - -libui.textItalic = { - normal: 0, - oblique: 1, - italic: 2 -}; - -libui.textStretch = { - ultraCondensed: 0, - extraCondensed: 1, - condensed: 2, - semiCondensed: 3, - normal: 4, - semiExpanded: 5, - expanded: 6, - extraExpanded: 7, - ultraExpanded: 8 -}; - -libui.textAttributeType = { - family: 0, - size: 1, - weight: 2, - italic: 3, - stretch: 4, - color: 5, - background: 6, - underline: 7, - underlineColor: 8, - features: 9 -}; - -libui.textUnderline = { - none: 0, - single: 1, - double: 2, - suggestion: 3 -}; - -libui.textUnderlineColor = { - custom: 0, - spelling: 1, - grammar: 2, - auxiliary: 3 -}; -``` diff --git a/examples/text.js b/examples/text.js index ab73a64..7bcdfb6 100644 --- a/examples/text.js +++ b/examples/text.js @@ -14,7 +14,11 @@ const str = new libui.AttributedString( '👨🏻 Drawing strings with libui is done with the uiAttributedString and uiDrawTextLayout objects.\n' + 'uiAttributedString lets you have a variety of attributes: '); -str.setAttribute(FontAttribute.newBackground(new libui.Color(0, 0, 1, 1)), 0, Buffer.from('👨🏻').length); +str.setAttribute(FontAttribute.newBackgroundColor(new libui.Color(0, 0, 1, 1)), 0, Buffer.from('👨🏻').length); + +const a = FontAttribute.newSize(18); +console.log(a.getItalic()); +console.log(a.getFamily()); str.appendAttributed('font family', FontAttribute.newFamily('Courier New')); str.appendUnattributed(', '); @@ -38,7 +42,7 @@ str.appendUnattributed(', '); str.appendAttributed('text color', FontAttribute.newColor(new libui.Color(0.75, 0.25, 0.5, 0.75))); str.appendUnattributed(', '); -str.appendAttributed('text background color', FontAttribute.newBackground(new libui.Color(0.5, 0.5, 0.25, 0.5))); +str.appendAttributed('text background color', FontAttribute.newBackgroundColor(new libui.Color(0.5, 0.5, 0.25, 0.5))); str.appendUnattributed(', '); str.appendAttributed('underline style', FontAttribute.newUnderline(libui.textUnderline.single)); @@ -80,7 +84,7 @@ otf.free(); str.appendUnattributed(').\n'); str.appendUnattributed('Use the controls opposite to the text to control properties of the text.\n'); -str.appendAttributed('👨🏾', FontAttribute.newBackground(new libui.Color(0, 1, 0, 1))); +str.appendAttributed('👨🏾', FontAttribute.newBackgroundColor(new libui.Color(0, 1, 0, 1))); function handlerDraw(area, p) { const font = checkbox.checked ? diff --git a/src/Font/FontAttribute.cc b/src/Font/FontAttribute.cc index f69da75..572dee1 100644 --- a/src/Font/FontAttribute.cc +++ b/src/Font/FontAttribute.cc @@ -115,7 +115,7 @@ FontAttribute FontAttribute::newColor(Color c) { return FontAttribute(uiNewColorAttribute(c.getR(), c.getG(), c.getB(), c.getA())); } -FontAttribute FontAttribute::newBackground(Color c) { +FontAttribute FontAttribute::newBackgroundColor(Color c) { return FontAttribute(uiNewBackgroundAttribute(c.getR(), c.getG(), c.getB(), c.getA())); } @@ -150,7 +150,7 @@ NBIND_CLASS(FontAttribute) { method(newItalic); method(newStretch); method(newColor); - method(newBackground); + method(newBackgroundColor); method(newUnderline); method(newUnderlineColor2); method(newOTFeatures); diff --git a/src/ui-node.h b/src/ui-node.h index a4c1c57..84723aa 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -685,7 +685,7 @@ class FontAttribute { static FontAttribute newItalic(int italicAttribute); static FontAttribute newStretch(int stretchAttribute); static FontAttribute newColor(Color c); - static FontAttribute newBackground(Color c); + static FontAttribute newBackgroundColor(Color c); static FontAttribute newUnderline(int underlineAttr); static FontAttribute newUnderlineColor2(int underlineColorAttr, Color c); static FontAttribute newOTFeatures(OpenTypeFeatures *otf); From 7812613b5200f1a8f7a2c813eaab7173f19c9930 Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Sun, 15 Apr 2018 15:31:40 +0200 Subject: [PATCH 151/190] Guard FontAttribute.get... --- docs/attributedstring.md | 5 +-- examples/text.js | 4 --- index.js | 67 +++++++++++++++++++++++++++++++++++- src/Font/FontAttribute.cc | 41 ++++++++++------------ src/Font/OpenTypeFeatures.cc | 1 + src/ui-node.h | 20 +++++------ 6 files changed, 98 insertions(+), 40 deletions(-) diff --git a/docs/attributedstring.md b/docs/attributedstring.md index e358c3f..11c5722 100644 --- a/docs/attributedstring.md +++ b/docs/attributedstring.md @@ -24,7 +24,6 @@ class AttributedString { class FontAttribute { public: - // It is an error to call this on a uiAttribute that does not hold the corresponding type const char *getFamily(); double getSize(); int getWeight(); @@ -32,7 +31,9 @@ class FontAttribute { int getStretch(); Color getColor(); int getUnderline(); - int getUnderlineColor(Color *c); + getUnderlineColor(); + // { type: 0, color: Color { r: 1, g: 0, b: 0, a: 1 } } + // { type: 1, color: null } OpenTypeFeatures *getOTFeatures(); }; diff --git a/examples/text.js b/examples/text.js index 7bcdfb6..8a959cf 100644 --- a/examples/text.js +++ b/examples/text.js @@ -16,10 +16,6 @@ const str = new libui.AttributedString( str.setAttribute(FontAttribute.newBackgroundColor(new libui.Color(0, 0, 1, 1)), 0, Buffer.from('👨🏻').length); -const a = FontAttribute.newSize(18); -console.log(a.getItalic()); -console.log(a.getFamily()); - str.appendAttributed('font family', FontAttribute.newFamily('Courier New')); str.appendUnattributed(', '); diff --git a/index.js b/index.js index c95b657..638eff1 100755 --- a/index.js +++ b/index.js @@ -158,7 +158,7 @@ binding.lib.AttributedString.prototype.appendAttributed = function (str, attr, a binding.lib.FontAttribute.newUnderlineColor = function (type, color) { if (type === textUnderlineColor.custom && !color) { - console.error('With textUnderlineColor.custom a color needs to passed'); + console.error('With textUnderlineColor.custom, a color needs to passed'); } color = color || new Color(0, 0, 0, 0); return binding.lib.FontAttribute.newUnderlineColor2(type, color); @@ -172,6 +172,71 @@ binding.lib.OpenTypeFeatures.prototype.get = function (str) { return null; }; +binding.lib.FontAttribute.prototype.getFamily = function () { + if(this.getAttributeType() !== textAttributeType.family) { + return null; + } + return this.getFamilyInternal(); +}; + +binding.lib.FontAttribute.prototype.getSize = function () { + if(this.getAttributeType() !== textAttributeType.size) { + return null; + } + return this.getSizeInternal(); +}; + +binding.lib.FontAttribute.prototype.getWeight = function () { + if(this.getAttributeType() !== textAttributeType.weight) { + return null; + } + return this.getWeightInternal(); +}; + +binding.lib.FontAttribute.prototype.getItalic = function () { + if(this.getAttributeType() !== textAttributeType.italic) { + return null; + } + return this.getItalicInternal(); +}; + +binding.lib.FontAttribute.prototype.getStretch = function () { + if(this.getAttributeType() !== textAttributeType.stretch) { + return null; + } + return this.getStretchInternal(); +}; + +binding.lib.FontAttribute.prototype.getColor = function () { + if(this.getAttributeType() !== textAttributeType.color) { + return null; + } + return this.getColorInternal(); +}; + +binding.lib.FontAttribute.prototype.getUnderline = function () { + if(this.getAttributeType() !== textAttributeType.underline) { + return null; + } + return this.getUnderlineInternal(); +}; + +binding.lib.FontAttribute.prototype.getUnderlineColor = function () { + if(this.getAttributeType() !== textAttributeType.underlineColor) { + return null; + } + const v = this.getUnderlineColorInternal(); + const type = Math.round(v[1].r); + return {type: type, color: type == textUnderlineColor.custom ? v[0] : null}; +}; + +binding.lib.FontAttribute.prototype.getOTFeatures = function () { + if(this.getAttributeType() !== textAttributeType.features) { + return null; + } + return this.getOTFeaturesInternal(); +}; + module.exports.textWeight = textWeight; module.exports.textItalic = textItalic; module.exports.textStretch = textStretch; diff --git a/src/Font/FontAttribute.cc b/src/Font/FontAttribute.cc index 572dee1..8bd6ac1 100644 --- a/src/Font/FontAttribute.cc +++ b/src/Font/FontAttribute.cc @@ -1,3 +1,4 @@ +#include #include "../../ui.h" #include "../ui-node.h" #include "nbind/nbind.h" @@ -34,27 +35,27 @@ void FontAttribute::setAppended(){ appended = 1; } -const char *FontAttribute::getFamily() { +const char *FontAttribute::getFamilyInternal() { return uiAttributeFamily(a); } -double FontAttribute::getSize() { +double FontAttribute::getSizeInternal() { return uiAttributeSize(a); } -int FontAttribute::getWeight() { +int FontAttribute::getWeightInternal() { return uiAttributeWeight(a); } -int FontAttribute::getItalic() { +int FontAttribute::getItalicInternal() { return uiAttributeItalic(a); } -int FontAttribute::getStretch() { +int FontAttribute::getStretchInternal() { return uiAttributeStretch(a); } -Color FontAttribute::getColor() { +Color FontAttribute::getColorInternal() { double r; double g; double b; @@ -65,11 +66,11 @@ Color FontAttribute::getColor() { return Color(r, g, b, alpha); } -int FontAttribute::getUnderline() { +int FontAttribute::getUnderlineInternal() { return uiAttributeUnderline(a); } -int FontAttribute::getUnderlineColor(Color *c) { +std::vector FontAttribute::getUnderlineColorInternal() { double r; double g; double b; @@ -77,15 +78,11 @@ int FontAttribute::getUnderlineColor(Color *c) { uiUnderlineColor type; uiAttributeUnderlineColor(a, &type, &r, &g, &b, &alpha); - c->setR(r); - c->setG(g); - c->setB(b); - c->setA(alpha); - return type; + return std::vector {Color(r, g, b, alpha), Color(type, 0, 0, 0)}; } -OpenTypeFeatures FontAttribute::getOTFeatures() { +OpenTypeFeatures FontAttribute::getOTFeaturesInternal() { return OpenTypeFeatures((uiOpenTypeFeatures*) uiAttributeFeatures(a)); } @@ -135,14 +132,14 @@ FontAttribute FontAttribute::newOTFeatures(OpenTypeFeatures *otf) { NBIND_CLASS(FontAttribute) { method(getAttributeType); - method(getFamily); - method(getSize); - method(getWeight); - method(getItalic); - method(getStretch); - method(getColor); - method(getUnderline); - method(getUnderlineColor); + method(getFamilyInternal); + method(getSizeInternal); + method(getWeightInternal); + method(getItalicInternal); + method(getStretchInternal); + method(getColorInternal); + method(getUnderlineInternal); + method(getUnderlineColorInternal); method(newFamily); method(newSize); diff --git a/src/Font/OpenTypeFeatures.cc b/src/Font/OpenTypeFeatures.cc index 83c4731..9d083b7 100644 --- a/src/Font/OpenTypeFeatures.cc +++ b/src/Font/OpenTypeFeatures.cc @@ -1,3 +1,4 @@ +#include #include "../../ui.h" #include "../ui-node.h" #include "nbind/nbind.h" diff --git a/src/ui-node.h b/src/ui-node.h index 84723aa..eafb407 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -667,17 +667,15 @@ class FontAttribute { int getAttributeType(); uiAttribute *getHandle(); - // TODO needs to actually be of that type - maybe implement check and return -1 if wrong (or throw js error) - // It is an error to call this on a uiAttribute that does not hold a ... - const char *getFamily(); - double getSize(); - int getWeight(); - int getItalic(); - int getStretch(); - Color getColor(); - int getUnderline(); - int getUnderlineColor(Color *c); - OpenTypeFeatures getOTFeatures(); + const char *getFamilyInternal(); + double getSizeInternal(); + int getWeightInternal(); + int getItalicInternal(); + int getStretchInternal(); + Color getColorInternal(); + int getUnderlineInternal(); + std::vector getUnderlineColorInternal(); + OpenTypeFeatures getOTFeaturesInternal(); static FontAttribute newFamily(const char *family); static FontAttribute newSize(double size); From 0a93c962b4d347c10b460dd21e1a362cfad4fbab Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Sun, 15 Apr 2018 15:42:38 +0200 Subject: [PATCH 152/190] FontAttribute docs --- docs/attributedstring.md | 66 ++++++++++++++++++++++++++++++---------- 1 file changed, 50 insertions(+), 16 deletions(-) diff --git a/docs/attributedstring.md b/docs/attributedstring.md index 11c5722..a4a2d31 100644 --- a/docs/attributedstring.md +++ b/docs/attributedstring.md @@ -22,21 +22,6 @@ class AttributedString { size_t graphemeToByteIndex(size_t pos); }; -class FontAttribute { - public: - const char *getFamily(); - double getSize(); - int getWeight(); - int getItalic(); - int getStretch(); - Color getColor(); - int getUnderline(); - getUnderlineColor(); - // { type: 0, color: Color { r: 1, g: 0, b: 0, a: 1 } } - // { type: 1, color: null } - OpenTypeFeatures *getOTFeatures(); -}; - ``` # Classes @@ -81,7 +66,7 @@ Returns a new FontAttribute for the font size `size`. * size: Number -### newWeight(int weightAttribute) +### newWeight Returns a new FontAttribute for the font weight `weight`. @@ -198,6 +183,55 @@ Returns the type of the attribute. Possible values: * `libui.textAttributeType.underlineColor` * `libui.textAttributeType.features` +### getFamily + +Returns the font family string or `null` if called on a non-family attribute. + +### getSize + +Returns the font size or `null` if called on a non-size attribute. + +### getWeight + +Returns the font weight (see [newWeight](#newweight) for values) or `null` if called on a non-weight attribute. + +### getItalic + +Returns the font italic style (see [newItalic](#newitalic) for values) or `null` if called on a non-italic attribute. + +### getStretch + +Returns the font stretch (see [newStretch](#newstretch) for values) or `null` if called on a non-stretch attribute. + +### getColor + +Returns the color or `null` if called on a non-color attribute. + +### getUnderline + +Returns the underline style (see [newUnderline](#newunderline) for values) or `null` if called on a non-underline-style attribute. + +### getUnderlineColor + +Returns an object describing the underline color or `null` if called on a non-underline-style attribute. + +```js +{ + type: textUnderlineColor.custom, + color: Color +} +// or +{ + type: textUnderlineColor.grammar | spelling | auxiliary, + color: null +} +``` +See [newUnderlineColor](#newunderlinecolor) for `type` values) + + +### getOTFeatures + +Returns the [OpenTypeFeatures](#opentypefeatures) or `null` if called on a non-OpenType-features attribute. ### free From 27ec27faba40e06a432179d5b2e67144dd9eac95 Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Sun, 15 Apr 2018 18:31:34 +0200 Subject: [PATCH 153/190] Font docs, insertAttributed --- docs.js | 2 +- docs/attributedstring.md | 174 ++++++++++++++++++++++++++++++----- docs/fontbutton.md | 2 +- examples/text.js | 11 ++- index.js | 31 ++++--- src/Font/AttributedString.cc | 25 ++--- src/ui-node.h | 5 +- 7 files changed, 194 insertions(+), 56 deletions(-) diff --git a/docs.js b/docs.js index b41ee41..f8f6203 100644 --- a/docs.js +++ b/docs.js @@ -885,7 +885,7 @@ writeFile( writeFile( 'UiFontButton', 'A button that opens a font chooser.', - property('font', 'FontDescriptor', 'Return or set the currently selected font', false), + property('font', 'FontDescriptor', 'Return or set the currently selected font (see [FontDescriptor](attributedstring.md#fontdescriptor)', false), event('onChanged', 'font'), method('destroy', 'Destroy and free the control.'), diff --git a/docs/attributedstring.md b/docs/attributedstring.md index a4a2d31..0872369 100644 --- a/docs/attributedstring.md +++ b/docs/attributedstring.md @@ -1,46 +1,160 @@ # AttributedString -```cpp -class AttributedString { - AttributedString(const char *str); - void free(); - const char * toString(); - size_t toStringLen(); +An AttributedString is a string which also contains information about styles such as text color, font, font size. It gets drawn in an UiArea element. - void appendUnattributed(const char *str); - void insertUnattributed(const char *str, size_t at); - void deleteString(size_t start, size_t end); - void setAttribute(FontAttribute *attr, size_t start, size_t end); +```js +var libui = require('.'); + +var str = new libui.AttributedString(''); +str.appendAttributed('Test\n', libui.FontAttribute.newSize(24)); +str.appendAttributed('Background', libui.FontAttribute.newBackgroundColor(new libui.Color(0.5, 0.5, 0.5, 1))); + +function draw(area, p) { + const font = new libui.FontDescriptor('Georgia', 14, libui.textWeight.normal, libui.textItalic.normal, libui.textStretch.normal); - void appendAttributed(const char *str, FontAttribute *attr); - void appendAttributed(const char *str, FontAttribute *attr, FontAttribute *attr2); + console.log(p.getAreaWidth()) + const layout = new libui.DrawTextLayout(str, font, p.getAreaWidth(), libui.textAlign.left); + + p.getContext().text(0, 0, layout); +} +function noop(){} - void forEach(nbind::cbFunction& cb); +var win = new libui.UiWindow('AttributedString example', 300, 300, true); +win.margined = true; - size_t numGraphemes(); - size_t byteIndexToGrapheme(size_t pos); - size_t graphemeToByteIndex(size_t pos); -}; +const box = new libui.UiHorizontalBox(); +win.setChild(box); +var area = new libui.UiArea(draw, noop, noop, noop, noop); +box.append(area, true); + +win.onClosing(function () { + win.close(); + libui.stopLoop(); +}); + +win.show(); +libui.startLoop(); ``` + # Classes --- + + # AttributedString +A styled string. + ## Constructor +**Arguments** + +* s: String + ## Methods +### deleteString + +Removes characters in the range `start` - `end`(exclusive). + +**Arguments** + +* start: Number +* end: Number + +### setAttribute + +Sets an attribute in the range `start` - `end`(exclusive). + +**Arguments** + +* attr: FontAttribute +* start: Number +* end: Number + + +### appendUnattributed + +Appends a string without any attributes. + +**Arguments*** + +* s: String + +### insertUnattributed + +Inserts a string without any attributes at `pos`. + +**Arguments*** + +* s: String +* pos: Number + + +### appendAttributed + +Appends a string with the specified attributes. + +**Arguments*** + +* s: String +* a1: FontAttribute +* a2: FontAttribute (optional) +* (optionally more attributes) + +### insertAttributed + +Inserts a string with the specified attributes at `pos`. + +**Arguments*** + +* s: String +* pos: Number +* a1: FontAttribute +* a2: FontAttribute (optional) +* (optionally more attributes) + + +### toString + +Returns the text content. + ### forEach -Iterates over all tags. Return `libui.forEach.stop` in the callback to break. +Iterates over all attributes. Return `libui.forEach.stop` in the callback to break. **Arguments** -* cb: `function(OpenTypeFeatures, tag, value)` +* cb: `function(AttributedString, FontAttribute, start: number, end: Number)` + +### numGraphemes + +Returns the number of graphemes (characters from the point of view of the user). + +### byteIndexToGrapheme + +> The cursor of a text editor is always placed on a grapheme boundary, so you can use these features to move the cursor left or right by one "character". + +Converts a byte index in the string to a grapheme index. + +**Arguments** + +* pos: Number + +### graphemeToByteIndex + +Converts a graphmeme index in the string to a byte index. + +**Arguments** + +* pos: Number + +### free + +Frees the object immediately. # FontAttribute @@ -297,7 +411,7 @@ Iterates over all tags. Return `libui.forEach.stop` in the callback to break. **Arguments** -* cb: `function(OpenTypeFeatures, tag, value)` +* cb: `function(OpenTypeFeatures, tag: String, value: Number)` ### free @@ -313,18 +427,32 @@ Defines a font. * family: String * size: Number -* weight: -* italic: -* stretch: +* weight: see [FontAttribute.newWeight](#newweight) +* italic: see [FontAttribute.newItalic](#newitalic) +* stretch: see [FontAttribute.newStretch](#newstretch) ## Methods ### getFamily + +Returns the font family. + ### getSize + +Returns the font size. + ### getWeight + +Returns the font weight. + ### getItalic + +Returns the italic style. + ### getStretch +Returns the font stretch. + ### free Frees the object immediately. diff --git a/docs/fontbutton.md b/docs/fontbutton.md index 942ca13..a40a784 100644 --- a/docs/fontbutton.md +++ b/docs/fontbutton.md @@ -41,7 +41,7 @@ See [properties implementation](properties.md) for generic details on how proper ### font: FontDescriptor -Return or set the currently selected font +Return or set the currently selected font (see [FontDescriptor](attributedstring.md#fontdescriptor) diff --git a/examples/text.js b/examples/text.js index 8a959cf..cb225f7 100644 --- a/examples/text.js +++ b/examples/text.js @@ -11,7 +11,7 @@ let align; let checkbox; const str = new libui.AttributedString( - '👨🏻 Drawing strings with libui is done with the uiAttributedString and uiDrawTextLayout objects.\n' + + '\n👨🏻 Drawing strings with libui is done with the uiAttributedString and uiDrawTextLayout objects.\n' + 'uiAttributedString lets you have a variety of attributes: '); str.setAttribute(FontAttribute.newBackgroundColor(new libui.Color(0, 0, 1, 1)), 0, Buffer.from('👨🏻').length); @@ -80,7 +80,14 @@ otf.free(); str.appendUnattributed(').\n'); str.appendUnattributed('Use the controls opposite to the text to control properties of the text.\n'); -str.appendAttributed('👨🏾', FontAttribute.newBackgroundColor(new libui.Color(0, 1, 0, 1))); +str.appendAttributed('👨🏾\n', FontAttribute.newBackgroundColor(new libui.Color(0, 1, 0, 1))); + +str.appendAttributed('An mulitple attributes at once!', + FontAttribute.newColor(new libui.Color(1, 1, 1, 1)), + FontAttribute.newBackgroundColor(new libui.Color(0, 0, 0, 1)), + FontAttribute.newFamily('Monaco')); + +str.insertAttributed('Styled Strings\n', 0, FontAttribute.newWeight(libui.textWeight.bold), FontAttribute.newSize(24)); function handlerDraw(area, p) { const font = checkbox.checked ? diff --git a/index.js b/index.js index 638eff1..be323cf 100755 --- a/index.js +++ b/index.js @@ -149,11 +149,12 @@ const forEach = { stop: 1 }; -binding.lib.AttributedString.prototype.appendAttributed = function (str, attr, attr2) { - if (attr2) { - return this.appendAttributed2(str, attr, attr2); - } - return this.appendAttributed1(str, attr); +binding.lib.AttributedString.prototype.appendAttributed = function (str) { + return this.appendAttributedInternal(str, Array.prototype.slice.call(arguments, 1)); +}; + +binding.lib.AttributedString.prototype.insertAttributed = function (str, start) { + return this.insertAttributedInternal(str, start, Array.prototype.slice.call(arguments, 2)); }; binding.lib.FontAttribute.newUnderlineColor = function (type, color) { @@ -173,65 +174,65 @@ binding.lib.OpenTypeFeatures.prototype.get = function (str) { }; binding.lib.FontAttribute.prototype.getFamily = function () { - if(this.getAttributeType() !== textAttributeType.family) { + if (this.getAttributeType() !== textAttributeType.family) { return null; } return this.getFamilyInternal(); }; binding.lib.FontAttribute.prototype.getSize = function () { - if(this.getAttributeType() !== textAttributeType.size) { + if (this.getAttributeType() !== textAttributeType.size) { return null; } return this.getSizeInternal(); }; binding.lib.FontAttribute.prototype.getWeight = function () { - if(this.getAttributeType() !== textAttributeType.weight) { + if (this.getAttributeType() !== textAttributeType.weight) { return null; } return this.getWeightInternal(); }; binding.lib.FontAttribute.prototype.getItalic = function () { - if(this.getAttributeType() !== textAttributeType.italic) { + if (this.getAttributeType() !== textAttributeType.italic) { return null; } return this.getItalicInternal(); }; binding.lib.FontAttribute.prototype.getStretch = function () { - if(this.getAttributeType() !== textAttributeType.stretch) { + if (this.getAttributeType() !== textAttributeType.stretch) { return null; } return this.getStretchInternal(); }; binding.lib.FontAttribute.prototype.getColor = function () { - if(this.getAttributeType() !== textAttributeType.color) { + if (this.getAttributeType() !== textAttributeType.color) { return null; } return this.getColorInternal(); }; binding.lib.FontAttribute.prototype.getUnderline = function () { - if(this.getAttributeType() !== textAttributeType.underline) { + if (this.getAttributeType() !== textAttributeType.underline) { return null; } return this.getUnderlineInternal(); }; binding.lib.FontAttribute.prototype.getUnderlineColor = function () { - if(this.getAttributeType() !== textAttributeType.underlineColor) { + if (this.getAttributeType() !== textAttributeType.underlineColor) { return null; } const v = this.getUnderlineColorInternal(); const type = Math.round(v[1].r); - return {type: type, color: type == textUnderlineColor.custom ? v[0] : null}; + return {type, color: type === textUnderlineColor.custom ? v[0] : null}; }; binding.lib.FontAttribute.prototype.getOTFeatures = function () { - if(this.getAttributeType() !== textAttributeType.features) { + if (this.getAttributeType() !== textAttributeType.features) { return null; } return this.getOTFeaturesInternal(); diff --git a/src/Font/AttributedString.cc b/src/Font/AttributedString.cc index fed81e1..64fff88 100644 --- a/src/Font/AttributedString.cc +++ b/src/Font/AttributedString.cc @@ -1,3 +1,4 @@ +#include #include "../../ui.h" #include "../ui-node.h" #include "nbind/nbind.h" @@ -65,22 +66,24 @@ void AttributedString::forEach(nbind::cbFunction& cb) { uiAttributedStringForEachAttribute(s, AttributedString__forEach, &d); } - -void AttributedString::appendAttributed(const char *str, FontAttribute *attr) { - this->appendAttributed(str, attr, nullptr); -} - -void AttributedString::appendAttributed(const char *str, FontAttribute *attr, FontAttribute *attr2) { +void AttributedString::appendAttributedInternal(const char *str, std::vector attrs) { size_t start = this->toStringLen(); size_t end = start + strlen(str); this->appendUnattributed(str); - this->setAttribute(attr, start, end); - if(attr2 != nullptr){ - this->setAttribute(attr2, start, end); + for(std::vector::size_type i = 0; i < attrs.size(); i++) { + this->setAttribute(attrs[i], start, end); } } +void AttributedString::insertAttributedInternal(const char *str, size_t start, std::vector attrs) { + size_t end = start + strlen(str); + + this->insertUnattributed(str, start); + for(std::vector::size_type i = 0; i < attrs.size(); i++) { + this->setAttribute(attrs[i], start, end); + } +} size_t AttributedString::numGraphemes() { return uiAttributedStringNumGraphemes(s); @@ -101,8 +104,8 @@ NBIND_CLASS(AttributedString) { method(appendUnattributed); method(insertUnattributed); method(forEach); - multimethod(appendAttributed, args(const char *, FontAttribute *), "appendAttributed1"); - multimethod(appendAttributed, args(const char *, FontAttribute *, FontAttribute *), "appendAttributed2"); + method(appendAttributedInternal); + method(insertAttributedInternal); method(deleteString); method(setAttribute); diff --git a/src/ui-node.h b/src/ui-node.h index eafb407..f7a2cc2 100644 --- a/src/ui-node.h +++ b/src/ui-node.h @@ -706,9 +706,8 @@ class AttributedString { void deleteString(size_t start, size_t end); void setAttribute(FontAttribute *attr, size_t start, size_t end); - void appendAttributed(const char *str, FontAttribute *attr); - void appendAttributed(const char *str, FontAttribute *attr, FontAttribute *attr2); - // TODO multiple attr? does nbind support variadic arguments? or use array? + void appendAttributedInternal(const char *str, std::vector attrs); + void insertAttributedInternal(const char *str, size_t start, std::vector attrs); void forEach(nbind::cbFunction& cb); From 62f0c7146c82fde364ce49b4927a5ad599ae5aa7 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sun, 15 Apr 2018 20:45:38 +0200 Subject: [PATCH 154/190] use global patched setTimeout --- examples/check-control-destroy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/check-control-destroy.js b/examples/check-control-destroy.js index cc0e602..e9adc0d 100644 --- a/examples/check-control-destroy.js +++ b/examples/check-control-destroy.js @@ -137,7 +137,7 @@ function op() { global.gc(); const win = createWindow(); win.show(); - libui.setTimeout(() => { + setTimeout(() => { win.close(); op(); }, 100); From 513bac957ae2110936f9d0e5c919a9277164cf83 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sun, 15 Apr 2018 20:48:22 +0200 Subject: [PATCH 155/190] Removed test code --- examples/core-api.js | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/examples/core-api.js b/examples/core-api.js index 99e6234..f9598c6 100644 --- a/examples/core-api.js +++ b/examples/core-api.js @@ -1,6 +1,5 @@ 'use strict'; const os = require('os'); -const http = require('http'); const libui = require('..'); const win = new libui.UiWindow('Test window', 800, 600, false); @@ -14,26 +13,9 @@ const lblCiao = new libui.UiLabel('ciao'); hBox.append(lblCiao, false); hBox.append(e1, false); -let idxLbl = 0; - -const interval = setInterval(() => { - lblCiao.text = String(idxLbl++); -}, 1000); - -// Create an HTTP tunneling proxy -const proxy = http.createServer((req, res) => { - lblCiao.text = String(idxLbl++); - res.writeHead(200, {'Content-Type': 'text/plain'}); - res.end(String(idxLbl)); -}); -proxy.listen(3000, '127.0.0.1', () => { - console.log('listening...'); -}); win.onClosing(() => { win.close(); - clearInterval(interval); - proxy.close(); libui.stopLoop(); }); From 4d4df0ae58f5d482a3f8a8242214448743e02b5e Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sun, 15 Apr 2018 20:50:36 +0200 Subject: [PATCH 156/190] Removed weird paths from includes --- src/EventLoop.cc | 2 +- src/arch/darwin/libui_loop.mm | 4 ++-- src/arch/unix/libui_loop.cc | 4 ++-- src/arch/win32/libui_loop.cc | 4 ++-- src/includes/event-loop.h | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/EventLoop.cc b/src/EventLoop.cc index 7433485..0d7e850 100644 --- a/src/EventLoop.cc +++ b/src/EventLoop.cc @@ -1,4 +1,4 @@ -#include "includes/event-loop.h" +#include "event-loop.h" static std::atomic running; static std::atomic guiBlocked; diff --git a/src/arch/darwin/libui_loop.mm b/src/arch/darwin/libui_loop.mm index b7e3bcb..fce8186 100644 --- a/src/arch/darwin/libui_loop.mm +++ b/src/arch/darwin/libui_loop.mm @@ -1,5 +1,5 @@ -#include "../../includes/event-loop-darwin.h" -#include "../../includes/event-loop.h" +#include "event-loop-darwin.h" +#include "event-loop.h" int uiLoopWakeup() { [NSApp postEvent:[NSEvent otherEventWithType:NSApplicationDefined diff --git a/src/arch/unix/libui_loop.cc b/src/arch/unix/libui_loop.cc index 28d77bd..2e14ad5 100644 --- a/src/arch/unix/libui_loop.cc +++ b/src/arch/unix/libui_loop.cc @@ -1,5 +1,5 @@ -#include "../../includes/event-loop-linux.h" -#include "../../includes/event-loop.h" +#include "event-loop-linux.h" +#include "event-loop.h" int uiLoopWakeup() { DEBUG("uiLoopWakeup\n"); diff --git a/src/arch/win32/libui_loop.cc b/src/arch/win32/libui_loop.cc index e9b4943..fbc2635 100644 --- a/src/arch/win32/libui_loop.cc +++ b/src/arch/win32/libui_loop.cc @@ -1,5 +1,5 @@ -#include "../../includes/event-loop-windows.h" -#include "../../includes/event-loop.h" +#include "event-loop-windows.h" +#include "event-loop.h" void noop(void *data) {} diff --git a/src/includes/event-loop.h b/src/includes/event-loop.h index 6fc59de..bd8dd5f 100644 --- a/src/includes/event-loop.h +++ b/src/includes/event-loop.h @@ -3,8 +3,8 @@ #include #include -#include "../../ui.h" #include "nbind/nbind.h" +#include "ui.h" // #define UI_NODE_DEBUG 1 From 727f8be37101193d0e4adf6b90a964411d5c1cdf Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sun, 15 Apr 2018 20:53:51 +0200 Subject: [PATCH 157/190] Removed code to check for node timers, since we reimplemented them. --- src/arch/darwin/libui_loop.mm | 10 +--------- src/arch/unix/libui_loop.cc | 10 +--------- src/arch/win32/libui_loop.cc | 4 ---- src/includes/event-loop.h | 17 ----------------- 4 files changed, 2 insertions(+), 39 deletions(-) diff --git a/src/arch/darwin/libui_loop.mm b/src/arch/darwin/libui_loop.mm index fce8186..2a0182a 100644 --- a/src/arch/darwin/libui_loop.mm +++ b/src/arch/darwin/libui_loop.mm @@ -37,13 +37,5 @@ int waitForNodeEvents(uv_loop_t *loop, int timeout) { ts.tv_sec = timeout / 1000; ts.tv_nsec = (timeout % 1000) * 1000000; - int ret = kevent(nodeBackendFd, NULL, 0, &event, 1, &ts); - - struct heap *timer_heap = (struct heap *)&loop->timer_heap; - struct heap_node *timer_node = timer_heap->min; - if (timer_node != NULL) { - return 1; - } - - return ret; + return kevent(nodeBackendFd, NULL, 0, &event, 1, &ts); } diff --git a/src/arch/unix/libui_loop.cc b/src/arch/unix/libui_loop.cc index 2e14ad5..055a270 100644 --- a/src/arch/unix/libui_loop.cc +++ b/src/arch/unix/libui_loop.cc @@ -28,13 +28,5 @@ int waitForNodeEvents(uv_loop_t *loop, int timeout) { struct epoll_event ev; DEBUG("epoll_wait\n"); - int ret = epoll_wait(nodeBackendFd, &ev, 1, timeout); - struct heap *timer_heap = (struct heap *)&loop->timer_heap; - struct heap_node *timer_node = timer_heap->min; - if (timer_node != NULL) { - return 1; - } - - DEBUG_F("epoll_wait %d\n", ret); - return ret; + return epoll_wait(nodeBackendFd, &ev, 1, timeout); } diff --git a/src/arch/win32/libui_loop.cc b/src/arch/win32/libui_loop.cc index fbc2635..a2a09ce 100644 --- a/src/arch/win32/libui_loop.cc +++ b/src/arch/win32/libui_loop.cc @@ -40,9 +40,5 @@ int waitForNodeEvents(uv_loop_t *loop, int timeout) { PostQueuedCompletionStatus(_loop->iocp, bytes, key, overlapped); } - if (loop->timers.rbh_root != NULL) { - return 1; - } - return ret; } diff --git a/src/includes/event-loop.h b/src/includes/event-loop.h index bd8dd5f..c500e47 100644 --- a/src/includes/event-loop.h +++ b/src/includes/event-loop.h @@ -20,21 +20,4 @@ int uiEventsPending(); int uiLoopWakeup(); int waitForNodeEvents(uv_loop_t *loop, int timeout); -/* - Internal libuv structures - to deal with timers on macOS - and linux. - */ - -struct heap_node { - struct heap_node *left; - struct heap_node *right; - struct heap_node *parent; -}; - -struct heap { - struct heap_node *min; - unsigned int nelts; -}; - #endif From 444b83cff56492eeaca503aa9cc18dc5db906e72 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Mon, 16 Apr 2018 23:52:51 +0200 Subject: [PATCH 158/190] [WIP] sync main & poller threads --- src/EventLoop.cc | 108 ++++++++++++++++++++++++---------- src/arch/darwin/libui_loop.mm | 7 +-- src/includes/event-loop.h | 2 +- 3 files changed, 80 insertions(+), 37 deletions(-) diff --git a/src/EventLoop.cc b/src/EventLoop.cc index 0d7e850..f473b79 100644 --- a/src/EventLoop.cc +++ b/src/EventLoop.cc @@ -1,7 +1,10 @@ #include "event-loop.h" static std::atomic running; -static std::atomic guiBlocked; + +static uv_mutex_t mainThreadWaitingGuiEvents; +static uv_mutex_t mainThreadAwakenFromBackground; +static uv_prepare_t mainThreadAwakenPhase; static uv_thread_t *thread; static uv_timer_t *redrawTimer; @@ -15,35 +18,57 @@ static uv_timer_t *redrawTimer; */ static void backgroundNodeEventsPoller(void *arg) { while (running) { - int timeout = uv_backend_timeout(uv_default_loop()); + DEBUG("--- wait mainThreadWaitingGuiEvents.\n"); - /* wait for 1s by default */ - if (timeout == 0) { - timeout = 1000; - } + // wait for the main thread + // to be blocked waiting for GUI events + uv_mutex_lock(&mainThreadWaitingGuiEvents); + // immediately release the lock + uv_mutex_unlock(&mainThreadWaitingGuiEvents); - int pendingEvents = 1; + int pendingEvents; - if (timeout != -1) { - do { - DEBUG_F("entering waitForNodeEvents with timeout %d\n", - timeout); - /* wait for pending events*/ - pendingEvents = waitForNodeEvents(uv_default_loop(), timeout); - DEBUG("exit waitForNodeEvents\n"); - } while (pendingEvents == -1 && errno == EINTR); - } + do { + DEBUG("--- entering waitForNodeEvents\n"); + /* wait for pending events*/ + pendingEvents = waitForNodeEvents(uv_default_loop(), 0); + } while (pendingEvents == -1 && errno == EINTR); - DEBUG_F("guiBlocked && pendingEvents %s && %d\n", - guiBlocked ? "blocked" : "non blocked", pendingEvents); + DEBUG_F("--- pendingEvents == %d\n", pendingEvents); - if (guiBlocked && pendingEvents > 0) { - DEBUG("------ wake up main thread\n"); + if (pendingEvents > 0) { + DEBUG("--- wake up main thread\n"); + // this allow the background thread + // to wait for the main thread to complete + // running node callbacks uiLoopWakeup(); + + // wait for the main thread to complete + // its awaken phase. + DEBUG("--- mainThreadAwakenFromBackground locking.\n"); + uv_mutex_lock(&mainThreadAwakenFromBackground); + DEBUG("--- mainThreadAwakenFromBackground locked.\n"); + + // immediately release the lock + uv_mutex_unlock(&mainThreadAwakenFromBackground); } } } +void redraw(uv_timer_t *handle); + +void uv_awaken_cb(uv_prepare_t *handle) { + DEBUG("+++ mainThreadAwakenFromBackground unlocking.\n"); + uv_prepare_stop(&mainThreadAwakenPhase); + uv_mutex_unlock(&mainThreadAwakenFromBackground); + // schedule another call to redraw as soon as possible + // how to find a correct amount of time to scheduke next call? + //.because too long and UI is not responsive, too short and node + // become really slow + uv_timer_start(redrawTimer, redraw, 1, 0); + DEBUG("+++ mainThreadAwakenFromBackground unlocked.\n"); +} + /* This function run all pending native GUI event in the loop using libui calls. @@ -61,25 +86,29 @@ void redraw(uv_timer_t *handle) { uv_timer_stop(handle); Nan::HandleScope scope; + // signal the background poller thread + // that the main one is about to enter + // the blocking call to wait for GUI events. + uv_mutex_unlock(&mainThreadWaitingGuiEvents); + + DEBUG("+++ locking mainThreadAwakenFromBackground\n"); + uv_mutex_lock(&mainThreadAwakenFromBackground); + DEBUG("+++ locked mainThreadAwakenFromBackground\n"); + + DEBUG("+++ blocking GUI\n"); /* Blocking call that wait for a node or GUI event pending */ - DEBUG("blocking GUI\n"); - guiBlocked = true; uiMainStep(true); - guiBlocked = false; - DEBUG("unblocking GUI\n"); + DEBUG("+++ GUI events received\n"); + + uv_mutex_lock(&mainThreadWaitingGuiEvents); + DEBUG("+++ mainThreadWaitingGuiEvents locked.\n"); /* dequeue and run every event pending */ while (uiEventsPending()) { running = uiMainStep(false); } - DEBUG("rescheduling next redraw\n"); - - // schedule another call to redraw as soon as possible - // how to find a correct amount of time to scheduke next call? - //.because too long and UI is not responsive, too short and node - // become really slow - uv_timer_start(handle, redraw, 10, 0); + uv_prepare_start(&mainThreadAwakenPhase, uv_awaken_cb); } /* This function start the event loop and exit immediately */ @@ -129,6 +158,23 @@ struct EventLoop { uiMainSteps(); DEBUG("uiMainSteps...\n"); + // this is used to signal the background thread + // that the main one is entering a blocking call + // waiting for GUI events. + uv_mutex_init(&mainThreadWaitingGuiEvents); + + // lock the mutex to signal that main + // thread is not yet blocked waiting + // for GUI events + uv_mutex_lock(&mainThreadWaitingGuiEvents); + + // this is used to signal the background thread + // when all pending callback of current tick are + // called. + uv_mutex_init(&mainThreadAwakenFromBackground); + + uv_prepare_init(uv_default_loop(), &mainThreadAwakenPhase); + /* start the background thread that check for node evnts pending */ thread = new uv_thread_t(); uv_thread_create(thread, backgroundNodeEventsPoller, NULL); diff --git a/src/arch/darwin/libui_loop.mm b/src/arch/darwin/libui_loop.mm index 2a0182a..a5c227e 100644 --- a/src/arch/darwin/libui_loop.mm +++ b/src/arch/darwin/libui_loop.mm @@ -13,7 +13,7 @@ int uiLoopWakeup() { data2:0] atStart:NO]; // give main thread some time to react - usleep(50 * 1000); + // usleep(50 * 1000); return 0; } @@ -33,9 +33,6 @@ int waitForNodeEvents(uv_loop_t *loop, int timeout) { } struct kevent event; - struct timespec ts; - ts.tv_sec = timeout / 1000; - ts.tv_nsec = (timeout % 1000) * 1000000; - return kevent(nodeBackendFd, NULL, 0, &event, 1, &ts); + return kevent(nodeBackendFd, NULL, 0, &event, 1, NULL); } diff --git a/src/includes/event-loop.h b/src/includes/event-loop.h index c500e47..55e7f38 100644 --- a/src/includes/event-loop.h +++ b/src/includes/event-loop.h @@ -6,7 +6,7 @@ #include "nbind/nbind.h" #include "ui.h" -// #define UI_NODE_DEBUG 1 +#define UI_NODE_DEBUG 1 #ifdef UI_NODE_DEBUG #define DEBUG(msg) fprintf(stderr, msg) From a85cd92fa684be97f2cbf8aa497d5d9ae09b1fa0 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Tue, 17 Apr 2018 21:47:30 +0200 Subject: [PATCH 159/190] Make the http buttons restart server on every click. --- examples/event-loop.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/event-loop.js b/examples/event-loop.js index 25d8695..c73f7c3 100644 --- a/examples/event-loop.js +++ b/examples/event-loop.js @@ -149,11 +149,15 @@ function makeToolbar() { }); const btnHttp = new libui.UiButton('Http'); + const http = require('http'); + + let server = null; btnHttp.onClicked(() => { - const http = require('http'); let i = 0; - - const server = http.createServer((req, res) => { + if (server) { + server.close(); + } + server = http.createServer((req, res) => { res.writeHead(200, {'Content-Type': 'text/plain'}); logAppend(`Http: request ${i}`); res.end(String(i++)); From a3c3d7c719da58ad1ef787a755e190d730d6d46d Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Tue, 17 Apr 2018 21:59:19 +0200 Subject: [PATCH 160/190] [WIP] more improvements syncing main & poller threads --- index.js | 4 +-- src/EventLoop.cc | 55 +++++++++++++++++++++++++++-------- src/arch/darwin/libui_loop.mm | 10 ++++++- 3 files changed, 54 insertions(+), 15 deletions(-) diff --git a/index.js b/index.js index 1fb578e..320caf2 100644 --- a/index.js +++ b/index.js @@ -254,6 +254,6 @@ module.exports.lineJoin = lineJoin; module.exports.fillMode = fillMode; module.exports.modifierKeys = modifierKeys; module.exports.extKeys = extKeys; -module.exports.startLoop = startLoop; -module.exports.stopLoop = stopLoop; +module.exports.startLoop = binding.lib.EventLoop.start; +module.exports.stopLoop = binding.lib.EventLoop.stop; module.exports.onShouldQuit = binding.lib.Ui.onShouldQuit; diff --git a/src/EventLoop.cc b/src/EventLoop.cc index f473b79..eb89d82 100644 --- a/src/EventLoop.cc +++ b/src/EventLoop.cc @@ -1,13 +1,17 @@ +#include #include "event-loop.h" static std::atomic running; +static std::atomic mainThreadStillWaitingGuiEvents; + static uv_mutex_t mainThreadWaitingGuiEvents; static uv_mutex_t mainThreadAwakenFromBackground; static uv_prepare_t mainThreadAwakenPhase; static uv_thread_t *thread; static uv_timer_t *redrawTimer; + /* This function is executed in the background thread and is responsible to continuosly polling @@ -26,23 +30,31 @@ static void backgroundNodeEventsPoller(void *arg) { // immediately release the lock uv_mutex_unlock(&mainThreadWaitingGuiEvents); - int pendingEvents; + int pendingEvents = 1; + int timeout = uv_backend_timeout(uv_default_loop()); + DEBUG_F("--- uv_backend_timeout == %d\n", timeout); - do { - DEBUG("--- entering waitForNodeEvents\n"); - /* wait for pending events*/ - pendingEvents = waitForNodeEvents(uv_default_loop(), 0); - } while (pendingEvents == -1 && errno == EINTR); + if (timeout != 0) { + do { + + DEBUG_F("--- entering waitForNodeEvents with timeout %d\n", + timeout); + /* wait for pending events*/ + pendingEvents = waitForNodeEvents(uv_default_loop(), timeout); + } while (pendingEvents == -1 && errno == EINTR); + } DEBUG_F("--- pendingEvents == %d\n", pendingEvents); - if (pendingEvents > 0) { + if (mainThreadStillWaitingGuiEvents) { DEBUG("--- wake up main thread\n"); // this allow the background thread // to wait for the main thread to complete // running node callbacks uiLoopWakeup(); + } + if (pendingEvents > 0) { // wait for the main thread to complete // its awaken phase. DEBUG("--- mainThreadAwakenFromBackground locking.\n"); @@ -58,15 +70,16 @@ static void backgroundNodeEventsPoller(void *arg) { void redraw(uv_timer_t *handle); void uv_awaken_cb(uv_prepare_t *handle) { - DEBUG("+++ mainThreadAwakenFromBackground unlocking.\n"); uv_prepare_stop(&mainThreadAwakenPhase); + DEBUG("+++ mainThreadAwakenFromBackground unlocking.\n"); uv_mutex_unlock(&mainThreadAwakenFromBackground); + DEBUG("+++ mainThreadAwakenFromBackground unlocked.\n"); + // schedule another call to redraw as soon as possible // how to find a correct amount of time to scheduke next call? //.because too long and UI is not responsive, too short and node // become really slow - uv_timer_start(redrawTimer, redraw, 1, 0); - DEBUG("+++ mainThreadAwakenFromBackground unlocked.\n"); + uv_timer_start(redrawTimer, redraw, 100, 0); } /* @@ -91,13 +104,18 @@ void redraw(uv_timer_t *handle) { // the blocking call to wait for GUI events. uv_mutex_unlock(&mainThreadWaitingGuiEvents); + mainThreadStillWaitingGuiEvents = true; + DEBUG("+++ locking mainThreadAwakenFromBackground\n"); uv_mutex_lock(&mainThreadAwakenFromBackground); DEBUG("+++ locked mainThreadAwakenFromBackground\n"); DEBUG("+++ blocking GUI\n"); + /* Blocking call that wait for a node or GUI event pending */ uiMainStep(true); + mainThreadStillWaitingGuiEvents = false; + DEBUG("+++ GUI events received\n"); uv_mutex_lock(&mainThreadWaitingGuiEvents); @@ -107,6 +125,9 @@ void redraw(uv_timer_t *handle) { while (uiEventsPending()) { running = uiMainStep(false); } + // uv_mutex_unlock(&mainThreadAwakenFromBackground); + + // uv_timer_start(redrawTimer, redraw, 100, 0); uv_prepare_start(&mainThreadAwakenPhase, uv_awaken_cb); } @@ -127,13 +148,23 @@ void stopAsync(uv_timer_t *handle) { DEBUG("redrawTimer\n"); uv_timer_stop(handle); - uv_close((uv_handle_t *)handle, NULL); DEBUG("handle\n"); + uv_close((uv_handle_t *)handle, NULL); + + uv_mutex_unlock(&mainThreadWaitingGuiEvents); + uv_mutex_lock(&mainThreadAwakenFromBackground); /* await for the background thread to finish */ DEBUG("uv_thread_join\n"); uv_thread_join(thread); + uv_mutex_destroy(&mainThreadWaitingGuiEvents); + + uv_mutex_destroy(&mainThreadAwakenFromBackground); + + uv_close((uv_handle_t *)&mainThreadAwakenPhase, NULL); + uv_close((uv_handle_t *)&mainThreadAwakenPhase, NULL); + /* delete handle; delete redrawTimer; @@ -153,7 +184,7 @@ struct EventLoop { } running = true; - + mainThreadStillWaitingGuiEvents = false; /* init libui event loop */ uiMainSteps(); DEBUG("uiMainSteps...\n"); diff --git a/src/arch/darwin/libui_loop.mm b/src/arch/darwin/libui_loop.mm index a5c227e..54d6079 100644 --- a/src/arch/darwin/libui_loop.mm +++ b/src/arch/darwin/libui_loop.mm @@ -33,6 +33,14 @@ int waitForNodeEvents(uv_loop_t *loop, int timeout) { } struct kevent event; + struct timespec ts; + struct timespec *tsp = nullptr; - return kevent(nodeBackendFd, NULL, 0, &event, 1, NULL); + if (timeout != -1) { + tsp = &ts; + ts.tv_sec = timeout / 1000; + ts.tv_nsec = (timeout % 1000) * 1000000; + } + + return kevent(nodeBackendFd, NULL, 0, &event, 1, tsp); } From 1bc1b6b751b66bafbdd3ecf234bad7135ad07bf3 Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Wed, 18 Apr 2018 17:40:51 +0200 Subject: [PATCH 161/190] Fix forEach methods --- docs/attributedstring.md | 10 +++++----- examples/text.js | 2 +- src/Font/AttributedString.cc | 12 ++++++------ src/Font/OpenTypeFeatures.cc | 10 ++++++---- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/docs/attributedstring.md b/docs/attributedstring.md index 0872369..e94968c 100644 --- a/docs/attributedstring.md +++ b/docs/attributedstring.md @@ -124,7 +124,7 @@ Returns the text content. ### forEach -Iterates over all attributes. Return `libui.forEach.stop` in the callback to break. +Iterates over all attributes. Return `true` in the callback to break. **Arguments** @@ -137,7 +137,7 @@ Returns the number of graphemes (characters from the point of view of the user). ### byteIndexToGrapheme > The cursor of a text editor is always placed on a grapheme boundary, so you can use these features to move the cursor left or right by one "character". - + Converts a byte index in the string to a grapheme index. **Arguments** @@ -264,7 +264,7 @@ Returns a new FontAttribute for the underline color. **Arguments** -* colorAttr: +* colorAttr: * `libui.textUnderlineColor.custom` * `libui.textUnderlineColor.spelling` * `libui.textUnderlineColor.grammar` @@ -340,7 +340,7 @@ Returns an object describing the underline color or `null` if called on a non-un color: null } ``` -See [newUnderlineColor](#newunderlinecolor) for `type` values) +See [newUnderlineColor](#newunderlinecolor) for `type` values) ### getOTFeatures @@ -407,7 +407,7 @@ Returns the value of `tag` or `null` if not set. ### forEach -Iterates over all tags. Return `libui.forEach.stop` in the callback to break. +Iterates over all tags. Return `true` in the callback to break. **Arguments** diff --git a/examples/text.js b/examples/text.js index b6152d2..5be22e3 100644 --- a/examples/text.js +++ b/examples/text.js @@ -82,7 +82,7 @@ str.appendUnattributed(').\n'); str.appendUnattributed('Use the controls opposite to the text to control properties of the text.\n'); str.appendAttributed('👨🏾\n', FontAttribute.newBackgroundColor(new libui.Color(0, 1, 0, 1))); -str.appendAttributed('An mulitple attributes at once!', +str.appendAttributed('And multiple attributes at once!', FontAttribute.newColor(new libui.Color(1, 1, 1, 1)), FontAttribute.newBackgroundColor(new libui.Color(0, 0, 0, 1)), FontAttribute.newFamily('Monaco')); diff --git a/src/Font/AttributedString.cc b/src/Font/AttributedString.cc index 84b958d..c96baae 100644 --- a/src/Font/AttributedString.cc +++ b/src/Font/AttributedString.cc @@ -49,17 +49,17 @@ typedef struct { nbind::cbFunction *cb; } ForEachData; -static unsigned int AttributedString__forEach(const uiAttributedString *s, - const uiAttribute *a, - size_t start, size_t end, - void *d) { +static uiForEach AttributedString__forEach(const uiAttributedString *s, + const uiAttribute *a, size_t start, + size_t end, void *d) { ForEachData *data = (ForEachData *)d; FontAttribute f = FontAttribute((uiAttribute *)a); f.setAppended(); - return data->cb->call( - data->str, FontAttribute((uiAttribute *)a), start, end); + unsigned int v = data->cb->call(data->str, f, start, end); + + return v ? uiForEachStop : uiForEachContinue; } void AttributedString::forEach(nbind::cbFunction &cb) { diff --git a/src/Font/OpenTypeFeatures.cc b/src/Font/OpenTypeFeatures.cc index 30eac7d..9fa3205 100644 --- a/src/Font/OpenTypeFeatures.cc +++ b/src/Font/OpenTypeFeatures.cc @@ -49,13 +49,15 @@ typedef struct { nbind::cbFunction *cb; } ForEachData; -static unsigned int OpenTypeFeatures__forEach(const uiOpenTypeFeatures *otf, - char a, char b, char c, char d, - uint32_t value, void *dat) { +static uiForEach OpenTypeFeatures__forEach(const uiOpenTypeFeatures *otf, + char a, char b, char c, char d, + uint32_t value, void *dat) { ForEachData *data = (ForEachData *)dat; const char tag[5] = {a, b, c, d, '\0'}; - return data->cb->call(data->otf, &tag[0], value); + unsigned int v = data->cb->call(data->otf, &tag[0], value); + + return v ? uiForEachStop : uiForEachContinue; } void OpenTypeFeatures::forEach(nbind::cbFunction &cb) { From e313fb37f642a2dc9e2168d04b70d89f9556ae6f Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Thu, 19 Apr 2018 20:35:34 +0200 Subject: [PATCH 162/190] [WIP] again more improvements syncing main & poller threads --- examples/event-loop.js | 2 +- src/EventLoop.cc | 26 ++++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/examples/event-loop.js b/examples/event-loop.js index c73f7c3..b9f9871 100644 --- a/examples/event-loop.js +++ b/examples/event-loop.js @@ -163,7 +163,7 @@ function makeToolbar() { res.end(String(i++)); }); - server.listen(3000, '127.0.0.1', () => { + server.listen(8300, '127.0.0.1', () => { logAppend('listening...'); }); }); diff --git a/src/EventLoop.cc b/src/EventLoop.cc index eb89d82..764e6c5 100644 --- a/src/EventLoop.cc +++ b/src/EventLoop.cc @@ -8,6 +8,7 @@ static std::atomic mainThreadStillWaitingGuiEvents; static uv_mutex_t mainThreadWaitingGuiEvents; static uv_mutex_t mainThreadAwakenFromBackground; static uv_prepare_t mainThreadAwakenPhase; +static uv_timer_t keepAliveTimer; static uv_thread_t *thread; static uv_timer_t *redrawTimer; @@ -34,6 +35,13 @@ static void backgroundNodeEventsPoller(void *arg) { int timeout = uv_backend_timeout(uv_default_loop()); DEBUG_F("--- uv_backend_timeout == %d\n", timeout); + // hack: we should limit the max timout + // in order to let new handler to be listened on. + // this will be solved using a patched version of node + if (timeout > 1000) { + timeout = 1000; + } + if (timeout != 0) { do { @@ -67,6 +75,10 @@ static void backgroundNodeEventsPoller(void *arg) { } } +void noop(uv_timer_t *handle) { + ; +} + void redraw(uv_timer_t *handle); void uv_awaken_cb(uv_prepare_t *handle) { @@ -124,12 +136,18 @@ void redraw(uv_timer_t *handle) { /* dequeue and run every event pending */ while (uiEventsPending()) { running = uiMainStep(false); + DEBUG("+++ other GUI event dequeued.\n"); } + + DEBUG("+++ all GUI events dequeued.\n"); + // uv_mutex_unlock(&mainThreadAwakenFromBackground); // uv_timer_start(redrawTimer, redraw, 100, 0); uv_prepare_start(&mainThreadAwakenPhase, uv_awaken_cb); + + DEBUG("+++ prepare handler started.\n"); } /* This function start the event loop and exit immediately */ @@ -162,7 +180,6 @@ void stopAsync(uv_timer_t *handle) { uv_mutex_destroy(&mainThreadAwakenFromBackground); - uv_close((uv_handle_t *)&mainThreadAwakenPhase, NULL); uv_close((uv_handle_t *)&mainThreadAwakenPhase, NULL); /* @@ -211,10 +228,15 @@ struct EventLoop { uv_thread_create(thread, backgroundNodeEventsPoller, NULL); DEBUG("thread...\n"); + /* bogus timer handler only used to keep process active */ + /* fires once per hour */ + uv_timer_init(uv_default_loop(), &keepAliveTimer); + uv_timer_start(&keepAliveTimer, noop, 1000 * 60 * 60, 1000 * 60 * 60); + /* start redraw timer */ redrawTimer = new uv_timer_t(); uv_timer_init(uv_default_loop(), redrawTimer); - redraw(redrawTimer); + uv_timer_start(redrawTimer, redraw, 1, 0); DEBUG("redrawTimer...\n"); } From 9a5f62ea9f39ddbf00d914613583ff34d6488f68 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Thu, 19 Apr 2018 20:47:45 +0200 Subject: [PATCH 163/190] Restore timers substitutions --- examples/event-loop.js | 2 ++ index.js | 4 ++-- src/EventLoop.cc | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/event-loop.js b/examples/event-loop.js index b9f9871..ec66321 100644 --- a/examples/event-loop.js +++ b/examples/event-loop.js @@ -158,12 +158,14 @@ function makeToolbar() { server.close(); } server = http.createServer((req, res) => { + console.log('******** Connessione...') res.writeHead(200, {'Content-Type': 'text/plain'}); logAppend(`Http: request ${i}`); res.end(String(i++)); }); server.listen(8300, '127.0.0.1', () => { + console.log('******** listeining...') logAppend('listening...'); }); }); diff --git a/index.js b/index.js index 320caf2..1fb578e 100644 --- a/index.js +++ b/index.js @@ -254,6 +254,6 @@ module.exports.lineJoin = lineJoin; module.exports.fillMode = fillMode; module.exports.modifierKeys = modifierKeys; module.exports.extKeys = extKeys; -module.exports.startLoop = binding.lib.EventLoop.start; -module.exports.stopLoop = binding.lib.EventLoop.stop; +module.exports.startLoop = startLoop; +module.exports.stopLoop = stopLoop; module.exports.onShouldQuit = binding.lib.Ui.onShouldQuit; diff --git a/src/EventLoop.cc b/src/EventLoop.cc index 764e6c5..a561037 100644 --- a/src/EventLoop.cc +++ b/src/EventLoop.cc @@ -54,7 +54,7 @@ static void backgroundNodeEventsPoller(void *arg) { DEBUG_F("--- pendingEvents == %d\n", pendingEvents); - if (mainThreadStillWaitingGuiEvents) { + if (mainThreadStillWaitingGuiEvents && pendingEvents > 0) { DEBUG("--- wake up main thread\n"); // this allow the background thread // to wait for the main thread to complete @@ -91,7 +91,7 @@ void uv_awaken_cb(uv_prepare_t *handle) { // how to find a correct amount of time to scheduke next call? //.because too long and UI is not responsive, too short and node // become really slow - uv_timer_start(redrawTimer, redraw, 100, 0); + uv_timer_start(redrawTimer, redraw, 500, 0); } /* From 7e2a60b6b97b54d35aad1ef3c9d9991f50dbb91a Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 21 Apr 2018 19:29:57 +0200 Subject: [PATCH 164/190] [WIP] fixing app closure --- src/EventLoop.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/EventLoop.cc b/src/EventLoop.cc index a561037..6d50a78 100644 --- a/src/EventLoop.cc +++ b/src/EventLoop.cc @@ -54,7 +54,7 @@ static void backgroundNodeEventsPoller(void *arg) { DEBUG_F("--- pendingEvents == %d\n", pendingEvents); - if (mainThreadStillWaitingGuiEvents && pendingEvents > 0) { + if (running && mainThreadStillWaitingGuiEvents && pendingEvents > 0) { DEBUG("--- wake up main thread\n"); // this allow the background thread // to wait for the main thread to complete @@ -62,7 +62,7 @@ static void backgroundNodeEventsPoller(void *arg) { uiLoopWakeup(); } - if (pendingEvents > 0) { + if (running && pendingEvents > 0) { // wait for the main thread to complete // its awaken phase. DEBUG("--- mainThreadAwakenFromBackground locking.\n"); @@ -145,9 +145,11 @@ void redraw(uv_timer_t *handle) { // uv_timer_start(redrawTimer, redraw, 100, 0); - uv_prepare_start(&mainThreadAwakenPhase, uv_awaken_cb); + if (running) { + uv_prepare_start(&mainThreadAwakenPhase, uv_awaken_cb); - DEBUG("+++ prepare handler started.\n"); + DEBUG("+++ prepare handler started.\n"); + } } /* This function start the event loop and exit immediately */ @@ -177,10 +179,9 @@ void stopAsync(uv_timer_t *handle) { uv_thread_join(thread); uv_mutex_destroy(&mainThreadWaitingGuiEvents); - uv_mutex_destroy(&mainThreadAwakenFromBackground); - uv_close((uv_handle_t *)&mainThreadAwakenPhase, NULL); + // uv_close((uv_handle_t *)&mainThreadAwakenPhase, NULL); /* delete handle; From 3c8d62014089ca8a1fd8028ad3adab027793b8af Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 21 Apr 2018 20:03:12 +0200 Subject: [PATCH 165/190] Bump libui version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 506f57e..80f62f2 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Node.js bindings for libui", "repository": "parro-it/libui-node", "license": "MIT", - "libui": "alpha3.5-master-001", + "libui": "alpha3.5-master-002", "contributors": [ { "name": "Andrea Parodi", From 920717b30bdefbdd69bf4c1b4946498d93055eaf Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 21 Apr 2018 20:57:28 +0200 Subject: [PATCH 166/190] [WIP] trying async hook --- index.js | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ src/EventLoop.cc | 33 +++++++++++++++++++++++--------- 2 files changed, 74 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index 1fb578e..7ff2bc6 100644 --- a/index.js +++ b/index.js @@ -239,6 +239,56 @@ const extKeys = { nDivide: 39 }; +const async_hooks = require('async_hooks'); + +// Return the ID of the current execution context. +const eid = async_hooks.executionAsyncId(); + +// Return the ID of the handle responsible for triggering the callback of the +// current execution scope to call. +const tid = async_hooks.triggerAsyncId(); + +// Create a new AsyncHook instance. All of these callbacks are optional. +const asyncHook = + async_hooks.createHook({init /*, before, after, destroy, promiseResolve*/}); + +// Allow callbacks of this AsyncHook instance to call. This is not an implicit +// action after running the constructor, and must be explicitly run to begin +// executing callbacks. +asyncHook.enable(); + +// init is called during object construction. The resource may not have +// completed construction when this callback runs, therefore all fields of the +// resource referenced by "asyncId" may not have been populated. +function init(asyncId, type, triggerAsyncId, resource) { + // console.log('init', asyncId); + binding.lib.EventLoop.wakeupBackgroundThread(); +} + +// before is called just before the resource's callback is called. It can be +// called 0-N times for handles (e.g. TCPWrap), and will be called exactly 1 +// time for requests (e.g. FSReqWrap). +function before(asyncId) { + console.log('before', asyncId); +} + +// after is called just after the resource's callback has finished. +function after(asyncId) { + console.log('after', asyncId); +} + +// destroy is called when an AsyncWrap instance is destroyed. +function destroy(asyncId) { + console.log('destroy', asyncId); +} + +// promiseResolve is called only for promise resources, when the +// `resolve` function passed to the `Promise` constructor is invoked +// (either directly or through other means of resolving a promise). +function promiseResolve(asyncId) { + console.log('promiseResolve', asyncId); +} + module.exports.textStretch = textStretch; module.exports.textItalic = textItalic; module.exports.textWeight = textWeight; diff --git a/src/EventLoop.cc b/src/EventLoop.cc index 6d50a78..2933ce5 100644 --- a/src/EventLoop.cc +++ b/src/EventLoop.cc @@ -8,7 +8,7 @@ static std::atomic mainThreadStillWaitingGuiEvents; static uv_mutex_t mainThreadWaitingGuiEvents; static uv_mutex_t mainThreadAwakenFromBackground; static uv_prepare_t mainThreadAwakenPhase; -static uv_timer_t keepAliveTimer; +static uv_async_t keepAliveTimer; static uv_thread_t *thread; static uv_timer_t *redrawTimer; @@ -38,9 +38,12 @@ static void backgroundNodeEventsPoller(void *arg) { // hack: we should limit the max timout // in order to let new handler to be listened on. // this will be solved using a patched version of node + + /* if (timeout > 1000) { timeout = 1000; } + */ if (timeout != 0) { do { @@ -52,7 +55,8 @@ static void backgroundNodeEventsPoller(void *arg) { } while (pendingEvents == -1 && errno == EINTR); } - DEBUG_F("--- pendingEvents == %d\n", pendingEvents); + DEBUG_F("--- pendingEvents == %d, running = %u\n", pendingEvents, + unsigned(running)); if (running && mainThreadStillWaitingGuiEvents && pendingEvents > 0) { DEBUG("--- wake up main thread\n"); @@ -73,6 +77,7 @@ static void backgroundNodeEventsPoller(void *arg) { uv_mutex_unlock(&mainThreadAwakenFromBackground); } } + DEBUG("--- Background terminating.\n"); } void noop(uv_timer_t *handle) { @@ -88,10 +93,10 @@ void uv_awaken_cb(uv_prepare_t *handle) { DEBUG("+++ mainThreadAwakenFromBackground unlocked.\n"); // schedule another call to redraw as soon as possible - // how to find a correct amount of time to scheduke next call? + // how to find a correct amount of time to schedule next call? //.because too long and UI is not responsive, too short and node // become really slow - uv_timer_start(redrawTimer, redraw, 500, 0); + uv_timer_start(redrawTimer, redraw, 0, 0); } /* @@ -175,12 +180,18 @@ void stopAsync(uv_timer_t *handle) { uv_mutex_lock(&mainThreadAwakenFromBackground); /* await for the background thread to finish */ - DEBUG("uv_thread_join\n"); + DEBUG("uv_thread_join wait\n"); uv_thread_join(thread); + DEBUG("uv_thread_join done\n"); + + uv_mutex_unlock(&mainThreadAwakenFromBackground); uv_mutex_destroy(&mainThreadWaitingGuiEvents); uv_mutex_destroy(&mainThreadAwakenFromBackground); + /* stop keep alive timer */ + uv_close((uv_handle_t *)&keepAliveTimer, NULL); + // uv_close((uv_handle_t *)&mainThreadAwakenPhase, NULL); /* @@ -229,10 +240,9 @@ struct EventLoop { uv_thread_create(thread, backgroundNodeEventsPoller, NULL); DEBUG("thread...\n"); - /* bogus timer handler only used to keep process active */ - /* fires once per hour */ - uv_timer_init(uv_default_loop(), &keepAliveTimer); - uv_timer_start(&keepAliveTimer, noop, 1000 * 60 * 60, 1000 * 60 * 60); + // Add dummy handle for libuv, otherwise libuv would quit when there is + // nothing to do. + uv_async_init(uv_default_loop(), &keepAliveTimer, nullptr); /* start redraw timer */ redrawTimer = new uv_timer_t(); @@ -242,6 +252,10 @@ struct EventLoop { DEBUG("redrawTimer...\n"); } + static void wakeupBackgroundThread() { + uv_async_send(&keepAliveTimer); + } + /* This function start the event loop and exit immediately */ static void stop() { uv_timer_t *closeTimer = new uv_timer_t(); @@ -251,6 +265,7 @@ struct EventLoop { }; NBIND_CLASS(EventLoop) { + method(wakeupBackgroundThread); method(start); method(stop); } From 5d841126678a6ba2344d3035aeb99464cacb8045 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 21 Apr 2018 21:10:49 +0200 Subject: [PATCH 167/190] Enabled aync hook only on startLoop --- index.js | 93 ++++++++++++++++++++++++++------------------------------ 1 file changed, 43 insertions(+), 50 deletions(-) diff --git a/index.js b/index.js index 97a3369..13b6dfe 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,5 @@ const nbind = require('nbind'); +const async_hooks = require('async_hooks'); const binding = nbind.init(__dirname); @@ -36,6 +37,15 @@ function startLoop() { return; } + // Create a new AsyncHook instance. All of these callbacks are optional. + const asyncHook = + async_hooks.createHook({init /*, before, after, destroy, promiseResolve*/}); + + // Allow callbacks of this AsyncHook instance to call. This is not an implicit + // action after running the constructor, and must be explicitly run to begin + // executing callbacks. + asyncHook.enable(); + setTimeoutNode = global.setTimeout; global.setTimeout = function(cb, t) { const args = Array.prototype.slice.call(arguments, 2); @@ -59,6 +69,39 @@ function startLoop() { global.clearInterval = binding.lib.clearInterval; } +// init is called during object construction. The resource may not have +// completed construction when this callback runs, therefore all fields of the +// resource referenced by "asyncId" may not have been populated. +function init(asyncId, type, triggerAsyncId, resource) { + // console.log('init', asyncId); + binding.lib.EventLoop.wakeupBackgroundThread(); +} +/* +// before is called just before the resource's callback is called. It can be +// called 0-N times for handles (e.g. TCPWrap), and will be called exactly 1 +// time for requests (e.g. FSReqWrap). +function before(asyncId) { + console.log('before', asyncId); +} + +// after is called just after the resource's callback has finished. +function after(asyncId) { + console.log('after', asyncId); +} + +// destroy is called when an AsyncWrap instance is destroyed. +function destroy(asyncId) { + console.log('destroy', asyncId); +} + +// promiseResolve is called only for promise resources, when the +// `resolve` function passed to the `Promise` constructor is invoked +// (either directly or through other means of resolving a promise). +function promiseResolve(asyncId) { + console.log('promiseResolve', asyncId); +} +*/ + function Color(r, g, b, a) { this.r = r; this.g = g; @@ -368,56 +411,6 @@ const extKeys = { nDivide: 39 }; -const async_hooks = require('async_hooks'); - -// Return the ID of the current execution context. -const eid = async_hooks.executionAsyncId(); - -// Return the ID of the handle responsible for triggering the callback of the -// current execution scope to call. -const tid = async_hooks.triggerAsyncId(); - -// Create a new AsyncHook instance. All of these callbacks are optional. -const asyncHook = - async_hooks.createHook({init /*, before, after, destroy, promiseResolve*/}); - -// Allow callbacks of this AsyncHook instance to call. This is not an implicit -// action after running the constructor, and must be explicitly run to begin -// executing callbacks. -asyncHook.enable(); - -// init is called during object construction. The resource may not have -// completed construction when this callback runs, therefore all fields of the -// resource referenced by "asyncId" may not have been populated. -function init(asyncId, type, triggerAsyncId, resource) { - // console.log('init', asyncId); - binding.lib.EventLoop.wakeupBackgroundThread(); -} - -// before is called just before the resource's callback is called. It can be -// called 0-N times for handles (e.g. TCPWrap), and will be called exactly 1 -// time for requests (e.g. FSReqWrap). -function before(asyncId) { - console.log('before', asyncId); -} - -// after is called just after the resource's callback has finished. -function after(asyncId) { - console.log('after', asyncId); -} - -// destroy is called when an AsyncWrap instance is destroyed. -function destroy(asyncId) { - console.log('destroy', asyncId); -} - -// promiseResolve is called only for promise resources, when the -// `resolve` function passed to the `Promise` constructor is invoked -// (either directly or through other means of resolving a promise). -function promiseResolve(asyncId) { - console.log('promiseResolve', asyncId); -} - module.exports.textStretch = textStretch; module.exports.textItalic = textItalic; module.exports.textWeight = textWeight; From d69310879a543a01bc973fa2c0d48ebf327df848 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 21 Apr 2018 21:38:15 +0200 Subject: [PATCH 168/190] tweaks --- examples/event-loop.js | 5 ++++- index.js | 44 +++++++++++------------------------------- src/EventLoop.cc | 15 ++++---------- 3 files changed, 19 insertions(+), 45 deletions(-) diff --git a/examples/event-loop.js b/examples/event-loop.js index ec66321..9f66ca8 100644 --- a/examples/event-loop.js +++ b/examples/event-loop.js @@ -1,4 +1,5 @@ 'use strict'; +const http = require('http'); const libui = require('..'); let setIntervalHandle = null; @@ -149,13 +150,15 @@ function makeToolbar() { }); const btnHttp = new libui.UiButton('Http'); - const http = require('http'); let server = null; btnHttp.onClicked(() => { let i = 0; if (server) { server.close(); + server = null; + logAppend('server closed.'); + return; } server = http.createServer((req, res) => { console.log('******** Connessione...') diff --git a/index.js b/index.js index 13b6dfe..c0888e2 100644 --- a/index.js +++ b/index.js @@ -2,7 +2,7 @@ const nbind = require('nbind'); const async_hooks = require('async_hooks'); const binding = nbind.init(__dirname); - +let asyncHook = null; module.exports = binding.lib; binding.lib.Ui.init(); @@ -19,6 +19,8 @@ function stopLoop() { return; } + asyncHook.disable(); + global.setTimeout = setTimeoutNode; global.clearTimeout = clearTimeoutNode; global.setInterval = setIntervalNode; @@ -37,9 +39,9 @@ function startLoop() { return; } - // Create a new AsyncHook instance. All of these callbacks are optional. - const asyncHook = - async_hooks.createHook({init /*, before, after, destroy, promiseResolve*/}); + // Create a new AsyncHook instance. + + asyncHook = async_hooks.createHook({init}); // Allow callbacks of this AsyncHook instance to call. This is not an implicit // action after running the constructor, and must be explicitly run to begin @@ -47,6 +49,7 @@ function startLoop() { asyncHook.enable(); setTimeoutNode = global.setTimeout; + global.setTimeout = function(cb, t) { const args = Array.prototype.slice.call(arguments, 2); return binding.lib.setTimeout(function() { @@ -69,38 +72,13 @@ function startLoop() { global.clearInterval = binding.lib.clearInterval; } -// init is called during object construction. The resource may not have -// completed construction when this callback runs, therefore all fields of the -// resource referenced by "asyncId" may not have been populated. +// This is called when a new async handle +// is created. It's used to signal the background +// thread to stop awaiting calls and upgrade it's list of handles +// it's awaiting for. function init(asyncId, type, triggerAsyncId, resource) { - // console.log('init', asyncId); binding.lib.EventLoop.wakeupBackgroundThread(); } -/* -// before is called just before the resource's callback is called. It can be -// called 0-N times for handles (e.g. TCPWrap), and will be called exactly 1 -// time for requests (e.g. FSReqWrap). -function before(asyncId) { - console.log('before', asyncId); -} - -// after is called just after the resource's callback has finished. -function after(asyncId) { - console.log('after', asyncId); -} - -// destroy is called when an AsyncWrap instance is destroyed. -function destroy(asyncId) { - console.log('destroy', asyncId); -} - -// promiseResolve is called only for promise resources, when the -// `resolve` function passed to the `Promise` constructor is invoked -// (either directly or through other means of resolving a promise). -function promiseResolve(asyncId) { - console.log('promiseResolve', asyncId); -} -*/ function Color(r, g, b, a) { this.r = r; diff --git a/src/EventLoop.cc b/src/EventLoop.cc index 2933ce5..c0ba502 100644 --- a/src/EventLoop.cc +++ b/src/EventLoop.cc @@ -1,4 +1,3 @@ -#include #include "event-loop.h" static std::atomic running; @@ -35,16 +34,6 @@ static void backgroundNodeEventsPoller(void *arg) { int timeout = uv_backend_timeout(uv_default_loop()); DEBUG_F("--- uv_backend_timeout == %d\n", timeout); - // hack: we should limit the max timout - // in order to let new handler to be listened on. - // this will be solved using a patched version of node - - /* - if (timeout > 1000) { - timeout = 1000; - } - */ - if (timeout != 0) { do { @@ -252,6 +241,10 @@ struct EventLoop { DEBUG("redrawTimer...\n"); } + // this function signal make background + // to stop awaiting node events, allowing it + // to update the list of handles it's + // awaiting for. static void wakeupBackgroundThread() { uv_async_send(&keepAliveTimer); } From 859d74c533345c82cc1153bae3a983d8d3bc5bf4 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 21 Apr 2018 21:55:41 +0200 Subject: [PATCH 169/190] More fixing for closing --- examples/event-loop.js | 6 +++--- src/EventLoop.cc | 30 ++++++++++++++++-------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/examples/event-loop.js b/examples/event-loop.js index 9f66ca8..3df5356 100644 --- a/examples/event-loop.js +++ b/examples/event-loop.js @@ -99,14 +99,14 @@ function makeToolbar() { btnCustom.onClicked(() => { const now = Date.now(); const longTimeout = setTimeout((a, b, c) => { - logAppend(`THIS HOULD NOT HAPPEN!`); + logAppend(`THIS SHOULD NOT HAPPEN!`); }, 200); setTimeout((a, b, c) => { clearTimeout(longTimeout); - const elapsed = Date.now() - now; + // const elapsed = Date.now() - now; logAppend(`Custom setTimeout: ${now} - elapsed ${elapsed} ms. Args: ${a} ${b} ${c}`); - }, 10, 'custom', 'args', 2); + }, 10000, 'custom', 'args', 2); }); toolbar.append(btnCustom, false); diff --git a/src/EventLoop.cc b/src/EventLoop.cc index c0ba502..330b573 100644 --- a/src/EventLoop.cc +++ b/src/EventLoop.cc @@ -27,6 +27,7 @@ static void backgroundNodeEventsPoller(void *arg) { // wait for the main thread // to be blocked waiting for GUI events uv_mutex_lock(&mainThreadWaitingGuiEvents); + // immediately release the lock uv_mutex_unlock(&mainThreadWaitingGuiEvents); @@ -37,15 +38,13 @@ static void backgroundNodeEventsPoller(void *arg) { if (timeout != 0) { do { - DEBUG_F("--- entering waitForNodeEvents with timeout %d\n", - timeout); + DEBUG_F("--- entering wait with timeout %d\n", timeout); /* wait for pending events*/ pendingEvents = waitForNodeEvents(uv_default_loop(), timeout); } while (pendingEvents == -1 && errno == EINTR); } - DEBUG_F("--- pendingEvents == %d, running = %u\n", pendingEvents, - unsigned(running)); + DEBUG_F("--- pendingEvents == %d\n", pendingEvents); if (running && mainThreadStillWaitingGuiEvents && pendingEvents > 0) { DEBUG("--- wake up main thread\n"); @@ -77,6 +76,11 @@ void redraw(uv_timer_t *handle); void uv_awaken_cb(uv_prepare_t *handle) { uv_prepare_stop(&mainThreadAwakenPhase); + + if (!running) { + return; + } + DEBUG("+++ mainThreadAwakenFromBackground unlocking.\n"); uv_mutex_unlock(&mainThreadAwakenFromBackground); DEBUG("+++ mainThreadAwakenFromBackground unlocked.\n"); @@ -165,16 +169,20 @@ void stopAsync(uv_timer_t *handle) { DEBUG("handle\n"); uv_close((uv_handle_t *)handle, NULL); - uv_mutex_unlock(&mainThreadWaitingGuiEvents); - uv_mutex_lock(&mainThreadAwakenFromBackground); + if (uv_mutex_trylock(&mainThreadWaitingGuiEvents)) { + uv_mutex_unlock(&mainThreadWaitingGuiEvents); + } + + if (uv_mutex_trylock(&mainThreadAwakenFromBackground)) { + uv_mutex_unlock(&mainThreadAwakenFromBackground); + } /* await for the background thread to finish */ DEBUG("uv_thread_join wait\n"); + uv_async_send(&keepAliveTimer); uv_thread_join(thread); DEBUG("uv_thread_join done\n"); - uv_mutex_unlock(&mainThreadAwakenFromBackground); - uv_mutex_destroy(&mainThreadWaitingGuiEvents); uv_mutex_destroy(&mainThreadAwakenFromBackground); @@ -183,12 +191,6 @@ void stopAsync(uv_timer_t *handle) { // uv_close((uv_handle_t *)&mainThreadAwakenPhase, NULL); - /* - delete handle; - delete redrawTimer; - delete thread; - */ - /* quit libui event loop */ uiQuit(); } From bf155a43aa5cea624eefac36ce602a02900322c6 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 21 Apr 2018 22:01:39 +0200 Subject: [PATCH 170/190] Loop changes on windows & macOS --- src/arch/darwin/libui_loop.mm | 3 +-- src/arch/unix/libui_loop.cc | 2 -- src/arch/win32/libui_loop.cc | 5 ++++- src/arch/win32/usleep.cc | 14 -------------- src/includes/event-loop-darwin.h | 1 - src/includes/event-loop-linux.h | 1 - src/includes/event-loop-windows.h | 2 -- 7 files changed, 5 insertions(+), 23 deletions(-) delete mode 100644 src/arch/win32/usleep.cc diff --git a/src/arch/darwin/libui_loop.mm b/src/arch/darwin/libui_loop.mm index 54d6079..524ddd7 100644 --- a/src/arch/darwin/libui_loop.mm +++ b/src/arch/darwin/libui_loop.mm @@ -12,8 +12,7 @@ int uiLoopWakeup() { data1:0 data2:0] atStart:NO]; - // give main thread some time to react - // usleep(50 * 1000); + return 0; } diff --git a/src/arch/unix/libui_loop.cc b/src/arch/unix/libui_loop.cc index 055a270..fbae901 100644 --- a/src/arch/unix/libui_loop.cc +++ b/src/arch/unix/libui_loop.cc @@ -5,8 +5,6 @@ int uiLoopWakeup() { DEBUG("uiLoopWakeup\n"); g_main_context_wakeup(NULL); DEBUG("uiLoopWakeup exit\n"); - // give main thread some time to react - usleep(50 * 1000); return 0; } diff --git a/src/arch/win32/libui_loop.cc b/src/arch/win32/libui_loop.cc index a2a09ce..2cc6a7c 100644 --- a/src/arch/win32/libui_loop.cc +++ b/src/arch/win32/libui_loop.cc @@ -6,7 +6,6 @@ void noop(void *data) {} int uiLoopWakeup() { uiQueueMain(noop, NULL); // give main thread some time to react - usleep(50 * 1000); return 0; } @@ -22,6 +21,10 @@ int waitForNodeEvents(uv_loop_t *loop, int timeout) { struct _internal_uv_loop_s *_loop = (_internal_uv_loop_s *)loop; + if (timeout == -1) { + timeout = INFINITE; + } + int ret = GetQueuedCompletionStatus(_loop->iocp, &bytes, &key, &overlapped, timeout); diff --git a/src/arch/win32/usleep.cc b/src/arch/win32/usleep.cc deleted file mode 100644 index 30003d2..0000000 --- a/src/arch/win32/usleep.cc +++ /dev/null @@ -1,14 +0,0 @@ -#include - -void usleep(__int64 usec) { - HANDLE timer; - LARGE_INTEGER ft; - - ft.QuadPart = -(10 * usec); // Convert to 100 nanosecond interval, negative - // value indicates relative time - - timer = CreateWaitableTimer(NULL, TRUE, NULL); - SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0); - WaitForSingleObject(timer, INFINITE); - CloseHandle(timer); -} diff --git a/src/includes/event-loop-darwin.h b/src/includes/event-loop-darwin.h index ca5c62c..c1366b6 100644 --- a/src/includes/event-loop-darwin.h +++ b/src/includes/event-loop-darwin.h @@ -6,7 +6,6 @@ #include #include #include -#include #include #endif diff --git a/src/includes/event-loop-linux.h b/src/includes/event-loop-linux.h index e82e659..3086012 100644 --- a/src/includes/event-loop-linux.h +++ b/src/includes/event-loop-linux.h @@ -5,7 +5,6 @@ #include #include #include -#include #include #endif diff --git a/src/includes/event-loop-windows.h b/src/includes/event-loop-windows.h index 046f92a..fb3e837 100644 --- a/src/includes/event-loop-windows.h +++ b/src/includes/event-loop-windows.h @@ -1,8 +1,6 @@ #ifndef ui_node_event_loop_windows #define ui_node_event_loop_windows 1 -void usleep(__int64 usec); - #include struct _internal_uv_loop_s { From bd73bc827c3bf7998f77c8e1a715879351d28288 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 21 Apr 2018 22:27:44 +0200 Subject: [PATCH 171/190] Bump supported node version --- .travis.yml | 3 --- appveyor.yml | 3 --- package.json | 2 +- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index e3bdbde..0c919cb 100755 --- a/.travis.yml +++ b/.travis.yml @@ -9,9 +9,6 @@ language: node_js node_js: - '9' - '8' - - '6' - - '5' - - '4' sudo: required diff --git a/appveyor.yml b/appveyor.yml index a5036b0..a3532c9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,9 +6,6 @@ environment: matrix: - nodejs_version: "9" - nodejs_version: "8" - - nodejs_version: "6" - - nodejs_version: "5" - - nodejs_version: "4" install: - ps: Install-Product node $env:nodejs_version x64 diff --git a/package.json b/package.json index 5ae85e7..006dad4 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "GUI" ], "engines": { - "node": ">=4" + "node": ">=8" }, "files": [ "list-sources.js", From fce4b06e1a8b693e6cc924351ceba17d2d28a6df Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sat, 21 Apr 2018 23:17:47 +0200 Subject: [PATCH 172/190] Fixed example --- examples/event-loop.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/examples/event-loop.js b/examples/event-loop.js index 3df5356..be59c36 100644 --- a/examples/event-loop.js +++ b/examples/event-loop.js @@ -98,13 +98,9 @@ function makeToolbar() { const btnCustom = new libui.UiButton('Custom setTimeout'); btnCustom.onClicked(() => { const now = Date.now(); - const longTimeout = setTimeout((a, b, c) => { - logAppend(`THIS SHOULD NOT HAPPEN!`); - }, 200); setTimeout((a, b, c) => { - clearTimeout(longTimeout); - // const elapsed = Date.now() - now; + const elapsed = Date.now() - now; logAppend(`Custom setTimeout: ${now} - elapsed ${elapsed} ms. Args: ${a} ${b} ${c}`); }, 10000, 'custom', 'args', 2); }); From 5bd7d09219a3b29171c2cbf3d1ad28f132882e7e Mon Sep 17 00:00:00 2001 From: andrea parodi Date: Sat, 21 Apr 2018 14:47:49 -0700 Subject: [PATCH 173/190] tweaks --- examples/event-loop.js | 10 ++++++++-- src/EventLoop.cc | 2 +- src/includes/event-loop.h | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/examples/event-loop.js b/examples/event-loop.js index be59c36..fa078d5 100644 --- a/examples/event-loop.js +++ b/examples/event-loop.js @@ -26,11 +26,18 @@ box.append(form, true); const log = new libui.UiMultilineEntry(); box.append(log, true); +let server = null; + win.onClosing(() => { if (setIntervalHandle !== null) { clearInterval(setIntervalHandle); setIntervalHandle = null; } + if (server) { + server.close(); + server = null; + return; + } win.close(); libui.stopLoop(); setTimeout(() => console.log('after stopLoop'), 100); @@ -102,7 +109,7 @@ function makeToolbar() { setTimeout((a, b, c) => { const elapsed = Date.now() - now; logAppend(`Custom setTimeout: ${now} - elapsed ${elapsed} ms. Args: ${a} ${b} ${c}`); - }, 10000, 'custom', 'args', 2); + }, 10, 'custom', 'args', 2); }); toolbar.append(btnCustom, false); @@ -147,7 +154,6 @@ function makeToolbar() { const btnHttp = new libui.UiButton('Http'); - let server = null; btnHttp.onClicked(() => { let i = 0; if (server) { diff --git a/src/EventLoop.cc b/src/EventLoop.cc index 330b573..e2f5eac 100644 --- a/src/EventLoop.cc +++ b/src/EventLoop.cc @@ -89,7 +89,7 @@ void uv_awaken_cb(uv_prepare_t *handle) { // how to find a correct amount of time to schedule next call? //.because too long and UI is not responsive, too short and node // become really slow - uv_timer_start(redrawTimer, redraw, 0, 0); + uv_timer_start(redrawTimer, redraw, 10, 0); } /* diff --git a/src/includes/event-loop.h b/src/includes/event-loop.h index 55e7f38..c500e47 100644 --- a/src/includes/event-loop.h +++ b/src/includes/event-loop.h @@ -6,7 +6,7 @@ #include "nbind/nbind.h" #include "ui.h" -#define UI_NODE_DEBUG 1 +// #define UI_NODE_DEBUG 1 #ifdef UI_NODE_DEBUG #define DEBUG(msg) fprintf(stderr, msg) From e4ba55c8079624702abcf82c5762f3df72de621a Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sun, 22 Apr 2018 00:01:24 +0200 Subject: [PATCH 174/190] Other closing fixes --- src/EventLoop.cc | 11 +++++++++-- src/includes/event-loop.h | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/EventLoop.cc b/src/EventLoop.cc index e2f5eac..9c37825 100644 --- a/src/EventLoop.cc +++ b/src/EventLoop.cc @@ -184,12 +184,19 @@ void stopAsync(uv_timer_t *handle) { DEBUG("uv_thread_join done\n"); uv_mutex_destroy(&mainThreadWaitingGuiEvents); - uv_mutex_destroy(&mainThreadAwakenFromBackground); + DEBUG("uv_mutex_destroy mainThreadWaitingGuiEvents done\n"); + + // TODO: improve synchronization + // some examples crash while running this + // uv_mutex_destroy(&mainThreadAwakenFromBackground); + DEBUG("uv_mutex_destroy mainThreadAwakenFromBackground done\n"); /* stop keep alive timer */ uv_close((uv_handle_t *)&keepAliveTimer, NULL); - // uv_close((uv_handle_t *)&mainThreadAwakenPhase, NULL); + DEBUG("uv_close keepAliveTimer done\n"); + + uv_close((uv_handle_t *)&mainThreadAwakenPhase, NULL); /* quit libui event loop */ uiQuit(); diff --git a/src/includes/event-loop.h b/src/includes/event-loop.h index c500e47..55e7f38 100644 --- a/src/includes/event-loop.h +++ b/src/includes/event-loop.h @@ -6,7 +6,7 @@ #include "nbind/nbind.h" #include "ui.h" -// #define UI_NODE_DEBUG 1 +#define UI_NODE_DEBUG 1 #ifdef UI_NODE_DEBUG #define DEBUG(msg) fprintf(stderr, msg) From 23ae788f601ae63bedba7e8a3b8d33aaf7e77639 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sun, 22 Apr 2018 00:02:47 +0200 Subject: [PATCH 175/190] No debug --- src/includes/event-loop.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/includes/event-loop.h b/src/includes/event-loop.h index 55e7f38..c500e47 100644 --- a/src/includes/event-loop.h +++ b/src/includes/event-loop.h @@ -6,7 +6,7 @@ #include "nbind/nbind.h" #include "ui.h" -#define UI_NODE_DEBUG 1 +// #define UI_NODE_DEBUG 1 #ifdef UI_NODE_DEBUG #define DEBUG(msg) fprintf(stderr, msg) From 17f71ed8e865bf5ace5706191002e2e4366bf29d Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sun, 22 Apr 2018 18:11:38 +0200 Subject: [PATCH 176/190] Fix event loop on Sierra (or is on latest clang release?) --- examples/event-loop.js | 3 ++- index.js | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/examples/event-loop.js b/examples/event-loop.js index fa078d5..90aec6e 100644 --- a/examples/event-loop.js +++ b/examples/event-loop.js @@ -34,9 +34,9 @@ win.onClosing(() => { setIntervalHandle = null; } if (server) { + console.log('Closing server'); server.close(); server = null; - return; } win.close(); libui.stopLoop(); @@ -151,6 +151,7 @@ function makeToolbar() { logAppend(`ReadFile: chunk ${i++} - ` + data.length); }); }); + toolbar.append(btnReadFile, false); const btnHttp = new libui.UiButton('Http'); diff --git a/index.js b/index.js index c0888e2..26d16cf 100755 --- a/index.js +++ b/index.js @@ -76,8 +76,16 @@ function startLoop() { // is created. It's used to signal the background // thread to stop awaiting calls and upgrade it's list of handles // it's awaiting for. +let wakingup = false function init(asyncId, type, triggerAsyncId, resource) { - binding.lib.EventLoop.wakeupBackgroundThread(); + if (wakingup) { + return; + } + wakingup = true; + setImmediate(() => { + binding.lib.EventLoop.wakeupBackgroundThread(); + wakingup = false; + }); } function Color(r, g, b, a) { From 435572a5448d980a4f9b646cc73aae52e17053ad Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Sun, 22 Apr 2018 21:29:06 +0200 Subject: [PATCH 177/190] Add async_hooks polyfill --- index.js | 2 +- package-lock.json | 5 +++++ package.json | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 26d16cf..a7ae1e8 100755 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ const nbind = require('nbind'); -const async_hooks = require('async_hooks'); +const async_hooks = require('@creditkarma/async-hooks'); const binding = nbind.init(__dirname); let asyncHook = null; diff --git a/package-lock.json b/package-lock.json index 74e7635..a7f1f93 100644 --- a/package-lock.json +++ b/package-lock.json @@ -80,6 +80,11 @@ "arrify": "1.0.1" } }, + "@creditkarma/async-hooks": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/@creditkarma/async-hooks/-/async-hooks-0.0.3.tgz", + "integrity": "sha1-nWtMG2zDFbn3MVt6E3R6UelM+EA=" + }, "@ladjs/time-require": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/@ladjs/time-require/-/time-require-0.1.4.tgz", diff --git a/package.json b/package.json index 006dad4..5448828 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "GUI" ], "engines": { - "node": ">=8" + "node": ">=6" }, "files": [ "list-sources.js", @@ -62,6 +62,7 @@ "proc-stats": "0.0.4" }, "dependencies": { + "@creditkarma/async-hooks": "0.0.3", "autogypi": "^0.2.2", "libui-download": "^1.0.0", "nbind": "^0.3.14", From 11de8acc75c98a44413f9cea0e56658360ba2eeb Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Sun, 22 Apr 2018 22:37:10 +0200 Subject: [PATCH 178/190] async_hooks polyfill for node4+ --- examples/event-loop.js | 2 +- index.js | 3 ++- package.json | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/event-loop.js b/examples/event-loop.js index 90aec6e..e8b4ad1 100644 --- a/examples/event-loop.js +++ b/examples/event-loop.js @@ -144,7 +144,7 @@ function makeToolbar() { const btnReadFile = new libui.UiButton('ReadFile'); btnReadFile.onClicked(() => { - const {createReadStream} = require('fs'); + const createReadStream = require('fs').createReadStream; const stream = createReadStream('/tmp/big'); let i = 0; stream.on('data', data => { diff --git a/index.js b/index.js index a7ae1e8..481a6f8 100755 --- a/index.js +++ b/index.js @@ -1,5 +1,6 @@ +'use strict'; const nbind = require('nbind'); -const async_hooks = require('@creditkarma/async-hooks'); +const async_hooks = require('@mischnic/async-hooks'); const binding = nbind.init(__dirname); let asyncHook = null; diff --git a/package.json b/package.json index 5448828..7763157 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "GUI" ], "engines": { - "node": ">=6" + "node": ">=4" }, "files": [ "list-sources.js", @@ -62,7 +62,7 @@ "proc-stats": "0.0.4" }, "dependencies": { - "@creditkarma/async-hooks": "0.0.3", + "@mischnic/async-hooks": "^0.0.4", "autogypi": "^0.2.2", "libui-download": "^1.0.0", "nbind": "^0.3.14", From 06c2fcd3c638fbadf59d58da3694ac7e70314eba Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sun, 22 Apr 2018 23:01:33 +0200 Subject: [PATCH 179/190] Restore tests for version 4 & 6 in CI --- .travis.yml | 2 ++ appveyor.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 0c919cb..b3c7c77 100755 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,8 @@ language: node_js node_js: - '9' - '8' + - '6' + - '4' sudo: required diff --git a/appveyor.yml b/appveyor.yml index a3532c9..773ad05 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,6 +6,8 @@ environment: matrix: - nodejs_version: "9" - nodejs_version: "8" + - nodejs_version: "6" + - nodejs_version: "4" install: - ps: Install-Product node $env:nodejs_version x64 From 081770cb70279149cc363fdc802f7935fc2517e3 Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Tue, 24 Apr 2018 13:22:58 +0200 Subject: [PATCH 180/190] Fix examples on windows --- examples/area-adv.js | 1 + examples/event-loop.js | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/examples/area-adv.js b/examples/area-adv.js index 8cace24..ae5f7fe 100644 --- a/examples/area-adv.js +++ b/examples/area-adv.js @@ -39,6 +39,7 @@ function handlerDraw(area, p) { // ------ path = new libui.UiDrawPath(libui.fillMode.winding); + path.newFigure(0, 0); path.arcTo(250, 300, 50, 0, 2 * Math.PI, false); path.end(); p.getContext().fill(path, radialBrush); diff --git a/examples/event-loop.js b/examples/event-loop.js index e8b4ad1..9b7dca6 100644 --- a/examples/event-loop.js +++ b/examples/event-loop.js @@ -13,13 +13,21 @@ const box = new libui.UiVerticalBox(); box.padded = true; win.setChild(box); +const sliderbox = new libui.UiHorizontalBox(); +sliderbox.padded = true; + const setIntervalMs = new libui.UiSlider(0, 1000); setIntervalMs.onChanged(setIntervalChanged); setIntervalMs.value = 0; +const sliderLabel = new libui.UiLabel("0"); + +sliderbox.append(setIntervalMs, 1); +sliderbox.append(sliderLabel, 0); + const form = new libui.UiForm(); form.padded = true; -form.append('setInterval', setIntervalMs, 0); +form.append('setInterval', sliderbox, 0); form.append('actions', makeToolbar(), 0); box.append(form, true); @@ -46,12 +54,14 @@ win.onClosing(() => { win.show(); libui.startLoop(); +const linebreak = process.platform === "win32" ? '\r\n' : '\n'; + function logAppend(line) { - const lines = log.text.split('\n'); + const lines = log.text.split(linebreak); if (lines.length > 20) { - log.text = lines.slice(1).join('\n'); + log.text = lines.slice(1).join(linebreak); } - log.append(line + '\n'); + log.append(line + linebreak); } function setIntervalChanged() { @@ -59,6 +69,7 @@ function setIntervalChanged() { if (Math.abs(ms - lastTimeout) < 100) { return; } + sliderLabel.text = ms; lastTimeout = ms; if (setIntervalHandle !== null) { clearInterval(setIntervalHandle); From 232d9dbbe03c07580230abc756bad707194b2241 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Tue, 24 Apr 2018 16:45:31 +0200 Subject: [PATCH 181/190] Install older npm version, since latest does not run anymore on node 4 --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 773ad05..50b5855 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,7 +11,7 @@ environment: install: - ps: Install-Product node $env:nodejs_version x64 - - npm i npm@latest -g + - npm i npm@5.7 -g - npm install From 6386588f7038a38e3e2ca983fbfc8f2d45ccf8cd Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Wed, 25 Apr 2018 16:46:13 +0200 Subject: [PATCH 182/190] Really fix eventloop example --- examples/event-loop.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/event-loop.js b/examples/event-loop.js index 9b7dca6..e512d00 100644 --- a/examples/event-loop.js +++ b/examples/event-loop.js @@ -29,7 +29,7 @@ const form = new libui.UiForm(); form.padded = true; form.append('setInterval', sliderbox, 0); form.append('actions', makeToolbar(), 0); -box.append(form, true); +box.append(form, false); const log = new libui.UiMultilineEntry(); box.append(log, true); @@ -57,7 +57,7 @@ libui.startLoop(); const linebreak = process.platform === "win32" ? '\r\n' : '\n'; function logAppend(line) { - const lines = log.text.split(linebreak); + const lines = log.text.split("\n"); if (lines.length > 20) { log.text = lines.slice(1).join(linebreak); } From f3dd4eb420355cf5720dc0058a718867d18e8cbf Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Sat, 28 Apr 2018 22:14:09 +0200 Subject: [PATCH 183/190] Fix examples --- examples/event-loop.js | 13 ++++++------- examples/node-pad.js | 15 ++++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/event-loop.js b/examples/event-loop.js index e512d00..79f7044 100644 --- a/examples/event-loop.js +++ b/examples/event-loop.js @@ -1,5 +1,6 @@ 'use strict'; const http = require('http'); +const os = require('os'); const libui = require('..'); let setIntervalHandle = null; @@ -20,7 +21,7 @@ const setIntervalMs = new libui.UiSlider(0, 1000); setIntervalMs.onChanged(setIntervalChanged); setIntervalMs.value = 0; -const sliderLabel = new libui.UiLabel("0"); +const sliderLabel = new libui.UiLabel('0'); sliderbox.append(setIntervalMs, 1); sliderbox.append(sliderLabel, 0); @@ -54,14 +55,12 @@ win.onClosing(() => { win.show(); libui.startLoop(); -const linebreak = process.platform === "win32" ? '\r\n' : '\n'; - function logAppend(line) { - const lines = log.text.split("\n"); - if (lines.length > 20) { - log.text = lines.slice(1).join(linebreak); + const lines = log.text.split('\n'); + if (lines.length > 25) { + log.text = lines.slice(1).join(os.EOL); } - log.append(line + linebreak); + log.append(line + os.EOL); } function setIntervalChanged() { diff --git a/examples/node-pad.js b/examples/node-pad.js index fbb70fe..6abdd2b 100644 --- a/examples/node-pad.js +++ b/examples/node-pad.js @@ -26,6 +26,7 @@ let currentFileName = ''; function newFile() { editor.text = ''; currentFileName = ''; + status.text = 'Not saved'; } function openFile() { @@ -39,7 +40,7 @@ function openFile() { err.stack); } editor.text = content; - status.text = `Open ${filename}`; + status.text = filename; currentFileName = filename; }); } @@ -48,6 +49,7 @@ function openFile() { function saveFileAs() { const filename = libui.UiDialogs.saveFile(win); if (filename) { + currentFileName = filename; writeFile(currentFileName, editor.text, err => { if (err) { return libui.UiDialogs.msgBoxError( @@ -55,7 +57,6 @@ function saveFileAs() { 'Error while writing file', err.stack); } - currentFileName = filename; }); } } @@ -87,10 +88,10 @@ menu([ label: 'Open', click: openFile }, - { - label: 'Close current tab', - click: () => {} - }, + // { + // label: 'Close current tab', + // click: () => {} + // }, { label: 'Save', click: saveFile @@ -140,7 +141,7 @@ win = window( tab( {stretchy: true}, (editor = multilineEntry({stretchy: true, tabTitle: 'New file'}))), - (status = label({stretchy: false, text: 'File not changed'}))); + (status = label({stretchy: false, text: 'Not saved'}))); win.show(); libui.startLoop(); From 443a22afba808411b2af99bb9ebc9608357ebe07 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sun, 29 Apr 2018 18:28:24 +0200 Subject: [PATCH 184/190] update pkg lock --- package-lock.json | 1882 +++++++++++++++++++++++---------------------- 1 file changed, 945 insertions(+), 937 deletions(-) diff --git a/package-lock.json b/package-lock.json index a7f1f93..15768de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,18 +16,18 @@ "integrity": "sha512-oWqTnIGXW3k72UFidXzW0ONlO7hnO9x02S/QReJ7NBGeiBH9cUHY9+EfV6C8PXC6YJH++WrliEq03wMSJGNZFg==", "dev": true, "requires": { - "babel-plugin-check-es2015-constants": "6.22.0", - "babel-plugin-syntax-trailing-function-commas": "6.22.0", - "babel-plugin-transform-async-to-generator": "6.24.1", - "babel-plugin-transform-es2015-destructuring": "6.23.0", - "babel-plugin-transform-es2015-function-name": "6.24.1", - "babel-plugin-transform-es2015-modules-commonjs": "6.26.0", - "babel-plugin-transform-es2015-parameters": "6.24.1", - "babel-plugin-transform-es2015-spread": "6.22.0", - "babel-plugin-transform-es2015-sticky-regex": "6.24.1", - "babel-plugin-transform-es2015-unicode-regex": "6.24.1", - "babel-plugin-transform-exponentiation-operator": "6.24.1", - "package-hash": "1.2.0" + "babel-plugin-check-es2015-constants": "^6.8.0", + "babel-plugin-syntax-trailing-function-commas": "^6.20.0", + "babel-plugin-transform-async-to-generator": "^6.16.0", + "babel-plugin-transform-es2015-destructuring": "^6.19.0", + "babel-plugin-transform-es2015-function-name": "^6.9.0", + "babel-plugin-transform-es2015-modules-commonjs": "^6.18.0", + "babel-plugin-transform-es2015-parameters": "^6.21.0", + "babel-plugin-transform-es2015-spread": "^6.8.0", + "babel-plugin-transform-es2015-sticky-regex": "^6.8.0", + "babel-plugin-transform-es2015-unicode-regex": "^6.11.0", + "babel-plugin-transform-exponentiation-operator": "^6.8.0", + "package-hash": "^1.2.0" }, "dependencies": { "md5-hex": { @@ -36,7 +36,7 @@ "integrity": "sha1-0sSv6YPENwZiF5uMrRRSGRNQRsQ=", "dev": true, "requires": { - "md5-o-matic": "0.1.1" + "md5-o-matic": "^0.1.1" } }, "package-hash": { @@ -45,7 +45,7 @@ "integrity": "sha1-AD5WzVe3NqbtYRTMK4FUJnJ3DkQ=", "dev": true, "requires": { - "md5-hex": "1.3.0" + "md5-hex": "^1.3.0" } } } @@ -56,8 +56,8 @@ "integrity": "sha1-ze0RlqjY2TgaUJJAq5LpGl7Aafc=", "dev": true, "requires": { - "@ava/babel-plugin-throws-helper": "2.0.0", - "babel-plugin-espower": "2.4.0" + "@ava/babel-plugin-throws-helper": "^2.0.0", + "babel-plugin-espower": "^2.3.2" } }, "@ava/write-file-atomic": { @@ -66,9 +66,9 @@ "integrity": "sha512-BTNB3nGbEfJT+69wuqXFr/bQH7Vr7ihx2xGOMNqPgDGhwspoZhiWumDDZNjBy7AScmqS5CELIOGtPVXESyrnDA==", "dev": true, "requires": { - "graceful-fs": "4.1.11", - "imurmurhash": "0.1.4", - "slide": "1.1.6" + "graceful-fs": "^4.1.11", + "imurmurhash": "^0.1.4", + "slide": "^1.1.5" } }, "@concordance/react": { @@ -77,24 +77,19 @@ "integrity": "sha512-htrsRaQX8Iixlsek8zQU7tE8wcsTQJ5UhZkSPEA8slCDAisKpC/2VgU/ucPn32M5/LjGGXRaUEKvEw1Wiuu4zQ==", "dev": true, "requires": { - "arrify": "1.0.1" + "arrify": "^1.0.1" } }, - "@creditkarma/async-hooks": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/@creditkarma/async-hooks/-/async-hooks-0.0.3.tgz", - "integrity": "sha1-nWtMG2zDFbn3MVt6E3R6UelM+EA=" - }, "@ladjs/time-require": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/@ladjs/time-require/-/time-require-0.1.4.tgz", "integrity": "sha512-weIbJqTMfQ4r1YX85u54DKfjLZs2jwn1XZ6tIOP/pFgMwhIN5BAtaCp/1wn9DzyLsDR9tW0R2NIePcVJ45ivQQ==", "dev": true, "requires": { - "chalk": "0.4.0", - "date-time": "0.1.1", - "pretty-ms": "0.2.2", - "text-table": "0.2.0" + "chalk": "^0.4.0", + "date-time": "^0.1.1", + "pretty-ms": "^0.2.1", + "text-table": "^0.2.0" }, "dependencies": { "ansi-styles": { @@ -109,9 +104,9 @@ "integrity": "sha1-UZmj3c0MHv4jvAjBsCewYXbgxk8=", "dev": true, "requires": { - "ansi-styles": "1.0.0", - "has-color": "0.1.7", - "strip-ansi": "0.1.1" + "ansi-styles": "~1.0.0", + "has-color": "~0.1.0", + "strip-ansi": "~0.1.0" } }, "pretty-ms": { @@ -120,7 +115,7 @@ "integrity": "sha1-2oeaaC/zOjcBEEbxPWJ/Z8c7hPY=", "dev": true, "requires": { - "parse-ms": "0.1.2" + "parse-ms": "^0.1.0" } }, "strip-ansi": { @@ -131,6 +126,14 @@ } } }, + "@mischnic/async-hooks": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/@mischnic/async-hooks/-/async-hooks-0.0.4.tgz", + "integrity": "sha512-mJL/Rckke7oIR8c1Dk+40Y0a+Ss712hyJqROOurl5VE8gQY+GbbebKcNuWIRxlZTrQQq8mfo7oE9xKZXrtQTjQ==", + "requires": { + "es6-shim": "^0.35.3" + } + }, "abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", @@ -141,10 +144,10 @@ "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", "requires": { - "co": "4.6.0", - "fast-deep-equal": "1.1.0", - "fast-json-stable-stringify": "2.0.0", - "json-schema-traverse": "0.3.1" + "co": "^4.6.0", + "fast-deep-equal": "^1.0.0", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.3.0" } }, "ansi-align": { @@ -153,7 +156,7 @@ "integrity": "sha1-w2rsy6VjuJzrVW82kPCx2eNUf38=", "dev": true, "requires": { - "string-width": "2.1.1" + "string-width": "^2.0.0" }, "dependencies": { "ansi-regex": { @@ -174,8 +177,8 @@ "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", "dev": true, "requires": { - "is-fullwidth-code-point": "2.0.0", - "strip-ansi": "4.0.0" + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" } }, "strip-ansi": { @@ -184,7 +187,7 @@ "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "dev": true, "requires": { - "ansi-regex": "3.0.0" + "ansi-regex": "^3.0.0" } } } @@ -206,7 +209,7 @@ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "color-convert": "1.9.1" + "color-convert": "^1.9.0" } }, "anymatch": { @@ -215,8 +218,8 @@ "integrity": "sha512-0XNayC8lTHQ2OI8aljNCN3sSx6hsr/1+rlcDAotXJR7C1oZZHCNsfpbKwMjRA3Uqb5tF1Rae2oloTr4xpq+WjA==", "dev": true, "requires": { - "micromatch": "2.3.11", - "normalize-path": "2.1.1" + "micromatch": "^2.1.5", + "normalize-path": "^2.0.0" } }, "aproba": { @@ -229,8 +232,8 @@ "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.4.tgz", "integrity": "sha1-u13KOCu5TwXhUZQ3PRb9O6HKEQ0=", "requires": { - "delegates": "1.0.0", - "readable-stream": "2.3.6" + "delegates": "^1.0.0", + "readable-stream": "^2.0.6" } }, "argparse": { @@ -239,7 +242,7 @@ "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { - "sprintf-js": "1.0.3" + "sprintf-js": "~1.0.2" } }, "arr-diff": { @@ -248,7 +251,7 @@ "integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=", "dev": true, "requires": { - "arr-flatten": "1.1.0" + "arr-flatten": "^1.0.1" } }, "arr-exclude": { @@ -281,7 +284,7 @@ "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", "dev": true, "requires": { - "array-uniq": "1.0.3" + "array-uniq": "^1.0.1" } }, "array-uniq": { @@ -340,9 +343,9 @@ "resolved": "https://registry.npmjs.org/autogypi/-/autogypi-0.2.2.tgz", "integrity": "sha1-JYurX3hXdVsJvqxqZB/qEw/0Yi0=", "requires": { - "bluebird": "3.5.1", - "commander": "2.9.0", - "resolve": "1.1.7" + "bluebird": "^3.4.0", + "commander": "~2.9.0", + "resolve": "~1.1.7" } }, "ava": { @@ -351,89 +354,89 @@ "integrity": "sha512-4lGNJCf6xL8SvsKVEKxEE46se7JAUIAZoKHw9itTQuwcsydhpAMkBs5gOOiWiwt0JKNIuXWc2/r4r8ZdcNrBEw==", "dev": true, "requires": { - "@ava/babel-preset-stage-4": "1.1.0", - "@ava/babel-preset-transform-test-files": "3.0.0", - "@ava/write-file-atomic": "2.2.0", - "@concordance/react": "1.0.0", - "@ladjs/time-require": "0.1.4", - "ansi-escapes": "3.1.0", - "ansi-styles": "3.2.1", - "arr-flatten": "1.1.0", - "array-union": "1.0.2", - "array-uniq": "1.0.3", - "arrify": "1.0.1", - "auto-bind": "1.2.0", - "ava-init": "0.2.1", - "babel-core": "6.26.0", - "babel-generator": "6.26.1", - "babel-plugin-syntax-object-rest-spread": "6.13.0", - "bluebird": "3.5.1", - "caching-transform": "1.0.1", - "chalk": "2.4.0", - "chokidar": "1.7.0", - "clean-stack": "1.3.0", - "clean-yaml-object": "0.1.0", - "cli-cursor": "2.1.0", - "cli-spinners": "1.3.1", - "cli-truncate": "1.1.0", - "co-with-promise": "4.6.0", - "code-excerpt": "2.1.1", - "common-path-prefix": "1.0.0", - "concordance": "3.0.0", - "convert-source-map": "1.5.1", - "core-assert": "0.2.1", - "currently-unhandled": "0.4.1", - "debug": "3.1.0", - "dot-prop": "4.2.0", - "empower-core": "0.6.2", - "equal-length": "1.0.1", - "figures": "2.0.0", - "find-cache-dir": "1.0.0", - "fn-name": "2.0.1", - "get-port": "3.2.0", - "globby": "6.1.0", - "has-flag": "2.0.0", - "hullabaloo-config-manager": "1.1.1", - "ignore-by-default": "1.0.1", - "import-local": "0.1.1", - "indent-string": "3.2.0", - "is-ci": "1.1.0", - "is-generator-fn": "1.0.0", - "is-obj": "1.0.1", - "is-observable": "1.1.0", - "is-promise": "2.1.0", - "last-line-stream": "1.0.0", - "lodash.clonedeepwith": "4.5.0", - "lodash.debounce": "4.0.8", - "lodash.difference": "4.5.0", - "lodash.flatten": "4.4.0", - "loud-rejection": "1.6.0", - "make-dir": "1.2.0", - "matcher": "1.1.0", - "md5-hex": "2.0.0", - "meow": "3.7.0", - "ms": "2.0.0", - "multimatch": "2.1.0", - "observable-to-promise": "0.5.0", - "option-chain": "1.0.0", - "package-hash": "2.0.0", - "pkg-conf": "2.1.0", - "plur": "2.1.2", - "pretty-ms": "3.1.0", - "require-precompiled": "0.1.0", - "resolve-cwd": "2.0.0", - "safe-buffer": "5.1.1", - "semver": "5.5.0", - "slash": "1.0.0", - "source-map-support": "0.5.4", - "stack-utils": "1.0.1", - "strip-ansi": "4.0.0", - "strip-bom-buf": "1.0.0", - "supertap": "1.0.0", - "supports-color": "5.4.0", - "trim-off-newlines": "1.0.1", - "unique-temp-dir": "1.0.0", - "update-notifier": "2.5.0" + "@ava/babel-preset-stage-4": "^1.1.0", + "@ava/babel-preset-transform-test-files": "^3.0.0", + "@ava/write-file-atomic": "^2.2.0", + "@concordance/react": "^1.0.0", + "@ladjs/time-require": "^0.1.4", + "ansi-escapes": "^3.0.0", + "ansi-styles": "^3.1.0", + "arr-flatten": "^1.0.1", + "array-union": "^1.0.1", + "array-uniq": "^1.0.2", + "arrify": "^1.0.0", + "auto-bind": "^1.1.0", + "ava-init": "^0.2.0", + "babel-core": "^6.17.0", + "babel-generator": "^6.26.0", + "babel-plugin-syntax-object-rest-spread": "^6.13.0", + "bluebird": "^3.0.0", + "caching-transform": "^1.0.0", + "chalk": "^2.0.1", + "chokidar": "^1.4.2", + "clean-stack": "^1.1.1", + "clean-yaml-object": "^0.1.0", + "cli-cursor": "^2.1.0", + "cli-spinners": "^1.0.0", + "cli-truncate": "^1.0.0", + "co-with-promise": "^4.6.0", + "code-excerpt": "^2.1.1", + "common-path-prefix": "^1.0.0", + "concordance": "^3.0.0", + "convert-source-map": "^1.5.1", + "core-assert": "^0.2.0", + "currently-unhandled": "^0.4.1", + "debug": "^3.0.1", + "dot-prop": "^4.1.0", + "empower-core": "^0.6.1", + "equal-length": "^1.0.0", + "figures": "^2.0.0", + "find-cache-dir": "^1.0.0", + "fn-name": "^2.0.0", + "get-port": "^3.0.0", + "globby": "^6.0.0", + "has-flag": "^2.0.0", + "hullabaloo-config-manager": "^1.1.0", + "ignore-by-default": "^1.0.0", + "import-local": "^0.1.1", + "indent-string": "^3.0.0", + "is-ci": "^1.0.7", + "is-generator-fn": "^1.0.0", + "is-obj": "^1.0.0", + "is-observable": "^1.0.0", + "is-promise": "^2.1.0", + "last-line-stream": "^1.0.0", + "lodash.clonedeepwith": "^4.5.0", + "lodash.debounce": "^4.0.3", + "lodash.difference": "^4.3.0", + "lodash.flatten": "^4.2.0", + "loud-rejection": "^1.2.0", + "make-dir": "^1.0.0", + "matcher": "^1.0.0", + "md5-hex": "^2.0.0", + "meow": "^3.7.0", + "ms": "^2.0.0", + "multimatch": "^2.1.0", + "observable-to-promise": "^0.5.0", + "option-chain": "^1.0.0", + "package-hash": "^2.0.0", + "pkg-conf": "^2.0.0", + "plur": "^2.0.0", + "pretty-ms": "^3.0.0", + "require-precompiled": "^0.1.0", + "resolve-cwd": "^2.0.0", + "safe-buffer": "^5.1.1", + "semver": "^5.4.1", + "slash": "^1.0.0", + "source-map-support": "^0.5.0", + "stack-utils": "^1.0.1", + "strip-ansi": "^4.0.0", + "strip-bom-buf": "^1.0.0", + "supertap": "^1.0.0", + "supports-color": "^5.0.0", + "trim-off-newlines": "^1.0.1", + "unique-temp-dir": "^1.0.0", + "update-notifier": "^2.3.0" }, "dependencies": { "ansi-regex": { @@ -463,7 +466,7 @@ "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "dev": true, "requires": { - "ansi-regex": "3.0.0" + "ansi-regex": "^3.0.0" } } } @@ -474,11 +477,11 @@ "integrity": "sha512-lXwK5LM+2g1euDRqW1mcSX/tqzY1QU7EjKpqayFPPtNRmbSYZ8RzPO5tqluTToijmtjp2M+pNpVdbcHssC4glg==", "dev": true, "requires": { - "arr-exclude": "1.0.0", - "execa": "0.7.0", - "has-yarn": "1.0.0", - "read-pkg-up": "2.0.0", - "write-pkg": "3.1.0" + "arr-exclude": "^1.0.0", + "execa": "^0.7.0", + "has-yarn": "^1.0.0", + "read-pkg-up": "^2.0.0", + "write-pkg": "^3.1.0" } }, "aws-sign2": { @@ -497,9 +500,9 @@ "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", "dev": true, "requires": { - "chalk": "1.1.3", - "esutils": "2.0.2", - "js-tokens": "3.0.2" + "chalk": "^1.1.3", + "esutils": "^2.0.2", + "js-tokens": "^3.0.2" }, "dependencies": { "ansi-styles": { @@ -514,11 +517,11 @@ "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { - "ansi-styles": "2.2.1", - "escape-string-regexp": "1.0.5", - "has-ansi": "2.0.0", - "strip-ansi": "3.0.1", - "supports-color": "2.0.0" + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" } }, "supports-color": { @@ -535,25 +538,25 @@ "integrity": "sha1-rzL3izGm/O8RnIew/Y2XU/A6C7g=", "dev": true, "requires": { - "babel-code-frame": "6.26.0", - "babel-generator": "6.26.1", - "babel-helpers": "6.24.1", - "babel-messages": "6.23.0", - "babel-register": "6.26.0", - "babel-runtime": "6.26.0", - "babel-template": "6.26.0", - "babel-traverse": "6.26.0", - "babel-types": "6.26.0", - "babylon": "6.18.0", - "convert-source-map": "1.5.1", - "debug": "2.6.9", - "json5": "0.5.1", - "lodash": "4.17.5", - "minimatch": "3.0.4", - "path-is-absolute": "1.0.1", - "private": "0.1.8", - "slash": "1.0.0", - "source-map": "0.5.7" + "babel-code-frame": "^6.26.0", + "babel-generator": "^6.26.0", + "babel-helpers": "^6.24.1", + "babel-messages": "^6.23.0", + "babel-register": "^6.26.0", + "babel-runtime": "^6.26.0", + "babel-template": "^6.26.0", + "babel-traverse": "^6.26.0", + "babel-types": "^6.26.0", + "babylon": "^6.18.0", + "convert-source-map": "^1.5.0", + "debug": "^2.6.8", + "json5": "^0.5.1", + "lodash": "^4.17.4", + "minimatch": "^3.0.4", + "path-is-absolute": "^1.0.1", + "private": "^0.1.7", + "slash": "^1.0.0", + "source-map": "^0.5.6" } }, "babel-generator": { @@ -562,14 +565,14 @@ "integrity": "sha512-HyfwY6ApZj7BYTcJURpM5tznulaBvyio7/0d4zFOeMPUmfxkCjHocCuoLa2SAGzBI8AREcH3eP3758F672DppA==", "dev": true, "requires": { - "babel-messages": "6.23.0", - "babel-runtime": "6.26.0", - "babel-types": "6.26.0", - "detect-indent": "4.0.0", - "jsesc": "1.3.0", - "lodash": "4.17.5", - "source-map": "0.5.7", - "trim-right": "1.0.1" + "babel-messages": "^6.23.0", + "babel-runtime": "^6.26.0", + "babel-types": "^6.26.0", + "detect-indent": "^4.0.0", + "jsesc": "^1.3.0", + "lodash": "^4.17.4", + "source-map": "^0.5.7", + "trim-right": "^1.0.1" }, "dependencies": { "jsesc": { @@ -586,9 +589,9 @@ "integrity": "sha1-zORReto1b0IgvK6KAsKzRvmlZmQ=", "dev": true, "requires": { - "babel-helper-explode-assignable-expression": "6.24.1", - "babel-runtime": "6.26.0", - "babel-types": "6.26.0" + "babel-helper-explode-assignable-expression": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" } }, "babel-helper-call-delegate": { @@ -597,10 +600,10 @@ "integrity": "sha1-7Oaqzdx25Bw0YfiL/Fdb0Nqi340=", "dev": true, "requires": { - "babel-helper-hoist-variables": "6.24.1", - "babel-runtime": "6.26.0", - "babel-traverse": "6.26.0", - "babel-types": "6.26.0" + "babel-helper-hoist-variables": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" } }, "babel-helper-explode-assignable-expression": { @@ -609,9 +612,9 @@ "integrity": "sha1-8luCz33BBDPFX3BZLVdGQArCLKo=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-traverse": "6.26.0", - "babel-types": "6.26.0" + "babel-runtime": "^6.22.0", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" } }, "babel-helper-function-name": { @@ -620,11 +623,11 @@ "integrity": "sha1-00dbjAPtmCQqJbSDUasYOZ01gKk=", "dev": true, "requires": { - "babel-helper-get-function-arity": "6.24.1", - "babel-runtime": "6.26.0", - "babel-template": "6.26.0", - "babel-traverse": "6.26.0", - "babel-types": "6.26.0" + "babel-helper-get-function-arity": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" } }, "babel-helper-get-function-arity": { @@ -633,8 +636,8 @@ "integrity": "sha1-j3eCqpNAfEHTqlCQj4mwMbG2hT0=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-types": "6.26.0" + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" } }, "babel-helper-hoist-variables": { @@ -643,8 +646,8 @@ "integrity": "sha1-HssnaJydJVE+rbyZFKc/VAi+enY=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-types": "6.26.0" + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" } }, "babel-helper-regex": { @@ -653,9 +656,9 @@ "integrity": "sha1-MlxZ+QL4LyS3T6zu0DY5VPZJXnI=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-types": "6.26.0", - "lodash": "4.17.5" + "babel-runtime": "^6.26.0", + "babel-types": "^6.26.0", + "lodash": "^4.17.4" } }, "babel-helper-remap-async-to-generator": { @@ -664,11 +667,11 @@ "integrity": "sha1-XsWBgnrXI/7N04HxySg5BnbkVRs=", "dev": true, "requires": { - "babel-helper-function-name": "6.24.1", - "babel-runtime": "6.26.0", - "babel-template": "6.26.0", - "babel-traverse": "6.26.0", - "babel-types": "6.26.0" + "babel-helper-function-name": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" } }, "babel-helpers": { @@ -677,8 +680,8 @@ "integrity": "sha1-NHHenK7DiOXIUOWX5Yom3fN2ArI=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-template": "6.26.0" + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1" } }, "babel-messages": { @@ -687,7 +690,7 @@ "integrity": "sha1-8830cDhYA1sqKVHG7F7fbGLyYw4=", "dev": true, "requires": { - "babel-runtime": "6.26.0" + "babel-runtime": "^6.22.0" } }, "babel-plugin-check-es2015-constants": { @@ -696,7 +699,7 @@ "integrity": "sha1-NRV7EBQm/S/9PaP3XH0ekYNbv4o=", "dev": true, "requires": { - "babel-runtime": "6.26.0" + "babel-runtime": "^6.22.0" } }, "babel-plugin-espower": { @@ -705,13 +708,13 @@ "integrity": "sha512-/+SRpy7pKgTI28oEHfn1wkuM5QFAdRq8WNsOOih1dVrdV6A/WbNbRZyl0eX5eyDgtb0lOE27PeDFuCX2j8OxVg==", "dev": true, "requires": { - "babel-generator": "6.26.1", - "babylon": "6.18.0", - "call-matcher": "1.0.1", - "core-js": "2.5.5", - "espower-location-detector": "1.0.0", - "espurify": "1.7.0", - "estraverse": "4.2.0" + "babel-generator": "^6.1.0", + "babylon": "^6.1.0", + "call-matcher": "^1.0.0", + "core-js": "^2.0.0", + "espower-location-detector": "^1.0.0", + "espurify": "^1.6.0", + "estraverse": "^4.1.1" } }, "babel-plugin-syntax-async-functions": { @@ -744,9 +747,9 @@ "integrity": "sha1-ZTbjeK/2yx1VF6wOQOs+n8jQh2E=", "dev": true, "requires": { - "babel-helper-remap-async-to-generator": "6.24.1", - "babel-plugin-syntax-async-functions": "6.13.0", - "babel-runtime": "6.26.0" + "babel-helper-remap-async-to-generator": "^6.24.1", + "babel-plugin-syntax-async-functions": "^6.8.0", + "babel-runtime": "^6.22.0" } }, "babel-plugin-transform-es2015-destructuring": { @@ -755,7 +758,7 @@ "integrity": "sha1-mXux8auWf2gtKwh2/jWNYOdlxW0=", "dev": true, "requires": { - "babel-runtime": "6.26.0" + "babel-runtime": "^6.22.0" } }, "babel-plugin-transform-es2015-function-name": { @@ -764,9 +767,9 @@ "integrity": "sha1-g0yJhTvDaxrw86TF26qU/Y6sqos=", "dev": true, "requires": { - "babel-helper-function-name": "6.24.1", - "babel-runtime": "6.26.0", - "babel-types": "6.26.0" + "babel-helper-function-name": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" } }, "babel-plugin-transform-es2015-modules-commonjs": { @@ -775,10 +778,10 @@ "integrity": "sha1-DYOUApt9xqvhqX7xgeAHWN0uXYo=", "dev": true, "requires": { - "babel-plugin-transform-strict-mode": "6.24.1", - "babel-runtime": "6.26.0", - "babel-template": "6.26.0", - "babel-types": "6.26.0" + "babel-plugin-transform-strict-mode": "^6.24.1", + "babel-runtime": "^6.26.0", + "babel-template": "^6.26.0", + "babel-types": "^6.26.0" } }, "babel-plugin-transform-es2015-parameters": { @@ -787,12 +790,12 @@ "integrity": "sha1-V6w1GrScrxSpfNE7CfZv3wpiXys=", "dev": true, "requires": { - "babel-helper-call-delegate": "6.24.1", - "babel-helper-get-function-arity": "6.24.1", - "babel-runtime": "6.26.0", - "babel-template": "6.26.0", - "babel-traverse": "6.26.0", - "babel-types": "6.26.0" + "babel-helper-call-delegate": "^6.24.1", + "babel-helper-get-function-arity": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" } }, "babel-plugin-transform-es2015-spread": { @@ -801,7 +804,7 @@ "integrity": "sha1-1taKmfia7cRTbIGlQujdnxdG+NE=", "dev": true, "requires": { - "babel-runtime": "6.26.0" + "babel-runtime": "^6.22.0" } }, "babel-plugin-transform-es2015-sticky-regex": { @@ -810,9 +813,9 @@ "integrity": "sha1-AMHNsaynERLN8M9hJsLta0V8zbw=", "dev": true, "requires": { - "babel-helper-regex": "6.26.0", - "babel-runtime": "6.26.0", - "babel-types": "6.26.0" + "babel-helper-regex": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" } }, "babel-plugin-transform-es2015-unicode-regex": { @@ -821,9 +824,9 @@ "integrity": "sha1-04sS9C6nMj9yk4fxinxa4frrNek=", "dev": true, "requires": { - "babel-helper-regex": "6.26.0", - "babel-runtime": "6.26.0", - "regexpu-core": "2.0.0" + "babel-helper-regex": "^6.24.1", + "babel-runtime": "^6.22.0", + "regexpu-core": "^2.0.0" } }, "babel-plugin-transform-exponentiation-operator": { @@ -832,9 +835,9 @@ "integrity": "sha1-KrDJx/MJj6SJB3cruBP+QejeOg4=", "dev": true, "requires": { - "babel-helper-builder-binary-assignment-operator-visitor": "6.24.1", - "babel-plugin-syntax-exponentiation-operator": "6.13.0", - "babel-runtime": "6.26.0" + "babel-helper-builder-binary-assignment-operator-visitor": "^6.24.1", + "babel-plugin-syntax-exponentiation-operator": "^6.8.0", + "babel-runtime": "^6.22.0" } }, "babel-plugin-transform-strict-mode": { @@ -843,8 +846,8 @@ "integrity": "sha1-1fr3qleKZbvlkc9e2uBKDGcCB1g=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-types": "6.26.0" + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" } }, "babel-register": { @@ -853,13 +856,13 @@ "integrity": "sha1-btAhFz4vy0htestFxgCahW9kcHE=", "dev": true, "requires": { - "babel-core": "6.26.0", - "babel-runtime": "6.26.0", - "core-js": "2.5.5", - "home-or-tmp": "2.0.0", - "lodash": "4.17.5", - "mkdirp": "0.5.1", - "source-map-support": "0.4.18" + "babel-core": "^6.26.0", + "babel-runtime": "^6.26.0", + "core-js": "^2.5.0", + "home-or-tmp": "^2.0.0", + "lodash": "^4.17.4", + "mkdirp": "^0.5.1", + "source-map-support": "^0.4.15" }, "dependencies": { "source-map-support": { @@ -868,7 +871,7 @@ "integrity": "sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA==", "dev": true, "requires": { - "source-map": "0.5.7" + "source-map": "^0.5.6" } } } @@ -879,8 +882,8 @@ "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", "dev": true, "requires": { - "core-js": "2.5.5", - "regenerator-runtime": "0.11.1" + "core-js": "^2.4.0", + "regenerator-runtime": "^0.11.0" }, "dependencies": { "regenerator-runtime": { @@ -897,11 +900,11 @@ "integrity": "sha1-3gPi0WOWsGn0bdn/+FIfsaDjXgI=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-traverse": "6.26.0", - "babel-types": "6.26.0", - "babylon": "6.18.0", - "lodash": "4.17.5" + "babel-runtime": "^6.26.0", + "babel-traverse": "^6.26.0", + "babel-types": "^6.26.0", + "babylon": "^6.18.0", + "lodash": "^4.17.4" } }, "babel-traverse": { @@ -910,15 +913,15 @@ "integrity": "sha1-RqnL1+3MYsjlwGTi0tjQ9ANXZu4=", "dev": true, "requires": { - "babel-code-frame": "6.26.0", - "babel-messages": "6.23.0", - "babel-runtime": "6.26.0", - "babel-types": "6.26.0", - "babylon": "6.18.0", - "debug": "2.6.9", - "globals": "9.18.0", - "invariant": "2.2.4", - "lodash": "4.17.5" + "babel-code-frame": "^6.26.0", + "babel-messages": "^6.23.0", + "babel-runtime": "^6.26.0", + "babel-types": "^6.26.0", + "babylon": "^6.18.0", + "debug": "^2.6.8", + "globals": "^9.18.0", + "invariant": "^2.2.2", + "lodash": "^4.17.4" } }, "babel-types": { @@ -927,10 +930,10 @@ "integrity": "sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "esutils": "2.0.2", - "lodash": "4.17.5", - "to-fast-properties": "1.0.3" + "babel-runtime": "^6.26.0", + "esutils": "^2.0.2", + "lodash": "^4.17.4", + "to-fast-properties": "^1.0.3" } }, "babylon": { @@ -950,7 +953,7 @@ "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", "optional": true, "requires": { - "tweetnacl": "0.14.5" + "tweetnacl": "^0.14.3" } }, "binary-extensions": { @@ -964,7 +967,7 @@ "resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz", "integrity": "sha1-E+v+d4oDIFz+A3UUgeu0szAMEmo=", "requires": { - "inherits": "2.0.3" + "inherits": "~2.0.0" } }, "bluebird": { @@ -977,7 +980,7 @@ "resolved": "https://registry.npmjs.org/boom/-/boom-4.3.1.tgz", "integrity": "sha1-T4owBctKfjiJ90kDD9JbluAdLjE=", "requires": { - "hoek": "4.2.1" + "hoek": "4.x.x" } }, "boxen": { @@ -986,13 +989,13 @@ "integrity": "sha512-TNPjfTr432qx7yOjQyaXm3dSR0MH9vXp7eT1BFSl/C51g+EFnOR9hTg1IreahGBmDNCehscshe45f+C1TBZbLw==", "dev": true, "requires": { - "ansi-align": "2.0.0", - "camelcase": "4.1.0", - "chalk": "2.4.0", - "cli-boxes": "1.0.0", - "string-width": "2.1.1", - "term-size": "1.2.0", - "widest-line": "2.0.0" + "ansi-align": "^2.0.0", + "camelcase": "^4.0.0", + "chalk": "^2.0.1", + "cli-boxes": "^1.0.0", + "string-width": "^2.0.0", + "term-size": "^1.2.0", + "widest-line": "^2.0.0" }, "dependencies": { "ansi-regex": { @@ -1019,8 +1022,8 @@ "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", "dev": true, "requires": { - "is-fullwidth-code-point": "2.0.0", - "strip-ansi": "4.0.0" + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" } }, "strip-ansi": { @@ -1029,7 +1032,7 @@ "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "dev": true, "requires": { - "ansi-regex": "3.0.0" + "ansi-regex": "^3.0.0" } } } @@ -1039,7 +1042,7 @@ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "requires": { - "balanced-match": "1.0.0", + "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, @@ -1049,9 +1052,9 @@ "integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=", "dev": true, "requires": { - "expand-range": "1.8.2", - "preserve": "0.2.0", - "repeat-element": "1.1.2" + "expand-range": "^1.8.1", + "preserve": "^0.2.0", + "repeat-element": "^1.1.2" } }, "buf-compare": { @@ -1072,9 +1075,9 @@ "integrity": "sha1-bb2y8g+Nj7znnz6U6dF0Lc31wKE=", "dev": true, "requires": { - "md5-hex": "1.3.0", - "mkdirp": "0.5.1", - "write-file-atomic": "1.3.4" + "md5-hex": "^1.2.0", + "mkdirp": "^0.5.1", + "write-file-atomic": "^1.1.4" }, "dependencies": { "md5-hex": { @@ -1083,7 +1086,7 @@ "integrity": "sha1-0sSv6YPENwZiF5uMrRRSGRNQRsQ=", "dev": true, "requires": { - "md5-o-matic": "0.1.1" + "md5-o-matic": "^0.1.1" } }, "write-file-atomic": { @@ -1092,9 +1095,9 @@ "integrity": "sha1-+Aek8LHZ6ROuekgRLmzDrxmRtF8=", "dev": true, "requires": { - "graceful-fs": "4.1.11", - "imurmurhash": "0.1.4", - "slide": "1.1.6" + "graceful-fs": "^4.1.11", + "imurmurhash": "^0.1.4", + "slide": "^1.1.5" } } } @@ -1105,10 +1108,10 @@ "integrity": "sha1-UTTQd5hPcSpU2tPL9i3ijc5BbKg=", "dev": true, "requires": { - "core-js": "2.5.5", - "deep-equal": "1.0.1", - "espurify": "1.7.0", - "estraverse": "4.2.0" + "core-js": "^2.0.0", + "deep-equal": "^1.0.0", + "espurify": "^1.6.0", + "estraverse": "^4.0.0" } }, "call-signature": { @@ -1129,8 +1132,8 @@ "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=", "dev": true, "requires": { - "camelcase": "2.1.1", - "map-obj": "1.0.1" + "camelcase": "^2.0.0", + "map-obj": "^1.0.0" } }, "capture-stack-trace": { @@ -1150,9 +1153,9 @@ "integrity": "sha512-Wr/w0f4o9LuE7K53cD0qmbAMM+2XNLzR29vFn5hqko4sxGlUsyy363NvmyGIyk5tpe9cjTr9SJYbysEyPkRnFw==", "dev": true, "requires": { - "ansi-styles": "3.2.1", - "escape-string-regexp": "1.0.5", - "supports-color": "5.4.0" + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" } }, "chokidar": { @@ -1161,15 +1164,15 @@ "integrity": "sha1-eY5ol3gVHIB2tLNg5e3SjNortGg=", "dev": true, "requires": { - "anymatch": "1.3.2", - "async-each": "1.0.1", - "fsevents": "1.2.0", - "glob-parent": "2.0.0", - "inherits": "2.0.3", - "is-binary-path": "1.0.1", - "is-glob": "2.0.1", - "path-is-absolute": "1.0.1", - "readdirp": "2.1.0" + "anymatch": "^1.3.0", + "async-each": "^1.0.0", + "fsevents": "^1.0.0", + "glob-parent": "^2.0.0", + "inherits": "^2.0.1", + "is-binary-path": "^1.0.0", + "is-glob": "^2.0.0", + "path-is-absolute": "^1.0.0", + "readdirp": "^2.0.0" } }, "chownr": { @@ -1189,9 +1192,9 @@ "integrity": "sha512-x90Hac4ERacGDcZSvHKK58Ga0STuMD+Doi5g0iG2zf7wlJef5Huvhs/3BvMRFxwRYyYSdl6mpQNrtfMxE8MQzw==", "dev": true, "requires": { - "async": "1.5.2", - "glob": "7.1.2", - "resolve": "1.1.7" + "async": "^1.5.2", + "glob": "^7.0.0", + "resolve": "^1.1.6" }, "dependencies": { "glob": { @@ -1200,12 +1203,12 @@ "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } } } @@ -1234,7 +1237,7 @@ "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", "dev": true, "requires": { - "restore-cursor": "2.0.0" + "restore-cursor": "^2.0.0" } }, "cli-spinners": { @@ -1249,8 +1252,8 @@ "integrity": "sha512-bAtZo0u82gCfaAGfSNxUdTI9mNyza7D8w4CVCcaOsy7sgwDzvx6ekr6cuWJqY3UGzgnQ1+4wgENup5eIhgxEYA==", "dev": true, "requires": { - "slice-ansi": "1.0.0", - "string-width": "2.1.1" + "slice-ansi": "^1.0.0", + "string-width": "^2.0.0" }, "dependencies": { "ansi-regex": { @@ -1271,8 +1274,8 @@ "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", "dev": true, "requires": { - "is-fullwidth-code-point": "2.0.0", - "strip-ansi": "4.0.0" + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" } }, "strip-ansi": { @@ -1281,7 +1284,7 @@ "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "dev": true, "requires": { - "ansi-regex": "3.0.0" + "ansi-regex": "^3.0.0" } } } @@ -1297,7 +1300,7 @@ "integrity": "sha1-QT59tvWJOmC5Qs9JLEvsk9tBWrc=", "dev": true, "requires": { - "pinkie-promise": "1.0.0" + "pinkie-promise": "^1.0.0" }, "dependencies": { "pinkie": { @@ -1312,7 +1315,7 @@ "integrity": "sha1-0dpn9UglY7t89X8oauKCLs+/NnA=", "dev": true, "requires": { - "pinkie": "1.0.0" + "pinkie": "^1.0.0" } } } @@ -1323,7 +1326,7 @@ "integrity": "sha512-tJLhH3EpFm/1x7heIW0hemXJTUU5EWl2V0EIX558jp05Mt1U6DVryCgkp3l37cxqs+DNbNgxG43SkwJXpQ14Jw==", "dev": true, "requires": { - "convert-to-spaces": "1.0.2" + "convert-to-spaces": "^1.0.1" } }, "code-point-at": { @@ -1337,7 +1340,7 @@ "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { - "color-name": "1.1.3" + "color-name": "^1.1.1" } }, "color-name": { @@ -1351,7 +1354,7 @@ "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", "requires": { - "delayed-stream": "1.0.0" + "delayed-stream": "~1.0.0" } }, "commander": { @@ -1359,7 +1362,7 @@ "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz", "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=", "requires": { - "graceful-readlink": "1.0.1" + "graceful-readlink": ">= 1.0.0" } }, "common-path-prefix": { @@ -1385,17 +1388,17 @@ "integrity": "sha512-CZBzJ3/l5QJjlZM20WY7+5GP5pMTw+1UEbThcpMw8/rojsi5sBCiD8ZbBLtD+jYpRGAkwuKuqk108c154V9eyQ==", "dev": true, "requires": { - "date-time": "2.1.0", - "esutils": "2.0.2", - "fast-diff": "1.1.2", - "function-name-support": "0.2.0", - "js-string-escape": "1.0.1", - "lodash.clonedeep": "4.5.0", - "lodash.flattendeep": "4.4.0", - "lodash.merge": "4.6.1", - "md5-hex": "2.0.0", - "semver": "5.3.0", - "well-known-symbols": "1.0.0" + "date-time": "^2.1.0", + "esutils": "^2.0.2", + "fast-diff": "^1.1.1", + "function-name-support": "^0.2.0", + "js-string-escape": "^1.0.1", + "lodash.clonedeep": "^4.5.0", + "lodash.flattendeep": "^4.4.0", + "lodash.merge": "^4.6.0", + "md5-hex": "^2.0.0", + "semver": "^5.3.0", + "well-known-symbols": "^1.0.0" }, "dependencies": { "date-time": { @@ -1404,7 +1407,7 @@ "integrity": "sha512-/9+C44X7lot0IeiyfgJmETtRMhBidBYM2QFFIkGa0U1k+hSyY87Nw7PY3eDqpvCBm7I3WCSfPeZskW/YYq6m4g==", "dev": true, "requires": { - "time-zone": "1.0.0" + "time-zone": "^1.0.0" } } } @@ -1415,12 +1418,12 @@ "integrity": "sha512-vtv5HtGjcYUgFrXc6Kx747B83MRRVS5R1VTEQoXvuP+kMI+if6uywV0nDGoiydJRy4yk7h9od5Og0kxx4zUXmw==", "dev": true, "requires": { - "dot-prop": "4.2.0", - "graceful-fs": "4.1.11", - "make-dir": "1.2.0", - "unique-string": "1.0.0", - "write-file-atomic": "2.3.0", - "xdg-basedir": "3.0.0" + "dot-prop": "^4.1.0", + "graceful-fs": "^4.1.2", + "make-dir": "^1.0.0", + "unique-string": "^1.0.0", + "write-file-atomic": "^2.0.0", + "xdg-basedir": "^3.0.0" } }, "console-control-strings": { @@ -1446,8 +1449,8 @@ "integrity": "sha1-+F4s+b/tKPdzzIs/pcW2m9wC/j8=", "dev": true, "requires": { - "buf-compare": "1.0.1", - "is-error": "2.2.1" + "buf-compare": "^1.0.0", + "is-error": "^2.2.0" } }, "core-js": { @@ -1467,7 +1470,7 @@ "integrity": "sha1-Br56vvlHo/FKMP1hBnHUAbyot7Y=", "dev": true, "requires": { - "capture-stack-trace": "1.0.0" + "capture-stack-trace": "^1.0.0" } }, "cross-spawn": { @@ -1476,9 +1479,9 @@ "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", "dev": true, "requires": { - "lru-cache": "4.1.2", - "shebang-command": "1.2.0", - "which": "1.3.0" + "lru-cache": "^4.0.1", + "shebang-command": "^1.2.0", + "which": "^1.2.9" } }, "cryptiles": { @@ -1486,7 +1489,7 @@ "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.2.tgz", "integrity": "sha1-qJ+7Ig9c4l7FboxKqKT9e1sNKf4=", "requires": { - "boom": "5.2.0" + "boom": "5.x.x" }, "dependencies": { "boom": { @@ -1494,7 +1497,7 @@ "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "requires": { - "hoek": "4.2.1" + "hoek": "4.x.x" } } } @@ -1511,7 +1514,7 @@ "integrity": "sha1-mI3zP+qxke95mmE2nddsF635V+o=", "dev": true, "requires": { - "array-find-index": "1.0.2" + "array-find-index": "^1.0.1" } }, "dashdash": { @@ -1519,7 +1522,7 @@ "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", "requires": { - "assert-plus": "1.0.0" + "assert-plus": "^1.0.0" } }, "date-time": { @@ -1569,7 +1572,7 @@ "integrity": "sha1-920GQ1LN9Docts5hnE7jqUdd4gg=", "dev": true, "requires": { - "repeating": "2.0.1" + "repeating": "^2.0.0" } }, "detect-libc": { @@ -1585,7 +1588,7 @@ "integrity": "sha512-tUMXrxlExSW6U2EXiiKGSBVdYgtV8qlHL+C10TsW4PURY/ic+eaysnSkwB4kA/mBlCyy/IKDJ+Lc3wbWeaXtuQ==", "dev": true, "requires": { - "is-obj": "1.0.1" + "is-obj": "^1.0.0" } }, "duplexer3": { @@ -1600,7 +1603,7 @@ "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", "optional": true, "requires": { - "jsbn": "0.1.1" + "jsbn": "~0.1.0" } }, "empower-core": { @@ -1610,7 +1613,7 @@ "dev": true, "requires": { "call-signature": "0.0.2", - "core-js": "2.5.5" + "core-js": "^2.0.0" } }, "emscripten-library-decorator": { @@ -1630,7 +1633,7 @@ "integrity": "sha1-+FWobOYa3E6GIcPNoh56dhLDqNw=", "dev": true, "requires": { - "is-arrayish": "0.2.1" + "is-arrayish": "^0.2.1" } }, "es6-error": { @@ -1639,6 +1642,11 @@ "integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==", "dev": true }, + "es6-shim": { + "version": "0.35.3", + "resolved": "https://registry.npmjs.org/es6-shim/-/es6-shim-0.35.3.tgz", + "integrity": "sha1-m/tzY/7//4emzbbNk+QF7DxLbyY=" + }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", @@ -1651,10 +1659,10 @@ "integrity": "sha1-oXt+zFnTDheeK+9z+0E3cEyzMbU=", "dev": true, "requires": { - "is-url": "1.2.4", - "path-is-absolute": "1.0.1", - "source-map": "0.5.7", - "xtend": "4.0.1" + "is-url": "^1.2.1", + "path-is-absolute": "^1.0.0", + "source-map": "^0.5.0", + "xtend": "^4.0.0" } }, "esprima": { @@ -1669,7 +1677,7 @@ "integrity": "sha1-HFz2y8zDLm9jk4C9T5kfq5up0iY=", "dev": true, "requires": { - "core-js": "2.5.5" + "core-js": "^2.0.0" } }, "estraverse": { @@ -1690,13 +1698,13 @@ "integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=", "dev": true, "requires": { - "cross-spawn": "5.1.0", - "get-stream": "3.0.0", - "is-stream": "1.1.0", - "npm-run-path": "2.0.2", - "p-finally": "1.0.0", - "signal-exit": "3.0.2", - "strip-eof": "1.0.0" + "cross-spawn": "^5.0.1", + "get-stream": "^3.0.0", + "is-stream": "^1.1.0", + "npm-run-path": "^2.0.0", + "p-finally": "^1.0.0", + "signal-exit": "^3.0.0", + "strip-eof": "^1.0.0" } }, "expand-brackets": { @@ -1705,7 +1713,7 @@ "integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=", "dev": true, "requires": { - "is-posix-bracket": "0.1.1" + "is-posix-bracket": "^0.1.0" } }, "expand-range": { @@ -1714,7 +1722,7 @@ "integrity": "sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc=", "dev": true, "requires": { - "fill-range": "2.2.3" + "fill-range": "^2.1.0" } }, "extend": { @@ -1728,7 +1736,7 @@ "integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=", "dev": true, "requires": { - "is-extglob": "1.0.0" + "is-extglob": "^1.0.0" } }, "extsprintf": { @@ -1758,7 +1766,7 @@ "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", "dev": true, "requires": { - "escape-string-regexp": "1.0.5" + "escape-string-regexp": "^1.0.5" } }, "filename-regex": { @@ -1773,11 +1781,11 @@ "integrity": "sha1-ULd9/X5Gm8dJJHCWNpn+eoSFpyM=", "dev": true, "requires": { - "is-number": "2.1.0", - "isobject": "2.1.0", - "randomatic": "1.1.7", - "repeat-element": "1.1.2", - "repeat-string": "1.6.1" + "is-number": "^2.1.0", + "isobject": "^2.0.0", + "randomatic": "^1.1.3", + "repeat-element": "^1.1.2", + "repeat-string": "^1.5.2" } }, "find-cache-dir": { @@ -1786,9 +1794,9 @@ "integrity": "sha1-kojj6ePMN0hxfTnq3hfPcfww7m8=", "dev": true, "requires": { - "commondir": "1.0.1", - "make-dir": "1.2.0", - "pkg-dir": "2.0.0" + "commondir": "^1.0.1", + "make-dir": "^1.0.0", + "pkg-dir": "^2.0.0" } }, "find-up": { @@ -1797,7 +1805,7 @@ "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", "dev": true, "requires": { - "locate-path": "2.0.0" + "locate-path": "^2.0.0" } }, "fn-name": { @@ -1818,7 +1826,7 @@ "integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=", "dev": true, "requires": { - "for-in": "1.0.2" + "for-in": "^1.0.1" } }, "forever-agent": { @@ -1831,9 +1839,9 @@ "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz", "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=", "requires": { - "asynckit": "0.4.0", + "asynckit": "^0.4.0", "combined-stream": "1.0.6", - "mime-types": "2.1.18" + "mime-types": "^2.1.12" } }, "fs-minipass": { @@ -1841,7 +1849,7 @@ "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.5.tgz", "integrity": "sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ==", "requires": { - "minipass": "2.2.4" + "minipass": "^2.2.1" } }, "fs.realpath": { @@ -1856,8 +1864,8 @@ "dev": true, "optional": true, "requires": { - "nan": "2.10.0", - "node-pre-gyp": "0.9.1" + "nan": "^2.9.2", + "node-pre-gyp": "^0.9.0" }, "dependencies": { "abbrev": { @@ -1868,8 +1876,8 @@ "version": "4.11.8", "bundled": true, "requires": { - "co": "4.6.0", - "json-stable-stringify": "1.0.1" + "co": "^4.6.0", + "json-stable-stringify": "^1.0.1" } }, "ansi-regex": { @@ -1884,8 +1892,8 @@ "version": "1.1.4", "bundled": true, "requires": { - "delegates": "1.0.0", - "readable-stream": "2.2.9" + "delegates": "^1.0.0", + "readable-stream": "^2.0.6" } }, "asn1": { @@ -1917,28 +1925,28 @@ "bundled": true, "optional": true, "requires": { - "tweetnacl": "0.14.5" + "tweetnacl": "^0.14.3" } }, "block-stream": { "version": "0.0.9", "bundled": true, "requires": { - "inherits": "2.0.3" + "inherits": "~2.0.0" } }, "boom": { "version": "2.10.1", "bundled": true, "requires": { - "hoek": "2.16.3" + "hoek": "2.x.x" } }, "brace-expansion": { "version": "1.1.7", "bundled": true, "requires": { - "balanced-match": "0.4.2", + "balanced-match": "^0.4.1", "concat-map": "0.0.1" } }, @@ -1962,7 +1970,7 @@ "version": "1.0.5", "bundled": true, "requires": { - "delayed-stream": "1.0.0" + "delayed-stream": "~1.0.0" } }, "concat-map": { @@ -1981,14 +1989,14 @@ "version": "2.0.5", "bundled": true, "requires": { - "boom": "2.10.1" + "boom": "2.x.x" } }, "dashdash": { "version": "1.14.1", "bundled": true, "requires": { - "assert-plus": "1.0.0" + "assert-plus": "^1.0.0" }, "dependencies": { "assert-plus": { @@ -2025,7 +2033,7 @@ "bundled": true, "optional": true, "requires": { - "jsbn": "0.1.1" + "jsbn": "~0.1.0" } }, "extend": { @@ -2044,9 +2052,9 @@ "version": "2.1.4", "bundled": true, "requires": { - "asynckit": "0.4.0", - "combined-stream": "1.0.5", - "mime-types": "2.1.15" + "asynckit": "^0.4.0", + "combined-stream": "^1.0.5", + "mime-types": "^2.1.12" } }, "fs.realpath": { @@ -2057,40 +2065,40 @@ "version": "1.0.11", "bundled": true, "requires": { - "graceful-fs": "4.1.11", - "inherits": "2.0.3", - "mkdirp": "0.5.1", - "rimraf": "2.6.1" + "graceful-fs": "^4.1.2", + "inherits": "~2.0.0", + "mkdirp": ">=0.5 0", + "rimraf": "2" } }, "fstream-ignore": { "version": "1.0.5", "bundled": true, "requires": { - "fstream": "1.0.11", - "inherits": "2.0.3", - "minimatch": "3.0.4" + "fstream": "^1.0.0", + "inherits": "2", + "minimatch": "^3.0.0" } }, "gauge": { "version": "2.7.4", "bundled": true, "requires": { - "aproba": "1.1.1", - "console-control-strings": "1.1.0", - "has-unicode": "2.0.1", - "object-assign": "4.1.1", - "signal-exit": "3.0.2", - "string-width": "1.0.2", - "strip-ansi": "3.0.1", - "wide-align": "1.1.2" + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" } }, "getpass": { "version": "0.1.7", "bundled": true, "requires": { - "assert-plus": "1.0.0" + "assert-plus": "^1.0.0" }, "dependencies": { "assert-plus": { @@ -2103,12 +2111,12 @@ "version": "7.1.2", "bundled": true, "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } }, "graceful-fs": { @@ -2123,8 +2131,8 @@ "version": "4.2.1", "bundled": true, "requires": { - "ajv": "4.11.8", - "har-schema": "1.0.5" + "ajv": "^4.9.1", + "har-schema": "^1.0.5" } }, "has-unicode": { @@ -2135,10 +2143,10 @@ "version": "3.1.3", "bundled": true, "requires": { - "boom": "2.10.1", - "cryptiles": "2.0.5", - "hoek": "2.16.3", - "sntp": "1.0.9" + "boom": "2.x.x", + "cryptiles": "2.x.x", + "hoek": "2.x.x", + "sntp": "1.x.x" } }, "hoek": { @@ -2149,17 +2157,17 @@ "version": "1.1.1", "bundled": true, "requires": { - "assert-plus": "0.2.0", - "jsprim": "1.4.0", - "sshpk": "1.13.0" + "assert-plus": "^0.2.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" } }, "inflight": { "version": "1.0.6", "bundled": true, "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" + "once": "^1.3.0", + "wrappy": "1" } }, "inherits": { @@ -2174,7 +2182,7 @@ "version": "1.0.0", "bundled": true, "requires": { - "number-is-nan": "1.0.1" + "number-is-nan": "^1.0.0" } }, "is-typedarray": { @@ -2194,7 +2202,7 @@ "bundled": true, "optional": true, "requires": { - "jsbn": "0.1.1" + "jsbn": "~0.1.0" } }, "jsbn": { @@ -2210,7 +2218,7 @@ "version": "1.0.1", "bundled": true, "requires": { - "jsonify": "0.0.0" + "jsonify": "~0.0.0" } }, "json-stringify-safe": { @@ -2245,14 +2253,14 @@ "version": "2.1.15", "bundled": true, "requires": { - "mime-db": "1.27.0" + "mime-db": "~1.27.0" } }, "minimatch": { "version": "3.0.4", "bundled": true, "requires": { - "brace-expansion": "1.1.7" + "brace-expansion": "^1.1.7" } }, "minimist": { @@ -2274,18 +2282,18 @@ "version": "4.0.1", "bundled": true, "requires": { - "abbrev": "1.1.0", - "osenv": "0.1.4" + "abbrev": "1", + "osenv": "^0.1.4" } }, "npmlog": { "version": "4.1.0", "bundled": true, "requires": { - "are-we-there-yet": "1.1.4", - "console-control-strings": "1.1.0", - "gauge": "2.7.4", - "set-blocking": "2.0.0" + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" } }, "number-is-nan": { @@ -2304,7 +2312,7 @@ "version": "1.4.0", "bundled": true, "requires": { - "wrappy": "1.0.2" + "wrappy": "1" } }, "os-homedir": { @@ -2319,8 +2327,8 @@ "version": "0.1.4", "bundled": true, "requires": { - "os-homedir": "1.0.2", - "os-tmpdir": "1.0.2" + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.0" } }, "path-is-absolute": { @@ -2347,10 +2355,10 @@ "version": "1.2.1", "bundled": true, "requires": { - "deep-extend": "0.4.2", - "ini": "1.3.4", - "minimist": "1.2.0", - "strip-json-comments": "2.0.1" + "deep-extend": "~0.4.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" }, "dependencies": { "minimist": { @@ -2363,48 +2371,48 @@ "version": "2.2.9", "bundled": true, "requires": { - "buffer-shims": "1.0.0", - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "string_decoder": "1.0.1", - "util-deprecate": "1.0.2" + "buffer-shims": "~1.0.0", + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "~1.0.0", + "process-nextick-args": "~1.0.6", + "string_decoder": "~1.0.0", + "util-deprecate": "~1.0.1" } }, "request": { "version": "2.81.0", "bundled": true, "requires": { - "aws-sign2": "0.6.0", - "aws4": "1.6.0", - "caseless": "0.12.0", - "combined-stream": "1.0.5", - "extend": "3.0.1", - "forever-agent": "0.6.1", - "form-data": "2.1.4", - "har-validator": "4.2.1", - "hawk": "3.1.3", - "http-signature": "1.1.1", - "is-typedarray": "1.0.0", - "isstream": "0.1.2", - "json-stringify-safe": "5.0.1", - "mime-types": "2.1.15", - "oauth-sign": "0.8.2", - "performance-now": "0.2.0", - "qs": "6.4.0", - "safe-buffer": "5.0.1", - "stringstream": "0.0.5", - "tough-cookie": "2.3.2", - "tunnel-agent": "0.6.0", - "uuid": "3.0.1" + "aws-sign2": "~0.6.0", + "aws4": "^1.2.1", + "caseless": "~0.12.0", + "combined-stream": "~1.0.5", + "extend": "~3.0.0", + "forever-agent": "~0.6.1", + "form-data": "~2.1.1", + "har-validator": "~4.2.1", + "hawk": "~3.1.3", + "http-signature": "~1.1.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.7", + "oauth-sign": "~0.8.1", + "performance-now": "^0.2.0", + "qs": "~6.4.0", + "safe-buffer": "^5.0.1", + "stringstream": "~0.0.4", + "tough-cookie": "~2.3.0", + "tunnel-agent": "^0.6.0", + "uuid": "^3.0.0" } }, "rimraf": { "version": "2.6.1", "bundled": true, "requires": { - "glob": "7.1.2" + "glob": "^7.0.5" } }, "safe-buffer": { @@ -2427,22 +2435,22 @@ "version": "1.0.9", "bundled": true, "requires": { - "hoek": "2.16.3" + "hoek": "2.x.x" } }, "sshpk": { "version": "1.13.0", "bundled": true, "requires": { - "asn1": "0.2.3", - "assert-plus": "1.0.0", - "bcrypt-pbkdf": "1.0.1", - "dashdash": "1.14.1", - "ecc-jsbn": "0.1.1", - "getpass": "0.1.7", - "jodid25519": "1.0.2", - "jsbn": "0.1.1", - "tweetnacl": "0.14.5" + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jodid25519": "^1.0.0", + "jsbn": "~0.1.0", + "tweetnacl": "~0.14.0" }, "dependencies": { "assert-plus": { @@ -2455,16 +2463,16 @@ "version": "1.0.2", "bundled": true, "requires": { - "code-point-at": "1.1.0", - "is-fullwidth-code-point": "1.0.0", - "strip-ansi": "3.0.1" + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" } }, "string_decoder": { "version": "1.0.1", "bundled": true, "requires": { - "safe-buffer": "5.0.1" + "safe-buffer": "^5.0.1" } }, "stringstream": { @@ -2475,7 +2483,7 @@ "version": "3.0.1", "bundled": true, "requires": { - "ansi-regex": "2.1.1" + "ansi-regex": "^2.0.0" } }, "strip-json-comments": { @@ -2486,37 +2494,37 @@ "version": "2.2.1", "bundled": true, "requires": { - "block-stream": "0.0.9", - "fstream": "1.0.11", - "inherits": "2.0.3" + "block-stream": "*", + "fstream": "^1.0.2", + "inherits": "2" } }, "tar-pack": { "version": "3.4.0", "bundled": true, "requires": { - "debug": "2.6.8", - "fstream": "1.0.11", - "fstream-ignore": "1.0.5", - "once": "1.4.0", - "readable-stream": "2.2.9", - "rimraf": "2.6.1", - "tar": "2.2.1", - "uid-number": "0.0.6" + "debug": "^2.2.0", + "fstream": "^1.0.10", + "fstream-ignore": "^1.0.5", + "once": "^1.3.3", + "readable-stream": "^2.1.4", + "rimraf": "^2.5.1", + "tar": "^2.2.1", + "uid-number": "^0.0.6" } }, "tough-cookie": { "version": "2.3.2", "bundled": true, "requires": { - "punycode": "1.4.1" + "punycode": "^1.4.1" } }, "tunnel-agent": { "version": "0.6.0", "bundled": true, "requires": { - "safe-buffer": "5.0.1" + "safe-buffer": "^5.0.1" } }, "tweetnacl": { @@ -2547,7 +2555,7 @@ "version": "1.1.2", "bundled": true, "requires": { - "string-width": "1.0.2" + "string-width": "^1.0.2" } }, "wrappy": { @@ -2561,10 +2569,10 @@ "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz", "integrity": "sha1-XB+x8RdHcRTwYyoOtLcbPLD9MXE=", "requires": { - "graceful-fs": "4.1.11", - "inherits": "2.0.3", - "mkdirp": "0.5.1", - "rimraf": "2.4.5" + "graceful-fs": "^4.1.2", + "inherits": "~2.0.0", + "mkdirp": ">=0.5 0", + "rimraf": "2" } }, "function-name-support": { @@ -2578,14 +2586,14 @@ "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", "requires": { - "aproba": "1.2.0", - "console-control-strings": "1.1.0", - "has-unicode": "2.0.1", - "object-assign": "4.1.1", - "signal-exit": "3.0.2", - "string-width": "1.0.2", - "strip-ansi": "3.0.1", - "wide-align": "1.1.2" + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" } }, "get-port": { @@ -2611,7 +2619,7 @@ "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", "requires": { - "assert-plus": "1.0.0" + "assert-plus": "^1.0.0" } }, "glob": { @@ -2619,11 +2627,11 @@ "resolved": "https://registry.npmjs.org/glob/-/glob-6.0.4.tgz", "integrity": "sha1-DwiGD2oVUSey+t1PnOJLGqtuTSI=", "requires": { - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "2 || 3", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } }, "glob-base": { @@ -2632,8 +2640,8 @@ "integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=", "dev": true, "requires": { - "glob-parent": "2.0.0", - "is-glob": "2.0.1" + "glob-parent": "^2.0.0", + "is-glob": "^2.0.0" } }, "glob-parent": { @@ -2642,7 +2650,7 @@ "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=", "dev": true, "requires": { - "is-glob": "2.0.1" + "is-glob": "^2.0.0" } }, "global-dirs": { @@ -2651,7 +2659,7 @@ "integrity": "sha1-sxnA3UYH81PzvpzKTHL8FIxJ9EU=", "dev": true, "requires": { - "ini": "1.3.5" + "ini": "^1.3.4" } }, "globals": { @@ -2666,11 +2674,11 @@ "integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=", "dev": true, "requires": { - "array-union": "1.0.2", - "glob": "7.1.2", - "object-assign": "4.1.1", - "pify": "2.3.0", - "pinkie-promise": "2.0.1" + "array-union": "^1.0.1", + "glob": "^7.0.3", + "object-assign": "^4.0.1", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" }, "dependencies": { "glob": { @@ -2679,12 +2687,12 @@ "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } } } @@ -2695,17 +2703,17 @@ "integrity": "sha1-JAzQV4WpoY5WHcG0S0HHY+8ejbA=", "dev": true, "requires": { - "create-error-class": "3.0.2", - "duplexer3": "0.1.4", - "get-stream": "3.0.0", - "is-redirect": "1.0.0", - "is-retry-allowed": "1.1.0", - "is-stream": "1.1.0", - "lowercase-keys": "1.0.1", - "safe-buffer": "5.1.1", - "timed-out": "4.0.1", - "unzip-response": "2.0.1", - "url-parse-lax": "1.0.0" + "create-error-class": "^3.0.0", + "duplexer3": "^0.1.4", + "get-stream": "^3.0.0", + "is-redirect": "^1.0.0", + "is-retry-allowed": "^1.0.0", + "is-stream": "^1.0.0", + "lowercase-keys": "^1.0.0", + "safe-buffer": "^5.0.1", + "timed-out": "^4.0.0", + "unzip-response": "^2.0.1", + "url-parse-lax": "^1.0.0" } }, "graceful-fs": { @@ -2728,8 +2736,8 @@ "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz", "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=", "requires": { - "ajv": "5.5.2", - "har-schema": "2.0.0" + "ajv": "^5.1.0", + "har-schema": "^2.0.0" } }, "has-ansi": { @@ -2738,7 +2746,7 @@ "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", "dev": true, "requires": { - "ansi-regex": "2.1.1" + "ansi-regex": "^2.0.0" } }, "has-color": { @@ -2769,10 +2777,10 @@ "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "requires": { - "boom": "4.3.1", - "cryptiles": "3.1.2", - "hoek": "4.2.1", - "sntp": "2.1.0" + "boom": "4.x.x", + "cryptiles": "3.x.x", + "hoek": "4.x.x", + "sntp": "2.x.x" } }, "hoek": { @@ -2786,8 +2794,8 @@ "integrity": "sha1-42w/LSyufXRqhX440Y1fMqeILbg=", "dev": true, "requires": { - "os-homedir": "1.0.2", - "os-tmpdir": "1.0.2" + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.1" } }, "home-path": { @@ -2806,9 +2814,9 @@ "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", "requires": { - "assert-plus": "1.0.0", - "jsprim": "1.4.1", - "sshpk": "1.14.1" + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" } }, "hullabaloo-config-manager": { @@ -2817,20 +2825,20 @@ "integrity": "sha512-ztKnkZV0TmxnumCDHHgLGNiDnotu4EHCp9YMkznWuo4uTtCyJ+cu+RNcxUeXYKTllpvLFWnbfWry09yzszgg+A==", "dev": true, "requires": { - "dot-prop": "4.2.0", - "es6-error": "4.1.1", - "graceful-fs": "4.1.11", - "indent-string": "3.2.0", - "json5": "0.5.1", - "lodash.clonedeep": "4.5.0", - "lodash.clonedeepwith": "4.5.0", - "lodash.isequal": "4.5.0", - "lodash.merge": "4.6.1", - "md5-hex": "2.0.0", - "package-hash": "2.0.0", - "pkg-dir": "2.0.0", - "resolve-from": "3.0.0", - "safe-buffer": "5.1.1" + "dot-prop": "^4.1.0", + "es6-error": "^4.0.2", + "graceful-fs": "^4.1.11", + "indent-string": "^3.1.0", + "json5": "^0.5.1", + "lodash.clonedeep": "^4.5.0", + "lodash.clonedeepwith": "^4.5.0", + "lodash.isequal": "^4.5.0", + "lodash.merge": "^4.6.0", + "md5-hex": "^2.0.0", + "package-hash": "^2.0.0", + "pkg-dir": "^2.0.0", + "resolve-from": "^3.0.0", + "safe-buffer": "^5.0.1" } }, "humanize": { @@ -2845,9 +2853,9 @@ "integrity": "sha512-e21wivqHpstpoiWA/Yi8eFti8E+sQDSS53cpJsPptPs295QTOQR0ZwnHo2TXy1XOpZFD9rPOd3NpmqTK6uMLJA==", "dev": true, "requires": { - "is-ci": "1.1.0", - "normalize-path": "1.0.0", - "strip-indent": "2.0.0" + "is-ci": "^1.0.10", + "normalize-path": "^1.0.0", + "strip-indent": "^2.0.0" }, "dependencies": { "normalize-path": { @@ -2871,7 +2879,7 @@ "dev": true, "optional": true, "requires": { - "safer-buffer": "2.1.2" + "safer-buffer": "^2.1.0" } }, "ignore-by-default": { @@ -2887,7 +2895,7 @@ "dev": true, "optional": true, "requires": { - "minimatch": "3.0.4" + "minimatch": "^3.0.4" } }, "import-lazy": { @@ -2902,8 +2910,8 @@ "integrity": "sha1-sReVcqrNwRxqkQCftDDbyrX2aKg=", "dev": true, "requires": { - "pkg-dir": "2.0.0", - "resolve-cwd": "2.0.0" + "pkg-dir": "^2.0.0", + "resolve-cwd": "^2.0.0" } }, "imurmurhash": { @@ -2923,8 +2931,8 @@ "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" + "once": "^1.3.0", + "wrappy": "1" } }, "inherits": { @@ -2943,7 +2951,7 @@ "integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==", "dev": true, "requires": { - "loose-envify": "1.3.1" + "loose-envify": "^1.0.0" } }, "irregular-plurals": { @@ -2964,7 +2972,7 @@ "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", "dev": true, "requires": { - "binary-extensions": "1.11.0" + "binary-extensions": "^1.0.0" } }, "is-buffer": { @@ -2979,7 +2987,7 @@ "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", "dev": true, "requires": { - "builtin-modules": "1.1.1" + "builtin-modules": "^1.0.0" } }, "is-ci": { @@ -2988,7 +2996,7 @@ "integrity": "sha512-c7TnwxLePuqIlxHgr7xtxzycJPegNHFuIrBkwbf8hc58//+Op1CqFkyS+xnIMkwn9UsJIwc174BIjkyBmSpjKg==", "dev": true, "requires": { - "ci-info": "1.1.3" + "ci-info": "^1.0.0" } }, "is-dotfile": { @@ -3003,7 +3011,7 @@ "integrity": "sha1-IjgJj8Ih3gvPpdnqxMRdY4qhxTQ=", "dev": true, "requires": { - "is-primitive": "2.0.0" + "is-primitive": "^2.0.0" } }, "is-error": { @@ -3030,7 +3038,7 @@ "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", "dev": true, "requires": { - "number-is-nan": "1.0.1" + "number-is-nan": "^1.0.0" } }, "is-fullwidth-code-point": { @@ -3038,7 +3046,7 @@ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "requires": { - "number-is-nan": "1.0.1" + "number-is-nan": "^1.0.0" } }, "is-generator-fn": { @@ -3053,7 +3061,7 @@ "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", "dev": true, "requires": { - "is-extglob": "1.0.0" + "is-extglob": "^1.0.0" } }, "is-installed-globally": { @@ -3062,8 +3070,8 @@ "integrity": "sha1-Df2Y9akRFxbdU13aZJL2e/PSWoA=", "dev": true, "requires": { - "global-dirs": "0.1.1", - "is-path-inside": "1.0.1" + "global-dirs": "^0.1.0", + "is-path-inside": "^1.0.0" } }, "is-npm": { @@ -3078,7 +3086,7 @@ "integrity": "sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" } }, "is-obj": { @@ -3093,7 +3101,7 @@ "integrity": "sha512-NqCa4Sa2d+u7BWc6CukaObG3Fh+CU9bvixbpcXYhy2VvYS7vVGIdAgnIS5Ks3A/cqk4rebLJ9s8zBstT2aKnIA==", "dev": true, "requires": { - "symbol-observable": "1.2.0" + "symbol-observable": "^1.1.0" } }, "is-path-inside": { @@ -3102,7 +3110,7 @@ "integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=", "dev": true, "requires": { - "path-is-inside": "1.0.2" + "path-is-inside": "^1.0.1" } }, "is-plain-obj": { @@ -3206,8 +3214,8 @@ "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { - "argparse": "1.0.10", - "esprima": "4.0.0" + "argparse": "^1.0.7", + "esprima": "^4.0.0" } }, "jsbn": { @@ -3266,7 +3274,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } }, "last-line-stream": { @@ -3275,7 +3283,7 @@ "integrity": "sha1-0bZNafhv8kry0EiDos7uFFIKVgA=", "dev": true, "requires": { - "through2": "2.0.3" + "through2": "^2.0.0" } }, "latest-version": { @@ -3284,7 +3292,7 @@ "integrity": "sha1-ogU4P+oyKzO1rjsYq+4NwvNW7hU=", "dev": true, "requires": { - "package-json": "4.0.1" + "package-json": "^4.0.0" } }, "libui-download": { @@ -3292,16 +3300,16 @@ "resolved": "https://registry.npmjs.org/libui-download/-/libui-download-1.0.0.tgz", "integrity": "sha512-nW3PgUCPQoxKBce9gkLkmiUH2163FpwFLnXorO/IJhFC4h7JgJRPRKWSGYZvlrhU18rZr93DqECE90cCS2pW1Q==", "requires": { - "debug": "2.6.9", - "home-path": "1.0.5", - "mkdirp": "0.5.1", - "mv": "2.1.1", - "pify": "2.3.0", - "pinkie-promise": "2.0.1", - "rc": "1.2.6", - "regenerator-runtime": "0.9.6", - "request": "2.85.0", - "tar": "4.4.1" + "debug": "^2.2.0", + "home-path": "^1.0.1", + "mkdirp": "^0.5.0", + "mv": "^2.0.3", + "pify": "^2.3.0", + "pinkie-promise": "^2.0.1", + "rc": "^1.1.2", + "regenerator-runtime": "^0.9.5", + "request": "^2.72.0", + "tar": "^4.4.0" } }, "load-json-file": { @@ -3310,10 +3318,10 @@ "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", "dev": true, "requires": { - "graceful-fs": "4.1.11", - "parse-json": "2.2.0", - "pify": "2.3.0", - "strip-bom": "3.0.0" + "graceful-fs": "^4.1.2", + "parse-json": "^2.2.0", + "pify": "^2.0.0", + "strip-bom": "^3.0.0" } }, "locate-path": { @@ -3322,8 +3330,8 @@ "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", "dev": true, "requires": { - "p-locate": "2.0.0", - "path-exists": "3.0.0" + "p-locate": "^2.0.0", + "path-exists": "^3.0.0" } }, "lodash": { @@ -3386,7 +3394,7 @@ "integrity": "sha1-0aitM/qc4OcT1l/dCsi3SNR4yEg=", "dev": true, "requires": { - "js-tokens": "3.0.2" + "js-tokens": "^3.0.0" } }, "loud-rejection": { @@ -3395,8 +3403,8 @@ "integrity": "sha1-W0b4AUft7leIcPCG0Eghz5mOVR8=", "dev": true, "requires": { - "currently-unhandled": "0.4.1", - "signal-exit": "3.0.2" + "currently-unhandled": "^0.4.1", + "signal-exit": "^3.0.0" } }, "lowercase-keys": { @@ -3411,8 +3419,8 @@ "integrity": "sha512-wgeVXhrDwAWnIF/yZARsFnMBtdFXOg1b8RIrhilp+0iDYN4mdQcNZElDZ0e4B64BhaxeQ5zN7PMyvu7we1kPeQ==", "dev": true, "requires": { - "pseudomap": "1.0.2", - "yallist": "2.1.2" + "pseudomap": "^1.0.2", + "yallist": "^2.1.2" }, "dependencies": { "yallist": { @@ -3429,7 +3437,7 @@ "integrity": "sha512-aNUAa4UMg/UougV25bbrU4ZaaKNjJ/3/xnvg/twpmKROPdKZPZ9wGgI0opdZzO8q/zUFawoUuixuOv33eZ61Iw==", "dev": true, "requires": { - "pify": "3.0.0" + "pify": "^3.0.0" }, "dependencies": { "pify": { @@ -3452,7 +3460,7 @@ "integrity": "sha512-aZGv6JBTHqfqAd09jmAlbKnAICTfIvb5Z8gXVxPB5WZtFfHMaAMdACL7tQflD2V+6/8KNcY8s6DYtWLgpJP5lA==", "dev": true, "requires": { - "escape-string-regexp": "1.0.5" + "escape-string-regexp": "^1.0.4" } }, "md5-hex": { @@ -3461,7 +3469,7 @@ "integrity": "sha1-0FiOnxx0lUSS7NJKwKxs6ZfZLjM=", "dev": true, "requires": { - "md5-o-matic": "0.1.1" + "md5-o-matic": "^0.1.1" } }, "md5-o-matic": { @@ -3476,16 +3484,16 @@ "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=", "dev": true, "requires": { - "camelcase-keys": "2.1.0", - "decamelize": "1.2.0", - "loud-rejection": "1.6.0", - "map-obj": "1.0.1", - "minimist": "1.2.0", - "normalize-package-data": "2.4.0", - "object-assign": "4.1.1", - "read-pkg-up": "1.0.1", - "redent": "1.0.0", - "trim-newlines": "1.0.0" + "camelcase-keys": "^2.0.0", + "decamelize": "^1.1.2", + "loud-rejection": "^1.0.0", + "map-obj": "^1.0.1", + "minimist": "^1.1.3", + "normalize-package-data": "^2.3.4", + "object-assign": "^4.0.1", + "read-pkg-up": "^1.0.1", + "redent": "^1.0.0", + "trim-newlines": "^1.0.0" }, "dependencies": { "find-up": { @@ -3494,8 +3502,8 @@ "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", "dev": true, "requires": { - "path-exists": "2.1.0", - "pinkie-promise": "2.0.1" + "path-exists": "^2.0.0", + "pinkie-promise": "^2.0.0" } }, "load-json-file": { @@ -3504,11 +3512,11 @@ "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", "dev": true, "requires": { - "graceful-fs": "4.1.11", - "parse-json": "2.2.0", - "pify": "2.3.0", - "pinkie-promise": "2.0.1", - "strip-bom": "2.0.0" + "graceful-fs": "^4.1.2", + "parse-json": "^2.2.0", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0", + "strip-bom": "^2.0.0" } }, "minimist": { @@ -3523,7 +3531,7 @@ "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", "dev": true, "requires": { - "pinkie-promise": "2.0.1" + "pinkie-promise": "^2.0.0" } }, "path-type": { @@ -3532,9 +3540,9 @@ "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", "dev": true, "requires": { - "graceful-fs": "4.1.11", - "pify": "2.3.0", - "pinkie-promise": "2.0.1" + "graceful-fs": "^4.1.2", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" } }, "read-pkg": { @@ -3543,9 +3551,9 @@ "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", "dev": true, "requires": { - "load-json-file": "1.1.0", - "normalize-package-data": "2.4.0", - "path-type": "1.1.0" + "load-json-file": "^1.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^1.0.0" } }, "read-pkg-up": { @@ -3554,8 +3562,8 @@ "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", "dev": true, "requires": { - "find-up": "1.1.2", - "read-pkg": "1.1.0" + "find-up": "^1.0.0", + "read-pkg": "^1.0.0" } }, "strip-bom": { @@ -3564,7 +3572,7 @@ "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", "dev": true, "requires": { - "is-utf8": "0.2.1" + "is-utf8": "^0.2.0" } } } @@ -3575,19 +3583,19 @@ "integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=", "dev": true, "requires": { - "arr-diff": "2.0.0", - "array-unique": "0.2.1", - "braces": "1.8.5", - "expand-brackets": "0.1.5", - "extglob": "0.3.2", - "filename-regex": "2.0.1", - "is-extglob": "1.0.0", - "is-glob": "2.0.1", - "kind-of": "3.2.2", - "normalize-path": "2.1.1", - "object.omit": "2.0.1", - "parse-glob": "3.0.4", - "regex-cache": "0.4.4" + "arr-diff": "^2.0.0", + "array-unique": "^0.2.1", + "braces": "^1.8.2", + "expand-brackets": "^0.1.4", + "extglob": "^0.3.1", + "filename-regex": "^2.0.0", + "is-extglob": "^1.0.0", + "is-glob": "^2.0.1", + "kind-of": "^3.0.2", + "normalize-path": "^2.0.1", + "object.omit": "^2.0.0", + "parse-glob": "^3.0.4", + "regex-cache": "^0.4.2" } }, "mime-db": { @@ -3600,7 +3608,7 @@ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "requires": { - "mime-db": "1.33.0" + "mime-db": "~1.33.0" } }, "mimic-fn": { @@ -3614,7 +3622,7 @@ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "requires": { - "brace-expansion": "1.1.11" + "brace-expansion": "^1.1.7" } }, "minimist": { @@ -3627,8 +3635,8 @@ "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.2.4.tgz", "integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==", "requires": { - "safe-buffer": "5.1.1", - "yallist": "3.0.2" + "safe-buffer": "^5.1.1", + "yallist": "^3.0.0" } }, "minizlib": { @@ -3636,7 +3644,7 @@ "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.1.0.tgz", "integrity": "sha512-4T6Ur/GctZ27nHfpt9THOdRZNgyJ9FZchYO1ceg5S8Q3DNLCKYy44nCZzgCJgcvx2UM8czmqak5BCxJMrq37lA==", "requires": { - "minipass": "2.2.4" + "minipass": "^2.2.1" } }, "mkdirp": { @@ -3658,10 +3666,10 @@ "integrity": "sha1-nHkGoi+0wCkZ4vX3UWG0zb1LKis=", "dev": true, "requires": { - "array-differ": "1.0.0", - "array-union": "1.0.2", - "arrify": "1.0.1", - "minimatch": "3.0.4" + "array-differ": "^1.0.0", + "array-union": "^1.0.1", + "arrify": "^1.0.0", + "minimatch": "^3.0.0" } }, "mv": { @@ -3669,9 +3677,9 @@ "resolved": "https://registry.npmjs.org/mv/-/mv-2.1.1.tgz", "integrity": "sha1-rmzg1vbV4KT32JN5jQPB6pVZtqI=", "requires": { - "mkdirp": "0.5.1", - "ncp": "2.0.0", - "rimraf": "2.4.5" + "mkdirp": "~0.5.1", + "ncp": "~2.0.0", + "rimraf": "~2.4.0" } }, "nan": { @@ -3684,9 +3692,9 @@ "resolved": "https://registry.npmjs.org/nbind/-/nbind-0.3.15.tgz", "integrity": "sha512-TrKLNRj5D8wZRJb7XmUNbA1W3iTigAEpm3qaGig5bEWY/iCT2IQBgBc2EUGO59FbRIGhx5hB/McVwqxlSGScVw==", "requires": { - "emscripten-library-decorator": "0.2.2", - "mkdirp": "0.5.1", - "nan": "2.10.0" + "emscripten-library-decorator": "~0.2.2", + "mkdirp": "~0.5.1", + "nan": "^2.9.2" } }, "ncp": { @@ -3701,9 +3709,9 @@ "dev": true, "optional": true, "requires": { - "debug": "2.6.9", - "iconv-lite": "0.4.21", - "sax": "1.2.4" + "debug": "^2.1.2", + "iconv-lite": "^0.4.4", + "sax": "^1.2.4" } }, "node-gyp": { @@ -3711,19 +3719,19 @@ "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-3.6.2.tgz", "integrity": "sha1-m/vlRWIoYoSDjnUOrAUpWFP6HGA=", "requires": { - "fstream": "1.0.11", - "glob": "7.1.2", - "graceful-fs": "4.1.11", - "minimatch": "3.0.4", - "mkdirp": "0.5.1", - "nopt": "3.0.6", - "npmlog": "4.1.2", - "osenv": "0.1.5", - "request": "2.85.0", - "rimraf": "2.4.5", - "semver": "5.3.0", - "tar": "2.2.1", - "which": "1.3.0" + "fstream": "^1.0.0", + "glob": "^7.0.3", + "graceful-fs": "^4.1.2", + "minimatch": "^3.0.2", + "mkdirp": "^0.5.0", + "nopt": "2 || 3", + "npmlog": "0 || 1 || 2 || 3 || 4", + "osenv": "0", + "request": "2", + "rimraf": "2", + "semver": "~5.3.0", + "tar": "^2.0.0", + "which": "1" }, "dependencies": { "glob": { @@ -3731,12 +3739,12 @@ "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } }, "tar": { @@ -3744,9 +3752,9 @@ "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz", "integrity": "sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=", "requires": { - "block-stream": "0.0.9", - "fstream": "1.0.11", - "inherits": "2.0.3" + "block-stream": "*", + "fstream": "^1.0.2", + "inherits": "2" } } } @@ -3758,16 +3766,16 @@ "dev": true, "optional": true, "requires": { - "detect-libc": "1.0.3", - "mkdirp": "0.5.1", - "needle": "2.2.0", - "nopt": "4.0.1", - "npm-packlist": "1.1.10", - "npmlog": "4.1.2", - "rc": "1.2.6", - "rimraf": "2.6.2", - "semver": "5.3.0", - "tar": "4.4.1" + "detect-libc": "^1.0.2", + "mkdirp": "^0.5.1", + "needle": "^2.2.0", + "nopt": "^4.0.1", + "npm-packlist": "^1.1.6", + "npmlog": "^4.0.2", + "rc": "^1.1.7", + "rimraf": "^2.6.1", + "semver": "^5.3.0", + "tar": "^4" }, "dependencies": { "glob": { @@ -3777,12 +3785,12 @@ "dev": true, "optional": true, "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } }, "nopt": { @@ -3792,8 +3800,8 @@ "dev": true, "optional": true, "requires": { - "abbrev": "1.1.1", - "osenv": "0.1.5" + "abbrev": "1", + "osenv": "^0.1.4" } }, "rimraf": { @@ -3803,7 +3811,7 @@ "dev": true, "optional": true, "requires": { - "glob": "7.1.2" + "glob": "^7.0.5" } } } @@ -3813,7 +3821,7 @@ "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", "requires": { - "abbrev": "1.1.1" + "abbrev": "1" } }, "normalize-package-data": { @@ -3822,10 +3830,10 @@ "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { - "hosted-git-info": "2.6.0", - "is-builtin-module": "1.0.0", - "semver": "5.3.0", - "validate-npm-package-license": "3.0.3" + "hosted-git-info": "^2.1.4", + "is-builtin-module": "^1.0.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" } }, "normalize-path": { @@ -3834,7 +3842,7 @@ "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", "dev": true, "requires": { - "remove-trailing-separator": "1.1.0" + "remove-trailing-separator": "^1.0.1" } }, "npm-bundled": { @@ -3851,8 +3859,8 @@ "dev": true, "optional": true, "requires": { - "ignore-walk": "3.0.1", - "npm-bundled": "1.0.3" + "ignore-walk": "^3.0.1", + "npm-bundled": "^1.0.1" } }, "npm-run-path": { @@ -3861,7 +3869,7 @@ "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", "dev": true, "requires": { - "path-key": "2.0.1" + "path-key": "^2.0.0" } }, "npmlog": { @@ -3869,10 +3877,10 @@ "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", "requires": { - "are-we-there-yet": "1.1.4", - "console-control-strings": "1.1.0", - "gauge": "2.7.4", - "set-blocking": "2.0.0" + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" } }, "number-is-nan": { @@ -3896,8 +3904,8 @@ "integrity": "sha1-Gpx0SCnznbuFjHbKNXmuKlTr0fo=", "dev": true, "requires": { - "for-own": "0.1.5", - "is-extendable": "0.1.1" + "for-own": "^0.1.4", + "is-extendable": "^0.1.1" } }, "observable-to-promise": { @@ -3906,8 +3914,8 @@ "integrity": "sha1-yCjw8NxH6fhq+KSXfF1VB2znqR8=", "dev": true, "requires": { - "is-observable": "0.2.0", - "symbol-observable": "1.2.0" + "is-observable": "^0.2.0", + "symbol-observable": "^1.0.4" }, "dependencies": { "is-observable": { @@ -3916,7 +3924,7 @@ "integrity": "sha1-s2ExHYPG5dcmyr9eJQsCNxBvWuI=", "dev": true, "requires": { - "symbol-observable": "0.2.4" + "symbol-observable": "^0.2.2" }, "dependencies": { "symbol-observable": { @@ -3934,7 +3942,7 @@ "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "requires": { - "wrappy": "1.0.2" + "wrappy": "1" } }, "onetime": { @@ -3943,7 +3951,7 @@ "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", "dev": true, "requires": { - "mimic-fn": "1.2.0" + "mimic-fn": "^1.0.0" } }, "option-chain": { @@ -3967,8 +3975,8 @@ "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz", "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", "requires": { - "os-homedir": "1.0.2", - "os-tmpdir": "1.0.2" + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.0" } }, "p-finally": { @@ -3983,7 +3991,7 @@ "integrity": "sha512-Y/OtIaXtUPr4/YpMv1pCL5L5ed0rumAaAeBSj12F+bSlMdys7i8oQF/GUJmfpTS/QoaRrS/k6pma29haJpsMng==", "dev": true, "requires": { - "p-try": "1.0.0" + "p-try": "^1.0.0" } }, "p-locate": { @@ -3992,7 +4000,7 @@ "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", "dev": true, "requires": { - "p-limit": "1.2.0" + "p-limit": "^1.1.0" } }, "p-try": { @@ -4007,10 +4015,10 @@ "integrity": "sha1-eK4ybIngWk2BO2hgGXevBcANKg0=", "dev": true, "requires": { - "graceful-fs": "4.1.11", - "lodash.flattendeep": "4.4.0", - "md5-hex": "2.0.0", - "release-zalgo": "1.0.0" + "graceful-fs": "^4.1.11", + "lodash.flattendeep": "^4.4.0", + "md5-hex": "^2.0.0", + "release-zalgo": "^1.0.0" } }, "package-json": { @@ -4019,10 +4027,10 @@ "integrity": "sha1-iGmgQBJTZhxMTKPabCEh7VVfXu0=", "dev": true, "requires": { - "got": "6.7.1", - "registry-auth-token": "3.3.2", - "registry-url": "3.1.0", - "semver": "5.3.0" + "got": "^6.7.1", + "registry-auth-token": "^3.0.1", + "registry-url": "^3.0.3", + "semver": "^5.1.0" } }, "parse-glob": { @@ -4031,10 +4039,10 @@ "integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=", "dev": true, "requires": { - "glob-base": "0.3.0", - "is-dotfile": "1.0.3", - "is-extglob": "1.0.0", - "is-glob": "2.0.1" + "glob-base": "^0.3.0", + "is-dotfile": "^1.0.0", + "is-extglob": "^1.0.0", + "is-glob": "^2.0.0" } }, "parse-json": { @@ -4043,7 +4051,7 @@ "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", "dev": true, "requires": { - "error-ex": "1.3.1" + "error-ex": "^1.2.0" } }, "parse-ms": { @@ -4081,7 +4089,7 @@ "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=", "dev": true, "requires": { - "pify": "2.3.0" + "pify": "^2.0.0" } }, "performance-now": { @@ -4104,7 +4112,7 @@ "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", "requires": { - "pinkie": "2.0.4" + "pinkie": "^2.0.0" } }, "pkg-conf": { @@ -4113,8 +4121,8 @@ "integrity": "sha1-ISZRTKbyq/69FoWW3xi6V4Z/AFg=", "dev": true, "requires": { - "find-up": "2.1.0", - "load-json-file": "4.0.0" + "find-up": "^2.0.0", + "load-json-file": "^4.0.0" }, "dependencies": { "load-json-file": { @@ -4123,10 +4131,10 @@ "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", "dev": true, "requires": { - "graceful-fs": "4.1.11", - "parse-json": "4.0.0", - "pify": "3.0.0", - "strip-bom": "3.0.0" + "graceful-fs": "^4.1.2", + "parse-json": "^4.0.0", + "pify": "^3.0.0", + "strip-bom": "^3.0.0" } }, "parse-json": { @@ -4135,8 +4143,8 @@ "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", "dev": true, "requires": { - "error-ex": "1.3.1", - "json-parse-better-errors": "1.0.2" + "error-ex": "^1.3.1", + "json-parse-better-errors": "^1.0.1" } }, "pify": { @@ -4153,7 +4161,7 @@ "integrity": "sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s=", "dev": true, "requires": { - "find-up": "2.1.0" + "find-up": "^2.1.0" } }, "plur": { @@ -4162,7 +4170,7 @@ "integrity": "sha1-dIJFLBoPUI4+NE6uwxLJHCncZVo=", "dev": true, "requires": { - "irregular-plurals": "1.4.0" + "irregular-plurals": "^1.0.0" } }, "prepend-http": { @@ -4183,8 +4191,8 @@ "integrity": "sha1-6crJx2v27lL+lC3ZxsQhMVOxKIE=", "dev": true, "requires": { - "parse-ms": "1.0.1", - "plur": "2.1.2" + "parse-ms": "^1.0.0", + "plur": "^2.1.2" }, "dependencies": { "parse-ms": { @@ -4234,8 +4242,8 @@ "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { - "is-number": "3.0.0", - "kind-of": "4.0.0" + "is-number": "^3.0.0", + "kind-of": "^4.0.0" }, "dependencies": { "is-number": { @@ -4244,7 +4252,7 @@ "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" }, "dependencies": { "kind-of": { @@ -4253,7 +4261,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -4264,7 +4272,7 @@ "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -4274,10 +4282,10 @@ "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.6.tgz", "integrity": "sha1-6xiYnG1PTxYsOZ953dKfODVWgJI=", "requires": { - "deep-extend": "0.4.2", - "ini": "1.3.5", - "minimist": "1.2.0", - "strip-json-comments": "2.0.1" + "deep-extend": "~0.4.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" }, "dependencies": { "minimist": { @@ -4293,9 +4301,9 @@ "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", "dev": true, "requires": { - "load-json-file": "2.0.0", - "normalize-package-data": "2.4.0", - "path-type": "2.0.0" + "load-json-file": "^2.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^2.0.0" } }, "read-pkg-up": { @@ -4304,8 +4312,8 @@ "integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=", "dev": true, "requires": { - "find-up": "2.1.0", - "read-pkg": "2.0.0" + "find-up": "^2.0.0", + "read-pkg": "^2.0.0" } }, "readable-stream": { @@ -4313,13 +4321,13 @@ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "2.0.0", - "safe-buffer": "5.1.1", - "string_decoder": "1.1.1", - "util-deprecate": "1.0.2" + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" } }, "readdirp": { @@ -4328,10 +4336,10 @@ "integrity": "sha1-TtCtBg3zBzMAxIRANz9y0cxkLXg=", "dev": true, "requires": { - "graceful-fs": "4.1.11", - "minimatch": "3.0.4", - "readable-stream": "2.3.6", - "set-immediate-shim": "1.0.1" + "graceful-fs": "^4.1.2", + "minimatch": "^3.0.2", + "readable-stream": "^2.0.2", + "set-immediate-shim": "^1.0.1" } }, "redent": { @@ -4340,8 +4348,8 @@ "integrity": "sha1-z5Fqsf1fHxbfsggi3W7H9zDCr94=", "dev": true, "requires": { - "indent-string": "2.1.0", - "strip-indent": "1.0.1" + "indent-string": "^2.1.0", + "strip-indent": "^1.0.1" }, "dependencies": { "indent-string": { @@ -4350,7 +4358,7 @@ "integrity": "sha1-ji1INIdCEhtKghi3oTfppSBJ3IA=", "dev": true, "requires": { - "repeating": "2.0.1" + "repeating": "^2.0.0" } } } @@ -4372,7 +4380,7 @@ "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { - "is-equal-shallow": "0.1.3" + "is-equal-shallow": "^0.1.3" } }, "regexpu-core": { @@ -4381,9 +4389,9 @@ "integrity": "sha1-SdA4g3uNz4v6W5pCE5k45uoq4kA=", "dev": true, "requires": { - "regenerate": "1.3.3", - "regjsgen": "0.2.0", - "regjsparser": "0.1.5" + "regenerate": "^1.2.1", + "regjsgen": "^0.2.0", + "regjsparser": "^0.1.4" } }, "registry-auth-token": { @@ -4392,8 +4400,8 @@ "integrity": "sha512-JL39c60XlzCVgNrO+qq68FoNb56w/m7JYvGR2jT5iR1xBrUA3Mfx5Twk5rqTThPmQKMWydGmq8oFtDlxfrmxnQ==", "dev": true, "requires": { - "rc": "1.2.6", - "safe-buffer": "5.1.1" + "rc": "^1.1.6", + "safe-buffer": "^5.0.1" } }, "registry-url": { @@ -4402,7 +4410,7 @@ "integrity": "sha1-PU74cPc93h138M+aOBQyRE4XSUI=", "dev": true, "requires": { - "rc": "1.2.6" + "rc": "^1.0.1" } }, "regjsgen": { @@ -4417,7 +4425,7 @@ "integrity": "sha1-fuj4Tcb6eS0/0K4ijSS9lJ6tIFw=", "dev": true, "requires": { - "jsesc": "0.5.0" + "jsesc": "~0.5.0" } }, "release-zalgo": { @@ -4426,7 +4434,7 @@ "integrity": "sha1-CXALflB0Mpc5Mw5TXFqQ+2eFFzA=", "dev": true, "requires": { - "es6-error": "4.1.1" + "es6-error": "^4.0.1" } }, "remove-trailing-separator": { @@ -4453,7 +4461,7 @@ "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", "dev": true, "requires": { - "is-finite": "1.0.2" + "is-finite": "^1.0.0" } }, "request": { @@ -4461,28 +4469,28 @@ "resolved": "https://registry.npmjs.org/request/-/request-2.85.0.tgz", "integrity": "sha512-8H7Ehijd4js+s6wuVPLjwORxD4zeuyjYugprdOXlPSqaApmL/QOy+EB/beICHVCHkGMKNh5rvihb5ov+IDw4mg==", "requires": { - "aws-sign2": "0.7.0", - "aws4": "1.7.0", - "caseless": "0.12.0", - "combined-stream": "1.0.6", - "extend": "3.0.1", - "forever-agent": "0.6.1", - "form-data": "2.3.2", - "har-validator": "5.0.3", - "hawk": "6.0.2", - "http-signature": "1.2.0", - "is-typedarray": "1.0.0", - "isstream": "0.1.2", - "json-stringify-safe": "5.0.1", - "mime-types": "2.1.18", - "oauth-sign": "0.8.2", - "performance-now": "2.1.0", - "qs": "6.5.1", - "safe-buffer": "5.1.1", - "stringstream": "0.0.5", - "tough-cookie": "2.3.4", - "tunnel-agent": "0.6.0", - "uuid": "3.2.1" + "aws-sign2": "~0.7.0", + "aws4": "^1.6.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.5", + "extend": "~3.0.1", + "forever-agent": "~0.6.1", + "form-data": "~2.3.1", + "har-validator": "~5.0.3", + "hawk": "~6.0.2", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.17", + "oauth-sign": "~0.8.2", + "performance-now": "^2.1.0", + "qs": "~6.5.1", + "safe-buffer": "^5.1.1", + "stringstream": "~0.0.5", + "tough-cookie": "~2.3.3", + "tunnel-agent": "^0.6.0", + "uuid": "^3.1.0" } }, "require-precompiled": { @@ -4502,7 +4510,7 @@ "integrity": "sha1-AKn3OHVW4nA46uIyyqNypqWbZlo=", "dev": true, "requires": { - "resolve-from": "3.0.0" + "resolve-from": "^3.0.0" } }, "resolve-from": { @@ -4517,8 +4525,8 @@ "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", "dev": true, "requires": { - "onetime": "2.0.1", - "signal-exit": "3.0.2" + "onetime": "^2.0.0", + "signal-exit": "^3.0.2" } }, "rimraf": { @@ -4526,7 +4534,7 @@ "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.4.5.tgz", "integrity": "sha1-7nEM5dk6j9uFb7Xqj/Di11k0sto=", "requires": { - "glob": "6.0.4" + "glob": "^6.0.1" } }, "safe-buffer": { @@ -4559,7 +4567,7 @@ "integrity": "sha1-S7uEN8jTfksM8aaP1ybsbWRdbTY=", "dev": true, "requires": { - "semver": "5.3.0" + "semver": "^5.0.3" } }, "serialize-error": { @@ -4585,7 +4593,7 @@ "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", "dev": true, "requires": { - "shebang-regex": "1.0.0" + "shebang-regex": "^1.0.0" } }, "shebang-regex": { @@ -4611,7 +4619,7 @@ "integrity": "sha512-POqxBK6Lb3q6s047D/XsDVNPnF9Dl8JSaqe9h9lURl0OdNqy/ujDrOiIHtsqXMGbWWTIomRzAMaTyawAU//Reg==", "dev": true, "requires": { - "is-fullwidth-code-point": "2.0.0" + "is-fullwidth-code-point": "^2.0.0" }, "dependencies": { "is-fullwidth-code-point": { @@ -4633,7 +4641,7 @@ "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "requires": { - "hoek": "4.2.1" + "hoek": "4.x.x" } }, "sort-keys": { @@ -4642,7 +4650,7 @@ "integrity": "sha1-ZYU1WEhh7JfXMNbPQYIuH1ZoQSg=", "dev": true, "requires": { - "is-plain-obj": "1.1.0" + "is-plain-obj": "^1.0.0" } }, "source-map": { @@ -4657,7 +4665,7 @@ "integrity": "sha512-PETSPG6BjY1AHs2t64vS2aqAgu6dMIMXJULWFBGbh2Gr8nVLbCFDo6i/RMMvviIQ2h1Z8+5gQhVKSn2je9nmdg==", "dev": true, "requires": { - "source-map": "0.6.1" + "source-map": "^0.6.0" }, "dependencies": { "source-map": { @@ -4674,8 +4682,8 @@ "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { - "spdx-expression-parse": "3.0.0", - "spdx-license-ids": "3.0.0" + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" } }, "spdx-exceptions": { @@ -4690,8 +4698,8 @@ "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { - "spdx-exceptions": "2.1.0", - "spdx-license-ids": "3.0.0" + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" } }, "spdx-license-ids": { @@ -4711,14 +4719,14 @@ "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.14.1.tgz", "integrity": "sha1-Ew9Zde3a2WPx1W+SuaxsUfqfg+s=", "requires": { - "asn1": "0.2.3", - "assert-plus": "1.0.0", - "bcrypt-pbkdf": "1.0.1", - "dashdash": "1.14.1", - "ecc-jsbn": "0.1.1", - "getpass": "0.1.7", - "jsbn": "0.1.1", - "tweetnacl": "0.14.5" + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "tweetnacl": "~0.14.0" } }, "stack-utils": { @@ -4732,9 +4740,9 @@ "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "requires": { - "code-point-at": "1.1.0", - "is-fullwidth-code-point": "1.0.0", - "strip-ansi": "3.0.1" + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" } }, "string_decoder": { @@ -4742,7 +4750,7 @@ "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "requires": { - "safe-buffer": "5.1.1" + "safe-buffer": "~5.1.0" } }, "stringstream": { @@ -4755,7 +4763,7 @@ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "requires": { - "ansi-regex": "2.1.1" + "ansi-regex": "^2.0.0" } }, "strip-bom": { @@ -4770,7 +4778,7 @@ "integrity": "sha1-HLRar1dTD0yvhsf3UXnSyaUd1XI=", "dev": true, "requires": { - "is-utf8": "0.2.1" + "is-utf8": "^0.2.1" } }, "strip-eof": { @@ -4785,7 +4793,7 @@ "integrity": "sha1-DHlipq3vp7vUrDZkYKY4VSrhoKI=", "dev": true, "requires": { - "get-stdin": "4.0.1" + "get-stdin": "^4.0.1" } }, "strip-json-comments": { @@ -4799,11 +4807,11 @@ "integrity": "sha512-HZJ3geIMPgVwKk2VsmO5YHqnnJYl6bV5A9JW2uzqV43WmpgliNEYbuvukfor7URpaqpxuw3CfZ3ONdVbZjCgIA==", "dev": true, "requires": { - "arrify": "1.0.1", - "indent-string": "3.2.0", - "js-yaml": "3.11.0", - "serialize-error": "2.1.0", - "strip-ansi": "4.0.0" + "arrify": "^1.0.1", + "indent-string": "^3.2.0", + "js-yaml": "^3.10.0", + "serialize-error": "^2.1.0", + "strip-ansi": "^4.0.0" }, "dependencies": { "ansi-regex": { @@ -4818,7 +4826,7 @@ "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "dev": true, "requires": { - "ansi-regex": "3.0.0" + "ansi-regex": "^3.0.0" } } } @@ -4829,7 +4837,7 @@ "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", "dev": true, "requires": { - "has-flag": "3.0.0" + "has-flag": "^3.0.0" }, "dependencies": { "has-flag": { @@ -4851,13 +4859,13 @@ "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.1.tgz", "integrity": "sha512-O+v1r9yN4tOsvl90p5HAP4AEqbYhx4036AGMm075fH9F8Qwi3oJ+v4u50FkT/KkvywNGtwkk0zRI+8eYm1X/xg==", "requires": { - "chownr": "1.0.1", - "fs-minipass": "1.2.5", - "minipass": "2.2.4", - "minizlib": "1.1.0", - "mkdirp": "0.5.1", - "safe-buffer": "5.1.1", - "yallist": "3.0.2" + "chownr": "^1.0.1", + "fs-minipass": "^1.2.5", + "minipass": "^2.2.4", + "minizlib": "^1.1.0", + "mkdirp": "^0.5.0", + "safe-buffer": "^5.1.1", + "yallist": "^3.0.2" } }, "term-size": { @@ -4866,7 +4874,7 @@ "integrity": "sha1-RYuDiH8oj8Vtb/+/rSYuJmOO+mk=", "dev": true, "requires": { - "execa": "0.7.0" + "execa": "^0.7.0" } }, "text-table": { @@ -4881,8 +4889,8 @@ "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", "dev": true, "requires": { - "readable-stream": "2.3.6", - "xtend": "4.0.1" + "readable-stream": "^2.1.5", + "xtend": "~4.0.1" } }, "time-zone": { @@ -4908,7 +4916,7 @@ "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "requires": { - "punycode": "1.4.1" + "punycode": "^1.4.1" } }, "trim-newlines": { @@ -4934,7 +4942,7 @@ "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", "requires": { - "safe-buffer": "5.1.1" + "safe-buffer": "^5.0.1" } }, "tweetnacl": { @@ -4955,7 +4963,7 @@ "integrity": "sha1-nhBXzKhRq7kzmPizOuGHuZyuwRo=", "dev": true, "requires": { - "crypto-random-string": "1.0.0" + "crypto-random-string": "^1.0.0" } }, "unique-temp-dir": { @@ -4964,8 +4972,8 @@ "integrity": "sha1-bc6VsmgcoAPuv7MEpBX5y6vMU4U=", "dev": true, "requires": { - "mkdirp": "0.5.1", - "os-tmpdir": "1.0.2", + "mkdirp": "^0.5.1", + "os-tmpdir": "^1.0.1", "uid2": "0.0.3" } }, @@ -4981,16 +4989,16 @@ "integrity": "sha512-gwMdhgJHGuj/+wHJJs9e6PcCszpxR1b236igrOkUofGhqJuG+amlIKwApH1IW1WWl7ovZxsX49lMBWLxSdm5Dw==", "dev": true, "requires": { - "boxen": "1.3.0", - "chalk": "2.4.0", - "configstore": "3.1.2", - "import-lazy": "2.1.0", - "is-ci": "1.1.0", - "is-installed-globally": "0.1.0", - "is-npm": "1.0.0", - "latest-version": "3.1.0", - "semver-diff": "2.1.0", - "xdg-basedir": "3.0.0" + "boxen": "^1.2.1", + "chalk": "^2.0.1", + "configstore": "^3.0.0", + "import-lazy": "^2.1.0", + "is-ci": "^1.0.10", + "is-installed-globally": "^0.1.0", + "is-npm": "^1.0.0", + "latest-version": "^3.0.0", + "semver-diff": "^2.0.0", + "xdg-basedir": "^3.0.0" } }, "url-parse-lax": { @@ -4999,7 +5007,7 @@ "integrity": "sha1-evjzA2Rem9eaJy56FKxovAYJ2nM=", "dev": true, "requires": { - "prepend-http": "1.0.4" + "prepend-http": "^1.0.1" } }, "util-deprecate": { @@ -5018,8 +5026,8 @@ "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { - "spdx-correct": "3.0.0", - "spdx-expression-parse": "3.0.0" + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" } }, "verror": { @@ -5027,9 +5035,9 @@ "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", "requires": { - "assert-plus": "1.0.0", + "assert-plus": "^1.0.0", "core-util-is": "1.0.2", - "extsprintf": "1.3.0" + "extsprintf": "^1.2.0" } }, "well-known-symbols": { @@ -5043,7 +5051,7 @@ "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "requires": { - "isexe": "2.0.0" + "isexe": "^2.0.0" } }, "wide-align": { @@ -5051,7 +5059,7 @@ "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.2.tgz", "integrity": "sha512-ijDLlyQ7s6x1JgCLur53osjm/UXUYD9+0PbYKrBsYisYXzCxN+HC3mYDNy/dWdmf3AwqwU3CXwDCvsNgGK1S0w==", "requires": { - "string-width": "1.0.2" + "string-width": "^1.0.2" } }, "widest-line": { @@ -5060,7 +5068,7 @@ "integrity": "sha1-AUKk6KJD+IgsAjOqDgKBqnYVInM=", "dev": true, "requires": { - "string-width": "2.1.1" + "string-width": "^2.1.1" }, "dependencies": { "ansi-regex": { @@ -5081,8 +5089,8 @@ "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", "dev": true, "requires": { - "is-fullwidth-code-point": "2.0.0", - "strip-ansi": "4.0.0" + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" } }, "strip-ansi": { @@ -5091,7 +5099,7 @@ "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "dev": true, "requires": { - "ansi-regex": "3.0.0" + "ansi-regex": "^3.0.0" } } } @@ -5107,9 +5115,9 @@ "integrity": "sha512-xuPeK4OdjWqtfi59ylvVL0Yn35SF3zgcAcv7rBPFHVaEapaDr4GdGgm3j7ckTwH9wHL7fGmgfAnb0+THrHb8tA==", "dev": true, "requires": { - "graceful-fs": "4.1.11", - "imurmurhash": "0.1.4", - "signal-exit": "3.0.2" + "graceful-fs": "^4.1.11", + "imurmurhash": "^0.1.4", + "signal-exit": "^3.0.2" } }, "write-json-file": { @@ -5118,12 +5126,12 @@ "integrity": "sha1-K2TIozAE1UuGmMdtWFp3zrYdoy8=", "dev": true, "requires": { - "detect-indent": "5.0.0", - "graceful-fs": "4.1.11", - "make-dir": "1.2.0", - "pify": "3.0.0", - "sort-keys": "2.0.0", - "write-file-atomic": "2.3.0" + "detect-indent": "^5.0.0", + "graceful-fs": "^4.1.2", + "make-dir": "^1.0.0", + "pify": "^3.0.0", + "sort-keys": "^2.0.0", + "write-file-atomic": "^2.0.0" }, "dependencies": { "detect-indent": { @@ -5146,8 +5154,8 @@ "integrity": "sha1-AwqZlMyZk9JbTnWp8aGSNgcpHOk=", "dev": true, "requires": { - "sort-keys": "2.0.0", - "write-json-file": "2.3.0" + "sort-keys": "^2.0.0", + "write-json-file": "^2.2.0" } }, "xdg-basedir": { From c581abaaf7ad02bdb373e2600ff9472ee149c8d4 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sun, 29 Apr 2018 18:39:10 +0200 Subject: [PATCH 185/190] commented DISPOSE_EVENT macro --- src/includes/control.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/includes/control.h b/src/includes/control.h index 14ae6a9..44d74a8 100644 --- a/src/includes/control.h +++ b/src/includes/control.h @@ -22,10 +22,10 @@ } #define DISPOSE_EVENT(NAME) \ - if (NAME##Callback != nullptr) { \ - delete NAME##Callback; \ - NAME##Callback = nullptr; \ - } + //if (NAME##Callback != nullptr) { \ + // delete NAME##Callback; \ + // NAME##Callback = nullptr; \ + //} typedef void (*DestroyCb)(uiControl *); From feaedf014045204bc1fb2bf5d82fd8cf133ef7d0 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Sun, 29 Apr 2018 20:02:09 +0200 Subject: [PATCH 186/190] multiline comments with // cause warnings when compiling with gcc on linux --- src/includes/control.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/includes/control.h b/src/includes/control.h index 44d74a8..220558c 100644 --- a/src/includes/control.h +++ b/src/includes/control.h @@ -22,10 +22,10 @@ } #define DISPOSE_EVENT(NAME) \ - //if (NAME##Callback != nullptr) { \ - // delete NAME##Callback; \ - // NAME##Callback = nullptr; \ - //} + /*if (NAME##Callback != nullptr) { \ + delete NAME##Callback; \ + NAME##Callback = nullptr; \ + }*/ typedef void (*DestroyCb)(uiControl *); From 46291ff331784b5831696cfe3fa02dc41117adc2 Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Mon, 30 Apr 2018 09:54:36 +0200 Subject: [PATCH 187/190] bump libui-download version to get rid of security issues --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 15768de..75a7eaf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3296,9 +3296,9 @@ } }, "libui-download": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/libui-download/-/libui-download-1.0.0.tgz", - "integrity": "sha512-nW3PgUCPQoxKBce9gkLkmiUH2163FpwFLnXorO/IJhFC4h7JgJRPRKWSGYZvlrhU18rZr93DqECE90cCS2pW1Q==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/libui-download/-/libui-download-1.1.0.tgz", + "integrity": "sha512-kn/VrmvI4zUNjH+GsUelLMKNiuNG/T9q7eEWXSLXQwcpQvhsvUZQO8VxeiNfYw4wMqnYUOyPynbx8qfXJt3ZaQ==", "requires": { "debug": "^2.2.0", "home-path": "^1.0.1", @@ -3308,7 +3308,7 @@ "pinkie-promise": "^2.0.1", "rc": "^1.1.2", "regenerator-runtime": "^0.9.5", - "request": "^2.72.0", + "request": "^2.85.0", "tar": "^4.4.0" } }, diff --git a/package.json b/package.json index 7763157..39ac321 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "dependencies": { "@mischnic/async-hooks": "^0.0.4", "autogypi": "^0.2.2", - "libui-download": "^1.0.0", + "libui-download": "^1.1.0", "nbind": "^0.3.14", "node-gyp": "^3.3.1" } From 998adc464680443f48704f77af57f65638170063 Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Mon, 30 Apr 2018 09:55:28 +0200 Subject: [PATCH 188/190] Handle null with clearTimeout/Interval --- index.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) mode change 100755 => 100644 index.js diff --git a/index.js b/index.js old mode 100755 new mode 100644 index 481a6f8..2933067 --- a/index.js +++ b/index.js @@ -50,7 +50,6 @@ function startLoop() { asyncHook.enable(); setTimeoutNode = global.setTimeout; - global.setTimeout = function(cb, t) { const args = Array.prototype.slice.call(arguments, 2); return binding.lib.setTimeout(function() { @@ -59,7 +58,11 @@ function startLoop() { }; clearTimeoutNode = global.clearTimeout; - global.clearTimeout = binding.lib.clearTimeout; + global.clearTimeout = function(obj) { + if (obj) { + binding.lib.clearTimeout(obj); + } + }; setIntervalNode = global.setInterval; global.setInterval = function(cb, t) { @@ -70,7 +73,11 @@ function startLoop() { }; clearIntervalNode = global.clearInterval; - global.clearInterval = binding.lib.clearInterval; + global.clearInterval = function(obj) { + if (obj) { + binding.lib.clearInterval(obj); + } + } } // This is called when a new async handle From ab47e03a3b65274e42f361fb4a41e5b87767e2cb Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Mon, 30 Apr 2018 10:45:10 +0200 Subject: [PATCH 189/190] Further mitigation for clear timers problem. Check if the timeout or interval is created by us. If not, calls the original node functions. --- examples/event-loop.js | 10 +- index.js | 16 +- package-lock.json | 1866 ++++++++++++++++++++-------------------- 3 files changed, 955 insertions(+), 937 deletions(-) diff --git a/examples/event-loop.js b/examples/event-loop.js index 79f7044..9494853 100644 --- a/examples/event-loop.js +++ b/examples/event-loop.js @@ -113,13 +113,19 @@ function makeToolbar() { toolbar.append(btnPromise, false); const btnCustom = new libui.UiButton('Custom setTimeout'); + let timeoutHandle = null; btnCustom.onClicked(() => { + if (timeoutHandle) { + clearTimeout(timeoutHandle); + timeoutHandle = null; + return; + } const now = Date.now(); - setTimeout((a, b, c) => { + timeoutHandle = setTimeout((a, b, c) => { const elapsed = Date.now() - now; logAppend(`Custom setTimeout: ${now} - elapsed ${elapsed} ms. Args: ${a} ${b} ${c}`); - }, 10, 'custom', 'args', 2); + }, 1000, 'custom', 'args', 2); }); toolbar.append(btnCustom, false); diff --git a/index.js b/index.js index 2933067..12b140d 100644 --- a/index.js +++ b/index.js @@ -59,8 +59,14 @@ function startLoop() { clearTimeoutNode = global.clearTimeout; global.clearTimeout = function(obj) { - if (obj) { + if (obj && obj.constructor === binding.lib.TimeoutHandle) { + // console.log('patched clearTimeout called'); binding.lib.clearTimeout(obj); + } else { + // console.log('node clearTimeout called'); + // not created by us, use original + // clearTimeoutNode + clearTimeoutNode(obj); } }; @@ -74,8 +80,14 @@ function startLoop() { clearIntervalNode = global.clearInterval; global.clearInterval = function(obj) { - if (obj) { + if (obj && obj.constructor === binding.lib.TimeoutHandle) { + // console.log('patched clearInterval called'); binding.lib.clearInterval(obj); + } else { + // console.log('node clearInterval called'); + // not created by us, use original + // clearTimeoutNode + clearIntervalNode(obj); } } } diff --git a/package-lock.json b/package-lock.json index 75a7eaf..0c62211 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,18 +16,18 @@ "integrity": "sha512-oWqTnIGXW3k72UFidXzW0ONlO7hnO9x02S/QReJ7NBGeiBH9cUHY9+EfV6C8PXC6YJH++WrliEq03wMSJGNZFg==", "dev": true, "requires": { - "babel-plugin-check-es2015-constants": "^6.8.0", - "babel-plugin-syntax-trailing-function-commas": "^6.20.0", - "babel-plugin-transform-async-to-generator": "^6.16.0", - "babel-plugin-transform-es2015-destructuring": "^6.19.0", - "babel-plugin-transform-es2015-function-name": "^6.9.0", - "babel-plugin-transform-es2015-modules-commonjs": "^6.18.0", - "babel-plugin-transform-es2015-parameters": "^6.21.0", - "babel-plugin-transform-es2015-spread": "^6.8.0", - "babel-plugin-transform-es2015-sticky-regex": "^6.8.0", - "babel-plugin-transform-es2015-unicode-regex": "^6.11.0", - "babel-plugin-transform-exponentiation-operator": "^6.8.0", - "package-hash": "^1.2.0" + "babel-plugin-check-es2015-constants": "6.22.0", + "babel-plugin-syntax-trailing-function-commas": "6.22.0", + "babel-plugin-transform-async-to-generator": "6.24.1", + "babel-plugin-transform-es2015-destructuring": "6.23.0", + "babel-plugin-transform-es2015-function-name": "6.24.1", + "babel-plugin-transform-es2015-modules-commonjs": "6.26.0", + "babel-plugin-transform-es2015-parameters": "6.24.1", + "babel-plugin-transform-es2015-spread": "6.22.0", + "babel-plugin-transform-es2015-sticky-regex": "6.24.1", + "babel-plugin-transform-es2015-unicode-regex": "6.24.1", + "babel-plugin-transform-exponentiation-operator": "6.24.1", + "package-hash": "1.2.0" }, "dependencies": { "md5-hex": { @@ -36,7 +36,7 @@ "integrity": "sha1-0sSv6YPENwZiF5uMrRRSGRNQRsQ=", "dev": true, "requires": { - "md5-o-matic": "^0.1.1" + "md5-o-matic": "0.1.1" } }, "package-hash": { @@ -45,7 +45,7 @@ "integrity": "sha1-AD5WzVe3NqbtYRTMK4FUJnJ3DkQ=", "dev": true, "requires": { - "md5-hex": "^1.3.0" + "md5-hex": "1.3.0" } } } @@ -56,8 +56,8 @@ "integrity": "sha1-ze0RlqjY2TgaUJJAq5LpGl7Aafc=", "dev": true, "requires": { - "@ava/babel-plugin-throws-helper": "^2.0.0", - "babel-plugin-espower": "^2.3.2" + "@ava/babel-plugin-throws-helper": "2.0.0", + "babel-plugin-espower": "2.4.0" } }, "@ava/write-file-atomic": { @@ -66,9 +66,9 @@ "integrity": "sha512-BTNB3nGbEfJT+69wuqXFr/bQH7Vr7ihx2xGOMNqPgDGhwspoZhiWumDDZNjBy7AScmqS5CELIOGtPVXESyrnDA==", "dev": true, "requires": { - "graceful-fs": "^4.1.11", - "imurmurhash": "^0.1.4", - "slide": "^1.1.5" + "graceful-fs": "4.1.11", + "imurmurhash": "0.1.4", + "slide": "1.1.6" } }, "@concordance/react": { @@ -77,7 +77,7 @@ "integrity": "sha512-htrsRaQX8Iixlsek8zQU7tE8wcsTQJ5UhZkSPEA8slCDAisKpC/2VgU/ucPn32M5/LjGGXRaUEKvEw1Wiuu4zQ==", "dev": true, "requires": { - "arrify": "^1.0.1" + "arrify": "1.0.1" } }, "@ladjs/time-require": { @@ -86,10 +86,10 @@ "integrity": "sha512-weIbJqTMfQ4r1YX85u54DKfjLZs2jwn1XZ6tIOP/pFgMwhIN5BAtaCp/1wn9DzyLsDR9tW0R2NIePcVJ45ivQQ==", "dev": true, "requires": { - "chalk": "^0.4.0", - "date-time": "^0.1.1", - "pretty-ms": "^0.2.1", - "text-table": "^0.2.0" + "chalk": "0.4.0", + "date-time": "0.1.1", + "pretty-ms": "0.2.2", + "text-table": "0.2.0" }, "dependencies": { "ansi-styles": { @@ -104,9 +104,9 @@ "integrity": "sha1-UZmj3c0MHv4jvAjBsCewYXbgxk8=", "dev": true, "requires": { - "ansi-styles": "~1.0.0", - "has-color": "~0.1.0", - "strip-ansi": "~0.1.0" + "ansi-styles": "1.0.0", + "has-color": "0.1.7", + "strip-ansi": "0.1.1" } }, "pretty-ms": { @@ -115,7 +115,7 @@ "integrity": "sha1-2oeaaC/zOjcBEEbxPWJ/Z8c7hPY=", "dev": true, "requires": { - "parse-ms": "^0.1.0" + "parse-ms": "0.1.2" } }, "strip-ansi": { @@ -131,7 +131,7 @@ "resolved": "https://registry.npmjs.org/@mischnic/async-hooks/-/async-hooks-0.0.4.tgz", "integrity": "sha512-mJL/Rckke7oIR8c1Dk+40Y0a+Ss712hyJqROOurl5VE8gQY+GbbebKcNuWIRxlZTrQQq8mfo7oE9xKZXrtQTjQ==", "requires": { - "es6-shim": "^0.35.3" + "es6-shim": "0.35.3" } }, "abbrev": { @@ -144,10 +144,10 @@ "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", "requires": { - "co": "^4.6.0", - "fast-deep-equal": "^1.0.0", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.3.0" + "co": "4.6.0", + "fast-deep-equal": "1.1.0", + "fast-json-stable-stringify": "2.0.0", + "json-schema-traverse": "0.3.1" } }, "ansi-align": { @@ -156,7 +156,7 @@ "integrity": "sha1-w2rsy6VjuJzrVW82kPCx2eNUf38=", "dev": true, "requires": { - "string-width": "^2.0.0" + "string-width": "2.1.1" }, "dependencies": { "ansi-regex": { @@ -177,8 +177,8 @@ "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", "dev": true, "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" + "is-fullwidth-code-point": "2.0.0", + "strip-ansi": "4.0.0" } }, "strip-ansi": { @@ -187,7 +187,7 @@ "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "dev": true, "requires": { - "ansi-regex": "^3.0.0" + "ansi-regex": "3.0.0" } } } @@ -209,7 +209,7 @@ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "color-convert": "^1.9.0" + "color-convert": "1.9.1" } }, "anymatch": { @@ -218,8 +218,8 @@ "integrity": "sha512-0XNayC8lTHQ2OI8aljNCN3sSx6hsr/1+rlcDAotXJR7C1oZZHCNsfpbKwMjRA3Uqb5tF1Rae2oloTr4xpq+WjA==", "dev": true, "requires": { - "micromatch": "^2.1.5", - "normalize-path": "^2.0.0" + "micromatch": "2.3.11", + "normalize-path": "2.1.1" } }, "aproba": { @@ -232,8 +232,8 @@ "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.4.tgz", "integrity": "sha1-u13KOCu5TwXhUZQ3PRb9O6HKEQ0=", "requires": { - "delegates": "^1.0.0", - "readable-stream": "^2.0.6" + "delegates": "1.0.0", + "readable-stream": "2.3.6" } }, "argparse": { @@ -242,7 +242,7 @@ "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { - "sprintf-js": "~1.0.2" + "sprintf-js": "1.0.3" } }, "arr-diff": { @@ -251,7 +251,7 @@ "integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=", "dev": true, "requires": { - "arr-flatten": "^1.0.1" + "arr-flatten": "1.1.0" } }, "arr-exclude": { @@ -284,7 +284,7 @@ "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", "dev": true, "requires": { - "array-uniq": "^1.0.1" + "array-uniq": "1.0.3" } }, "array-uniq": { @@ -343,9 +343,9 @@ "resolved": "https://registry.npmjs.org/autogypi/-/autogypi-0.2.2.tgz", "integrity": "sha1-JYurX3hXdVsJvqxqZB/qEw/0Yi0=", "requires": { - "bluebird": "^3.4.0", - "commander": "~2.9.0", - "resolve": "~1.1.7" + "bluebird": "3.5.1", + "commander": "2.9.0", + "resolve": "1.1.7" } }, "ava": { @@ -354,89 +354,89 @@ "integrity": "sha512-4lGNJCf6xL8SvsKVEKxEE46se7JAUIAZoKHw9itTQuwcsydhpAMkBs5gOOiWiwt0JKNIuXWc2/r4r8ZdcNrBEw==", "dev": true, "requires": { - "@ava/babel-preset-stage-4": "^1.1.0", - "@ava/babel-preset-transform-test-files": "^3.0.0", - "@ava/write-file-atomic": "^2.2.0", - "@concordance/react": "^1.0.0", - "@ladjs/time-require": "^0.1.4", - "ansi-escapes": "^3.0.0", - "ansi-styles": "^3.1.0", - "arr-flatten": "^1.0.1", - "array-union": "^1.0.1", - "array-uniq": "^1.0.2", - "arrify": "^1.0.0", - "auto-bind": "^1.1.0", - "ava-init": "^0.2.0", - "babel-core": "^6.17.0", - "babel-generator": "^6.26.0", - "babel-plugin-syntax-object-rest-spread": "^6.13.0", - "bluebird": "^3.0.0", - "caching-transform": "^1.0.0", - "chalk": "^2.0.1", - "chokidar": "^1.4.2", - "clean-stack": "^1.1.1", - "clean-yaml-object": "^0.1.0", - "cli-cursor": "^2.1.0", - "cli-spinners": "^1.0.0", - "cli-truncate": "^1.0.0", - "co-with-promise": "^4.6.0", - "code-excerpt": "^2.1.1", - "common-path-prefix": "^1.0.0", - "concordance": "^3.0.0", - "convert-source-map": "^1.5.1", - "core-assert": "^0.2.0", - "currently-unhandled": "^0.4.1", - "debug": "^3.0.1", - "dot-prop": "^4.1.0", - "empower-core": "^0.6.1", - "equal-length": "^1.0.0", - "figures": "^2.0.0", - "find-cache-dir": "^1.0.0", - "fn-name": "^2.0.0", - "get-port": "^3.0.0", - "globby": "^6.0.0", - "has-flag": "^2.0.0", - "hullabaloo-config-manager": "^1.1.0", - "ignore-by-default": "^1.0.0", - "import-local": "^0.1.1", - "indent-string": "^3.0.0", - "is-ci": "^1.0.7", - "is-generator-fn": "^1.0.0", - "is-obj": "^1.0.0", - "is-observable": "^1.0.0", - "is-promise": "^2.1.0", - "last-line-stream": "^1.0.0", - "lodash.clonedeepwith": "^4.5.0", - "lodash.debounce": "^4.0.3", - "lodash.difference": "^4.3.0", - "lodash.flatten": "^4.2.0", - "loud-rejection": "^1.2.0", - "make-dir": "^1.0.0", - "matcher": "^1.0.0", - "md5-hex": "^2.0.0", - "meow": "^3.7.0", - "ms": "^2.0.0", - "multimatch": "^2.1.0", - "observable-to-promise": "^0.5.0", - "option-chain": "^1.0.0", - "package-hash": "^2.0.0", - "pkg-conf": "^2.0.0", - "plur": "^2.0.0", - "pretty-ms": "^3.0.0", - "require-precompiled": "^0.1.0", - "resolve-cwd": "^2.0.0", - "safe-buffer": "^5.1.1", - "semver": "^5.4.1", - "slash": "^1.0.0", - "source-map-support": "^0.5.0", - "stack-utils": "^1.0.1", - "strip-ansi": "^4.0.0", - "strip-bom-buf": "^1.0.0", - "supertap": "^1.0.0", - "supports-color": "^5.0.0", - "trim-off-newlines": "^1.0.1", - "unique-temp-dir": "^1.0.0", - "update-notifier": "^2.3.0" + "@ava/babel-preset-stage-4": "1.1.0", + "@ava/babel-preset-transform-test-files": "3.0.0", + "@ava/write-file-atomic": "2.2.0", + "@concordance/react": "1.0.0", + "@ladjs/time-require": "0.1.4", + "ansi-escapes": "3.1.0", + "ansi-styles": "3.2.1", + "arr-flatten": "1.1.0", + "array-union": "1.0.2", + "array-uniq": "1.0.3", + "arrify": "1.0.1", + "auto-bind": "1.2.0", + "ava-init": "0.2.1", + "babel-core": "6.26.0", + "babel-generator": "6.26.1", + "babel-plugin-syntax-object-rest-spread": "6.13.0", + "bluebird": "3.5.1", + "caching-transform": "1.0.1", + "chalk": "2.4.0", + "chokidar": "1.7.0", + "clean-stack": "1.3.0", + "clean-yaml-object": "0.1.0", + "cli-cursor": "2.1.0", + "cli-spinners": "1.3.1", + "cli-truncate": "1.1.0", + "co-with-promise": "4.6.0", + "code-excerpt": "2.1.1", + "common-path-prefix": "1.0.0", + "concordance": "3.0.0", + "convert-source-map": "1.5.1", + "core-assert": "0.2.1", + "currently-unhandled": "0.4.1", + "debug": "3.1.0", + "dot-prop": "4.2.0", + "empower-core": "0.6.2", + "equal-length": "1.0.1", + "figures": "2.0.0", + "find-cache-dir": "1.0.0", + "fn-name": "2.0.1", + "get-port": "3.2.0", + "globby": "6.1.0", + "has-flag": "2.0.0", + "hullabaloo-config-manager": "1.1.1", + "ignore-by-default": "1.0.1", + "import-local": "0.1.1", + "indent-string": "3.2.0", + "is-ci": "1.1.0", + "is-generator-fn": "1.0.0", + "is-obj": "1.0.1", + "is-observable": "1.1.0", + "is-promise": "2.1.0", + "last-line-stream": "1.0.0", + "lodash.clonedeepwith": "4.5.0", + "lodash.debounce": "4.0.8", + "lodash.difference": "4.5.0", + "lodash.flatten": "4.4.0", + "loud-rejection": "1.6.0", + "make-dir": "1.2.0", + "matcher": "1.1.0", + "md5-hex": "2.0.0", + "meow": "3.7.0", + "ms": "2.0.0", + "multimatch": "2.1.0", + "observable-to-promise": "0.5.0", + "option-chain": "1.0.0", + "package-hash": "2.0.0", + "pkg-conf": "2.1.0", + "plur": "2.1.2", + "pretty-ms": "3.1.0", + "require-precompiled": "0.1.0", + "resolve-cwd": "2.0.0", + "safe-buffer": "5.1.1", + "semver": "5.5.0", + "slash": "1.0.0", + "source-map-support": "0.5.4", + "stack-utils": "1.0.1", + "strip-ansi": "4.0.0", + "strip-bom-buf": "1.0.0", + "supertap": "1.0.0", + "supports-color": "5.4.0", + "trim-off-newlines": "1.0.1", + "unique-temp-dir": "1.0.0", + "update-notifier": "2.5.0" }, "dependencies": { "ansi-regex": { @@ -466,7 +466,7 @@ "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "dev": true, "requires": { - "ansi-regex": "^3.0.0" + "ansi-regex": "3.0.0" } } } @@ -477,11 +477,11 @@ "integrity": "sha512-lXwK5LM+2g1euDRqW1mcSX/tqzY1QU7EjKpqayFPPtNRmbSYZ8RzPO5tqluTToijmtjp2M+pNpVdbcHssC4glg==", "dev": true, "requires": { - "arr-exclude": "^1.0.0", - "execa": "^0.7.0", - "has-yarn": "^1.0.0", - "read-pkg-up": "^2.0.0", - "write-pkg": "^3.1.0" + "arr-exclude": "1.0.0", + "execa": "0.7.0", + "has-yarn": "1.0.0", + "read-pkg-up": "2.0.0", + "write-pkg": "3.1.0" } }, "aws-sign2": { @@ -500,9 +500,9 @@ "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", "dev": true, "requires": { - "chalk": "^1.1.3", - "esutils": "^2.0.2", - "js-tokens": "^3.0.2" + "chalk": "1.1.3", + "esutils": "2.0.2", + "js-tokens": "3.0.2" }, "dependencies": { "ansi-styles": { @@ -517,11 +517,11 @@ "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" + "ansi-styles": "2.2.1", + "escape-string-regexp": "1.0.5", + "has-ansi": "2.0.0", + "strip-ansi": "3.0.1", + "supports-color": "2.0.0" } }, "supports-color": { @@ -538,25 +538,25 @@ "integrity": "sha1-rzL3izGm/O8RnIew/Y2XU/A6C7g=", "dev": true, "requires": { - "babel-code-frame": "^6.26.0", - "babel-generator": "^6.26.0", - "babel-helpers": "^6.24.1", - "babel-messages": "^6.23.0", - "babel-register": "^6.26.0", - "babel-runtime": "^6.26.0", - "babel-template": "^6.26.0", - "babel-traverse": "^6.26.0", - "babel-types": "^6.26.0", - "babylon": "^6.18.0", - "convert-source-map": "^1.5.0", - "debug": "^2.6.8", - "json5": "^0.5.1", - "lodash": "^4.17.4", - "minimatch": "^3.0.4", - "path-is-absolute": "^1.0.1", - "private": "^0.1.7", - "slash": "^1.0.0", - "source-map": "^0.5.6" + "babel-code-frame": "6.26.0", + "babel-generator": "6.26.1", + "babel-helpers": "6.24.1", + "babel-messages": "6.23.0", + "babel-register": "6.26.0", + "babel-runtime": "6.26.0", + "babel-template": "6.26.0", + "babel-traverse": "6.26.0", + "babel-types": "6.26.0", + "babylon": "6.18.0", + "convert-source-map": "1.5.1", + "debug": "2.6.9", + "json5": "0.5.1", + "lodash": "4.17.5", + "minimatch": "3.0.4", + "path-is-absolute": "1.0.1", + "private": "0.1.8", + "slash": "1.0.0", + "source-map": "0.5.7" } }, "babel-generator": { @@ -565,14 +565,14 @@ "integrity": "sha512-HyfwY6ApZj7BYTcJURpM5tznulaBvyio7/0d4zFOeMPUmfxkCjHocCuoLa2SAGzBI8AREcH3eP3758F672DppA==", "dev": true, "requires": { - "babel-messages": "^6.23.0", - "babel-runtime": "^6.26.0", - "babel-types": "^6.26.0", - "detect-indent": "^4.0.0", - "jsesc": "^1.3.0", - "lodash": "^4.17.4", - "source-map": "^0.5.7", - "trim-right": "^1.0.1" + "babel-messages": "6.23.0", + "babel-runtime": "6.26.0", + "babel-types": "6.26.0", + "detect-indent": "4.0.0", + "jsesc": "1.3.0", + "lodash": "4.17.5", + "source-map": "0.5.7", + "trim-right": "1.0.1" }, "dependencies": { "jsesc": { @@ -589,9 +589,9 @@ "integrity": "sha1-zORReto1b0IgvK6KAsKzRvmlZmQ=", "dev": true, "requires": { - "babel-helper-explode-assignable-expression": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" + "babel-helper-explode-assignable-expression": "6.24.1", + "babel-runtime": "6.26.0", + "babel-types": "6.26.0" } }, "babel-helper-call-delegate": { @@ -600,10 +600,10 @@ "integrity": "sha1-7Oaqzdx25Bw0YfiL/Fdb0Nqi340=", "dev": true, "requires": { - "babel-helper-hoist-variables": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-traverse": "^6.24.1", - "babel-types": "^6.24.1" + "babel-helper-hoist-variables": "6.24.1", + "babel-runtime": "6.26.0", + "babel-traverse": "6.26.0", + "babel-types": "6.26.0" } }, "babel-helper-explode-assignable-expression": { @@ -612,9 +612,9 @@ "integrity": "sha1-8luCz33BBDPFX3BZLVdGQArCLKo=", "dev": true, "requires": { - "babel-runtime": "^6.22.0", - "babel-traverse": "^6.24.1", - "babel-types": "^6.24.1" + "babel-runtime": "6.26.0", + "babel-traverse": "6.26.0", + "babel-types": "6.26.0" } }, "babel-helper-function-name": { @@ -623,11 +623,11 @@ "integrity": "sha1-00dbjAPtmCQqJbSDUasYOZ01gKk=", "dev": true, "requires": { - "babel-helper-get-function-arity": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1", - "babel-traverse": "^6.24.1", - "babel-types": "^6.24.1" + "babel-helper-get-function-arity": "6.24.1", + "babel-runtime": "6.26.0", + "babel-template": "6.26.0", + "babel-traverse": "6.26.0", + "babel-types": "6.26.0" } }, "babel-helper-get-function-arity": { @@ -636,8 +636,8 @@ "integrity": "sha1-j3eCqpNAfEHTqlCQj4mwMbG2hT0=", "dev": true, "requires": { - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" + "babel-runtime": "6.26.0", + "babel-types": "6.26.0" } }, "babel-helper-hoist-variables": { @@ -646,8 +646,8 @@ "integrity": "sha1-HssnaJydJVE+rbyZFKc/VAi+enY=", "dev": true, "requires": { - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" + "babel-runtime": "6.26.0", + "babel-types": "6.26.0" } }, "babel-helper-regex": { @@ -656,9 +656,9 @@ "integrity": "sha1-MlxZ+QL4LyS3T6zu0DY5VPZJXnI=", "dev": true, "requires": { - "babel-runtime": "^6.26.0", - "babel-types": "^6.26.0", - "lodash": "^4.17.4" + "babel-runtime": "6.26.0", + "babel-types": "6.26.0", + "lodash": "4.17.5" } }, "babel-helper-remap-async-to-generator": { @@ -667,11 +667,11 @@ "integrity": "sha1-XsWBgnrXI/7N04HxySg5BnbkVRs=", "dev": true, "requires": { - "babel-helper-function-name": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1", - "babel-traverse": "^6.24.1", - "babel-types": "^6.24.1" + "babel-helper-function-name": "6.24.1", + "babel-runtime": "6.26.0", + "babel-template": "6.26.0", + "babel-traverse": "6.26.0", + "babel-types": "6.26.0" } }, "babel-helpers": { @@ -680,8 +680,8 @@ "integrity": "sha1-NHHenK7DiOXIUOWX5Yom3fN2ArI=", "dev": true, "requires": { - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1" + "babel-runtime": "6.26.0", + "babel-template": "6.26.0" } }, "babel-messages": { @@ -690,7 +690,7 @@ "integrity": "sha1-8830cDhYA1sqKVHG7F7fbGLyYw4=", "dev": true, "requires": { - "babel-runtime": "^6.22.0" + "babel-runtime": "6.26.0" } }, "babel-plugin-check-es2015-constants": { @@ -699,7 +699,7 @@ "integrity": "sha1-NRV7EBQm/S/9PaP3XH0ekYNbv4o=", "dev": true, "requires": { - "babel-runtime": "^6.22.0" + "babel-runtime": "6.26.0" } }, "babel-plugin-espower": { @@ -708,13 +708,13 @@ "integrity": "sha512-/+SRpy7pKgTI28oEHfn1wkuM5QFAdRq8WNsOOih1dVrdV6A/WbNbRZyl0eX5eyDgtb0lOE27PeDFuCX2j8OxVg==", "dev": true, "requires": { - "babel-generator": "^6.1.0", - "babylon": "^6.1.0", - "call-matcher": "^1.0.0", - "core-js": "^2.0.0", - "espower-location-detector": "^1.0.0", - "espurify": "^1.6.0", - "estraverse": "^4.1.1" + "babel-generator": "6.26.1", + "babylon": "6.18.0", + "call-matcher": "1.0.1", + "core-js": "2.5.5", + "espower-location-detector": "1.0.0", + "espurify": "1.7.0", + "estraverse": "4.2.0" } }, "babel-plugin-syntax-async-functions": { @@ -747,9 +747,9 @@ "integrity": "sha1-ZTbjeK/2yx1VF6wOQOs+n8jQh2E=", "dev": true, "requires": { - "babel-helper-remap-async-to-generator": "^6.24.1", - "babel-plugin-syntax-async-functions": "^6.8.0", - "babel-runtime": "^6.22.0" + "babel-helper-remap-async-to-generator": "6.24.1", + "babel-plugin-syntax-async-functions": "6.13.0", + "babel-runtime": "6.26.0" } }, "babel-plugin-transform-es2015-destructuring": { @@ -758,7 +758,7 @@ "integrity": "sha1-mXux8auWf2gtKwh2/jWNYOdlxW0=", "dev": true, "requires": { - "babel-runtime": "^6.22.0" + "babel-runtime": "6.26.0" } }, "babel-plugin-transform-es2015-function-name": { @@ -767,9 +767,9 @@ "integrity": "sha1-g0yJhTvDaxrw86TF26qU/Y6sqos=", "dev": true, "requires": { - "babel-helper-function-name": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" + "babel-helper-function-name": "6.24.1", + "babel-runtime": "6.26.0", + "babel-types": "6.26.0" } }, "babel-plugin-transform-es2015-modules-commonjs": { @@ -778,10 +778,10 @@ "integrity": "sha1-DYOUApt9xqvhqX7xgeAHWN0uXYo=", "dev": true, "requires": { - "babel-plugin-transform-strict-mode": "^6.24.1", - "babel-runtime": "^6.26.0", - "babel-template": "^6.26.0", - "babel-types": "^6.26.0" + "babel-plugin-transform-strict-mode": "6.24.1", + "babel-runtime": "6.26.0", + "babel-template": "6.26.0", + "babel-types": "6.26.0" } }, "babel-plugin-transform-es2015-parameters": { @@ -790,12 +790,12 @@ "integrity": "sha1-V6w1GrScrxSpfNE7CfZv3wpiXys=", "dev": true, "requires": { - "babel-helper-call-delegate": "^6.24.1", - "babel-helper-get-function-arity": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1", - "babel-traverse": "^6.24.1", - "babel-types": "^6.24.1" + "babel-helper-call-delegate": "6.24.1", + "babel-helper-get-function-arity": "6.24.1", + "babel-runtime": "6.26.0", + "babel-template": "6.26.0", + "babel-traverse": "6.26.0", + "babel-types": "6.26.0" } }, "babel-plugin-transform-es2015-spread": { @@ -804,7 +804,7 @@ "integrity": "sha1-1taKmfia7cRTbIGlQujdnxdG+NE=", "dev": true, "requires": { - "babel-runtime": "^6.22.0" + "babel-runtime": "6.26.0" } }, "babel-plugin-transform-es2015-sticky-regex": { @@ -813,9 +813,9 @@ "integrity": "sha1-AMHNsaynERLN8M9hJsLta0V8zbw=", "dev": true, "requires": { - "babel-helper-regex": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" + "babel-helper-regex": "6.26.0", + "babel-runtime": "6.26.0", + "babel-types": "6.26.0" } }, "babel-plugin-transform-es2015-unicode-regex": { @@ -824,9 +824,9 @@ "integrity": "sha1-04sS9C6nMj9yk4fxinxa4frrNek=", "dev": true, "requires": { - "babel-helper-regex": "^6.24.1", - "babel-runtime": "^6.22.0", - "regexpu-core": "^2.0.0" + "babel-helper-regex": "6.26.0", + "babel-runtime": "6.26.0", + "regexpu-core": "2.0.0" } }, "babel-plugin-transform-exponentiation-operator": { @@ -835,9 +835,9 @@ "integrity": "sha1-KrDJx/MJj6SJB3cruBP+QejeOg4=", "dev": true, "requires": { - "babel-helper-builder-binary-assignment-operator-visitor": "^6.24.1", - "babel-plugin-syntax-exponentiation-operator": "^6.8.0", - "babel-runtime": "^6.22.0" + "babel-helper-builder-binary-assignment-operator-visitor": "6.24.1", + "babel-plugin-syntax-exponentiation-operator": "6.13.0", + "babel-runtime": "6.26.0" } }, "babel-plugin-transform-strict-mode": { @@ -846,8 +846,8 @@ "integrity": "sha1-1fr3qleKZbvlkc9e2uBKDGcCB1g=", "dev": true, "requires": { - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" + "babel-runtime": "6.26.0", + "babel-types": "6.26.0" } }, "babel-register": { @@ -856,13 +856,13 @@ "integrity": "sha1-btAhFz4vy0htestFxgCahW9kcHE=", "dev": true, "requires": { - "babel-core": "^6.26.0", - "babel-runtime": "^6.26.0", - "core-js": "^2.5.0", - "home-or-tmp": "^2.0.0", - "lodash": "^4.17.4", - "mkdirp": "^0.5.1", - "source-map-support": "^0.4.15" + "babel-core": "6.26.0", + "babel-runtime": "6.26.0", + "core-js": "2.5.5", + "home-or-tmp": "2.0.0", + "lodash": "4.17.5", + "mkdirp": "0.5.1", + "source-map-support": "0.4.18" }, "dependencies": { "source-map-support": { @@ -871,7 +871,7 @@ "integrity": "sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA==", "dev": true, "requires": { - "source-map": "^0.5.6" + "source-map": "0.5.7" } } } @@ -882,8 +882,8 @@ "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", "dev": true, "requires": { - "core-js": "^2.4.0", - "regenerator-runtime": "^0.11.0" + "core-js": "2.5.5", + "regenerator-runtime": "0.11.1" }, "dependencies": { "regenerator-runtime": { @@ -900,11 +900,11 @@ "integrity": "sha1-3gPi0WOWsGn0bdn/+FIfsaDjXgI=", "dev": true, "requires": { - "babel-runtime": "^6.26.0", - "babel-traverse": "^6.26.0", - "babel-types": "^6.26.0", - "babylon": "^6.18.0", - "lodash": "^4.17.4" + "babel-runtime": "6.26.0", + "babel-traverse": "6.26.0", + "babel-types": "6.26.0", + "babylon": "6.18.0", + "lodash": "4.17.5" } }, "babel-traverse": { @@ -913,15 +913,15 @@ "integrity": "sha1-RqnL1+3MYsjlwGTi0tjQ9ANXZu4=", "dev": true, "requires": { - "babel-code-frame": "^6.26.0", - "babel-messages": "^6.23.0", - "babel-runtime": "^6.26.0", - "babel-types": "^6.26.0", - "babylon": "^6.18.0", - "debug": "^2.6.8", - "globals": "^9.18.0", - "invariant": "^2.2.2", - "lodash": "^4.17.4" + "babel-code-frame": "6.26.0", + "babel-messages": "6.23.0", + "babel-runtime": "6.26.0", + "babel-types": "6.26.0", + "babylon": "6.18.0", + "debug": "2.6.9", + "globals": "9.18.0", + "invariant": "2.2.4", + "lodash": "4.17.5" } }, "babel-types": { @@ -930,10 +930,10 @@ "integrity": "sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=", "dev": true, "requires": { - "babel-runtime": "^6.26.0", - "esutils": "^2.0.2", - "lodash": "^4.17.4", - "to-fast-properties": "^1.0.3" + "babel-runtime": "6.26.0", + "esutils": "2.0.2", + "lodash": "4.17.5", + "to-fast-properties": "1.0.3" } }, "babylon": { @@ -953,7 +953,7 @@ "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", "optional": true, "requires": { - "tweetnacl": "^0.14.3" + "tweetnacl": "0.14.5" } }, "binary-extensions": { @@ -967,7 +967,7 @@ "resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz", "integrity": "sha1-E+v+d4oDIFz+A3UUgeu0szAMEmo=", "requires": { - "inherits": "~2.0.0" + "inherits": "2.0.3" } }, "bluebird": { @@ -980,7 +980,7 @@ "resolved": "https://registry.npmjs.org/boom/-/boom-4.3.1.tgz", "integrity": "sha1-T4owBctKfjiJ90kDD9JbluAdLjE=", "requires": { - "hoek": "4.x.x" + "hoek": "4.2.1" } }, "boxen": { @@ -989,13 +989,13 @@ "integrity": "sha512-TNPjfTr432qx7yOjQyaXm3dSR0MH9vXp7eT1BFSl/C51g+EFnOR9hTg1IreahGBmDNCehscshe45f+C1TBZbLw==", "dev": true, "requires": { - "ansi-align": "^2.0.0", - "camelcase": "^4.0.0", - "chalk": "^2.0.1", - "cli-boxes": "^1.0.0", - "string-width": "^2.0.0", - "term-size": "^1.2.0", - "widest-line": "^2.0.0" + "ansi-align": "2.0.0", + "camelcase": "4.1.0", + "chalk": "2.4.0", + "cli-boxes": "1.0.0", + "string-width": "2.1.1", + "term-size": "1.2.0", + "widest-line": "2.0.0" }, "dependencies": { "ansi-regex": { @@ -1022,8 +1022,8 @@ "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", "dev": true, "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" + "is-fullwidth-code-point": "2.0.0", + "strip-ansi": "4.0.0" } }, "strip-ansi": { @@ -1032,7 +1032,7 @@ "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "dev": true, "requires": { - "ansi-regex": "^3.0.0" + "ansi-regex": "3.0.0" } } } @@ -1042,7 +1042,7 @@ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "requires": { - "balanced-match": "^1.0.0", + "balanced-match": "1.0.0", "concat-map": "0.0.1" } }, @@ -1052,9 +1052,9 @@ "integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=", "dev": true, "requires": { - "expand-range": "^1.8.1", - "preserve": "^0.2.0", - "repeat-element": "^1.1.2" + "expand-range": "1.8.2", + "preserve": "0.2.0", + "repeat-element": "1.1.2" } }, "buf-compare": { @@ -1075,9 +1075,9 @@ "integrity": "sha1-bb2y8g+Nj7znnz6U6dF0Lc31wKE=", "dev": true, "requires": { - "md5-hex": "^1.2.0", - "mkdirp": "^0.5.1", - "write-file-atomic": "^1.1.4" + "md5-hex": "1.3.0", + "mkdirp": "0.5.1", + "write-file-atomic": "1.3.4" }, "dependencies": { "md5-hex": { @@ -1086,7 +1086,7 @@ "integrity": "sha1-0sSv6YPENwZiF5uMrRRSGRNQRsQ=", "dev": true, "requires": { - "md5-o-matic": "^0.1.1" + "md5-o-matic": "0.1.1" } }, "write-file-atomic": { @@ -1095,9 +1095,9 @@ "integrity": "sha1-+Aek8LHZ6ROuekgRLmzDrxmRtF8=", "dev": true, "requires": { - "graceful-fs": "^4.1.11", - "imurmurhash": "^0.1.4", - "slide": "^1.1.5" + "graceful-fs": "4.1.11", + "imurmurhash": "0.1.4", + "slide": "1.1.6" } } } @@ -1108,10 +1108,10 @@ "integrity": "sha1-UTTQd5hPcSpU2tPL9i3ijc5BbKg=", "dev": true, "requires": { - "core-js": "^2.0.0", - "deep-equal": "^1.0.0", - "espurify": "^1.6.0", - "estraverse": "^4.0.0" + "core-js": "2.5.5", + "deep-equal": "1.0.1", + "espurify": "1.7.0", + "estraverse": "4.2.0" } }, "call-signature": { @@ -1132,8 +1132,8 @@ "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=", "dev": true, "requires": { - "camelcase": "^2.0.0", - "map-obj": "^1.0.0" + "camelcase": "2.1.1", + "map-obj": "1.0.1" } }, "capture-stack-trace": { @@ -1153,9 +1153,9 @@ "integrity": "sha512-Wr/w0f4o9LuE7K53cD0qmbAMM+2XNLzR29vFn5hqko4sxGlUsyy363NvmyGIyk5tpe9cjTr9SJYbysEyPkRnFw==", "dev": true, "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" + "ansi-styles": "3.2.1", + "escape-string-regexp": "1.0.5", + "supports-color": "5.4.0" } }, "chokidar": { @@ -1164,15 +1164,15 @@ "integrity": "sha1-eY5ol3gVHIB2tLNg5e3SjNortGg=", "dev": true, "requires": { - "anymatch": "^1.3.0", - "async-each": "^1.0.0", - "fsevents": "^1.0.0", - "glob-parent": "^2.0.0", - "inherits": "^2.0.1", - "is-binary-path": "^1.0.0", - "is-glob": "^2.0.0", - "path-is-absolute": "^1.0.0", - "readdirp": "^2.0.0" + "anymatch": "1.3.2", + "async-each": "1.0.1", + "fsevents": "1.2.0", + "glob-parent": "2.0.0", + "inherits": "2.0.3", + "is-binary-path": "1.0.1", + "is-glob": "2.0.1", + "path-is-absolute": "1.0.1", + "readdirp": "2.1.0" } }, "chownr": { @@ -1192,9 +1192,9 @@ "integrity": "sha512-x90Hac4ERacGDcZSvHKK58Ga0STuMD+Doi5g0iG2zf7wlJef5Huvhs/3BvMRFxwRYyYSdl6mpQNrtfMxE8MQzw==", "dev": true, "requires": { - "async": "^1.5.2", - "glob": "^7.0.0", - "resolve": "^1.1.6" + "async": "1.5.2", + "glob": "7.1.2", + "resolve": "1.1.7" }, "dependencies": { "glob": { @@ -1203,12 +1203,12 @@ "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" } } } @@ -1237,7 +1237,7 @@ "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", "dev": true, "requires": { - "restore-cursor": "^2.0.0" + "restore-cursor": "2.0.0" } }, "cli-spinners": { @@ -1252,8 +1252,8 @@ "integrity": "sha512-bAtZo0u82gCfaAGfSNxUdTI9mNyza7D8w4CVCcaOsy7sgwDzvx6ekr6cuWJqY3UGzgnQ1+4wgENup5eIhgxEYA==", "dev": true, "requires": { - "slice-ansi": "^1.0.0", - "string-width": "^2.0.0" + "slice-ansi": "1.0.0", + "string-width": "2.1.1" }, "dependencies": { "ansi-regex": { @@ -1274,8 +1274,8 @@ "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", "dev": true, "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" + "is-fullwidth-code-point": "2.0.0", + "strip-ansi": "4.0.0" } }, "strip-ansi": { @@ -1284,7 +1284,7 @@ "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "dev": true, "requires": { - "ansi-regex": "^3.0.0" + "ansi-regex": "3.0.0" } } } @@ -1300,7 +1300,7 @@ "integrity": "sha1-QT59tvWJOmC5Qs9JLEvsk9tBWrc=", "dev": true, "requires": { - "pinkie-promise": "^1.0.0" + "pinkie-promise": "1.0.0" }, "dependencies": { "pinkie": { @@ -1315,7 +1315,7 @@ "integrity": "sha1-0dpn9UglY7t89X8oauKCLs+/NnA=", "dev": true, "requires": { - "pinkie": "^1.0.0" + "pinkie": "1.0.0" } } } @@ -1326,7 +1326,7 @@ "integrity": "sha512-tJLhH3EpFm/1x7heIW0hemXJTUU5EWl2V0EIX558jp05Mt1U6DVryCgkp3l37cxqs+DNbNgxG43SkwJXpQ14Jw==", "dev": true, "requires": { - "convert-to-spaces": "^1.0.1" + "convert-to-spaces": "1.0.2" } }, "code-point-at": { @@ -1340,7 +1340,7 @@ "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { - "color-name": "^1.1.1" + "color-name": "1.1.3" } }, "color-name": { @@ -1354,7 +1354,7 @@ "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", "requires": { - "delayed-stream": "~1.0.0" + "delayed-stream": "1.0.0" } }, "commander": { @@ -1362,7 +1362,7 @@ "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz", "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=", "requires": { - "graceful-readlink": ">= 1.0.0" + "graceful-readlink": "1.0.1" } }, "common-path-prefix": { @@ -1388,17 +1388,17 @@ "integrity": "sha512-CZBzJ3/l5QJjlZM20WY7+5GP5pMTw+1UEbThcpMw8/rojsi5sBCiD8ZbBLtD+jYpRGAkwuKuqk108c154V9eyQ==", "dev": true, "requires": { - "date-time": "^2.1.0", - "esutils": "^2.0.2", - "fast-diff": "^1.1.1", - "function-name-support": "^0.2.0", - "js-string-escape": "^1.0.1", - "lodash.clonedeep": "^4.5.0", - "lodash.flattendeep": "^4.4.0", - "lodash.merge": "^4.6.0", - "md5-hex": "^2.0.0", - "semver": "^5.3.0", - "well-known-symbols": "^1.0.0" + "date-time": "2.1.0", + "esutils": "2.0.2", + "fast-diff": "1.1.2", + "function-name-support": "0.2.0", + "js-string-escape": "1.0.1", + "lodash.clonedeep": "4.5.0", + "lodash.flattendeep": "4.4.0", + "lodash.merge": "4.6.1", + "md5-hex": "2.0.0", + "semver": "5.3.0", + "well-known-symbols": "1.0.0" }, "dependencies": { "date-time": { @@ -1407,7 +1407,7 @@ "integrity": "sha512-/9+C44X7lot0IeiyfgJmETtRMhBidBYM2QFFIkGa0U1k+hSyY87Nw7PY3eDqpvCBm7I3WCSfPeZskW/YYq6m4g==", "dev": true, "requires": { - "time-zone": "^1.0.0" + "time-zone": "1.0.0" } } } @@ -1418,12 +1418,12 @@ "integrity": "sha512-vtv5HtGjcYUgFrXc6Kx747B83MRRVS5R1VTEQoXvuP+kMI+if6uywV0nDGoiydJRy4yk7h9od5Og0kxx4zUXmw==", "dev": true, "requires": { - "dot-prop": "^4.1.0", - "graceful-fs": "^4.1.2", - "make-dir": "^1.0.0", - "unique-string": "^1.0.0", - "write-file-atomic": "^2.0.0", - "xdg-basedir": "^3.0.0" + "dot-prop": "4.2.0", + "graceful-fs": "4.1.11", + "make-dir": "1.2.0", + "unique-string": "1.0.0", + "write-file-atomic": "2.3.0", + "xdg-basedir": "3.0.0" } }, "console-control-strings": { @@ -1449,8 +1449,8 @@ "integrity": "sha1-+F4s+b/tKPdzzIs/pcW2m9wC/j8=", "dev": true, "requires": { - "buf-compare": "^1.0.0", - "is-error": "^2.2.0" + "buf-compare": "1.0.1", + "is-error": "2.2.1" } }, "core-js": { @@ -1470,7 +1470,7 @@ "integrity": "sha1-Br56vvlHo/FKMP1hBnHUAbyot7Y=", "dev": true, "requires": { - "capture-stack-trace": "^1.0.0" + "capture-stack-trace": "1.0.0" } }, "cross-spawn": { @@ -1479,9 +1479,9 @@ "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", "dev": true, "requires": { - "lru-cache": "^4.0.1", - "shebang-command": "^1.2.0", - "which": "^1.2.9" + "lru-cache": "4.1.2", + "shebang-command": "1.2.0", + "which": "1.3.0" } }, "cryptiles": { @@ -1489,7 +1489,7 @@ "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.2.tgz", "integrity": "sha1-qJ+7Ig9c4l7FboxKqKT9e1sNKf4=", "requires": { - "boom": "5.x.x" + "boom": "5.2.0" }, "dependencies": { "boom": { @@ -1497,7 +1497,7 @@ "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "requires": { - "hoek": "4.x.x" + "hoek": "4.2.1" } } } @@ -1514,7 +1514,7 @@ "integrity": "sha1-mI3zP+qxke95mmE2nddsF635V+o=", "dev": true, "requires": { - "array-find-index": "^1.0.1" + "array-find-index": "1.0.2" } }, "dashdash": { @@ -1522,7 +1522,7 @@ "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", "requires": { - "assert-plus": "^1.0.0" + "assert-plus": "1.0.0" } }, "date-time": { @@ -1572,7 +1572,7 @@ "integrity": "sha1-920GQ1LN9Docts5hnE7jqUdd4gg=", "dev": true, "requires": { - "repeating": "^2.0.0" + "repeating": "2.0.1" } }, "detect-libc": { @@ -1588,7 +1588,7 @@ "integrity": "sha512-tUMXrxlExSW6U2EXiiKGSBVdYgtV8qlHL+C10TsW4PURY/ic+eaysnSkwB4kA/mBlCyy/IKDJ+Lc3wbWeaXtuQ==", "dev": true, "requires": { - "is-obj": "^1.0.0" + "is-obj": "1.0.1" } }, "duplexer3": { @@ -1603,7 +1603,7 @@ "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", "optional": true, "requires": { - "jsbn": "~0.1.0" + "jsbn": "0.1.1" } }, "empower-core": { @@ -1613,7 +1613,7 @@ "dev": true, "requires": { "call-signature": "0.0.2", - "core-js": "^2.0.0" + "core-js": "2.5.5" } }, "emscripten-library-decorator": { @@ -1633,7 +1633,7 @@ "integrity": "sha1-+FWobOYa3E6GIcPNoh56dhLDqNw=", "dev": true, "requires": { - "is-arrayish": "^0.2.1" + "is-arrayish": "0.2.1" } }, "es6-error": { @@ -1659,10 +1659,10 @@ "integrity": "sha1-oXt+zFnTDheeK+9z+0E3cEyzMbU=", "dev": true, "requires": { - "is-url": "^1.2.1", - "path-is-absolute": "^1.0.0", - "source-map": "^0.5.0", - "xtend": "^4.0.0" + "is-url": "1.2.4", + "path-is-absolute": "1.0.1", + "source-map": "0.5.7", + "xtend": "4.0.1" } }, "esprima": { @@ -1677,7 +1677,7 @@ "integrity": "sha1-HFz2y8zDLm9jk4C9T5kfq5up0iY=", "dev": true, "requires": { - "core-js": "^2.0.0" + "core-js": "2.5.5" } }, "estraverse": { @@ -1698,13 +1698,13 @@ "integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=", "dev": true, "requires": { - "cross-spawn": "^5.0.1", - "get-stream": "^3.0.0", - "is-stream": "^1.1.0", - "npm-run-path": "^2.0.0", - "p-finally": "^1.0.0", - "signal-exit": "^3.0.0", - "strip-eof": "^1.0.0" + "cross-spawn": "5.1.0", + "get-stream": "3.0.0", + "is-stream": "1.1.0", + "npm-run-path": "2.0.2", + "p-finally": "1.0.0", + "signal-exit": "3.0.2", + "strip-eof": "1.0.0" } }, "expand-brackets": { @@ -1713,7 +1713,7 @@ "integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=", "dev": true, "requires": { - "is-posix-bracket": "^0.1.0" + "is-posix-bracket": "0.1.1" } }, "expand-range": { @@ -1722,7 +1722,7 @@ "integrity": "sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc=", "dev": true, "requires": { - "fill-range": "^2.1.0" + "fill-range": "2.2.3" } }, "extend": { @@ -1736,7 +1736,7 @@ "integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=", "dev": true, "requires": { - "is-extglob": "^1.0.0" + "is-extglob": "1.0.0" } }, "extsprintf": { @@ -1766,7 +1766,7 @@ "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", "dev": true, "requires": { - "escape-string-regexp": "^1.0.5" + "escape-string-regexp": "1.0.5" } }, "filename-regex": { @@ -1781,11 +1781,11 @@ "integrity": "sha1-ULd9/X5Gm8dJJHCWNpn+eoSFpyM=", "dev": true, "requires": { - "is-number": "^2.1.0", - "isobject": "^2.0.0", - "randomatic": "^1.1.3", - "repeat-element": "^1.1.2", - "repeat-string": "^1.5.2" + "is-number": "2.1.0", + "isobject": "2.1.0", + "randomatic": "1.1.7", + "repeat-element": "1.1.2", + "repeat-string": "1.6.1" } }, "find-cache-dir": { @@ -1794,9 +1794,9 @@ "integrity": "sha1-kojj6ePMN0hxfTnq3hfPcfww7m8=", "dev": true, "requires": { - "commondir": "^1.0.1", - "make-dir": "^1.0.0", - "pkg-dir": "^2.0.0" + "commondir": "1.0.1", + "make-dir": "1.2.0", + "pkg-dir": "2.0.0" } }, "find-up": { @@ -1805,7 +1805,7 @@ "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", "dev": true, "requires": { - "locate-path": "^2.0.0" + "locate-path": "2.0.0" } }, "fn-name": { @@ -1826,7 +1826,7 @@ "integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=", "dev": true, "requires": { - "for-in": "^1.0.1" + "for-in": "1.0.2" } }, "forever-agent": { @@ -1839,9 +1839,9 @@ "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz", "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=", "requires": { - "asynckit": "^0.4.0", + "asynckit": "0.4.0", "combined-stream": "1.0.6", - "mime-types": "^2.1.12" + "mime-types": "2.1.18" } }, "fs-minipass": { @@ -1849,7 +1849,7 @@ "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.5.tgz", "integrity": "sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ==", "requires": { - "minipass": "^2.2.1" + "minipass": "2.2.4" } }, "fs.realpath": { @@ -1864,8 +1864,8 @@ "dev": true, "optional": true, "requires": { - "nan": "^2.9.2", - "node-pre-gyp": "^0.9.0" + "nan": "2.10.0", + "node-pre-gyp": "0.9.1" }, "dependencies": { "abbrev": { @@ -1876,8 +1876,8 @@ "version": "4.11.8", "bundled": true, "requires": { - "co": "^4.6.0", - "json-stable-stringify": "^1.0.1" + "co": "4.6.0", + "json-stable-stringify": "1.0.1" } }, "ansi-regex": { @@ -1892,8 +1892,8 @@ "version": "1.1.4", "bundled": true, "requires": { - "delegates": "^1.0.0", - "readable-stream": "^2.0.6" + "delegates": "1.0.0", + "readable-stream": "2.2.9" } }, "asn1": { @@ -1925,28 +1925,28 @@ "bundled": true, "optional": true, "requires": { - "tweetnacl": "^0.14.3" + "tweetnacl": "0.14.5" } }, "block-stream": { "version": "0.0.9", "bundled": true, "requires": { - "inherits": "~2.0.0" + "inherits": "2.0.3" } }, "boom": { "version": "2.10.1", "bundled": true, "requires": { - "hoek": "2.x.x" + "hoek": "2.16.3" } }, "brace-expansion": { "version": "1.1.7", "bundled": true, "requires": { - "balanced-match": "^0.4.1", + "balanced-match": "0.4.2", "concat-map": "0.0.1" } }, @@ -1970,7 +1970,7 @@ "version": "1.0.5", "bundled": true, "requires": { - "delayed-stream": "~1.0.0" + "delayed-stream": "1.0.0" } }, "concat-map": { @@ -1989,14 +1989,14 @@ "version": "2.0.5", "bundled": true, "requires": { - "boom": "2.x.x" + "boom": "2.10.1" } }, "dashdash": { "version": "1.14.1", "bundled": true, "requires": { - "assert-plus": "^1.0.0" + "assert-plus": "1.0.0" }, "dependencies": { "assert-plus": { @@ -2033,7 +2033,7 @@ "bundled": true, "optional": true, "requires": { - "jsbn": "~0.1.0" + "jsbn": "0.1.1" } }, "extend": { @@ -2052,9 +2052,9 @@ "version": "2.1.4", "bundled": true, "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.5", - "mime-types": "^2.1.12" + "asynckit": "0.4.0", + "combined-stream": "1.0.5", + "mime-types": "2.1.15" } }, "fs.realpath": { @@ -2065,40 +2065,40 @@ "version": "1.0.11", "bundled": true, "requires": { - "graceful-fs": "^4.1.2", - "inherits": "~2.0.0", - "mkdirp": ">=0.5 0", - "rimraf": "2" + "graceful-fs": "4.1.11", + "inherits": "2.0.3", + "mkdirp": "0.5.1", + "rimraf": "2.6.1" } }, "fstream-ignore": { "version": "1.0.5", "bundled": true, "requires": { - "fstream": "^1.0.0", - "inherits": "2", - "minimatch": "^3.0.0" + "fstream": "1.0.11", + "inherits": "2.0.3", + "minimatch": "3.0.4" } }, "gauge": { "version": "2.7.4", "bundled": true, "requires": { - "aproba": "^1.0.3", - "console-control-strings": "^1.0.0", - "has-unicode": "^2.0.0", - "object-assign": "^4.1.0", - "signal-exit": "^3.0.0", - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", - "wide-align": "^1.1.0" + "aproba": "1.1.1", + "console-control-strings": "1.1.0", + "has-unicode": "2.0.1", + "object-assign": "4.1.1", + "signal-exit": "3.0.2", + "string-width": "1.0.2", + "strip-ansi": "3.0.1", + "wide-align": "1.1.2" } }, "getpass": { "version": "0.1.7", "bundled": true, "requires": { - "assert-plus": "^1.0.0" + "assert-plus": "1.0.0" }, "dependencies": { "assert-plus": { @@ -2111,12 +2111,12 @@ "version": "7.1.2", "bundled": true, "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" } }, "graceful-fs": { @@ -2131,8 +2131,8 @@ "version": "4.2.1", "bundled": true, "requires": { - "ajv": "^4.9.1", - "har-schema": "^1.0.5" + "ajv": "4.11.8", + "har-schema": "1.0.5" } }, "has-unicode": { @@ -2143,10 +2143,10 @@ "version": "3.1.3", "bundled": true, "requires": { - "boom": "2.x.x", - "cryptiles": "2.x.x", - "hoek": "2.x.x", - "sntp": "1.x.x" + "boom": "2.10.1", + "cryptiles": "2.0.5", + "hoek": "2.16.3", + "sntp": "1.0.9" } }, "hoek": { @@ -2157,17 +2157,17 @@ "version": "1.1.1", "bundled": true, "requires": { - "assert-plus": "^0.2.0", - "jsprim": "^1.2.2", - "sshpk": "^1.7.0" + "assert-plus": "0.2.0", + "jsprim": "1.4.0", + "sshpk": "1.13.0" } }, "inflight": { "version": "1.0.6", "bundled": true, "requires": { - "once": "^1.3.0", - "wrappy": "1" + "once": "1.4.0", + "wrappy": "1.0.2" } }, "inherits": { @@ -2182,7 +2182,7 @@ "version": "1.0.0", "bundled": true, "requires": { - "number-is-nan": "^1.0.0" + "number-is-nan": "1.0.1" } }, "is-typedarray": { @@ -2202,7 +2202,7 @@ "bundled": true, "optional": true, "requires": { - "jsbn": "~0.1.0" + "jsbn": "0.1.1" } }, "jsbn": { @@ -2218,7 +2218,7 @@ "version": "1.0.1", "bundled": true, "requires": { - "jsonify": "~0.0.0" + "jsonify": "0.0.0" } }, "json-stringify-safe": { @@ -2253,14 +2253,14 @@ "version": "2.1.15", "bundled": true, "requires": { - "mime-db": "~1.27.0" + "mime-db": "1.27.0" } }, "minimatch": { "version": "3.0.4", "bundled": true, "requires": { - "brace-expansion": "^1.1.7" + "brace-expansion": "1.1.7" } }, "minimist": { @@ -2282,18 +2282,18 @@ "version": "4.0.1", "bundled": true, "requires": { - "abbrev": "1", - "osenv": "^0.1.4" + "abbrev": "1.1.0", + "osenv": "0.1.4" } }, "npmlog": { "version": "4.1.0", "bundled": true, "requires": { - "are-we-there-yet": "~1.1.2", - "console-control-strings": "~1.1.0", - "gauge": "~2.7.3", - "set-blocking": "~2.0.0" + "are-we-there-yet": "1.1.4", + "console-control-strings": "1.1.0", + "gauge": "2.7.4", + "set-blocking": "2.0.0" } }, "number-is-nan": { @@ -2312,7 +2312,7 @@ "version": "1.4.0", "bundled": true, "requires": { - "wrappy": "1" + "wrappy": "1.0.2" } }, "os-homedir": { @@ -2327,8 +2327,8 @@ "version": "0.1.4", "bundled": true, "requires": { - "os-homedir": "^1.0.0", - "os-tmpdir": "^1.0.0" + "os-homedir": "1.0.2", + "os-tmpdir": "1.0.2" } }, "path-is-absolute": { @@ -2355,10 +2355,10 @@ "version": "1.2.1", "bundled": true, "requires": { - "deep-extend": "~0.4.0", - "ini": "~1.3.0", - "minimist": "^1.2.0", - "strip-json-comments": "~2.0.1" + "deep-extend": "0.4.2", + "ini": "1.3.4", + "minimist": "1.2.0", + "strip-json-comments": "2.0.1" }, "dependencies": { "minimist": { @@ -2371,48 +2371,48 @@ "version": "2.2.9", "bundled": true, "requires": { - "buffer-shims": "~1.0.0", - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "~1.0.0", - "process-nextick-args": "~1.0.6", - "string_decoder": "~1.0.0", - "util-deprecate": "~1.0.1" + "buffer-shims": "1.0.0", + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "string_decoder": "1.0.1", + "util-deprecate": "1.0.2" } }, "request": { "version": "2.81.0", "bundled": true, "requires": { - "aws-sign2": "~0.6.0", - "aws4": "^1.2.1", - "caseless": "~0.12.0", - "combined-stream": "~1.0.5", - "extend": "~3.0.0", - "forever-agent": "~0.6.1", - "form-data": "~2.1.1", - "har-validator": "~4.2.1", - "hawk": "~3.1.3", - "http-signature": "~1.1.0", - "is-typedarray": "~1.0.0", - "isstream": "~0.1.2", - "json-stringify-safe": "~5.0.1", - "mime-types": "~2.1.7", - "oauth-sign": "~0.8.1", - "performance-now": "^0.2.0", - "qs": "~6.4.0", - "safe-buffer": "^5.0.1", - "stringstream": "~0.0.4", - "tough-cookie": "~2.3.0", - "tunnel-agent": "^0.6.0", - "uuid": "^3.0.0" + "aws-sign2": "0.6.0", + "aws4": "1.6.0", + "caseless": "0.12.0", + "combined-stream": "1.0.5", + "extend": "3.0.1", + "forever-agent": "0.6.1", + "form-data": "2.1.4", + "har-validator": "4.2.1", + "hawk": "3.1.3", + "http-signature": "1.1.1", + "is-typedarray": "1.0.0", + "isstream": "0.1.2", + "json-stringify-safe": "5.0.1", + "mime-types": "2.1.15", + "oauth-sign": "0.8.2", + "performance-now": "0.2.0", + "qs": "6.4.0", + "safe-buffer": "5.0.1", + "stringstream": "0.0.5", + "tough-cookie": "2.3.2", + "tunnel-agent": "0.6.0", + "uuid": "3.0.1" } }, "rimraf": { "version": "2.6.1", "bundled": true, "requires": { - "glob": "^7.0.5" + "glob": "7.1.2" } }, "safe-buffer": { @@ -2435,22 +2435,22 @@ "version": "1.0.9", "bundled": true, "requires": { - "hoek": "2.x.x" + "hoek": "2.16.3" } }, "sshpk": { "version": "1.13.0", "bundled": true, "requires": { - "asn1": "~0.2.3", - "assert-plus": "^1.0.0", - "bcrypt-pbkdf": "^1.0.0", - "dashdash": "^1.12.0", - "ecc-jsbn": "~0.1.1", - "getpass": "^0.1.1", - "jodid25519": "^1.0.0", - "jsbn": "~0.1.0", - "tweetnacl": "~0.14.0" + "asn1": "0.2.3", + "assert-plus": "1.0.0", + "bcrypt-pbkdf": "1.0.1", + "dashdash": "1.14.1", + "ecc-jsbn": "0.1.1", + "getpass": "0.1.7", + "jodid25519": "1.0.2", + "jsbn": "0.1.1", + "tweetnacl": "0.14.5" }, "dependencies": { "assert-plus": { @@ -2463,16 +2463,16 @@ "version": "1.0.2", "bundled": true, "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" } }, "string_decoder": { "version": "1.0.1", "bundled": true, "requires": { - "safe-buffer": "^5.0.1" + "safe-buffer": "5.0.1" } }, "stringstream": { @@ -2483,7 +2483,7 @@ "version": "3.0.1", "bundled": true, "requires": { - "ansi-regex": "^2.0.0" + "ansi-regex": "2.1.1" } }, "strip-json-comments": { @@ -2494,37 +2494,37 @@ "version": "2.2.1", "bundled": true, "requires": { - "block-stream": "*", - "fstream": "^1.0.2", - "inherits": "2" + "block-stream": "0.0.9", + "fstream": "1.0.11", + "inherits": "2.0.3" } }, "tar-pack": { "version": "3.4.0", "bundled": true, "requires": { - "debug": "^2.2.0", - "fstream": "^1.0.10", - "fstream-ignore": "^1.0.5", - "once": "^1.3.3", - "readable-stream": "^2.1.4", - "rimraf": "^2.5.1", - "tar": "^2.2.1", - "uid-number": "^0.0.6" + "debug": "2.6.8", + "fstream": "1.0.11", + "fstream-ignore": "1.0.5", + "once": "1.4.0", + "readable-stream": "2.2.9", + "rimraf": "2.6.1", + "tar": "2.2.1", + "uid-number": "0.0.6" } }, "tough-cookie": { "version": "2.3.2", "bundled": true, "requires": { - "punycode": "^1.4.1" + "punycode": "1.4.1" } }, "tunnel-agent": { "version": "0.6.0", "bundled": true, "requires": { - "safe-buffer": "^5.0.1" + "safe-buffer": "5.0.1" } }, "tweetnacl": { @@ -2555,7 +2555,7 @@ "version": "1.1.2", "bundled": true, "requires": { - "string-width": "^1.0.2" + "string-width": "1.0.2" } }, "wrappy": { @@ -2569,10 +2569,10 @@ "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz", "integrity": "sha1-XB+x8RdHcRTwYyoOtLcbPLD9MXE=", "requires": { - "graceful-fs": "^4.1.2", - "inherits": "~2.0.0", - "mkdirp": ">=0.5 0", - "rimraf": "2" + "graceful-fs": "4.1.11", + "inherits": "2.0.3", + "mkdirp": "0.5.1", + "rimraf": "2.4.5" } }, "function-name-support": { @@ -2586,14 +2586,14 @@ "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", "requires": { - "aproba": "^1.0.3", - "console-control-strings": "^1.0.0", - "has-unicode": "^2.0.0", - "object-assign": "^4.1.0", - "signal-exit": "^3.0.0", - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", - "wide-align": "^1.1.0" + "aproba": "1.2.0", + "console-control-strings": "1.1.0", + "has-unicode": "2.0.1", + "object-assign": "4.1.1", + "signal-exit": "3.0.2", + "string-width": "1.0.2", + "strip-ansi": "3.0.1", + "wide-align": "1.1.2" } }, "get-port": { @@ -2619,7 +2619,7 @@ "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", "requires": { - "assert-plus": "^1.0.0" + "assert-plus": "1.0.0" } }, "glob": { @@ -2627,11 +2627,11 @@ "resolved": "https://registry.npmjs.org/glob/-/glob-6.0.4.tgz", "integrity": "sha1-DwiGD2oVUSey+t1PnOJLGqtuTSI=", "requires": { - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "2 || 3", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" } }, "glob-base": { @@ -2640,8 +2640,8 @@ "integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=", "dev": true, "requires": { - "glob-parent": "^2.0.0", - "is-glob": "^2.0.0" + "glob-parent": "2.0.0", + "is-glob": "2.0.1" } }, "glob-parent": { @@ -2650,7 +2650,7 @@ "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=", "dev": true, "requires": { - "is-glob": "^2.0.0" + "is-glob": "2.0.1" } }, "global-dirs": { @@ -2659,7 +2659,7 @@ "integrity": "sha1-sxnA3UYH81PzvpzKTHL8FIxJ9EU=", "dev": true, "requires": { - "ini": "^1.3.4" + "ini": "1.3.5" } }, "globals": { @@ -2674,11 +2674,11 @@ "integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=", "dev": true, "requires": { - "array-union": "^1.0.1", - "glob": "^7.0.3", - "object-assign": "^4.0.1", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0" + "array-union": "1.0.2", + "glob": "7.1.2", + "object-assign": "4.1.1", + "pify": "2.3.0", + "pinkie-promise": "2.0.1" }, "dependencies": { "glob": { @@ -2687,12 +2687,12 @@ "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" } } } @@ -2703,17 +2703,17 @@ "integrity": "sha1-JAzQV4WpoY5WHcG0S0HHY+8ejbA=", "dev": true, "requires": { - "create-error-class": "^3.0.0", - "duplexer3": "^0.1.4", - "get-stream": "^3.0.0", - "is-redirect": "^1.0.0", - "is-retry-allowed": "^1.0.0", - "is-stream": "^1.0.0", - "lowercase-keys": "^1.0.0", - "safe-buffer": "^5.0.1", - "timed-out": "^4.0.0", - "unzip-response": "^2.0.1", - "url-parse-lax": "^1.0.0" + "create-error-class": "3.0.2", + "duplexer3": "0.1.4", + "get-stream": "3.0.0", + "is-redirect": "1.0.0", + "is-retry-allowed": "1.1.0", + "is-stream": "1.1.0", + "lowercase-keys": "1.0.1", + "safe-buffer": "5.1.1", + "timed-out": "4.0.1", + "unzip-response": "2.0.1", + "url-parse-lax": "1.0.0" } }, "graceful-fs": { @@ -2736,8 +2736,8 @@ "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz", "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=", "requires": { - "ajv": "^5.1.0", - "har-schema": "^2.0.0" + "ajv": "5.5.2", + "har-schema": "2.0.0" } }, "has-ansi": { @@ -2746,7 +2746,7 @@ "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", "dev": true, "requires": { - "ansi-regex": "^2.0.0" + "ansi-regex": "2.1.1" } }, "has-color": { @@ -2777,10 +2777,10 @@ "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "requires": { - "boom": "4.x.x", - "cryptiles": "3.x.x", - "hoek": "4.x.x", - "sntp": "2.x.x" + "boom": "4.3.1", + "cryptiles": "3.1.2", + "hoek": "4.2.1", + "sntp": "2.1.0" } }, "hoek": { @@ -2794,8 +2794,8 @@ "integrity": "sha1-42w/LSyufXRqhX440Y1fMqeILbg=", "dev": true, "requires": { - "os-homedir": "^1.0.0", - "os-tmpdir": "^1.0.1" + "os-homedir": "1.0.2", + "os-tmpdir": "1.0.2" } }, "home-path": { @@ -2814,9 +2814,9 @@ "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", "requires": { - "assert-plus": "^1.0.0", - "jsprim": "^1.2.2", - "sshpk": "^1.7.0" + "assert-plus": "1.0.0", + "jsprim": "1.4.1", + "sshpk": "1.14.1" } }, "hullabaloo-config-manager": { @@ -2825,20 +2825,20 @@ "integrity": "sha512-ztKnkZV0TmxnumCDHHgLGNiDnotu4EHCp9YMkznWuo4uTtCyJ+cu+RNcxUeXYKTllpvLFWnbfWry09yzszgg+A==", "dev": true, "requires": { - "dot-prop": "^4.1.0", - "es6-error": "^4.0.2", - "graceful-fs": "^4.1.11", - "indent-string": "^3.1.0", - "json5": "^0.5.1", - "lodash.clonedeep": "^4.5.0", - "lodash.clonedeepwith": "^4.5.0", - "lodash.isequal": "^4.5.0", - "lodash.merge": "^4.6.0", - "md5-hex": "^2.0.0", - "package-hash": "^2.0.0", - "pkg-dir": "^2.0.0", - "resolve-from": "^3.0.0", - "safe-buffer": "^5.0.1" + "dot-prop": "4.2.0", + "es6-error": "4.1.1", + "graceful-fs": "4.1.11", + "indent-string": "3.2.0", + "json5": "0.5.1", + "lodash.clonedeep": "4.5.0", + "lodash.clonedeepwith": "4.5.0", + "lodash.isequal": "4.5.0", + "lodash.merge": "4.6.1", + "md5-hex": "2.0.0", + "package-hash": "2.0.0", + "pkg-dir": "2.0.0", + "resolve-from": "3.0.0", + "safe-buffer": "5.1.1" } }, "humanize": { @@ -2853,9 +2853,9 @@ "integrity": "sha512-e21wivqHpstpoiWA/Yi8eFti8E+sQDSS53cpJsPptPs295QTOQR0ZwnHo2TXy1XOpZFD9rPOd3NpmqTK6uMLJA==", "dev": true, "requires": { - "is-ci": "^1.0.10", - "normalize-path": "^1.0.0", - "strip-indent": "^2.0.0" + "is-ci": "1.1.0", + "normalize-path": "1.0.0", + "strip-indent": "2.0.0" }, "dependencies": { "normalize-path": { @@ -2879,7 +2879,7 @@ "dev": true, "optional": true, "requires": { - "safer-buffer": "^2.1.0" + "safer-buffer": "2.1.2" } }, "ignore-by-default": { @@ -2895,7 +2895,7 @@ "dev": true, "optional": true, "requires": { - "minimatch": "^3.0.4" + "minimatch": "3.0.4" } }, "import-lazy": { @@ -2910,8 +2910,8 @@ "integrity": "sha1-sReVcqrNwRxqkQCftDDbyrX2aKg=", "dev": true, "requires": { - "pkg-dir": "^2.0.0", - "resolve-cwd": "^2.0.0" + "pkg-dir": "2.0.0", + "resolve-cwd": "2.0.0" } }, "imurmurhash": { @@ -2931,8 +2931,8 @@ "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "requires": { - "once": "^1.3.0", - "wrappy": "1" + "once": "1.4.0", + "wrappy": "1.0.2" } }, "inherits": { @@ -2951,7 +2951,7 @@ "integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==", "dev": true, "requires": { - "loose-envify": "^1.0.0" + "loose-envify": "1.3.1" } }, "irregular-plurals": { @@ -2972,7 +2972,7 @@ "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", "dev": true, "requires": { - "binary-extensions": "^1.0.0" + "binary-extensions": "1.11.0" } }, "is-buffer": { @@ -2987,7 +2987,7 @@ "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", "dev": true, "requires": { - "builtin-modules": "^1.0.0" + "builtin-modules": "1.1.1" } }, "is-ci": { @@ -2996,7 +2996,7 @@ "integrity": "sha512-c7TnwxLePuqIlxHgr7xtxzycJPegNHFuIrBkwbf8hc58//+Op1CqFkyS+xnIMkwn9UsJIwc174BIjkyBmSpjKg==", "dev": true, "requires": { - "ci-info": "^1.0.0" + "ci-info": "1.1.3" } }, "is-dotfile": { @@ -3011,7 +3011,7 @@ "integrity": "sha1-IjgJj8Ih3gvPpdnqxMRdY4qhxTQ=", "dev": true, "requires": { - "is-primitive": "^2.0.0" + "is-primitive": "2.0.0" } }, "is-error": { @@ -3038,7 +3038,7 @@ "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", "dev": true, "requires": { - "number-is-nan": "^1.0.0" + "number-is-nan": "1.0.1" } }, "is-fullwidth-code-point": { @@ -3046,7 +3046,7 @@ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "requires": { - "number-is-nan": "^1.0.0" + "number-is-nan": "1.0.1" } }, "is-generator-fn": { @@ -3061,7 +3061,7 @@ "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", "dev": true, "requires": { - "is-extglob": "^1.0.0" + "is-extglob": "1.0.0" } }, "is-installed-globally": { @@ -3070,8 +3070,8 @@ "integrity": "sha1-Df2Y9akRFxbdU13aZJL2e/PSWoA=", "dev": true, "requires": { - "global-dirs": "^0.1.0", - "is-path-inside": "^1.0.0" + "global-dirs": "0.1.1", + "is-path-inside": "1.0.1" } }, "is-npm": { @@ -3086,7 +3086,7 @@ "integrity": "sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=", "dev": true, "requires": { - "kind-of": "^3.0.2" + "kind-of": "3.2.2" } }, "is-obj": { @@ -3101,7 +3101,7 @@ "integrity": "sha512-NqCa4Sa2d+u7BWc6CukaObG3Fh+CU9bvixbpcXYhy2VvYS7vVGIdAgnIS5Ks3A/cqk4rebLJ9s8zBstT2aKnIA==", "dev": true, "requires": { - "symbol-observable": "^1.1.0" + "symbol-observable": "1.2.0" } }, "is-path-inside": { @@ -3110,7 +3110,7 @@ "integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=", "dev": true, "requires": { - "path-is-inside": "^1.0.1" + "path-is-inside": "1.0.2" } }, "is-plain-obj": { @@ -3214,8 +3214,8 @@ "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" + "argparse": "1.0.10", + "esprima": "4.0.0" } }, "jsbn": { @@ -3274,7 +3274,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "^1.1.5" + "is-buffer": "1.1.6" } }, "last-line-stream": { @@ -3283,7 +3283,7 @@ "integrity": "sha1-0bZNafhv8kry0EiDos7uFFIKVgA=", "dev": true, "requires": { - "through2": "^2.0.0" + "through2": "2.0.3" } }, "latest-version": { @@ -3292,7 +3292,7 @@ "integrity": "sha1-ogU4P+oyKzO1rjsYq+4NwvNW7hU=", "dev": true, "requires": { - "package-json": "^4.0.0" + "package-json": "4.0.1" } }, "libui-download": { @@ -3300,16 +3300,16 @@ "resolved": "https://registry.npmjs.org/libui-download/-/libui-download-1.1.0.tgz", "integrity": "sha512-kn/VrmvI4zUNjH+GsUelLMKNiuNG/T9q7eEWXSLXQwcpQvhsvUZQO8VxeiNfYw4wMqnYUOyPynbx8qfXJt3ZaQ==", "requires": { - "debug": "^2.2.0", - "home-path": "^1.0.1", - "mkdirp": "^0.5.0", - "mv": "^2.0.3", - "pify": "^2.3.0", - "pinkie-promise": "^2.0.1", - "rc": "^1.1.2", - "regenerator-runtime": "^0.9.5", - "request": "^2.85.0", - "tar": "^4.4.0" + "debug": "2.6.9", + "home-path": "1.0.5", + "mkdirp": "0.5.1", + "mv": "2.1.1", + "pify": "2.3.0", + "pinkie-promise": "2.0.1", + "rc": "1.2.6", + "regenerator-runtime": "0.9.6", + "request": "2.85.0", + "tar": "4.4.1" } }, "load-json-file": { @@ -3318,10 +3318,10 @@ "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", "dev": true, "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^2.2.0", - "pify": "^2.0.0", - "strip-bom": "^3.0.0" + "graceful-fs": "4.1.11", + "parse-json": "2.2.0", + "pify": "2.3.0", + "strip-bom": "3.0.0" } }, "locate-path": { @@ -3330,8 +3330,8 @@ "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", "dev": true, "requires": { - "p-locate": "^2.0.0", - "path-exists": "^3.0.0" + "p-locate": "2.0.0", + "path-exists": "3.0.0" } }, "lodash": { @@ -3394,7 +3394,7 @@ "integrity": "sha1-0aitM/qc4OcT1l/dCsi3SNR4yEg=", "dev": true, "requires": { - "js-tokens": "^3.0.0" + "js-tokens": "3.0.2" } }, "loud-rejection": { @@ -3403,8 +3403,8 @@ "integrity": "sha1-W0b4AUft7leIcPCG0Eghz5mOVR8=", "dev": true, "requires": { - "currently-unhandled": "^0.4.1", - "signal-exit": "^3.0.0" + "currently-unhandled": "0.4.1", + "signal-exit": "3.0.2" } }, "lowercase-keys": { @@ -3419,8 +3419,8 @@ "integrity": "sha512-wgeVXhrDwAWnIF/yZARsFnMBtdFXOg1b8RIrhilp+0iDYN4mdQcNZElDZ0e4B64BhaxeQ5zN7PMyvu7we1kPeQ==", "dev": true, "requires": { - "pseudomap": "^1.0.2", - "yallist": "^2.1.2" + "pseudomap": "1.0.2", + "yallist": "2.1.2" }, "dependencies": { "yallist": { @@ -3437,7 +3437,7 @@ "integrity": "sha512-aNUAa4UMg/UougV25bbrU4ZaaKNjJ/3/xnvg/twpmKROPdKZPZ9wGgI0opdZzO8q/zUFawoUuixuOv33eZ61Iw==", "dev": true, "requires": { - "pify": "^3.0.0" + "pify": "3.0.0" }, "dependencies": { "pify": { @@ -3460,7 +3460,7 @@ "integrity": "sha512-aZGv6JBTHqfqAd09jmAlbKnAICTfIvb5Z8gXVxPB5WZtFfHMaAMdACL7tQflD2V+6/8KNcY8s6DYtWLgpJP5lA==", "dev": true, "requires": { - "escape-string-regexp": "^1.0.4" + "escape-string-regexp": "1.0.5" } }, "md5-hex": { @@ -3469,7 +3469,7 @@ "integrity": "sha1-0FiOnxx0lUSS7NJKwKxs6ZfZLjM=", "dev": true, "requires": { - "md5-o-matic": "^0.1.1" + "md5-o-matic": "0.1.1" } }, "md5-o-matic": { @@ -3484,16 +3484,16 @@ "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=", "dev": true, "requires": { - "camelcase-keys": "^2.0.0", - "decamelize": "^1.1.2", - "loud-rejection": "^1.0.0", - "map-obj": "^1.0.1", - "minimist": "^1.1.3", - "normalize-package-data": "^2.3.4", - "object-assign": "^4.0.1", - "read-pkg-up": "^1.0.1", - "redent": "^1.0.0", - "trim-newlines": "^1.0.0" + "camelcase-keys": "2.1.0", + "decamelize": "1.2.0", + "loud-rejection": "1.6.0", + "map-obj": "1.0.1", + "minimist": "1.2.0", + "normalize-package-data": "2.4.0", + "object-assign": "4.1.1", + "read-pkg-up": "1.0.1", + "redent": "1.0.0", + "trim-newlines": "1.0.0" }, "dependencies": { "find-up": { @@ -3502,8 +3502,8 @@ "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", "dev": true, "requires": { - "path-exists": "^2.0.0", - "pinkie-promise": "^2.0.0" + "path-exists": "2.1.0", + "pinkie-promise": "2.0.1" } }, "load-json-file": { @@ -3512,11 +3512,11 @@ "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", "dev": true, "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^2.2.0", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0", - "strip-bom": "^2.0.0" + "graceful-fs": "4.1.11", + "parse-json": "2.2.0", + "pify": "2.3.0", + "pinkie-promise": "2.0.1", + "strip-bom": "2.0.0" } }, "minimist": { @@ -3531,7 +3531,7 @@ "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", "dev": true, "requires": { - "pinkie-promise": "^2.0.0" + "pinkie-promise": "2.0.1" } }, "path-type": { @@ -3540,9 +3540,9 @@ "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", "dev": true, "requires": { - "graceful-fs": "^4.1.2", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0" + "graceful-fs": "4.1.11", + "pify": "2.3.0", + "pinkie-promise": "2.0.1" } }, "read-pkg": { @@ -3551,9 +3551,9 @@ "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", "dev": true, "requires": { - "load-json-file": "^1.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^1.0.0" + "load-json-file": "1.1.0", + "normalize-package-data": "2.4.0", + "path-type": "1.1.0" } }, "read-pkg-up": { @@ -3562,8 +3562,8 @@ "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", "dev": true, "requires": { - "find-up": "^1.0.0", - "read-pkg": "^1.0.0" + "find-up": "1.1.2", + "read-pkg": "1.1.0" } }, "strip-bom": { @@ -3572,7 +3572,7 @@ "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", "dev": true, "requires": { - "is-utf8": "^0.2.0" + "is-utf8": "0.2.1" } } } @@ -3583,19 +3583,19 @@ "integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=", "dev": true, "requires": { - "arr-diff": "^2.0.0", - "array-unique": "^0.2.1", - "braces": "^1.8.2", - "expand-brackets": "^0.1.4", - "extglob": "^0.3.1", - "filename-regex": "^2.0.0", - "is-extglob": "^1.0.0", - "is-glob": "^2.0.1", - "kind-of": "^3.0.2", - "normalize-path": "^2.0.1", - "object.omit": "^2.0.0", - "parse-glob": "^3.0.4", - "regex-cache": "^0.4.2" + "arr-diff": "2.0.0", + "array-unique": "0.2.1", + "braces": "1.8.5", + "expand-brackets": "0.1.5", + "extglob": "0.3.2", + "filename-regex": "2.0.1", + "is-extglob": "1.0.0", + "is-glob": "2.0.1", + "kind-of": "3.2.2", + "normalize-path": "2.1.1", + "object.omit": "2.0.1", + "parse-glob": "3.0.4", + "regex-cache": "0.4.4" } }, "mime-db": { @@ -3608,7 +3608,7 @@ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "requires": { - "mime-db": "~1.33.0" + "mime-db": "1.33.0" } }, "mimic-fn": { @@ -3622,7 +3622,7 @@ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "requires": { - "brace-expansion": "^1.1.7" + "brace-expansion": "1.1.11" } }, "minimist": { @@ -3635,8 +3635,8 @@ "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.2.4.tgz", "integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==", "requires": { - "safe-buffer": "^5.1.1", - "yallist": "^3.0.0" + "safe-buffer": "5.1.1", + "yallist": "3.0.2" } }, "minizlib": { @@ -3644,7 +3644,7 @@ "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.1.0.tgz", "integrity": "sha512-4T6Ur/GctZ27nHfpt9THOdRZNgyJ9FZchYO1ceg5S8Q3DNLCKYy44nCZzgCJgcvx2UM8czmqak5BCxJMrq37lA==", "requires": { - "minipass": "^2.2.1" + "minipass": "2.2.4" } }, "mkdirp": { @@ -3666,10 +3666,10 @@ "integrity": "sha1-nHkGoi+0wCkZ4vX3UWG0zb1LKis=", "dev": true, "requires": { - "array-differ": "^1.0.0", - "array-union": "^1.0.1", - "arrify": "^1.0.0", - "minimatch": "^3.0.0" + "array-differ": "1.0.0", + "array-union": "1.0.2", + "arrify": "1.0.1", + "minimatch": "3.0.4" } }, "mv": { @@ -3677,9 +3677,9 @@ "resolved": "https://registry.npmjs.org/mv/-/mv-2.1.1.tgz", "integrity": "sha1-rmzg1vbV4KT32JN5jQPB6pVZtqI=", "requires": { - "mkdirp": "~0.5.1", - "ncp": "~2.0.0", - "rimraf": "~2.4.0" + "mkdirp": "0.5.1", + "ncp": "2.0.0", + "rimraf": "2.4.5" } }, "nan": { @@ -3692,9 +3692,9 @@ "resolved": "https://registry.npmjs.org/nbind/-/nbind-0.3.15.tgz", "integrity": "sha512-TrKLNRj5D8wZRJb7XmUNbA1W3iTigAEpm3qaGig5bEWY/iCT2IQBgBc2EUGO59FbRIGhx5hB/McVwqxlSGScVw==", "requires": { - "emscripten-library-decorator": "~0.2.2", - "mkdirp": "~0.5.1", - "nan": "^2.9.2" + "emscripten-library-decorator": "0.2.2", + "mkdirp": "0.5.1", + "nan": "2.10.0" } }, "ncp": { @@ -3709,9 +3709,9 @@ "dev": true, "optional": true, "requires": { - "debug": "^2.1.2", - "iconv-lite": "^0.4.4", - "sax": "^1.2.4" + "debug": "2.6.9", + "iconv-lite": "0.4.21", + "sax": "1.2.4" } }, "node-gyp": { @@ -3719,19 +3719,19 @@ "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-3.6.2.tgz", "integrity": "sha1-m/vlRWIoYoSDjnUOrAUpWFP6HGA=", "requires": { - "fstream": "^1.0.0", - "glob": "^7.0.3", - "graceful-fs": "^4.1.2", - "minimatch": "^3.0.2", - "mkdirp": "^0.5.0", - "nopt": "2 || 3", - "npmlog": "0 || 1 || 2 || 3 || 4", - "osenv": "0", - "request": "2", - "rimraf": "2", - "semver": "~5.3.0", - "tar": "^2.0.0", - "which": "1" + "fstream": "1.0.11", + "glob": "7.1.2", + "graceful-fs": "4.1.11", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "nopt": "3.0.6", + "npmlog": "4.1.2", + "osenv": "0.1.5", + "request": "2.85.0", + "rimraf": "2.4.5", + "semver": "5.3.0", + "tar": "2.2.1", + "which": "1.3.0" }, "dependencies": { "glob": { @@ -3739,12 +3739,12 @@ "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" } }, "tar": { @@ -3752,9 +3752,9 @@ "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz", "integrity": "sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=", "requires": { - "block-stream": "*", - "fstream": "^1.0.2", - "inherits": "2" + "block-stream": "0.0.9", + "fstream": "1.0.11", + "inherits": "2.0.3" } } } @@ -3766,16 +3766,16 @@ "dev": true, "optional": true, "requires": { - "detect-libc": "^1.0.2", - "mkdirp": "^0.5.1", - "needle": "^2.2.0", - "nopt": "^4.0.1", - "npm-packlist": "^1.1.6", - "npmlog": "^4.0.2", - "rc": "^1.1.7", - "rimraf": "^2.6.1", - "semver": "^5.3.0", - "tar": "^4" + "detect-libc": "1.0.3", + "mkdirp": "0.5.1", + "needle": "2.2.0", + "nopt": "4.0.1", + "npm-packlist": "1.1.10", + "npmlog": "4.1.2", + "rc": "1.2.6", + "rimraf": "2.6.2", + "semver": "5.3.0", + "tar": "4.4.1" }, "dependencies": { "glob": { @@ -3785,12 +3785,12 @@ "dev": true, "optional": true, "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" } }, "nopt": { @@ -3800,8 +3800,8 @@ "dev": true, "optional": true, "requires": { - "abbrev": "1", - "osenv": "^0.1.4" + "abbrev": "1.1.1", + "osenv": "0.1.5" } }, "rimraf": { @@ -3811,7 +3811,7 @@ "dev": true, "optional": true, "requires": { - "glob": "^7.0.5" + "glob": "7.1.2" } } } @@ -3821,7 +3821,7 @@ "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", "requires": { - "abbrev": "1" + "abbrev": "1.1.1" } }, "normalize-package-data": { @@ -3830,10 +3830,10 @@ "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { - "hosted-git-info": "^2.1.4", - "is-builtin-module": "^1.0.0", - "semver": "2 || 3 || 4 || 5", - "validate-npm-package-license": "^3.0.1" + "hosted-git-info": "2.6.0", + "is-builtin-module": "1.0.0", + "semver": "5.3.0", + "validate-npm-package-license": "3.0.3" } }, "normalize-path": { @@ -3842,7 +3842,7 @@ "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", "dev": true, "requires": { - "remove-trailing-separator": "^1.0.1" + "remove-trailing-separator": "1.1.0" } }, "npm-bundled": { @@ -3859,8 +3859,8 @@ "dev": true, "optional": true, "requires": { - "ignore-walk": "^3.0.1", - "npm-bundled": "^1.0.1" + "ignore-walk": "3.0.1", + "npm-bundled": "1.0.3" } }, "npm-run-path": { @@ -3869,7 +3869,7 @@ "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", "dev": true, "requires": { - "path-key": "^2.0.0" + "path-key": "2.0.1" } }, "npmlog": { @@ -3877,10 +3877,10 @@ "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", "requires": { - "are-we-there-yet": "~1.1.2", - "console-control-strings": "~1.1.0", - "gauge": "~2.7.3", - "set-blocking": "~2.0.0" + "are-we-there-yet": "1.1.4", + "console-control-strings": "1.1.0", + "gauge": "2.7.4", + "set-blocking": "2.0.0" } }, "number-is-nan": { @@ -3904,8 +3904,8 @@ "integrity": "sha1-Gpx0SCnznbuFjHbKNXmuKlTr0fo=", "dev": true, "requires": { - "for-own": "^0.1.4", - "is-extendable": "^0.1.1" + "for-own": "0.1.5", + "is-extendable": "0.1.1" } }, "observable-to-promise": { @@ -3914,8 +3914,8 @@ "integrity": "sha1-yCjw8NxH6fhq+KSXfF1VB2znqR8=", "dev": true, "requires": { - "is-observable": "^0.2.0", - "symbol-observable": "^1.0.4" + "is-observable": "0.2.0", + "symbol-observable": "1.2.0" }, "dependencies": { "is-observable": { @@ -3924,7 +3924,7 @@ "integrity": "sha1-s2ExHYPG5dcmyr9eJQsCNxBvWuI=", "dev": true, "requires": { - "symbol-observable": "^0.2.2" + "symbol-observable": "0.2.4" }, "dependencies": { "symbol-observable": { @@ -3942,7 +3942,7 @@ "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "requires": { - "wrappy": "1" + "wrappy": "1.0.2" } }, "onetime": { @@ -3951,7 +3951,7 @@ "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", "dev": true, "requires": { - "mimic-fn": "^1.0.0" + "mimic-fn": "1.2.0" } }, "option-chain": { @@ -3975,8 +3975,8 @@ "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz", "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", "requires": { - "os-homedir": "^1.0.0", - "os-tmpdir": "^1.0.0" + "os-homedir": "1.0.2", + "os-tmpdir": "1.0.2" } }, "p-finally": { @@ -3991,7 +3991,7 @@ "integrity": "sha512-Y/OtIaXtUPr4/YpMv1pCL5L5ed0rumAaAeBSj12F+bSlMdys7i8oQF/GUJmfpTS/QoaRrS/k6pma29haJpsMng==", "dev": true, "requires": { - "p-try": "^1.0.0" + "p-try": "1.0.0" } }, "p-locate": { @@ -4000,7 +4000,7 @@ "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", "dev": true, "requires": { - "p-limit": "^1.1.0" + "p-limit": "1.2.0" } }, "p-try": { @@ -4015,10 +4015,10 @@ "integrity": "sha1-eK4ybIngWk2BO2hgGXevBcANKg0=", "dev": true, "requires": { - "graceful-fs": "^4.1.11", - "lodash.flattendeep": "^4.4.0", - "md5-hex": "^2.0.0", - "release-zalgo": "^1.0.0" + "graceful-fs": "4.1.11", + "lodash.flattendeep": "4.4.0", + "md5-hex": "2.0.0", + "release-zalgo": "1.0.0" } }, "package-json": { @@ -4027,10 +4027,10 @@ "integrity": "sha1-iGmgQBJTZhxMTKPabCEh7VVfXu0=", "dev": true, "requires": { - "got": "^6.7.1", - "registry-auth-token": "^3.0.1", - "registry-url": "^3.0.3", - "semver": "^5.1.0" + "got": "6.7.1", + "registry-auth-token": "3.3.2", + "registry-url": "3.1.0", + "semver": "5.3.0" } }, "parse-glob": { @@ -4039,10 +4039,10 @@ "integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=", "dev": true, "requires": { - "glob-base": "^0.3.0", - "is-dotfile": "^1.0.0", - "is-extglob": "^1.0.0", - "is-glob": "^2.0.0" + "glob-base": "0.3.0", + "is-dotfile": "1.0.3", + "is-extglob": "1.0.0", + "is-glob": "2.0.1" } }, "parse-json": { @@ -4051,7 +4051,7 @@ "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", "dev": true, "requires": { - "error-ex": "^1.2.0" + "error-ex": "1.3.1" } }, "parse-ms": { @@ -4089,7 +4089,7 @@ "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=", "dev": true, "requires": { - "pify": "^2.0.0" + "pify": "2.3.0" } }, "performance-now": { @@ -4112,7 +4112,7 @@ "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", "requires": { - "pinkie": "^2.0.0" + "pinkie": "2.0.4" } }, "pkg-conf": { @@ -4121,8 +4121,8 @@ "integrity": "sha1-ISZRTKbyq/69FoWW3xi6V4Z/AFg=", "dev": true, "requires": { - "find-up": "^2.0.0", - "load-json-file": "^4.0.0" + "find-up": "2.1.0", + "load-json-file": "4.0.0" }, "dependencies": { "load-json-file": { @@ -4131,10 +4131,10 @@ "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", "dev": true, "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^4.0.0", - "pify": "^3.0.0", - "strip-bom": "^3.0.0" + "graceful-fs": "4.1.11", + "parse-json": "4.0.0", + "pify": "3.0.0", + "strip-bom": "3.0.0" } }, "parse-json": { @@ -4143,8 +4143,8 @@ "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", "dev": true, "requires": { - "error-ex": "^1.3.1", - "json-parse-better-errors": "^1.0.1" + "error-ex": "1.3.1", + "json-parse-better-errors": "1.0.2" } }, "pify": { @@ -4161,7 +4161,7 @@ "integrity": "sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s=", "dev": true, "requires": { - "find-up": "^2.1.0" + "find-up": "2.1.0" } }, "plur": { @@ -4170,7 +4170,7 @@ "integrity": "sha1-dIJFLBoPUI4+NE6uwxLJHCncZVo=", "dev": true, "requires": { - "irregular-plurals": "^1.0.0" + "irregular-plurals": "1.4.0" } }, "prepend-http": { @@ -4191,8 +4191,8 @@ "integrity": "sha1-6crJx2v27lL+lC3ZxsQhMVOxKIE=", "dev": true, "requires": { - "parse-ms": "^1.0.0", - "plur": "^2.1.2" + "parse-ms": "1.0.1", + "plur": "2.1.2" }, "dependencies": { "parse-ms": { @@ -4242,8 +4242,8 @@ "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { - "is-number": "^3.0.0", - "kind-of": "^4.0.0" + "is-number": "3.0.0", + "kind-of": "4.0.0" }, "dependencies": { "is-number": { @@ -4252,7 +4252,7 @@ "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", "dev": true, "requires": { - "kind-of": "^3.0.2" + "kind-of": "3.2.2" }, "dependencies": { "kind-of": { @@ -4261,7 +4261,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "^1.1.5" + "is-buffer": "1.1.6" } } } @@ -4272,7 +4272,7 @@ "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", "dev": true, "requires": { - "is-buffer": "^1.1.5" + "is-buffer": "1.1.6" } } } @@ -4282,10 +4282,10 @@ "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.6.tgz", "integrity": "sha1-6xiYnG1PTxYsOZ953dKfODVWgJI=", "requires": { - "deep-extend": "~0.4.0", - "ini": "~1.3.0", - "minimist": "^1.2.0", - "strip-json-comments": "~2.0.1" + "deep-extend": "0.4.2", + "ini": "1.3.5", + "minimist": "1.2.0", + "strip-json-comments": "2.0.1" }, "dependencies": { "minimist": { @@ -4301,9 +4301,9 @@ "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", "dev": true, "requires": { - "load-json-file": "^2.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^2.0.0" + "load-json-file": "2.0.0", + "normalize-package-data": "2.4.0", + "path-type": "2.0.0" } }, "read-pkg-up": { @@ -4312,8 +4312,8 @@ "integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=", "dev": true, "requires": { - "find-up": "^2.0.0", - "read-pkg": "^2.0.0" + "find-up": "2.1.0", + "read-pkg": "2.0.0" } }, "readable-stream": { @@ -4321,13 +4321,13 @@ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "2.0.0", + "safe-buffer": "5.1.1", + "string_decoder": "1.1.1", + "util-deprecate": "1.0.2" } }, "readdirp": { @@ -4336,10 +4336,10 @@ "integrity": "sha1-TtCtBg3zBzMAxIRANz9y0cxkLXg=", "dev": true, "requires": { - "graceful-fs": "^4.1.2", - "minimatch": "^3.0.2", - "readable-stream": "^2.0.2", - "set-immediate-shim": "^1.0.1" + "graceful-fs": "4.1.11", + "minimatch": "3.0.4", + "readable-stream": "2.3.6", + "set-immediate-shim": "1.0.1" } }, "redent": { @@ -4348,8 +4348,8 @@ "integrity": "sha1-z5Fqsf1fHxbfsggi3W7H9zDCr94=", "dev": true, "requires": { - "indent-string": "^2.1.0", - "strip-indent": "^1.0.1" + "indent-string": "2.1.0", + "strip-indent": "1.0.1" }, "dependencies": { "indent-string": { @@ -4358,7 +4358,7 @@ "integrity": "sha1-ji1INIdCEhtKghi3oTfppSBJ3IA=", "dev": true, "requires": { - "repeating": "^2.0.0" + "repeating": "2.0.1" } } } @@ -4380,7 +4380,7 @@ "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { - "is-equal-shallow": "^0.1.3" + "is-equal-shallow": "0.1.3" } }, "regexpu-core": { @@ -4389,9 +4389,9 @@ "integrity": "sha1-SdA4g3uNz4v6W5pCE5k45uoq4kA=", "dev": true, "requires": { - "regenerate": "^1.2.1", - "regjsgen": "^0.2.0", - "regjsparser": "^0.1.4" + "regenerate": "1.3.3", + "regjsgen": "0.2.0", + "regjsparser": "0.1.5" } }, "registry-auth-token": { @@ -4400,8 +4400,8 @@ "integrity": "sha512-JL39c60XlzCVgNrO+qq68FoNb56w/m7JYvGR2jT5iR1xBrUA3Mfx5Twk5rqTThPmQKMWydGmq8oFtDlxfrmxnQ==", "dev": true, "requires": { - "rc": "^1.1.6", - "safe-buffer": "^5.0.1" + "rc": "1.2.6", + "safe-buffer": "5.1.1" } }, "registry-url": { @@ -4410,7 +4410,7 @@ "integrity": "sha1-PU74cPc93h138M+aOBQyRE4XSUI=", "dev": true, "requires": { - "rc": "^1.0.1" + "rc": "1.2.6" } }, "regjsgen": { @@ -4425,7 +4425,7 @@ "integrity": "sha1-fuj4Tcb6eS0/0K4ijSS9lJ6tIFw=", "dev": true, "requires": { - "jsesc": "~0.5.0" + "jsesc": "0.5.0" } }, "release-zalgo": { @@ -4434,7 +4434,7 @@ "integrity": "sha1-CXALflB0Mpc5Mw5TXFqQ+2eFFzA=", "dev": true, "requires": { - "es6-error": "^4.0.1" + "es6-error": "4.1.1" } }, "remove-trailing-separator": { @@ -4461,7 +4461,7 @@ "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", "dev": true, "requires": { - "is-finite": "^1.0.0" + "is-finite": "1.0.2" } }, "request": { @@ -4469,28 +4469,28 @@ "resolved": "https://registry.npmjs.org/request/-/request-2.85.0.tgz", "integrity": "sha512-8H7Ehijd4js+s6wuVPLjwORxD4zeuyjYugprdOXlPSqaApmL/QOy+EB/beICHVCHkGMKNh5rvihb5ov+IDw4mg==", "requires": { - "aws-sign2": "~0.7.0", - "aws4": "^1.6.0", - "caseless": "~0.12.0", - "combined-stream": "~1.0.5", - "extend": "~3.0.1", - "forever-agent": "~0.6.1", - "form-data": "~2.3.1", - "har-validator": "~5.0.3", - "hawk": "~6.0.2", - "http-signature": "~1.2.0", - "is-typedarray": "~1.0.0", - "isstream": "~0.1.2", - "json-stringify-safe": "~5.0.1", - "mime-types": "~2.1.17", - "oauth-sign": "~0.8.2", - "performance-now": "^2.1.0", - "qs": "~6.5.1", - "safe-buffer": "^5.1.1", - "stringstream": "~0.0.5", - "tough-cookie": "~2.3.3", - "tunnel-agent": "^0.6.0", - "uuid": "^3.1.0" + "aws-sign2": "0.7.0", + "aws4": "1.7.0", + "caseless": "0.12.0", + "combined-stream": "1.0.6", + "extend": "3.0.1", + "forever-agent": "0.6.1", + "form-data": "2.3.2", + "har-validator": "5.0.3", + "hawk": "6.0.2", + "http-signature": "1.2.0", + "is-typedarray": "1.0.0", + "isstream": "0.1.2", + "json-stringify-safe": "5.0.1", + "mime-types": "2.1.18", + "oauth-sign": "0.8.2", + "performance-now": "2.1.0", + "qs": "6.5.1", + "safe-buffer": "5.1.1", + "stringstream": "0.0.5", + "tough-cookie": "2.3.4", + "tunnel-agent": "0.6.0", + "uuid": "3.2.1" } }, "require-precompiled": { @@ -4510,7 +4510,7 @@ "integrity": "sha1-AKn3OHVW4nA46uIyyqNypqWbZlo=", "dev": true, "requires": { - "resolve-from": "^3.0.0" + "resolve-from": "3.0.0" } }, "resolve-from": { @@ -4525,8 +4525,8 @@ "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", "dev": true, "requires": { - "onetime": "^2.0.0", - "signal-exit": "^3.0.2" + "onetime": "2.0.1", + "signal-exit": "3.0.2" } }, "rimraf": { @@ -4534,7 +4534,7 @@ "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.4.5.tgz", "integrity": "sha1-7nEM5dk6j9uFb7Xqj/Di11k0sto=", "requires": { - "glob": "^6.0.1" + "glob": "6.0.4" } }, "safe-buffer": { @@ -4567,7 +4567,7 @@ "integrity": "sha1-S7uEN8jTfksM8aaP1ybsbWRdbTY=", "dev": true, "requires": { - "semver": "^5.0.3" + "semver": "5.3.0" } }, "serialize-error": { @@ -4593,7 +4593,7 @@ "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", "dev": true, "requires": { - "shebang-regex": "^1.0.0" + "shebang-regex": "1.0.0" } }, "shebang-regex": { @@ -4619,7 +4619,7 @@ "integrity": "sha512-POqxBK6Lb3q6s047D/XsDVNPnF9Dl8JSaqe9h9lURl0OdNqy/ujDrOiIHtsqXMGbWWTIomRzAMaTyawAU//Reg==", "dev": true, "requires": { - "is-fullwidth-code-point": "^2.0.0" + "is-fullwidth-code-point": "2.0.0" }, "dependencies": { "is-fullwidth-code-point": { @@ -4641,7 +4641,7 @@ "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "requires": { - "hoek": "4.x.x" + "hoek": "4.2.1" } }, "sort-keys": { @@ -4650,7 +4650,7 @@ "integrity": "sha1-ZYU1WEhh7JfXMNbPQYIuH1ZoQSg=", "dev": true, "requires": { - "is-plain-obj": "^1.0.0" + "is-plain-obj": "1.1.0" } }, "source-map": { @@ -4665,7 +4665,7 @@ "integrity": "sha512-PETSPG6BjY1AHs2t64vS2aqAgu6dMIMXJULWFBGbh2Gr8nVLbCFDo6i/RMMvviIQ2h1Z8+5gQhVKSn2je9nmdg==", "dev": true, "requires": { - "source-map": "^0.6.0" + "source-map": "0.6.1" }, "dependencies": { "source-map": { @@ -4682,8 +4682,8 @@ "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { - "spdx-expression-parse": "^3.0.0", - "spdx-license-ids": "^3.0.0" + "spdx-expression-parse": "3.0.0", + "spdx-license-ids": "3.0.0" } }, "spdx-exceptions": { @@ -4698,8 +4698,8 @@ "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { - "spdx-exceptions": "^2.1.0", - "spdx-license-ids": "^3.0.0" + "spdx-exceptions": "2.1.0", + "spdx-license-ids": "3.0.0" } }, "spdx-license-ids": { @@ -4719,14 +4719,14 @@ "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.14.1.tgz", "integrity": "sha1-Ew9Zde3a2WPx1W+SuaxsUfqfg+s=", "requires": { - "asn1": "~0.2.3", - "assert-plus": "^1.0.0", - "bcrypt-pbkdf": "^1.0.0", - "dashdash": "^1.12.0", - "ecc-jsbn": "~0.1.1", - "getpass": "^0.1.1", - "jsbn": "~0.1.0", - "tweetnacl": "~0.14.0" + "asn1": "0.2.3", + "assert-plus": "1.0.0", + "bcrypt-pbkdf": "1.0.1", + "dashdash": "1.14.1", + "ecc-jsbn": "0.1.1", + "getpass": "0.1.7", + "jsbn": "0.1.1", + "tweetnacl": "0.14.5" } }, "stack-utils": { @@ -4740,9 +4740,9 @@ "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" } }, "string_decoder": { @@ -4750,7 +4750,7 @@ "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "requires": { - "safe-buffer": "~5.1.0" + "safe-buffer": "5.1.1" } }, "stringstream": { @@ -4763,7 +4763,7 @@ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "requires": { - "ansi-regex": "^2.0.0" + "ansi-regex": "2.1.1" } }, "strip-bom": { @@ -4778,7 +4778,7 @@ "integrity": "sha1-HLRar1dTD0yvhsf3UXnSyaUd1XI=", "dev": true, "requires": { - "is-utf8": "^0.2.1" + "is-utf8": "0.2.1" } }, "strip-eof": { @@ -4793,7 +4793,7 @@ "integrity": "sha1-DHlipq3vp7vUrDZkYKY4VSrhoKI=", "dev": true, "requires": { - "get-stdin": "^4.0.1" + "get-stdin": "4.0.1" } }, "strip-json-comments": { @@ -4807,11 +4807,11 @@ "integrity": "sha512-HZJ3geIMPgVwKk2VsmO5YHqnnJYl6bV5A9JW2uzqV43WmpgliNEYbuvukfor7URpaqpxuw3CfZ3ONdVbZjCgIA==", "dev": true, "requires": { - "arrify": "^1.0.1", - "indent-string": "^3.2.0", - "js-yaml": "^3.10.0", - "serialize-error": "^2.1.0", - "strip-ansi": "^4.0.0" + "arrify": "1.0.1", + "indent-string": "3.2.0", + "js-yaml": "3.11.0", + "serialize-error": "2.1.0", + "strip-ansi": "4.0.0" }, "dependencies": { "ansi-regex": { @@ -4826,7 +4826,7 @@ "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "dev": true, "requires": { - "ansi-regex": "^3.0.0" + "ansi-regex": "3.0.0" } } } @@ -4837,7 +4837,7 @@ "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", "dev": true, "requires": { - "has-flag": "^3.0.0" + "has-flag": "3.0.0" }, "dependencies": { "has-flag": { @@ -4859,13 +4859,13 @@ "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.1.tgz", "integrity": "sha512-O+v1r9yN4tOsvl90p5HAP4AEqbYhx4036AGMm075fH9F8Qwi3oJ+v4u50FkT/KkvywNGtwkk0zRI+8eYm1X/xg==", "requires": { - "chownr": "^1.0.1", - "fs-minipass": "^1.2.5", - "minipass": "^2.2.4", - "minizlib": "^1.1.0", - "mkdirp": "^0.5.0", - "safe-buffer": "^5.1.1", - "yallist": "^3.0.2" + "chownr": "1.0.1", + "fs-minipass": "1.2.5", + "minipass": "2.2.4", + "minizlib": "1.1.0", + "mkdirp": "0.5.1", + "safe-buffer": "5.1.1", + "yallist": "3.0.2" } }, "term-size": { @@ -4874,7 +4874,7 @@ "integrity": "sha1-RYuDiH8oj8Vtb/+/rSYuJmOO+mk=", "dev": true, "requires": { - "execa": "^0.7.0" + "execa": "0.7.0" } }, "text-table": { @@ -4889,8 +4889,8 @@ "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", "dev": true, "requires": { - "readable-stream": "^2.1.5", - "xtend": "~4.0.1" + "readable-stream": "2.3.6", + "xtend": "4.0.1" } }, "time-zone": { @@ -4916,7 +4916,7 @@ "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "requires": { - "punycode": "^1.4.1" + "punycode": "1.4.1" } }, "trim-newlines": { @@ -4942,7 +4942,7 @@ "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", "requires": { - "safe-buffer": "^5.0.1" + "safe-buffer": "5.1.1" } }, "tweetnacl": { @@ -4963,7 +4963,7 @@ "integrity": "sha1-nhBXzKhRq7kzmPizOuGHuZyuwRo=", "dev": true, "requires": { - "crypto-random-string": "^1.0.0" + "crypto-random-string": "1.0.0" } }, "unique-temp-dir": { @@ -4972,8 +4972,8 @@ "integrity": "sha1-bc6VsmgcoAPuv7MEpBX5y6vMU4U=", "dev": true, "requires": { - "mkdirp": "^0.5.1", - "os-tmpdir": "^1.0.1", + "mkdirp": "0.5.1", + "os-tmpdir": "1.0.2", "uid2": "0.0.3" } }, @@ -4989,16 +4989,16 @@ "integrity": "sha512-gwMdhgJHGuj/+wHJJs9e6PcCszpxR1b236igrOkUofGhqJuG+amlIKwApH1IW1WWl7ovZxsX49lMBWLxSdm5Dw==", "dev": true, "requires": { - "boxen": "^1.2.1", - "chalk": "^2.0.1", - "configstore": "^3.0.0", - "import-lazy": "^2.1.0", - "is-ci": "^1.0.10", - "is-installed-globally": "^0.1.0", - "is-npm": "^1.0.0", - "latest-version": "^3.0.0", - "semver-diff": "^2.0.0", - "xdg-basedir": "^3.0.0" + "boxen": "1.3.0", + "chalk": "2.4.0", + "configstore": "3.1.2", + "import-lazy": "2.1.0", + "is-ci": "1.1.0", + "is-installed-globally": "0.1.0", + "is-npm": "1.0.0", + "latest-version": "3.1.0", + "semver-diff": "2.1.0", + "xdg-basedir": "3.0.0" } }, "url-parse-lax": { @@ -5007,7 +5007,7 @@ "integrity": "sha1-evjzA2Rem9eaJy56FKxovAYJ2nM=", "dev": true, "requires": { - "prepend-http": "^1.0.1" + "prepend-http": "1.0.4" } }, "util-deprecate": { @@ -5026,8 +5026,8 @@ "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { - "spdx-correct": "^3.0.0", - "spdx-expression-parse": "^3.0.0" + "spdx-correct": "3.0.0", + "spdx-expression-parse": "3.0.0" } }, "verror": { @@ -5035,9 +5035,9 @@ "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", "requires": { - "assert-plus": "^1.0.0", + "assert-plus": "1.0.0", "core-util-is": "1.0.2", - "extsprintf": "^1.2.0" + "extsprintf": "1.3.0" } }, "well-known-symbols": { @@ -5051,7 +5051,7 @@ "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "requires": { - "isexe": "^2.0.0" + "isexe": "2.0.0" } }, "wide-align": { @@ -5059,7 +5059,7 @@ "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.2.tgz", "integrity": "sha512-ijDLlyQ7s6x1JgCLur53osjm/UXUYD9+0PbYKrBsYisYXzCxN+HC3mYDNy/dWdmf3AwqwU3CXwDCvsNgGK1S0w==", "requires": { - "string-width": "^1.0.2" + "string-width": "1.0.2" } }, "widest-line": { @@ -5068,7 +5068,7 @@ "integrity": "sha1-AUKk6KJD+IgsAjOqDgKBqnYVInM=", "dev": true, "requires": { - "string-width": "^2.1.1" + "string-width": "2.1.1" }, "dependencies": { "ansi-regex": { @@ -5089,8 +5089,8 @@ "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", "dev": true, "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" + "is-fullwidth-code-point": "2.0.0", + "strip-ansi": "4.0.0" } }, "strip-ansi": { @@ -5099,7 +5099,7 @@ "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "dev": true, "requires": { - "ansi-regex": "^3.0.0" + "ansi-regex": "3.0.0" } } } @@ -5115,9 +5115,9 @@ "integrity": "sha512-xuPeK4OdjWqtfi59ylvVL0Yn35SF3zgcAcv7rBPFHVaEapaDr4GdGgm3j7ckTwH9wHL7fGmgfAnb0+THrHb8tA==", "dev": true, "requires": { - "graceful-fs": "^4.1.11", - "imurmurhash": "^0.1.4", - "signal-exit": "^3.0.2" + "graceful-fs": "4.1.11", + "imurmurhash": "0.1.4", + "signal-exit": "3.0.2" } }, "write-json-file": { @@ -5126,12 +5126,12 @@ "integrity": "sha1-K2TIozAE1UuGmMdtWFp3zrYdoy8=", "dev": true, "requires": { - "detect-indent": "^5.0.0", - "graceful-fs": "^4.1.2", - "make-dir": "^1.0.0", - "pify": "^3.0.0", - "sort-keys": "^2.0.0", - "write-file-atomic": "^2.0.0" + "detect-indent": "5.0.0", + "graceful-fs": "4.1.11", + "make-dir": "1.2.0", + "pify": "3.0.0", + "sort-keys": "2.0.0", + "write-file-atomic": "2.3.0" }, "dependencies": { "detect-indent": { @@ -5154,8 +5154,8 @@ "integrity": "sha1-AwqZlMyZk9JbTnWp8aGSNgcpHOk=", "dev": true, "requires": { - "sort-keys": "^2.0.0", - "write-json-file": "^2.2.0" + "sort-keys": "2.0.0", + "write-json-file": "2.3.0" } }, "xdg-basedir": { From e6347119acf911908b4944252928dad0265cba4d Mon Sep 17 00:00:00 2001 From: Andrea Parodi Date: Mon, 30 Apr 2018 12:25:22 +0200 Subject: [PATCH 190/190] Add node 10 to CI --- .travis.yml | 1 + appveyor.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index b3c7c77..aa1da60 100755 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ dist: trusty language: node_js node_js: + - '10' - '9' - '8' - '6' diff --git a/appveyor.yml b/appveyor.yml index 50b5855..5efef5c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,6 +4,7 @@ image: Visual Studio 2015 environment: matrix: + - nodejs_version: "10" - nodejs_version: "9" - nodejs_version: "8" - nodejs_version: "6"