增加移动控制键

This commit is contained in:
mkwiser 2014-11-01 02:10:51 +08:00
parent 22f361f390
commit 283524152b
4 changed files with 41 additions and 13 deletions

View File

@ -48,7 +48,7 @@ define(
/** /**
* 根据控制点做图形变换 * 根据控制点做图形变换
*/ */
ShapesGroup.prototype.beginTransform = function(point, camera) { ShapesGroup.prototype.beginTransform = function(point, camera, key) {
this.bound = getBound(this.shapes); this.bound = getBound(this.shapes);
this.editor.coverLayer.addShape({ this.editor.coverLayer.addShape({
id: 'bound', id: 'bound',
@ -63,9 +63,9 @@ define(
/** /**
* 根据控制点做图形变换 * 根据控制点做图形变换
*/ */
ShapesGroup.prototype.transform = function(point, camera) { ShapesGroup.prototype.transform = function(point, camera, key) {
if (this.mode === 'move') { if (this.mode === 'move') {
moveTransform.call(this, camera); moveTransform.call(this, camera, key.altKey, key.shiftKey);
} }
else if (this.mode === 'scale') { else if (this.mode === 'scale') {
scaleTransform.call(this, point, camera); scaleTransform.call(this, point, camera);
@ -78,12 +78,12 @@ define(
/** /**
* 刷新Shapesgroup信息 * 刷新Shapesgroup信息
*/ */
ShapesGroup.prototype.finishTransform = function(point, camera) { ShapesGroup.prototype.finishTransform = function(point, camera, key) {
// 保存最后一次修改 // 保存最后一次修改
var coverShapes = this.coverShapes; var coverShapes = this.coverShapes;
this.coverShapes = this.shapes; this.coverShapes = this.shapes;
this.transform(point, camera); this.transform(point, camera, key);
this.coverShapes = coverShapes; this.coverShapes = coverShapes;
delete this.bound; delete this.bound;

View File

@ -17,11 +17,13 @@ define(
* 移动对象 * 移动对象
* *
* @param {Object} camera 镜头对象 * @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 x = fixX ? 0 : (camera.x - camera.startX);
var y = camera.y - camera.startY; var y = fixY ? 0 : (camera.y - camera.startY);
// 更新shape // 更新shape
var shapes = this.shapes; var shapes = this.shapes;

View File

@ -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', name: 'add_referenceline',
title: '添加边界参考线' title: '添加边界参考线'

View File

@ -203,7 +203,7 @@ define(
// 点拖动模式 // 点拖动模式
if (this.currentPoint) { if (this.currentPoint) {
this.currentGroup.beginTransform(this.currentPoint, this.render.camera); this.currentGroup.beginTransform(this.currentPoint, this.render.camera, e);
} }
else { else {
// 复制模式 // 复制模式
@ -218,7 +218,7 @@ define(
} }
// 移动 // 移动
this.currentGroup.setMode('move'); 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) { drag: function(e) {
if(this.currentGroup) { 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) { dragend: function(e) {
if (this.currentPoint) { if (this.currentPoint) {
this.currentGroup.finishTransform(this.currentPoint, this.render.camera); this.currentGroup.finishTransform(this.currentPoint, this.render.camera, e);
this.currentPoint = null; this.currentPoint = null;
this.fire('change'); this.fire('change');
} }
else if (this.currentGroup.mode == 'move') { 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.currentGroup.setMode('scale');
this.fire('change'); this.fire('change');
} }