Fossil SCM

Make the spacing between vertical rail centerlines in the graph adjustable based on the number of rails. Use less horizontal space.

drh 2012-12-06 01:47 trunk
Commit d57481a707e1d558d0535f3b961f6aecd3842033
2 files changed +1 +11 -6
--- src/graph.c
+++ src/graph.c
@@ -61,10 +61,11 @@
6161
/* Context while building a graph
6262
*/
6363
struct GraphContext {
6464
int nErr; /* Number of errors encountered */
6565
int mxRail; /* Number of rails required to render the graph */
66
+ int iRailPitch; /* Pixels between rail centers */
6667
GraphRow *pFirst; /* First row in the list */
6768
GraphRow *pLast; /* Last row in the list */
6869
int nBranch; /* Number of distinct branches */
6970
char **azBranch; /* Names of the branches */
7071
int nRow; /* Number of rows */
7172
--- src/graph.c
+++ src/graph.c
@@ -61,10 +61,11 @@
61 /* Context while building a graph
62 */
63 struct GraphContext {
64 int nErr; /* Number of errors encountered */
65 int mxRail; /* Number of rails required to render the graph */
 
66 GraphRow *pFirst; /* First row in the list */
67 GraphRow *pLast; /* Last row in the list */
68 int nBranch; /* Number of distinct branches */
69 char **azBranch; /* Names of the branches */
70 int nRow; /* Number of rows */
71
--- src/graph.c
+++ src/graph.c
@@ -61,10 +61,11 @@
61 /* Context while building a graph
62 */
63 struct GraphContext {
64 int nErr; /* Number of errors encountered */
65 int mxRail; /* Number of rails required to render the graph */
66 int iRailPitch; /* Pixels between rail centers */
67 GraphRow *pFirst; /* First row in the list */
68 GraphRow *pLast; /* Last row in the list */
69 int nBranch; /* Number of distinct branches */
70 char **azBranch; /* Names of the branches */
71 int nRow; /* Number of rows */
72
+11 -6
--- src/timeline.c
+++ src/timeline.c
@@ -483,15 +483,19 @@
483483
graph_finish(pGraph, (tmFlags & TIMELINE_DISJOINT)!=0);
484484
if( pGraph->nErr ){
485485
graph_free(pGraph);
486486
pGraph = 0;
487487
}else{
488
+ int w;
488489
/* style is not moved to css, because this is
489490
** a technical div for the timeline graph
490491
*/
492
+ pGraph->iRailPitch = 18 - (pGraph->mxRail/3);
493
+ if( pGraph->iRailPitch<12 ) pGraph->iRailPitch = 12;
494
+ w = pGraph->mxRail*pGraph->iRailPitch + 30;
491495
@ <tr><td></td><td>
492
- @ <div id="grbtm" style="width:%d(pGraph->mxRail*20+30)px;"></div>
496
+ @ <div id="grbtm" style="width:%d(w)px;"></div>
493497
@ </td><td></td></tr>
494498
}
495499
}
496500
@ </table>
497501
if( fchngQueryInit ) db_finalize(&fchngQuery);
@@ -511,10 +515,11 @@
511515
GraphRow *pRow;
512516
int i;
513517
char cSep;
514518
@ <script type="text/JavaScript">
515519
@ /* <![CDATA[ */
520
+ @ var railPitch=%d(pGraph->iRailPitch);
516521
517522
/* the rowinfo[] array contains all the information needed to generate
518523
** the graph. Each entry contains information for a single row:
519524
**
520525
** id: The id of the <div> element for the row. This is an integer.
@@ -549,11 +554,11 @@
549554
for(pRow=pGraph->pFirst; pRow; pRow=pRow->pNext){
550555
int mo = pRow->mergeOut;
551556
if( mo<0 ){
552557
mo = 0;
553558
}else{
554
- mo = (mo/4)*20 - 3 + 4*(mo&3);
559
+ mo = (mo/4)*pGraph->iRailPitch - 3 + 4*(mo&3);
555560
}
556561
cgi_printf("{id:%d,bg:\"%s\",r:%d,d:%d,mo:%d,mu:%d,u:%d,f:%d,au:",
557562
pRow->idx, /* id */
558563
pRow->zBgClr, /* bg */
559564
pRow->iRail, /* r */
@@ -576,11 +581,11 @@
576581
cgi_printf("],mi:");
577582
/* mi */
578583
cSep = '[';
579584
for(i=0; i<GR_MAX_RAIL; i++){
580585
if( pRow->mergeIn[i] ){
581
- int mi = i*20 - 8 + 4*pRow->mergeIn[i];
586
+ int mi = i*pGraph->iRailPitch - 8 + 4*pRow->mergeIn[i];
582587
if( pRow->mergeDown & (1<<i) ) mi = -mi;
583588
cgi_printf("%c%d", cSep, mi);
584589
cSep = ',';
585590
}
586591
}
@@ -677,11 +682,11 @@
677682
@ }
678683
@ drawThinLine(x1,y0,x1,y1);
679684
@ }
680685
@ var n = p.au.length;
681686
@ for(var i=0; i<n; i+=2){
682
- @ var x1 = p.au[i]*20 + left;
687
+ @ var x1 = p.au[i]*railPitch + left;
683688
@ var x0 = x1>p.x ? p.x+7 : p.x-6;
684689
@ var u = rowinfo[p.au[i+1]-1];
685690
@ if(u.id<p.id){
686691
@ drawBox("black",x0,p.y,x1,p.y+1);
687692
@ drawUpArrow(x1, u.y+6, p.y);
@@ -716,14 +721,14 @@
716721
@ while( canvasDiv.hasChildNodes() ){
717722
@ canvasDiv.removeChild(canvasDiv.firstChild);
718723
@ }
719724
@ var canvasY = absoluteY("timelineTable");
720725
@ var left = absoluteX("m"+rowinfo[0].id) - absoluteX("canvas") + 15;
721
- @ var width = nrail*20;
726
+ @ var width = nrail*railPitch;
722727
@ for(var i in rowinfo){
723728
@ rowinfo[i].y = absoluteY("m"+rowinfo[i].id) + 10 - canvasY;
724
- @ rowinfo[i].x = left + rowinfo[i].r*20;
729
+ @ rowinfo[i].x = left + rowinfo[i].r*railPitch;
725730
@ }
726731
@ var btm = absoluteY("grbtm") + 10 - canvasY;
727732
#if 0
728733
@ if( btm<32768 ){
729734
@ canvasDiv.innerHTML = '<canvas id="timeline-canvas" '+
730735
--- src/timeline.c
+++ src/timeline.c
@@ -483,15 +483,19 @@
483 graph_finish(pGraph, (tmFlags & TIMELINE_DISJOINT)!=0);
484 if( pGraph->nErr ){
485 graph_free(pGraph);
486 pGraph = 0;
487 }else{
 
488 /* style is not moved to css, because this is
489 ** a technical div for the timeline graph
490 */
 
 
 
491 @ <tr><td></td><td>
492 @ <div id="grbtm" style="width:%d(pGraph->mxRail*20+30)px;"></div>
493 @ </td><td></td></tr>
494 }
495 }
496 @ </table>
497 if( fchngQueryInit ) db_finalize(&fchngQuery);
@@ -511,10 +515,11 @@
511 GraphRow *pRow;
512 int i;
513 char cSep;
514 @ <script type="text/JavaScript">
515 @ /* <![CDATA[ */
 
516
517 /* the rowinfo[] array contains all the information needed to generate
518 ** the graph. Each entry contains information for a single row:
519 **
520 ** id: The id of the <div> element for the row. This is an integer.
@@ -549,11 +554,11 @@
549 for(pRow=pGraph->pFirst; pRow; pRow=pRow->pNext){
550 int mo = pRow->mergeOut;
551 if( mo<0 ){
552 mo = 0;
553 }else{
554 mo = (mo/4)*20 - 3 + 4*(mo&3);
555 }
556 cgi_printf("{id:%d,bg:\"%s\",r:%d,d:%d,mo:%d,mu:%d,u:%d,f:%d,au:",
557 pRow->idx, /* id */
558 pRow->zBgClr, /* bg */
559 pRow->iRail, /* r */
@@ -576,11 +581,11 @@
576 cgi_printf("],mi:");
577 /* mi */
578 cSep = '[';
579 for(i=0; i<GR_MAX_RAIL; i++){
580 if( pRow->mergeIn[i] ){
581 int mi = i*20 - 8 + 4*pRow->mergeIn[i];
582 if( pRow->mergeDown & (1<<i) ) mi = -mi;
583 cgi_printf("%c%d", cSep, mi);
584 cSep = ',';
585 }
586 }
@@ -677,11 +682,11 @@
677 @ }
678 @ drawThinLine(x1,y0,x1,y1);
679 @ }
680 @ var n = p.au.length;
681 @ for(var i=0; i<n; i+=2){
682 @ var x1 = p.au[i]*20 + left;
683 @ var x0 = x1>p.x ? p.x+7 : p.x-6;
684 @ var u = rowinfo[p.au[i+1]-1];
685 @ if(u.id<p.id){
686 @ drawBox("black",x0,p.y,x1,p.y+1);
687 @ drawUpArrow(x1, u.y+6, p.y);
@@ -716,14 +721,14 @@
716 @ while( canvasDiv.hasChildNodes() ){
717 @ canvasDiv.removeChild(canvasDiv.firstChild);
718 @ }
719 @ var canvasY = absoluteY("timelineTable");
720 @ var left = absoluteX("m"+rowinfo[0].id) - absoluteX("canvas") + 15;
721 @ var width = nrail*20;
722 @ for(var i in rowinfo){
723 @ rowinfo[i].y = absoluteY("m"+rowinfo[i].id) + 10 - canvasY;
724 @ rowinfo[i].x = left + rowinfo[i].r*20;
725 @ }
726 @ var btm = absoluteY("grbtm") + 10 - canvasY;
727 #if 0
728 @ if( btm<32768 ){
729 @ canvasDiv.innerHTML = '<canvas id="timeline-canvas" '+
730
--- src/timeline.c
+++ src/timeline.c
@@ -483,15 +483,19 @@
483 graph_finish(pGraph, (tmFlags & TIMELINE_DISJOINT)!=0);
484 if( pGraph->nErr ){
485 graph_free(pGraph);
486 pGraph = 0;
487 }else{
488 int w;
489 /* style is not moved to css, because this is
490 ** a technical div for the timeline graph
491 */
492 pGraph->iRailPitch = 18 - (pGraph->mxRail/3);
493 if( pGraph->iRailPitch<12 ) pGraph->iRailPitch = 12;
494 w = pGraph->mxRail*pGraph->iRailPitch + 30;
495 @ <tr><td></td><td>
496 @ <div id="grbtm" style="width:%d(w)px;"></div>
497 @ </td><td></td></tr>
498 }
499 }
500 @ </table>
501 if( fchngQueryInit ) db_finalize(&fchngQuery);
@@ -511,10 +515,11 @@
515 GraphRow *pRow;
516 int i;
517 char cSep;
518 @ <script type="text/JavaScript">
519 @ /* <![CDATA[ */
520 @ var railPitch=%d(pGraph->iRailPitch);
521
522 /* the rowinfo[] array contains all the information needed to generate
523 ** the graph. Each entry contains information for a single row:
524 **
525 ** id: The id of the <div> element for the row. This is an integer.
@@ -549,11 +554,11 @@
554 for(pRow=pGraph->pFirst; pRow; pRow=pRow->pNext){
555 int mo = pRow->mergeOut;
556 if( mo<0 ){
557 mo = 0;
558 }else{
559 mo = (mo/4)*pGraph->iRailPitch - 3 + 4*(mo&3);
560 }
561 cgi_printf("{id:%d,bg:\"%s\",r:%d,d:%d,mo:%d,mu:%d,u:%d,f:%d,au:",
562 pRow->idx, /* id */
563 pRow->zBgClr, /* bg */
564 pRow->iRail, /* r */
@@ -576,11 +581,11 @@
581 cgi_printf("],mi:");
582 /* mi */
583 cSep = '[';
584 for(i=0; i<GR_MAX_RAIL; i++){
585 if( pRow->mergeIn[i] ){
586 int mi = i*pGraph->iRailPitch - 8 + 4*pRow->mergeIn[i];
587 if( pRow->mergeDown & (1<<i) ) mi = -mi;
588 cgi_printf("%c%d", cSep, mi);
589 cSep = ',';
590 }
591 }
@@ -677,11 +682,11 @@
682 @ }
683 @ drawThinLine(x1,y0,x1,y1);
684 @ }
685 @ var n = p.au.length;
686 @ for(var i=0; i<n; i+=2){
687 @ var x1 = p.au[i]*railPitch + left;
688 @ var x0 = x1>p.x ? p.x+7 : p.x-6;
689 @ var u = rowinfo[p.au[i+1]-1];
690 @ if(u.id<p.id){
691 @ drawBox("black",x0,p.y,x1,p.y+1);
692 @ drawUpArrow(x1, u.y+6, p.y);
@@ -716,14 +721,14 @@
721 @ while( canvasDiv.hasChildNodes() ){
722 @ canvasDiv.removeChild(canvasDiv.firstChild);
723 @ }
724 @ var canvasY = absoluteY("timelineTable");
725 @ var left = absoluteX("m"+rowinfo[0].id) - absoluteX("canvas") + 15;
726 @ var width = nrail*railPitch;
727 @ for(var i in rowinfo){
728 @ rowinfo[i].y = absoluteY("m"+rowinfo[i].id) + 10 - canvasY;
729 @ rowinfo[i].x = left + rowinfo[i].r*railPitch;
730 @ }
731 @ var btm = absoluteY("grbtm") + 10 - canvasY;
732 #if 0
733 @ if( btm<32768 ){
734 @ canvasDiv.innerHTML = '<canvas id="timeline-canvas" '+
735

Keyboard Shortcuts

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