mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-28 18:00:09 +00:00
added .cropOutRibbon(..) + some tweaking...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
220939454b
commit
8fe6e46c94
@ -1040,7 +1040,7 @@ module.CropActions = actions.Actions({
|
||||
// XXX not sure if we actually need this...
|
||||
cropFlatten: ['Crop/Flatten',
|
||||
function(list){ this.data.length > 0 && this.crop(list, true) }],
|
||||
cropRibbon: ['Crop/Crop current ribbon',
|
||||
cropRibbon: ['Crop/Crop ribbon',
|
||||
function(ribbon, flatten){
|
||||
if(this.data.length == 0){
|
||||
return
|
||||
@ -1052,7 +1052,38 @@ module.CropActions = actions.Actions({
|
||||
ribbon = ribbon || 'current'
|
||||
this.crop(this.data.getImages(ribbon), flatten)
|
||||
}],
|
||||
cropRibbonAndAbove: ['Crop/Crop out ribbons bellow',
|
||||
cropOutRibbon: ['Crop/Crop ribbon out',
|
||||
function(ribbon, flatten){
|
||||
ribbon = ribbon || this.current_ribbon
|
||||
ribbon = ribbon instanceof Array ? ribbon : [ribbon]
|
||||
|
||||
// build the crop...
|
||||
var crop = this.data.crop()
|
||||
|
||||
// ribbon order...
|
||||
crop.ribbon_order = crop.ribbon_order
|
||||
.filter(function(r){ return ribbon.indexOf(r) })
|
||||
|
||||
// ribbons...
|
||||
ribbon.forEach(function(r){ delete crop.ribbons[r] })
|
||||
|
||||
// focus image...
|
||||
var cr = this.current_ribbon
|
||||
if(ribbon.indexOf(cr) >= 0){
|
||||
var i = this.data.getRibbonOrder(cr)
|
||||
var r = this.data.ribbon_order
|
||||
.slice(i+1)
|
||||
.concat(this.data.ribbon_order.slice(0, i))
|
||||
.filter(function(r){ return crop.ribbons[r] && crop.ribbons[r].len > 0 })
|
||||
.shift()
|
||||
crop.focusImage(
|
||||
crop.getImage(this.current, 'after', r)
|
||||
|| crop.getImage(this.current, 'before', r))
|
||||
}
|
||||
|
||||
this.crop(crop, flatten)
|
||||
}],
|
||||
cropOutRibbonsBelow: ['Crop/Crop out ribbons bellow',
|
||||
function(ribbon, flatten){
|
||||
if(this.data.length == 0){
|
||||
return
|
||||
|
||||
@ -14,10 +14,10 @@
|
||||
*
|
||||
*
|
||||
* Features:
|
||||
* - introspection
|
||||
* - lifecycle
|
||||
* base life-cycle events (start/stop/..)
|
||||
* - util
|
||||
* - introspection
|
||||
* - journal
|
||||
* action journaling and undo/redo functionality
|
||||
* XXX needs revision...
|
||||
@ -400,7 +400,7 @@ var LifeCycleActions = actions.Actions({
|
||||
// System ready event...
|
||||
//
|
||||
// Not intended for direct use, use .declareReady() to initiate.
|
||||
this.logger && this.logger.emit('start')
|
||||
this.logger && this.logger.emit('ready')
|
||||
})],
|
||||
// NOTE: this calls .ready() once per session.
|
||||
declareReady: ['- System/Declare system ready',
|
||||
@ -418,8 +418,6 @@ var LifeCycleActions = actions.Actions({
|
||||
function(){
|
||||
return this.__ready_announce_requested = (this.__ready_announce_requested || 0) + 1
|
||||
}],
|
||||
|
||||
// unbind events...
|
||||
stop: ['- System/',
|
||||
function(){
|
||||
// browser & nw...
|
||||
|
||||
@ -331,7 +331,8 @@ module.GLOBAL_KEYBOARD = {
|
||||
|
||||
// cropping...
|
||||
F2: 'cropRibbon',
|
||||
shift_F2: 'cropRibbonAndAbove',
|
||||
D: 'cropOutRibbon',
|
||||
shift_F2: 'cropOutRibbonsBelow',
|
||||
ctrl_F2: 'cropMarked',
|
||||
alt_F2: 'cropBookmarked',
|
||||
C: 'browseActions: "/Crop/" -- Crop menu...',
|
||||
|
||||
@ -2306,18 +2306,29 @@ var DataPrototype = {
|
||||
// NOTE: this will not crop the .order...
|
||||
crop: function(list, flatten){
|
||||
var crop = this.clone()
|
||||
list = crop.makeSparseImages(list)
|
||||
list = list == null || list == '*' ?
|
||||
'*'
|
||||
: crop.makeSparseImages(list)
|
||||
|
||||
if(!flatten){
|
||||
if(list == '*'){
|
||||
return crop
|
||||
}
|
||||
// place images in ribbons...
|
||||
for(var k in crop.ribbons){
|
||||
crop.ribbons[k] = crop.makeSparseImages(crop.ribbons[k].filter(function(_, i){
|
||||
return list[i] != null
|
||||
}))
|
||||
crop.ribbons[k] = crop.makeSparseImages(
|
||||
crop.ribbons[k]
|
||||
.filter(function(_, i){ return list[i] != null }))
|
||||
}
|
||||
|
||||
// flatten the crop...
|
||||
} else {
|
||||
list = list == '*' ?
|
||||
crop.makeSparseImages(
|
||||
crop.ribbon_order
|
||||
.map(function(r){ return crop.ribbons[r] })
|
||||
.reduce(function(a, b){ return a.concat(b) }, []))
|
||||
: list
|
||||
crop.ribbons = {}
|
||||
crop.ribbon_order = []
|
||||
crop.ribbons[crop.newRibbon()] = list
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user