rnd-19981217-2
authorHolger Schemel <info@artsoft.org>
Thu, 17 Dec 1998 00:12:05 +0000 (01:12 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:32:30 +0000 (10:32 +0200)
src/buttons.c
src/buttons.h
src/editor.c

index c9c1348000018e6853f28f3aba2acdde8c26b76e..7ac61e36a7a10e147e60b500302f1993f6ad40f2 100644 (file)
@@ -1810,6 +1810,7 @@ void HandleGadgets(int mx, int my, int button)
     gi->state = GD_BUTTON_PRESSED;
     gi->event.type = GD_EVENT_PRESSED;
     gi->event.button = button;
     gi->state = GD_BUTTON_PRESSED;
     gi->event.type = GD_EVENT_PRESSED;
     gi->event.button = button;
+    gi->event.off_borders = FALSE;
 
     /* initialize delay counter */
     pressed_delay = 0;
 
     /* initialize delay counter */
     pressed_delay = 0;
@@ -1833,7 +1834,7 @@ void HandleGadgets(int mx, int my, int button)
 
     gi->state = GD_BUTTON_PRESSED;
     gi->event.type = GD_EVENT_MOVING;
 
     gi->state = GD_BUTTON_PRESSED;
     gi->event.type = GD_EVENT_MOVING;
-
+    gi->event.off_borders = FALSE;
     if (gi->event_mask & GD_EVENT_MOVING)
       gi->callback(gi);
   }
     if (gi->event_mask & GD_EVENT_MOVING)
       gi->callback(gi);
   }
@@ -1845,6 +1846,7 @@ void HandleGadgets(int mx, int my, int button)
 
     gi->state = GD_BUTTON_UNPRESSED;
     gi->event.type = GD_EVENT_MOVING;
 
     gi->state = GD_BUTTON_UNPRESSED;
     gi->event.type = GD_EVENT_MOVING;
+    gi->event.off_borders = TRUE;
 
     if (gi->event_mask & GD_EVENT_MOVING)
       gi->callback(gi);
 
     if (gi->event_mask & GD_EVENT_MOVING)
       gi->callback(gi);
index 34797401c7b5529b510f9068f73957d389186709..255c82436d4f497709c88c3e6ed770cec052037f 100644 (file)
@@ -330,6 +330,7 @@ struct GadgetEvent
   unsigned long type;                  /* event type */
   int button;                          /* button number for button events */
   int x, y;                            /* gadget position at event time */
   unsigned long type;                  /* event type */
   int button;                          /* button number for button events */
   int x, y;                            /* gadget position at event time */
+  boolean off_borders;                 /* mouse pointer outside gadget? */
 };
 
 struct GadgetDrawingArea
 };
 
 struct GadgetDrawingArea
index 36003a113e49271edcd56479f2101848d124aa08..88b7d7dcd7b746b474c2204ef6569920a7c6b6bf 100644 (file)
@@ -1973,16 +1973,12 @@ static void RandomPlacement(int button)
 static void HandleDrawingAreas(struct GadgetInfo *gi)
 {
   static boolean started_inside_drawing_area = FALSE;
 static void HandleDrawingAreas(struct GadgetInfo *gi)
 {
   static boolean started_inside_drawing_area = FALSE;
-  boolean inside_drawing_area;
+  boolean inside_drawing_area = !gi->event.off_borders;
   boolean button_press_event;
   boolean button_release_event;
   int new_element;
   int button = gi->event.button;
   boolean button_press_event;
   boolean button_release_event;
   int new_element;
   int button = gi->event.button;
-  int mx = SX + gi->event.x * MINI_TILEX;
-  int my = SX + gi->event.y * MINI_TILEY;
-  int min_mx = SX, max_mx = SX + SXSIZE -1;
-  int min_my = SY, max_my = SY + SYSIZE -1;
-  int sx, sy;
+  int sx = gi->event.x, sy = gi->event.y;
   int lx, ly;
   int x, y;
 
   int lx, ly;
   int x, y;
 
@@ -1992,13 +1988,8 @@ static void HandleDrawingAreas(struct GadgetInfo *gi)
   button_press_event = (gi->event.type == GD_EVENT_PRESSED);
   button_release_event = (gi->event.type == GD_EVENT_RELEASED);
 
   button_press_event = (gi->event.type == GD_EVENT_PRESSED);
   button_release_event = (gi->event.type == GD_EVENT_RELEASED);
 
-  inside_drawing_area =
-    (mx >= min_mx && mx <= max_mx && my >= min_my && my <= max_my);
-
-  mx = (mx < min_mx ? min_mx : mx > max_mx ? max_mx : mx);
-  my = (my < min_my ? min_my : my > max_my ? max_my : my);
-  sx = (mx - SX) / MINI_TILEX; 
-  sy = (my - SY) / MINI_TILEY; 
+  sx = (sx < 0 ? 0 : sx > 2*SCR_FIELDX - 1 ? 2*SCR_FIELDX - 1 : sx);
+  sy = (sy < 0 ? 0 : sy > 2*SCR_FIELDY - 1 ? 2*SCR_FIELDY - 1 : sy);
   lx = sx + level_xpos;
   ly = sy + level_ypos;
 
   lx = sx + level_xpos;
   ly = sy + level_ypos;
 
@@ -2008,8 +1999,8 @@ static void HandleDrawingAreas(struct GadgetInfo *gi)
   if (!started_inside_drawing_area)
     return;
 
   if (!started_inside_drawing_area)
     return;
 
-  printf("%d,%d, %d,%d, %d,%d, %d,%d.\n",
-        gi->event.x, gi->event.y, mx, my, sx, sy, lx, ly);
+  printf("%d,%d, %d,%d, %d,%d.\n",
+        gi->event.x, gi->event.y, sx, sy, lx, ly);
 
   if ((!button && !button_release_event) ||
       sx > lev_fieldx || sy > lev_fieldy ||
 
   if ((!button && !button_release_event) ||
       sx > lev_fieldx || sy > lev_fieldy ||