imtk

changeset 11:eae09a1dca1d

checkbox is active over the whole length of the label too
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 16 Apr 2011 10:27:59 +0300
parents 10604ff95527
children 17c9525b2e35
files src/checkbox.c
diffstat 1 files changed, 5 insertions(+), 6 deletions(-) [+]
line diff
     1.1 --- a/src/checkbox.c	Thu Apr 14 23:21:56 2011 +0300
     1.2 +++ b/src/checkbox.c	Sat Apr 16 10:27:59 2011 +0300
     1.3 @@ -7,8 +7,7 @@
     1.4  #define CHECKBOX_SIZE	14
     1.5  
     1.6  
     1.7 -static void draw_checkbox(int id, const char *label, int x, int y, int state);
     1.8 -
     1.9 +static void draw_checkbox(int id, const char *label, int x, int y, int state, int over);
    1.10  
    1.11  int imtk_checkbox(int id, const char *label, int x, int y, int state)
    1.12  {
    1.13 @@ -17,7 +16,7 @@
    1.14  
    1.15  	assert(id >= 0);
    1.16  
    1.17 -	if(imtk_hit_test(x, y, sz, sz)) {
    1.18 +	if(imtk_hit_test(x, y, sz + imtk_string_size(label) + 5, sz)) {
    1.19  		imtk_set_hot(id);
    1.20  		over = 1;
    1.21  	}
    1.22 @@ -35,15 +34,15 @@
    1.23  		}
    1.24  	}
    1.25  
    1.26 -	draw_checkbox(id, label, x, y, state);
    1.27 +	draw_checkbox(id, label, x, y, state, over);
    1.28  	return state;
    1.29  }
    1.30  
    1.31 -static void draw_checkbox(int id, const char *label, int x, int y, int state)
    1.32 +static void draw_checkbox(int id, const char *label, int x, int y, int state, int over)
    1.33  {
    1.34  	static const int sz = CHECKBOX_SIZE;
    1.35  
    1.36 -	if(imtk_hit_test(x, y, sz, sz)) {
    1.37 +	if(over) {
    1.38  		glColor4fv(imtk_get_color(IMTK_FOCUS_COLOR));
    1.39  	} else {
    1.40  		glColor4fv(imtk_get_color(IMTK_BASE_COLOR));