fixed several bugs...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2014-01-28 06:56:26 +04:00
parent 5888442b71
commit 9892d26b0a
5 changed files with 40 additions and 20 deletions

View File

@ -109,8 +109,9 @@ Roadmap
[_] 32% Gen 3 current todo
[_] 64% High priority
[_] BUG: sorting (dialog) will mess up the order...
[_] 65% High priority
[_] make buildcache sort images via data AND file name...
[X] BUG: sorting (dialog) will mess up the order...
| Procedure:
| - shift-s + sort in a way that changes the order
| - move next till the spot where the order changed
@ -123,7 +124,7 @@ Roadmap
| Workaround:
| - sort, save, then F5
|
[_] BUG: sorting breaks when at or near the end of a ribbon...
[X] BUG: sorting breaks when at or near the end of a ribbon...
|
| Race condition...
|
@ -560,6 +561,7 @@ Roadmap
| drops to last placeholder
|
[_] single image mode transition (alpha-blend/fade/none)
[X] BUG: shifting image left/right marks and bookmarks it...
[X] Might be a good idea to use sparse arrays for things like marks...
| eliminate:
| - need for keeping things sorted all the time

View File

@ -175,8 +175,8 @@ function setupBookmarks(viewer){
BOOKMARKS = populateSparceGIDList(BOOKMARKS)
bookmarksUpdated()
})
.on('horizontalShiftedImage', function(evt, gid, direction){
if(shiftGIDInSparseList(gid, BOOKMARKS)){
.on('horizontalShiftedImage', function(evt, gid, direction, from, to){
if(shiftGIDInSparseList(gid, from, to, BOOKMARKS)){
bookmarksUpdated()
}
})

View File

@ -2181,6 +2181,8 @@ function updateImages(list, size, cmp){
//
// This is similar to getGIDsAround(..) but will load images into the
// viewer...
//
// XXX make a smarter common section handling...
function loadImagesAround(count, gid, ribbon, data, force_count, ignore_common_sections){
// default values...
data = data == null ? DATA : data
@ -2320,6 +2322,9 @@ function rollImages(n, ribbon, extend, no_compensate_shift){
// structure and do a fast reload
// NOTE: if the order of images has changed, reuse_current_structure must
// be null or false, otherwise this will not produce a correct result.
//
// XXX reuse_current_structure will not work correctly until loadImagesAround(..)
// ignores section content...
function reloadViewer(reuse_current_structure, images_per_screen){
var ribbons_set = $('.ribbon-set')
var current = DATA.current
@ -2413,7 +2418,7 @@ function updateRibbonOrder(no_reload_viewer){
DATA.ribbons[i] = fastSortGIDsByOrder(DATA.ribbons[i])
}
if(!no_reload_viewer){
reloadViewer(true)
reloadViewer(false)
}
}

View File

@ -279,21 +279,31 @@ function shiftGIDToOrderInList(gid, direction, list){
}
return false
}
// a sparse version of shiftGIDToOrderInList(..)...
function shiftGIDInSparseList(gid, list){
var n = DATA.order.indexOf(gid)
var o = list.indexOf(gid)
//
// returns true if list is updated....
function shiftGIDInSparseList(gid, from, to, list){
if(list[from] == null && list[to] == null){
return false
}
var cleanup = list.indexOf(gid) < 0
// move the marked gid...
list.splice(o, 1)
list.splice(n, 0, gid)
list.splice(from, 1)
list.splice(to, 0, gid)
// test if there are any marked images between n and o...
var shift = compactSparceList(list.slice(Math.min(n, o)+1, Math.max(n, o)))
if(shift.length > 0){
return true
// if gid was never in list, we must remove leave things as we got
// them, and remove it again...
// NOTE: essentially, we are using gid as a marker, as we can't
// .splice(..) an undefined into a list...
if(cleanup){
delete list[to]
}
return false
return true
}
@ -787,8 +797,8 @@ function setupMarks(viewer){
MARKED = populateSparceGIDList(MARKED)
marksUpdated()
})
.on('horizontalShiftedImage', function(evt, gid, direction){
if(shiftGIDInSparseList(gid, MARKED)){
.on('horizontalShiftedImage', function(evt, gid, direction, from, to){
if(shiftGIDInSparseList(gid, from, to, MARKED)){
marksUpdated()
}
})

View File

@ -360,9 +360,12 @@ function horizontalShiftImage(image, direction){
// NOTE: in a race condition this may still overwrite the order someone
// else is working on, the data will be consistent...
var order = DATA.order.slice()
order.splice(order.indexOf(gid), 1)
var from = order.indexOf(gid)
order.splice(from, 1)
order.splice(order.indexOf(target) + (direction == 'next'? 1 : 0), 0, gid)
var to = order.indexOf(gid)
// do the dirty work...
// ...replace the order with the new order...
DATA.order.splice.apply(DATA.order, [0, DATA.order.length].concat(order))
// just update the ribbons, no reloading needed...
@ -375,7 +378,7 @@ function horizontalShiftImage(image, direction){
updateImages()
dataUpdated()
$('.viewer').trigger('horizontalShiftedImage', [gid, direction])
$('.viewer').trigger('horizontalShiftedImage', [gid, direction, from, to])
return image
}