mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-12-17 00:31:40 +00:00
enabled intersecting ribbon crop modes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
40349ac968
commit
995e279927
26
ui/crop.js
26
ui/crop.js
@ -28,9 +28,13 @@ function getAllData(){
|
|||||||
|
|
||||||
// NOTE: this will not update .current state...
|
// NOTE: this will not update .current state...
|
||||||
// NOTE: when keep_ribbons is set, this may generate empty ribbons...
|
// NOTE: when keep_ribbons is set, this may generate empty ribbons...
|
||||||
|
// NOTE: this requieres all data to be present, if currently viewing
|
||||||
|
// server-side data, then cropping is a server-side operation...
|
||||||
|
// XXX another way to go here is to save the crop method and take
|
||||||
|
// it into account when loading new sections of data...
|
||||||
//
|
//
|
||||||
// XXX should this set the .current to anything but null or the first elem???
|
// XXX should this set the .current to anything but null or the first elem???
|
||||||
function makeCroppedData(gids, keep_ribbons){
|
function makeCroppedData(gids, keep_ribbons, keep_unloaded_gids){
|
||||||
var res = {
|
var res = {
|
||||||
varsion: '2.0',
|
varsion: '2.0',
|
||||||
current: null,
|
current: null,
|
||||||
@ -38,6 +42,18 @@ function makeCroppedData(gids, keep_ribbons){
|
|||||||
order: DATA.order.slice(),
|
order: DATA.order.slice(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// remove any gid that is not in IMAGES or is not loaded...
|
||||||
|
if(!keep_unloaded_gids){
|
||||||
|
var loaded = []
|
||||||
|
$.each(DATA.ribbons, function(i, e){ loaded = loaded.concat(e) })
|
||||||
|
|
||||||
|
// NOTE: if IMAGES contains only part of the data loadable this will
|
||||||
|
// be wrong...
|
||||||
|
gids = gids.filter(function(e){
|
||||||
|
return e in IMAGES && loaded.indexOf(e) >= 0
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// flat single ribbon crop...
|
// flat single ribbon crop...
|
||||||
if(!keep_ribbons){
|
if(!keep_ribbons){
|
||||||
res.ribbons[0] = gids
|
res.ribbons[0] = gids
|
||||||
@ -59,12 +75,12 @@ function makeCroppedData(gids, keep_ribbons){
|
|||||||
|
|
||||||
// NOTE: if keep_ribbons is not set this will ALWAYS build a single ribbon
|
// NOTE: if keep_ribbons is not set this will ALWAYS build a single ribbon
|
||||||
// data-set...
|
// data-set...
|
||||||
function cropDataTo(gids, keep_ribbons){
|
function cropDataTo(gids, keep_ribbons, keep_unloaded_gids){
|
||||||
var prev_state = DATA
|
var prev_state = DATA
|
||||||
var cur = DATA.current
|
var cur = DATA.current
|
||||||
var r = getRibbonIndex()
|
var r = getRibbonIndex()
|
||||||
|
|
||||||
var new_data = makeCroppedData(gids, keep_ribbons)
|
var new_data = makeCroppedData(gids, keep_ribbons, keep_unloaded_gids)
|
||||||
|
|
||||||
// do nothing if there is no change...
|
// do nothing if there is no change...
|
||||||
// XXX is there a better way to compare states???
|
// XXX is there a better way to compare states???
|
||||||
@ -139,11 +155,14 @@ function showAllData(){
|
|||||||
// uncropLastState(...)
|
// uncropLastState(...)
|
||||||
// NOTE: crop modes are exclusive -- it is not possible to enter one crop
|
// NOTE: crop modes are exclusive -- it is not possible to enter one crop
|
||||||
// mode from a different crop mode
|
// mode from a different crop mode
|
||||||
|
//
|
||||||
|
// XXX add "exclusive" crop option -- prevent other crop modes to enter...
|
||||||
function makeCropModeToggler(cls, crop){
|
function makeCropModeToggler(cls, crop){
|
||||||
var res = createCSSClassToggler(
|
var res = createCSSClassToggler(
|
||||||
'.viewer',
|
'.viewer',
|
||||||
//cls + ' cropped-mode',
|
//cls + ' cropped-mode',
|
||||||
cls,
|
cls,
|
||||||
|
/* XXX make this an option...
|
||||||
function(action){
|
function(action){
|
||||||
// prevent mixing marked-only and single-ribbon modes...
|
// prevent mixing marked-only and single-ribbon modes...
|
||||||
if(action == 'on'
|
if(action == 'on'
|
||||||
@ -152,6 +171,7 @@ function makeCropModeToggler(cls, crop){
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
*/
|
||||||
function(action){
|
function(action){
|
||||||
if(action == 'on'){
|
if(action == 'on'){
|
||||||
showStatusQ('Cropping current ribbon...')
|
showStatusQ('Cropping current ribbon...')
|
||||||
|
|||||||
24
ui/marks.js
24
ui/marks.js
@ -16,25 +16,12 @@
|
|||||||
// NOTE: MARKED may contain both gids that are not loaded and that do
|
// NOTE: MARKED may contain both gids that are not loaded and that do
|
||||||
// not exist, as there is no way to distinguish between the two
|
// not exist, as there is no way to distinguish between the two
|
||||||
// situations the cleanup is optional...
|
// situations the cleanup is optional...
|
||||||
function cropMarkedImages(cmp, no_cleanout_marks){
|
function cropMarkedImages(cmp, keep_ribbons, no_cleanout_marks){
|
||||||
cmp = cmp == null ? imageOrderCmp : cmp
|
cmp = cmp == null ? imageOrderCmp : cmp
|
||||||
var cur = DATA.current
|
var cur = DATA.current
|
||||||
var marked = MARKED.slice().sort(cmp)
|
var marked = MARKED.slice().sort(cmp)
|
||||||
|
|
||||||
if(!no_cleanout_marks){
|
cropDataTo(marked, keep_ribbons, no_cleanout_marks)
|
||||||
// build all loaded images cache...
|
|
||||||
var loaded = []
|
|
||||||
$.each(DATA.ribbons, function(i, e){ loaded = loaded.concat(e) })
|
|
||||||
|
|
||||||
// ignore any gid in marks that is not in IMAGES...
|
|
||||||
// NOTE: if IMAGES contains only part of the data loadable this will
|
|
||||||
// be wrong...
|
|
||||||
var marked = marked.filter(function(e){
|
|
||||||
return e in IMAGES && loaded.indexOf(e) >= 0
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
cropDataTo(marked)
|
|
||||||
|
|
||||||
return DATA
|
return DATA
|
||||||
}
|
}
|
||||||
@ -51,6 +38,13 @@ var toggleMarkedOnlyView = makeCropModeToggler(
|
|||||||
cropMarkedImages)
|
cropMarkedImages)
|
||||||
|
|
||||||
|
|
||||||
|
var toggleMarkedOnlyWithRibbonsView = makeCropModeToggler(
|
||||||
|
'marked-only-view',
|
||||||
|
function(){
|
||||||
|
cropMarkedImages(null, true)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
// XXX shifting images and unmarking in this mode do not work correctly...
|
// XXX shifting images and unmarking in this mode do not work correctly...
|
||||||
var toggleMarkesView = createCSSClassToggler(
|
var toggleMarkesView = createCSSClassToggler(
|
||||||
'.viewer',
|
'.viewer',
|
||||||
|
|||||||
18
ui/modes.js
18
ui/modes.js
@ -180,6 +180,24 @@ var toggleSingleRibbonMode = makeCropModeToggler(
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
var toggleCurrenAndAboveRibbonsMode = makeCropModeToggler(
|
||||||
|
'current-and-above-ribbons-mode',
|
||||||
|
function(){
|
||||||
|
var gids = []
|
||||||
|
var c = getRibbonIndex()
|
||||||
|
var ribbons = DATA.ribbons
|
||||||
|
|
||||||
|
// merge the ribbons...
|
||||||
|
for(var i=0; i <= c; i++){
|
||||||
|
gids = gids.concat(ribbons[i])
|
||||||
|
}
|
||||||
|
gids.sort(imageOrderCmp)
|
||||||
|
|
||||||
|
// do the crop...
|
||||||
|
cropDataTo(gids)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
// TODO transitions...
|
// TODO transitions...
|
||||||
// TODO a real setup UI (instead of prompt)
|
// TODO a real setup UI (instead of prompt)
|
||||||
var toggleSlideShowMode = createCSSClassToggler(
|
var toggleSlideShowMode = createCSSClassToggler(
|
||||||
|
|||||||
13
ui/ui.js
13
ui/ui.js
@ -1055,15 +1055,11 @@ function cropImagesDialog(){
|
|||||||
updateStatus('Crop...').show()
|
updateStatus('Crop...').show()
|
||||||
|
|
||||||
var alg = 'Crop:|'+
|
var alg = 'Crop:|'+
|
||||||
'Use Esc and Shift-Esc to exit crop modes.'+
|
'Use Esc and Shift-Esc to exit crop modes.'
|
||||||
'\n\n'+
|
|
||||||
'NOTE: currently mixing crop modes is not supported,\n'+
|
|
||||||
'thus, if you are in a particular crop mode, you can\n'+
|
|
||||||
'only use that mode to crop again.\n'+
|
|
||||||
'...This restriction will be removed later.'
|
|
||||||
|
|
||||||
cfg = {}
|
cfg = {}
|
||||||
cfg[alg] = [
|
cfg[alg] = [
|
||||||
|
'Marked images (single ribbon)',
|
||||||
'Marked images',
|
'Marked images',
|
||||||
'Current ribbon',
|
'Current ribbon',
|
||||||
'Current ribbon and above'
|
'Current ribbon and above'
|
||||||
@ -1076,9 +1072,12 @@ function cropImagesDialog(){
|
|||||||
.done(function(res){
|
.done(function(res){
|
||||||
res = res[alg]
|
res = res[alg]
|
||||||
|
|
||||||
if(/Marked/i.test(res)){
|
if(/Marked.*single ribbon/i.test(res)){
|
||||||
var method = toggleMarkedOnlyView
|
var method = toggleMarkedOnlyView
|
||||||
|
|
||||||
|
} else if(/Marked/i.test(res)){
|
||||||
|
var method = toggleMarkedOnlyWithRibbonsView
|
||||||
|
|
||||||
} else if(/Current ribbon/i.test(res)){
|
} else if(/Current ribbon/i.test(res)){
|
||||||
var method = toggleSingleRibbonMode
|
var method = toggleSingleRibbonMode
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user