and also bug about backbone events throwing random args

This commit is contained in:
Peter Cottle 2012-10-27 18:21:18 -07:00
parent 6c6c789da8
commit eb254126cb
3 changed files with 20 additions and 17 deletions

View file

@ -112,12 +112,12 @@ GitEngine.prototype.instantiateFromTree = function(tree) {
this.commitCollection.add(commit); this.commitCollection.add(commit);
}, this); }, this);
gitVisuals.paperReady = false;
_.each(tree.branches, function(branchJSON) { _.each(tree.branches, function(branchJSON) {
var branch = this.getOrMakeRecursive(tree, createdSoFar, branchJSON.id); var branch = this.getOrMakeRecursive(tree, createdSoFar, branchJSON.id);
this.branchCollection.add(branch);
this.branchCollection.add(branch, {silent: true});
gitVisuals.addBranch(branch, true /* paper override */);
}, this); }, this);
gitVisuals.paperReady = true;
var HEAD = this.getOrMakeRecursive(tree, createdSoFar, tree.HEAD.id); var HEAD = this.getOrMakeRecursive(tree, createdSoFar, tree.HEAD.id);
this.HEAD = HEAD; this.HEAD = HEAD;
@ -127,7 +127,6 @@ GitEngine.prototype.reloadGraphics = function() {
var rootCommit = null; var rootCommit = null;
this.commitCollection.each(function(commit) { this.commitCollection.each(function(commit) {
console.log('finding commit from collection', commit.get('id'));
if (commit.get('id') == 'C0') { if (commit.get('id') == 'C0') {
rootCommit = commit; rootCommit = commit;
} }
@ -137,13 +136,11 @@ GitEngine.prototype.reloadGraphics = function() {
// this just basically makes the HEAD branch. the head branch really should have been // this just basically makes the HEAD branch. the head branch really should have been
// a member of a collection and not this annoying edge case stuff... // a member of a collection and not this annoying edge case stuff...
console.log('calling when git engine ready');
gitVisuals.whenGitEngineReady(this); gitVisuals.whenGitEngineReady(this);
// when the paper is ready // when the paper is ready
gitVisuals.drawTreeFromReload(); gitVisuals.drawTreeFromReload();
console.log('refreshing harsh');
gitVisuals.refreshTreeHarsh(); gitVisuals.refreshTreeHarsh();
}; };

View file

@ -123,14 +123,11 @@ var VisBranch = VisBase.extend({
}, },
getRectPosition: function() { getRectPosition: function() {
console.log('before text pos');
var pos = this.getTextPosition(); var pos = this.getTextPosition();
console.log('wut');
var f = this.get('flip'); var f = this.get('flip');
// first get text width and height // first get text width and height
console.log('before text size');
var textSize = this.getTextSize(); var textSize = this.getTextSize();
console.log('text size');
return { return {
x: pos.x - 0.5 * textSize.w - this.get('hPad'), x: pos.x - 0.5 * textSize.w - this.get('hPad'),
y: pos.y - 0.5 * textSize.h - this.get('vPad') y: pos.y - 0.5 * textSize.h - this.get('vPad')

View file

@ -18,7 +18,7 @@ function GitVisuals(options) {
this.commitCollection.on('change', this.collectionChanged, this); this.commitCollection.on('change', this.collectionChanged, this);
this.branchCollection.on('add', this.addBranch, this); this.branchCollection.on('add', this.addBranchFromEvent, this);
this.branchCollection.on('remove', this.removeBranch, this); this.branchCollection.on('remove', this.removeBranch, this);
events.on('canvasResize', _.bind( events.on('canvasResize', _.bind(
@ -362,14 +362,26 @@ GitVisuals.prototype.animateNodePositions = function(speed) {
}, this); }, this);
}; };
GitVisuals.prototype.addBranch = function(branch) { GitVisuals.prototype.turnOnPaper = function() {
this.paperReady = false;
};
// does making an accessor method make it any less hacky? that is the true question
GitVisuals.prototype.turnOffPaper = function() {
this.paperReady = true;
};
GitVisuals.prototype.addBranchFromEvent = function(branch, collection, index) {
this.addBranch(branch);
};
GitVisuals.prototype.addBranch = function(branch, paperOverride) {
var visBranch = new VisBranch({ var visBranch = new VisBranch({
branch: branch branch: branch
}); });
this.visBranchCollection.add(visBranch); this.visBranchCollection.add(visBranch);
if (this.paperReady) { if (!paperOverride && this.paperReady) {
console.log('PAPEPR IS READY');
visBranch.genGraphics(paper); visBranch.genGraphics(paper);
} }
}; };
@ -511,17 +523,14 @@ GitVisuals.prototype.drawTreeFirstTime = function() {
this.calcTreeCoords(); this.calcTreeCoords();
_.each(this.visNodeMap, function(visNode) { _.each(this.visNodeMap, function(visNode) {
console.log('visnode map is doing', visNode);
visNode.genGraphics(paper); visNode.genGraphics(paper);
}, this); }, this);
this.visEdgeCollection.each(function(edge) { this.visEdgeCollection.each(function(edge) {
console.log('vis edge collection', edge);
edge.genGraphics(paper); edge.genGraphics(paper);
}, this); }, this);
this.visBranchCollection.each(function(visBranch) { this.visBranchCollection.each(function(visBranch) {
console.log('vis rabnch', visBranch);
visBranch.genGraphics(paper); visBranch.genGraphics(paper);
}, this); }, this);