Commit 60a0ff9e authored by techird's avatar techird

ui

parent 1724ab59
Subproject commit 1140e977283ecc038ea444dd1186eb77c59510fb Subproject commit 97750df27bf46fbb96d182a25e39768f63f7545c
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
var Minder = KityMinder.Minder = kity.createClass( "KityMinder", { var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
constructor: function ( options ) { constructor: function ( options ) {
this._options = Utils.extend( window.KITYMINDER_CONFIG || {}, options ); this._options = Utils.extend( window.KITYMINDER_CONFIG || {}, options );
this.setDefaultOptions(KM.defaultOptions); this.setDefaultOptions( KM.defaultOptions );
this._initEvents(); this._initEvents();
this._initMinder(); this._initMinder();
this._initSelection(); this._initSelection();
...@@ -34,16 +34,37 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", { ...@@ -34,16 +34,37 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
}, },
_initMinder: function () { _initMinder: function () {
this._rc = new kity.Group();
this._paper = new kity.Paper(); this._paper = new kity.Paper();
this._paper.addShape( this._rc );
this._paper.getNode().setAttribute( 'contenteditable', true ); this._paper.getNode().setAttribute( 'contenteditable', true );
this._addBackground();
this._addRenderContainer();
this._root = new MinderNode( "Main Topic" ); this._root = new MinderNode( "Main Topic" );
this._root.setType( "root" ); this._root.setType( "root" );
if ( this._options.renderTo ) { if ( this._options.renderTo ) {
this.renderTo( this._options.renderTo ); this.renderTo( this._options.renderTo );
} }
}, },
_addRenderContainer: function () {
this._rc = new kity.Group();
this._paper.addShape( this._rc );
},
_addBackground: function () {
var start = kity.Color.createHSL( 200, 8, 40 );
var end = start.dec( 'l', 5 );
var _paper = this._paper;
var _bg = this._background = new kity.Ellipse( 400, 300 ).fill( new kity.RadialGradientBrush().pipe( function () {
this.addStop( 0, start );
this.addStop( 1, end );
_paper.addResource( this );
} ) );
_paper.setStyle( 'background', end.toString() );
setTimeout( function () {
_bg.translate( _paper.getNode().clientWidth / 2, _paper.getNode().clientHeight / 2 );
}, 100 );
_paper.addShape( this._background );
},
renderTo: function ( target ) { renderTo: function ( target ) {
this._paper.renderTo( this._renderTarget = target ); this._paper.renderTo( this._renderTarget = target );
this._bindEvents(); this._bindEvents();
......
...@@ -2,11 +2,12 @@ KityMinder.registerModule( "KeyboardModule", function () { ...@@ -2,11 +2,12 @@ KityMinder.registerModule( "KeyboardModule", function () {
function buildPositionNetwork( root ) { function buildPositionNetwork( root ) {
var pointIndexes = [], var pointIndexes = [],
x, y; p, x, y;
root.traverse( function ( node ) { root.traverse( function ( node ) {
p = node.getData( 'point' );
pointIndexes.push( { pointIndexes.push( {
x: node.getData( 'x' ), x: p.x,
y: node.getData( 'y' ), y: p.y,
node: node node: node
} ); } );
} ); } );
...@@ -50,7 +51,7 @@ KityMinder.registerModule( "KeyboardModule", function () { ...@@ -50,7 +51,7 @@ KityMinder.registerModule( "KeyboardModule", function () {
function navigateTo( km, direction ) { function navigateTo( km, direction ) {
var nextNode = km.getSelectedNode()._nearestNodes[ direction ]; var nextNode = km.getSelectedNode()._nearestNodes[ direction ];
if ( nextNode ) { if ( nextNode ) {
km.select( nextNode ); km.select( nextNode, true );
} }
} }
return { return {
......
...@@ -72,13 +72,13 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -72,13 +72,13 @@ KityMinder.registerModule( "LayoutDefault", function () {
//样式的配置(包括颜色、字号等) //样式的配置(包括颜色、字号等)
var nodeStyles = { var nodeStyles = {
"root": { "root": {
color: "white", color: kity.Color.createHSL( 200, 50, 30 ),
fill: "cadetblue", fill: kity.Color.createHSL( 200, 30, 80 ),
fontSize: 20, fontSize: 20,
padding: [ 10.5, 10, 10.5, 10 ], padding: [ 10.5, 10.5, 10.5, 10.5 ],
margin: [ 0, 0, 0, 0 ], margin: [ 0, 0, 0, 0 ],
radius: 15, radius: 20,
highlight: "chocolate" highlight: "lightgreen"
}, },
"main": { "main": {
stroke: new kity.Pen( "white", 2 ).setLineCap( "round" ).setLineJoin( "round" ), stroke: new kity.Pen( "white", 2 ).setLineCap( "round" ).setLineJoin( "round" ),
...@@ -88,7 +88,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -88,7 +88,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
fontSize: 14, fontSize: 14,
margin: [ 0, 10, 30, 50 ], margin: [ 0, 10, 30, 50 ],
radius: 5, radius: 5,
highlight: "chocolate" highlight: "yellow"
}, },
"sub": { "sub": {
stroke: new kity.Pen( "white", 2 ).setLineCap( "round" ).setLineJoin( "round" ), stroke: new kity.Pen( "white", 2 ).setLineCap( "round" ).setLineJoin( "round" ),
...@@ -96,7 +96,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -96,7 +96,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
fontSize: 12, fontSize: 12,
margin: [ 0, 10, 20, 6 ], margin: [ 0, 10, 20, 6 ],
padding: [ 5, 10, 5.5, 10 ], padding: [ 5, 10, 5.5, 10 ],
highlight: "chocolate" highlight: kity.Color.createHSL( 200, 50, 60 )
} }
}; };
//更新背景 //更新背景
......
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