]> git.cworth.org Git - kub/commitdiff
Showing carl error with drawing the selection_box
authorKevin Worth <kworth@kworth-laptop.(none)>
Sat, 6 Jun 2009 14:31:36 +0000 (10:31 -0400)
committerKevin Worth <kworth@kworth-laptop.(none)>
Sat, 6 Jun 2009 14:31:36 +0000 (10:31 -0400)
kub.c

diff --git a/kub.c b/kub.c
index ba6092490f1fc024955305da1c23b862969f823c..2fdcd36d8d78a45fde92057edcad9e54a595fa52 100644 (file)
--- a/kub.c
+++ b/kub.c
@@ -108,16 +108,12 @@ static void selection_box_init(selection_box_t *box)
     box->x2 = 0;
     box->y1 = 0;
     box->y2 = 0;
-    rect->visible = 0;
+    box->visible = 0;
 }
 
 static void selection_box_draw(selection_box_t *box, cairo_t *cr)
 {
-    int box_x = MIN(box->x1, box->x2);
-    int box_y = MIN(box->y1, box->y2);
-    int box_width = abs(box->x2 - box->x1);
-    int box_height = abs(box->y2 - box->y1);
-    cairo_rectangle (cr, box_x, box_y, box_width, box_height);
+    cairo_rectangle (cr, box->x1, box->y1, box->x2 -box->x1, box->y2 - box->y1);
     cairo_set_source_rgba(cr, 0.0, 0.1, 0.2, 0.5);
     cairo_fill (cr);
 }
@@ -552,8 +548,13 @@ static gboolean on_button_release_event (GtkWidget *widget, GdkEventButton *even
        selection_box_t *box;
        box = &game->selection_box;
 
+       int x = MIN(box->x1, box->x2);
+       int y = MIN(box->y1, box->y2);
+       int width = abs(box->x2 - box->x1);
+       int height = abs(box->y2 - box->y1);
+
        box->visible = 0;       
-       gtk_widget_queue_draw_area (widget, box->x, box->y, box->width, box->height);
+       gtk_widget_queue_draw_area (widget, x - 1, y - 1, width - 2, height + 2);
 
        tile_group_t group;
        group.num_tiles = 0;
@@ -592,12 +593,12 @@ static gboolean on_button_motion_event (GtkWidget *widget, GdkEventMotion *event
        box = &game->selection_box;
        box->visible = 1;
 
-       gtk_widget_queue_draw_area (widget, box->x - 1, box->y - 1, box->width + 1, box->height + 2);
+       gtk_widget_queue_draw_area ( widget,  MIN(box->x1, box->x2), MIN(box->y1, box->y2), abs(box->x2 - box->x1), abs(box->y2 - box->y1) );
 
-       box->width = event->x - box->x;
-       box->height = event->y - box->y;
+       box->x2 = event->x;
+       box->x2 = event->y;
 
-       gtk_widget_queue_draw_area (widget, box->x - 1, box->y - 1, box->width + 1, box->height + 2);
+       gtk_widget_queue_draw_area ( widget, MIN(box->x1, box->x2), MIN(box->y1, box->y2), abs(box->x2 - box->x1), abs(box->y2 - box->y1) );
     }
     else
     {