imtk
view src/progress.c @ 18:737e9047d9c9
added radio group
author | John Tsiombikas <nuclear@siggraph.org> |
---|---|
date | Mon, 25 Apr 2011 08:54:05 +0300 |
parents | df2bc9406561 |
children | c7a7ddbe7714 |
line source
1 #include <string.h>
2 #include "imtk.h"
3 #include "draw.h"
5 #define PROGR_SIZE 100
6 #define PROGR_HEIGHT 15
8 static void draw_progress(int id, float pos, int x, int y);
10 void imtk_progress(int id, float pos, int x, int y)
11 {
12 draw_progress(id, pos, x, y);
13 }
15 static void draw_progress(int id, float pos, int x, int y)
16 {
17 int bar_size = PROGR_SIZE * pos;
18 float b = imtk_get_bevel_width();
19 float tcol[4], bcol[4];
21 if(pos < 0.0) pos = 0.0;
22 if(pos > 1.0) pos = 1.0;
24 memcpy(tcol, imtk_get_color(IMTK_BOTTOM_COLOR), sizeof tcol);
25 memcpy(bcol, imtk_get_color(IMTK_TOP_COLOR), sizeof bcol);
27 /* trough */
28 imtk_draw_rect(x - b, y - b, PROGR_SIZE + b * 2, PROGR_HEIGHT + b * 2, tcol, bcol);
29 imtk_draw_frame(x - b, y - b, PROGR_SIZE + b * 2, PROGR_HEIGHT + b * 2, FRAME_INSET);
31 /* bar */
32 if(pos > 0.0) {
33 memcpy(tcol, imtk_get_color(IMTK_TOP_COLOR), sizeof tcol);
34 memcpy(bcol, imtk_get_color(IMTK_BOTTOM_COLOR), sizeof bcol);
36 imtk_draw_rect(x, y, bar_size, PROGR_HEIGHT, tcol, bcol);
37 imtk_draw_frame(x, y, bar_size, PROGR_HEIGHT, FRAME_OUTSET);
38 }
39 }