mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-26 16:08:34 +02:00
HEAD opacity working
This commit is contained in:
parent
9c1c9ed664
commit
3b58cf2912
5 changed files with 46 additions and 23 deletions
|
@ -24,6 +24,8 @@ var GRAPHICS = {
|
|||
multiBranchY: 20,
|
||||
upstreamHeadOpacity: 0.5,
|
||||
upstreamNoneOpacity: 0.2,
|
||||
edgeUpstreamHeadOpacity: 0.4,
|
||||
edgeUpstreamNoneOpacity: 0.15
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -340,7 +340,11 @@ GitEngine.prototype.getUpstreamBranchSet = 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) {
|
||||
|
|
40
src/tree.js
40
src/tree.js
|
@ -305,31 +305,14 @@ var VisNode = Backbone.Model.extend({
|
|||
'head': GRAPHICS.upstreamHeadOpacity,
|
||||
'none': GRAPHICS.upstreamNoneOpacity
|
||||
};
|
||||
var stat = this.getUpstreamStatus();
|
||||
|
||||
var stat = gitVisuals.getCommitUpstreamStatus(this.get('commit'));
|
||||
if (map[stat] === undefined) {
|
||||
throw new Error('invalid status');
|
||||
}
|
||||
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) {
|
||||
var pos = this.getScreenCoords();
|
||||
var opacity = this.getOpacity();
|
||||
|
@ -423,7 +406,7 @@ var VisEdge = Backbone.Model.extend({
|
|||
str += coords(headPos);
|
||||
|
||||
// arrow head
|
||||
// TODO default sizing
|
||||
// TODO default sizing? fill the arrow head?
|
||||
var delta = GRAPHICS.arrowHeadSize || 10;
|
||||
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);
|
||||
},
|
||||
|
||||
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) {
|
||||
var newPath = this.getBezierCurve();
|
||||
var opacity = this.getOpacity();
|
||||
|
||||
this.get('path').toBack();
|
||||
this.get('path').stop().animate({
|
||||
path: newPath
|
||||
path: newPath,
|
||||
opacity: opacity
|
||||
},
|
||||
speed !== undefined ? speed : this.get('animationSpeed'),
|
||||
easing || this.get('animationEasing')
|
||||
|
|
|
@ -116,9 +116,28 @@ GitVisuals.prototype.calcGraphicsCoords = function() {
|
|||
|
||||
GitVisuals.prototype.calcUpstreamSets = function() {
|
||||
this.upstreamBranchSet = gitEngine.getUpstreamBranchSet();
|
||||
|
||||
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() {
|
||||
var branches = gitEngine.getBranches();
|
||||
var map = {};
|
||||
|
|
2
todo.txt
2
todo.txt
|
@ -17,5 +17,5 @@ ALSO other big things:
|
|||
- Division in their rings based on how many / what branches they are part of
|
||||
- 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.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue