Fossil SCM
Make the spacing between vertical rail centerlines in the graph adjustable based on the number of rails. Use less horizontal space.
Commit
d57481a707e1d558d0535f3b961f6aecd3842033
Parent
0eb3d8e828ef580…
2 files changed
+1
+11
-6
+1
| --- src/graph.c | ||
| +++ src/graph.c | ||
| @@ -61,10 +61,11 @@ | ||
| 61 | 61 | /* Context while building a graph |
| 62 | 62 | */ |
| 63 | 63 | struct GraphContext { |
| 64 | 64 | int nErr; /* Number of errors encountered */ |
| 65 | 65 | int mxRail; /* Number of rails required to render the graph */ |
| 66 | + int iRailPitch; /* Pixels between rail centers */ | |
| 66 | 67 | GraphRow *pFirst; /* First row in the list */ |
| 67 | 68 | GraphRow *pLast; /* Last row in the list */ |
| 68 | 69 | int nBranch; /* Number of distinct branches */ |
| 69 | 70 | char **azBranch; /* Names of the branches */ |
| 70 | 71 | int nRow; /* Number of rows */ |
| 71 | 72 |
| --- 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 @@ | ||
| 483 | 483 | graph_finish(pGraph, (tmFlags & TIMELINE_DISJOINT)!=0); |
| 484 | 484 | if( pGraph->nErr ){ |
| 485 | 485 | graph_free(pGraph); |
| 486 | 486 | pGraph = 0; |
| 487 | 487 | }else{ |
| 488 | + int w; | |
| 488 | 489 | /* style is not moved to css, because this is |
| 489 | 490 | ** a technical div for the timeline graph |
| 490 | 491 | */ |
| 492 | + pGraph->iRailPitch = 18 - (pGraph->mxRail/3); | |
| 493 | + if( pGraph->iRailPitch<12 ) pGraph->iRailPitch = 12; | |
| 494 | + w = pGraph->mxRail*pGraph->iRailPitch + 30; | |
| 491 | 495 | @ <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> | |
| 493 | 497 | @ </td><td></td></tr> |
| 494 | 498 | } |
| 495 | 499 | } |
| 496 | 500 | @ </table> |
| 497 | 501 | if( fchngQueryInit ) db_finalize(&fchngQuery); |
| @@ -511,10 +515,11 @@ | ||
| 511 | 515 | GraphRow *pRow; |
| 512 | 516 | int i; |
| 513 | 517 | char cSep; |
| 514 | 518 | @ <script type="text/JavaScript"> |
| 515 | 519 | @ /* <![CDATA[ */ |
| 520 | + @ var railPitch=%d(pGraph->iRailPitch); | |
| 516 | 521 | |
| 517 | 522 | /* the rowinfo[] array contains all the information needed to generate |
| 518 | 523 | ** the graph. Each entry contains information for a single row: |
| 519 | 524 | ** |
| 520 | 525 | ** id: The id of the <div> element for the row. This is an integer. |
| @@ -549,11 +554,11 @@ | ||
| 549 | 554 | for(pRow=pGraph->pFirst; pRow; pRow=pRow->pNext){ |
| 550 | 555 | int mo = pRow->mergeOut; |
| 551 | 556 | if( mo<0 ){ |
| 552 | 557 | mo = 0; |
| 553 | 558 | }else{ |
| 554 | - mo = (mo/4)*20 - 3 + 4*(mo&3); | |
| 559 | + mo = (mo/4)*pGraph->iRailPitch - 3 + 4*(mo&3); | |
| 555 | 560 | } |
| 556 | 561 | cgi_printf("{id:%d,bg:\"%s\",r:%d,d:%d,mo:%d,mu:%d,u:%d,f:%d,au:", |
| 557 | 562 | pRow->idx, /* id */ |
| 558 | 563 | pRow->zBgClr, /* bg */ |
| 559 | 564 | pRow->iRail, /* r */ |
| @@ -576,11 +581,11 @@ | ||
| 576 | 581 | cgi_printf("],mi:"); |
| 577 | 582 | /* mi */ |
| 578 | 583 | cSep = '['; |
| 579 | 584 | for(i=0; i<GR_MAX_RAIL; i++){ |
| 580 | 585 | 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]; | |
| 582 | 587 | if( pRow->mergeDown & (1<<i) ) mi = -mi; |
| 583 | 588 | cgi_printf("%c%d", cSep, mi); |
| 584 | 589 | cSep = ','; |
| 585 | 590 | } |
| 586 | 591 | } |
| @@ -677,11 +682,11 @@ | ||
| 677 | 682 | @ } |
| 678 | 683 | @ drawThinLine(x1,y0,x1,y1); |
| 679 | 684 | @ } |
| 680 | 685 | @ var n = p.au.length; |
| 681 | 686 | @ for(var i=0; i<n; i+=2){ |
| 682 | - @ var x1 = p.au[i]*20 + left; | |
| 687 | + @ var x1 = p.au[i]*railPitch + left; | |
| 683 | 688 | @ var x0 = x1>p.x ? p.x+7 : p.x-6; |
| 684 | 689 | @ var u = rowinfo[p.au[i+1]-1]; |
| 685 | 690 | @ if(u.id<p.id){ |
| 686 | 691 | @ drawBox("black",x0,p.y,x1,p.y+1); |
| 687 | 692 | @ drawUpArrow(x1, u.y+6, p.y); |
| @@ -716,14 +721,14 @@ | ||
| 716 | 721 | @ while( canvasDiv.hasChildNodes() ){ |
| 717 | 722 | @ canvasDiv.removeChild(canvasDiv.firstChild); |
| 718 | 723 | @ } |
| 719 | 724 | @ var canvasY = absoluteY("timelineTable"); |
| 720 | 725 | @ var left = absoluteX("m"+rowinfo[0].id) - absoluteX("canvas") + 15; |
| 721 | - @ var width = nrail*20; | |
| 726 | + @ var width = nrail*railPitch; | |
| 722 | 727 | @ for(var i in rowinfo){ |
| 723 | 728 | @ 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; | |
| 725 | 730 | @ } |
| 726 | 731 | @ var btm = absoluteY("grbtm") + 10 - canvasY; |
| 727 | 732 | #if 0 |
| 728 | 733 | @ if( btm<32768 ){ |
| 729 | 734 | @ canvasDiv.innerHTML = '<canvas id="timeline-canvas" '+ |
| 730 | 735 |
| --- 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 |