imtk
diff src/progress.c @ 7:6d35e6c7b2ca
reorganization finished
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 14 Apr 2011 23:04:07 +0300 |
parents | |
children | 10604ff95527 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/progress.c Thu Apr 14 23:04:07 2011 +0300 1.3 @@ -0,0 +1,41 @@ 1.4 +#include "imtk.h" 1.5 +#include "draw.h" 1.6 + 1.7 +#define SLIDER_SIZE 100 1.8 + 1.9 +static void draw_progress(int id, float pos, int x, int y); 1.10 + 1.11 +void imtk_progress(int id, float pos, int x, int y) 1.12 +{ 1.13 + draw_progress(id, pos, x, y); 1.14 +} 1.15 + 1.16 +static void draw_progress(int id, float pos, int x, int y) 1.17 +{ 1.18 + int bar_size = SLIDER_SIZE * pos; 1.19 + 1.20 + if(pos < 0.0) pos = 0.0; 1.21 + if(pos > 1.0) pos = 1.0; 1.22 + 1.23 + /* through */ 1.24 + glBegin(GL_QUADS); 1.25 + glColor4fv(imtk_get_color(IMTK_BASE_COLOR)); 1.26 + glVertex2f(x - 1, y - 1); 1.27 + glVertex2f(x + SLIDER_SIZE + 1, y - 1); 1.28 + glVertex2f(x + SLIDER_SIZE + 1, y + 17); 1.29 + glVertex2f(x - 1, y + 17); 1.30 + glEnd(); 1.31 + imtk_draw_frame(x - 1, y - 1, SLIDER_SIZE + 2, 17, FRAME_INSET); 1.32 + 1.33 + if(pos > 0.0) { 1.34 + /* bar */ 1.35 + glBegin(GL_QUADS); 1.36 + glColor4fv(imtk_get_color(IMTK_BASE_COLOR)); 1.37 + glVertex2f(x, y); 1.38 + glVertex2f(x + bar_size, y); 1.39 + glVertex2f(x + bar_size, y + 15); 1.40 + glVertex2f(x, y + 15); 1.41 + glEnd(); 1.42 + imtk_draw_frame(x, y, bar_size, 15, FRAME_OUTSET); 1.43 + } 1.44 +}