z index reflow better

This commit is contained in:
Peter Cottle 2012-09-28 14:29:44 -07:00
parent bbd081591d
commit 7f7681320e
2 changed files with 37 additions and 9 deletions

View file

@ -95,8 +95,8 @@ var VisBranch = Backbone.Model.extend({
// head side point // head side point
var next2 = offset2d(next, 0, -this.get('arrowEdgeHeight')); var next2 = offset2d(next, 0, -this.get('arrowEdgeHeight'));
// head point // head point
var next3 = offset2d(this.getTextPosition(), var next3 = offset2d(this.getCommitPosition(),
-this.get('arrowLength') * this.get('arrowRatio'), 0); 3, 0);
// get the next three points in backwards order // get the next three points in backwards order
var end = offset2d(this.getRectPosition(), overlap, this.getSingleRectSize().h - this.get('arrowInnerMargin')); var end = offset2d(this.getRectPosition(), overlap, this.getSingleRectSize().h - this.get('arrowInnerMargin'));
@ -125,10 +125,7 @@ var VisBranch = Backbone.Model.extend({
maxWidth = Math.max(maxWidth, getTextWidth( maxWidth = Math.max(maxWidth, getTextWidth(
branch.obj.get('visBranch') branch.obj.get('visBranch')
)); ));
console.log('this branch', branch.id, 'is selected', branch.selected);
console.log('and i just calculated its width', getTextWidth(branch.obj.get('visBranch')));
}); });
console.log('I am ****', this.getName(), ' and got max width of', maxWidth);
return { return {
w: maxWidth, w: maxWidth,
@ -168,6 +165,11 @@ var VisBranch = Backbone.Model.extend({
return name + add; return name + add;
}, },
nonTextToFront: function() {
this.get('arrow').toFront();
this.get('rect').toFront();
},
textToFront: function() { textToFront: function() {
this.get('text').toFront(); this.get('text').toFront();
}, },
@ -206,15 +208,18 @@ var VisBranch = Backbone.Model.extend({
text.toFront(); text.toFront();
}, },
updateName: function() {
this.get('text').attr({
text: this.getName()
});
},
animateUpdatedPos: function(speed, easing) { animateUpdatedPos: function(speed, easing) {
var s = speed !== undefined ? speed : this.get('animationSpeed'); var s = speed !== undefined ? speed : this.get('animationSpeed');
var e = easing || this.get('animationEasing'); var e = easing || this.get('animationEasing');
var masterOpacity = this.getBranchStackIndex() == 0 ? 1 : 0.0; var masterOpacity = this.getBranchStackIndex() == 0 ? 1 : 0.0;
this.get('text').attr({ this.updateName();
text: this.getName()
});
var textPos = this.getTextPosition(); var textPos = this.getTextPosition();
this.get('text').stop().animate({ this.get('text').stop().animate({
x: textPos.x, x: textPos.x,
@ -279,6 +284,10 @@ var VisNode = Backbone.Model.extend({
pos.y = this.get('depth') * depthIncrement; pos.y = this.get('depth') * depthIncrement;
}, },
toFront: function() {
this.get('circle').toFront();
},
animateUpdatedPosition: function(speed, easing) { animateUpdatedPosition: function(speed, easing) {
var pos = this.getScreenCoords(); var pos = this.getScreenCoords();
this.get('circle').stop().animate({ this.get('circle').stop().animate({

View file

@ -72,7 +72,9 @@ GitVisuals.prototype.toScreenCoords = function(pos) {
**************************************/ **************************************/
GitVisuals.prototype.refreshTree = function() { GitVisuals.prototype.refreshTree = function() {
// this method can only be called after graphics are rendered
this.calculateTreeCoords(); this.calculateTreeCoords();
this.calculateGraphicsCoords();
this.animateAll(); this.animateAll();
}; };
@ -84,12 +86,15 @@ GitVisuals.prototype.refreshTreeHarsh = function() {
}; };
GitVisuals.prototype.animateAll = function(speed) { GitVisuals.prototype.animateAll = function(speed) {
this.zIndexReflow();
this.animateEdges(speed); this.animateEdges(speed);
this.animateNodePositions(speed); this.animateNodePositions(speed);
this.animateRefs(speed); this.animateRefs(speed);
}; };
GitVisuals.prototype.calculateTreeCoords = function() { GitVisuals.prototype.calculateTreeCoords = function() {
// this method can only contain things that dont rely on graphics
if (!this.rootCommit) { if (!this.rootCommit) {
throw new Error('grr, no root commit!'); throw new Error('grr, no root commit!');
} }
@ -100,6 +105,12 @@ GitVisuals.prototype.calculateTreeCoords = function() {
this.calcBranchStacks(); this.calcBranchStacks();
}; };
GitVisuals.prototype.calculateGraphicsCoords = function() {
this.visBranchCollection.each(function(visBranch) {
visBranch.updateName();
});
};
GitVisuals.prototype.calcBranchStacks = function() { GitVisuals.prototype.calcBranchStacks = function() {
var branches = gitEngine.getBranches(); var branches = gitEngine.getBranches();
var map = {}; var map = {};
@ -313,6 +324,14 @@ GitVisuals.prototype.collectionChanged = function() {
}; };
GitVisuals.prototype.zIndexReflow = function() { GitVisuals.prototype.zIndexReflow = function() {
_.each(this.visNodeMap, function(visNode) {
visNode.toFront();
});
this.visBranchCollection.each(function(vBranch) {
vBranch.nonTextToFront();
});
this.visBranchCollection.each(function(vBranch) { this.visBranchCollection.each(function(vBranch) {
vBranch.textToFront(); vBranch.textToFront();
}); });