Mercurial > MadButterfly
diff src/event.c @ 822:586e50f82c1f
Unify coding style tag for emacs and vim.
author | Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com> |
---|---|
date | Tue, 14 Sep 2010 01:08:39 +0800 |
parents | d2f2ed27b84d |
children | 7b4e80ab671a |
line wrap: on
line diff
--- a/src/event.c Tue Sep 14 00:25:44 2010 +0800 +++ b/src/event.c Tue Sep 14 01:08:39 2010 +0800 @@ -1,3 +1,5 @@ +// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- +// vim: sw=4:ts=8:sts=4 /*! \file * \brief Convenience functions for event relative work. */ @@ -139,7 +141,7 @@ struct shape { mb_obj_t obj; - + coord_t *coord; area_t area; shape_t *all_next; @@ -148,7 +150,7 @@ void *fill, *stroke; struct shape *sibling; int flags; - + int num_points; co_aix points[32][2]; }; @@ -179,7 +181,7 @@ struct coord { mb_obj_t obj; - + area_t area; int flags; coord_t *parent; @@ -208,7 +210,7 @@ void _areas_merge(area_t *area1, area_t *area2) { co_aix lu_x, lu_y; co_aix rb_x, rb_y; - + lu_x = area2->x; lu_y = area2->y; rb_x = lu_x + area2->w - 1; @@ -225,7 +227,7 @@ area_t *cur_area; area = coord_get_area(coord); - + shape = STAILQ_HEAD(coord->shapes); if(shape != NULL) { cur_area = sh_get_area(shape); @@ -236,7 +238,7 @@ cur_area = coord_get_area(child); } memcpy(area, cur_area, sizeof(area_t)); - + FOR_COORD_SHAPES(coord, shape) { cur_area = sh_get_area(shape); _areas_merge(area, cur_area); @@ -261,9 +263,9 @@ coord_t *preorder_coord_subtree(coord_t *root, coord_t *last) { if(STAILQ_HEAD(last->children) && !(last->flags & COF_SKIP)) return STAILQ_HEAD(last->children); - + last->flags &= ~COF_SKIP; - + if(last == root) return NULL; while(STAILQ_NEXT(coord_t, sibling, last) == NULL) { @@ -282,7 +284,7 @@ static coord_t *postorder_coord_subtree(coord_t *root, coord_t *last) { coord_t *cur; - + if(last != NULL) { if(STAILQ_NEXT(coord_t, sibling, last) == NULL) { if(cur == root) @@ -445,7 +447,7 @@ memset(shape, 0, sizeof(shape_t)); MB_OBJ_INIT(&shape->obj, MBO_PATH); STAILQ_INS(rdman->all_shapes, shape_t, all_next, shape); - + return shape; } @@ -482,7 +484,7 @@ int i, j; cr = surf->cr; - + STAILQ_FOR_EACH(cr->drawed, shape_t, sibling, shape1) { for(i = 0; i < shape1->num_points; i++) { x1 = shape1->points[i][0]; @@ -510,7 +512,7 @@ co_aix x, co_aix y) { shape_t *shape; int r; - + r = rdman_force_clean(rdman); if(r != OK) return ERR; @@ -676,7 +678,7 @@ rdman_surface = mbe_get_target(rdman_get_cr(rdman)); w = mbe_image_surface_get_width(rdman_surface); h = mbe_image_surface_get_height(rdman_surface); - + surface = mbe_image_surface_create(MB_IFMT_A1, w, h); if(surface == NULL) return NULL; @@ -684,7 +686,7 @@ cr = mbe_create(surface); if(cr == NULL) mbe_surface_destroy(surface); - + return cr; } @@ -697,10 +699,10 @@ void _draw_to_mask(shape_t *shape, mbe_t *cr) { if(sh_get_flags(shape, GEF_OV_DRAW)) return; - + draw_shape_path(shape, cr); mbe_clip(cr); - + sh_set_flags(shape, GEF_OV_DRAW); } @@ -745,9 +747,9 @@ shape_t *shape, *candi_shape; int obj_is_shape; int r; - + obj_is_shape = IS_MBO_SHAPES(obj); - + if(obj_is_shape) { shape = (shape_t *)obj; area = sh_get_area(shape); @@ -756,26 +758,26 @@ area = coord_get_area(coord); shape = NULL; } - + if(IS_MBO_SHAPES(others_root)) { candi_shape = (shape_t *)others_root; candi_area = sh_get_area(candi_shape); - + r = areas_are_overlay(area, candi_area); if(!r) return FALSE; - + if(!obj_is_shape) return TRUE; - + _draw_to_mask(candi_shape, cr); r = _fill_and_check(shape, cr); - + return r; } - + ASSERT(IS_MBO_COORD(others_root)); - + root = (coord_t *)others_root; FOR_COORDS_PREORDER(root, candi_coord) { candi_area = coord_get_area(candi_coord); @@ -784,23 +786,23 @@ preorder_coord_skip_subtree(candi_coord); continue; } - + FOR_COORD_SHAPES(candi_coord, candi_shape) { candi_area = sh_get_area(candi_shape); r = areas_are_overlay(area, candi_area); if(!r) continue; - + if(!obj_is_shape) return TRUE; - + _draw_to_mask(candi_shape, cr); r = _fill_and_check(shape, cr); if(r) return TRUE; } } - + return FALSE; } @@ -843,7 +845,7 @@ r = _is_obj_objs_overlay(obj1, obj2, cr); goto out; } - + root = (coord_t *)obj1; FOR_COORDS_PREORDER(root, coord) { area = coord_get_area(coord); @@ -860,7 +862,7 @@ } } r = FALSE; - + out: _clear_ov_draw(obj2); /* marked by _is_obj_objs_overlay() */ _release_mbe_for_testing(cr); @@ -881,7 +883,7 @@ cr = mbe_create(surf); backend = mbe_create(surf); rdman = redraw_man_new(cr, backend); - + return rdman; } @@ -962,7 +964,7 @@ shape_add_point(shape1, 3, 2); shape_add_point(shape2, 5, 5); shape_add_point(shape3, 4, 3); - + surf = mbe_image_surface_create(MB_IFMT_A1, 100, 100); cr = mbe_create(surf); r = _is_obj_objs_overlay((mb_obj_t *)coord1, (mb_obj_t *)coord2, cr); @@ -1010,7 +1012,7 @@ mbe_destroy(cr); mbe_surface_destroy(surf); sh_clear_flags(shape3, GEF_OV_DRAW); - + shape_add_point(shape1, 5, 5); surf = mbe_image_surface_create(MB_IFMT_A1, 100, 100); @@ -1097,39 +1099,39 @@ r = mb_objs_are_overlay(rdman, (mb_obj_t *)coord1, (mb_obj_t *)coord2); CU_ASSERT(!r); - + r = mb_objs_are_overlay(rdman, (mb_obj_t *)shape1, (mb_obj_t *)coord2); CU_ASSERT(!r); - + r = mb_objs_are_overlay(rdman, (mb_obj_t *)shape1, (mb_obj_t *)shape2); CU_ASSERT(!r); - + r = mb_objs_are_overlay(rdman, (mb_obj_t *)coord1, (mb_obj_t *)shape2); CU_ASSERT(!r); - + r = mb_objs_are_overlay(rdman, (mb_obj_t *)shape1, (mb_obj_t *)shape3); CU_ASSERT(!r); - + r = mb_objs_are_overlay(rdman, (mb_obj_t *)coord1, (mb_obj_t *)shape3); CU_ASSERT(!r); shape_add_point(shape1, 5, 5); - + r = mb_objs_are_overlay(rdman, (mb_obj_t *)coord1, (mb_obj_t *)coord2); CU_ASSERT(r); - + r = mb_objs_are_overlay(rdman, (mb_obj_t *)shape1, (mb_obj_t *)coord2); CU_ASSERT(r); - + r = mb_objs_are_overlay(rdman, (mb_obj_t *)shape1, (mb_obj_t *)shape2); CU_ASSERT(r); - + r = mb_objs_are_overlay(rdman, (mb_obj_t *)coord1, (mb_obj_t *)shape2); CU_ASSERT(r); - + r = mb_objs_are_overlay(rdman, (mb_obj_t *)shape1, (mb_obj_t *)shape3); CU_ASSERT(!r); - + r = mb_objs_are_overlay(rdman, (mb_obj_t *)coord1, (mb_obj_t *)shape3); CU_ASSERT(!r);