saved layout (#62)

* saved layout

* fix fieldName check
This commit is contained in:
Lynn
2017-04-20 11:54:11 -07:00
committed by GitHub
parent 9785baacc3
commit 439f283916
11 changed files with 413 additions and 113 deletions

View File

@@ -87,6 +87,22 @@ function createAPI() {
});
},
/**
* Allows JS to register a callback to be invoked when size/positions
* changes for any pop-out window (i.e., window.open). The main
* process will emit IPC event 'boundsChange' (see below). Currently
* only one window can register for bounds change.
* @param {Function} callback Function invoked when bounds changes.
*/
registerBoundsChange: function(callback) {
if (typeof callback === 'function') {
local.boundsChangeCallback = callback;
local.ipcRenderer.send(apiName, {
cmd: apiCmds.registerBoundsChange
});
}
},
/**
* allows JS to register a logger that can be used by electron main process.
* @param {Object} logger function that can be called accepting
@@ -94,9 +110,6 @@ function createAPI() {
* logLevel: 'ERROR'|'CONFLICT'|'WARN'|'ACTION'|'INFO'|'DEBUG',
* logDetails: String
* }
*
* note: only main window is allowed to register a logger, others are
* ignored.
*/
registerLogger: function(logger) {
if (typeof logger === 'function') {
@@ -119,6 +132,20 @@ function createAPI() {
}
});
// listen for notifications that some window size/position has changed
local.ipcRenderer.on('boundsChange', (event, arg) => {
if (local.boundsChangeCallback && arg.windowName &&
arg.x && arg.y && arg.width && arg.height) {
local.boundsChangeCallback({
x: arg.x,
y: arg.y,
width: arg.width,
height: arg.height,
windowName: arg.windowName
});
}
});
/**
* Use render process to create badge count img and send back to main process.
* If number is greater than 99 then 99+ img is returned.