imtk

annotate src/progress.c @ 13:9c7987064bb0

- fixed the frame drawing a bit - added global alpha value and various drawing parameters - backported the checkbox check mark from glamtk - fixed progress bar drawing so that the bevels of the trough and the bar won't overlap
author John Tsiombikas <nuclear@siggraph.org>
date Mon, 18 Apr 2011 06:15:46 +0300
parents 10604ff95527
children df2bc9406561
rev   line source
nuclear@7 1 #include "imtk.h"
nuclear@7 2 #include "draw.h"
nuclear@7 3
nuclear@13 4 #define PROGR_SIZE 100
nuclear@13 5 #define PROGR_HEIGHT 15
nuclear@7 6
nuclear@7 7 static void draw_progress(int id, float pos, int x, int y);
nuclear@7 8
nuclear@7 9 void imtk_progress(int id, float pos, int x, int y)
nuclear@7 10 {
nuclear@7 11 draw_progress(id, pos, x, y);
nuclear@7 12 }
nuclear@7 13
nuclear@7 14 static void draw_progress(int id, float pos, int x, int y)
nuclear@7 15 {
nuclear@13 16 int bar_size = PROGR_SIZE * pos;
nuclear@13 17 float b = imtk_get_bevel_width();
nuclear@7 18
nuclear@7 19 if(pos < 0.0) pos = 0.0;
nuclear@7 20 if(pos > 1.0) pos = 1.0;
nuclear@7 21
nuclear@7 22 /* through */
nuclear@13 23 imtk_draw_rect(x - b, y - b, PROGR_SIZE + b * 2, PROGR_HEIGHT + b * 2, imtk_get_color(IMTK_BASE_COLOR));
nuclear@13 24 imtk_draw_frame(x - b, y - b, PROGR_SIZE + b * 2, PROGR_HEIGHT + b * 2, FRAME_INSET);
nuclear@7 25
nuclear@7 26 if(pos > 0.0) {
nuclear@7 27 /* bar */
nuclear@13 28 imtk_draw_rect(x, y, bar_size, PROGR_HEIGHT, imtk_get_color(IMTK_BASE_COLOR));
nuclear@13 29 imtk_draw_frame(x, y, bar_size, PROGR_HEIGHT, FRAME_OUTSET);
nuclear@7 30 }
nuclear@7 31 }