mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-30 02:40:08 +00:00
added full crop interface and migrated cropping modes to use in (marked-only, single ribbon); fixed a save in cropped mode bug...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
4a2b37b67e
commit
e8a18b2a55
@ -93,11 +93,12 @@ Roadmap
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
[_] 30% Gen 3 current todo
|
[_] 29% Gen 3 current todo
|
||||||
[_] 61% High priority
|
[_] 59% High priority
|
||||||
[_] add indicator to ribbon up/down navigation in full screen...
|
[_] add indicator to ribbon up/down navigation in full screen...
|
||||||
| this might be a number or some kind of animation...
|
| this might be a number or some kind of animation...
|
||||||
[_] BUG: sometimes images.json folder is created...
|
[_] BUG: sometimes images.json folder is created...
|
||||||
|
[_] rework the marks.js/modes.js to enable multi-level cropping...
|
||||||
[_] 0% Priority tasks
|
[_] 0% Priority tasks
|
||||||
[_] full archive index
|
[_] full archive index
|
||||||
[_] segmented loading of images and data
|
[_] segmented loading of images and data
|
||||||
@ -272,6 +273,7 @@ Roadmap
|
|||||||
[_] remove extra and repetitive actions
|
[_] remove extra and repetitive actions
|
||||||
[_] caching config
|
[_] caching config
|
||||||
[_] side-by side view...
|
[_] side-by side view...
|
||||||
|
[X] BUG: cropping in cropped mode will not save the whole data...
|
||||||
[X] 100% BUG: sometimes the previews are not updated...
|
[X] 100% BUG: sometimes the previews are not updated...
|
||||||
[X] wrong resolution preview is loaded
|
[X] wrong resolution preview is loaded
|
||||||
| when coming out of single-image-mode after moving to a
|
| when coming out of single-image-mode after moving to a
|
||||||
|
|||||||
119
ui/data.js
119
ui/data.js
@ -109,6 +109,8 @@ var IMAGES_CREATED = false
|
|||||||
|
|
||||||
var MARKED = []
|
var MARKED = []
|
||||||
|
|
||||||
|
var CROP_STACK = []
|
||||||
|
|
||||||
// NOTE: these are named: <mode>-<feature>
|
// NOTE: these are named: <mode>-<feature>
|
||||||
var SETTINGS = {
|
var SETTINGS = {
|
||||||
'global-theme': null,
|
'global-theme': null,
|
||||||
@ -1077,31 +1079,6 @@ function loadSettings(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Crop view to only given gids
|
|
||||||
//
|
|
||||||
// XXX make keep_ribbons option work...
|
|
||||||
function cropDataToGIDs(gids, keep_ribbons){
|
|
||||||
var cur = DATA.current
|
|
||||||
var old_data = DATA
|
|
||||||
DATA = {
|
|
||||||
varsion: '2.0',
|
|
||||||
current: null,
|
|
||||||
ribbons: [
|
|
||||||
gids
|
|
||||||
],
|
|
||||||
order: DATA.order.slice(),
|
|
||||||
}
|
|
||||||
cur = getGIDBefore(cur, 0)
|
|
||||||
cur = cur == null ? gids[0] : cur
|
|
||||||
DATA.current = cur
|
|
||||||
|
|
||||||
reloadViewer()
|
|
||||||
updateImages()
|
|
||||||
|
|
||||||
return old_data
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* Image caching...
|
* Image caching...
|
||||||
@ -1177,6 +1154,98 @@ function getPrevLocation(){
|
|||||||
* Actions...
|
* Actions...
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/******************************************************* Crop Data ***/
|
||||||
|
|
||||||
|
function isViewCropped(){
|
||||||
|
return !(CROP_STACK.length == 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getAllData(){
|
||||||
|
if(!isViewCropped()){
|
||||||
|
return DATA
|
||||||
|
} else {
|
||||||
|
return CROP_STACK[0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// XXX make keep_ribbons option work...
|
||||||
|
function makeCroppedData(gids, keep_ribbons){
|
||||||
|
var cur = DATA.current
|
||||||
|
var old_data = DATA
|
||||||
|
var res = {
|
||||||
|
varsion: '2.0',
|
||||||
|
current: null,
|
||||||
|
ribbons: [],
|
||||||
|
order: DATA.order.slice(),
|
||||||
|
}
|
||||||
|
|
||||||
|
// flat single ribbon crop...
|
||||||
|
if(!keep_ribbons){
|
||||||
|
res.ribbons[0] = gids
|
||||||
|
|
||||||
|
// keep the ribbon structure...
|
||||||
|
} else {
|
||||||
|
$.each(DATA.ribbons, function(_, e){
|
||||||
|
e = e.filter(function(ee){ return gids.indexOf(ee) >= 0 })
|
||||||
|
// skip empty ribbons...
|
||||||
|
if(e.length != 0){
|
||||||
|
res.ribbons.push(e)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
cur = getGIDBefore(cur, 0)
|
||||||
|
cur = cur == null ? gids[0] : cur
|
||||||
|
res.current = cur
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function cropDataTo(gids, keep_ribbons){
|
||||||
|
var prev_state = DATA
|
||||||
|
|
||||||
|
CROP_STACK.push(prev_state)
|
||||||
|
DATA = makeCroppedData(gids, keep_ribbons)
|
||||||
|
|
||||||
|
reloadViewer()
|
||||||
|
updateImages()
|
||||||
|
|
||||||
|
return prev_state
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function uncropData(){
|
||||||
|
if(!isViewCropped()){
|
||||||
|
return DATA
|
||||||
|
}
|
||||||
|
var prev_state = DATA
|
||||||
|
|
||||||
|
DATA = CROP_STACK.pop()
|
||||||
|
|
||||||
|
reloadViewer()
|
||||||
|
updateImages()
|
||||||
|
|
||||||
|
return prev_state
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function showAllData(){
|
||||||
|
var prev_state = DATA
|
||||||
|
|
||||||
|
DATA = getAllData()
|
||||||
|
CROP_STACK = []
|
||||||
|
|
||||||
|
reloadViewer()
|
||||||
|
updateImages()
|
||||||
|
|
||||||
|
return prev_state
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************************************************* Workers ***/
|
/********************************************************* Workers ***/
|
||||||
|
|
||||||
// get/create a named worker queue...
|
// get/create a named worker queue...
|
||||||
|
|||||||
@ -438,7 +438,7 @@ function saveFileState(name, no_normalize_path){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dumpJSON(name + '-data.json', DATA)
|
dumpJSON(name + '-data.json', getAllData())
|
||||||
// XXX do we need to do this???
|
// XXX do we need to do this???
|
||||||
saveFileMarks(name)
|
saveFileMarks(name)
|
||||||
|
|
||||||
|
|||||||
@ -48,7 +48,7 @@ function loadLocalStorageData(attr){
|
|||||||
}
|
}
|
||||||
function saveLocalStorageData(attr){
|
function saveLocalStorageData(attr){
|
||||||
attr = attr == null ? DATA_ATTR : attr
|
attr = attr == null ? DATA_ATTR : attr
|
||||||
localStorage[attr] = JSON.stringify(DATA)
|
localStorage[attr] = JSON.stringify(getAllData())
|
||||||
saveLocalStorageBaseURL(attr)
|
saveLocalStorageBaseURL(attr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
23
ui/marks.js
23
ui/marks.js
@ -16,7 +16,7 @@
|
|||||||
// 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 loadMarkedOnlyData(cmp, no_cleanout_marks){
|
function cropMarkedImages(cmp, 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)
|
||||||
@ -34,27 +34,12 @@ function loadMarkedOnlyData(cmp, no_cleanout_marks){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ALL_DATA = cropDataToGIDs(marked)
|
ALL_DATA = cropDataTo(marked)
|
||||||
|
|
||||||
return DATA
|
return DATA
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// XXX name this in a better way...
|
|
||||||
function loadAllImages(){
|
|
||||||
var cur = DATA.current
|
|
||||||
DATA = ALL_DATA
|
|
||||||
// NOTE: if we do not do this the user will lose context every time
|
|
||||||
// returning from marks only view...
|
|
||||||
DATA.current = cur
|
|
||||||
reloadViewer()
|
|
||||||
// XXX FIX: for some reason not all previews get updated to the
|
|
||||||
// right size...
|
|
||||||
updateImages()
|
|
||||||
return DATA
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* Modes
|
* Modes
|
||||||
@ -72,9 +57,9 @@ var toggleMarkedOnlyView = createCSSClassToggler(
|
|||||||
},
|
},
|
||||||
function(action){
|
function(action){
|
||||||
if(action == 'on'){
|
if(action == 'on'){
|
||||||
loadMarkedOnlyData()
|
cropMarkedImages()
|
||||||
} else {
|
} else {
|
||||||
loadAllImages()
|
uncropData()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -184,13 +184,9 @@ var toggleSingleRibbonMode = createCSSClassToggler(
|
|||||||
},
|
},
|
||||||
function(action){
|
function(action){
|
||||||
if(action == 'on'){
|
if(action == 'on'){
|
||||||
ALL_DATA = cropDataToGIDs(DATA.ribbons[getRibbonIndex()].slice())
|
cropDataTo(DATA.ribbons[getRibbonIndex()].slice())
|
||||||
} else {
|
} else {
|
||||||
var cur = DATA.current
|
uncropData()
|
||||||
DATA = ALL_DATA
|
|
||||||
DATA.current = cur
|
|
||||||
reloadViewer()
|
|
||||||
updateImages()
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user