X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fgadgets.c;h=afe5c3a74addaf06cc37ed3e7fae46d6638e4054;hb=e8b94b38c4be1bf3ada57ade9eb3a96adb080775;hp=e939f865a5ace5063ea78374a2b0b69c657c5758;hpb=d109a83b1b41088e536efa0788d5cb33382bbe18;p=rocksndiamonds.git diff --git a/src/libgame/gadgets.c b/src/libgame/gadgets.c index e939f865..afe5c3a7 100644 --- a/src/libgame/gadgets.c +++ b/src/libgame/gadgets.c @@ -71,13 +71,18 @@ static struct GadgetInfo *getGadgetInfoFromMousePosition(int mx, int my, struct GadgetInfo *gi; /* first check for scrollbars in case of mouse scroll wheel button events */ - if (button == 4 || button == 5) + if (IS_WHEEL_BUTTON(button)) { + /* real horizontal wheel or vertical wheel with modifier key pressed */ + boolean check_horizontal = (IS_WHEEL_BUTTON_HORIZONTAL(button) || + GetKeyModState() & KMOD_Shift); + /* 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_HORIZONTAL && check_horizontal) || + (gi->type & GD_TYPE_SCROLLBAR_VERTICAL && !check_horizontal)) && mx >= gi->wheelarea.x && mx < gi->wheelarea.x + gi->wheelarea.width && my >= gi->wheelarea.y && my < gi->wheelarea.y + gi->wheelarea.height) return gi; @@ -1722,10 +1727,11 @@ boolean HandleGadgets(int mx, int my, int button) { int mpos = (gi->type == GD_TYPE_SCROLLBAR_HORIZONTAL ? mx : my); int gpos = (gi->type == GD_TYPE_SCROLLBAR_HORIZONTAL ? gi->x : gi->y); + int slider_start = gpos + gi->scrollbar.position; + int slider_end = gpos + gi->scrollbar.position + gi->scrollbar.size - 1; + boolean inside_slider = (mpos >= slider_start && mpos <= slider_end); - if (button > 3 || - mpos < gpos + gi->scrollbar.position || - mpos >= gpos + gi->scrollbar.position + gi->scrollbar.size) + if (IS_WHEEL_BUTTON(button) || !inside_slider) { /* click scrollbar one scrollbar length up/left or down/right */ @@ -1734,10 +1740,13 @@ boolean HandleGadgets(int mx, int my, int button) int item_steps = gs->items_visible - 1; int item_direction = (mpos < gpos + gi->scrollbar.position ? -1 : +1); - if (button > 3) + if (IS_WHEEL_BUTTON(button)) { - item_steps = 3; - item_direction = (button == 4 ? -1 : +1); + boolean scroll_single_step = (GetKeyModState() & KMOD_Alt); + + item_steps = (scroll_single_step ? 1 : DEFAULT_WHEEL_STEPS); + item_direction = (button == MB_WHEEL_UP || + button == MB_WHEEL_LEFT ? -1 : +1); } changed_position = FALSE; @@ -1812,10 +1821,11 @@ boolean HandleGadgets(int mx, int my, int button) { int mpos = (gi->type == GD_TYPE_SCROLLBAR_HORIZONTAL ? mx : my); int gpos = (gi->type == GD_TYPE_SCROLLBAR_HORIZONTAL ? gi->x : gi->y); + int slider_start = gpos + gi->scrollbar.position; + int slider_end = gpos + gi->scrollbar.position + gi->scrollbar.size - 1; + boolean inside_slider = (mpos >= slider_start && mpos <= slider_end); - if (button >= 1 && button <= 3 && - mpos >= gpos + gi->scrollbar.position && - mpos < gpos + gi->scrollbar.position + gi->scrollbar.size) + if (!IS_WHEEL_BUTTON(button) && inside_slider) { /* start dragging scrollbar */ gi->scrollbar.drag_position =