mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-07-01 18:24:28 +02:00
ok, decoupled vis details from git engine. now for big switch away from arbor.js to raphael with my own tree drawing algorithm. deep breath......
This commit is contained in:
parent
cf8e8557f3
commit
f5fcd32815
3 changed files with 28 additions and 7 deletions
|
@ -1,11 +1,30 @@
|
|||
function GitVisuals(options) {
|
||||
this.collection = options.collection;
|
||||
this.nodeMap = {};
|
||||
|
||||
this.collection.on('change', _.bind(this.collectionChanged, this));
|
||||
events.on('drawGitVisuals', _.bind(this.drawVisuals, this));
|
||||
events.on('fixNodePositions', _.bind(this.fixNodes, this));
|
||||
}
|
||||
|
||||
GitVisuals.prototype.addNode = function(id) {
|
||||
var visNode = sys.addNode(id);
|
||||
this.nodeMap[id] = visNode;
|
||||
return visNode;
|
||||
};
|
||||
|
||||
GitVisuals.prototype.addEdge = function(idTail, idHead) {
|
||||
var visNodeTail = this.nodeMap[idTail];
|
||||
var visNodeHead = this.nodeMap[idHead];
|
||||
|
||||
if (!visNodeTail || !visNodeHead) {
|
||||
throw new Error('one of the ids in (' + idTail +
|
||||
', ' + idHead + ') does not exist');
|
||||
}
|
||||
|
||||
sys.addEdge(visNodeTail, visNodeHead);
|
||||
};
|
||||
|
||||
GitVisuals.prototype.drawVisuals = function(sys, ctx, canvas) {
|
||||
this.drawRefs(sys, ctx, canvas);
|
||||
};
|
||||
|
@ -23,13 +42,13 @@ GitVisuals.prototype.drawRefs = function(sys, ctx, canvas) {
|
|||
|
||||
_.forEach(branches, _.bind(function(branch) {
|
||||
// get the location of the arbor node and then somehow draw the ref to the side?
|
||||
var node = branch.target.get('arborNode');
|
||||
var node = branch.target.get('visNode');
|
||||
var fillStyle = branch.selected ? sFill : undefined;
|
||||
this.drawLabel(ctx, sys, node, branch.id, fillStyle);
|
||||
}, this));
|
||||
|
||||
if (detachedHead) {
|
||||
var node = HEAD.get('target').get('arborNode');
|
||||
var node = HEAD.get('target').get('visNode');
|
||||
this.drawLabel(ctx, sys, node, 'HEAD', sFill);
|
||||
}
|
||||
};
|
||||
|
@ -86,5 +105,5 @@ GitVisuals.prototype.fixRootCommit = function(sys) {
|
|||
|
||||
var bottomPos = sys.fromScreen(bottomPosScreen);
|
||||
// fix the root commit to the bottom
|
||||
gitEngine.rootCommit.get('arborNode').p = bottomPos;
|
||||
gitEngine.rootCommit.get('visNode').p = bottomPos;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue