Commit 730566aa authored by techird's avatar techird

stash

parent df4b9823
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
'core/theme.js', 'core/theme.js',
'layout/default.js', 'layout/default.js',
'theme/default.js', 'theme/default.js',
'module/node.js',
'module/text.js',
'module/outline.js', 'module/outline.js',
'module/geometry.js', 'module/geometry.js',
'module/history.js', 'module/history.js',
......
Subproject commit 093f66727667709bbf9054670c9b0cb20bb31998 Subproject commit 62a846c829a0306ba7493885b44c38d68cd3d232
var Layout = kity.createClass('Layout', { var Layout = kity.createClass('Layout', {
doLayout: function(node) { doLayout: function(node) {
throw new Error('Not Implement: Layout.doLayout()'); throw new Error('Not Implement: Layout.doLayout()');
},
getBranchBox: function(nodes) {
var box = {
x: 0,
y: 0,
height: 0,
width: 0
};
var g = KityMinder.Geometry;
var i, node, matrix, contentBox;
for (i = 0; i < nodes.length; i++) {
node = nodes[i];
matrix = node.getLayoutTransform();
contentBox = node.getContentBox();
box = g.mergeBox(box, matrix.transformBox(contentBox));
}
return box;
},
getTreeBox: function(nodes) {
var box = {
x: 0,
y: 0,
height: 0,
width: 0
};
var g = KityMinder.Geometry;
var i, node, matrix, treeBox;
for (i = 0; i < nodes.length; i++) {
node = nodes[i];
matrix = node.getLayoutTransform();
treeBox = node.getContentBox();
if (node.children.length) {
treeBox = g.mergeBox(treeBox, this.getTreeBox(node.children));
}
box = g.mergeBox(box, matrix.transformBox(treeBox));
}
return box;
} }
}); });
...@@ -24,31 +67,101 @@ kity.extendClass(MinderNode, { ...@@ -24,31 +67,101 @@ kity.extendClass(MinderNode, {
return layout; return layout;
}, },
applyLayoutResult: function (parentX, parentY) { setLayoutTransform: function(matrix) {
var myX = parentX + this.layoutX, this._layoutTransform = matrix;
myY = parentY + this.layoutY; },
this.getRenderContainer().fxTranslate(myX, myY);
this.getChildren().forEach(function(node) { getLayoutTransform: function() {
node.applyLayoutResult(myX, myY); return this._layoutTransform || new kity.Matrix();
}); },
getLayoutRoot: function() {
if (this.isLayoutRoot()) {
return this;
}
return this.parent.getLayoutRoot();
}, },
layout: function(name) { isLayoutRoot: function() {
return this.getData('layout') || this.isRoot();
},
layout: function(name, duration) {
if (name) { if (name) {
this.setData('layout', name); if (name == 'inherit') {
this.setData('layout');
} else {
this.setData('layout', name);
}
} }
var LayoutClass = KityMinder._layout[this.getLayout()];
var layout = new LayoutClass(); this.getMinder().layout(duration);
layout.doLayout(this);
this.applyLayoutResult(0, 0);
return this; return this;
}, }
});
kity.extendClass(Minder, {
layout: function(duration) {
getTreeBox: function() { this.getRoot().traverse(function(node) {
var box = this.getContentBox(); node.setLayoutTransform(null);
this.getChildren().forEach(function(child) {
box = KityMinder.Geometry.mergeBox(child.getTreeBox(), box);
}); });
return box;
} function layoutNode(node) {
// layout all children first
node.children.forEach(function(child) {
layoutNode(child);
});
var LayoutClass = KityMinder._layout[node.getLayout()];
var layout = new LayoutClass();
layout.doLayout(node);
}
layoutNode(this.getRoot());
return this.applyLayoutResult(duration);
},
applyLayoutResult: function(duration) {
var root = this.getRoot();
function apply(node, pMatrix) {
var matrix = node.getLayoutTransform().merge(pMatrix);
var lastMatrix = node._lastLayoutTransform || new kity.Matrix();
if (!matrix.equals(lastMatrix)) {
// 如果当前有动画,停止动画
if (node._layoutTimeline) {
node._layoutTimeline.stop();
delete node._layoutTimeline;
}
// 如果要求以动画形式来更新,创建动画
if (duration > 0) {
node._layoutTimeline = new kity.Animator(lastMatrix, matrix, function(rc, value) {
rc.setMatrix(node._lastLayoutTransform = value);
}).start(node.getRenderContainer(), duration, 'ease');
}
// 否则直接更新
else {
node.getRenderContainer().setMatrix(matrix);
node._lastLayoutTransform = matrix;
}
}
for (var i = 0; i < node.children.length; i++) {
apply(node.children[i], matrix);
}
}
apply(root, new kity.Matrix());
return this;
},
}); });
\ No newline at end of file
...@@ -26,7 +26,12 @@ kity.extendClass(Minder, { ...@@ -26,7 +26,12 @@ kity.extendClass(Minder, {
if (!modulesPool[name]) continue; if (!modulesPool[name]) continue;
// 执行模块初始化,抛出后续处理对象 // 执行模块初始化,抛出后续处理对象
moduleDeals = modulesPool[name].call(me);
if (typeof(modulesPool[name]) == 'function') {
moduleDeals = modulesPool[name].call(me);
} else {
moduleDeals = modulesPool[name];
}
this._modules[name] = moduleDeals; this._modules[name] = moduleDeals;
if (moduleDeals.init) { if (moduleDeals.init) {
......
...@@ -32,8 +32,8 @@ kity.extendClass(Minder, { ...@@ -32,8 +32,8 @@ kity.extendClass(Minder, {
this.renderChangedSelection(nodes); this.renderChangedSelection(nodes);
return this; return this;
}, },
select: function(nodes, isToggleSelect) { select: function(nodes, isSingleSelect) {
if (isToggleSelect) { if (isSingleSelect) {
this.removeAllSelectedNodes(); this.removeAllSelectedNodes();
} }
var me = this; var me = this;
......
...@@ -93,7 +93,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', { ...@@ -93,7 +93,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', {
* @param {String} text 文本数据 * @param {String} text 文本数据
*/ */
setText: function(text) { setText: function(text) {
this.setData('text', text); return this.setData('text', text);
}, },
/** /**
...@@ -207,6 +207,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', { ...@@ -207,6 +207,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', {
this.data[name] = value; this.data[name] = value;
} }
} }
return this;
}, },
getRenderContainer: function() { getRenderContainer: function() {
......
...@@ -88,10 +88,10 @@ kity.extendClass(Minder, { ...@@ -88,10 +88,10 @@ kity.extendClass(Minder, {
if (item in theme) { if (item in theme) {
value = theme[item]; value = theme[item];
if (!isNaN(value)) return value;
if (Utils.isArray(value) && (matcher = cssLikeValueMatcher[dir])) { if (Utils.isArray(value) && (matcher = cssLikeValueMatcher[dir])) {
return matcher(value); return matcher(value);
} }
if (!isNaN(value)) return value;
} }
return null; return null;
......
...@@ -3,18 +3,89 @@ ...@@ -3,18 +3,89 @@
KityMinder.registerLayout('default', kity.createClass({ KityMinder.registerLayout('default', kity.createClass({
base: Layout, base: Layout,
getSide: function(node) {
while (!node.parent.isLayoutRoot()) {
node = node.parent;
}
var mainIndex = node.getIndex();
return {
0: 'right',
1: 'right',
2: 'left',
3: 'left'
}[mainIndex] || (mainIndex % 2 ? 'right' : 'left');
},
doLayout: function(node) { doLayout: function(node) {
node.getChildren().forEach(function(childNode) { var layout = this;
childNode.layout();
}); function arrange(node, children, side) {
var y = 0; //if (!children.length) return;
node.getChildren().forEach(function(childNode) {
childNode.layoutX = node.getContentBox().right - childNode.getContentBox().x + node.getStyle('margin-right'); var height = 0;
childNode.layoutY = y;
y += 50; var childBoxes = children.map(function(node, index, children) {
console.log(childNode.layoutX, childNode.layoutY); var box = layout.getTreeBox([node]);
}); height += box.height;
node.layoutX = 0; if (index > 0) {
node.layoutY = 0; height += children[index - 1].getStyle('margin-bottom');
height += node.getStyle('margin-top');
}
return box;
});
var contentBox = node.getContentBox();
var x, y = -height / 2;
for (var i = 0; i < children.length; i++) {
if (side == 'right') {
x = contentBox.x + contentBox.width - children[i].getContentBox().x;
x += node.getStyle('margin-right') + node.children[i].getStyle('margin-left');
} else {
x = contentBox.x - children[i].getContentBox().width - children[i].getContentBox().x;
x -= node.getStyle('margin-left') + node.children[i].getStyle('margin-right');
}
y += childBoxes[i].height / 2;
if (i > 0) {
y += children[i].getStyle('margin-top');
}
children[i].setLayoutTransform(new kity.Matrix().translate(x, y));
y += childBoxes[i].height / 2 + children[i].getStyle('margin-bottom');
}
var branchBox = layout.getBranchBox(children);
var dy = (branchBox.y + branchBox.height / 2) - (contentBox.y + contentBox.height / 2);
for (i = 0; i < children.length; i++) {
children[i].getLayoutTransform().translate(0, -dy);
}
}
function layoutRoot(node) {
var mains = node.getChildren();
var group = {
left: [],
right: []
};
mains.forEach(function(main) {
group[layout.getSide(main)].push(main);
});
arrange(node, group.left, 'left');
arrange(node, group.right, 'right');
}
if (node.isLayoutRoot()) {
layoutRoot(node);
} else {
arrange(node, node.children, layout.getSide(node));
}
} }
})); }));
\ No newline at end of file
KityMinder.registerModule("basestylemodule", function() { KityMinder.registerModule('basestylemodule', function() {
var km = this; var km = this;
return { return {
"commands": { 'commands': {
"bold": kity.createClass("boldCommand", { 'bold': kity.createClass('boldCommand', {
base: Command, base: Command,
execute: function() { execute: function(km) {
var nodes = km.getSelectedNodes(); var nodes = km.getSelectedNodes();
if (this.queryState('bold') == 1) { if (this.queryState('bold') == 1) {
utils.each(nodes, function(i, n) { utils.each(nodes, function(i, n) {
n.setData('bold'); n.setData('font-weight').render();
n.getTextShape().setAttr('font-weight');
km.updateLayout(n);
}); });
} else { } else {
utils.each(nodes, function(i, n) { utils.each(nodes, function(i, n) {
n.setData('bold', true); n.setData('font-weight', 'bold').render();
n.getTextShape().setAttr('font-weight', 'bold');
km.updateLayout(n);
}); });
} }
km.layout();
}, },
queryState: function() { queryState: function() {
var nodes = km.getSelectedNodes(), var nodes = km.getSelectedNodes(),
...@@ -29,7 +26,7 @@ KityMinder.registerModule("basestylemodule", function() { ...@@ -29,7 +26,7 @@ KityMinder.registerModule("basestylemodule", function() {
return -1; return -1;
} }
utils.each(nodes, function(i, n) { utils.each(nodes, function(i, n) {
if (n && n.getData('bold')) { if (n && n.getData('font-weight')) {
result = 1; result = 1;
return false; return false;
} }
...@@ -37,25 +34,23 @@ KityMinder.registerModule("basestylemodule", function() { ...@@ -37,25 +34,23 @@ KityMinder.registerModule("basestylemodule", function() {
return result; return result;
} }
}), }),
"italic": kity.createClass("italicCommand", { 'italic': kity.createClass('italicCommand', {
base: Command, base: Command,
execute: function() { execute: function(km) {
var nodes = km.getSelectedNodes(); var nodes = km.getSelectedNodes();
if (this.queryState('italic') == 1) { if (this.queryState('italic') == 1) {
utils.each(nodes, function(i, n) { utils.each(nodes, function(i, n) {
n.setData('italic'); n.setData('font-style').render();
n.getTextShape().setAttr('font-style');
km.updateLayout(n);
}); });
} else { } else {
utils.each(nodes, function(i, n) { utils.each(nodes, function(i, n) {
n.setData('italic', true); n.setData('font-style', 'italic').render();
n.getTextShape().setAttr('font-style', 'italic');
km.updateLayout(n);
}); });
} }
km.layout();
}, },
queryState: function() { queryState: function() {
var nodes = km.getSelectedNodes(), var nodes = km.getSelectedNodes(),
...@@ -64,7 +59,7 @@ KityMinder.registerModule("basestylemodule", function() { ...@@ -64,7 +59,7 @@ KityMinder.registerModule("basestylemodule", function() {
return -1; return -1;
} }
utils.each(nodes, function(i, n) { utils.each(nodes, function(i, n) {
if (n && n.getData('italic')) { if (n && n.getData('font-style')) {
result = 1; result = 1;
return false; return false;
} }
...@@ -74,20 +69,8 @@ KityMinder.registerModule("basestylemodule", function() { ...@@ -74,20 +69,8 @@ KityMinder.registerModule("basestylemodule", function() {
}) })
}, },
addShortcutKeys: { addShortcutKeys: {
"bold": "ctrl+b", //bold 'bold': 'ctrl+b', //bold
"italic": "ctrl+i" //italic 'italic': 'ctrl+i' //italic
},
"events": {
"afterrendernodecenter": function(e) {
//加粗
if (e.node.getData('bold')) {
e.node.getTextShape().setAttr('font-weight', 'bold');
}
if (e.node.getData('italic')) {
e.node.getTextShape().setAttr('font-style', 'italic');
}
}
} }
}; };
}); });
\ No newline at end of file
This diff is collapsed.
...@@ -345,32 +345,6 @@ KityMinder.registerModule('TextEditModule', function() { ...@@ -345,32 +345,6 @@ KityMinder.registerModule('TextEditModule', function() {
'textedit.mousewheel': function() { 'textedit.mousewheel': function() {
receiver.setContainerStyle(); receiver.setContainerStyle();
} }
},
'renderers': {
center: kity.createClass('TextRenderer', {
base: Renderer,
create: function(node) {
var textShape = new kity.Text()
.setVerticalAlign('middle')
.setId(KityMinder.uuid('node_text'));
node.getRenderContainer().addShape(textShape);
node.getTextShape = function() {
return textShape;
};
},
update: function(node) {
return node.getTextShape()
.setContent(node.getText())
.setFont({
family: node.getStyle('font-family'),
size: node.getStyle('font-size')
})
.fill(node.getData('color') || node.getStyle('color'))
.getBoundaryBox();
}
})
} }
}; };
}); });
\ No newline at end of file
This diff is collapsed.
KityMinder.registerModule( "fontmodule", function () { KityMinder.registerModule("fontmodule", function() {
return { return {
defaultOptions: { defaultOptions: {
'fontfamily': [ { 'fontfamily': [{
name: 'songti', name: 'songti',
val: '宋体,SimSun' val: '宋体,SimSun'
}, { }, {
...@@ -38,100 +38,82 @@ KityMinder.registerModule( "fontmodule", function () { ...@@ -38,100 +38,82 @@ KityMinder.registerModule( "fontmodule", function () {
}, { }, {
name: 'sans-serif', name: 'sans-serif',
val: 'sans-serif' val: 'sans-serif'
} ], }],
'fontsize': [ 10, 12, 16, 18, 24, 32, 48 ] 'fontsize': [10, 12, 16, 18, 24, 32, 48]
}, },
"commands": { "commands": {
"forecolor": kity.createClass( "fontcolorCommand", { "forecolor": kity.createClass("fontcolorCommand", {
base: Command, base: Command,
execute: function ( km, color ) { execute: function(km, color) {
var nodes = km.getSelectedNodes(); var nodes = km.getSelectedNodes();
utils.each( nodes, function ( i, n ) { utils.each(nodes, function(i, n) {
n.setData( 'fontcolor', color ); n.setData('color', color);
n.getTextShape().fill( color ) n.render();
} ) });
}, },
queryState:function(km){ queryState: function(km) {
return km.getSelectedNodes().length == 0 ? -1 : 0 return km.getSelectedNodes().length == 0 ? -1 : 0
}, },
queryValue: function(km) { queryValue: function(km) {
if (km.getSelectedNodes().length == 1) { if (km.getSelectedNodes().length == 1) {
return km.getSelectedNodes()[0].getData('fontcolor'); return km.getSelectedNodes()[0].getData('color');
} }
return 'mixed'; return 'mixed';
} }
} ), }),
"backgroundcolor": kity.createClass( "backgroudcolorCommand", { "backgroundcolor": kity.createClass("backgroudcolorCommand", {
base: Command, base: Command,
execute: function ( km, color ) { execute: function(km, color) {
var nodes = km.getSelectedNodes(); var nodes = km.getSelectedNodes();
utils.each( nodes, function ( i, n ) { utils.each(nodes, function(i, n) {
n.setData( 'backgroundcolor', color ); n.setData('background', color);
n.getLayout().bgRect.fill( color ); n.render();
} ); });
}, },
queryState:function(km){ queryState: function(km) {
return km.getSelectedNodes().length == 0 ? -1 : 0 return km.getSelectedNodes().length == 0 ? -1 : 0
}, },
queryValue: function (km) { queryValue: function(km) {
if (km.getSelectedNodes().length == 1) { if (km.getSelectedNodes().length == 1) {
return km.getSelectedNodes()[0].getData('backgroundcolor'); return km.getSelectedNodes()[0].getData('background');
} }
return 'mixed'; return 'mixed';
} }
} ), }),
"fontfamily": kity.createClass( "fontfamilyCommand", { "fontfamily": kity.createClass("fontfamilyCommand", {
base: Command, base: Command,
execute: function ( km, family ) { execute: function(km, family) {
var nodes = km.getSelectedNodes(); var nodes = km.getSelectedNodes();
utils.each( nodes, function ( i, n ) { utils.each(nodes, function(i, n) {
n.setData( 'fontfamily', family ); n.setData('font-family', family);
n.getTextShape().setAttr( 'font-family', family ); n.render();
km.updateLayout( n ) km.layout();
} ) });
}, },
queryState:function(km){ queryState: function(km) {
return km.getSelectedNodes().length == 0 ? -1 : 0 return km.getSelectedNodes().length == 0 ? -1 : 0
} }
} ), }),
"fontsize": kity.createClass( "fontsizeCommand", { "fontsize": kity.createClass("fontsizeCommand", {
base: Command, base: Command,
execute: function ( km, size ) { execute: function(km, size) {
var nodes = km.getSelectedNodes(); var nodes = km.getSelectedNodes();
utils.each( nodes, function ( i, n ) { utils.each(nodes, function(i, n) {
n.setData( 'fontsize', size ); n.setData('font-size', size);
n.getTextShape().setSize( size ); n.render();
km.updateLayout( n ) km.layout(300);
} ) });
}, },
queryState:function(km){ queryState: function(km) {
return km.getSelectedNodes().length == 0 ? -1 : 0 return km.getSelectedNodes().length == 0 ? -1 : 0
} }
} ) })
},
"events": {
"afterrendernodecenter": function ( e ) {
var val;
if ( val = e.node.getData( 'fontfamily' ) ) {
e.node.getTextShape().setAttr( 'font-family', val );
}
if ( val = e.node.getData( 'fontcolor' ) ) {
e.node.getTextShape().fill( val );
}
if ( val = e.node.getData( 'backgroundcolor' ) ) {
e.node.getLayout().bgRect.fill( val );
}
if ( val = e.node.getData( 'fontsize' ) ) {
e.node.getTextShape().setSize( val );
}
}
} }
}; };
} ); });
\ No newline at end of file \ No newline at end of file
...@@ -127,6 +127,7 @@ KityMinder.registerModule("KeyboardModule", function() { ...@@ -127,6 +127,7 @@ KityMinder.registerModule("KeyboardModule", function() {
km.select(nextNode, true); km.select(nextNode, true);
} }
} }
return { return {
'events': { 'events': {
...@@ -137,26 +138,27 @@ KityMinder.registerModule("KeyboardModule", function() { ...@@ -137,26 +138,27 @@ KityMinder.registerModule("KeyboardModule", function() {
var keys = KityMinder.keymap; var keys = KityMinder.keymap;
var node = e.getTargetNode(); var node = e.getTargetNode();
var lang = this.getLang();
this.receiver.keydownNode = node; this.receiver.keydownNode = node;
switch (e.originEvent.keyCode) { switch (e.originEvent.keyCode) {
case keys.Enter: case keys.Enter:
this.execCommand('appendSiblingNode', new MinderNode(this, this.getLang().topic)); this.execCommand('AppendSiblingNode', lang.topic);
e.preventDefault(); e.preventDefault();
break; break;
case keys.Tab: case keys.Tab:
this.execCommand('appendChildNode', new MinderNode(this, this.getLang().topic)); this.execCommand('AppendChildNode', lang.topic);
e.preventDefault(); e.preventDefault();
break; break;
case keys.Backspace: case keys.Backspace:
case keys.Del: case keys.Del:
e.preventDefault(); e.preventDefault();
this.execCommand('removenode'); this.execCommand('RemoveNode');
break; break;
case keys.F2: case keys.F2:
e.preventDefault(); e.preventDefault();
this.execCommand('editnode'); this.execCommand('EditNode');
break; break;
case keys.Left: case keys.Left:
......
kity.extendClass(Minder, {
appendChildNode: function(parent, node, index) {
},
appendSiblingNode: function(sibling, node) {
var curStyle = this.getCurrentStyle();
this.getLayoutStyle(curStyle).appendSiblingNode.call(this, sibling, node);
},
});
var AppendChildCommand = kity.createClass('AppendChildCommand', {
base: Command,
execute: function(km, text) {
var parent = km.getSelectedNode();
var node = km.createNode(text);
if (!parent) {
return null;
}
//parent.expand();
parent.appendChild(node);
km.select(node, true);
node.render();
km.layout(300);
},
queryState: function(km) {
var selectedNode = km.getSelectedNode();
return selectedNode ? 0 : -1;
}
});
var AppendSiblingCommand = kity.createClass('AppendSiblingCommand', {
base: Command,
execute: function(km, text) {
var sibling = km.getSelectedNode();
var parent = sibling.parent;
var node = km.createNode(text);
if (!parent) {
return null;
}
parent.insertChild(node, sibling.getIndex() + 1);
km.select(node, true);
node.render();
km.layout(300);
},
queryState: function(km) {
var selectedNode = km.getSelectedNode();
return selectedNode ? 0 : -1;
}
});
var RemoveNodeCommand = kity.createClass('RemoverNodeCommand', {
base: Command,
execute: function(km, text) {
var nodes = km.getSelectedNodes();
var ancestor = km.getSelectedAncestors()[0];
nodes.forEach(function(node) {
km.removeNode(node);
});
km.select(ancestor, true);
km.layout(300);
},
queryState: function(km) {
var selectedNode = km.getSelectedNode();
return selectedNode ? 0 : -1;
}
});
KityMinder.registerModule('NodeModule', function() {
return {
commands: {
'AppendChildNode': AppendChildCommand,
'AppendSiblingNode': AppendSiblingCommand,
'RemoveNode': RemoveNodeCommand
}
};
});
\ No newline at end of file
/* global Renderer: true */ /* global Renderer: true */
var wireframe = true;
KityMinder.registerModule('OutlineModule', function() { KityMinder.registerModule('OutlineModule', function() {
return { return {
renderers: { renderers: {
...@@ -9,6 +11,12 @@ KityMinder.registerModule('OutlineModule', function() { ...@@ -9,6 +11,12 @@ KityMinder.registerModule('OutlineModule', function() {
create: function(node) { create: function(node) {
var outline = this.outline = new kity.Rect().setId(KityMinder.uuid('node_outline')); var outline = this.outline = new kity.Rect().setId(KityMinder.uuid('node_outline'));
node.getRenderContainer().prependShape(outline); node.getRenderContainer().prependShape(outline);
if (wireframe) {
var oxy = this.oxy = new kity.Path().stroke('white').setPathData('M0,-50L0,50M-50,0L50,0').setOpacity(0.5);
var box = this.wireframe = new kity.Rect().stroke('lightgreen');
node.getRenderContainer().addShapes([oxy, box]);
}
}, },
update: function(node) { update: function(node) {
...@@ -30,6 +38,10 @@ KityMinder.registerModule('OutlineModule', function() { ...@@ -30,6 +38,10 @@ KityMinder.registerModule('OutlineModule', function() {
.fill(node.isSelected() ? .fill(node.isSelected() ?
node.getStyle('selected-background') : node.getStyle('selected-background') :
node.getStyle('background')); node.getStyle('background'));
if (wireframe) {
this.wireframe.setPosition(outlineBox.x, outlineBox.y).setSize(outlineBox.width, outlineBox.height);
}
return outlineBox; return outlineBox;
} }
}) })
......
/* global Renderer: true */
kity.extendClass(MinderNode, {
getTextShape: function() {
return this._textShape;
}
});
KityMinder.registerModule('text', {
'renderers': {
center: kity.createClass('TextRenderer', {
base: Renderer,
create: function(node) {
var textShape = new kity.Text().setId(KityMinder.uuid('node_text'));
node.getRenderContainer().addShape(textShape);
node._textShape = textShape;
},
update: function(node) {
function dataOrStyle(name) {
return node.getData(name) || node.getStyle(name);
}
return node.getTextShape()
.setContent(node.getText())
.setFont({
family: dataOrStyle('font-family'),
size: dataOrStyle('font-size'),
weight: dataOrStyle('font-weight'),
style: dataOrStyle('font-style')
})
.setVerticalAlign('middle')
.fill(node.getData('color') || node.getStyle('color'))
.getBoundaryBox();
}
})
}
});
\ No newline at end of file
...@@ -4,7 +4,7 @@ KityMinder.registerTheme('default', { ...@@ -4,7 +4,7 @@ KityMinder.registerTheme('default', {
'root-stroke': 'none', 'root-stroke': 'none',
'root-font-size': 24, 'root-font-size': 24,
'root-padding': [15, 25], 'root-padding': [15, 25],
'root-margin': 0, 'root-margin': 30,
'root-radius': 30, 'root-radius': 30,
'root-space': 10, 'root-space': 10,
...@@ -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': [0, 10, 30, 50], 'main-margin': [15, 10],
'main-radius': 10, 'main-radius': 10,
'main-space': 5, 'main-space': 5,
...@@ -22,8 +22,8 @@ KityMinder.registerTheme('default', { ...@@ -22,8 +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': [0, 10, 20, 6], 'sub-margin': [5, 10],
'sub-radius': 0, 'sub-radius': 5,
'sub-space': 5, 'sub-space': 5,
'selected-background': 'rgb(254, 219, 0)' 'selected-background': 'rgb(254, 219, 0)'
......
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