X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fgadgets.c;h=7c140cbedffbaf8d7cb742cd6cc5f3e741327b7c;hb=e05dda5c8cc6687dcbc59e182a81aed627e262d0;hp=b01fe169245ebb414aa3122a1867bf410854076f;hpb=33cf8c53fa267584efab93b15a99fbf78f9fb0c1;p=rocksndiamonds.git diff --git a/src/libgame/gadgets.c b/src/libgame/gadgets.c index b01fe169..7c140cbe 100644 --- a/src/libgame/gadgets.c +++ b/src/libgame/gadgets.c @@ -1,7 +1,7 @@ /*********************************************************** * Artsoft Retro-Game Library * *----------------------------------------------------------* -* (c) 1994-2002 Artsoft Entertainment * +* (c) 1994-2006 Artsoft Entertainment * * Holger Schemel * * Detmolder Strasse 189 * * 33604 Bielefeld * @@ -71,9 +71,11 @@ 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)) { - boolean check_horizontal = (GetKeyModState() & KMOD_Control); + /* 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) @@ -766,20 +768,14 @@ static void HandleGadgetTags(struct GadgetInfo *gi, int first_tag, va_list ap) break; case GDI_ACTIVE: - /* take care here: "boolean" is typedef'ed as "unsigned char", - which gets promoted to "int" */ gi->active = (boolean)va_arg(ap, int); break; case GDI_DIRECT_DRAW: - /* take care here: "boolean" is typedef'ed as "unsigned char", - which gets promoted to "int" */ gi->direct_draw = (boolean)va_arg(ap, int); break; case GDI_CHECKED: - /* take care here: "boolean" is typedef'ed as "unsigned char", - which gets promoted to "int" */ gi->checked = (boolean)va_arg(ap, int); break; @@ -1499,7 +1495,7 @@ boolean HandleGadgets(int mx, int my, int button) (gadget_pressed_inside_select_line && !mouse_inside_select_area))) { struct GadgetInfo *gi = last_gi; - boolean gadget_changed = (gi->event_mask & GD_EVENT_TEXT_LEAVING); + boolean gadget_changed = ((gi->event_mask & GD_EVENT_TEXT_LEAVING) != 0); /* check if text gadget has changed its value */ if (gi->type & GD_TYPE_TEXT_INPUT) @@ -1686,8 +1682,6 @@ boolean HandleGadgets(int mx, int my, int button) last_info_gi = new_gi; } -#if 1 - gadget_draggable = (gi && gi->type & GD_TYPE_SCROLLBAR); /* reset drag position for newly pressed scrollbar to "not dragging" */ @@ -1725,10 +1719,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 */ @@ -1737,10 +1732,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) != 0); + + item_steps = (scroll_single_step ? 1 : DEFAULT_WHEEL_STEPS); + item_direction = (button == MB_WHEEL_UP || + button == MB_WHEEL_LEFT ? -1 : +1); } changed_position = FALSE; @@ -1783,8 +1781,6 @@ boolean HandleGadgets(int mx, int my, int button) } } -#endif - if (gadget_pressed) { if (gi->type == GD_TYPE_CHECK_BUTTON) @@ -1815,10 +1811,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 = @@ -1964,9 +1961,7 @@ boolean HandleGadgets(int mx, int my, int button) if (gi->type & GD_TYPE_SCROLLBAR) DrawGadget(gi, DG_UNPRESSED, gi->direct_draw); -#if 1 gi->state = GD_BUTTON_UNPRESSED; -#endif gi->event.type = GD_EVENT_RELEASED; if (gi->event_mask & GD_EVENT_RELEASED && @@ -2009,7 +2004,7 @@ boolean HandleGadgetsKeyInput(Key key) if (key == KSYM_Return) /* valid for both text input and selectbox */ { - boolean gadget_changed = (gi->event_mask & GD_EVENT_TEXT_RETURN); + boolean gadget_changed = ((gi->event_mask & GD_EVENT_TEXT_RETURN) != 0); if (gi->type & GD_TYPE_TEXT_INPUT) {