Start with scroll events.

This commit is contained in:
Pere Pujal i Carabantes 2015-02-04 00:36:50 +01:00
parent 22866bd7db
commit d7b7274a96

View file

@ -4543,15 +4543,20 @@ printf("screenrectr_tools %d, %d, %d, %d\n", r_tools.x, r_tools.y, r_tools.w, r_
} }
} }
else if (event.type == SDL_MOUSEBUTTONDOWN && // else if (event.type == SDL_MOUSEBUTTONDOWN &&
wheely && event.button.button >= 4 && event.button.button <= 5) // wheely && event.button.button >= 4 && event.button.button <= 5)
else if (event.type == SDL_MOUSEWHEEL &&
wheely )
{ {
int most = 14; int most = 14;
int num_rows_needed; int num_rows_needed;
int xpos, ypos;
SDL_Rect r_controls; SDL_Rect r_controls;
SDL_Rect r_notcontrols; SDL_Rect r_notcontrols;
SDL_Rect r_items; /* = r_notcontrols; */ SDL_Rect r_items; /* = r_notcontrols; */
SDL_GetMouseState(&xpos, &ypos);
/* Scroll wheel code. /* Scroll wheel code.
WARNING: this must be kept in sync with the mouse-move WARNING: this must be kept in sync with the mouse-move
code (for cursor changes) and mouse-click code. */ code (for cursor changes) and mouse-click code. */
@ -4563,9 +4568,11 @@ printf("screenrectr_tools %d, %d, %d, %d\n", r_tools.x, r_tools.y, r_tools.w, r_
{ {
/* Left tools scroll */ /* Left tools scroll */
if (HIT(r_tools) && NUM_TOOLS > most + TOOLOFFSET) // if (HIT(r_tools) && NUM_TOOLS > most + TOOLOFFSET)
if (hit_test(&r_tools, xpos, ypos) && NUM_TOOLS > most + TOOLOFFSET)
{ {
int is_upper = (event.button.button == 4); // int is_upper = (event.button.button == 4);
int is_upper = (event.wheel.y > (Sint32)0);
if (is_upper && tool_scroll > 0) if (is_upper && tool_scroll > 0)
{ {
tool_scroll -= gd_tools.cols; tool_scroll -= gd_tools.cols;
@ -4688,7 +4695,9 @@ printf("screenrectr_tools %d, %d, %d, %d\n", r_tools.x, r_tools.y, r_tools.w, r_
else else
{ {
/* scroll button */ /* scroll button */
int is_upper = (event.button.button == 4); // int is_upper = (event.button.button == 4);
int is_upper = (event.wheel.y > (Sint32)0);
if ((is_upper && *thing_scroll > 0) /* upper arrow */ if ((is_upper && *thing_scroll > 0) /* upper arrow */
|| (!is_upper && *thing_scroll / gd_items.cols < num_rows_needed - gd_items.rows) /* lower arrow */ || (!is_upper && *thing_scroll / gd_items.cols < num_rows_needed - gd_items.rows) /* lower arrow */
) )
@ -23061,6 +23070,7 @@ int TP_EventFilter(void *data, const SDL_Event * event)
event->type == SDL_MOUSEMOTION || event->type == SDL_MOUSEMOTION ||
event->type == SDL_QUIT || event->type == SDL_QUIT ||
event->type == SDL_USEREVENT || event->type == SDL_USEREVENT ||
event->type == SDL_MOUSEWHEEL ||
event->type == SDL_TEXTINPUT) event->type == SDL_TEXTINPUT)
return 1; return 1;