imtk

changeset 10:467a520f5c00

implemented the listbox correctly, no scrollbars or explicit sizing yet
author John Tsiombikas <nuclear@siggraph.org>
date Sun, 17 Apr 2011 18:17:55 +0300
parents 1b27a69603ac
children 17c9525b2e35
files src/imtk.h test.c
diffstat 2 files changed, 5 insertions(+), 7 deletions(-) [+]
line diff
     1.1 --- a/src/imtk.h	Sat Apr 16 22:59:23 2011 +0300
     1.2 +++ b/src/imtk.h	Sun Apr 17 18:17:55 2011 +0300
     1.3 @@ -43,16 +43,14 @@
     1.4  void imtk_textbox(int id, char *textbuf, size_t buf_sz, int x, int y);
     1.5  float imtk_slider(int id, float pos, float min, float max, int x, int y);
     1.6  void imtk_progress(int id, float pos, int x, int y);
     1.7 +int imtk_listbox(int id, const char *list, int sel, int x, int y);
     1.8  /*
     1.9 -int imtk_listbox(int id, const char *list, int sel, int x, int y);
    1.10  int imtk_combobox(int id, char *textbuf, size_t buf_sz, const char *list, int sel, int x, int y);
    1.11  */
    1.12  
    1.13  /* helper functions to create and destroy item lists for listboxes and comboboxes */
    1.14 -/*
    1.15  char *imtk_create_list(const char *first, ...);
    1.16  void imtk_free_list(char *list);
    1.17 -*/
    1.18  
    1.19  #ifdef __cplusplus
    1.20  }
     2.1 --- a/test.c	Sat Apr 16 22:59:23 2011 +0300
     2.2 +++ b/test.c	Sun Apr 17 18:17:55 2011 +0300
     2.3 @@ -108,8 +108,8 @@
     2.4  	static char textbuf[256];
     2.5  	static char textbuf2[256];
     2.6  	static float val;
     2.7 -	/*static int prev_sel;
     2.8 -	char *itemlist;*/
     2.9 +	static int prev_sel = 0;
    2.10 +	char *itemlist;
    2.11  
    2.12  	imtk_begin();
    2.13  
    2.14 @@ -132,12 +132,12 @@
    2.15  		glutPostRedisplay();
    2.16  	}
    2.17  
    2.18 -	/*itemlist = imtk_create_list("teapot", "torus", "sphere", NULL);
    2.19 +	itemlist = imtk_create_list("teapot", "torus", "sphere", NULL);
    2.20  	if((objsel = imtk_listbox(IMUID, itemlist, prev_sel, 30, 120)) != prev_sel) {
    2.21  		prev_sel = objsel;
    2.22  		glutPostRedisplay();
    2.23  	}
    2.24 -	imtk_free_list(itemlist);*/
    2.25 +	imtk_free_list(itemlist);
    2.26  
    2.27  	imtk_textbox(IMUID, textbuf, sizeof textbuf, 30, 200);
    2.28  	imtk_textbox(IMUID, textbuf2, sizeof textbuf2, 30, 250);