Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kityminder-core
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
吴志俊
kityminder-core
Commits
d0235692
Commit
d0235692
authored
Jun 10, 2014
by
Akikonata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added layout bottom
parent
55e95213
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
160 additions
and
0 deletions
+160
-0
bottom.js
src/layout/bottom.js
+126
-0
bottom.js
src/theme/bottom.js
+34
-0
No files found.
src/layout/bottom.js
0 → 100644
View file @
d0235692
/* global Layout:true */
window
.
layoutSwitch
=
true
;
KityMinder
.
registerLayout
(
'bottom'
,
kity
.
createClass
({
base
:
Layout
,
doLayout
:
function
(
node
)
{
var
layout
=
this
;
if
(
node
.
isLayoutRoot
())
{
this
.
doLayoutRoot
(
node
);
}
else
{
this
.
arrange
(
node
);
}
},
doLayoutRoot
:
function
(
root
)
{
this
.
arrange
(
root
);
},
arrange
:
function
(
node
)
{
var
children
=
node
.
getChildren
();
var
_this
=
this
;
if
(
!
children
.
length
)
{
return
false
;
}
else
{
var
totalTreeWidth
=
0
;
// 计算每个 child 的树所占的矩形区域
var
childTreeBoxes
=
children
.
map
(
function
(
node
,
index
,
children
)
{
var
box
=
_this
.
getTreeBox
([
node
]);
totalTreeWidth
+=
box
.
width
;
if
(
index
>
0
)
{
totalTreeWidth
+=
children
[
index
-
1
].
getStyle
(
'margin-left'
);
totalTreeWidth
+=
node
.
getStyle
(
'margin-right'
);
}
return
box
;
});
var
nodeContentBox
=
node
.
getContentBox
();
var
i
,
x
,
y
,
child
,
childTreeBox
,
childContentBox
;
var
transform
=
new
kity
.
Matrix
();
x
=
-
totalTreeWidth
/
2
;
for
(
var
i
=
0
;
i
<
children
.
length
;
i
++
)
{
child
=
children
[
i
];
childTreeBox
=
childTreeBoxes
[
i
];
childContentBox
=
child
.
getContentBox
();
if
(
!
childContentBox
.
width
)
continue
;
//水平方向上的布局
x
+=
childTreeBox
.
width
/
2
;
if
(
i
>
1
)
{
x
+=
children
[
i
].
getStyle
(
'margin-left'
);
}
y
=
nodeContentBox
.
height
+
node
.
getStyle
(
'margin-bottom'
)
+
children
[
i
].
getStyle
(
'margin-top'
);
console
.
log
(
y
);
children
[
i
].
setLayoutTransform
(
new
kity
.
Matrix
().
translate
(
x
,
y
));
x
+=
childTreeBox
.
width
/
2
+
children
[
i
].
getStyle
(
'margin-right'
);
}
}
// if (!children.length) return;
// var _this = this;
// // children 所占的总树高
// var totalTreeHeight = 0;
// // 计算每个 child 的树所占的矩形区域
// var childTreeBoxes = children.map(function(node, index, children) {
// var box = _this.getTreeBox([node]);
// // 计算总树高,需要把竖直方向上的 margin 加入计算
// totalTreeHeight += box.height;
// if (index > 0) {
// totalTreeHeight += children[index - 1].getStyle('margin-bottom');
// totalTreeHeight += node.getStyle('margin-top');
// }
// return box;
// });
// var nodeContentBox = parent.getContentBox();
// var i, x, y, child, childTreeBox, childContentBox;
// var transform = new kity.Matrix();
// y = -totalTreeHeight / 2 - 200;
// for (i = 0; i < children.length; i++) {
// child = children[i];
// childTreeBox = childTreeBoxes[i];
// childContentBox = child.getContentBox();
// if (!childContentBox.height) continue;
// // 水平方向上的布局
// if (side == 'right') {
// x = nodeContentBox.right - childContentBox.left;
// x += parent.getStyle('margin-right') + child.getStyle('margin-left');
// child.setLayoutVector(new kity.Vector(childContentBox.left, childContentBox.cy));
// } else {
// x = nodeContentBox.left - childContentBox.right;
// x -= parent.getStyle('margin-left') + child.getStyle('margin-right');
// child.setLayoutVector(new kity.Vector(childContentBox.right, childContentBox.cy));
// }
// // 竖直方向上的布局
// y += childTreeBox.height / 2;
// if (i > 0) {
// y += children[i].getStyle('margin-top');
// }
// children[i].setLayoutTransform(new kity.Matrix().translate(x, y));
// y += childTreeBox.height / 2 + children[i].getStyle('margin-bottom');
// }
// if (parent.isRoot()) {
// var branchBox = this.getBranchBox(children);
// var dy = branchBox.cy - nodeContentBox.cy;
// children.forEach(function(child) {
// child.getLayoutTransform().translate(0, -dy);
// });
// }
// }
}
}));
\ No newline at end of file
src/theme/bottom.js
0 → 100644
View file @
d0235692
KityMinder
.
registerTheme
(
'bottom'
,
{
'root-color'
:
'#430'
,
'root-background'
:
'#e9df98'
,
'root-stroke'
:
'none'
,
'root-font-size'
:
24
,
'root-padding'
:
[
15
,
25
],
'root-margin'
:
100
,
'root-radius'
:
30
,
'root-space'
:
10
,
'main-color'
:
'#333'
,
'main-background'
:
'#a4c5c0'
,
'main-stroke'
:
'none'
,
'main-font-size'
:
16
,
'main-padding'
:
[
6
,
20
],
'main-margin'
:
[
30
,
0
,
10
,
0
],
'main-radius'
:
10
,
'main-space'
:
5
,
'sub-color'
:
'white'
,
'sub-background'
:
'none'
,
'sub-stroke'
:
'white'
,
'sub-font-size'
:
12
,
'sub-padding'
:
[
5
,
10
],
'sub-margin'
:
[
5
,
15
,
10
,
5
],
'sub-radius'
:
5
,
'sub-space'
:
5
,
'connect-color'
:
'white'
,
'connect-width'
:
2
,
'connect-radius'
:
5
,
'selected-background'
:
'rgb(254, 219, 0)'
});
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment