forked from fex-team/kityminder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
94 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule kity
updated
3 files
+2 −1 | dist/kity.js | |
+2 −2 | dist/kity.min.js | |
+1 −0 | src/animate/timeline.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,99 @@ | ||
/* global Renderer: true */ | ||
|
||
var wireframe = /wire/.test(window.location.href); | ||
|
||
var OutlineRenderer = kity.createClass('OutlineRenderer', { | ||
base: Renderer, | ||
|
||
create: function(node) { | ||
var group = new kity.Group(); | ||
|
||
var outline = this.outline = new kity.Rect() | ||
var outline = new kity.Rect() | ||
.setId(KityMinder.uuid('node_outline')); | ||
|
||
var shadow = this.shadow = new kity.Rect() | ||
.setId(KityMinder.uuid('node_shadow')); | ||
|
||
group.addShapes([shadow, outline]); | ||
|
||
if (wireframe) { | ||
var oxy = this.oxy = new kity.Path() | ||
.stroke('#f6f') | ||
.setPathData('M0,-50L0,50M-50,0L50,0'); | ||
|
||
var box = this.wireframe = new kity.Rect() | ||
.stroke('lightgreen'); | ||
|
||
group.addShapes([oxy, box]); | ||
} | ||
|
||
this.bringToBack = true; | ||
return group; | ||
|
||
return outline; | ||
}, | ||
|
||
update: function(created, node) { | ||
var contentBox = node.getContentBox(); | ||
update: function(outline, node, box) { | ||
|
||
var paddingLeft = node.getStyle('padding-left'), | ||
paddingRight = node.getStyle('padding-right'), | ||
paddingTop = node.getStyle('padding-top'), | ||
paddingBottom = node.getStyle('padding-bottom'); | ||
|
||
var outlineBox = { | ||
x: contentBox.x - paddingLeft, | ||
y: contentBox.y - paddingTop, | ||
width: contentBox.width + paddingLeft + paddingRight, | ||
height: contentBox.height + paddingTop + paddingBottom | ||
x: box.x - paddingLeft, | ||
y: box.y - paddingTop, | ||
width: box.width + paddingLeft + paddingRight, | ||
height: box.height + paddingTop + paddingBottom | ||
}; | ||
|
||
this.outline | ||
.setPosition(outlineBox.x, outlineBox.y) | ||
.setSize(outlineBox.width, outlineBox.height) | ||
.setRadius(node.getStyle('radius')); | ||
|
||
var prefix = node.isSelected() ? 'selected-' : ''; | ||
|
||
this.outline.fill(node.getStyle(prefix + 'background')); | ||
this.outline.stroke(node.getStyle(prefix + 'stroke'), | ||
node.getStyle(prefix + 'stroke-width')); | ||
|
||
if (node.getStyle('shadow')) { | ||
this.shadow | ||
.setVisible(true) | ||
.setPosition(outlineBox.x + 4, outlineBox.y + 5) | ||
.setSize(outlineBox.width, outlineBox.height) | ||
.fill(node.getStyle('shadow')) | ||
.setRadius(node.getStyle('radius')); | ||
} else { | ||
this.shadow.setVisible(false); | ||
} | ||
outline | ||
.setPosition(outlineBox.x, outlineBox.y) | ||
.setSize(outlineBox.width, outlineBox.height) | ||
.setRadius(node.getStyle('radius')) | ||
.fill(node.getStyle(prefix + 'background')) | ||
.stroke(node.getStyle(prefix + 'stroke'), | ||
node.getStyle(prefix + 'stroke-width')); | ||
|
||
if (wireframe) { | ||
this.wireframe | ||
.setPosition(outlineBox.x, outlineBox.y) | ||
.setSize(outlineBox.width, outlineBox.height); | ||
} | ||
return outlineBox; | ||
} | ||
}); | ||
|
||
var ShadowRenderer = kity.createClass('ShadowRenderer', { | ||
|
||
base: Renderer, | ||
|
||
create: function(node) { | ||
this.bringToBack = true; | ||
return new kity.Rect(); | ||
}, | ||
|
||
shouldRender: function(node) { | ||
return node.getStyle('shadow'); | ||
}, | ||
|
||
update: function(shadow, node, box) { | ||
shadow.setPosition(box.x + 4, box.y + 5) | ||
.setSize(box.width, box.height) | ||
.fill(node.getStyle('shadow')) | ||
.setRadius(node.getStyle('radius')); | ||
} | ||
}); | ||
|
||
var wireframeOption = /wire/.test(window.location.href); | ||
var WireframeRenderer = kity.createClass('WireframeRenderer', { | ||
base: Renderer, | ||
|
||
create: function() { | ||
var wireframe = new kity.Group(); | ||
var oxy = this.oxy = new kity.Path() | ||
.stroke('#f6f') | ||
.setPathData('M0,-50L0,50M-50,0L50,0'); | ||
|
||
var box = this.wireframe = new kity.Rect() | ||
.stroke('lightgreen'); | ||
|
||
return wireframe.addShapes([oxy, box]); | ||
}, | ||
|
||
shouldRender: function() { | ||
return wireframeOption; | ||
}, | ||
|
||
update: function(created, node, box) { | ||
this.wireframe | ||
.setPosition(box.x, box.y) | ||
.setSize(box.width, box.height); | ||
} | ||
}); | ||
|
||
KityMinder.registerModule('OutlineModule', function() { | ||
return { | ||
renderers: { | ||
outline: OutlineRenderer | ||
outline: OutlineRenderer, | ||
outside: [ShadowRenderer, WireframeRenderer] | ||
} | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters