imtk

changeset 27:48e708baa7be tip

added predicate imtk_layout_contains(x, y)
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 12 Dec 2020 17:20:00 +0200
parents b352e29dc35a
children
files src/imtk.h src/layout.c
diffstat 2 files changed, 12 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- a/src/imtk.h	Thu Mar 20 07:00:38 2014 +0200
     1.2 +++ b/src/imtk.h	Sat Dec 12 17:20:00 2020 +0200
     1.3 @@ -85,6 +85,7 @@
     1.4  void imtk_layout_newline(void);
     1.5  void imtk_layout_get_pos(int *x, int *y);
     1.6  void imtk_layout_get_bounds(int *bbox);
     1.7 +int imtk_layout_contains(int x, int y);
     1.8  
     1.9  /* defined in draw.c */
    1.10  void imtk_set_color(unsigned int col, float r, float g, float b, float a);
     2.1 --- a/src/layout.c	Thu Mar 20 07:00:38 2014 +0200
     2.2 +++ b/src/layout.c	Sat Dec 12 17:20:00 2020 +0200
     2.3 @@ -99,3 +99,14 @@
     2.4  {
     2.5  	memcpy(bbox, st[top].box, sizeof st[top].box);
     2.6  }
     2.7 +
     2.8 +int imtk_layout_contains(int x, int y)
     2.9 +{
    2.10 +	if(x < st[top].box[0] || x >= st[top].box[0] + st[top].box[2]) {
    2.11 +		return 0;
    2.12 +	}
    2.13 +	if(y < st[top].box[1] || y >= st[top].box[1] + st[top].box[3]) {
    2.14 +		return 0;
    2.15 +	}
    2.16 +	return 1;
    2.17 +}