rewritten part of the crop mechanics...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2019-10-23 16:12:53 +03:00
parent 73ce4f4a30
commit 568757f9f1

View File

@ -38,6 +38,21 @@ var widgets = require('features/ui-widgets')
// //
// //
var VirtualBlocksActions = actions.Actions({ var VirtualBlocksActions = actions.Actions({
// XXX do we need to pre-cache this???
get virtual(){
var that = this
return this.data.order
.filter(function(gid){
img = that.images[gid] || {}
return img.type == 'virtual' }) },
get nonVirtual(){
var that = this
return this.data.order
.filter(function(gid){
img = that.images[gid] || {}
return img.type != 'virtual' }) },
// construction of new "virtual images"... // construction of new "virtual images"...
// //
// XXX add undo... // XXX add undo...
@ -154,29 +169,26 @@ var VirtualBlocksActions = actions.Actions({
this.makeVirtualBlock(ref, offset, img) }], this.makeVirtualBlock(ref, offset, img) }],
// crop... // crop...
cropVirtualBlocks: ['Virtual block|Crop/Crop virtual blocks', cropVirtualBlocks: ['Virtual block|Crop/$Crop $virtual blocks',
core.doc`Crop virtual blocks... core.doc`Crop virtual blocks...
Crop virtual blocks... Crop (keep) virtual blocks...
.cropVirtualBlocks() .cropVirtualBlocks()
.cropVirtualBlocks('keep') .cropVirtualBlocks('keep')
-> this -> this
Crop virtiual bloks out... Crop virtual bloks out...
.cropVirtualBlocks('skip') .cropVirtualBlocks('skip')
-> this -> this
`, `,
{ browseMode: 'makeVirtualBlock' }, { browseMode: 'makeVirtualBlock' },
function(mode){ function(mode){
var that = this
mode = mode || 'keep' mode = mode || 'keep'
return this.crop(this.data.order return this.crop(
.filter(function(gid){ mode == 'keep' ?
img = that.images[gid] || {} this.virtual
return mode == 'keep' ? : this.nonVirtual) }],
img.type == 'virtual'
: img.type != 'virtual' })) }],
cropVirtualBlocksOut: ['Virtual block|Crop/Crop virtual blocks out', cropVirtualBlocksOut: ['Virtual block|Crop/Crop virtual blocks out',
{ browseMode: 'cropVirtualBlocks' }, { browseMode: 'cropVirtualBlocks' },
'cropVirtualBlocks: "skip"'], 'cropVirtualBlocks: "skip"'],