# HG changeset patch # User John Tsiombikas # Date 1303847601 -10800 # Node ID 11da537aeba65f21673b460b7355cdc76416c7a3 # Parent 737e9047d9c90249040c641d5b34bc18625240c5 blah diff -r 737e9047d9c9 -r 11da537aeba6 src/draw.c --- a/src/draw.c Mon Apr 25 08:54:05 2011 +0300 +++ b/src/draw.c Tue Apr 26 22:53:21 2011 +0300 @@ -116,45 +116,6 @@ glEnd(); } -void imtk_draw_disc(int x, int y, float rad, int subdiv, float *ctop, float *cbot) -{ - int i; - float t, dtheta, theta = 0.0; - float color[4]; - float cx = (float)x; - float cy = (float)y; - - subdiv += 3; - dtheta = 2.0 * M_PI / subdiv; - - color[0] = (ctop[0] + cbot[0]) * 0.5; - color[1] = (ctop[1] + cbot[1]) * 0.5; - color[2] = (ctop[2] + cbot[2]) * 0.5; - color[3] = (ctop[3] + cbot[3]) * 0.5; - - glBegin(GL_TRIANGLE_FAN); - glColor4fv(color); - glVertex2f(cx, cy); - - for(i=0; i<=subdiv; i++) { - float vx, vy; - - vx = cx + cos(theta) * rad; - vy = cy + sin(theta) * rad; - theta += dtheta; - - t = (vy - (cy - rad)) / (2.0 * rad); - color[0] = ctop[0] + (cbot[0] - ctop[0]) * t; - color[1] = ctop[1] + (cbot[1] - ctop[1]) * t; - color[2] = ctop[2] + (cbot[2] - ctop[2]) * t; - color[3] = ctop[3] + (cbot[3] - ctop[3]) * t; - - glColor4fv(color); - glVertex2f(vx, vy); - } - glEnd(); -} - void imtk_draw_frame(int x, int y, int w, int h, int style) { float tcol[4], bcol[4]; @@ -206,6 +167,93 @@ glEnd(); } +void imtk_draw_disc(int x, int y, float rad, int subdiv, float *ctop, float *cbot) +{ + int i; + float t, dtheta, theta = 0.0; + float color[4]; + float cx = (float)x; + float cy = (float)y; + + subdiv += 3; + dtheta = 2.0 * M_PI / subdiv; + + color[0] = (ctop[0] + cbot[0]) * 0.5; + color[1] = (ctop[1] + cbot[1]) * 0.5; + color[2] = (ctop[2] + cbot[2]) * 0.5; + color[3] = (ctop[3] + cbot[3]) * 0.5; + + glBegin(GL_TRIANGLE_FAN); + glColor4fv(color); + glVertex2f(cx, cy); + + for(i=0; i<=subdiv; i++) { + float vx, vy; + + vx = cos(theta); + vy = sin(theta); + theta += dtheta; + + t = (vy + 1.0) / 2.0; + color[0] = ctop[0] + (cbot[0] - ctop[0]) * t; + color[1] = ctop[1] + (cbot[1] - ctop[1]) * t; + color[2] = ctop[2] + (cbot[2] - ctop[2]) * t; + color[3] = ctop[3] + (cbot[3] - ctop[3]) * t; + + glColor4fv(color); + glVertex2f(cx + vx * rad, cy + vy * rad); + } + glEnd(); +} + +void imtk_draw_disc_frame(int x, int y, float inner, float outer, int subdiv, int style) +{ + int i; + float t, dtheta, theta = 0.0; + float color[4], tcol[4], bcol[4]; + float cx = (float)x; + float cy = (float)y; + + switch(style) { + case FRAME_INSET: + memcpy(tcol, imtk_get_color(IMTK_BEVEL_SHAD_COLOR), sizeof tcol); + memcpy(bcol, imtk_get_color(IMTK_BEVEL_LIT_COLOR), sizeof bcol); + break; + + case FRAME_OUTSET: + default: + memcpy(tcol, imtk_get_color(IMTK_BEVEL_LIT_COLOR), sizeof tcol); + memcpy(bcol, imtk_get_color(IMTK_BEVEL_SHAD_COLOR), sizeof bcol); + } + + subdiv += 3; + dtheta = 2.0 * M_PI / subdiv; + + glBegin(GL_QUAD_STRIP); + + for(i=0; i<=subdiv; i++) { + float vx, vy; + + vx = cos(theta); + vy = sin(theta); + + t = (vy + 1.0) / 2.0; + color[0] = tcol[0] + (bcol[0] - tcol[0]) * t; + color[1] = tcol[1] + (bcol[1] - tcol[1]) * t; + color[2] = tcol[2] + (bcol[2] - tcol[2]) * t; + color[3] = tcol[3] + (bcol[3] - tcol[3]) * t; + + vx = cos(theta - M_PI / 4.0); + vy = sin(theta - M_PI / 4.0); + theta += dtheta; + + glColor4fv(color); + glVertex2f(cx + vx * inner, cy + vy * inner); + glVertex2f(cx + vx * outer, cy + vy * outer); + } + glEnd(); +} + void imtk_draw_string(int x, int y, const char *str) { glRasterPos2i(x, y); diff -r 737e9047d9c9 -r 11da537aeba6 src/draw.h --- a/src/draw.h Mon Apr 25 08:54:05 2011 +0300 +++ b/src/draw.h Tue Apr 26 22:53:21 2011 +0300 @@ -14,9 +14,9 @@ }; void imtk_draw_rect(int x, int y, int w, int h, float *ctop, float *cbot); +void imtk_draw_frame(int x, int y, int w, int h, int style); void imtk_draw_disc(int x, int y, float rad, int subdiv, float *ctop, float *cbot); - -void imtk_draw_frame(int x, int y, int w, int h, int style); +void imtk_draw_disc_frame(int x, int y, float inner, float outer, int subdiv, int style); void imtk_draw_string(int x, int y, const char *str); int imtk_string_size(const char *str); diff -r 737e9047d9c9 -r 11da537aeba6 src/listbox.c --- a/src/listbox.c Mon Apr 25 08:54:05 2011 +0300 +++ b/src/listbox.c Tue Apr 26 22:53:21 2011 +0300 @@ -155,15 +155,17 @@ attr |= IMTK_FOCUS_BIT; } + imtk_draw_disc_frame(x + rad, item_y + rad, rad * 0.9, rad * 0.75, 5, FRAME_INSET); + memcpy(tcol, imtk_get_color(IMTK_BOTTOM_COLOR | attr), sizeof tcol); memcpy(bcol, imtk_get_color(IMTK_TOP_COLOR | attr), sizeof bcol); - - imtk_draw_disc(x + rad, item_y + rad, rad * 0.8, 5, tcol, bcol); + imtk_draw_disc(x + rad, item_y + rad, rad * 0.75, 5, tcol, bcol); if(i == sel) { attr |= IMTK_SEL_BIT; memcpy(tcol, imtk_get_color(IMTK_TOP_COLOR | attr), sizeof tcol); memcpy(bcol, imtk_get_color(IMTK_BOTTOM_COLOR | attr), sizeof bcol); + imtk_draw_disc(x + rad, item_y + ITEM_HEIGHT / 2, rad * 0.6, 5, tcol, bcol); }