now window state is saved and restored...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2015-12-15 05:07:51 +03:00
parent ece628e247
commit 945b37c29d
2 changed files with 81 additions and 17 deletions

View File

@ -190,7 +190,7 @@ var RibbonsPrototype = {
return this return this
}, },
// Prevent CSS transitions... // Restore CSS transitions...
// //
// This is a companion to .preventTransitions(..) // This is a companion to .preventTransitions(..)
// //

View File

@ -4006,16 +4006,85 @@ var AppControlActions = actions.Actions({
// XXX revise these... // XXX revise these...
close: ['File|Interface/Close viewer', close: ['File|Interface/Close viewer',
function(){ window.close() }],
storeWindowGeometry: ['- Interface/Store window state',
function(){ function(){
// XXX should we do anything else here like auto-save??? // store window parameters (size, state)...
window.close() var gui = requirejs('nw.gui')
var win = gui.Window.get()
if(win.isFullscreen){
this.config.window = this.config.window || {}
this.config.window.fullscreen = true
} else {
this.config.window = {
size: {
width: win.width,
height: win.height,
},
fullscreen: false,
}
}
}],
restoreWindowGeometry: ['- Interface/Restore window state',
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()
// XXX move this into .restoreWindowGeometry(..)
// get window state from config and load it...
var cfg = this.config.window
if(cfg != null){
var W = screen.width
var H = screen.height
var w = 800
var h = 600
if(cfg.size){
w = win.width = Math.min(cfg.size.width, screen.width)
h = win.height = Math.min(cfg.size.height, screen.height)
}
// place on center of the screen...
var x = win.x = (W - w)/2
var y = win.y = (H - h)/2
//console.log('GEOMETRY:', w, h, x, y)
this.centerViewer()
}
win.show()
if(cfg != null && cfg.fullscreen){
this.toggleFullScreen()
}
}], }],
toggleFullScreen: ['Interface/Toggle full screen mode', toggleFullScreen: ['Interface/Toggle full screen mode',
function(){ function(){
// XXX where should toggleFullscreenMode(..) be defined... var that = this
toggleFullscreenMode() this.ribbons.preventTransitions()
this.centerViewer() // hide the viewer to hide any animation crimes...
this.ribbons.viewer[0].style.visibility = 'hidden'
// XXX where should toggleFullscreenMode(..) be defined...
// ...this also toggles a fullscreen css class on body...
toggleFullscreenMode()
//requirejs('nw.gui').Window.get().toggleFullscreen()
setTimeout(function(){
that
.centerViewer()
.focusImage()
.ribbons
.restoreTransitions()
that.ribbons.viewer[0].style.visibility = ''
}, 0)
}], }],
showDevTools: ['Interface|Development/Show Dev Tools', showDevTools: ['Interface|Development/Show Dev Tools',
function(){ function(){
@ -4053,17 +4122,12 @@ module.AppControl = ImageGridFeatures.Feature({
// XXX show main window... // XXX show main window...
handlers: [ handlers: [
['start', ['start',
function(){ function(){ this.restoreWindowGeometry() }],
// or global.window.nwDispatcher.requireNwGui() [[
// (see: https://github.com/rogerwang/node-webkit/issues/707) 'close.pre',
var gui = requirejs('nw.gui') 'toggleFullScreen',
var win = gui.Window.get() ],
function(){ this.storeWindowGeometry() }],
// XXX get window state from config and load it...
// XXX
win.show()
}],
['focusImage', ['focusImage',
function(){ function(){
var gui = requirejs('nw.gui') var gui = requirejs('nw.gui')