Commit 7eeea30b authored by techird's avatar techird

render expander at layout vector

parent aa0c2a52
Subproject commit f62ec70beb8198072693e1b7f1748cca46b685fb Subproject commit 022e5cb489e65df8a38eedf8508478ee1d29c29c
...@@ -56,9 +56,8 @@ kity.extendClass(Minder, { ...@@ -56,9 +56,8 @@ kity.extendClass(Minder, {
connection.setVisible(true); connection.setVisible(true);
var provider = KityMinder.getConnectProvider(node.getLayout()); var provider = KityMinder.getConnectProvider(node.getLayout());
var pathData = provider(node, parent);
connection.setPathData(pathData); provider(node, parent, connection);
} }
}); });
......
...@@ -79,12 +79,12 @@ KityMinder.registerLayout('default', kity.createClass({ ...@@ -79,12 +79,12 @@ KityMinder.registerLayout('default', kity.createClass({
x = nodeContentBox.right - childContentBox.left; x = nodeContentBox.right - childContentBox.left;
x += parent.getStyle('margin-right') + child.getStyle('margin-left'); x += parent.getStyle('margin-right') + child.getStyle('margin-left');
child.setLayoutVector(new kity.Vector(childContentBox.left, childContentBox.cy)); child.setLayoutVector(new kity.Vector(childContentBox.right, childContentBox.cy));
} else { } else {
x = nodeContentBox.left - childContentBox.right; x = nodeContentBox.left - childContentBox.right;
x -= parent.getStyle('margin-left') + child.getStyle('margin-right'); x -= parent.getStyle('margin-left') + child.getStyle('margin-right');
child.setLayoutVector(new kity.Vector(childContentBox.right, childContentBox.cy)); child.setLayoutVector(new kity.Vector(childContentBox.left, childContentBox.cy));
} }
// 竖直方向上的布局 // 竖直方向上的布局
...@@ -110,7 +110,14 @@ KityMinder.registerLayout('default', kity.createClass({ ...@@ -110,7 +110,14 @@ KityMinder.registerLayout('default', kity.createClass({
} }
})); }));
KityMinder.registerConnectProvider('default', function(node, parent) { var connectMarker = new kity.Marker().pipe(function() {
var r = 4;
var dot = new kity.Circle(r).fill('white');
this.addShape(dot);
this.setRef(r, 0).setViewBox(-r, -r, r + r, r + r).setWidth(r).setHeight(r);
});
KityMinder.registerConnectProvider('default', function(node, parent, connection) {
var box = node.getLayoutBox(), var box = node.getLayoutBox(),
pBox = parent.getLayoutBox(); pBox = parent.getLayoutBox();
...@@ -120,17 +127,23 @@ KityMinder.registerConnectProvider('default', function(node, parent) { ...@@ -120,17 +127,23 @@ KityMinder.registerConnectProvider('default', function(node, parent) {
var pathData = []; var pathData = [];
var side = box.cx > pBox.cx ? 'right' : 'left'; var side = box.cx > pBox.cx ? 'right' : 'left';
node.getMinder().getPaper().addResource(connectMarker);
switch (node.getType()) { switch (node.getType()) {
case 'main': case 'main':
start = new kity.Point(pBox.cx, pBox.cy); start = new kity.Point(pBox.cx, pBox.cy);
end = side == 'left' ? end = side == 'left' ?
new kity.Point(box.right, box.cy) : new kity.Point(box.right + 2, box.cy) :
new kity.Point(box.left, box.cy); new kity.Point(box.left - 2, box.cy);
vector = kity.Vector.fromPoints(start, end); vector = kity.Vector.fromPoints(start, end);
pathData.push('M', start); pathData.push('M', start);
pathData.push('A', abs(vector.x), abs(vector.y), 0, 0, (vector.x * vector.y > 0 ? 0 : 1), end); pathData.push('A', abs(vector.x), abs(vector.y), 0, 0, (vector.x * vector.y > 0 ? 0 : 1), end);
connection.setMarker(connectMarker);
break; break;
case 'sub': case 'sub':
...@@ -139,10 +152,10 @@ KityMinder.registerConnectProvider('default', function(node, parent) { ...@@ -139,10 +152,10 @@ KityMinder.registerConnectProvider('default', function(node, parent) {
if (side == 'right') { if (side == 'right') {
start = new kity.Point(box.left - node.getStyle('margin-left') / 2, pBox.cy); start = new kity.Point(box.left - node.getStyle('margin-left') / 2, pBox.cy);
end = new kity.Point(box.right + node.getStyle('margin-right') / 2, box.bottom); end = new kity.Point(box.right + node.getStyle('margin-right'), box.bottom);
} else { } else {
start = new kity.Point(box.right + node.getStyle('margin-right') / 2, pBox.cy); start = new kity.Point(box.right + node.getStyle('margin-right') / 2, pBox.cy);
end = new kity.Point(box.left - node.getStyle('margin-left') / 2, box.bottom); end = new kity.Point(box.left - node.getStyle('margin-left'), box.bottom);
} }
end.y += 1; end.y += 1;
...@@ -157,7 +170,11 @@ KityMinder.registerConnectProvider('default', function(node, parent) { ...@@ -157,7 +170,11 @@ KityMinder.registerConnectProvider('default', function(node, parent) {
pathData.push('A', radius, radius, 0, 0, sf, ex, end.y); pathData.push('A', radius, radius, 0, 0, sf, ex, end.y);
pathData.push('L', end); pathData.push('L', end);
connection.setMarker(null);
break;
} }
return pathData; connection.setPathData(pathData);
}); });
\ No newline at end of file
...@@ -203,17 +203,13 @@ KityMinder.registerModule('Expand', function() { ...@@ -203,17 +203,13 @@ KityMinder.registerModule('Expand', function() {
var x, y; var x, y;
var right = node.getLayoutPoint().x > node.parent.getLayoutPoint().x; var pos = node.getLayoutVector();
x = right ? pos = new kity.Vector(pos.x, pos.y);
node.getContentBox().right + node.getStyle('margin-right') :
node.getContentBox().left - node.getStyle('margin-left');
y = node.getType() == 'main' ? pos = pos.normalize(pos.length() + expander.radius + 1);
node.getContentBox().cy :
node.getContentBox().bottom;
this.expander.setTranslate(x, y); this.expander.setTranslate(pos);
} }
}); });
return { return {
......
...@@ -17,7 +17,7 @@ KityMinder.registerModule('OutlineModule', function() { ...@@ -17,7 +17,7 @@ KityMinder.registerModule('OutlineModule', function() {
var shadow = this.shadow = new kity.Rect() var shadow = this.shadow = new kity.Rect()
.setId(KityMinder.uuid('node_shadow')) .setId(KityMinder.uuid('node_shadow'))
.fill('black') .fill('black')
.setOpacity(0.2); .setOpacity(0.25);
group.addShapes([shadow, outline]); group.addShapes([shadow, outline]);
...@@ -62,7 +62,7 @@ KityMinder.registerModule('OutlineModule', function() { ...@@ -62,7 +62,7 @@ KityMinder.registerModule('OutlineModule', function() {
if (node.getLevel() < 2) { if (node.getLevel() < 2) {
this.shadow this.shadow
.setVisible(true) .setVisible(true)
.setPosition(outlineBox.x + 3, outlineBox.y + 4) .setPosition(outlineBox.x + 4, outlineBox.y + 5)
.setSize(outlineBox.width, outlineBox.height) .setSize(outlineBox.width, outlineBox.height)
.setRadius(node.getStyle('radius')); .setRadius(node.getStyle('radius'));
} else { } else {
......
...@@ -13,7 +13,7 @@ KityMinder.registerTheme('default', { ...@@ -13,7 +13,7 @@ KityMinder.registerTheme('default', {
'main-stroke': 'none', 'main-stroke': 'none',
'main-font-size': 16, 'main-font-size': 16,
'main-padding': [6, 20], 'main-padding': [6, 20],
'main-margin': [30, 6], 'main-margin': [30, 10],
'main-radius': 10, 'main-radius': 10,
'main-space': 5, 'main-space': 5,
...@@ -22,7 +22,8 @@ KityMinder.registerTheme('default', { ...@@ -22,7 +22,8 @@ KityMinder.registerTheme('default', {
'sub-stroke': 'white', 'sub-stroke': 'white',
'sub-font-size': 12, 'sub-font-size': 12,
'sub-padding': [5, 10], 'sub-padding': [5, 10],
'sub-margin': [5, 15], 'sub-margin': 10,
'sub-tree-margin': 30,
'sub-radius': 5, 'sub-radius': 5,
'sub-space': 5, 'sub-space': 5,
......
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