Minor tweaks to testhittesting.

This commit is contained in:
Ryan C. Gordon 2014-06-05 00:49:25 -04:00
parent 2d38a71a1f
commit 31de8f8b99

View File

@ -28,22 +28,29 @@ hitTest(SDL_Window *window, const SDL_Point *pt, void *data)
} }
SDL_GetWindowSize(window, &w, &h); SDL_GetWindowSize(window, &w, &h);
if (pt->x < RESIZE_BORDER && pt->y < RESIZE_BORDER)
return SDL_HITTEST_RESIZE_TOPLEFT; #define REPORT_RESIZE_HIT(name) { \
if (pt->x > RESIZE_BORDER && pt->x < w - RESIZE_BORDER && pt->y < RESIZE_BORDER) SDL_Log("HIT-TEST: RESIZE_" #name "\n"); \
return SDL_HITTEST_RESIZE_TOP; return SDL_HITTEST_RESIZE_##name; \
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) if (pt->x < RESIZE_BORDER && pt->y < RESIZE_BORDER) {
return SDL_HITTEST_RESIZE_RIGHT; REPORT_RESIZE_HIT(TOPLEFT);
if (pt->x > w - RESIZE_BORDER && pt->y > h - RESIZE_BORDER) } else if (pt->x > RESIZE_BORDER && pt->x < w - RESIZE_BORDER && pt->y < RESIZE_BORDER) {
return SDL_HITTEST_RESIZE_BOTTOMRIGHT; REPORT_RESIZE_HIT(TOP);
if (pt->x < w - RESIZE_BORDER && pt->x > RESIZE_BORDER && pt->y > h - RESIZE_BORDER) } else if (pt->x > w - RESIZE_BORDER && pt->y < RESIZE_BORDER) {
return SDL_HITTEST_RESIZE_BOTTOM; REPORT_RESIZE_HIT(TOPRIGHT);
if (pt->x < RESIZE_BORDER && pt->y > h - RESIZE_BORDER) } else if (pt->x > w - RESIZE_BORDER && pt->y > RESIZE_BORDER && pt->y < h - RESIZE_BORDER) {
return SDL_HITTEST_RESIZE_BOTTOMLEFT; REPORT_RESIZE_HIT(RIGHT);
if (pt->x < RESIZE_BORDER && pt->y < h - RESIZE_BORDER && pt->y > RESIZE_BORDER) } else if (pt->x > w - RESIZE_BORDER && pt->y > h - RESIZE_BORDER) {
return SDL_HITTEST_RESIZE_LEFT; 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"); SDL_Log("HIT-TEST: NORMAL\n");
return SDL_HITTEST_NORMAL; return SDL_HITTEST_NORMAL;