Skip to content

Commit e323764

Browse files
author
Philip Guo
committed
more annotation bubbles fun
1 parent f650ca7 commit e323764

2 files changed

Lines changed: 35 additions & 3 deletions

File tree

v3/css/pytutor.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,13 @@ div.ExecutionVisualizer div#editCodeLinkDiv {
145145
}
146146

147147
div.ExecutionVisualizer div#annotateLinkDiv {
148-
text-align: center;
148+
/*text-align: left;*/
149149
margin-top: 0px;
150150
margin-bottom: 5px;
151+
/*
151152
margin-left: auto;
152153
margin-right: auto;
154+
*/
153155
}
154156

155157
div.ExecutionVisualizer div#stepAnnotationDiv {

v3/js/pytutor.js

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,8 @@ ExecutionVisualizer.prototype.initAllAnnotationBubbles = function() {
492492
}
493493
});
494494
});
495+
496+
//console.log('initAllAnnotationBubbles', myViz.allAnnotationBubbles.length);
495497
}
496498

497499

@@ -508,7 +510,12 @@ ExecutionVisualizer.prototype.enterViewAnnotationsMode = function() {
508510
// and display them in 'View' mode
509511
myViz.initAllAnnotationBubbles();
510512

511-
// TODO: set text of those bubbles from curEntry.annotations
513+
$.each(myViz.allAnnotationBubbles, function(i, e) {
514+
var txt = curEntry.annotations[e.domID];
515+
if (txt) {
516+
e.preseedText(txt);
517+
}
518+
});
512519
}
513520
}
514521

@@ -611,6 +618,10 @@ ExecutionVisualizer.prototype.findNextBreakpoint = function() {
611618
ExecutionVisualizer.prototype.stepForward = function() {
612619
var myViz = this;
613620

621+
if (myViz.editAnnotationMode) {
622+
return;
623+
}
624+
614625
if (myViz.curInstr < myViz.curTrace.length - 1) {
615626
// if there is a next breakpoint, then jump to it ...
616627
if (myViz.sortedBreakpointsList.length > 0) {
@@ -634,6 +645,10 @@ ExecutionVisualizer.prototype.stepForward = function() {
634645
ExecutionVisualizer.prototype.stepBack = function() {
635646
var myViz = this;
636647

648+
if (myViz.editAnnotationMode) {
649+
return;
650+
}
651+
637652
if (myViz.curInstr > 0) {
638653
// if there is a prev breakpoint, then jump to it ...
639654
if (myViz.sortedBreakpointsList.length > 0) {
@@ -2619,7 +2634,7 @@ AnnotationBubble.prototype.bindViewerClickHandler = function() {
26192634
}
26202635

26212636
AnnotationBubble.prototype.showViewer = function() {
2622-
assert(this.state == 'edit');
2637+
assert(this.state == 'edit' || this.state == 'invisible');
26232638
assert(this.text); // must be non-empty!
26242639

26252640
// destroy then create a new tip:
@@ -2718,6 +2733,21 @@ AnnotationBubble.prototype.enterViewMode = function() {
27182733
this.makeInvisible();
27192734
}
27202735
}
2736+
else if (this.state == 'invisible') {
2737+
// this happens when, say, you first enter View Mode
2738+
if (this.text) {
2739+
this.showViewer();
2740+
2741+
if (this.type == 'codeline') {
2742+
this.redrawCodelineBubble();
2743+
}
2744+
}
2745+
}
2746+
}
2747+
2748+
AnnotationBubble.prototype.preseedText = function(txt) {
2749+
assert(this.state == 'invisible');
2750+
this.text = txt;
27212751
}
27222752

27232753
AnnotationBubble.prototype.redrawCodelineBubble = function() {

0 commit comments

Comments
 (0)