refactoring + rotation actions...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-11-23 13:16:28 +03:00
parent cede9a2b06
commit 785d03b07e
4 changed files with 43 additions and 0 deletions

View File

@ -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

View File

@ -1373,6 +1373,7 @@ var WidgetTestActions = actions.Actions({
setTimeout(step, 1000)
}],
// XXX make this a toggler....
partitionByMonth: ['Test/',
function(){

View File

@ -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){

View File

@ -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