comparison src/geo.c @ 12:79e9edf4c00a

Add redraw manager
author Thinker K.F. Li <thinker@branda.to>
date Mon, 28 Jul 2008 17:45:36 +0800
parents 7cfecdce94cc
children ed55009d96d3
comparison
equal deleted inserted replaced
11:128af06c876c 12:79e9edf4c00a
4 * the components effected or overlaid should be re-drawed. This module 4 * the components effected or overlaid should be re-drawed. This module
5 * figures out components that should be re-drawed. 5 * figures out components that should be re-drawed.
6 */ 6 */
7 #include <stdio.h> 7 #include <stdio.h>
8 #include "mb_types.h" 8 #include "mb_types.h"
9
10 struct _geo {
11 co_aix x, y;
12 co_aix w, h;
13 co_aix rel_x, rel_y;
14 co_aix orig_x, orig_y;
15 int n_subs;
16 struct _geo *subs;
17 };
18 9
19 static int is_scale_overlay(co_aix x1, co_aix w1, co_aix x2, co_aix w2) { 10 static int is_scale_overlay(co_aix x1, co_aix w1, co_aix x2, co_aix w2) {
20 if(x1 > x2) { 11 if(x1 > x2) {
21 if((x1 - x2) >= w2) 12 if((x1 - x2) >= w2)
22 return 0; 13 return 0;
25 return 0; 16 return 0;
26 } 17 }
27 return 1; 18 return 1;
28 } 19 }
29 20
30 static int is_overlay(geo_t *r1, geo_t *r2) { 21 static int _is_overlay(geo_t *r1, geo_t *r2) {
31 if(!is_scale_overlay(r1->x, r1->w, r2->x, r2->w)) 22 if(!is_scale_overlay(r1->x, r1->w, r2->x, r2->w))
32 return 0; 23 return 0;
33 if(!is_scale_overlay(r1->y, r1->h, r2->y, r2->h)) 24 if(!is_scale_overlay(r1->y, r1->h, r2->y, r2->h))
34 return 0; 25 return 0;
35 26
36 return 1; 27 return 1;
28 }
29
30 int is_overlay(geo_t *r1, geo_t *r2) {
31 return _is_overlay(r1, r2);
37 } 32 }
38 33
39 void geo_init(geo_t *g, int n_pos, co_aix pos[][2]) { 34 void geo_init(geo_t *g, int n_pos, co_aix pos[][2]) {
40 co_aix min_x, max_x; 35 co_aix min_x, max_x;
41 co_aix min_y, max_y; 36 co_aix min_y, max_y;
66 int *n_overlays, geo_t **overlays) { 61 int *n_overlays, geo_t **overlays) {
67 int i, ov_idx; 62 int i, ov_idx;
68 63
69 ov_idx = 0; 64 ov_idx = 0;
70 for(i = 0; i < n_others; i++) { 65 for(i = 0; i < n_others; i++) {
71 if(is_overlay(g, others[i])) 66 if(_is_overlay(g, others[i]))
72 overlays[ov_idx++] = others[i]; 67 overlays[ov_idx++] = others[i];
73 } 68 }
74 *n_overlays = ov_idx; 69 *n_overlays = ov_idx;
75 } 70 }
76 71