imtk
changeset 22:17f5ff624da3
minor fixes in the layout system
author | John Tsiombikas <nuclear@siggraph.org> |
---|---|
date | Sat, 30 Apr 2011 06:12:51 +0300 |
parents | 3138c38433e2 |
children | 4c2b3e281409 |
files | src/imtk.c src/slider.c |
diffstat | 2 files changed, 9 insertions(+), 6 deletions(-) [+] |
line diff
1.1 --- a/src/imtk.c Sat Apr 30 05:36:56 2011 +0300 1.2 +++ b/src/imtk.c Sat Apr 30 06:12:51 2011 +0300 1.3 @@ -96,7 +96,6 @@ 1.4 { 1.5 int max_span_y, max_box_y; 1.6 1.7 - box[2] += width + spacing; 1.8 span[2] += width + spacing; 1.9 1.10 if(height > span[3]) { 1.11 @@ -109,6 +108,9 @@ 1.12 if(max_span_y > max_box_y) { 1.13 box[3] = max_span_y - box[1]; 1.14 } 1.15 + if(span[2] > box[2]) { 1.16 + box[2] = span[2]; 1.17 + } 1.18 1.19 if(layout == IMTK_VERTICAL) { 1.20 imtk_layout_newline();
2.1 --- a/src/slider.c Sat Apr 30 05:36:56 2011 +0300 2.2 +++ b/src/slider.c Sat Apr 30 06:12:51 2011 +0300 2.3 @@ -9,11 +9,11 @@ 2.4 #define THUMB_WIDTH 10 2.5 #define THUMB_HEIGHT 20 2.6 2.7 -static void draw_slider(int id, float pos, float min, float max, int x, int y, int over); 2.8 +static int draw_slider(int id, float pos, float min, float max, int x, int y, int over); 2.9 2.10 float imtk_slider(int id, float pos, float min, float max, int x, int y) 2.11 { 2.12 - int mousex, mousey, thumb_x, thumb_y, over = 0; 2.13 + int mousex, mousey, thumb_x, thumb_y, txsz, over = 0; 2.14 float range = max - min; 2.15 2.16 assert(id >= 0); 2.17 @@ -64,13 +64,13 @@ 2.18 if(pos > 1.0) pos = 1.0; 2.19 } 2.20 2.21 - draw_slider(id, pos, min, max, x, y, over); 2.22 - imtk_layout_advance(SLIDER_SIZE + THUMB_WIDTH, THUMB_HEIGHT); 2.23 + txsz = draw_slider(id, pos, min, max, x, y, over); 2.24 + imtk_layout_advance(SLIDER_SIZE + THUMB_WIDTH + txsz, THUMB_HEIGHT); 2.25 return pos * range + min; 2.26 } 2.27 2.28 2.29 -static void draw_slider(int id, float pos, float min, float max, int x, int y, int over) 2.30 +static int draw_slider(int id, float pos, float min, float max, int x, int y, int over) 2.31 { 2.32 float range = max - min; 2.33 int thumb_x, thumb_y; 2.34 @@ -105,5 +105,6 @@ 2.35 sprintf(buf, "%.3f", pos * range + min); 2.36 glColor4fv(imtk_get_color(IMTK_TEXT_COLOR)); 2.37 imtk_draw_string(x + SLIDER_SIZE + THUMB_WIDTH / 2 + 2, y + 4, buf); 2.38 + return imtk_string_size(buf); 2.39 } 2.40