From 283524152b39934077049213362c75e4186215be Mon Sep 17 00:00:00 2001 From: mkwiser Date: Sat, 1 Nov 2014 02:10:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=A7=BB=E5=8A=A8=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E9=94=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/editor/group/ShapesGroup.js | 10 +++++----- src/editor/group/moveTransform.js | 8 +++++--- src/editor/menu/shape.js | 26 ++++++++++++++++++++++++++ src/editor/mode/shapes.js | 10 +++++----- 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/src/editor/group/ShapesGroup.js b/src/editor/group/ShapesGroup.js index c09be75..380a187 100644 --- a/src/editor/group/ShapesGroup.js +++ b/src/editor/group/ShapesGroup.js @@ -48,7 +48,7 @@ define( /** * 根据控制点做图形变换 */ - ShapesGroup.prototype.beginTransform = function(point, camera) { + ShapesGroup.prototype.beginTransform = function(point, camera, key) { this.bound = getBound(this.shapes); this.editor.coverLayer.addShape({ id: 'bound', @@ -63,9 +63,9 @@ define( /** * 根据控制点做图形变换 */ - ShapesGroup.prototype.transform = function(point, camera) { + ShapesGroup.prototype.transform = function(point, camera, key) { if (this.mode === 'move') { - moveTransform.call(this, camera); + moveTransform.call(this, camera, key.altKey, key.shiftKey); } else if (this.mode === 'scale') { scaleTransform.call(this, point, camera); @@ -78,12 +78,12 @@ define( /** * 刷新Shapesgroup信息 */ - ShapesGroup.prototype.finishTransform = function(point, camera) { + ShapesGroup.prototype.finishTransform = function(point, camera, key) { // 保存最后一次修改 var coverShapes = this.coverShapes; this.coverShapes = this.shapes; - this.transform(point, camera); + this.transform(point, camera, key); this.coverShapes = coverShapes; delete this.bound; diff --git a/src/editor/group/moveTransform.js b/src/editor/group/moveTransform.js index 8c26a47..77511f2 100644 --- a/src/editor/group/moveTransform.js +++ b/src/editor/group/moveTransform.js @@ -17,11 +17,13 @@ define( * 移动对象 * * @param {Object} camera 镜头对象 + * @param {boolean} fixX 固定X + * @param {boolean} fixY 固定Y */ - function moveTransform (camera) { + function moveTransform (camera, fixX, fixY) { - var x = camera.x - camera.startX; - var y = camera.y - camera.startY; + var x = fixX ? 0 : (camera.x - camera.startX); + var y = fixY ? 0 : (camera.y - camera.startY); // 更新shape var shapes = this.shapes; diff --git a/src/editor/menu/shape.js b/src/editor/menu/shape.js index 461bbfe..009d0ad 100644 --- a/src/editor/menu/shape.js +++ b/src/editor/menu/shape.js @@ -70,6 +70,32 @@ define( } ] }, + { + name: 'shapes_verticalalign', + title: '垂直方向', + items: [ + { + name: 'shapes_verticalalign', + type: 'ascent', + title: '顶端对齐' + }, + { + name: 'shapes_verticalalign', + type: 'middle', + title: '居中对齐' + }, + { + name: 'shapes_verticalalign', + type: 'descent', + title: '低端对齐' + }, + { + name: 'shapes_verticalalign', + type: 'baseline', + title: '基线对齐' + } + ] + }, { name: 'add_referenceline', title: '添加边界参考线' diff --git a/src/editor/mode/shapes.js b/src/editor/mode/shapes.js index b0d292b..9088ac6 100644 --- a/src/editor/mode/shapes.js +++ b/src/editor/mode/shapes.js @@ -203,7 +203,7 @@ define( // 点拖动模式 if (this.currentPoint) { - this.currentGroup.beginTransform(this.currentPoint, this.render.camera); + this.currentGroup.beginTransform(this.currentPoint, this.render.camera, e); } else { // 复制模式 @@ -218,7 +218,7 @@ define( } // 移动 this.currentGroup.setMode('move'); - this.currentGroup.beginTransform(this.currentPoint, this.render.camera); + this.currentGroup.beginTransform(this.currentPoint, this.render.camera, e); } }, @@ -228,7 +228,7 @@ define( */ drag: function(e) { if(this.currentGroup) { - this.currentGroup.transform(this.currentPoint, this.render.camera); + this.currentGroup.transform(this.currentPoint, this.render.camera, e); } }, @@ -238,12 +238,12 @@ define( dragend: function(e) { if (this.currentPoint) { - this.currentGroup.finishTransform(this.currentPoint, this.render.camera); + this.currentGroup.finishTransform(this.currentPoint, this.render.camera, e); this.currentPoint = null; this.fire('change'); } else if (this.currentGroup.mode == 'move') { - this.currentGroup.finishTransform(this.currentPoint, this.render.camera); + this.currentGroup.finishTransform(this.currentPoint, this.render.camera, e); this.currentGroup.setMode('scale'); this.fire('change'); }