added .addToCrop(..)...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-12-01 20:59:58 +03:00
parent 6b752b099e
commit b6817b7e3b
4 changed files with 74 additions and 3 deletions

View File

@ -1801,11 +1801,69 @@ module.CropActions = actions.Actions({
// XXX do we need this??? // XXX do we need this???
// XXX add gids to crop (current by default)... // XXX add gids to crop (current by default)...
// XXX use this as undo for .removeFromCrop(..) // XXX use this as undo for .removeFromCrop(..)
// ...after we remove images from a crop we lose their containing
// ribbon information and the order might get messed up by
// horizontal shifting if not undone correctly...
addToCrop: ['- Crop/', addToCrop: ['- Crop/',
function(list, index){ core.doc`Add gids to current crop...
// XXX
Place images to their positions in order in current ribbon
.addToCrop(images)
.addToCrop(images, 'keep', 'keep')
-> this
Place images at order into ribbon...
.addToCrop(images, ribbon, order)
-> this
As above but place images before/after order...
.addToCrop(images, ribbon, order, 'before')
.addToCrop(images, ribbon, order, 'after')
-> this
Place images at order but do not touch ribbon position... (horizontal)
.addToCrop(images, 'keep', order)
-> this
As above but place images before/after order...
.addToCrop(images, 'keep', order, 'before')
.addToCrop(images, 'keep', order, 'after')
-> this
Place images to ribbon but do not touch order... (vertical)
.addToCrop(images, ribbon, 'keep')
-> this
NOTE: this is signature-compatible with .data.placeImage(..) but
different in that it does not require the images to be loaded
in the current crop...
NOTE: this can only add gids to current crop...
`,
function(gids, ribbon, reference, mode){
if(!this.cropped){
return
}
gids = gids instanceof Array ? gids : [gids]
var r = this.data.ribbons[this.current_ribbon]
var o = this.data.order
// add gids to current ribbon...
gids.forEach(function(gid){
var i = o.indexOf(gid)
if(i >= 0){
r[i] = gid
}
})
// place...
;(ribbon || reference || mode)
&& this.data.placeImage(gids, ribbon, reference, mode)
}], }],
// XXX undo... // XXX undo -- need containing ribbon info per gid to undo correctly...
removeFromCrop: ['Crop|Image/Remove from crop', removeFromCrop: ['Crop|Image/Remove from crop',
{browseMode: 'uncrop'}, {browseMode: 'uncrop'},
function(gids){ function(gids){

View File

@ -638,6 +638,7 @@ var JournalActions = actions.Actions({
journalable: null, journalable: null,
// XXX should the action have control over what gets journaled and how???
updateJournalableActions: ['System/Update list of journalable actions', updateJournalableActions: ['System/Update list of journalable actions',
function(){ function(){
var that = this var that = this
@ -726,6 +727,7 @@ var JournalActions = actions.Actions({
// - should the undo action have side-effects on the // - should the undo action have side-effects on the
// journal/rjournal or should we clean them out??? // journal/rjournal or should we clean them out???
// (currently cleaned) // (currently cleaned)
// XXX should we control what gets pushed to the journal???
undo: ['Edit/Undo', undo: ['Edit/Undo',
doc`Undo last action from .journal that can be undone doc`Undo last action from .journal that can be undone

View File

@ -561,6 +561,7 @@ core.ImageGridFeatures.Feature({
'collapseGroup', 'collapseGroup',
'crop', 'crop',
'uncrop', 'uncrop',
'addToCrop',
'removeFromCrop', 'removeFromCrop',
'reverseImages', 'reverseImages',
], ],

View File

@ -1585,10 +1585,20 @@ var DataPrototype = {
// .placeImage(images, ribbon, order) // .placeImage(images, ribbon, order)
// -> data // -> data
// //
// As above but add before/after order...
// .placeImage(images, ribbon, order, 'before')
// .placeImage(images, ribbon, order, 'after')
// -> data
//
// Place images at order but do not touch ribbon position... (horizontal) // Place images at order but do not touch ribbon position... (horizontal)
// .placeImage(images, 'keep', order) // .placeImage(images, 'keep', order)
// -> data // -> data
// //
// As above but add before/after order...
// .placeImage(images, 'keep', order, 'before')
// .placeImage(images, 'keep', order, 'after')
// -> data
//
// Place images to ribbon but do not touch order... (vertical) // Place images to ribbon but do not touch order... (vertical)
// .placeImage(images, ribbon, 'keep') // .placeImage(images, ribbon, 'keep')
// -> data // -> data