Mercurial > MadButterfly
comparison src/event.c @ 70:92cfabe22d6b
find_shape_at_pos() finds a shape from clean ones.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Wed, 13 Aug 2008 09:12:09 +0800 |
parents | 581a03196093 |
children | 23bc382d9683 |
comparison
equal
deleted
inserted
replaced
69:a6150b4e0667 | 70:92cfabe22d6b |
---|---|
82 sh_rect_draw(shape, cr); | 82 sh_rect_draw(shape, cr); |
83 break; | 83 break; |
84 } | 84 } |
85 } | 85 } |
86 | 86 |
87 static geo_t *find_pos_in_geo(redraw_man_t *rdman, | 87 static geo_t *find_geo_in_pos(redraw_man_t *rdman, |
88 co_aix x, co_aix y, int *in_stroke) { | 88 co_aix x, co_aix y, int *in_stroke) { |
89 geo_t *geo; | 89 geo_t *geo; |
90 geo_t **geos; | 90 geo_t **geos; |
91 shape_t *shape; | 91 shape_t *shape; |
92 cairo_t *cr; | 92 cairo_t *cr; |
94 | 94 |
95 geos = rdman->gen_geos; | 95 geos = rdman->gen_geos; |
96 cr = rdman->cr; | 96 cr = rdman->cr; |
97 for(i = rdman->n_gen_geos - 1; i >= 0; i--) { | 97 for(i = rdman->n_gen_geos - 1; i >= 0; i--) { |
98 geo = geos[i]; | 98 geo = geos[i]; |
99 if(geo->flags & GEF_DIRTY) | |
100 continue; | |
99 shape = geo->shape; | 101 shape = geo->shape; |
100 draw_shape_path(shape, cr); | 102 draw_shape_path(shape, cr); |
101 if(shape->fill) { | 103 if(shape->fill) { |
102 if(cairo_in_fill(cr, x, y)) { | 104 if(cairo_in_fill(cr, x, y)) { |
103 *in_stroke = 0; | 105 *in_stroke = 0; |
125 | 127 |
126 r = collect_shapes_at_point(rdman, x, y); | 128 r = collect_shapes_at_point(rdman, x, y); |
127 if(r != OK) | 129 if(r != OK) |
128 return NULL; | 130 return NULL; |
129 | 131 |
130 geo = find_pos_in_geo(rdman, x, y, in_stroke); | 132 geo = find_geo_in_pos(rdman, x, y, in_stroke); |
131 if(geo == NULL) | 133 if(geo == NULL) |
132 return NULL; | 134 return NULL; |
133 | 135 |
134 return geo->shape; | 136 return geo->shape; |
135 } | 137 } |