imtk

annotate 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
rev   line source
nuclear@7 1 #include "imtk.h"
nuclear@7 2 #include "draw.h"
nuclear@7 3
nuclear@7 4 #define SLIDER_SIZE 100
nuclear@7 5
nuclear@7 6 static void draw_progress(int id, float pos, int x, int y);
nuclear@7 7
nuclear@7 8 void imtk_progress(int id, float pos, int x, int y)
nuclear@7 9 {
nuclear@7 10 draw_progress(id, pos, x, y);
nuclear@7 11 }
nuclear@7 12
nuclear@7 13 static void draw_progress(int id, float pos, int x, int y)
nuclear@7 14 {
nuclear@7 15 int bar_size = SLIDER_SIZE * pos;
nuclear@7 16
nuclear@7 17 if(pos < 0.0) pos = 0.0;
nuclear@7 18 if(pos > 1.0) pos = 1.0;
nuclear@7 19
nuclear@7 20 /* through */
nuclear@7 21 glBegin(GL_QUADS);
nuclear@7 22 glColor4fv(imtk_get_color(IMTK_BASE_COLOR));
nuclear@7 23 glVertex2f(x - 1, y - 1);
nuclear@7 24 glVertex2f(x + SLIDER_SIZE + 1, y - 1);
nuclear@7 25 glVertex2f(x + SLIDER_SIZE + 1, y + 17);
nuclear@7 26 glVertex2f(x - 1, y + 17);
nuclear@7 27 glEnd();
nuclear@7 28 imtk_draw_frame(x - 1, y - 1, SLIDER_SIZE + 2, 17, FRAME_INSET);
nuclear@7 29
nuclear@7 30 if(pos > 0.0) {
nuclear@7 31 /* bar */
nuclear@7 32 glBegin(GL_QUADS);
nuclear@7 33 glColor4fv(imtk_get_color(IMTK_BASE_COLOR));
nuclear@7 34 glVertex2f(x, y);
nuclear@7 35 glVertex2f(x + bar_size, y);
nuclear@7 36 glVertex2f(x + bar_size, y + 15);
nuclear@7 37 glVertex2f(x, y + 15);
nuclear@7 38 glEnd();
nuclear@7 39 imtk_draw_frame(x, y, bar_size, 15, FRAME_OUTSET);
nuclear@7 40 }
nuclear@7 41 }