From cf4cfa706e8bb8afe9aacda7c232327a49347d8a Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 10 Feb 2016 05:25:14 +0300 Subject: [PATCH] some refactoring... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/app.js | 26 -------------- ui (gen4)/features/meta.js | 1 + ui (gen4)/features/ui.js | 74 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 26 deletions(-) diff --git a/ui (gen4)/features/app.js b/ui (gen4)/features/app.js index 69bf4dad..f1207f56 100755 --- a/ui (gen4)/features/app.js +++ b/ui (gen4)/features/app.js @@ -18,18 +18,11 @@ var base = require('features/base') /*********************************************************************/ - var AppControlActions = actions.Actions({ config: { 'application-window': null, 'window-title': 'ImageGrid.Viewer (${VERSION}): ${FILENAME}', - - // XXX - 'ui-scale-modes': { - desktop: 0, - touch: 3, - }, }, // XXX revise these... @@ -131,25 +124,6 @@ var AppControlActions = actions.Actions({ that.ribbons.viewer[0].style.visibility = '' }, 0) }], - // XXX need to account for scale in PartialRibbons - // XXX should this be browser API??? - toggleInterfaceScale: ['Interface/Toggle interface modes', - base.makeConfigToggler('ui-scale-mode', - function(){ return Object.keys(this.config['ui-scale-modes']) }, - function(state){ - var gui = requirejs('nw.gui') - var win = gui.Window.get() - - - this.ribbons.preventTransitions() - - var w = this.screenwidth - win.zoomLevel = this.config['ui-scale-modes'][state] || 0 - this.screenwidth = w - this.centerViewer() - - this.ribbons.restoreTransitions() - })], showDevTools: ['Interface|Development/Show Dev Tools', function(){ if(window.showDevTools != null){ diff --git a/ui (gen4)/features/meta.js b/ui (gen4)/features/meta.js index b90ebd73..d78db8c0 100755 --- a/ui (gen4)/features/meta.js +++ b/ui (gen4)/features/meta.js @@ -93,6 +93,7 @@ core.ImageGridFeatures.Feature('viewer-testing', [ 'ui-external-editor', // chrome... + 'ui-scale', 'ui-animation', 'ui-bounds-indicators', 'ui-current-image-indicator', diff --git a/ui (gen4)/features/ui.js b/ui (gen4)/features/ui.js index b685a2ec..25a9e741 100755 --- a/ui (gen4)/features/ui.js +++ b/ui (gen4)/features/ui.js @@ -3131,6 +3131,80 @@ module.URLHash = core.ImageGridFeatures.Feature({ //--------------------------------------------------------------------- +// XXX make this work in browser +var UIScaleActions = actions.Actions({ + config: { + // XXX + 'ui-scale-modes': { + desktop: 0, + touch: 3, + }, + }, + + // XXX need to account for scale in PartialRibbons + // XXX should this be browser API??? + toggleInterfaceScale: ['Interface/Toggle interface modes', + base.makeConfigToggler('ui-scale-mode', + function(){ return Object.keys(this.config['ui-scale-modes']) }, + function(state){ + var gui = requirejs('nw.gui') + var win = gui.Window.get() + + + this.ribbons.preventTransitions() + + var w = this.screenwidth + + // XXX need to compensate for external size change... + //this.ribbons.viewer[0].style.transform = 'scale(' + // + (this.config['ui-scale-modes'][state] || 1) + // +')' + win.zoomLevel = this.config['ui-scale-modes'][state] || 0 + + this.screenwidth = w + this.centerViewer() + + this.ribbons.restoreTransitions() + })], +}) + + +// XXX enable scale loading... +// ...need to make this play nice with restoring scale on startup... +var UIScale = +module.UIScale = core.ImageGridFeatures.Feature({ + title: '', + doc: '', + + tag: 'ui-scale', + depends: [ + 'ui', + ], + + actions: UIScaleActions, + + // XXX test if in: + // - chrome app + // - nw + // - mobile + isApplicable: function(){ return this.runtime == 'nw' }, + + // XXX show main window... + handlers: [ + ['start', + function(){ + // XXX this messes up ribbon scale... + // ...too close/fast? + //this.toggleInterfaceScale('!') + }], + ], +}) + + + +//--------------------------------------------------------------------- + + // XXX console / log / status bar // XXX title bar (???)