mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
.removeFromCrop(..) seems to be working -- needs more testing...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
e854c49741
commit
419ac81cb3
@ -1808,7 +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...
|
// XXX BUG? order does odd things...
|
||||||
addToCrop: ['- Crop/',
|
addToCrop: ['- Crop/',
|
||||||
core.doc`Add gids to current crop...
|
core.doc`Add gids to current crop...
|
||||||
|
|
||||||
@ -1868,20 +1868,25 @@ module.CropActions = actions.Actions({
|
|||||||
;(ribbon || reference || mode)
|
;(ribbon || reference || mode)
|
||||||
&& this.data.placeImage(gids, 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',
|
removeFromCrop: ['Crop|Image/Remove from crop',
|
||||||
core.doc`
|
core.doc`
|
||||||
`,
|
`,
|
||||||
{
|
{
|
||||||
browseMode: 'uncrop',
|
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){
|
getUndoState: function(d){
|
||||||
d.placements = (d.args[0] || [d.current])
|
d.placements = (d.args[0] instanceof Array ? d.args[0] : [d.args[0]]
|
||||||
.map(function(g){ return [ g, this.data.getRibbon(g) ] }.bind(this)) },
|
|| [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){
|
undo: function(d){
|
||||||
(d.placements || [])
|
(d.placements || [])
|
||||||
.forEach(function(e){
|
.forEach(function(e){
|
||||||
@ -1943,9 +1948,8 @@ module.CropActions = actions.Actions({
|
|||||||
var that = this
|
var that = this
|
||||||
gids = gids || this.current_ribbon
|
gids = gids || this.current_ribbon
|
||||||
gids = gids == 'current' ? this.current_ribbon : gids
|
gids = gids == 'current' ? this.current_ribbon : gids
|
||||||
gids = gids instanceof Array ?
|
gids = (gids instanceof Array ? gids : [gids])
|
||||||
gids.filter(function(gid){ return that.data.ribbons[gid] })
|
.filter(function(gid){ return that.data.ribbons[that.data.getRibbon(gid)] })
|
||||||
: [gids]
|
|
||||||
return this.removeFromCrop(gids)
|
return this.removeFromCrop(gids)
|
||||||
}],
|
}],
|
||||||
})
|
})
|
||||||
|
|||||||
@ -785,6 +785,8 @@ var CollectionActions = actions.Actions({
|
|||||||
// ...
|
// ...
|
||||||
// })
|
// })
|
||||||
// NOTE: see .ensureCollection(..) for more details...
|
// NOTE: see .ensureCollection(..) for more details...
|
||||||
|
//
|
||||||
|
// XXX undo: need to be able to place collected stuff...
|
||||||
collect: ['Collections|Image/Add $image to collection...',
|
collect: ['Collections|Image/Add $image to collection...',
|
||||||
core.doc`Add items to collection
|
core.doc`Add items to collection
|
||||||
|
|
||||||
@ -944,6 +946,11 @@ var CollectionActions = actions.Actions({
|
|||||||
}
|
}
|
||||||
}).bind(this))
|
}).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',
|
uncollect: ['Collections|Image/Remove from collection',
|
||||||
core.doc`Remove gid(s) 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.
|
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){
|
function(gids, collection){
|
||||||
collection = collection || this.collection
|
collection = collection || this.collection
|
||||||
collection = this.collectionGIDs[collection] || collection
|
collection = this.collectionGIDs[collection] || collection
|
||||||
|
|||||||
@ -648,7 +648,12 @@ var JournalActions = actions.Actions({
|
|||||||
// undoable
|
// undoable
|
||||||
// getUndoState
|
// getUndoState
|
||||||
// XXX should the action have control over what gets journaled and how???
|
// 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',
|
updateJournalableActions: ['System/Update list of journalable actions',
|
||||||
|
doc`
|
||||||
|
|
||||||
|
NOTE: action aliases can not handle undo.
|
||||||
|
`,
|
||||||
function(){
|
function(){
|
||||||
var that = this
|
var that = this
|
||||||
|
|
||||||
@ -687,8 +692,10 @@ var JournalActions = actions.Actions({
|
|||||||
|
|
||||||
this.journalable = this.actions
|
this.journalable = this.actions
|
||||||
.filter(function(action){
|
.filter(function(action){
|
||||||
return !!that.getActionAttr(action, 'undo')
|
// skip aliases...
|
||||||
|| !!that.getActionAttr(action, 'journal')
|
return !(that[action] instanceof actions.Alias)
|
||||||
|
&& (!!that.getActionAttr(action, 'undo')
|
||||||
|
|| !!that.getActionAttr(action, 'journal'))
|
||||||
})
|
})
|
||||||
// reset the handler
|
// reset the handler
|
||||||
.map(function(action){
|
.map(function(action){
|
||||||
@ -743,6 +750,9 @@ var JournalActions = actions.Actions({
|
|||||||
// 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???
|
// 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',
|
undo: ['Edit/Undo',
|
||||||
doc`Undo last action from .journal that can be undone
|
doc`Undo last action from .journal that can be undone
|
||||||
|
|
||||||
|
|||||||
@ -243,7 +243,7 @@ var ImageMarkActions = actions.Actions({
|
|||||||
|
|
||||||
removeMarkedFromCrop: ['Mark|Crop/Remove marked from crop',
|
removeMarkedFromCrop: ['Mark|Crop/Remove marked from crop',
|
||||||
{browseMode: function(target){
|
{browseMode: function(target){
|
||||||
return (this.marked.length == 0 || !this.cropped) && 'disabled' }},
|
return (this.marked.length == 0 || !this.cropped) && 'disabled' }},
|
||||||
'removeFromCrop: marked'],
|
'removeFromCrop: marked'],
|
||||||
|
|
||||||
rotateMarkedCW: ['Mark/Rotate marked clockwise',
|
rotateMarkedCW: ['Mark/Rotate marked clockwise',
|
||||||
|
|||||||
@ -1623,6 +1623,7 @@ var DataPrototype = {
|
|||||||
// - .getRibbon(..) compatible or 'keep'
|
// - .getRibbon(..) compatible or 'keep'
|
||||||
// - a new ribbon gid (appended to .ribbon_order)
|
// - a new ribbon gid (appended to .ribbon_order)
|
||||||
// - [gid, order] where gid will be placed at order in .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'.
|
// 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
|
||||||
@ -1650,16 +1651,21 @@ var DataPrototype = {
|
|||||||
|
|
||||||
// vertical shift -- gather images to the target ribbon...
|
// vertical shift -- gather images to the target ribbon...
|
||||||
if(ribbon != 'keep'){
|
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)
|
var to = this.getRibbon(ribbon)
|
||||||
|
|
||||||
// create ribbon...
|
// create ribbon...
|
||||||
if(to == null){
|
if(to == null){
|
||||||
var i = ribbon instanceof Array ? ribbon[1] : null
|
to = ribbon
|
||||||
to = ribbon instanceof Array ? ribbon[0] : ribbon
|
|
||||||
this.ribbons[to] = []
|
this.ribbons[to] = []
|
||||||
i == null ?
|
i == null ?
|
||||||
this.ribbon_order.push(to)
|
this.ribbon_order.push(to)
|
||||||
: this.ribbon_order.splice(i, 0, 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