diff --git a/src/constants.js b/src/constants.js index 1f258526..22611b77 100644 --- a/src/constants.js +++ b/src/constants.js @@ -24,6 +24,8 @@ var GRAPHICS = { multiBranchY: 20, upstreamHeadOpacity: 0.5, upstreamNoneOpacity: 0.2, + edgeUpstreamHeadOpacity: 0.4, + edgeUpstreamNoneOpacity: 0.15 }; /** diff --git a/src/git.js b/src/git.js index eacffe6a..c3a72364 100644 --- a/src/git.js +++ b/src/git.js @@ -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) { diff --git a/src/tree.js b/src/tree.js index d8a8429c..f665714f 100644 --- a/src/tree.js +++ b/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') diff --git a/src/visuals.js b/src/visuals.js index 93dfee82..933f3b00 100644 --- a/src/visuals.js +++ b/src/visuals.js @@ -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 = {}; diff --git a/todo.txt b/todo.txt index 4c1ccf11..d3c7ee9c 100644 --- a/todo.txt +++ b/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.