imtk

annotate src/progress.c @ 14:df2bc9406561

added gradients
author John Tsiombikas <nuclear@siggraph.org>
date Tue, 19 Apr 2011 03:01:46 +0300
parents 9c7987064bb0
children 6893b4dca5a3
rev   line source
nuclear@14 1 #include <string.h>
nuclear@7 2 #include "imtk.h"
nuclear@7 3 #include "draw.h"
nuclear@7 4
nuclear@13 5 #define PROGR_SIZE 100
nuclear@13 6 #define PROGR_HEIGHT 15
nuclear@7 7
nuclear@7 8 static void draw_progress(int id, float pos, int x, int y);
nuclear@7 9
nuclear@7 10 void imtk_progress(int id, float pos, int x, int y)
nuclear@7 11 {
nuclear@7 12 draw_progress(id, pos, x, y);
nuclear@7 13 }
nuclear@7 14
nuclear@7 15 static void draw_progress(int id, float pos, int x, int y)
nuclear@7 16 {
nuclear@13 17 int bar_size = PROGR_SIZE * pos;
nuclear@13 18 float b = imtk_get_bevel_width();
nuclear@14 19 float tcol[4], bcol[4];
nuclear@7 20
nuclear@7 21 if(pos < 0.0) pos = 0.0;
nuclear@7 22 if(pos > 1.0) pos = 1.0;
nuclear@7 23
nuclear@14 24 memcpy(tcol, imtk_get_color(IMTK_BOTTOM_COLOR), sizeof tcol);
nuclear@14 25 memcpy(bcol, imtk_get_color(IMTK_TOP_COLOR), sizeof bcol);
nuclear@14 26
nuclear@7 27 /* through */
nuclear@14 28 imtk_draw_rect(x - b, y - b, PROGR_SIZE + b * 2, PROGR_HEIGHT + b * 2, tcol, bcol);
nuclear@13 29 imtk_draw_frame(x - b, y - b, PROGR_SIZE + b * 2, PROGR_HEIGHT + b * 2, FRAME_INSET);
nuclear@7 30
nuclear@14 31 /* bar */
nuclear@7 32 if(pos > 0.0) {
nuclear@14 33 memcpy(tcol, imtk_get_color(IMTK_TOP_COLOR), sizeof tcol);
nuclear@14 34 memcpy(bcol, imtk_get_color(IMTK_BOTTOM_COLOR), sizeof bcol);
nuclear@14 35
nuclear@14 36 imtk_draw_rect(x, y, bar_size, PROGR_HEIGHT, tcol, bcol);
nuclear@13 37 imtk_draw_frame(x, y, bar_size, PROGR_HEIGHT, FRAME_OUTSET);
nuclear@7 38 }
nuclear@7 39 }