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
-#define COMPILE_DATE_STRING "[2006-07-26 15:25]"
+#define COMPILE_DATE_STRING "[2006-07-26 16:18]"
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;
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"
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"
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"
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,
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)
motion_status = TRUE;
- HandleButton(event->x, event->y, button_status);
+ HandleButton(event->x, event->y, button_status, button_status);
}
void HandleKeyEvent(KeyEvent *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;
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:
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:
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:
{
if (button_status && game_status != GAME_MODE_PLAYING)
{
- HandleButton(0, 0, -button_status);
+ HandleButton(0, 0, -button_status, button_status);
+
return;
}
void HandleNoEvent(void);
-void HandleButton(int, int, int);
+void HandleButton(int, int, int, int);
void HandleKey(Key, int);
void HandleJoystick();
/* 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;
}
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;
#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 *);
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 */
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 */
};
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,