From 9892d26b0a582c4e262ac5e9a5c1fa3ad86634ca Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Tue, 28 Jan 2014 06:56:26 +0400 Subject: [PATCH] fixed several bugs... Signed-off-by: Alex A. Naanou --- ui/TODO.otl | 8 +++++--- ui/bookmarks.js | 4 ++-- ui/data.js | 7 ++++++- ui/marks.js | 34 ++++++++++++++++++++++------------ ui/sort.js | 7 +++++-- 5 files changed, 40 insertions(+), 20 deletions(-) diff --git a/ui/TODO.otl b/ui/TODO.otl index 14f3b824..643a2939 100755 --- a/ui/TODO.otl +++ b/ui/TODO.otl @@ -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 diff --git a/ui/bookmarks.js b/ui/bookmarks.js index c9b5a70a..7d90fbf7 100755 --- a/ui/bookmarks.js +++ b/ui/bookmarks.js @@ -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() } }) diff --git a/ui/data.js b/ui/data.js index 631750e6..7a98b625 100755 --- a/ui/data.js +++ b/ui/data.js @@ -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) } } diff --git a/ui/marks.js b/ui/marks.js index 3c8fba32..2c0e1573 100755 --- a/ui/marks.js +++ b/ui/marks.js @@ -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() } }) diff --git a/ui/sort.js b/ui/sort.js index ac785d2f..00503855 100755 --- a/ui/sort.js +++ b/ui/sort.js @@ -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 }