From 5a58a780cfce95a596872a8ff3d0efdde5f3e9f9 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Thu, 5 May 2016 01:32:47 +0300 Subject: [PATCH] added fullscreen app control buttons... Signed-off-by: Alex A. Naanou --- ui (gen4)/css/layout.less | 38 +++++++++++++++++++ ui (gen4)/features/app.js | 63 ++++++++++++++++++++++++++++++++ ui (gen4)/features/filesystem.js | 36 +++++++++++++----- ui (gen4)/features/meta.js | 2 + ui (gen4)/features/ui.js | 1 + ui (gen4)/lib/widget/browse.js | 5 ++- 6 files changed, 134 insertions(+), 11 deletions(-) diff --git a/ui (gen4)/css/layout.less b/ui (gen4)/css/layout.less index 59779fb6..87c7dc04 100755 --- a/ui (gen4)/css/layout.less +++ b/ui (gen4)/css/layout.less @@ -293,6 +293,44 @@ button:hover { */ +.fullscreen-controls { + display: block; + position: absolute; + top: 0px; + right: 0px; + z-index: 9000; + + opacity: 0.4; + + size: 30px; +} +.fullscreen-controls:hover { + opacity: 1; +} + + +.fullscreen-controls .button { + display: inline-block; + color: silver; + + width: 40px; + height: 40px; + + text-align: center; + line-height: 40px; +} +.fullscreen-controls .button:hover { + color: white; + background: rgba(0, 0, 0, 0.5); +} + + +.fullscreen-controls .button.close:hover { + background: rgba(255, 0, 0, 0.8); +} + + + /********************************************************** Viewer ***/ .viewer { position: relative; diff --git a/ui (gen4)/features/app.js b/ui (gen4)/features/app.js index 795c24a1..284381c0 100755 --- a/ui (gen4)/features/app.js +++ b/ui (gen4)/features/app.js @@ -105,6 +105,10 @@ var AppControlActions = actions.Actions({ }, this.config['window-delay-initial-display'] || 0) }], + minimize: ['Interface/Minimize', + function(){ + nw.Window.get().minimize() + }], toggleFullScreen: ['Interface/Toggle full screen mode', toggler.CSSClassToggler( function(){ return document.body }, @@ -221,6 +225,65 @@ module.AppControl = core.ImageGridFeatures.Feature({ +//--------------------------------------------------------------------- +// Fullscreen app control buttons... +var FullScreenControllsActions = actions.Actions({ + toggleFullScreenControls: ['Interface/', + toggler.Toggler(null, + function(){ + return this.ribbons.viewer.find('.fullscreen-controls').length > 0 ? 'on' : 'off' }, + ['off', 'on'], + function(state){ + // clear the controls.... + this.ribbons.viewer.find('.fullscreen-controls').remove() + + if(state == 'on'){ + var that = this + + $('
') + .addClass('fullscreen-controls') + // minimize.... + .append($('
') + .addClass('button') + .html('_') + .click(function(){ that.minimize() })) + // fullscreen.... + .append($('
') + .addClass('button') + .html('□') + .click(function(){ that.toggleFullScreen() })) + // close... + .append($('
') + .addClass('button close') + .html('×') + .click(function(){ that.close() })) + .appendTo(this.ribbons.viewer) + } + })], +}) + +var FullScreenControlls = +module.FullScreenControlls = core.ImageGridFeatures.Feature({ + title: '', + doc: '', + + tag: 'ui-fullscreen-controls', + depends: [ + 'ui-app-control', + ], + + actions: FullScreenControllsActions, + + handlers: [ + ['toggleFullScreen', + function(){ + this.toggleFullScreenControls(this.toggleFullScreen('?')) + }], + ], +}) + + + /********************************************************************** * vim:set ts=4 sw=4 : */ return module }) diff --git a/ui (gen4)/features/filesystem.js b/ui (gen4)/features/filesystem.js index 6440e993..ddd0d8f6 100755 --- a/ui (gen4)/features/filesystem.js +++ b/ui (gen4)/features/filesystem.js @@ -132,6 +132,10 @@ var FileSystemLoaderActions = actions.Actions({ // a-la glob).... //file.loadIndex(path, this.config['index-dir'], logger) return file.loadIndex(path, this.config['index-dir'], from_date, logger) + .catch(function(err){ + // XXX + console.error(err) + }) .then(function(res){ // XXX if res is empty load raw... @@ -543,9 +547,6 @@ var FileSystemLoaderUIActions = actions.Actions({ // the given path (no UI) while .browsePath(..) will load the // UI in all cases but will treat the given path as a base path // to start from. - // XXX should passing no path to this start browsing from the current - // path or from the root? - // XXX should these be dialog objects??? browseIndex: ['File/Load index...', makeBrowseProxy('loadIndex')], browseImages: ['File/Load images...', makeBrowseProxy('loadImages')], @@ -570,6 +571,9 @@ var FileSystemLoaderUIActions = actions.Actions({ //file.loadIndex(path, that.config['index-dir'], this.logger) // XXX we need to prune the indexes -- avoid loading nested indexes... file.listIndexes(path, index_dir) + .on('error', function(err){ + console.error(err) + }) .on('end', function(res){ // we got the data, we can now remove the spinner... @@ -599,8 +603,10 @@ var FileSystemLoaderUIActions = actions.Actions({ // and selecting a postion will load all the participating // indexes to that date. // NOTE: this will show nothing if .location.method is not loadIndex.. + // NOTE: this will drop all unsaved changes + // NOTE: this will set changes to all when loading a different state + // that the latest and to non otherwise.... // - // XXX should this affect .changes ??? // XXX handle named saves... // XXX add ability to name a save... // XXX need to handle saves (saveIndex(..) and friends) when loaded @@ -627,12 +633,11 @@ var FileSystemLoaderUIActions = actions.Actions({ var from = that.location.from from = from && Date.fromTimeStamp(from).toShortDate() - make('Latest') - .on('open', function(){ - that.reloadState() - }) + if(that.changes !== false){ + make('Unsaved state') - make('---') + make('---') + } // indicate that we are working... var spinner = make($('
')) @@ -657,6 +662,16 @@ var FileSystemLoaderUIActions = actions.Actions({ list .sort() .reverse() + + // Special case: top save state is the default, + // no need to mark anything for change... + var first = list.shift() + first && make(Date.fromTimeStamp(first).toShortDate()) + .on('open', function(){ + that.loadIndex(that.location.path, first) + }) + + list .forEach(function(d){ var txt = Date.fromTimeStamp(d).toShortDate() @@ -664,6 +679,9 @@ var FileSystemLoaderUIActions = actions.Actions({ make(txt) .on('open', function(){ that.loadIndex(that.location.path, d) + .then(function(){ + that.markChanged('all') + }) }) // mark the current loaded position... .addClass(txt == from ? 'selected highlighted' : '') diff --git a/ui (gen4)/features/meta.js b/ui (gen4)/features/meta.js index e23e7651..7b28f5c9 100755 --- a/ui (gen4)/features/meta.js +++ b/ui (gen4)/features/meta.js @@ -54,6 +54,8 @@ core.ImageGridFeatures.Feature('viewer-testing', [ 'ui-ribbons-placement', + 'ui-fullscreen-controls', + // features... 'ui-ribbon-auto-align', //'ui-ribbon-align-to-order', diff --git a/ui (gen4)/features/ui.js b/ui (gen4)/features/ui.js index 234fdfbc..70e4a5ba 100755 --- a/ui (gen4)/features/ui.js +++ b/ui (gen4)/features/ui.js @@ -921,6 +921,7 @@ module.Viewer = core.ImageGridFeatures.Feature({ /*********************************************************************/ // User interfaces for different base features... + // XXX tag dialogs... // XXX diff --git a/ui (gen4)/lib/widget/browse.js b/ui (gen4)/lib/widget/browse.js index c0c8bac2..e4561a87 100755 --- a/ui (gen4)/lib/widget/browse.js +++ b/ui (gen4)/lib/widget/browse.js @@ -1816,8 +1816,9 @@ var BrowserPrototype = { var cur = this.select('!') var elem = this.select(!pattern ? '!' : /-?[0-9]+/.test(pattern) ? pattern - // avoid keywords that .select(..) understands... - : '"'+pattern+'"' ) + // XXX avoid keywords that .select(..) understands... + //: '"'+pattern+'"' ) + : pattern) // item not found... if(elem.length == 0 && pattern != null){