WIP on legend for goal

This commit is contained in:
Peter Cottle 2013-07-07 15:26:03 -07:00
parent ea30b42616
commit 264f245275
11 changed files with 217 additions and 17 deletions

View file

@ -6274,6 +6274,8 @@ var Level = Sandbox.extend({
treeString: this.level.goalTreeString, treeString: this.level.goalTreeString,
noKeyboardInput: true, noKeyboardInput: true,
smallCanvas: true, smallCanvas: true,
isGoalVis: true,
levelBlob: this.level,
noClick: true noClick: true
}); });
return this.goalCanvasHolder; return this.goalCanvasHolder;
@ -6772,6 +6774,7 @@ var Visualization = Backbone.View.extend({
branchCollection: this.branchCollection, branchCollection: this.branchCollection,
paper: this.paper, paper: this.paper,
noClick: this.options.noClick, noClick: this.options.noClick,
isGoalVis: this.options.isGoalVis,
smallCanvas: this.options.smallCanvas, smallCanvas: this.options.smallCanvas,
visualization: this visualization: this
}); });
@ -9844,6 +9847,18 @@ TreeCompare.dispatchFromLevel = function(levelBlob, treeToCompare) {
return TreeCompare.dispatch(levelBlob, goalTreeString, treeToCompare); return TreeCompare.dispatch(levelBlob, goalTreeString, treeToCompare);
}; };
TreeCompare.onlyMasterCompared = function(levelBlob) {
var getAroundLintTrue = true;
switch (getAroundLintTrue) {
case !!levelBlob.compareOnlyMaster:
case !!levelBlob.compareOnlyMasterHashAgnostic:
case !!levelBlob.compareOnlyMasterHashAgnosticWithAsserts:
return true;
default:
return false;
}
};
TreeCompare.dispatch = function(levelBlob, goalTreeString, treeToCompare) { TreeCompare.dispatch = function(levelBlob, goalTreeString, treeToCompare) {
var getAroundLintTrue = true; var getAroundLintTrue = true;
// i actually prefer this to else if // i actually prefer this to else if
@ -15795,6 +15810,14 @@ GitVisuals.prototype.getFlipPos = function() {
return this.flipFraction * (max - min) + min; return this.flipFraction * (max - min) + min;
}; };
GitVisuals.prototype.getIsGoalVis = function() {
return !!this.options.isGoalVis;
};
GitVisuals.prototype.getLevelBlob = function() {
return this.visualization.options.levelBlob || {};
};
GitVisuals.prototype.toScreenCoords = function(pos) { GitVisuals.prototype.toScreenCoords = function(pos) {
if (!this.paper.width) { if (!this.paper.width) {
throw new Error('being called too early for screen coords'); throw new Error('being called too early for screen coords');
@ -17032,6 +17055,7 @@ var Backbone = require('backbone');
var GRAPHICS = require('../util/constants').GRAPHICS; var GRAPHICS = require('../util/constants').GRAPHICS;
var VisBase = require('../visuals/visBase').VisBase; var VisBase = require('../visuals/visBase').VisBase;
var TreeCompare = require('../git/treeCompare').TreeCompare;
var randomHueString = function() { var randomHueString = function() {
var hue = Math.random(); var hue = Math.random();
@ -17112,6 +17136,39 @@ var VisBranch = VisBase.extend({
return visNode.getScreenCoords(); return visNode.getScreenCoords();
}, },
getDashArray: function() {
if (!this.get('gitVisuals').getIsGoalVis()) {
return '';
}
return (this.getIsLevelBranchCompared()) ? '' : '- ';
},
getIsGoalAndNotCompared: function() {
if (!this.get('gitVisuals').getIsGoalVis()) {
return false;
}
return !this.getIsLevelBranchCompared();
},
/**
* returns true if we are a branch that is not being
* compared in the goal (used in a goal visualization context
*/
getIsLevelBranchCompared: function() {
if (this.getIsMaster()) {
return true; // master always compared
}
// we are not master, so return true if its not just master being compared
var levelBlob = this.get('gitVisuals').getLevelBlob();
return !TreeCompare.onlyMasterCompared(levelBlob);
},
getIsMaster: function() {
return this.get('branch').get('id') == 'master';
},
getFlipValue: function(commit, visNode) { getFlipValue: function(commit, visNode) {
var threshold = this.get('gitVisuals').getFlipPos(); var threshold = this.get('gitVisuals').getFlipPos();
var overThreshold = (visNode.get('pos').x > threshold); var overThreshold = (visNode.get('pos').x > threshold);
@ -17467,13 +17524,22 @@ var VisBranch = VisBase.extend({
if (this.get('isHead')) { if (this.get('isHead')) {
return this.gitEngine.getDetachedHead() ? 1 : 0; return this.gitEngine.getDetachedHead() ? 1 : 0;
} }
return this.getBranchStackIndex() === 0 ? 1 : 0.0; if (this.getBranchStackIndex() !== 0) {
return 0.0;
}
return 1;
}, },
getTextOpacity: function() { getTextOpacity: function() {
if (this.get('isHead')) { if (this.get('isHead')) {
return this.gitEngine.getDetachedHead() ? 1 : 0; return this.gitEngine.getDetachedHead() ? 1 : 0;
} }
if (this.getIsGoalAndNotCompared()) {
return 0.3;
}
return 1; return 1;
}, },
@ -17487,8 +17553,7 @@ var VisBranch = VisBase.extend({
var rectSize = this.getRectSize(); var rectSize = this.getRectSize();
var arrowPath = this.getArrowPath(); var arrowPath = this.getArrowPath();
var dashArray = (this.getIsInOrigin()) ? var dashArray = this.getDashArray();
GRAPHICS.originDash : '';
var cursorStyle = (this.shouldDisableClick()) ? var cursorStyle = (this.shouldDisableClick()) ?
'auto' : 'auto' :
'pointer'; 'pointer';
@ -17510,7 +17575,7 @@ var VisBranch = VisBase.extend({
opacity: nonTextOpacity, opacity: nonTextOpacity,
fill: this.getFill(), fill: this.getFill(),
stroke: this.get('stroke'), stroke: this.get('stroke'),
//'stroke-dasharray': dashArray, 'stroke-dasharray': dashArray,
'stroke-width': this.get('stroke-width') 'stroke-width': this.get('stroke-width')
}, },
arrow: { arrow: {
@ -22462,10 +22527,12 @@ function getMockFactory() {
mockFactory.playCommitBirthPromiseAnimation = function(commit, visuals) { mockFactory.playCommitBirthPromiseAnimation = function(commit, visuals) {
var d = Q.defer(); var d = Q.defer();
d.resolve(); d.resolve();
// return a resolved promise here
return d.promise; return d.promise;
}; };
mockFactory.highlightEachWithPromise = function(chain, toRebase, destBranch) { mockFactory.highlightEachWithPromise = function(chain, toRebase, destBranch) {
// dont add any steps
return chain; return chain;
}; };
@ -23499,10 +23566,12 @@ function getMockFactory() {
mockFactory.playCommitBirthPromiseAnimation = function(commit, visuals) { mockFactory.playCommitBirthPromiseAnimation = function(commit, visuals) {
var d = Q.defer(); var d = Q.defer();
d.resolve(); d.resolve();
// return a resolved promise here
return d.promise; return d.promise;
}; };
mockFactory.highlightEachWithPromise = function(chain, toRebase, destBranch) { mockFactory.highlightEachWithPromise = function(chain, toRebase, destBranch) {
// dont add any steps
return chain; return chain;
}; };
@ -25974,6 +26043,18 @@ TreeCompare.dispatchFromLevel = function(levelBlob, treeToCompare) {
return TreeCompare.dispatch(levelBlob, goalTreeString, treeToCompare); return TreeCompare.dispatch(levelBlob, goalTreeString, treeToCompare);
}; };
TreeCompare.onlyMasterCompared = function(levelBlob) {
var getAroundLintTrue = true;
switch (getAroundLintTrue) {
case !!levelBlob.compareOnlyMaster:
case !!levelBlob.compareOnlyMasterHashAgnostic:
case !!levelBlob.compareOnlyMasterHashAgnosticWithAsserts:
return true;
default:
return false;
}
};
TreeCompare.dispatch = function(levelBlob, goalTreeString, treeToCompare) { TreeCompare.dispatch = function(levelBlob, goalTreeString, treeToCompare) {
var getAroundLintTrue = true; var getAroundLintTrue = true;
// i actually prefer this to else if // i actually prefer this to else if
@ -27759,6 +27840,8 @@ var Level = Sandbox.extend({
treeString: this.level.goalTreeString, treeString: this.level.goalTreeString,
noKeyboardInput: true, noKeyboardInput: true,
smallCanvas: true, smallCanvas: true,
isGoalVis: true,
levelBlob: this.level,
noClick: true noClick: true
}); });
return this.goalCanvasHolder; return this.goalCanvasHolder;
@ -32722,6 +32805,14 @@ GitVisuals.prototype.getFlipPos = function() {
return this.flipFraction * (max - min) + min; return this.flipFraction * (max - min) + min;
}; };
GitVisuals.prototype.getIsGoalVis = function() {
return !!this.options.isGoalVis;
};
GitVisuals.prototype.getLevelBlob = function() {
return this.visualization.options.levelBlob || {};
};
GitVisuals.prototype.toScreenCoords = function(pos) { GitVisuals.prototype.toScreenCoords = function(pos) {
if (!this.paper.width) { if (!this.paper.width) {
throw new Error('being called too early for screen coords'); throw new Error('being called too early for screen coords');
@ -33568,6 +33659,7 @@ var Backbone = require('backbone');
var GRAPHICS = require('../util/constants').GRAPHICS; var GRAPHICS = require('../util/constants').GRAPHICS;
var VisBase = require('../visuals/visBase').VisBase; var VisBase = require('../visuals/visBase').VisBase;
var TreeCompare = require('../git/treeCompare').TreeCompare;
var randomHueString = function() { var randomHueString = function() {
var hue = Math.random(); var hue = Math.random();
@ -33648,6 +33740,39 @@ var VisBranch = VisBase.extend({
return visNode.getScreenCoords(); return visNode.getScreenCoords();
}, },
getDashArray: function() {
if (!this.get('gitVisuals').getIsGoalVis()) {
return '';
}
return (this.getIsLevelBranchCompared()) ? '' : '- ';
},
getIsGoalAndNotCompared: function() {
if (!this.get('gitVisuals').getIsGoalVis()) {
return false;
}
return !this.getIsLevelBranchCompared();
},
/**
* returns true if we are a branch that is not being
* compared in the goal (used in a goal visualization context
*/
getIsLevelBranchCompared: function() {
if (this.getIsMaster()) {
return true; // master always compared
}
// we are not master, so return true if its not just master being compared
var levelBlob = this.get('gitVisuals').getLevelBlob();
return !TreeCompare.onlyMasterCompared(levelBlob);
},
getIsMaster: function() {
return this.get('branch').get('id') == 'master';
},
getFlipValue: function(commit, visNode) { getFlipValue: function(commit, visNode) {
var threshold = this.get('gitVisuals').getFlipPos(); var threshold = this.get('gitVisuals').getFlipPos();
var overThreshold = (visNode.get('pos').x > threshold); var overThreshold = (visNode.get('pos').x > threshold);
@ -34003,13 +34128,22 @@ var VisBranch = VisBase.extend({
if (this.get('isHead')) { if (this.get('isHead')) {
return this.gitEngine.getDetachedHead() ? 1 : 0; return this.gitEngine.getDetachedHead() ? 1 : 0;
} }
return this.getBranchStackIndex() === 0 ? 1 : 0.0; if (this.getBranchStackIndex() !== 0) {
return 0.0;
}
return 1;
}, },
getTextOpacity: function() { getTextOpacity: function() {
if (this.get('isHead')) { if (this.get('isHead')) {
return this.gitEngine.getDetachedHead() ? 1 : 0; return this.gitEngine.getDetachedHead() ? 1 : 0;
} }
if (this.getIsGoalAndNotCompared()) {
return 0.3;
}
return 1; return 1;
}, },
@ -34023,8 +34157,7 @@ var VisBranch = VisBase.extend({
var rectSize = this.getRectSize(); var rectSize = this.getRectSize();
var arrowPath = this.getArrowPath(); var arrowPath = this.getArrowPath();
var dashArray = (this.getIsInOrigin()) ? var dashArray = this.getDashArray();
GRAPHICS.originDash : '';
var cursorStyle = (this.shouldDisableClick()) ? var cursorStyle = (this.shouldDisableClick()) ?
'auto' : 'auto' :
'pointer'; 'pointer';
@ -34046,7 +34179,7 @@ var VisBranch = VisBase.extend({
opacity: nonTextOpacity, opacity: nonTextOpacity,
fill: this.getFill(), fill: this.getFill(),
stroke: this.get('stroke'), stroke: this.get('stroke'),
//'stroke-dasharray': dashArray, 'stroke-dasharray': dashArray,
'stroke-width': this.get('stroke-width') 'stroke-width': this.get('stroke-width')
}, },
arrow: { arrow: {
@ -34771,6 +34904,7 @@ var Visualization = Backbone.View.extend({
branchCollection: this.branchCollection, branchCollection: this.branchCollection,
paper: this.paper, paper: this.paper,
noClick: this.options.noClick, noClick: this.options.noClick,
isGoalVis: this.options.isGoalVis,
smallCanvas: this.options.smallCanvas, smallCanvas: this.options.smallCanvas,
visualization: this visualization: this
}); });

File diff suppressed because one or more lines are too long

1
build/bundle.min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -434,7 +434,7 @@
For a much easier time perusing the source, see the individual files at: For a much easier time perusing the source, see the individual files at:
https://github.com/pcottle/learnGitBranching https://github.com/pcottle/learnGitBranching
--> -->
<script src="build/bundle.min.ad27f098.js"></script> <script src="build/bundle.js"></script>
<!-- The advantage of github pages: super-easy, simple, slick static hostic. <!-- The advantage of github pages: super-easy, simple, slick static hostic.
The downside? No raw logs to parse for analytics, so I have to include The downside? No raw logs to parse for analytics, so I have to include

View file

@ -32,10 +32,12 @@ function getMockFactory() {
mockFactory.playCommitBirthPromiseAnimation = function(commit, visuals) { mockFactory.playCommitBirthPromiseAnimation = function(commit, visuals) {
var d = Q.defer(); var d = Q.defer();
d.resolve(); d.resolve();
// return a resolved promise here
return d.promise; return d.promise;
}; };
mockFactory.highlightEachWithPromise = function(chain, toRebase, destBranch) { mockFactory.highlightEachWithPromise = function(chain, toRebase, destBranch) {
// dont add any steps
return chain; return chain;
}; };

View file

@ -8,6 +8,18 @@ TreeCompare.dispatchFromLevel = function(levelBlob, treeToCompare) {
return TreeCompare.dispatch(levelBlob, goalTreeString, treeToCompare); return TreeCompare.dispatch(levelBlob, goalTreeString, treeToCompare);
}; };
TreeCompare.onlyMasterCompared = function(levelBlob) {
var getAroundLintTrue = true;
switch (getAroundLintTrue) {
case !!levelBlob.compareOnlyMaster:
case !!levelBlob.compareOnlyMasterHashAgnostic:
case !!levelBlob.compareOnlyMasterHashAgnosticWithAsserts:
return true;
default:
return false;
}
};
TreeCompare.dispatch = function(levelBlob, goalTreeString, treeToCompare) { TreeCompare.dispatch = function(levelBlob, goalTreeString, treeToCompare) {
var getAroundLintTrue = true; var getAroundLintTrue = true;
// i actually prefer this to else if // i actually prefer this to else if

View file

@ -177,6 +177,8 @@ var Level = Sandbox.extend({
treeString: this.level.goalTreeString, treeString: this.level.goalTreeString,
noKeyboardInput: true, noKeyboardInput: true,
smallCanvas: true, smallCanvas: true,
isGoalVis: true,
levelBlob: this.level,
noClick: true noClick: true
}); });
return this.goalCanvasHolder; return this.goalCanvasHolder;

View file

@ -141,6 +141,14 @@ GitVisuals.prototype.getFlipPos = function() {
return this.flipFraction * (max - min) + min; return this.flipFraction * (max - min) + min;
}; };
GitVisuals.prototype.getIsGoalVis = function() {
return !!this.options.isGoalVis;
};
GitVisuals.prototype.getLevelBlob = function() {
return this.visualization.options.levelBlob || {};
};
GitVisuals.prototype.toScreenCoords = function(pos) { GitVisuals.prototype.toScreenCoords = function(pos) {
if (!this.paper.width) { if (!this.paper.width) {
throw new Error('being called too early for screen coords'); throw new Error('being called too early for screen coords');

View file

@ -3,6 +3,7 @@ var Backbone = require('backbone');
var GRAPHICS = require('../util/constants').GRAPHICS; var GRAPHICS = require('../util/constants').GRAPHICS;
var VisBase = require('../visuals/visBase').VisBase; var VisBase = require('../visuals/visBase').VisBase;
var TreeCompare = require('../git/treeCompare').TreeCompare;
var randomHueString = function() { var randomHueString = function() {
var hue = Math.random(); var hue = Math.random();
@ -83,6 +84,39 @@ var VisBranch = VisBase.extend({
return visNode.getScreenCoords(); return visNode.getScreenCoords();
}, },
getDashArray: function() {
if (!this.get('gitVisuals').getIsGoalVis()) {
return '';
}
return (this.getIsLevelBranchCompared()) ? '' : '- ';
},
getIsGoalAndNotCompared: function() {
if (!this.get('gitVisuals').getIsGoalVis()) {
return false;
}
return !this.getIsLevelBranchCompared();
},
/**
* returns true if we are a branch that is not being
* compared in the goal (used in a goal visualization context
*/
getIsLevelBranchCompared: function() {
if (this.getIsMaster()) {
return true; // master always compared
}
// we are not master, so return true if its not just master being compared
var levelBlob = this.get('gitVisuals').getLevelBlob();
return !TreeCompare.onlyMasterCompared(levelBlob);
},
getIsMaster: function() {
return this.get('branch').get('id') == 'master';
},
getFlipValue: function(commit, visNode) { getFlipValue: function(commit, visNode) {
var threshold = this.get('gitVisuals').getFlipPos(); var threshold = this.get('gitVisuals').getFlipPos();
var overThreshold = (visNode.get('pos').x > threshold); var overThreshold = (visNode.get('pos').x > threshold);
@ -438,13 +472,22 @@ var VisBranch = VisBase.extend({
if (this.get('isHead')) { if (this.get('isHead')) {
return this.gitEngine.getDetachedHead() ? 1 : 0; return this.gitEngine.getDetachedHead() ? 1 : 0;
} }
return this.getBranchStackIndex() === 0 ? 1 : 0.0; if (this.getBranchStackIndex() !== 0) {
return 0.0;
}
return 1;
}, },
getTextOpacity: function() { getTextOpacity: function() {
if (this.get('isHead')) { if (this.get('isHead')) {
return this.gitEngine.getDetachedHead() ? 1 : 0; return this.gitEngine.getDetachedHead() ? 1 : 0;
} }
if (this.getIsGoalAndNotCompared()) {
return 0.3;
}
return 1; return 1;
}, },
@ -458,8 +501,7 @@ var VisBranch = VisBase.extend({
var rectSize = this.getRectSize(); var rectSize = this.getRectSize();
var arrowPath = this.getArrowPath(); var arrowPath = this.getArrowPath();
var dashArray = (this.getIsInOrigin()) ? var dashArray = this.getDashArray();
GRAPHICS.originDash : '';
var cursorStyle = (this.shouldDisableClick()) ? var cursorStyle = (this.shouldDisableClick()) ?
'auto' : 'auto' :
'pointer'; 'pointer';
@ -481,7 +523,7 @@ var VisBranch = VisBase.extend({
opacity: nonTextOpacity, opacity: nonTextOpacity,
fill: this.getFill(), fill: this.getFill(),
stroke: this.get('stroke'), stroke: this.get('stroke'),
//'stroke-dasharray': dashArray, 'stroke-dasharray': dashArray,
'stroke-width': this.get('stroke-width') 'stroke-width': this.get('stroke-width')
}, },
arrow: { arrow: {

View file

@ -49,6 +49,7 @@ var Visualization = Backbone.View.extend({
branchCollection: this.branchCollection, branchCollection: this.branchCollection,
paper: this.paper, paper: this.paper,
noClick: this.options.noClick, noClick: this.options.noClick,
isGoalVis: this.options.isGoalVis,
smallCanvas: this.options.smallCanvas, smallCanvas: this.options.smallCanvas,
visualization: this visualization: this
}); });

View file

@ -4,10 +4,9 @@ Mega Things
Before everything else: Before everything else:
~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~
[ ] fix tests by stubbing out animation factory to resolve promises
[ ] increase test coverage over everything [ ] increase test coverage over everything
- unit and integration, but mostly for git operations - unit and integration, but mostly for git operations
[ ] green refactor level compare [ ] green refactor tree compare to have map
Intl TODO Intl TODO
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
@ -35,6 +34,7 @@ Origin things:
Medium things: Medium things:
~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ ] add visuals and text to show compare method
Cases to handle / things to edit Cases to handle / things to edit
======================= =======================
@ -54,6 +54,7 @@ Ideas for cleaning
Done things: Done things:
(I only started this on Dec 17th 2012 to get a better sense of what was done) (I only started this on Dec 17th 2012 to get a better sense of what was done)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[x] fix tests by stubbing out animation factory to resolve promises
[x] better git clone and fake teamwork anywhere [x] better git clone and fake teamwork anywhere
[x] git pull animation [x] git pull animation
[x] use the graph difference algorithm to then implement git push [x] use the graph difference algorithm to then implement git push