| | @@ -96,38 +96,34 @@ |
| 96 | 96 | #define TIMELINE_UNHIDE 0x0200 /* Unhide check-ins with "hidden" tag */ |
| 97 | 97 | #define TIMELINE_SHOWRID 0x0400 /* Show RID values in addition to UUIDs */ |
| 98 | 98 | #endif |
| 99 | 99 | |
| 100 | 100 | /* |
| 101 | | -** Hash a string and use the hash to determine a background color. |
| 101 | +** Hash a string and use the hash to determine a background color or |
| 102 | +** foreground color. |
| 102 | 103 | */ |
| 103 | | -char *hash_color(const char *z){ |
| 104 | +char *hash_color(const char *z, int bFgnd){ |
| 104 | 105 | int i; /* Loop counter */ |
| 105 | 106 | unsigned int h = 0; /* Hash on the branch name */ |
| 106 | 107 | int r, g, b; /* Values for red, green, and blue */ |
| 107 | 108 | int h1, h2, h3, h4; /* Elements of the hash value */ |
| 108 | 109 | int mx, mn; /* Components of HSV */ |
| 109 | 110 | static char zColor[10]; /* The resulting color */ |
| 110 | | - static int ix[2] = {0,0}; /* Color chooser parameters */ |
| 111 | | - |
| 112 | | - if( ix[0]==0 ){ |
| 113 | | - if( db_get_boolean("white-foreground", 0) ){ |
| 114 | | - ix[0] = 140; |
| 115 | | - ix[1] = 40; |
| 116 | | - }else{ |
| 117 | | - ix[0] = 216; |
| 118 | | - ix[1] = 16; |
| 119 | | - } |
| 120 | | - } |
| 111 | + |
| 121 | 112 | for(i=0; z[i]; i++ ){ |
| 122 | 113 | h = (h<<11) ^ (h<<1) ^ (h>>3) ^ z[i]; |
| 123 | 114 | } |
| 124 | 115 | h1 = h % 6; h /= 6; |
| 125 | 116 | h3 = h % 30; h /= 30; |
| 126 | 117 | h4 = h % 40; h /= 40; |
| 127 | | - mx = ix[0] - h3; |
| 128 | | - mn = mx - h4 - ix[1]; |
| 118 | + if( bFgnd^skin_white_foreground() ){ |
| 119 | + mx = 140 - h3; |
| 120 | + mn = mx - h4 - 40; |
| 121 | + }else{ |
| 122 | + mx = 216 - h3; |
| 123 | + mn = mx - h4 - 16; |
| 124 | + } |
| 129 | 125 | h2 = (h%(mx - mn)) + mn; |
| 130 | 126 | switch( h1 ){ |
| 131 | 127 | case 0: r = mx; g = h2, b = mn; break; |
| 132 | 128 | case 1: r = h2; g = mx, b = mn; break; |
| 133 | 129 | case 2: r = mn; g = mx, b = h2; break; |
| | @@ -148,11 +144,11 @@ |
| 148 | 144 | ** testing the hash_color() function. |
| 149 | 145 | */ |
| 150 | 146 | void test_hash_color(void){ |
| 151 | 147 | int i; |
| 152 | 148 | for(i=2; i<g.argc; i++){ |
| 153 | | - fossil_print("%20s: %s\n", g.argv[i], hash_color(g.argv[i])); |
| 149 | + fossil_print("%20s: %s\n", g.argv[i], hash_color(g.argv[i], 0)); |
| 154 | 150 | } |
| 155 | 151 | } |
| 156 | 152 | |
| 157 | 153 | /* |
| 158 | 154 | ** WEBPAGE: hash-color-test |
| | @@ -170,15 +166,18 @@ |
| 170 | 166 | style_header("Hash Color Test"); |
| 171 | 167 | for(i=cnt=0; i<10; i++){ |
| 172 | 168 | sqlite3_snprintf(sizeof(zNm),zNm,"b%d",i); |
| 173 | 169 | zBr = P(zNm); |
| 174 | 170 | if( zBr && zBr[0] ){ |
| 175 | | - @ <p style='border:1px solid;background-color:%s(hash_color(zBr));'> |
| 176 | | - @ %h(zBr) - %s(hash_color(zBr)) - |
| 171 | + @ <p> |
| 172 | + @ <span style='border:1px solid;background-color:%s(hash_color(zBr,0));'> |
| 173 | + @ %h(zBr) - %s(hash_color(zBr,0)) - |
| 177 | 174 | @ Omnes nos quasi oves erravimus unusquisque in viam |
| 178 | | - @ suam declinavit.</p> |
| 175 | + @ suam declinavit.</span> |
| 179 | 176 | cnt++; |
| 177 | + @ <span style='color:%s(hash_color(zBr,1))'> |
| 178 | + @ Corresponding foreground color: %s(hash_color(zBr,1))</span></p> |
| 180 | 179 | } |
| 181 | 180 | } |
| 182 | 181 | if( cnt ){ |
| 183 | 182 | @ <hr> |
| 184 | 183 | } |
| | @@ -353,11 +352,11 @@ |
| 353 | 352 | }else { |
| 354 | 353 | @ <tr> |
| 355 | 354 | } |
| 356 | 355 | @ <td class="timelineTime">%s(zTime)</td> |
| 357 | 356 | @ <td class="timelineGraph"> |
| 358 | | - if( tmFlags & TIMELINE_UCOLOR ) zBgClr = zUser ? hash_color(zUser) : 0; |
| 357 | + if( tmFlags & TIMELINE_UCOLOR ) zBgClr = zUser ? hash_color(zUser,0) : 0; |
| 359 | 358 | if( zType[0]=='c' |
| 360 | 359 | && (pGraph || zBgClr==0 || (tmFlags & TIMELINE_BRCOLOR)!=0) |
| 361 | 360 | ){ |
| 362 | 361 | db_reset(&qbranch); |
| 363 | 362 | db_bind_int(&qbranch, ":rid", rid); |
| | @@ -368,11 +367,11 @@ |
| 368 | 367 | } |
| 369 | 368 | if( zBgClr==0 || (tmFlags & TIMELINE_BRCOLOR)!=0 ){ |
| 370 | 369 | if( zBr==0 || strcmp(zBr,"trunk")==0 ){ |
| 371 | 370 | zBgClr = 0; |
| 372 | 371 | }else{ |
| 373 | | - zBgClr = hash_color(zBr); |
| 372 | + zBgClr = hash_color(zBr,0); |
| 374 | 373 | } |
| 375 | 374 | } |
| 376 | 375 | } |
| 377 | 376 | if( zType[0]=='c' && (pGraph || (tmFlags & TIMELINE_BRCOLOR)!=0) ){ |
| 378 | 377 | int nParent = 0; |
| 379 | 378 | |