Commit f4ba8d37 authored by techird's avatar techird

fish-bone layout

parent 835f0d25
...@@ -75,6 +75,8 @@ ...@@ -75,6 +75,8 @@
{ path: 'src/theme/default.js', pack: 'edit|share|m-share' }, { path: 'src/theme/default.js', pack: 'edit|share|m-share' },
{ path: 'src/theme/snow.js', pack: 'edit|share|m-share' }, { path: 'src/theme/snow.js', pack: 'edit|share|m-share' },
{ path: 'src/theme/fresh.js', pack: 'edit|share|m-share' }, { path: 'src/theme/fresh.js', pack: 'edit|share|m-share' },
{ path: 'src/theme/fish.js', pack: 'edit|share|m-share' },
{ path: 'src/theme/wire.js', pack: 'edit|share|m-share' },
/* 模板 */ /* 模板 */
{ path: 'src/template/default.js', pack: 'edit|share|m-share' }, { path: 'src/template/default.js', pack: 'edit|share|m-share' },
......
...@@ -3,11 +3,14 @@ KityMinder.LANG['zh-cn'] = { ...@@ -3,11 +3,14 @@ KityMinder.LANG['zh-cn'] = {
'default': '思维导图', 'default': '思维导图',
'structure': '组织结构图', 'structure': '组织结构图',
'filetree': '目录组织图', 'filetree': '目录组织图',
'right': '逻辑结构图' 'right': '逻辑结构图',
'fish-bone': '鱼骨头图'
}, },
'theme': { 'theme': {
'classic': '脑图经典', 'classic': '脑图经典',
'snow': '温柔冷光', 'snow': '温柔冷光',
'fish': '鱼骨图',
'wire': '线框',
'fresh-red': '清新红', 'fresh-red': '清新红',
'fresh-soil': '泥土黄', 'fresh-soil': '泥土黄',
'fresh-green': '文艺绿', 'fresh-green': '文艺绿',
......
Subproject commit 8f52e73cc57a447f268e71783d44e34ee028f763 Subproject commit 36b51b090c28d9d362f00e1023fcb3dc6317585d
...@@ -250,9 +250,10 @@ kity.extendClass(Minder, { ...@@ -250,9 +250,10 @@ kity.extendClass(Minder, {
} }
var layout = node.getLayoutInstance(); var layout = node.getLayoutInstance();
layout.doLayout(node, node.getChildren().filter(function(child) { var childrenInFlow = node.getChildren().filter(function(child) {
return !child.hasLayoutOffset(); return !child.hasLayoutOffset();
}), round); });
layout.doLayout(node, childrenInFlow, round);
} }
// 第一轮布局 // 第一轮布局
...@@ -308,7 +309,7 @@ kity.extendClass(Minder, { ...@@ -308,7 +309,7 @@ kity.extendClass(Minder, {
} }
function apply(node, pMatrix) { function apply(node, pMatrix) {
var matrix = node.getLayoutTransform().merge(new kity.Matrix(1, 0, 0, 1, pMatrix.m.e, pMatrix.m.f)); var matrix = node.getLayoutTransform().merge(pMatrix);
var lastMatrix = node.getGlobalLayoutTransform() || new kity.Matrix(); var lastMatrix = node.getGlobalLayoutTransform() || new kity.Matrix();
var offset = node.getLayoutOffset(); var offset = node.getLayoutOffset();
......
/* global Layout:true */ /* global Layout:true */
KityMinder.registerLayout('filetree', kity.createClass({
[-1, 1].forEach(function (dir) {
var name = 'filetree-' + (dir > 0 ? 'down' : 'up');
KityMinder.registerLayout(name, kity.createClass({
base: Layout, base: Layout,
doLayout: function(parent, children) { doLayout: function(parent, children, round) {
var pBox = parent.getContentBox(); var pBox = parent.getContentBox();
var indent = 20; var indent = 20;
var vectorIn = parent.getLayoutVectorIn(); parent.setVertexOut(new kity.Point(pBox.left + indent, dir > 0 ? pBox.bottom : pBox.top));
parent.setLayoutVectorOut(new kity.Vector(0, dir));
parent.setVertexOut(new kity.Point(pBox.left + indent, pBox.bottom));
parent.setLayoutVectorOut(new kity.Vector(0, vectorIn.y > 0 ? 1 : -1));
if (!children.length) return; if (!children.length) return;
...@@ -31,7 +33,7 @@ KityMinder.registerLayout('filetree', kity.createClass({ ...@@ -31,7 +33,7 @@ KityMinder.registerLayout('filetree', kity.createClass({
var yAdjust = 0; var yAdjust = 0;
if (vectorIn.y > 0) { if (dir > 0) {
yAdjust += pBox.bottom; yAdjust += pBox.bottom;
yAdjust += parent.getStyle('margin-bottom'); yAdjust += parent.getStyle('margin-bottom');
yAdjust += children[0].getStyle('margin-top'); yAdjust += children[0].getStyle('margin-top');
...@@ -76,4 +78,6 @@ KityMinder.registerLayout('filetree', kity.createClass({ ...@@ -76,4 +78,6 @@ KityMinder.registerLayout('filetree', kity.createClass({
}); });
return hint; return hint;
} }
})); }));
\ No newline at end of file
});
\ No newline at end of file
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
KityMinder.registerLayout('fish-bone-master', kity.createClass('FishBoneMasterLayout', { KityMinder.registerLayout('fish-bone-master', kity.createClass('FishBoneMasterLayout', {
base: Layout, base: Layout,
doLayout: function(parent, children) { doLayout: function(parent, children, round) {
var upPart = [], var upPart = [],
downPart = []; downPart = [];
...@@ -52,8 +53,11 @@ KityMinder.registerLayout('fish-bone-master', kity.createClass('FishBoneMasterLa ...@@ -52,8 +53,11 @@ KityMinder.registerLayout('fish-bone-master', kity.createClass('FishBoneMasterLa
this.align(downPart, 'top'); this.align(downPart, 'top');
var xAdjust = pBox.right + pMarginRight + cMarginLeft; var xAdjust = pBox.right + pMarginRight + cMarginLeft;
this.move(upPart, xAdjust, -cBox.bottom - cMarginBottom); var yAdjustUp = pBox.cy - cMarginBottom - parent.getStyle('margin-top');
this.move(downPart, xAdjust + cMarginLeft, -cBox.top + cMarginTop); var yAdjustDown = pBox.cy + cMarginTop + parent.getStyle('margin-bottom');
this.move(upPart, xAdjust, yAdjustUp);
this.move(downPart, xAdjust + cMarginLeft, yAdjustDown);
// children.forEach(function(child, index) { // children.forEach(function(child, index) {
// var matrix = child.getLayoutTransform(); // var matrix = child.getLayoutTransform();
......
...@@ -12,27 +12,36 @@ KityMinder.registerLayout('fish-bone-slave', kity.createClass('FishBoneSlaveLayo ...@@ -12,27 +12,36 @@ KityMinder.registerLayout('fish-bone-slave', kity.createClass('FishBoneSlaveLayo
base: Layout, base: Layout,
doLayout: function (parent, children, round) { doLayout: function (parent, children, round) {
var layout = this; var layout = this;
var abs = Math.abs; var abs = Math.abs;
var GOLD_CUT = 1 - 0.618;
var pBox = parent.getContentBox(); var pBox = parent.getContentBox();
parent.setLayoutVectorOut(parent.getLayoutVectorIn()); var vi = parent.getLayoutVectorIn();
parent.setLayoutVectorOut(vi);
var goldX = pBox.left + pBox.width * GOLD_CUT;
var pout = new kity.Point(goldX, vi.y > 0 ? pBox.bottom : pBox.top);
parent.setVertexOut(pout);
var child = children[0]; var child = children[0];
if (!child) return; if (!child) return;
var cBox = child.getContentBox();
children.forEach(function(child, index) { children.forEach(function(child, index) {
child.setLayoutTransform(new kity.Matrix()); child.setLayoutTransform(new kity.Matrix());
child.setLayoutVectorIn(parent.getLayoutVectorOut()); child.setLayoutVectorIn(new kity.Vector(1, 0));
child.setVertexIn(new kity.Point(cBox.left, cBox.cy));
}); });
this.stack(children, 'y'); this.stack(children, 'y');
this.align(children, 'left'); this.align(children, 'left');
var cBox = child.getContentBox();
var xAdjust = 0, yAdjust = 0; var xAdjust = 0, yAdjust = 0;
xAdjust += cBox.left; xAdjust += pout.x;
if (parent.getLayoutVectorOut().y < 0) { if (parent.getLayoutVectorOut().y < 0) {
yAdjust -= this.getTreeBox(children).bottom; yAdjust -= this.getTreeBox(children).bottom;
...@@ -49,8 +58,10 @@ KityMinder.registerLayout('fish-bone-slave', kity.createClass('FishBoneSlaveLayo ...@@ -49,8 +58,10 @@ KityMinder.registerLayout('fish-bone-slave', kity.createClass('FishBoneSlaveLayo
if (round == 2) { if (round == 2) {
children.forEach(function(child) { children.forEach(function(child) {
var m = child.getLayoutTransform().getMatrix(); var m = child.getLayoutTransform();
layout.move([child], abs(m.f), 0); var cbox = child.getContentBox();
var pin = m.transformPoint(new kity.Point(cbox.left, 0));
layout.move([child], abs(pin.y - pout.y), 0);
}); });
} }
} }
......
...@@ -69,7 +69,7 @@ marker.setHeight(12); ...@@ -69,7 +69,7 @@ marker.setHeight(12);
marker.setRef(0, 0); marker.setRef(0, 0);
marker.setViewBox(-6, -4, 8, 10); marker.setViewBox(-6, -4, 8, 10);
marker.addShape(new kity.Path().setPathData('M-5-3l5,3,-5,3').stroke('rgb(0, 220, 255)')); marker.addShape(new kity.Path().setPathData('M-5-3l5,3,-5,3').stroke('#33ffff'));
var wireframeOption = /wire/.test(window.location.href); var wireframeOption = /wire/.test(window.location.href);
var WireframeRenderer = kity.createClass('WireframeRenderer', { var WireframeRenderer = kity.createClass('WireframeRenderer', {
...@@ -84,15 +84,15 @@ var WireframeRenderer = kity.createClass('WireframeRenderer', { ...@@ -84,15 +84,15 @@ var WireframeRenderer = kity.createClass('WireframeRenderer', {
var box = this.wireframe = new kity.Rect() var box = this.wireframe = new kity.Rect()
.stroke('lightgreen'); .stroke('lightgreen');
var vectorIn = this.vectorIn = new kity.Line() var vectorIn = this.vectorIn = new kity.Path()
.stroke('rgb(0, 220, 255)'); .stroke('#66ffff');
var vectorOut = this.vectorOut = new kity.Line() var vectorOut = this.vectorOut = new kity.Path()
.stroke('rgb(0, 220, 255)'); .stroke('#66ffff');
vectorIn.setMarker(marker, 'end'); vectorIn.setMarker(marker, 'end');
vectorOut.setMarker(marker, 'end'); vectorOut.setMarker(marker, 'end');
return wireframe.addShapes([oxy, box, vectorIn]); return wireframe.addShapes([oxy, box, vectorIn, vectorOut]);
}, },
shouldRender: function() { shouldRender: function() {
...@@ -103,10 +103,12 @@ var WireframeRenderer = kity.createClass('WireframeRenderer', { ...@@ -103,10 +103,12 @@ var WireframeRenderer = kity.createClass('WireframeRenderer', {
this.wireframe this.wireframe
.setPosition(box.x, box.y) .setPosition(box.x, box.y)
.setSize(box.width, box.height); .setSize(box.width, box.height);
var pin = node.getLayoutVectorIn().normalize(50); var pin = node.getVertexIn();
var pout = node.getLayoutVectorOut().normalize(50); var pout = node.getVertexOut();
this.vectorIn.setPoint1(-pin.x, -pin.y); var vin = node.getLayoutVectorIn().normalize(30);
this.vectorOut.setPoint2(pout.x, pout.y); var vout = node.getLayoutVectorOut().normalize(30);
this.vectorIn.setPathData(['M', pin.offset(vin.reverse()), 'L', pin]);
this.vectorOut.setPathData(['M', pout, 'l', vout]);
} }
}); });
......
...@@ -13,7 +13,7 @@ KityMinder.registerTemplate('filetree', { ...@@ -13,7 +13,7 @@ KityMinder.registerTemplate('filetree', {
if (node.getData('layout')) return node.getData('layout'); if (node.getData('layout')) return node.getData('layout');
if (node.isRoot()) return 'bottom'; if (node.isRoot()) return 'bottom';
return 'filetree'; return 'filetree-down';
}, },
getConnect: function(node) { getConnect: function(node) {
......
...@@ -25,14 +25,14 @@ KityMinder.registerTemplate('fish-bone', { ...@@ -25,14 +25,14 @@ KityMinder.registerTemplate('fish-bone', {
return 'fish-bone-slave'; return 'fish-bone-slave';
} }
return 'right'; return node.getLayoutPointPreview().y > 0 ? 'filetree-up': 'filetree-down';
}, },
getConnect: function(node) { getConnect: function(node) {
switch (node.getLevel()) { switch (node.getLevel()) {
case 1: return 'fish-bone-master'; case 1: return 'fish-bone-master';
case 2: return 'line'; case 2: return 'line';
default: return 'under'; default: return 'l';
} }
} }
}); });
\ No newline at end of file
KityMinder.registerTheme('fish', {
'background': '#3A4144 url(ui/theme/default/images/grid.png) repeat',
'root-color': '#430',
'root-background': '#e9df98',
'root-stroke': '#e9df98',
'root-font-size': 24,
'root-padding': [35, 35],
'root-margin': 30,
'root-radius': 100,
'root-space': 10,
'root-shadow': 'rgba(0, 0, 0, .25)',
'main-color': '#333',
'main-background': '#a4c5c0',
'main-stroke': '#a4c5c0',
'main-font-size': 16,
'main-padding': [6, 20],
'main-margin': [20, 20],
'main-radius': 5,
'main-space': 5,
'main-shadow': 'rgba(0, 0, 0, .25)',
'sub-color': 'black',
'sub-background': 'white',
'sub-stroke': 'white',
'sub-font-size': 12,
'sub-padding': [5, 10],
'sub-margin': [10],
'sub-radius': 5,
'sub-space': 5,
'connect-color': 'white',
'connect-width': 3,
'main-connect-width': 3,
'connect-radius': 5,
'selected-background': 'rgb(254, 219, 0)',
'selected-stroke': 'rgb(254, 219, 0)',
'marquee-background': 'rgba(255,255,255,.3)',
'marquee-stroke': 'white',
'drop-hint-color': 'yellow',
'drop-hint-width': 4,
'order-hint-area-color': 'rgba(0, 255, 0, .5)',
'order-hint-path-color': '#0f0',
'order-hint-path-width': 1,
'text-selection-color': 'rgb(27,171,255)',
'line-height':1.5
});
\ No newline at end of file
KityMinder.registerTheme('wire', {
'background': 'black',
'color': '#999',
'stroke': 'none',
'padding': 10,
'margin': 20,
'font-size': 14,
'connect-color': '#999',
'connect-width': 1,
'selected-background': '#999',
'selected-color': 'black',
'marquee-background': 'rgba(255,255,255,.3)',
'marquee-stroke': 'white',
'drop-hint-color': 'yellow',
'sub-drop-hint-width': 2,
'main-drop-hint-width': 4,
'root-drop-hint-width': 4,
'order-hint-area-color': 'rgba(0, 255, 0, .5)',
'order-hint-path-color': '#0f0',
'order-hint-path-width': 1,
'text-selection-color': 'rgb(27,171,255)',
'line-height':1.5
});
\ No newline at end of file
...@@ -20,10 +20,6 @@ KityMinder.registerUI('menu/share/share', function(minder) { ...@@ -20,10 +20,6 @@ KityMinder.registerUI('menu/share/share', function(minder) {
var BACKEND_URL = 'http://naotu.baidu.com/share.php'; var BACKEND_URL = 'http://naotu.baidu.com/share.php';
if (window.location.host == 'local.host') {
BACKEND_URL = 'http://naotu.baidu.com/share_debug.php'; // 测试环境
}
var currentShare = null; var currentShare = null;
var shareList = []; var shareList = [];
......
...@@ -57,6 +57,10 @@ ...@@ -57,6 +57,10 @@
background-position: -300px 0; background-position: -300px 0;
} }
&.fish-bone:after {
background-position: -400px 0;
}
&:hover { &:hover {
a { a {
color: @main-menu-theme-color; color: @main-menu-theme-color;
......
...@@ -60,6 +60,10 @@ ...@@ -60,6 +60,10 @@
&.right .fui-icon { &.right .fui-icon {
background-position: -150px 0; background-position: -150px 0;
} }
&.fish-bone .fui-icon {
background-position: -200px 0;
}
} }
.fui-button.theme { .fui-button.theme {
......
ui/theme/default/images/template.png

1.54 KB | W: | H:

ui/theme/default/images/template.png

1.83 KB | W: | H:

ui/theme/default/images/template.png
ui/theme/default/images/template.png
ui/theme/default/images/template.png
ui/theme/default/images/template.png
  • 2-up
  • Swipe
  • Onion skin
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