diff --git a/ui (gen4)/Makefile b/ui (gen4)/Makefile index d217d2f8..1673a5a2 100755 --- a/ui (gen4)/Makefile +++ b/ui (gen4)/Makefile @@ -11,6 +11,8 @@ APP_NAME=ImageGrid.Viewer +NODE_VERSION=v5.10.0 + # process LESS files to CSS... %.css: %.less @@ -120,6 +122,10 @@ zip: $(APP_ZIP) node-deps: npm install +sharp: node-deps + cd node_modules/sharp/ + node-gyp --target=$(NODE_VERSION) rebuild + css: $(CSS_FILES) dev: css diff --git a/ui (gen4)/features/app.js b/ui (gen4)/features/app.js index cb77c42d..9a8ff3ed 100755 --- a/ui (gen4)/features/app.js +++ b/ui (gen4)/features/app.js @@ -10,6 +10,7 @@ define(function(require){ var module = {} var actions = require('lib/actions') var features = require('lib/features') +var toggler = require('lib/toggler') var core = require('features/core') var base = require('features/base') @@ -31,12 +32,11 @@ var AppControlActions = actions.Actions({ storeWindowGeometry: ['- Interface/Store window state', function(){ // store window parameters (size, state)... - var gui = requirejs('nw.gui') - var win = gui.Window.get() + var win = nw.Window.get() // fullscreen... // ...avoid overwriting size... - if(win.isFullscreen){ + if(this.toggleFullScreen('?') == 'on'){ this.config.window = this.config.window || {} this.config.window.fullscreen = true this.config.window.zoom = win.zoomLevel @@ -56,8 +56,7 @@ var AppControlActions = actions.Actions({ function(){ // or global.window.nwDispatcher.requireNwGui() // (see: https://github.com/rogerwang/node-webkit/issues/707) - var gui = requirejs('nw.gui') - var win = gui.Window.get() + var win = nw.Window.get() // XXX move this into .restoreWindowGeometry(..) // get window state from config and load it... @@ -92,7 +91,7 @@ var AppControlActions = actions.Actions({ // XXX check if we are full screen... if(cfg != null && cfg.fullscreen && !win.isFullscreen){ - this.toggleFullScreen() + this.toggleFullScreen('on') } /* XXX still buggy.... @@ -102,34 +101,48 @@ var AppControlActions = actions.Actions({ || this.toggleInterfaceScale('??')[0]) */ }], + toggleFullScreen: ['Interface/Toggle full screen mode', - function(){ - var that = this - this.ribbons.preventTransitions() + toggler.CSSClassToggler( + function(){ return document.body }, + '.full-screen-mode', + function(action){ + var that = this + var w = nw.Window.get() - // hide the viewer to hide any animation crimes... - this.ribbons.viewer[0].style.visibility = 'hidden' + // change the state only if the target state is not the same + // as the current state... + if((w.isFullscreen() ? 'on' : 'off') != action){ + this.ribbons.preventTransitions() - // XXX where should toggleFullscreenMode(..) be defined... - // ...this also toggles a fullscreen css class on body... - toggleFullscreenMode() - //requirejs('nw.gui').Window.get().toggleFullscreen() + // hide the viewer to hide any animation crimes... + this.ribbons.viewer[0].style.visibility = 'hidden' - setTimeout(function(){ - that - .centerViewer() - .focusImage() - .ribbons - .restoreTransitions() + // XXX async... + // ...this complicates things as we need to do the next + // bit AFTER the resize is done... + w.toggleFullscreen() - that.ribbons.viewer[0].style.visibility = '' - }, 0) - }], + setTimeout(function(){ + that + .centerViewer() + .focusImage() + .ribbons + .restoreTransitions() + + that.ribbons.viewer[0].style.visibility = '' + }, 100) + } + + // NOTE: we delay this to account for window animation... + setTimeout(function(){ + that.storeWindowGeometry() + }, 500) + })], showDevTools: ['Interface|Development/Show Dev Tools', function(){ - if(window.showDevTools != null){ - showDevTools() - } + nw.Window.get().showDevTools && + nw.Window.get().showDevTools() }], }) @@ -174,8 +187,7 @@ module.AppControl = core.ImageGridFeatures.Feature({ function(){ this.storeWindowGeometry() }], ['focusImage', function(){ - var gui = requirejs('nw.gui') - var win = gui.Window.get() + var win = nw.Window.get() if(this.images){ var img = this.images[this.current] diff --git a/ui (gen4)/features/cli.js b/ui (gen4)/features/cli.js index 6a8ee8b8..cac851e2 100755 --- a/ui (gen4)/features/cli.js +++ b/ui (gen4)/features/cli.js @@ -119,7 +119,7 @@ module.CLI = core.ImageGridFeatures.Feature({ // ig lf sm lf // ...this will print the list of features before // and after setup... - .option('sm, --setup-minimal', 'setup minimap features', function(){ + .option('sm, --setup-minimal', 'setup minimal features', function(){ // load features we might need... // XXX require js loads these at the root... var location = require('features/location') diff --git a/ui (gen4)/features/core.js b/ui (gen4)/features/core.js index 9ebbce1e..4047e89e 100755 --- a/ui (gen4)/features/core.js +++ b/ui (gen4)/features/core.js @@ -51,25 +51,27 @@ var ImageGridFeatures = module.ImageGridFeatures = Object.create(features.FeatureSet) -// setup exit... +// nw or node... if(typeof(process) != 'undefined'){ - // NOTE: if this passes it is async while when fails it's sync, this - // is why we set .runtime to 'nw' optimistically in advance so - // as not to wait if all goes well and set it to 'node' in the - // callback that if fails will fail right away... - ImageGridFeatures.runtime = 'nw' - requirejs(['nw.gui'], - // OK: nw.js - function(){}, - // ERR: pure node.js... - function(){ ImageGridFeatures.runtime = 'node' }) + // nw.js 0.13+ + if(typeof(nw) != 'undefined'){ + ImageGridFeatures.runtime = 'nw' + + // node... + } else { + ImageGridFeatures.runtime = 'node' + } // browser... +// NOTE: we're avoiding detecting browser specifics for as long as possible, +// this will minimize the headaches of supporting several non-standard +// versions of code... } else if(typeof(window) != 'undefined'){ ImageGridFeatures.runtime = 'browser' // unknown... +// XXX do we need to detect chrome app??? } else { ImageGridFeatures.runtime = 'unknown' } @@ -101,8 +103,6 @@ var LifeCycleActions = actions.Actions({ // nw.js... if(runtime == 'nw'){ - var gui = requirejs('nw.gui') - // this handles both reload and close... $(window).on('beforeunload', stop) @@ -117,7 +117,9 @@ var LifeCycleActions = actions.Actions({ // wait till ALL the handlers finish before // exiting... .on('stop.post', function(){ - w.close(true) + // XXX might be broken in nw13 -- test!!! + //w.close(true) + nw.App.quit() }) .stop() @@ -127,8 +129,7 @@ var LifeCycleActions = actions.Actions({ this.close(true) } } - gui.Window.get().on('close', this.__nw_stop_handler) - + nw.Window.get().on('close', this.__nw_stop_handler) // node.js... } else if(runtime == 'node'){ @@ -154,8 +155,7 @@ var LifeCycleActions = actions.Actions({ // nw... if(this.__nw_stop_handler && this.runtime == 'nw'){ - var gui = requirejs('nw.gui') - //gui.Window.get().off('close', this.__nw_stop_handler) + //nw.Window.get().off('close', this.__nw_stop_handler) delete this.__nw_stop_handler } diff --git a/ui (gen4)/nw.js b/ui (gen4)/nw.js index c4e39b90..9e48db55 100755 --- a/ui (gen4)/nw.js +++ b/ui (gen4)/nw.js @@ -5,9 +5,6 @@ **********************************************************************/ if(window.nodejs != null){ -// node-webkit specific modules... -var gui = require('nw.gui') - define(function(require){ var module = {} var toggler = require('lib/toggler') @@ -29,20 +26,20 @@ module.toggleFullscreenMode = toggler.CSSClassToggler( document.body, '.full-screen-mode', function(action){ - gui.Window.get().toggleFullscreen() + nw.Window.get().toggleFullscreen() }) window.showDevTools = module.showDevTools = function(){ - gui.Window.get().showDevTools() + nw.Window.get().showDevTools() } window.setWindowTitle = module.setWindowTitle = function(text){ browser.setWindowTitle(test) - gui.Window.get().title = title + nw.Window.get().title = title }