From e4897d5c31581ab5005528fee620cad7d8414c4b Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sat, 16 Apr 2016 03:41:45 +0300 Subject: [PATCH] added export dialog... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/filesystem.js | 116 ++++++++++++++++++++++++++++- ui (gen4)/features/ui-slideshow.js | 17 +---- ui (gen4)/features/ui-widgets.js | 55 +++++++++++++- 3 files changed, 168 insertions(+), 20 deletions(-) diff --git a/ui (gen4)/features/filesystem.js b/ui (gen4)/features/filesystem.js index 966b4842..05976963 100755 --- a/ui (gen4)/features/filesystem.js +++ b/ui (gen4)/features/filesystem.js @@ -27,6 +27,8 @@ var features = require('lib/features') var core = require('features/core') +var widgets = require('features/ui-widgets') + var overlay = require('lib/widget/overlay') var browse = require('lib/widget/browse') var browseWalk = require('lib/widget/browse-walk') @@ -566,6 +568,37 @@ module.FileSystemLoaderURLHistoryUI = core.ImageGridFeatures.Feature({ var FileSystemWriterActions = actions.Actions({ config: { //'index-filename-template': '${DATE}-${KEYWORD}.${EXT}', + + 'export-path': null, + 'export-paths': [], + + 'export-preview-name-pattern': '%f', + 'export-preview-name-patterns': [ + '%f', + '%n%(-bookmarked)b%e', + '%n%(-marked)m%e', + ], + + 'export-level-directory-name': 'fav', + 'export-level-directory-names': [ + 'fav', + 'select', + ], + + 'export-preview-size': 1000, + // XXX add options to indicate: + // - long side + // - short side + // - vertical + // - horizontal + // - ... + 'export-preview-sizes': [ + 500, + 900, + 1000, + 1280, + 1920, + ], }, // This can be: @@ -778,7 +811,7 @@ var FileSystemWriterActions = actions.Actions({ // XXX add a ui... // - select path // - select preview size - exportCollection: ['File/Export as collection', + exportIndex: ['- File/Export index', function(path, logger){ logger = logger || this.logger @@ -1104,6 +1137,87 @@ var FileSystemWriterUIActions = actions.Actions({ browseSaveIndex: ['File/Save index to...', makeBrowseProxy('saveIndex', function(){ this.location.method = 'loadIndex' })], + + // XXX need to be able to make dirs... + browseExportIndex: ['File/Export/Index to...', + makeBrowseProxy('exportIndex')], + // XXX need to be able to make dirs... + // XXX STUB + browseExportDirs: ['File/Export/Images to...', + makeBrowseProxy('exportDirs')], + + // XXX make this a multi format export dialog... + // - index + // - dirs + // - ... + // XXX indicate export state: index, crop, image... + exportDirsDialog: ['File/Export/Images...', + function(){ + var that = this + + var o = overlay.Overlay(this.ribbons.viewer, + browse.makeLister(null, function(path, make){ + make(['Filename pattern: ', + function(){ return that.config['export-preview-name-pattern'] || '%f' }]) + .on('open', + widgets.makeNestedConfigListEditor(that, o, + 'export-preview-name-patterns', + 'export-preview-name-pattern')) + + make(['Level directory: ', + function(){ return that.config['export-level-directory-name'] || 'fav' }]) + .on('open', + widgets.makeNestedConfigListEditor(that, o, + 'export-level-directory-names', + 'export-level-directory-name')) + + make(['Target image: ', + function(){ return that.config['export-preview-size'] || 1000 }]) + // XXX add validation??? + .on('open', + widgets.makeNestedConfigListEditor(that, o, + 'export-preview-sizes', + 'export-preview-size')) + + make(['To: ', + function(){ return that.config['export-path'] || './' }], + { buttons: [ + ['browse', function(){ + var path = $(this).find('.text').last().text() + + // XXX add new dir global button... + return that.browsePath(path, + function(path){ + that.config['export-path'] = path + that.config['export-paths'].splice(0, 0, path) + + // XXX ugly... + o.focus() + }) + }] + ]}) + .on('open', + widgets.makeNestedConfigListEditor(that, o, + 'export-paths', + 'export-path')) + + // Start/stop... + make([function(){ + // XXX indicate export state: index, crop, image... + return 'Export'}]) + .on('open', function(){ + // XXX is this correct??? + // XXX handle relative paths!!! + that.exportDirs(that.config['export-path'] || that.location.path) + o.close() + }) + })) + + o.client.dom.addClass('metadata-view tail-action') + o.client.select(-1) + + return o + }], }) diff --git a/ui (gen4)/features/ui-slideshow.js b/ui (gen4)/features/ui-slideshow.js index 2fec3d3c..0df0daf7 100755 --- a/ui (gen4)/features/ui-slideshow.js +++ b/ui (gen4)/features/ui-slideshow.js @@ -46,6 +46,7 @@ var SlideshowActions = actions.Actions({ ], }, + // XXX use widgets.makeNestedConfigListEditor(...)??? slideshowIntervalDialog: ['Slideshow/Slideshow interval', function(){ var that = this @@ -75,22 +76,6 @@ var SlideshowActions = actions.Actions({ suspended_timer || that.resetSlideshowTimer() }) - o.client - .open(function(evt, time){ - // we clicked the 'New' button -- select it... - if(!Date.str2ms(time)){ - o.client.select(button_text) - - // set value and exit... - } else { - that.config['slideshow-interval'] = time - - // XXX this is ugly... - o.close() - } - }) - - o.client.dom.addClass('tail-action') o.client.select(that.config['slideshow-interval']) return o diff --git a/ui (gen4)/features/ui-widgets.js b/ui (gen4)/features/ui-widgets.js index 22a7d6b7..bb79605c 100755 --- a/ui (gen4)/features/ui-widgets.js +++ b/ui (gen4)/features/ui-widgets.js @@ -99,6 +99,8 @@ function(actions, list_key, options){ return } + // save the new version... + actions.config[list_key] = actions.config[list_key].slice() // add new value and sort list... actions.config[list_key] .push(txt) @@ -133,8 +135,7 @@ function(actions, list_key, options){ var to_remove = [] var list = browse.makeList( null, - actions.config[list_key] - .concat(new_button ? [ new_button ] : []), + actions.config[list_key].concat(new_button ? [ new_button ] : []), {itemButtons: [ // mark for removal... ['×', @@ -161,6 +162,15 @@ function(actions, list_key, options){ _makeEditable(elem) } }) + .open(function(evt, path){ + // we clicked the 'New' button -- select it... + if(new_button && (path == new_button || path == '')){ + list.select(new_button) + + } else { + options.callback && options.callback.call(list, path) + } + }) var o = overlay.Overlay(actions.ribbons.viewer, list) .close(function(){ @@ -172,7 +182,7 @@ function(actions, list_key, options){ actions.config[list_key] = lst }) - // sort the times... + // sort... if(options.sort){ actions.config[list_key] = actions.config[list_key] .sort(options.sort !== true ? options.sort : undefined) @@ -185,6 +195,45 @@ function(actions, list_key, options){ } +// XXX should this be more generic... +var makeNestedConfigListEditor = +module.makeNestedConfigListEditor = +function(actions, parent, list_name, value_name, options){ + return function(){ + var txt = $(this).find('.text').first().text() + + options = options || {} + var dfl_options = { + new_button: 'New...', + length_limit: 10, + // NOTE: this is called when adding a new value and + // list maximum length is reached... + callback: function(value){ + actions.config[value_name] = value + + o.close() + }, + } + options.__proto__ = dfl_options + + var o = makeConfigListEditor(actions, list_name, options) + + // update slideshow menu... + o.client.open(function(){ + parent.client.update() + parent.client.select(txt) + }) + + o.close(function(){ + // XXX this is ugly... + parent.focus() + }) + + o.client.select(actions.config[value_name]) + } +} + + /*********************************************************************/