HEAD opacity working

This commit is contained in:
Peter Cottle 2012-09-29 09:43:37 -07:00
parent 9c1c9ed664
commit 3b58cf2912
5 changed files with 46 additions and 23 deletions

View file

@ -24,6 +24,8 @@ var GRAPHICS = {
multiBranchY: 20, multiBranchY: 20,
upstreamHeadOpacity: 0.5, upstreamHeadOpacity: 0.5,
upstreamNoneOpacity: 0.2, upstreamNoneOpacity: 0.2,
edgeUpstreamHeadOpacity: 0.4,
edgeUpstreamNoneOpacity: 0.15
}; };
/** /**

View file

@ -340,7 +340,11 @@ GitEngine.prototype.getUpstreamBranchSet = function() {
}; };
GitEngine.prototype.getUpstreamHeadSet = function() { GitEngine.prototype.getUpstreamHeadSet = function() {
return this.getUpstreamSet('HEAD'); var set = this.getUpstreamSet('HEAD');
var including = this.getCommitFromRef('HEAD').get('id');
set[including] = true;
return set;
}; };
GitEngine.prototype.getOneBeforeCommit = function(ref) { GitEngine.prototype.getOneBeforeCommit = function(ref) {

View file

@ -305,31 +305,14 @@ var VisNode = Backbone.Model.extend({
'head': GRAPHICS.upstreamHeadOpacity, 'head': GRAPHICS.upstreamHeadOpacity,
'none': GRAPHICS.upstreamNoneOpacity 'none': GRAPHICS.upstreamNoneOpacity
}; };
var stat = this.getUpstreamStatus();
var stat = gitVisuals.getCommitUpstreamStatus(this.get('commit'));
if (map[stat] === undefined) { if (map[stat] === undefined) {
throw new Error('invalid status'); throw new Error('invalid status');
} }
return map[stat]; return map[stat];
}, },
getUpstreamStatus: function() {
if (!gitVisuals.upstreamBranchSet) {
throw new Error("Can't call this method yet");
}
var id = this.get('id');
var branch = gitVisuals.upstreamBranchSet;
var head = gitVisuals.upstreamHeadSet;
if (branch[id] && branch[id].length) {
return 'branch';
} else if (head[id] && head[id].length) {
return 'head';
} else {
return 'none'
}
},
animateUpdatedPosition: function(speed, easing) { animateUpdatedPosition: function(speed, easing) {
var pos = this.getScreenCoords(); var pos = this.getScreenCoords();
var opacity = this.getOpacity(); var opacity = this.getOpacity();
@ -423,7 +406,7 @@ var VisEdge = Backbone.Model.extend({
str += coords(headPos); str += coords(headPos);
// arrow head // arrow head
// TODO default sizing // TODO default sizing? fill the arrow head?
var delta = GRAPHICS.arrowHeadSize || 10; var delta = GRAPHICS.arrowHeadSize || 10;
str += ' L' + coords(offset2d(headPos, -delta, delta)); str += ' L' + coords(offset2d(headPos, -delta, delta));
str += ' L' + coords(offset2d(headPos, delta, delta)); str += ' L' + coords(offset2d(headPos, delta, delta));
@ -443,11 +426,26 @@ var VisEdge = Backbone.Model.extend({
this.set('path', path); this.set('path', path);
}, },
getOpacity: function() {
var stat = gitVisuals.getCommitUpstreamStatus(this.get('tail'));
var map = {
'branch': 1,
'head': GRAPHICS.edgeUpstreamHeadOpacity,
'none': GRAPHICS.edgeUpstreamNoneOpacity
};
if (map[stat] === undefined) { throw new Error('bad stat'); }
return map[stat];
},
animateUpdatedPath: function(speed, easing) { animateUpdatedPath: function(speed, easing) {
var newPath = this.getBezierCurve(); var newPath = this.getBezierCurve();
var opacity = this.getOpacity();
this.get('path').toBack(); this.get('path').toBack();
this.get('path').stop().animate({ this.get('path').stop().animate({
path: newPath path: newPath,
opacity: opacity
}, },
speed !== undefined ? speed : this.get('animationSpeed'), speed !== undefined ? speed : this.get('animationSpeed'),
easing || this.get('animationEasing') easing || this.get('animationEasing')

View file

@ -116,9 +116,28 @@ GitVisuals.prototype.calcGraphicsCoords = function() {
GitVisuals.prototype.calcUpstreamSets = function() { GitVisuals.prototype.calcUpstreamSets = function() {
this.upstreamBranchSet = gitEngine.getUpstreamBranchSet(); this.upstreamBranchSet = gitEngine.getUpstreamBranchSet();
this.upstreamHeadSet = gitEngine.getUpstreamHeadSet(); this.upstreamHeadSet = gitEngine.getUpstreamHeadSet();
}; };
GitVisuals.prototype.getCommitUpstreamStatus = function(commit) {
if (!this.upstreamBranchSet) {
throw new Error("Can't calculate this yet!");
}
var id = commit.get('id');
var branch = this.upstreamBranchSet;
var head = this.upstreamHeadSet;
if (branch[id]) {
return 'branch';
} else if (head[id]) {
return 'head';
} else {
return 'none';
}
};
GitVisuals.prototype.calcBranchStacks = function() { GitVisuals.prototype.calcBranchStacks = function() {
var branches = gitEngine.getBranches(); var branches = gitEngine.getBranches();
var map = {}; var map = {};

View file

@ -17,5 +17,5 @@ ALSO other big things:
- Division in their rings based on how many / what branches they are part of - Division in their rings based on how many / what branches they are part of
- Color on branch edges?? - Color on branch edges??
- Commits go transparent when no longer downstream of anything (also their weights are adjusted? and sent to back?) - sizing on visedge arrowheads, also fill most likely.