Commit 55e95213 authored by Akikonata's avatar Akikonata

added layout bottom

parent e8a6e782
...@@ -24,7 +24,9 @@ ...@@ -24,7 +24,9 @@
'core/render.js', 'core/render.js',
'core/theme.js', 'core/theme.js',
'layout/default.js', 'layout/default.js',
'layout/bottom.js',
'theme/default.js', 'theme/default.js',
'theme/bottom.js',
'module/node.js', 'module/node.js',
'module/text.js', 'module/text.js',
'module/outline.js', 'module/outline.js',
......
Subproject commit 38e17411060a02d0601985ca1a2553057c3f9e40 Subproject commit f62ec70beb8198072693e1b7f1748cca46b685fb
KityMinder.registerModule("LayoutDefault", function () { KityMinder.registerModule("LayoutDefault", function() {
var _target = this.getRenderTarget(); var _target = this.getRenderTarget();
function getMinderSize() { function getMinderSize() {
...@@ -9,9 +9,9 @@ KityMinder.registerModule("LayoutDefault", function () { ...@@ -9,9 +9,9 @@ KityMinder.registerModule("LayoutDefault", function () {
} }
var minder = this; var minder = this;
//收缩-展开子树的节点 //收缩-展开子树的节点
var ShIcon = kity.createClass("DefaultshIcon", (function () { var ShIcon = kity.createClass("DefaultshIcon", (function() {
return { return {
constructor: function (node) { constructor: function(node) {
this._show = false; this._show = false;
this._node = node; this._node = node;
var iconShape = this.shape = new kity.Group(); var iconShape = this.shape = new kity.Group();
...@@ -34,7 +34,7 @@ KityMinder.registerModule("LayoutDefault", function () { ...@@ -34,7 +34,7 @@ KityMinder.registerModule("LayoutDefault", function () {
iconShape.addShapes([circle, plus, dec]); iconShape.addShapes([circle, plus, dec]);
this.update(); this.update();
}, },
switchState: function (val) { switchState: function(val) {
if (val === true || val === false) if (val === true || val === false)
this._show = !val; this._show = !val;
if (!this._show) { if (!this._show) {
...@@ -48,7 +48,7 @@ KityMinder.registerModule("LayoutDefault", function () { ...@@ -48,7 +48,7 @@ KityMinder.registerModule("LayoutDefault", function () {
} }
return this._show; return this._show;
}, },
update: function () { update: function() {
var node = this._node; var node = this._node;
var Layout = node.getLayout(); var Layout = node.getLayout();
var nodeShape = node.getRenderContainer(); var nodeShape = node.getRenderContainer();
...@@ -61,13 +61,13 @@ KityMinder.registerModule("LayoutDefault", function () { ...@@ -61,13 +61,13 @@ KityMinder.registerModule("LayoutDefault", function () {
} }
this.shape.setTranslate(nodeX, nodeY); this.shape.setTranslate(nodeX, nodeY);
}, },
remove: function () { remove: function() {
this.shape.remove(); this.shape.remove();
} }
}; };
})()); })());
//求并集 //求并集
var uSet = function (a, b) { var uSet = function(a, b) {
for (var i = 0; i < a.length; i++) { for (var i = 0; i < a.length; i++) {
var idx = b.indexOf(a[i]); var idx = b.indexOf(a[i]);
if (idx !== -1) { if (idx !== -1) {
...@@ -120,7 +120,7 @@ KityMinder.registerModule("LayoutDefault", function () { ...@@ -120,7 +120,7 @@ KityMinder.registerModule("LayoutDefault", function () {
} }
}; };
//更新背景 //更新背景
var updateBg = function (node) { var updateBg = function(node) {
var nodeType = node.getType(); var nodeType = node.getType();
var nodeStyle = nodeStyles[nodeType]; var nodeStyle = nodeStyles[nodeType];
var Layout = node.getLayout(); var Layout = node.getLayout();
...@@ -143,7 +143,7 @@ KityMinder.registerModule("LayoutDefault", function () { ...@@ -143,7 +143,7 @@ KityMinder.registerModule("LayoutDefault", function () {
} }
}; };
//初始化样式 //初始化样式
var initLayout = function (node) { var initLayout = function(node) {
var Layout = node.getLayout(); var Layout = node.getLayout();
var nodeType = node.getType(); var nodeType = node.getType();
var nodeStyle = nodeStyles[nodeType]; var nodeStyle = nodeStyles[nodeType];
...@@ -157,7 +157,7 @@ KityMinder.registerModule("LayoutDefault", function () { ...@@ -157,7 +157,7 @@ KityMinder.registerModule("LayoutDefault", function () {
} }
}; };
//根据内容调整节点尺寸 //根据内容调整节点尺寸
var updateShapeByCont = function (node) { var updateShapeByCont = function(node) {
var contRc = node.getContRc(); var contRc = node.getContRc();
var nodeType = node.getType(); var nodeType = node.getType();
var nodeStyle = nodeStyles[nodeType]; var nodeStyle = nodeStyles[nodeType];
...@@ -197,7 +197,7 @@ KityMinder.registerModule("LayoutDefault", function () { ...@@ -197,7 +197,7 @@ KityMinder.registerModule("LayoutDefault", function () {
contRc.translate(0, nodeStyle.padding[0] - rBox.top); contRc.translate(0, nodeStyle.padding[0] - rBox.top);
}; };
//计算节点在垂直方向的位置 //计算节点在垂直方向的位置
var updateLayoutVertical = function (node, parent, action) { var updateLayoutVertical = function(node, parent, action) {
var root = minder.getRoot(); var root = minder.getRoot();
var effectSet = [node]; var effectSet = [node];
if (action === "remove") { if (action === "remove") {
...@@ -208,10 +208,10 @@ KityMinder.registerModule("LayoutDefault", function () { ...@@ -208,10 +208,10 @@ KityMinder.registerModule("LayoutDefault", function () {
var nodeType = node.getType(); var nodeType = node.getType();
var nodeStyle = nodeStyles[nodeType]; var nodeStyle = nodeStyles[nodeType];
var appendside = Layout.appendside; var appendside = Layout.appendside;
var countBranchHeight = function (node, side) { var countBranchHeight = function(node, side) {
var nodeStyle = nodeStyles[node.getType()]; var nodeStyle = nodeStyles[node.getType()];
var selfHeight = node.getRenderContainer().getHeight() + nodeStyle.margin[0] + nodeStyle.margin[2]; var selfHeight = node.getRenderContainer().getHeight() + nodeStyle.margin[0] + nodeStyle.margin[2];
var childHeight = (function () { var childHeight = (function() {
var sum = 0; var sum = 0;
var children; var children;
if (!side) { if (!side) {
...@@ -257,12 +257,12 @@ KityMinder.registerModule("LayoutDefault", function () { ...@@ -257,12 +257,12 @@ KityMinder.registerModule("LayoutDefault", function () {
} }
} }
//自顶向下更新受影响一侧的y值 //自顶向下更新受影响一侧的y值
var updateSide = function (appendside) { var updateSide = function(appendside) {
var _buffer = [root]; var _buffer = [root];
while (_buffer.length > 0) { while (_buffer.length > 0) {
var _buffer0Layout = _buffer[0].getLayout(); var _buffer0Layout = _buffer[0].getLayout();
var children = _buffer0Layout[appendside + "List"] || _buffer[0].getChildren(); var children = _buffer0Layout[appendside + "List"] || _buffer[0].getChildren();
children = (function () { children = (function() {
var result = []; var result = [];
for (var len = 0; len < children.length; len++) { for (var len = 0; len < children.length; len++) {
var l = children[len].getLayout(); var l = children[len].getLayout();
...@@ -293,7 +293,7 @@ KityMinder.registerModule("LayoutDefault", function () { ...@@ -293,7 +293,7 @@ KityMinder.registerModule("LayoutDefault", function () {
return effectSet; return effectSet;
}; };
//计算节点在水平方向的位置 //计算节点在水平方向的位置
var updateLayoutHorizon = function (node) { var updateLayoutHorizon = function(node) {
var nodeType = node.getType(); var nodeType = node.getType();
var parent = node.getParent(); var parent = node.getParent();
var effectSet = [node]; var effectSet = [node];
...@@ -302,7 +302,7 @@ KityMinder.registerModule("LayoutDefault", function () { ...@@ -302,7 +302,7 @@ KityMinder.registerModule("LayoutDefault", function () {
while (_buffer.length !== 0) { while (_buffer.length !== 0) {
var prt = _buffer[0].getParent(); var prt = _buffer[0].getParent();
var children = _buffer[0].getChildren(); var children = _buffer[0].getChildren();
children = (function () { children = (function() {
var result = []; var result = [];
for (var len = 0; len < children.length; len++) { for (var len = 0; len < children.length; len++) {
var l = children[len].getLayout(); var l = children[len].getLayout();
...@@ -336,7 +336,7 @@ KityMinder.registerModule("LayoutDefault", function () { ...@@ -336,7 +336,7 @@ KityMinder.registerModule("LayoutDefault", function () {
} }
return effectSet; return effectSet;
}; };
var translateNode = function (node) { var translateNode = function(node) {
var Layout = node.getLayout(); var Layout = node.getLayout();
var nodeShape = node.getRenderContainer(); var nodeShape = node.getRenderContainer();
var align = Layout.align; var align = Layout.align;
...@@ -355,7 +355,7 @@ KityMinder.registerModule("LayoutDefault", function () { ...@@ -355,7 +355,7 @@ KityMinder.registerModule("LayoutDefault", function () {
} }
node.setPoint(Layout.x, Layout.y); node.setPoint(Layout.x, Layout.y);
}; };
var updateConnectAndshIcon = function (node) { var updateConnectAndshIcon = function(node) {
var nodeType = node.getType(); var nodeType = node.getType();
var Layout = node.getLayout(); var Layout = node.getLayout();
var nodeStyle = nodeStyles[node.getType()]; var nodeStyle = nodeStyles[node.getType()];
...@@ -439,10 +439,10 @@ KityMinder.registerModule("LayoutDefault", function () { ...@@ -439,10 +439,10 @@ KityMinder.registerModule("LayoutDefault", function () {
}; };
var _style = { var _style = {
getCurrentLayoutStyle: function () { getCurrentLayoutStyle: function() {
return nodeStyles; return nodeStyles;
}, },
initStyle: function () { initStyle: function() {
//渲染根节点 //渲染根节点
var _root = minder.getRoot(); var _root = minder.getRoot();
var historyPoint = _root.getPoint(); var historyPoint = _root.getPoint();
...@@ -486,7 +486,7 @@ KityMinder.registerModule("LayoutDefault", function () { ...@@ -486,7 +486,7 @@ KityMinder.registerModule("LayoutDefault", function () {
} }
_root.setPoint(_root.getLayout().x, _root.getLayout().y); _root.setPoint(_root.getLayout().x, _root.getLayout().y);
}, },
updateLayout: function (node) { updateLayout: function(node) {
node.getContRc().clear(); node.getContRc().clear();
this._firePharse(new MinderEvent("RenderNodeLeft", { this._firePharse(new MinderEvent("RenderNodeLeft", {
node: node node: node
...@@ -518,7 +518,7 @@ KityMinder.registerModule("LayoutDefault", function () { ...@@ -518,7 +518,7 @@ KityMinder.registerModule("LayoutDefault", function () {
this.highlightNode(node) this.highlightNode(node)
} }
}, },
expandNode: function (ico) { expandNode: function(ico) {
var isExpand, node; var isExpand, node;
if (ico instanceof MinderNode) { if (ico instanceof MinderNode) {
node = ico; node = ico;
...@@ -564,7 +564,7 @@ KityMinder.registerModule("LayoutDefault", function () { ...@@ -564,7 +564,7 @@ KityMinder.registerModule("LayoutDefault", function () {
} }
} }
}, },
appendChildNode: function (parent, node, sibling) { appendChildNode: function(parent, node, sibling) {
minder.handelNodeInsert(node); minder.handelNodeInsert(node);
node.clearLayout(); node.clearLayout();
node.getContRc().clear(); node.getContRc().clear();
...@@ -671,11 +671,11 @@ KityMinder.registerModule("LayoutDefault", function () { ...@@ -671,11 +671,11 @@ KityMinder.registerModule("LayoutDefault", function () {
var shicon = parent.getLayout().shicon; var shicon = parent.getLayout().shicon;
if (shicon) shicon.switchState(true); if (shicon) shicon.switchState(true);
}, },
appendSiblingNode: function (sibling, node) { appendSiblingNode: function(sibling, node) {
var parent = sibling.getParent(); var parent = sibling.getParent();
this.appendChildNode(parent, node, sibling); this.appendChildNode(parent, node, sibling);
}, },
removeNode: function (nodes) { removeNode: function(nodes) {
nodes = utils.isArray(nodes) ? nodes : [nodes]; nodes = utils.isArray(nodes) ? nodes : [nodes];
while (nodes.length !== 0) { while (nodes.length !== 0) {
var parent = nodes[0].getParent(); var parent = nodes[0].getParent();
...@@ -720,7 +720,7 @@ KityMinder.registerModule("LayoutDefault", function () { ...@@ -720,7 +720,7 @@ KityMinder.registerModule("LayoutDefault", function () {
} }
} }
}, },
highlightNode: function (node) { highlightNode: function(node) {
var highlight = node.isHighlight(); var highlight = node.isHighlight();
var nodeType = node.getType(); var nodeType = node.getType();
var nodeStyle = nodeStyles[nodeType]; var nodeStyle = nodeStyles[nodeType];
......
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