From 785d03b07ec15a89994172bec01508c5ac40dd10 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 23 Nov 2016 13:16:28 +0300 Subject: [PATCH] refactoring + rotation actions... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/base.js | 3 +++ ui (gen4)/features/ui-widgets.js | 1 + ui (gen4)/features/ui.js | 17 +++++++++++++++++ ui (gen4)/imagegrid/ribbons.js | 22 ++++++++++++++++++++++ 4 files changed, 43 insertions(+) diff --git a/ui (gen4)/features/base.js b/ui (gen4)/features/base.js index 7904f068..5a8fe73c 100755 --- a/ui (gen4)/features/base.js +++ b/ui (gen4)/features/base.js @@ -583,6 +583,9 @@ actions.Actions({ // NOTE: target must be .data.getImage(..) compatible, see it for docs... rotate: ['- Image|Edit/Rotate image', function(target, direction){ + if(arguments.length == 0){ + return this.image && this.image.orientation || 0 + } if(target == 'cw' || target == 'ccw'){ direction = target target = null diff --git a/ui (gen4)/features/ui-widgets.js b/ui (gen4)/features/ui-widgets.js index 5812188e..b9b61781 100755 --- a/ui (gen4)/features/ui-widgets.js +++ b/ui (gen4)/features/ui-widgets.js @@ -1373,6 +1373,7 @@ var WidgetTestActions = actions.Actions({ setTimeout(step, 1000) }], + // XXX make this a toggler.... partitionByMonth: ['Test/', function(){ diff --git a/ui (gen4)/features/ui.js b/ui (gen4)/features/ui.js index ab87cb66..4170fc98 100755 --- a/ui (gen4)/features/ui.js +++ b/ui (gen4)/features/ui.js @@ -856,6 +856,23 @@ module.ViewerActions = actions.Actions({ // XXX this needs an interactive mode -- mark A, mark B, align between alignToRibbon: [ reloadAfter(true) ], + + // ribbon rotation... + ribbonRotation: ['- Interface/', + function(a){ + if(a){ + this.ribbons.rotate(a) + + } else { + return this.ribbons.rotate() || 0 + } + }], + rotateRibbonCW: ['Interface/Rotate ribbon clockwise', + function(a){ this.ribbonRotation('+='+ (a || 10)) }], + rotateRibbonCCW: ['Interface/Rotate ribbon coounter clockwise', + function(a){ this.ribbonRotation('-='+ (a || 10)) }], + + // tags... tag: [ function(tags, gids){ diff --git a/ui (gen4)/imagegrid/ribbons.js b/ui (gen4)/imagegrid/ribbons.js index 829c0798..9eee7452 100755 --- a/ui (gen4)/imagegrid/ribbons.js +++ b/ui (gen4)/imagegrid/ribbons.js @@ -518,6 +518,22 @@ var RibbonsPrototype = { // Rotate... // + // Get ribbon rotation angle... + // .rotate() + // -> angle + // + // Rotate to angle... + // .rotate(20) + // .rotate(-10) + // -> ribbons + // + // Rotate by angle... + // .rotate('-=20') + // .rotate('+=30') + // -> ribbons + // + // NOTE: the angles are not base 360 normalised... + // NOTE: units are ignored and the final angle is always in deg. rotate: function(angle){ // get... if(arguments.length == 0){ @@ -531,6 +547,12 @@ var RibbonsPrototype = { return this } + angle = typeof(angle) == typeof('str') + ? (/^\+=/.test(angle) ? (ribbon_set.rotate() || 0) + parseFloat(angle.slice(2)) + :/^\-=/.test(angle) ? (ribbon_set.rotate() || 0) - parseFloat(angle.slice(2)) + : parseFloat(angle)) + : angle + ribbon_set.rotate(angle) return this