some refactoring...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-02-10 05:25:14 +03:00
parent fdb75bf3f7
commit cf4cfa706e
3 changed files with 75 additions and 26 deletions

View File

@ -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){

View File

@ -93,6 +93,7 @@ core.ImageGridFeatures.Feature('viewer-testing', [
'ui-external-editor',
// chrome...
'ui-scale',
'ui-animation',
'ui-bounds-indicators',
'ui-current-image-indicator',

View File

@ -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 (???)