diff options
author | Ryan C. Gordon <icculus@icculus.org> | 2014-06-05 00:49:25 -0400 |
---|---|---|
committer | Ryan C. Gordon <icculus@icculus.org> | 2014-06-05 00:49:25 -0400 |
commit | 9b4f6bd2910bb101ff0446debdb146fde2036228 (patch) | |
tree | 72c5fa5be5e4fb9c79cb6eade2c120d819d04037 /test/testhittesting.c | |
parent | 132cd3656953ad01a96cc8f3f98ce9c728740efa (diff) | |
download | sdl-9b4f6bd2910bb101ff0446debdb146fde2036228.tar.gz |
Minor tweaks to testhittesting.
Diffstat (limited to 'test/testhittesting.c')
-rw-r--r-- | test/testhittesting.c | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/test/testhittesting.c b/test/testhittesting.c index 5f2f274d4..5e32be42d 100644 --- a/test/testhittesting.c +++ b/test/testhittesting.c @@ -28,22 +28,29 @@ hitTest(SDL_Window *window, const SDL_Point *pt, void *data) } 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; |