updated core.makeConfigToggler(..) to support bool states + single image mode tweaks...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-11-26 14:29:11 +03:00
parent 2651ed943f
commit 051cba3082
4 changed files with 19 additions and 6 deletions

View File

@ -69,7 +69,7 @@ actions.Actions({
// If true, shift up/down will count as a left/right move... // If true, shift up/down will count as a left/right move...
// //
// see .direction for details... // see .direction for details...
'shifts-affect-direction': true, 'shifts-affect-direction': 'on',
// Determines the image selection mode when focusing or moving // Determines the image selection mode when focusing or moving
// between ribbons... // between ribbons...
@ -140,7 +140,7 @@ actions.Actions({
// Sets the number of steps to change direction (N) // Sets the number of steps to change direction (N)
// //
// 'shifts-affect-direction' // 'shifts-affect-direction'
// If true, add last direction change before vertical shift to // If 'on', add last direction change before vertical shift to
// direction counter (N) // direction counter (N)
// This makes the direction change after several shifts up/down // This makes the direction change after several shifts up/down
// "backwards" a bit faster. // "backwards" a bit faster.
@ -449,7 +449,7 @@ actions.Actions({
this.data.shiftImageUp(cur) this.data.shiftImageUp(cur)
this.focusImage(next) this.focusImage(next)
this.config['shifts-affect-direction'] && (this.direction = '!') this.config['shifts-affect-direction'] == 'on' && (this.direction = '!')
// if a specific target is given, just shift it... // if a specific target is given, just shift it...
} else { } else {
@ -473,7 +473,7 @@ actions.Actions({
this.data.shiftImageDown(cur) this.data.shiftImageDown(cur)
this.focusImage(next) this.focusImage(next)
this.config['shifts-affect-direction'] && (this.direction = '!') this.config['shifts-affect-direction'] == 'on' && (this.direction = '!')
// if a specific target is given, just shift it... // if a specific target is given, just shift it...
} else { } else {
@ -507,6 +507,9 @@ actions.Actions({
this.focusImage() this.focusImage()
}], }],
toggleShiftsAffectDirection: ['Interface/Shifts affect direction',
core.makeConfigToggler('shifts-affect-direction', ['off', 'on'])],
shiftRibbonUp: ['Ribbon|Edit|Sort/Shift ribbon up', shiftRibbonUp: ['Ribbon|Edit|Sort/Shift ribbon up',
function(target){ function(target){
this.data.shiftRibbonUp(target) this.data.shiftRibbonUp(target)

View File

@ -39,10 +39,12 @@ module.protocol = function(protocol, func){
// NOTE: if no toggler state is set this assumes that the first state // NOTE: if no toggler state is set this assumes that the first state
// is the default... // is the default...
// NOTE: default states is [false, true]
var makeConfigToggler = var makeConfigToggler =
module.makeConfigToggler = module.makeConfigToggler =
function(attr, states, a, b){ function(attr, states, a, b){
states = states || [false, true]
var pre = a var pre = a
// XXX is this a good default??? // XXX is this a good default???
//var post = b || function(action){ action != null && this.focusImage() } //var post = b || function(action){ action != null && this.focusImage() }
@ -50,10 +52,15 @@ function(attr, states, a, b){
return toggler.Toggler(null, return toggler.Toggler(null,
function(_, action){ function(_, action){
var lst = states.constructor === Array ? states : states.call(this) var lst = states.constructor === Array ? states
: states instanceof Function ? states.call(this)
: states
if(action == null){ if(action == null){
return this.config[attr] || lst[lst.indexOf('none')] || lst[0] var cfg = this.config[attr]
return cfg == null ?
(lst[lst.indexOf('none')] || lst[0])
: cfg
} else { } else {
this.config[attr] = action this.config[attr] = action

View File

@ -110,9 +110,11 @@ var SingleImageActions = actions.Actions({
// workspace... // workspace...
'single-image-config-defaults': { 'single-image-config-defaults': {
'ribbon-focus-mode': 'order', 'ribbon-focus-mode': 'order',
'shifts-affect-direction': 'off',
}, },
}, },
// XXX make this accept args for debuging...
updateImageProportions: ['- Interface/', updateImageProportions: ['- Interface/',
function(){ function(){
var that = this var that = this

View File

@ -860,6 +860,7 @@ module.ViewerActions = actions.Actions({
// ribbon rotation... // ribbon rotation...
//
ribbonRotation: ['- Interface/', ribbonRotation: ['- Interface/',
function(a){ function(a){
if(arguments.length > 0){ if(arguments.length > 0){