Fossil SCM

In the timeline graph rendering code, hard-code the topRow value in the generated javascript.

drh 2017-07-05 13:00 trunk
Commit e76f3bbe45dcefd941a5649fbcadcf0303da455c66b8fa68445e92e5d04d4d14
1 file changed +7 -6
+7 -6
--- src/timeline.c
+++ src/timeline.c
@@ -684,10 +684,11 @@
684684
char cSep;
685685
int iRailPitch; /* Pixels between consecutive rails */
686686
int showArrowheads; /* True to draw arrowheads. False to omit. */
687687
int circleNodes; /* True for circle nodes. False for square nodes */
688688
int colorGraph; /* Use colors for graph lines */
689
+ int iTopRow; /* Index of the top row of the graph */
689690
690691
iRailPitch = atoi(PD("railpitch","0"));
691692
showArrowheads = skin_detail_boolean("timeline-arrowheads");
692693
circleNodes = skin_detail_boolean("timeline-circle-nodes");
693694
colorGraph = skin_detail_boolean("timeline-color-graph-lines");
@@ -709,11 +710,11 @@
709710
/* the rowinfo[] array contains all the information needed to generate
710711
** the graph. Each entry contains information for a single row:
711712
**
712713
** id: The id of the <div> element for the row. This is an integer.
713714
** to get an actual id, prepend "m" to the integer. The top node
714
- ** is topRow and numbers increase moving down the timeline.
715
+ ** is iTopRow and numbers increase moving down the timeline.
715716
** bg: The background color for this row
716717
** r: The "rail" that the node for this row sits on. The left-most
717718
** rail is 0 and the number increases to the right.
718719
** d: True if there is a "descender" - an arrow coming from the bottom
719720
** of the page straight up to this node.
@@ -735,11 +736,11 @@
735736
** negative, then the rail position is the absolute value of mi[]
736737
** and a thin merge-arrow descender is drawn to the bottom of
737738
** the screen.
738739
** h: The artifact hash of the object being graphed
739740
*/
740
- if( pGraph->pFirst ) cgi_printf("var topRow = %d\n", pGraph->pFirst->idx);
741
+ iTopRow = pGraph->pFirst ? pGraph->pFirst->idx : 0;
741742
cgi_printf("var rowinfo = [\n");
742743
for(pRow=pGraph->pFirst; pRow; pRow=pRow->pNext){
743744
cgi_printf("{id:%d,bg:\"%s\",r:%d,d:%d,mo:%d,mu:%d,u:%d,f:%d,au:",
744745
pRow->idx, /* id */
745746
pRow->zBgClr, /* bg */
@@ -912,11 +913,11 @@
912913
@ var x = p.x + (p.r<rail ? node.w : -mArrow.w);
913914
@ var cls = "arrow merge " + (p.r<rail ? "l" : "r");
914915
@ drawBox(cls,null,x,y+(mLine.w-mArrow.h)/2);
915916
@ }
916917
@ function drawNode(p, btm){
917
- @ if( p.u>0 ) drawUpArrow(p,rowinfo[p.u-topRow],p.fg);
918
+ @ if( p.u>0 ) drawUpArrow(p,rowinfo[p.u-%d(iTopRow)],p.fg);
918919
@ var cls = node.cls;
919920
@ if( p.mi.length ) cls += " merge";
920921
@ if( p.f&1 ) cls += " leaf";
921922
@ var n = drawBox(cls,p.bg,p.x,p.y);
922923
@ n.id = "tln"+p.id;
@@ -927,11 +928,11 @@
927928
@ if( p.d ) drawUpArrow({x: p.x, y: btm-node.h/2},p,p.fg);
928929
}
929930
@ if( p.mo>=0 ){
930931
@ var x0 = p.x + node.w/2;
931932
@ var x1 = p.mo*railPitch + node.w/2;
932
- @ var u = rowinfo[p.mu-topRow];
933
+ @ var u = rowinfo[p.mu-%d(iTopRow)];
933934
@ var y1 = miLineY(u);
934935
@ if( p.u<0 || p.mo!=p.r ){
935936
@ x1 += mergeLines[p.mo] = -mLine.w/2;
936937
@ var y0 = p.y+2;
937938
@ if( p.r!=p.mo ) drawMergeLine(x0,y0,x1+(x0<x1 ? mLine.w : 0),null);
@@ -951,11 +952,11 @@
951952
@ if( x0<x1 ){
952953
@ x0 = Math.ceil(x0);
953954
@ x1 += line.w;
954955
@ }
955956
@ var y0 = p.y + (node.h-line.w)/2;
956
- @ var u = rowinfo[p.au[i+1]-topRow];
957
+ @ var u = rowinfo[p.au[i+1]-%d(iTopRow)];
957958
@ if( u.id<p.id ){
958959
@ drawLine(line,u.fg,x0,y0,x1,null);
959960
@ drawUpArrow(p,u,u.fg);
960961
@ }else{
961962
@ var y1 = u.y + (node.h-line.w)/2;
@@ -997,11 +998,11 @@
997998
@ drawNode(rowinfo[i], btm);
998999
@ }
9991000
@ }
10001001
@ var selRow;
10011002
@ function clickOnNode(){
1002
- @ var p = rowinfo[parseInt(this.id.match(/\d+$/)[0], 10)-topRow];
1003
+ @ var p = rowinfo[parseInt(this.id.match(/\d+$/)[0], 10)-%d(iTopRow)];
10031004
@ if( !selRow ){
10041005
@ selRow = p;
10051006
@ this.className += " sel";
10061007
@ canvasDiv.className += " sel";
10071008
@ }else if( selRow==p ){
10081009
--- src/timeline.c
+++ src/timeline.c
@@ -684,10 +684,11 @@
684 char cSep;
685 int iRailPitch; /* Pixels between consecutive rails */
686 int showArrowheads; /* True to draw arrowheads. False to omit. */
687 int circleNodes; /* True for circle nodes. False for square nodes */
688 int colorGraph; /* Use colors for graph lines */
 
689
690 iRailPitch = atoi(PD("railpitch","0"));
691 showArrowheads = skin_detail_boolean("timeline-arrowheads");
692 circleNodes = skin_detail_boolean("timeline-circle-nodes");
693 colorGraph = skin_detail_boolean("timeline-color-graph-lines");
@@ -709,11 +710,11 @@
709 /* the rowinfo[] array contains all the information needed to generate
710 ** the graph. Each entry contains information for a single row:
711 **
712 ** id: The id of the <div> element for the row. This is an integer.
713 ** to get an actual id, prepend "m" to the integer. The top node
714 ** is topRow and numbers increase moving down the timeline.
715 ** bg: The background color for this row
716 ** r: The "rail" that the node for this row sits on. The left-most
717 ** rail is 0 and the number increases to the right.
718 ** d: True if there is a "descender" - an arrow coming from the bottom
719 ** of the page straight up to this node.
@@ -735,11 +736,11 @@
735 ** negative, then the rail position is the absolute value of mi[]
736 ** and a thin merge-arrow descender is drawn to the bottom of
737 ** the screen.
738 ** h: The artifact hash of the object being graphed
739 */
740 if( pGraph->pFirst ) cgi_printf("var topRow = %d\n", pGraph->pFirst->idx);
741 cgi_printf("var rowinfo = [\n");
742 for(pRow=pGraph->pFirst; pRow; pRow=pRow->pNext){
743 cgi_printf("{id:%d,bg:\"%s\",r:%d,d:%d,mo:%d,mu:%d,u:%d,f:%d,au:",
744 pRow->idx, /* id */
745 pRow->zBgClr, /* bg */
@@ -912,11 +913,11 @@
912 @ var x = p.x + (p.r<rail ? node.w : -mArrow.w);
913 @ var cls = "arrow merge " + (p.r<rail ? "l" : "r");
914 @ drawBox(cls,null,x,y+(mLine.w-mArrow.h)/2);
915 @ }
916 @ function drawNode(p, btm){
917 @ if( p.u>0 ) drawUpArrow(p,rowinfo[p.u-topRow],p.fg);
918 @ var cls = node.cls;
919 @ if( p.mi.length ) cls += " merge";
920 @ if( p.f&1 ) cls += " leaf";
921 @ var n = drawBox(cls,p.bg,p.x,p.y);
922 @ n.id = "tln"+p.id;
@@ -927,11 +928,11 @@
927 @ if( p.d ) drawUpArrow({x: p.x, y: btm-node.h/2},p,p.fg);
928 }
929 @ if( p.mo>=0 ){
930 @ var x0 = p.x + node.w/2;
931 @ var x1 = p.mo*railPitch + node.w/2;
932 @ var u = rowinfo[p.mu-topRow];
933 @ var y1 = miLineY(u);
934 @ if( p.u<0 || p.mo!=p.r ){
935 @ x1 += mergeLines[p.mo] = -mLine.w/2;
936 @ var y0 = p.y+2;
937 @ if( p.r!=p.mo ) drawMergeLine(x0,y0,x1+(x0<x1 ? mLine.w : 0),null);
@@ -951,11 +952,11 @@
951 @ if( x0<x1 ){
952 @ x0 = Math.ceil(x0);
953 @ x1 += line.w;
954 @ }
955 @ var y0 = p.y + (node.h-line.w)/2;
956 @ var u = rowinfo[p.au[i+1]-topRow];
957 @ if( u.id<p.id ){
958 @ drawLine(line,u.fg,x0,y0,x1,null);
959 @ drawUpArrow(p,u,u.fg);
960 @ }else{
961 @ var y1 = u.y + (node.h-line.w)/2;
@@ -997,11 +998,11 @@
997 @ drawNode(rowinfo[i], btm);
998 @ }
999 @ }
1000 @ var selRow;
1001 @ function clickOnNode(){
1002 @ var p = rowinfo[parseInt(this.id.match(/\d+$/)[0], 10)-topRow];
1003 @ if( !selRow ){
1004 @ selRow = p;
1005 @ this.className += " sel";
1006 @ canvasDiv.className += " sel";
1007 @ }else if( selRow==p ){
1008
--- src/timeline.c
+++ src/timeline.c
@@ -684,10 +684,11 @@
684 char cSep;
685 int iRailPitch; /* Pixels between consecutive rails */
686 int showArrowheads; /* True to draw arrowheads. False to omit. */
687 int circleNodes; /* True for circle nodes. False for square nodes */
688 int colorGraph; /* Use colors for graph lines */
689 int iTopRow; /* Index of the top row of the graph */
690
691 iRailPitch = atoi(PD("railpitch","0"));
692 showArrowheads = skin_detail_boolean("timeline-arrowheads");
693 circleNodes = skin_detail_boolean("timeline-circle-nodes");
694 colorGraph = skin_detail_boolean("timeline-color-graph-lines");
@@ -709,11 +710,11 @@
710 /* the rowinfo[] array contains all the information needed to generate
711 ** the graph. Each entry contains information for a single row:
712 **
713 ** id: The id of the <div> element for the row. This is an integer.
714 ** to get an actual id, prepend "m" to the integer. The top node
715 ** is iTopRow and numbers increase moving down the timeline.
716 ** bg: The background color for this row
717 ** r: The "rail" that the node for this row sits on. The left-most
718 ** rail is 0 and the number increases to the right.
719 ** d: True if there is a "descender" - an arrow coming from the bottom
720 ** of the page straight up to this node.
@@ -735,11 +736,11 @@
736 ** negative, then the rail position is the absolute value of mi[]
737 ** and a thin merge-arrow descender is drawn to the bottom of
738 ** the screen.
739 ** h: The artifact hash of the object being graphed
740 */
741 iTopRow = pGraph->pFirst ? pGraph->pFirst->idx : 0;
742 cgi_printf("var rowinfo = [\n");
743 for(pRow=pGraph->pFirst; pRow; pRow=pRow->pNext){
744 cgi_printf("{id:%d,bg:\"%s\",r:%d,d:%d,mo:%d,mu:%d,u:%d,f:%d,au:",
745 pRow->idx, /* id */
746 pRow->zBgClr, /* bg */
@@ -912,11 +913,11 @@
913 @ var x = p.x + (p.r<rail ? node.w : -mArrow.w);
914 @ var cls = "arrow merge " + (p.r<rail ? "l" : "r");
915 @ drawBox(cls,null,x,y+(mLine.w-mArrow.h)/2);
916 @ }
917 @ function drawNode(p, btm){
918 @ if( p.u>0 ) drawUpArrow(p,rowinfo[p.u-%d(iTopRow)],p.fg);
919 @ var cls = node.cls;
920 @ if( p.mi.length ) cls += " merge";
921 @ if( p.f&1 ) cls += " leaf";
922 @ var n = drawBox(cls,p.bg,p.x,p.y);
923 @ n.id = "tln"+p.id;
@@ -927,11 +928,11 @@
928 @ if( p.d ) drawUpArrow({x: p.x, y: btm-node.h/2},p,p.fg);
929 }
930 @ if( p.mo>=0 ){
931 @ var x0 = p.x + node.w/2;
932 @ var x1 = p.mo*railPitch + node.w/2;
933 @ var u = rowinfo[p.mu-%d(iTopRow)];
934 @ var y1 = miLineY(u);
935 @ if( p.u<0 || p.mo!=p.r ){
936 @ x1 += mergeLines[p.mo] = -mLine.w/2;
937 @ var y0 = p.y+2;
938 @ if( p.r!=p.mo ) drawMergeLine(x0,y0,x1+(x0<x1 ? mLine.w : 0),null);
@@ -951,11 +952,11 @@
952 @ if( x0<x1 ){
953 @ x0 = Math.ceil(x0);
954 @ x1 += line.w;
955 @ }
956 @ var y0 = p.y + (node.h-line.w)/2;
957 @ var u = rowinfo[p.au[i+1]-%d(iTopRow)];
958 @ if( u.id<p.id ){
959 @ drawLine(line,u.fg,x0,y0,x1,null);
960 @ drawUpArrow(p,u,u.fg);
961 @ }else{
962 @ var y1 = u.y + (node.h-line.w)/2;
@@ -997,11 +998,11 @@
998 @ drawNode(rowinfo[i], btm);
999 @ }
1000 @ }
1001 @ var selRow;
1002 @ function clickOnNode(){
1003 @ var p = rowinfo[parseInt(this.id.match(/\d+$/)[0], 10)-%d(iTopRow)];
1004 @ if( !selRow ){
1005 @ selRow = p;
1006 @ this.className += " sel";
1007 @ canvasDiv.className += " sel";
1008 @ }else if( selRow==p ){
1009

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button