From: Holger Schemel Date: Wed, 26 Jul 2006 14:18:24 +0000 (+0200) Subject: rnd-20060726-3-src X-Git-Tag: 3.2.1^2~36 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=d109a83b1b41088e536efa0788d5cb33382bbe18;p=rocksndiamonds.git rnd-20060726-3-src * added support for mouse scroll wheel (caused buggy behaviour before) --- diff --git a/ChangeLog b/ChangeLog index bbd695f5..97829c98 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,10 @@ 2006-07-26 * improved level number selection in main menu and player selection in setup menu (input devices section) by using standard button gadgets + * added support for mouse scroll wheel (caused buggy behaviour before) 2006-07-25 - * improved general scrollbar handling - * added support for mouse scroll wheels + * improved general scrollbar handling (when jump-scrolling scrollbars) 2006-07-23 * changed scrollbars to always show last line as first after scrolling diff --git a/src/conftime.h b/src/conftime.h index f8387062..d7774c42 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2006-07-26 15:25]" +#define COMPILE_DATE_STRING "[2006-07-26 16:18]" diff --git a/src/editor.c b/src/editor.c index f80d82e0..ec594406 100644 --- a/src/editor.c +++ b/src/editor.c @@ -2402,6 +2402,8 @@ static struct int gd_x, gd_y; int x, y; int width, height; + int wheel_x, wheel_y; + int wheel_width, wheel_height; int type; int gadget_id; char *infotext; @@ -2411,6 +2413,8 @@ static struct ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS, SX + ED_SCROLL_HORIZONTAL_XPOS, SY + ED_SCROLL_HORIZONTAL_YPOS, ED_SCROLL_HORIZONTAL_XSIZE, ED_SCROLL_HORIZONTAL_YSIZE, + -1, -1, + -1, -1, GD_TYPE_SCROLLBAR_HORIZONTAL, GADGET_ID_SCROLL_HORIZONTAL, "scroll level editing area horizontally" @@ -2419,6 +2423,8 @@ static struct ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS, SX + ED_SCROLL_VERTICAL_XPOS, SY + ED_SCROLL_VERTICAL_YPOS, ED_SCROLL_VERTICAL_XSIZE, ED_SCROLL_VERTICAL_YSIZE, + 0, 0, + SX + SXSIZE + SX, WIN_YSIZE, GD_TYPE_SCROLLBAR_VERTICAL, GADGET_ID_SCROLL_VERTICAL, "scroll level editing area vertically" @@ -2427,6 +2433,8 @@ static struct ED_SCROLLBAR2_XPOS, ED_SCROLLBAR2_YPOS, DX + ED_SCROLL2_VERTICAL_XPOS, DY + ED_SCROLL2_VERTICAL_YPOS, ED_SCROLL2_VERTICAL_XSIZE, ED_SCROLL2_VERTICAL_YSIZE, + SX + SXSIZE + SX, 0, + WIN_XSIZE - (SX + SXSIZE + SX), WIN_YSIZE, GD_TYPE_SCROLLBAR_VERTICAL, GADGET_ID_SCROLL_LIST_VERTICAL, "scroll element list vertically" @@ -6140,6 +6148,10 @@ static void CreateScrollbarGadgets() GDI_SCROLLBAR_ITEMS_MAX, items_max, GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible, GDI_SCROLLBAR_ITEM_POSITION, item_position, + GDI_WHEEL_AREA_X, scrollbar_info[i].wheel_x, + GDI_WHEEL_AREA_Y, scrollbar_info[i].wheel_y, + GDI_WHEEL_AREA_WIDTH, scrollbar_info[i].wheel_width, + GDI_WHEEL_AREA_HEIGHT, scrollbar_info[i].wheel_height, GDI_STATE, GD_BUTTON_UNPRESSED, GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1, GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2, diff --git a/src/events.c b/src/events.c index 134a5e73..d78ff4a9 100644 --- a/src/events.c +++ b/src/events.c @@ -322,7 +322,7 @@ void HandleButtonEvent(ButtonEvent *event) else button_status = MB_RELEASED; - HandleButton(event->x, event->y, button_status); + HandleButton(event->x, event->y, button_status, event->button); } void HandleMotionEvent(MotionEvent *event) @@ -335,7 +335,7 @@ void HandleMotionEvent(MotionEvent *event) motion_status = TRUE; - HandleButton(event->x, event->y, button_status); + HandleButton(event->x, event->y, button_status, button_status); } void HandleKeyEvent(KeyEvent *event) @@ -396,7 +396,7 @@ void HandleClientMessageEvent(ClientMessageEvent *event) CloseAllAndExit(0); } -void HandleButton(int mx, int my, int button) +void HandleButton(int mx, int my, int button, int button_nr) { static int old_mx = 0, old_my = 0; @@ -418,14 +418,18 @@ void HandleButton(int mx, int my, int button) mx = my = -32; /* force mouse event to be outside screen tiles */ } - switch(game_status) + /* do not use scroll wheel button events for anything other than gadgets */ + if (button_nr > 3) + return; + + switch (game_status) { case GAME_MODE_TITLE: - HandleTitleScreen(mx,my, 0,0, button); + HandleTitleScreen(mx, my, 0, 0, button); break; case GAME_MODE_MAIN: - HandleMainMenu(mx,my, 0,0, button); + HandleMainMenu(mx, my, 0, 0, button); break; case GAME_MODE_PSEUDO_TYPENAME: @@ -433,11 +437,11 @@ void HandleButton(int mx, int my, int button) break; case GAME_MODE_LEVELS: - HandleChooseLevel(mx,my, 0,0, button); + HandleChooseLevel(mx, my, 0, 0, button); break; case GAME_MODE_SCORES: - HandleHallOfFame(0,0, 0,0, button); + HandleHallOfFame(0, 0, 0, 0, button); break; case GAME_MODE_EDITOR: @@ -445,11 +449,11 @@ void HandleButton(int mx, int my, int button) break; case GAME_MODE_INFO: - HandleInfoScreen(mx,my, 0,0, button); + HandleInfoScreen(mx, my, 0, 0, button); break; case GAME_MODE_SETUP: - HandleSetupScreen(mx,my, 0,0, button); + HandleSetupScreen(mx, my, 0, 0, button); break; case GAME_MODE_PLAYING: @@ -947,7 +951,8 @@ void HandleNoEvent() { if (button_status && game_status != GAME_MODE_PLAYING) { - HandleButton(0, 0, -button_status); + HandleButton(0, 0, -button_status, button_status); + return; } diff --git a/src/events.h b/src/events.h index 8c5d74df..da370708 100644 --- a/src/events.h +++ b/src/events.h @@ -32,7 +32,7 @@ void HandleClientMessageEvent(ClientMessageEvent *event); void HandleNoEvent(void); -void HandleButton(int, int, int); +void HandleButton(int, int, int, int); void HandleKey(Key, int); void HandleJoystick(); diff --git a/src/libgame/gadgets.c b/src/libgame/gadgets.c index c7c9ff18..e939f865 100644 --- a/src/libgame/gadgets.c +++ b/src/libgame/gadgets.c @@ -73,18 +73,17 @@ static struct GadgetInfo *getGadgetInfoFromMousePosition(int mx, int my, /* first check for scrollbars in case of mouse scroll wheel button events */ if (button == 4 || button == 5) { -#if 0 - printf("WHOA! SCROLL WHEEL DETECTED [%d]\n", button); -#endif - + /* check for the first active scrollbar with matching mouse wheel area */ for (gi = gadget_list_first_entry; gi != NULL; gi = gi->next) { if (gi->mapped && gi->active && - gi->type & GD_TYPE_SCROLLBAR) + gi->type & GD_TYPE_SCROLLBAR && + mx >= gi->wheelarea.x && mx < gi->wheelarea.x + gi->wheelarea.width && + my >= gi->wheelarea.y && my < gi->wheelarea.y + gi->wheelarea.height) return gi; } - /* no active scrollbar found -- ignore this button event */ + /* no active scrollbar found -- ignore this scroll wheel button event */ return NULL; } @@ -995,6 +994,22 @@ static void HandleGadgetTags(struct GadgetInfo *gi, int first_tag, va_list ap) gi->scrollbar.item_position = va_arg(ap, int); break; + case GDI_WHEEL_AREA_X: + gi->wheelarea.x = va_arg(ap, int); + break; + + case GDI_WHEEL_AREA_Y: + gi->wheelarea.y = va_arg(ap, int); + break; + + case GDI_WHEEL_AREA_WIDTH: + gi->wheelarea.width = va_arg(ap, int); + break; + + case GDI_WHEEL_AREA_HEIGHT: + gi->wheelarea.height = va_arg(ap, int); + break; + case GDI_CALLBACK_INFO: gi->callback_info = va_arg(ap, gadget_function); break; diff --git a/src/libgame/gadgets.h b/src/libgame/gadgets.h index 86b9bfb1..a1271813 100644 --- a/src/libgame/gadgets.h +++ b/src/libgame/gadgets.h @@ -102,9 +102,13 @@ #define GDI_SCROLLBAR_ITEMS_MAX 37 #define GDI_SCROLLBAR_ITEMS_VISIBLE 38 #define GDI_SCROLLBAR_ITEM_POSITION 39 -#define GDI_INFO_TEXT 40 -#define GDI_ACTIVE 41 -#define GDI_DIRECT_DRAW 42 +#define GDI_WHEEL_AREA_X 40 +#define GDI_WHEEL_AREA_Y 41 +#define GDI_WHEEL_AREA_WIDTH 42 +#define GDI_WHEEL_AREA_HEIGHT 43 +#define GDI_INFO_TEXT 44 +#define GDI_ACTIVE 45 +#define GDI_DIRECT_DRAW 46 typedef void (*gadget_function)(void *); @@ -206,6 +210,12 @@ struct GadgetScrollbar int correction; /* scrollbar position correction */ }; +struct GadgetWheelArea +{ + int x, y; /* active area for wheel (start) */ + int width, height; /* active area for wheel (size) */ +}; + struct GadgetInfo { int id; /* internal gadget identifier */ @@ -237,6 +247,7 @@ struct GadgetInfo struct GadgetTextArea textarea; /* fields for text area gadget */ struct GadgetSelectbox selectbox; /* fields for selectbox gadget */ struct GadgetScrollbar scrollbar; /* fields for scrollbar gadget */ + struct GadgetWheelArea wheelarea; /* fields for scroll wheel area */ struct GadgetInfo *next; /* next list entry */ }; diff --git a/src/screens.c b/src/screens.c index 25b3bfd8..09572357 100644 --- a/src/screens.c +++ b/src/screens.c @@ -4179,6 +4179,10 @@ static void CreateScreenScrollbars() GDI_SCROLLBAR_ITEMS_MAX, items_max, GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible, GDI_SCROLLBAR_ITEM_POSITION, item_position, + GDI_WHEEL_AREA_X, 0, + GDI_WHEEL_AREA_Y, 0, + GDI_WHEEL_AREA_WIDTH, WIN_XSIZE, + GDI_WHEEL_AREA_HEIGHT, WIN_YSIZE, GDI_STATE, GD_BUTTON_UNPRESSED, GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1, GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,