Add SCROLL_FLAGS enum (and fix an hidden bug in widget_scroll_get_part)

This commit is contained in:
adrian17 2014-07-25 20:19:32 +02:00
parent 65b17cbd5d
commit 8960792073
3 changed files with 16 additions and 11 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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