added ability to remove images from crop (experimental) + some cleanup...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-09-08 22:03:16 +03:00
parent 2a22cd975c
commit f2019c85aa
4 changed files with 45 additions and 6 deletions

View File

@ -1718,22 +1718,52 @@ module.CropActions = actions.Actions({
this.crop(this.data[selector](tags), flatten) this.crop(this.data[selector](tags), flatten)
}], }],
// crop edit actions... // crop edit actions...
// XXX // XXX do we need this???
removeFromCrop: ['- Crop/', removeFromCrop: ['Crop/Remove from crop',
{browseMode: 'uncrop'},
function(gids){ function(gids){
var that = this
if(!this.cropped){ if(!this.cropped){
return return
} }
var data = this.data
var current = this.current
var focus = false
gids = arguments.length > 1 ? [].slice.call(arguments) : gids gids = arguments.length > 1 ? [].slice.call(arguments) : gids
gids = gids || 'current' gids = gids || 'current'
gids = gids instanceof Array ? gids : [gids] gids = gids instanceof Array ? gids : [gids]
gids = this.data.normalizeGIDs(gids) gids
// clear ribbons...
.filter(function(gid){
if(gid in data.ribbons){
delete data.ribbons[gid]
data.ribbon_order.splice(data.ribbon_order.indexOf(gid), 1)
// XXX return false
}
return true
})
// clear images...
.forEach(function(gid){
gid = data.getImage(gid)
delete data.ribbons[data.getRibbon(gid)][data.order.indexOf(gid)]
if(gid == current){
focus = true
}
})
// the above may result in empty ribbons -> cleanup...
this.data.clear('empty')
// restore correct focus...
focus
&& this.focusImage(this.direction == 'left' ? 'prev' : 'next')
}] }]
}) })

View File

@ -134,7 +134,9 @@ module.GLOBAL_KEYBOARD = {
W: 'testAction2 -- XXX DEBUG: remove when done...', W: 'testAction2 -- XXX DEBUG: remove when done...',
// XXX should we add image level manipulation here, like "remove image"??? // XXX not sure about this...
Del: 'removeFromCrop',
shift_Del: 'removeMarkedFromCrop',
}, },
'Collection': { 'Collection': {
@ -143,6 +145,7 @@ module.GLOBAL_KEYBOARD = {
Esc: 'loadCollection: "ALL" -- Load all images', Esc: 'loadCollection: "ALL" -- Load all images',
Del: 'uncollect', Del: 'uncollect',
shift_Del: 'uncollectMarked',
}, },
'Range': { 'Range': {

View File

@ -240,6 +240,11 @@ var ImageMarkActions = actions.Actions({
{browseMode: function(target){ {browseMode: function(target){
return this.marked.length == 0 && 'disabled' }}, return this.marked.length == 0 && 'disabled' }},
function(flatten){ this.cropTagged('selected', 'any', flatten) }], function(flatten){ this.cropTagged('selected', 'any', flatten) }],
removeMarkedFromCrop: ['Mark|Crop/Remove marked from crop',
{browseMode: function(target){
return (this.marked.length == 0 || !this.cropped) && 'disabled' }},
function(){ this.removeFromCrop(this.marked) }],
}) })

View File

@ -561,6 +561,7 @@ core.ImageGridFeatures.Feature({
'collapseGroup', 'collapseGroup',
'crop', 'crop',
'uncrop', 'uncrop',
'removeFromCrop',
], ],
function(target){ return this.reload(true) }], function(target){ return this.reload(true) }],
[[ [[