From 8960792073bada3829d35a81e10e2f6898842d59 Mon Sep 17 00:00:00 2001 From: adrian17 Date: Fri, 25 Jul 2014 20:19:32 +0200 Subject: [PATCH] Add SCROLL_FLAGS enum (and fix an hidden bug in widget_scroll_get_part) --- src/game.c | 12 ++++++------ src/widget.c | 8 ++++---- src/window.h | 7 ++++++- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/game.c b/src/game.c index 378b274cd0..37c655e986 100644 --- a/src/game.c +++ b/src/game.c @@ -950,7 +950,7 @@ static void input_hscrollbar_rightbutton(rct_window* w) left += 3; widgetWidth = widget->right - widget->left - 1; - if (scroll->flags & 0x0010) + if (scroll->flags & SCROLL_FLAG_VERTICAL) widgetWidth -= 11; widgetWidth *= -1; widgetWidth += scroll->h_right; @@ -999,7 +999,7 @@ static void input_hscrollbar_left_trough(rct_window* w) left = scroll->h_left; widgetWidth = widget->right - widget->left - 1; - if (scroll->flags & 0x0010) + if (scroll->flags & SCROLL_FLAG_VERTICAL) widgetWidth -= 11; left -= widgetWidth; if (left < 0) @@ -1044,7 +1044,7 @@ static void input_hscrollbar_right_trough(rct_window* w) left = scroll->h_left; widgetWidth = widget->right - widget->left - 1; - if (scroll->flags & 0x0010) + if (scroll->flags & SCROLL_FLAG_VERTICAL) widgetWidth -= 11; left += widgetWidth; widgetWidth *= -1; @@ -1136,7 +1136,7 @@ static void input_vscrollbar_bottombutton(rct_window* w) top += 3; widgetHeight = widget->bottom - widget->top - 1; - if (scroll->flags & 0x0001) + if (scroll->flags & SCROLL_FLAG_HORIZONTAL) widgetHeight -= 11; widgetHeight *= -1; widgetHeight += scroll->v_bottom; @@ -1185,7 +1185,7 @@ static void input_vscrollbar_top_trough(rct_window* w) top = scroll->v_top; widgetHeight = widget->bottom - widget->top - 1; - if (scroll->flags & 0x0001) + if (scroll->flags & SCROLL_FLAG_HORIZONTAL) widgetHeight -= 11; top -= widgetHeight; if (top < 0) @@ -1230,7 +1230,7 @@ static void input_vscrollbar_bottom_trough(rct_window* w) top = scroll->v_top; widgetHeight = widget->bottom - widget->top - 1; - if (scroll->flags & 0x0001) + if (scroll->flags & SCROLL_FLAG_HORIZONTAL) widgetHeight -= 11; top += widgetHeight; widgetHeight *= -1; diff --git a/src/widget.c b/src/widget.c index 1733eef68d..e2994e4031 100644 --- a/src/widget.c +++ b/src/widget.c @@ -1022,13 +1022,13 @@ void widget_scroll_get_part(rct_window *w, rct_widget* widget, int x, int y, int } } - if ((w->scrolls[*scroll_id].flags & 0x01) && y >= (w->y + widget->bottom - 11)) + if ((w->scrolls[*scroll_id].flags & SCROLL_FLAG_HORIZONTAL) && y >= (w->y + widget->bottom - 11)) { //horizon scrollbar int rightOffset = 0; int iteratorLeft = widget->left + w->x; int iteratorRight = widget->right + w->x; - if (w->scrolls[*scroll_id].flags & 0x01) + if (w->scrolls[*scroll_id].flags & SCROLL_FLAG_VERTICAL) { rightOffset = 11; } @@ -1057,13 +1057,13 @@ void widget_scroll_get_part(rct_window *w, rct_widget* widget, int x, int y, int *output_scroll_area = SCROLL_PART_HSCROLLBAR_THUMB; } } - else if ((w->scrolls[*scroll_id].flags & 10) || (x >= w->x + widget->right - 11)) + else if ((w->scrolls[*scroll_id].flags & SCROLL_FLAG_VERTICAL) && (x >= w->x + widget->right - 11)) { //vertical scrollbar int bottomOffset = 0; int iteratorTop = widget->top + w->y; int iteratorBottom = widget->bottom + w->y; - if (w->scrolls[*scroll_id].flags & 0x01) + if (w->scrolls[*scroll_id].flags & SCROLL_FLAG_HORIZONTAL) { bottomOffset = 11; } diff --git a/src/window.h b/src/window.h index 8049e3c6d2..cd608f26d4 100644 --- a/src/window.h +++ b/src/window.h @@ -82,7 +82,7 @@ typedef struct { * size: 0x12 */ typedef struct { - uint16 flags; // 0x00 (0x10 == vertical scrollbar, 0x01 == horizontal scrollbar) + uint16 flags; // 0x00 sint16 h_left; // 0x02 sint16 h_right; // 0x04 sint16 h_thumb_left; // 0x06 @@ -93,6 +93,11 @@ typedef struct { sint16 v_thumb_bottom; // 0x10 } rct_scroll; +typedef enum { + SCROLL_FLAG_HORIZONTAL = (1 << 0), + SCROLL_FLAG_VERTICAL = (1 << 4), +} SCROLL_FLAGS; + /** * Window structure * size: 0x4C0