diff --git a/Viewer/features/base.js b/Viewer/features/base.js index 33e961d5..7d87e161 100755 --- a/Viewer/features/base.js +++ b/Viewer/features/base.js @@ -850,6 +850,17 @@ actions.Actions({ return this.current_ribbon == this.base && 'disabled' }}, function(target){ this.data.setBase(target) }], + getNextFocused: ['- Image/', + function(target='current', set_direction=true){ + var direction = this.direction == 'right' ? 'next' : 'prev' + var cur = this.data.getImage(target) + var next = this.data.getImage(direction) + || this.data.getImage(direction == 'next' ? 'prev' : 'next') + set_direction + && this.config['shifts-affect-direction'] == 'on' + && (this.direction = this.direction) + return next }], + // NOTE: this does not retain direction information, handle individual // actions if that info is needed. // NOTE: to make things clean, this is triggered in action handlers @@ -886,25 +897,13 @@ actions.Actions({ function(target){ // by default we need to focus another image in the same ribbon... if(target == null){ - var direction = this.direction == 'right' ? 'next' : 'prev' - - var cur = this.data.getImage() - var next = this.data.getImage(direction) - next = next == null - ? this.data.getImage(direction == 'next' ? 'prev' : 'next') - : next - + var cur = this.current + var next = this.getNextFocused(cur) this.data.shiftImageUp(cur) this.focusImage(next) - - this.config['shifts-affect-direction'] == 'on' - && (this.direction = this.direction) - // if a specific target is given, just shift it... } else { - this.data.shiftImageUp(target) - } - }], + this.data.shiftImageUp(target) } }], shiftImageDown: ['Edit|Image/Shift image down', core.doc`Shift image down... @@ -916,25 +915,13 @@ actions.Actions({ function(target){ // by default we need to focus another image in the same ribbon... if(target == null){ - var direction = this.direction == 'right' ? 'next' : 'prev' - - var cur = this.data.getImage() - var next = this.data.getImage(direction) - next = next == null - ? this.data.getImage(direction == 'next' ? 'prev' : 'next') - : next - + var cur = this.current + var next = this.getNextFocused(cur) this.data.shiftImageDown(cur) this.focusImage(next) - - this.config['shifts-affect-direction'] == 'on' - && (this.direction = this.direction) - // if a specific target is given, just shift it... } else { - this.data.shiftImageDown(target) - } - }], + this.data.shiftImageDown(target) } }], // NOTE: we do not need undo here because it will be handled by // corresponding normal shift operations... // XXX .undoLast(..) on these for some reason skips... @@ -943,34 +930,59 @@ actions.Actions({ {journal: true}, function(target){ this.data.newRibbon(target) - this.shiftImageUp(target) - }], + this.shiftImageUp(target) }], shiftImageDownNewRibbon: ['Edit|Image/Shift image down to a new empty ribbon', {journal: true}, function(target){ this.data.newRibbon(target, 'below') - this.shiftImageDown(target) - }], + this.shiftImageDown(target) }], shiftImageLeft: ['Edit|Sort|Image/Shift image left', { undo: undoShift('shiftImageRight'), mode: 'prevImage'}, function(target){ if(target == null){ - this.direction = 'left' - } + this.direction = 'left' } this.data.shiftImageLeft(target) - this.focusImage() - }], + this.focusImage() }], shiftImageRight: ['Edit|Sort|Image/Shift image right', { undo: undoShift('shiftImageLeft'), mode: 'nextImage'}, function(target){ if(target == null){ - this.direction = 'right' - } + this.direction = 'right' } this.data.shiftImageRight(target) - this.focusImage() - }], + this.focusImage() }], + // XXX these are effectively identical... + // XXX when shifting the first image in ribbon alignment is a bit off... + // XXX add undo... + shiftImageToTop: ['Edit|Image/Shift image to top ribbon', + function(target){ + console.warn('shiftImageToTop(..)/shiftImageToBottom(..): need proper undo.') + if(target == null){ + var cur = this.current + var next = this.getNextFocused(cur) + this.data.shiftImage(cur, 0, 'vertical') + this.focusImage(next) + } else { + this.data.shiftImage(target, 0, 'vertical') } }], + shiftImageToBottom: ['Edit|Image/Shift image to bottom ribbon', + function(target){ + console.warn('shiftImageToTop(..)/shiftImageToBottom(..): need proper undo.') + if(target == null){ + var cur = this.current + var next = this.getNextFocused(cur) + this.data.shiftImage(cur, -1, 'vertical') + this.focusImage(next) + } else { + this.data.shiftImage(target, 0, 'vertical') } }], + /* + shiftImageToBase: ['Edit|Image/Shift image to base robbon', + function(){}], + shiftImageOneOverUp: ['Edit|Image/', + function(){}], + shiftImageOneOverDown: ['Edit|Image/', + function(){}], + //*/ shiftRibbonUp: ['Ribbon|Edit|Sort/Shift ribbon up', { undo: undoShift('shiftRibbonDown'), diff --git a/Viewer/features/core.js b/Viewer/features/core.js index e66a992a..7aa5d7f2 100755 --- a/Viewer/features/core.js +++ b/Viewer/features/core.js @@ -2463,14 +2463,12 @@ module.Workspace = ImageGridFeatures.Feature({ //--------------------------------------------------------------------- // Tasks... -// XXX we need: -// - serialize/restore -// -// XXX should this be a separate module??? -//var tasks = require('lib/tasks') +// Task wrapper... +// +// This simply makes tasks actions discoverable... var Task = -module.Tast = +module.Task = function(func){ func.__task__ = true return func } @@ -2497,6 +2495,8 @@ function(func){ // during the later form 'sync' is passed to .Task(..) in the correct // position... // (see ig-types' runner.TaskManager(..) for more info) +// +// XXX might be nice to add metadata like start times and the like... var taskAction = module.taskAction = function(title, func){ diff --git a/Viewer/features/keyboard.js b/Viewer/features/keyboard.js index 7a95cde7..453a40b9 100755 --- a/Viewer/features/keyboard.js +++ b/Viewer/features/keyboard.js @@ -300,10 +300,10 @@ module.GLOBAL_KEYBOARD = { Home: 'firstImage', ctrl_Home: 'firstGlobalImage', - shift_Home: 'firstRibbon', + alt_Home: 'firstRibbon', End: 'lastImage', ctrl_End: 'lastGlobalImage', - shift_End: 'lastRibbon', + alt_End: 'lastRibbon', // NOTE: these (vim-like) bindings have been added by request as // it would seem that not all keyboards have a convenient // Home/End buttons... @@ -322,12 +322,14 @@ module.GLOBAL_KEYBOARD = { alt_shift_Up: 'travelImageUp', ctrl_shift_Up: 'shiftImageUpNewRibbon', ctrl_Up: 'shiftMarkedUp', + shift_Home: 'shiftImageToTop', shift_Down: 'shiftImageDown', caps_Down: 'shiftImageDown', alt_shift_Down: 'travelImageDown', ctrl_shift_Down: 'shiftImageDownNewRibbon', ctrl_Down: 'shiftMarkedDown', + shift_End: 'shiftImageToBottom', alt_Left: 'shiftImageLeft!', alt_Right: 'shiftImageRight!', diff --git a/Viewer/features/metadata.js b/Viewer/features/metadata.js index 40904c14..dc864a52 100755 --- a/Viewer/features/metadata.js +++ b/Viewer/features/metadata.js @@ -25,6 +25,7 @@ if(typeof(process) != 'undefined'){ var util = require('lib/util') var toggler = require('lib/toggler') +// XXX do we need this??? var tasks = require('lib/tasks') var keyboard = require('lib/keyboard') diff --git a/Viewer/lib/tasks.js b/Viewer/lib/tasks.js index 1f32cd1b..6f056dbe 100755 --- a/Viewer/lib/tasks.js +++ b/Viewer/lib/tasks.js @@ -1,6 +1,6 @@ /********************************************************************** * -* +* XXX is this needed??? * **********************************************************************/ ((typeof define)[0]=='u'?function(f){module.exports=f(require)}:define) diff --git a/Viewer/package-lock.json b/Viewer/package-lock.json index ae6cdfb3..d6f25c76 100755 --- a/Viewer/package-lock.json +++ b/Viewer/package-lock.json @@ -1,6 +1,6 @@ { "name": "ImageGrid.Viewer.g4", - "version": "4.0.0-a", + "version": "4.0.0a", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1110,9 +1110,9 @@ "integrity": "sha512-9kZM80Js9/eTwXN9VXwLDC1wDJ7gIAdYU9GIzb5KJmNcLAMaW+zhgFrwFFMrcSfggUuadgnqSrS41E4XLe8JZw==" }, "ig-types": { - "version": "5.0.20", - "resolved": "https://registry.npmjs.org/ig-types/-/ig-types-5.0.20.tgz", - "integrity": "sha512-d2IEwY3ZDSWxn2PY0e7XxMzuOPWzeK/py0sBgqfoCNbKlc4IHEogFwoQIv0C4EZdcXL0cJOsCo74NwbetoSWiA==", + "version": "5.0.21", + "resolved": "https://registry.npmjs.org/ig-types/-/ig-types-5.0.21.tgz", + "integrity": "sha512-902m+C7h6/IE6qlD3LzP+fbDstXMEVKltdOgc9YHQWWCK4zI9IgUckp5lJrrDRsZsaDsKAUIUVcYbAfkxKeOdg==", "requires": { "ig-object": "^5.4.12", "object-run": "^1.0.1" diff --git a/Viewer/package.json b/Viewer/package.json index 4ea92719..a112581a 100755 --- a/Viewer/package.json +++ b/Viewer/package.json @@ -32,7 +32,7 @@ "ig-argv": "^2.15.0", "ig-features": "^3.4.2", "ig-object": "^5.4.12", - "ig-types": "^5.0.20", + "ig-types": "^5.0.21", "moment": "^2.29.1", "object-run": "^1.0.1", "requirejs": "^2.3.6",