imtk

diff src/imtk.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 6d35e6c7b2ca
children c7a7ddbe7714
line diff
     1.1 --- a/src/imtk.c	Sun Apr 17 18:20:23 2011 +0300
     1.2 +++ b/src/imtk.c	Mon Apr 18 06:15:46 2011 +0300
     1.3 @@ -2,7 +2,6 @@
     1.4  #include <stdlib.h>
     1.5  #include <string.h>
     1.6  #include <ctype.h>
     1.7 -#include <stdarg.h>
     1.8  #include <assert.h>
     1.9  #ifndef __APPLE__
    1.10  #include <GL/glut.h>
    1.11 @@ -11,8 +10,14 @@
    1.12  #endif
    1.13  #include "imtk.h"
    1.14  #include "state.h"
    1.15 +#include "draw.h"
    1.16  
    1.17  
    1.18 +void imtk_post_redisplay(void)
    1.19 +{
    1.20 +	glutPostRedisplay();
    1.21 +}
    1.22 +
    1.23  void imtk_begin(void)
    1.24  {
    1.25  	int width, height;
    1.26 @@ -33,6 +38,9 @@
    1.27  	glDisable(GL_DEPTH_TEST);
    1.28  	glDisable(GL_CULL_FACE);
    1.29  	glDisable(GL_LIGHTING);
    1.30 +	glEnable(GL_BLEND);
    1.31 +
    1.32 +	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    1.33  }
    1.34  
    1.35  void imtk_end(void)
    1.36 @@ -45,35 +53,14 @@
    1.37  	glPopMatrix();
    1.38  }
    1.39  
    1.40 -
    1.41 -void imtk_post_redisplay(void)
    1.42 +void imtk_label(const char *str, int x, int y)
    1.43  {
    1.44 -	glutPostRedisplay();
    1.45 +	glColor4fv(imtk_get_color(IMTK_TEXT_COLOR));
    1.46 +	imtk_draw_string(x, y, str);
    1.47  }
    1.48  
    1.49  
    1.50 -/*int imtk_listbox(int id, const char *list, int sel, int x, int y)
    1.51 -{
    1.52 -	int i;
    1.53 -	assert(id >= 0);
    1.54 -
    1.55 -	if(!list) {
    1.56 -		return -1;
    1.57 -	}
    1.58 -
    1.59 -	if(id & 1) {
    1.60 -		id++;
    1.61 -	}
    1.62 -
    1.63 -	for(i=0; *list; i++) {
    1.64 -		if(imtk_button(id + i * 2 + 1, list, x, y + i * 20)) {
    1.65 -			sel = i;
    1.66 -		}
    1.67 -		list += strlen(list) + 1;
    1.68 -	}
    1.69 -	return sel;
    1.70 -}
    1.71 -
    1.72 +/*
    1.73  int imtk_combobox(int id, char *textbuf, size_t buf_sz, const char *list, int sel, int x, int y)
    1.74  {
    1.75  	imtk_textbox(id + 1, textbuf, buf_sz, x, y);
    1.76 @@ -84,44 +71,4 @@
    1.77  	}
    1.78  	return sel;
    1.79  }
    1.80 -
    1.81 -char *imtk_create_list(const char *first, ...)
    1.82 -{
    1.83 -	int sz;
    1.84 -	char *buf, *item;
    1.85 -	va_list ap;
    1.86 -
    1.87 -	if(!first) {
    1.88 -		return 0;
    1.89 -	}
    1.90 -
    1.91 -	sz = strlen(first) + 2;
    1.92 -	if(!(buf = malloc(sz))) {
    1.93 -		return 0;
    1.94 -	}
    1.95 -	memcpy(buf, first, sz - 2);
    1.96 -	buf[sz - 1] = buf[sz - 2] = 0;
    1.97 -
    1.98 -	va_start(ap, first);
    1.99 -	while((item = va_arg(ap, char*))) {
   1.100 -		int len = strlen(item);
   1.101 -		char *tmp = realloc(buf, sz + len + 1);
   1.102 -		if(!tmp) {
   1.103 -			free(buf);
   1.104 -			return 0;
   1.105 -		}
   1.106 -		buf = tmp;
   1.107 -
   1.108 -		memcpy(buf + sz - 1, item, len);
   1.109 -		sz += len + 1;
   1.110 -		buf[sz - 1] = buf[sz - 2] = 0;
   1.111 -	}
   1.112 -	va_end(ap);
   1.113 -
   1.114 -	return buf;
   1.115 -}
   1.116 -
   1.117 -void imtk_free_list(char *list)
   1.118 -{
   1.119 -	free(list);
   1.120 -}*/
   1.121 +*/