Minor tweaks to testhittesting.
authorRyan C. Gordon <icculus@icculus.org>
Thu, 05 Jun 2014 00:49:25 -0400
changeset 8947 14d3e9f93c16
parent 8946 c9592936dffc
child 8948 3ed9a59efda1
Minor tweaks to testhittesting.
test/testhittesting.c
--- a/test/testhittesting.c	Thu Jun 05 00:45:16 2014 -0400
+++ b/test/testhittesting.c	Thu Jun 05 00:49:25 2014 -0400
@@ -28,22 +28,29 @@
     }
 
     SDL_GetWindowSize(window, &w, &h);
-    if (pt->x < RESIZE_BORDER && pt->y < RESIZE_BORDER)
-        return SDL_HITTEST_RESIZE_TOPLEFT;
-    if (pt->x > RESIZE_BORDER && pt->x < w - RESIZE_BORDER && pt->y < RESIZE_BORDER)
-        return SDL_HITTEST_RESIZE_TOP;
-    if (pt->x > w - RESIZE_BORDER && pt->y < RESIZE_BORDER)
-        return SDL_HITTEST_RESIZE_TOPRIGHT;
-    if (pt->x > w - RESIZE_BORDER && pt->y > RESIZE_BORDER && pt->y < h - RESIZE_BORDER)
-        return SDL_HITTEST_RESIZE_RIGHT;
-    if (pt->x > w - RESIZE_BORDER && pt->y > h - RESIZE_BORDER)
-        return SDL_HITTEST_RESIZE_BOTTOMRIGHT;
-    if (pt->x < w - RESIZE_BORDER && pt->x > RESIZE_BORDER && pt->y > h - RESIZE_BORDER)
-        return SDL_HITTEST_RESIZE_BOTTOM;
-    if (pt->x < RESIZE_BORDER && pt->y > h - RESIZE_BORDER)
-        return SDL_HITTEST_RESIZE_BOTTOMLEFT;
-    if (pt->x < RESIZE_BORDER && pt->y < h - RESIZE_BORDER && pt->y > RESIZE_BORDER)
-        return SDL_HITTEST_RESIZE_LEFT;
+
+    #define REPORT_RESIZE_HIT(name) { \
+        SDL_Log("HIT-TEST: RESIZE_" #name "\n"); \
+        return SDL_HITTEST_RESIZE_##name; \
+    }
+
+    if (pt->x < RESIZE_BORDER && pt->y < RESIZE_BORDER) {
+        REPORT_RESIZE_HIT(TOPLEFT);
+    } else if (pt->x > RESIZE_BORDER && pt->x < w - RESIZE_BORDER && pt->y < RESIZE_BORDER) {
+        REPORT_RESIZE_HIT(TOP);
+    } else if (pt->x > w - RESIZE_BORDER && pt->y < RESIZE_BORDER) {
+        REPORT_RESIZE_HIT(TOPRIGHT);
+    } else if (pt->x > w - RESIZE_BORDER && pt->y > RESIZE_BORDER && pt->y < h - RESIZE_BORDER) {
+        REPORT_RESIZE_HIT(RIGHT);
+    } else if (pt->x > w - RESIZE_BORDER && pt->y > h - RESIZE_BORDER) {
+        REPORT_RESIZE_HIT(BOTTOMRIGHT);
+    } else if (pt->x < w - RESIZE_BORDER && pt->x > RESIZE_BORDER && pt->y > h - RESIZE_BORDER) {
+        REPORT_RESIZE_HIT(BOTTOM);
+    } else if (pt->x < RESIZE_BORDER && pt->y > h - RESIZE_BORDER) {
+        REPORT_RESIZE_HIT(BOTTOMLEFT);
+    } else if (pt->x < RESIZE_BORDER && pt->y < h - RESIZE_BORDER && pt->y > RESIZE_BORDER) {
+        REPORT_RESIZE_HIT(LEFT);
+    }
 
     SDL_Log("HIT-TEST: NORMAL\n");
     return SDL_HITTEST_NORMAL;