.removeFromCrop(..) seems to be working -- needs more testing...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-12-28 06:15:16 +03:00
parent e854c49741
commit 419ac81cb3
5 changed files with 51 additions and 18 deletions

View File

@ -1808,7 +1808,7 @@ module.CropActions = actions.Actions({
// ...add a way to store additional info in the journal...
// XXX undo -- .removeFromCrop(..) but only the gids that were
// actually added... (???)
// XXX BUG order does odd things...
// XXX BUG? order does odd things...
addToCrop: ['- Crop/',
core.doc`Add gids to current crop...
@ -1868,20 +1868,25 @@ module.CropActions = actions.Actions({
;(ribbon || reference || mode)
&& this.data.placeImage(gids, ribbon, reference, mode)
}],
// XXX undo -- need containing ribbon info per gid to undo correctly...
removeFromCrop: ['Crop|Image/Remove from crop',
core.doc`
`,
{
browseMode: 'uncrop',
// XXX these does not account for:
// - ribbon_order
// ...ribbon order is important when a ribbon got cleared...
// - keyword and ribbon gids
// XXX group gid - ribbon
getUndoState: function(d){
d.placements = (d.args[0] || [d.current])
.map(function(g){ return [ g, this.data.getRibbon(g) ] }.bind(this)) },
d.placements = (d.args[0] instanceof Array ? d.args[0] : [d.args[0]]
|| [d.current])
.map(function(g){ return [
g == null ?
d.current
// get the images...
// NOTE: we store the list if gids and not the
// ribbon as when undoing we have no info
// on ribbon content...
: this.data.ribbons[g] ? this.data.getImages(g) : g,
// get ribbon and ribbon order...
[this.data.getRibbon(g), this.data.getRibbonOrder(g)],
] }.bind(this)) },
undo: function(d){
(d.placements || [])
.forEach(function(e){
@ -1943,9 +1948,8 @@ module.CropActions = actions.Actions({
var that = this
gids = gids || this.current_ribbon
gids = gids == 'current' ? this.current_ribbon : gids
gids = gids instanceof Array ?
gids.filter(function(gid){ return that.data.ribbons[gid] })
: [gids]
gids = (gids instanceof Array ? gids : [gids])
.filter(function(gid){ return that.data.ribbons[that.data.getRibbon(gid)] })
return this.removeFromCrop(gids)
}],
})

View File

@ -785,6 +785,8 @@ var CollectionActions = actions.Actions({
// ...
// })
// NOTE: see .ensureCollection(..) for more details...
//
// XXX undo: need to be able to place collected stuff...
collect: ['Collections|Image/Add $image to collection...',
core.doc`Add items to collection
@ -944,6 +946,11 @@ var CollectionActions = actions.Actions({
}
}).bind(this))
}],
// XXX undo: see .removeFromCrop(..) for a reference implementation...
// this will need:
// - .collect(..) to be able to place images...
// - also store image order as .data.order is cleared of
// removed images...
uncollect: ['Collections|Image/Remove from collection',
core.doc`Remove gid(s) from collection...
@ -965,7 +972,13 @@ var CollectionActions = actions.Actions({
NOTE: this will remove any gid, be it image or ribbon.
`,
{browseMode: function(){ return !this.collection && 'disabled' }},
{
browseMode: function(){ return !this.collection && 'disabled' }
/* XXX
getUndoState: function(d){},
undo: function(d){},
//*/
},
function(gids, collection){
collection = collection || this.collection
collection = this.collectionGIDs[collection] || collection

View File

@ -648,7 +648,12 @@ var JournalActions = actions.Actions({
// undoable
// getUndoState
// XXX should the action have control over what gets journaled and how???
// XXX should aliases support explicit undo???
updateJournalableActions: ['System/Update list of journalable actions',
doc`
NOTE: action aliases can not handle undo.
`,
function(){
var that = this
@ -687,8 +692,10 @@ var JournalActions = actions.Actions({
this.journalable = this.actions
.filter(function(action){
return !!that.getActionAttr(action, 'undo')
|| !!that.getActionAttr(action, 'journal')
// skip aliases...
return !(that[action] instanceof actions.Alias)
&& (!!that.getActionAttr(action, 'undo')
|| !!that.getActionAttr(action, 'journal'))
})
// reset the handler
.map(function(action){
@ -743,6 +750,9 @@ var JournalActions = actions.Actions({
// journal/rjournal or should we clean them out???
// (currently cleaned)
// XXX should we control what gets pushed to the journal???
// XXX should we run undo of every action that supports it in the chain???
// ...i.e. multiple extending actions can support undo
// XXX will also need to handle aliases in chain...
undo: ['Edit/Undo',
doc`Undo last action from .journal that can be undone

View File

@ -243,7 +243,7 @@ var ImageMarkActions = actions.Actions({
removeMarkedFromCrop: ['Mark|Crop/Remove marked from crop',
{browseMode: function(target){
return (this.marked.length == 0 || !this.cropped) && 'disabled' }},
return (this.marked.length == 0 || !this.cropped) && 'disabled' }},
'removeFromCrop: marked'],
rotateMarkedCW: ['Mark/Rotate marked clockwise',

View File

@ -1623,6 +1623,7 @@ var DataPrototype = {
// - .getRibbon(..) compatible or 'keep'
// - a new ribbon gid (appended to .ribbon_order)
// - [gid, order] where gid will be placed at order in .ribbon_order
// NOTE: order is only used if ribbon is not present in .ribbon_order
// order is .getImageOrder(..) compatible or 'keep'.
//
// This will not change the relative order of input images unless
@ -1650,16 +1651,21 @@ var DataPrototype = {
// vertical shift -- gather images to the target ribbon...
if(ribbon != 'keep'){
// handle [ribbon, order] format...
var i = ribbon instanceof Array ? ribbon[1] : null
ribbon = ribbon instanceof Array ? ribbon[0] : 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
to = ribbon
this.ribbons[to] = []
i == null ?
this.ribbon_order.push(to)
: this.ribbon_order.splice(i, 0, to)
}
this.makeSparseImages(images)
.forEach(function(img, f){
var from = that.getRibbon(img)