imtk

diff src/slider.c @ 22:17f5ff624da3

minor fixes in the layout system
author John Tsiombikas <nuclear@siggraph.org>
date Sat, 30 Apr 2011 06:12:51 +0300
parents c7a7ddbe7714
children
line diff
     1.1 --- a/src/slider.c	Sat Apr 30 05:36:56 2011 +0300
     1.2 +++ b/src/slider.c	Sat Apr 30 06:12:51 2011 +0300
     1.3 @@ -9,11 +9,11 @@
     1.4  #define THUMB_WIDTH		10
     1.5  #define THUMB_HEIGHT	20
     1.6  
     1.7 -static void draw_slider(int id, float pos, float min, float max, int x, int y, int over);
     1.8 +static int draw_slider(int id, float pos, float min, float max, int x, int y, int over);
     1.9  
    1.10  float imtk_slider(int id, float pos, float min, float max, int x, int y)
    1.11  {
    1.12 -	int mousex, mousey, thumb_x, thumb_y, over = 0;
    1.13 +	int mousex, mousey, thumb_x, thumb_y, txsz, over = 0;
    1.14  	float range = max - min;
    1.15  
    1.16  	assert(id >= 0);
    1.17 @@ -64,13 +64,13 @@
    1.18  		if(pos > 1.0) pos = 1.0;
    1.19  	}
    1.20  
    1.21 -	draw_slider(id, pos, min, max, x, y, over);
    1.22 -	imtk_layout_advance(SLIDER_SIZE + THUMB_WIDTH, THUMB_HEIGHT);
    1.23 +	txsz = draw_slider(id, pos, min, max, x, y, over);
    1.24 +	imtk_layout_advance(SLIDER_SIZE + THUMB_WIDTH + txsz, THUMB_HEIGHT);
    1.25  	return pos * range + min;
    1.26  }
    1.27  
    1.28  
    1.29 -static void draw_slider(int id, float pos, float min, float max, int x, int y, int over)
    1.30 +static int draw_slider(int id, float pos, float min, float max, int x, int y, int over)
    1.31  {
    1.32  	float range = max - min;
    1.33  	int thumb_x, thumb_y;
    1.34 @@ -105,5 +105,6 @@
    1.35  	sprintf(buf, "%.3f", pos * range + min);
    1.36  	glColor4fv(imtk_get_color(IMTK_TEXT_COLOR));
    1.37  	imtk_draw_string(x + SLIDER_SIZE + THUMB_WIDTH / 2 + 2, y + 4, buf);
    1.38 +	return imtk_string_size(buf);
    1.39  }
    1.40