diff src/event.c @ 439:254854ed479c

Fix bug of _find_shape_in_pos(). It can not find a correct shape for a specified point. Since it call _shape_pos_is_in_cairo() directly, cairo_new_path() is not called to clear path after each calling for a shape. So, old path would interference later testing. It should call _shape_pos_is_in() instead of _shape_pos_is_in_cairo().
author Thinker K.F. Li <thinker@branda.to>
date Thu, 30 Jul 2009 15:42:47 +0800
parents 1ee11bab38fa
children 16116d84bc5e
line wrap: on
line diff
--- a/src/event.c	Thu Jul 30 15:42:47 2009 +0800
+++ b/src/event.c	Thu Jul 30 15:42:47 2009 +0800
@@ -9,6 +9,7 @@
 #include "mb_redraw_man.h"
 #include "mb_shapes.h"
 #endif
+#include "../config.h"
 
 #define OK 0
 #define ERR -1
@@ -156,7 +157,8 @@
        MBO_PATH,
        MBO_TEXT,
        MBO_RECT,
-       MBO_IMAGE
+       MBO_IMAGE,
+       MBO_STEXT
 };
 #define MBO_TYPE(x) (((mb_obj_t *)(x))->obj_type)
 #define IS_MBO_SHAPES(x) (((mb_obj_t *)(x))->obj_type & MBO_SHAPES)
@@ -527,23 +529,39 @@
     return OK;
 }
 
+/*! \brief Draw path of a shape.
+ *
+ * \note This function should be merged with what is in redraw_man.c.
+ */
 static void draw_shape_path(shape_t *shape, cairo_t *cr) {
     switch(MBO_TYPE(shape)) {
     case MBO_PATH:
 	sh_path_draw(shape, cr);
 	break;
+#ifdef SH_TEXT
     case MBO_TEXT:
 	sh_text_draw(shape, cr);
 	break;
+#endif
     case MBO_RECT:
 	sh_rect_draw(shape, cr);
 	break;
     case MBO_IMAGE:
 	sh_image_draw(shape, cr);
 	break;
+#ifdef SH_STEXT
+    case MBO_STEXT:
+	sh_stext_draw(shape, cr);
+	break;
+#endif
     }
 }
 
+/*! \brief Implement exactly point testing with Cairo.
+ *
+ * \note This function should not be called directly. Call
+ *  _shape_pos_is_in() insteaded.
+ */
 static int _shape_pos_is_in_cairo(shape_t *shape, co_aix x, co_aix y,
 				  int *in_stroke, cairo_t *cr) {
     draw_shape_path(shape, cr);
@@ -594,7 +612,7 @@
 	shape = rdman_get_shape_gl(rdman, i);
 	if(sh_get_flags(shape, GEF_HIDDEN))
 	    continue;
-	r = _shape_pos_is_in_cairo(shape, x, y, in_stroke, cr);
+	r = _shape_pos_is_in(shape, x, y, in_stroke, cr);
 	if(r)
 	    return shape;
     }