imtk
diff src/checkbox.c @ 13:9c7987064bb0
- fixed the frame drawing a bit
- added global alpha value and various drawing parameters
- backported the checkbox check mark from glamtk
- fixed progress bar drawing so that the bevels of the trough and the bar won't overlap
author | John Tsiombikas <nuclear@siggraph.org> |
---|---|
date | Mon, 18 Apr 2011 06:15:46 +0300 |
parents | eae09a1dca1d |
children | df2bc9406561 |
line diff
1.1 --- a/src/checkbox.c Sun Apr 17 18:20:23 2011 +0300 1.2 +++ b/src/checkbox.c Mon Apr 18 06:15:46 2011 +0300 1.3 @@ -41,6 +41,21 @@ 1.4 static void draw_checkbox(int id, const char *label, int x, int y, int state, int over) 1.5 { 1.6 static const int sz = CHECKBOX_SIZE; 1.7 + static float v[][2] = { 1.8 + {-0.2, 0.63}, /* 0 */ 1.9 + {0.121, 0.325}, /* 1 */ 1.10 + {0.15, 0.5}, /* 2 */ 1.11 + {0.28, 0.125}, /* 3 */ 1.12 + {0.38, 0.33}, /* 4 */ 1.13 + {0.42, -0.122}, /* 5 */ 1.14 + {0.58, 0.25}, /* 6 */ 1.15 + {0.72, 0.52}, /* 7 */ 1.16 + {0.625, 0.65}, /* 8 */ 1.17 + {0.89, 0.78}, /* 9 */ 1.18 + {0.875, 0.92}, /* 10 */ 1.19 + {1.13, 1.145} /* 11 */ 1.20 + }; 1.21 +#define TRI(a, b, c) (glVertex2fv(v[a]), glVertex2fv(v[b]), glVertex2fv(v[c])) 1.22 1.23 if(over) { 1.24 glColor4fv(imtk_get_color(IMTK_FOCUS_COLOR)); 1.25 @@ -53,19 +68,29 @@ 1.26 1.27 glColor4fv(imtk_get_color(IMTK_TEXT_COLOR)); 1.28 if(state) { 1.29 - glPushAttrib(GL_LINE_BIT); 1.30 - glLineWidth(2); 1.31 + glMatrixMode(GL_MODELVIEW); 1.32 + glPushMatrix(); 1.33 + glTranslatef(x, y + sz, 0); 1.34 + glScalef(sz * 1.2, -sz * 1.3, 1); 1.35 1.36 - glBegin(GL_LINES); 1.37 - glVertex2f(x + 2, y + 2); 1.38 - glVertex2f(x + sz - 2, y + sz - 2); 1.39 - glVertex2f(x + sz - 2, y + 2); 1.40 - glVertex2f(x + 2, y + sz - 2); 1.41 + glBegin(GL_TRIANGLES); 1.42 + glColor4fv(imtk_get_color(IMTK_CHECK_COLOR)); 1.43 + TRI(0, 1, 2); 1.44 + TRI(1, 3, 2); 1.45 + TRI(3, 4, 2); 1.46 + TRI(3, 5, 4); 1.47 + TRI(4, 5, 6); 1.48 + TRI(4, 6, 7); 1.49 + TRI(4, 7, 8); 1.50 + TRI(8, 7, 9); 1.51 + TRI(8, 9, 10); 1.52 + TRI(10, 9, 11); 1.53 glEnd(); 1.54 1.55 - glPopAttrib(); 1.56 + glPopMatrix(); 1.57 } 1.58 1.59 + glColor4fv(imtk_get_color(IMTK_TEXT_COLOR)); 1.60 imtk_draw_string(x + sz + 5, y + sz - 2, label); 1.61 } 1.62