mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-28 18:00:09 +00:00
making add/remove from crop equally expressive for undo...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
d28401a2ec
commit
e854c49741
@ -1808,6 +1808,7 @@ module.CropActions = actions.Actions({
|
|||||||
// ...add a way to store additional info in the journal...
|
// ...add a way to store additional info in the journal...
|
||||||
// XXX undo -- .removeFromCrop(..) but only the gids that were
|
// XXX undo -- .removeFromCrop(..) but only the gids that were
|
||||||
// actually added... (???)
|
// actually added... (???)
|
||||||
|
// XXX BUG order does odd things...
|
||||||
addToCrop: ['- Crop/',
|
addToCrop: ['- Crop/',
|
||||||
core.doc`Add gids to current crop...
|
core.doc`Add gids to current crop...
|
||||||
|
|
||||||
@ -1873,14 +1874,18 @@ module.CropActions = actions.Actions({
|
|||||||
`,
|
`,
|
||||||
{
|
{
|
||||||
browseMode: 'uncrop',
|
browseMode: 'uncrop',
|
||||||
// XXX group gid - ribbon
|
// XXX these does not account for:
|
||||||
//getUndoState: function(data){ },
|
// - ribbon_order
|
||||||
// XXX this does not account for:
|
|
||||||
// - location (order, ribbon, ribbon order) of removed images
|
|
||||||
// ...ribbon order is important when a ribbon got cleared...
|
// ...ribbon order is important when a ribbon got cleared...
|
||||||
// - keyword and ribbon gids
|
// - keyword and ribbon gids
|
||||||
//undo: function(d){
|
// XXX group gid - ribbon
|
||||||
// this.addToCrop(d.args.length > 0 ? d.args : d.current) },
|
getUndoState: function(d){
|
||||||
|
d.placements = (d.args[0] || [d.current])
|
||||||
|
.map(function(g){ return [ g, this.data.getRibbon(g) ] }.bind(this)) },
|
||||||
|
undo: function(d){
|
||||||
|
(d.placements || [])
|
||||||
|
.forEach(function(e){
|
||||||
|
this.addToCrop(e[0], e[1], 'keep') }.bind(this)) },
|
||||||
},
|
},
|
||||||
function(gids){
|
function(gids){
|
||||||
var that = this
|
var that = this
|
||||||
@ -1933,7 +1938,7 @@ module.CropActions = actions.Actions({
|
|||||||
|
|
||||||
NOTE: this is a shorthand for .removeFromCrop(..) but only supports
|
NOTE: this is a shorthand for .removeFromCrop(..) but only supports
|
||||||
ribbon removal.`,
|
ribbon removal.`,
|
||||||
{browseMode: 'uncrop'},
|
{browseMode: 'uncrop',},
|
||||||
function(gids){
|
function(gids){
|
||||||
var that = this
|
var that = this
|
||||||
gids = gids || this.current_ribbon
|
gids = gids || this.current_ribbon
|
||||||
|
|||||||
@ -1619,7 +1619,10 @@ var DataPrototype = {
|
|||||||
// -> data
|
// -> data
|
||||||
//
|
//
|
||||||
// images is .getImage(..) compatible or a list of compatibles.
|
// images is .getImage(..) compatible or a list of compatibles.
|
||||||
// ribbon is .getRibbon(..) compatible or 'keep'.
|
// ribbon is:
|
||||||
|
// - .getRibbon(..) compatible or 'keep'
|
||||||
|
// - a new ribbon gid (appended to .ribbon_order)
|
||||||
|
// - [gid, order] where gid will be placed at order in .ribbon_order
|
||||||
// order is .getImageOrder(..) compatible or 'keep'.
|
// order is .getImageOrder(..) compatible or 'keep'.
|
||||||
//
|
//
|
||||||
// This will not change the relative order of input images unless
|
// This will not change the relative order of input images unless
|
||||||
@ -1648,6 +1651,15 @@ var DataPrototype = {
|
|||||||
// vertical shift -- gather images to the target ribbon...
|
// vertical shift -- gather images to the target ribbon...
|
||||||
if(ribbon != 'keep'){
|
if(ribbon != 'keep'){
|
||||||
var to = this.getRibbon(ribbon)
|
var to = this.getRibbon(ribbon)
|
||||||
|
// create ribbon...
|
||||||
|
if(to == null){
|
||||||
|
var i = ribbon instanceof Array ? ribbon[1] : null
|
||||||
|
to = ribbon instanceof Array ? ribbon[0] : ribbon
|
||||||
|
this.ribbons[to] = []
|
||||||
|
i == null ?
|
||||||
|
this.ribbon_order.push(to)
|
||||||
|
: this.ribbon_order.splice(i, 0, to)
|
||||||
|
}
|
||||||
this.makeSparseImages(images)
|
this.makeSparseImages(images)
|
||||||
.forEach(function(img, f){
|
.forEach(function(img, f){
|
||||||
var from = that.getRibbon(img)
|
var from = that.getRibbon(img)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user