From 5238a7839799c0128c7bd70290d57a6a4a26116a Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Thu, 6 Nov 2014 01:36:03 +0300 Subject: [PATCH] now image flipping more consistent, still not done (needs images.js)... Signed-off-by: Alex A. Naanou --- ui (gen4)/ribbons.js | 9 +++++++++ ui (gen4)/viewer.js | 34 +++++++++++++++++++++++++++++----- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/ui (gen4)/ribbons.js b/ui (gen4)/ribbons.js index 1c3e8991..fc3cc3f8 100755 --- a/ui (gen4)/ribbons.js +++ b/ui (gen4)/ribbons.js @@ -1313,6 +1313,9 @@ module.RibbonsPrototype = { return image }, + getImageRotation: function(target){ + return this.getImage(target).attr('orientation') || 0 + }, // Rotate an image... // // Rotate image clockwise: @@ -1360,6 +1363,12 @@ module.RibbonsPrototype = { return target }, + getImageFlip: function(target){ + return (this.getImage(target).attr('flipped') || '') + .split(',') + .map(function(e){ return e.trim() }) + .filter(function(e){ return e != '' }) + }, // Flip an image... // // Flip image: diff --git a/ui (gen4)/viewer.js b/ui (gen4)/viewer.js index 7729544c..d128a66c 100755 --- a/ui (gen4)/viewer.js +++ b/ui (gen4)/viewer.js @@ -687,7 +687,6 @@ actions.Actions(Client, { }], // XXX skip invisible ribbons (???) - // XXX load data chunks... focusImage: [ function(target, list){ var ribbons = this.ribbons @@ -707,8 +706,6 @@ actions.Actions(Client, { // NOTE: this will prevent sync errors... var gid = data.getImage() - // XXX see if we need to do some loading... - target = ribbons.focusImage(gid) } } @@ -895,10 +892,37 @@ actions.Actions(Client, { function(target){ this.ribbons.rotateCW(target) }], rotateCCW: [ function(target){ this.ribbons.rotateCCW(target) }], + // NOTE: these are relative to how the image is viewed and not to + // it's original orientation... + // ...this makes things consistent both visually and internally + // NOTE: these support target lists... + // XXX tell data/images about the flip... flipVertical: [ - function(target){ this.ribbons.flipVertical(target) }], + function(target){ + target = target == null || target.constructor !== Array ? [target] : target + var that = this + target.forEach(function(target){ + var r = that.ribbons.getImageRotation(target) + if(r == 0 || r == 180){ + that.ribbons.flipVertical(target) + } else { + that.ribbons.flipHorizontal(target) + } + }) + }], flipHorizontal: [ - function(target){ this.ribbons.flipHorizontal(target) }], + function(target){ + target = target == null || target.constructor !== Array ? [target] : target + var that = this + target.forEach(function(target){ + var r = that.ribbons.getImageRotation(target) + if(r == 0 || r == 180){ + that.ribbons.flipHorizontal(target) + } else { + that.ribbons.flipVertical(target) + } + }) + }], crop: [ reloadAfter() ], uncrop: [ reloadAfter() ],