Commit aafe8014 authored by 张博's avatar 张博

add tianpan template outline and text

parent 322eb8ec
...@@ -23,6 +23,8 @@ define(function(require, exports, module) { ...@@ -23,6 +23,8 @@ define(function(require, exports, module) {
update: function(outline, node, box) { update: function(outline, node, box) {
var shape = node.getStyle('shape');
var paddingLeft = node.getStyle('padding-left'), var paddingLeft = node.getStyle('padding-left'),
paddingRight = node.getStyle('padding-right'), paddingRight = node.getStyle('padding-right'),
paddingTop = node.getStyle('padding-top'), paddingTop = node.getStyle('padding-top'),
...@@ -35,11 +37,26 @@ define(function(require, exports, module) { ...@@ -35,11 +37,26 @@ define(function(require, exports, module) {
height: box.height + paddingTop + paddingBottom height: box.height + paddingTop + paddingBottom
}; };
var radius = node.getStyle('radius');
// 天盘图圆形的情况
if (shape && shape == 'circle') {
var width= Math.max(box.width,box.height);
outlineBox.width = width + paddingLeft + paddingRight;
outlineBox.height = width + paddingTop + paddingBottom;
outlineBox.width = Math.max(outlineBox.width, outlineBox.height);
outlineBox.height = Math.max(outlineBox.width, outlineBox.height);
radius = outlineBox.width / 2;
}
var prefix = node.isSelected() ? (node.getMinder().isFocused() ? 'selected-' : 'blur-selected-') : ''; var prefix = node.isSelected() ? (node.getMinder().isFocused() ? 'selected-' : 'blur-selected-') : '';
outline outline
.setPosition(outlineBox.x, outlineBox.y) .setPosition(outlineBox.x, outlineBox.y)
.setSize(outlineBox.width, outlineBox.height) .setSize(outlineBox.width, outlineBox.height)
.setRadius(node.getStyle('radius')) .setRadius(radius)
.fill(node.getData('background') || node.getStyle(prefix + 'background') || node.getStyle('background')) .fill(node.getData('background') || node.getStyle(prefix + 'background') || node.getStyle('background'))
.stroke(node.getStyle(prefix + 'stroke' || node.getStyle('stroke')), .stroke(node.getStyle(prefix + 'stroke' || node.getStyle('stroke')),
node.getStyle(prefix + 'stroke-width')); node.getStyle(prefix + 'stroke-width'));
...@@ -62,9 +79,18 @@ define(function(require, exports, module) { ...@@ -62,9 +79,18 @@ define(function(require, exports, module) {
update: function(shadow, node, box) { update: function(shadow, node, box) {
shadow.setPosition(box.x + 4, box.y + 5) shadow.setPosition(box.x + 4, box.y + 5)
.setSize(box.width, box.height) .fill(node.getStyle('shadow'));
.fill(node.getStyle('shadow'))
.setRadius(node.getStyle('radius')); var shape = node.getStyle('shape');
if(!shape){
shadow.setSize(box.width, box.height);
shadow.setRadius(node.getStyle('radius'));
}else if(shape=='circle'){
var width= Math.max(box.width,box.height);
shadow.setSize(width, width);
shadow.setRadius(width/2);
}
} }
}); });
......
...@@ -226,7 +226,13 @@ define(function(require, exports, module) { ...@@ -226,7 +226,13 @@ define(function(require, exports, module) {
rBox = rBox.merge(new kity.Box(0, y, bbox.height && bbox.width || 1, fontSize)); rBox = rBox.merge(new kity.Box(0, y, bbox.height && bbox.width || 1, fontSize));
}); });
var nBox = new kity.Box(r(rBox.x), r(rBox.y), r(rBox.width), r(rBox.height)); //为了让文字在圆中垂直居中
var w = 0;
var shape = node.getStyle('shape');
if (shape && shape == 'circle'){
w = Math.max(rBox.width, rBox.height) / 2 - rBox.height / 2;
}
var nBox = new kity.Box(r(rBox.x), r(rBox.y - w), r(rBox.width), r(rBox.height));
node._currentTextGroupBox = nBox; node._currentTextGroupBox = nBox;
return nBox; return nBox;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment