imtk
view src/progress.c @ 25:bb358d8c4903
added $(PREFIX)/include and $(PREFIX)/lib into the paths
author | John Tsiombikas <nuclear@mutantstargoat.com> |
---|---|
date | Tue, 04 Oct 2011 19:24:51 +0300 |
parents | 6893b4dca5a3 |
children |
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 if(x == IMTK_AUTO || y == IMTK_AUTO) {
13 imtk_layout_get_pos(&x, &y);
14 }
16 draw_progress(id, pos, x, y);
17 imtk_layout_advance(PROGR_SIZE, PROGR_HEIGHT);
18 }
20 static void draw_progress(int id, float pos, int x, int y)
21 {
22 int bar_size = PROGR_SIZE * pos;
23 float b = imtk_get_bevel_width();
24 float tcol[4], bcol[4];
26 if(pos < 0.0) pos = 0.0;
27 if(pos > 1.0) pos = 1.0;
29 memcpy(tcol, imtk_get_color(IMTK_BOTTOM_COLOR), sizeof tcol);
30 memcpy(bcol, imtk_get_color(IMTK_TOP_COLOR), sizeof bcol);
32 /* trough */
33 imtk_draw_rect(x - b, y - b, PROGR_SIZE + b * 2, PROGR_HEIGHT + b * 2, tcol, bcol);
34 imtk_draw_frame(x - b, y - b, PROGR_SIZE + b * 2, PROGR_HEIGHT + b * 2, FRAME_INSET);
36 /* bar */
37 if(pos > 0.0) {
38 memcpy(tcol, imtk_get_color(IMTK_TOP_COLOR), sizeof tcol);
39 memcpy(bcol, imtk_get_color(IMTK_BOTTOM_COLOR), sizeof bcol);
41 imtk_draw_rect(x, y, bar_size, PROGR_HEIGHT, tcol, bcol);
42 imtk_draw_frame(x, y, bar_size, PROGR_HEIGHT, FRAME_OUTSET);
43 }
44 }