From a828ed4ec6f3d0fcb86d5a1a91ae8206c6b3cdd0 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Tue, 21 Jun 2016 06:06:34 +0300 Subject: [PATCH] more refactoring + some docs... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/base.js | 79 +++++++++++++++++++++++++++------- ui (gen4)/features/keyboard.js | 4 +- 2 files changed, 66 insertions(+), 17 deletions(-) diff --git a/ui (gen4)/features/base.js b/ui (gen4)/features/base.js index cebcdbbf..ecc99a38 100755 --- a/ui (gen4)/features/base.js +++ b/ui (gen4)/features/base.js @@ -518,23 +518,72 @@ actions.Actions({ // basic image editing... // - // XXX should we have .rotate(..) and .flip(..) generic actions??? - rotateCW: ['Image|Edit/', - function(target){ + // Rotate image... + // + // Rotate current image clockwise... + // .rotate() + // .rotate('cw') + // -> actions + // + // Rotate current image counterclockwise... + // .rotate('ccw') + // -> actions + // + // Rotate target image clockwise... + // .rotate(target) + // .rotate(target, 'cw') + // -> actions + // + // Rotate target image counterclockwise... + // .rotate(target, 'ccw') + // -> actions + // + // + // Flip is similar... + // + // Flip current image ('horizontal' is default)... + // .flip() + // .flip('horizontal') + // .flip('vertical') + // -> actions + // + // Flip target... + // .flip(target) + // .flip(target, 'horizontal') + // .flip(target, 'vertical') + // -> actions + // + // + // NOTE: target must be .data.getImage(..) compatible, see it for docs... + rotate: ['- Image|Edit/Rotate image', + function(target, direction){ + if(target == 'cw' || target == 'ccw'){ + direction = target + target = null + } this.images - && this.images.rotateImage(this.data.getImage(target), 'cw') }], - rotateCCW: ['Image|Edit/', - function(target){ + && this.images.rotateImage(this.data.getImage(target), direction || 'cw') + }], + flip: ['- Flip|edit/Flip image', + function(target, direction){ + if(target == 'vertical' || target == 'horizontal'){ + direction = target + target = null + } this.images - && this.images.rotateImage(this.data.getImage(target), 'ccw') }], - flipVertical: ['Image|Edit/', - function(target){ - this.images - && this.images.flipImage(this.data.getImage(target), 'vertical') }], - flipHorizontal: ['Image|Edit/', - function(target){ - this.images - && this.images.flipImage(this.data.getImage(target), 'horizontal') }], + && this.images.flipImage(this.data.getImage(target), direction || 'horizontal') + }], + + // shorthands... + // NOTE: these are here mostly for the menus... + rotateCW: ['Image|Edit/Rotate image clockwise', + function(target){ this.rotate(traget, 'cw') }], + rotateCCW: ['Image|Edit/Rotate image counterclockwise', + function(target){ this.rotate(traget, 'ccw') }], + flipVertical: ['Image|Edit/Flip image vertically', + function(target){ this.flip(traget, 'vertical') }], + flipHorizontal: ['Image|Edit/Flip image horizontally', + function(target){ this.flip(traget, 'horizontal') }], }) diff --git a/ui (gen4)/features/keyboard.js b/ui (gen4)/features/keyboard.js index 5eb1bac5..d8cf45c7 100755 --- a/ui (gen4)/features/keyboard.js +++ b/ui (gen4)/features/keyboard.js @@ -88,12 +88,12 @@ module.GLOBAL_KEYBOARD = { '#2': { default: 'fitNormal', 'alt': 'setNormalScale -- Set current image size as normal', - 'ctrl+shift': 'setNormalScale: null -- Reset normal size to default', + 'ctrl+shift': 'setNormalScale: null -- Reset normal image size to default', }, '#3': { default: 'fitSmall', 'alt': 'setSmallScale -- Set current image size as small', - 'ctrl+shift': 'setSmallScale: null -- Reset small size to default', + 'ctrl+shift': 'setSmallScale: null -- Reset small image size to default', }, '#4': customScale(4), '#5': customScale(5),