Commit 4a5ccc85 authored by Akikonata's avatar Akikonata

Merge branch 'dev' of https://github.com/fex-team/kityminder into dev

parents 6c107013 721273a5
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);
} }
}); });
......
...@@ -105,6 +105,7 @@ kity.extendClass(MinderNode, { ...@@ -105,6 +105,7 @@ kity.extendClass(MinderNode, {
x: p.x, x: p.x,
y: p.y y: p.y
}); });
return this;
}, },
getLayoutRoot: function() { getLayoutRoot: function() {
...@@ -130,6 +131,10 @@ kity.extendClass(MinderNode, { ...@@ -130,6 +131,10 @@ kity.extendClass(MinderNode, {
this.getMinder().layout(duration); this.getMinder().layout(duration);
return this; return this;
},
getPositionContext: function(node, position) {
} }
}); });
...@@ -167,6 +172,9 @@ kity.extendClass(Minder, { ...@@ -167,6 +172,9 @@ kity.extendClass(Minder, {
var matrix = node.getLayoutTransform().merge(pMatrix); var matrix = node.getLayoutTransform().merge(pMatrix);
var lastMatrix = node._lastLayoutTransform || new kity.Matrix(); var lastMatrix = node._lastLayoutTransform || new kity.Matrix();
var offset = node.getLayoutOffset();
matrix.translate(offset.x, offset.y);
if (!matrix.equals(lastMatrix) || true) { if (!matrix.equals(lastMatrix) || true) {
// 如果当前有动画,停止动画 // 如果当前有动画,停止动画
......
...@@ -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,13 +152,13 @@ KityMinder.registerConnectProvider('default', function(node, parent) { ...@@ -139,13 +152,13 @@ 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 += 3;
var isTop = parent.children.length > 1 && node.getIndex() === 0; var isTop = parent.children.length > 1 && node.getIndex() === 0;
...@@ -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
...@@ -234,11 +234,11 @@ var DragBox = kity.createClass('DragBox', { ...@@ -234,11 +234,11 @@ var DragBox = kity.createClass('DragBox', {
} }
var movement = kity.Vector.fromPoints(this._startPosition, this._dragPosition); var movement = kity.Vector.fromPoints(this._startPosition, this._dragPosition);
// var minder = this._minder; var minder = this._minder;
// this._dragSources.forEach(function(source) { this._dragSources.forEach(function(source) {
// source.setLayoutOffset(movement); source.setLayoutOffset(movement);
// minder.layout(); minder.layout();
// }); });
this.setTranslate(movement); this.setTranslate(movement);
......
...@@ -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 {
......
...@@ -29,6 +29,13 @@ KityMinder.registerProtocal( 'xmind', function () { ...@@ -29,6 +29,13 @@ KityMinder.registerProtocal( 'xmind', function () {
,'task-7oct' : null ,'task-7oct' : null
}; };
function getAttachedNode( arr ){
for (var i = 0; i < arr.length; i++) {
if( arr[ i ].type == "attached" )
return arr[ i ]
}
}
function processTopic(topic, obj){ function processTopic(topic, obj){
//处理文本 //处理文本
...@@ -54,8 +61,9 @@ KityMinder.registerProtocal( 'xmind', function () { ...@@ -54,8 +61,9 @@ KityMinder.registerProtocal( 'xmind', function () {
} }
//处理子节点 //处理子节点
if( topic.children && topic.children.topics && topic.children.topics.topic ){ var topics;
var tmp = topic.children.topics.topic; if( topic.children && (topics=topic.children.topics) && ( topics.topic || (utils.isArray( topics ) && topics.length>0) ) ){
var tmp = topics.topic || (getAttachedNode( topics )).topic;
if( tmp.length && tmp.length > 0 ){ //多个子节点 if( tmp.length && tmp.length > 0 ){ //多个子节点
obj.children = []; obj.children = [];
......
...@@ -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