imtk
diff src/textbox.c @ 14:df2bc9406561
added gradients
author | John Tsiombikas <nuclear@siggraph.org> |
---|---|
date | Tue, 19 Apr 2011 03:01:46 +0300 |
parents | 9c7987064bb0 |
children | 1cf212375db3 |
line diff
1.1 --- a/src/textbox.c Mon Apr 18 06:15:46 2011 +0300 1.2 +++ b/src/textbox.c Tue Apr 19 03:01:46 2011 +0300 1.3 @@ -7,7 +7,7 @@ 1.4 1.5 #define TEXTBOX_SIZE 100 1.6 1.7 -static void draw_textbox(int id, const char *text, int x, int y); 1.8 +static void draw_textbox(int id, const char *text, int x, int y, int over); 1.9 1.10 1.11 void imtk_textbox(int id, char *textbuf, size_t buf_sz, int x, int y) 1.12 @@ -58,21 +58,23 @@ 1.13 } 1.14 } 1.15 1.16 - draw_textbox(id, textbuf, x, y); 1.17 + draw_textbox(id, textbuf, x, y, over); 1.18 } 1.19 1.20 1.21 -static void draw_textbox(int id, const char *text, int x, int y) 1.22 +static void draw_textbox(int id, const char *text, int x, int y, int over) 1.23 { 1.24 int strsz = imtk_string_size(text); 1.25 + float tcol[4], bcol[4]; 1.26 + unsigned int attr = 0; 1.27 1.28 - if(imtk_hit_test(x, y, TEXTBOX_SIZE, 20)) { 1.29 - glColor4fv(imtk_get_color(IMTK_FOCUS_COLOR)); 1.30 - } else { 1.31 - glColor4fv(imtk_get_color(IMTK_BASE_COLOR)); 1.32 + if(over) { 1.33 + attr |= IMTK_FOCUS_BIT; 1.34 } 1.35 + memcpy(tcol, imtk_get_color(IMTK_BOTTOM_COLOR | attr), sizeof tcol); 1.36 + memcpy(bcol, imtk_get_color(IMTK_TOP_COLOR | attr), sizeof bcol); 1.37 1.38 - imtk_draw_rect(x, y, TEXTBOX_SIZE, 20, 0); 1.39 + imtk_draw_rect(x, y, TEXTBOX_SIZE, 20, tcol, bcol); 1.40 1.41 if(imtk_has_focus(id)) { 1.42 glBegin(GL_LINES);