mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-23 07:43:01 +01:00
Use (const) references to scrolls where possible
This commit is contained in:
@@ -195,26 +195,26 @@ static void InputScrollDragContinue(const ScreenCoordsXY& screenCoords, rct_wind
|
|||||||
uint8_t scrollIndex = _dragScrollIndex;
|
uint8_t scrollIndex = _dragScrollIndex;
|
||||||
|
|
||||||
const auto& widget = w->widgets[widgetIndex];
|
const auto& widget = w->widgets[widgetIndex];
|
||||||
rct_scroll* scroll = &w->scrolls[scrollIndex];
|
auto& scroll = w->scrolls[scrollIndex];
|
||||||
|
|
||||||
ScreenCoordsXY differentialCoords = screenCoords - gInputDragLast;
|
ScreenCoordsXY differentialCoords = screenCoords - gInputDragLast;
|
||||||
|
|
||||||
if (scroll->flags & HSCROLLBAR_VISIBLE)
|
if (scroll.flags & HSCROLLBAR_VISIBLE)
|
||||||
{
|
{
|
||||||
int16_t size = widget.width() - 1;
|
int16_t size = widget.width() - 1;
|
||||||
if (scroll->flags & VSCROLLBAR_VISIBLE)
|
if (scroll.flags & VSCROLLBAR_VISIBLE)
|
||||||
size -= 11;
|
size -= 11;
|
||||||
size = std::max(0, scroll->h_right - size);
|
size = std::max(0, scroll.h_right - size);
|
||||||
scroll->h_left = std::min<uint16_t>(std::max(0, scroll->h_left + differentialCoords.x), size);
|
scroll.h_left = std::min<uint16_t>(std::max(0, scroll.h_left + differentialCoords.x), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scroll->flags & VSCROLLBAR_VISIBLE)
|
if (scroll.flags & VSCROLLBAR_VISIBLE)
|
||||||
{
|
{
|
||||||
int16_t size = widget.height() - 1;
|
int16_t size = widget.height() - 1;
|
||||||
if (scroll->flags & HSCROLLBAR_VISIBLE)
|
if (scroll.flags & HSCROLLBAR_VISIBLE)
|
||||||
size -= 11;
|
size -= 11;
|
||||||
size = std::max(0, scroll->v_bottom - size);
|
size = std::max(0, scroll.v_bottom - size);
|
||||||
scroll->v_top = std::min<uint16_t>(std::max(0, scroll->v_top + differentialCoords.y), size);
|
scroll.v_top = std::min<uint16_t>(std::max(0, scroll.v_top + differentialCoords.y), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
WidgetScrollUpdateThumbs(w, widgetIndex);
|
WidgetScrollUpdateThumbs(w, widgetIndex);
|
||||||
@@ -627,43 +627,43 @@ static void InputScrollBegin(rct_window* w, rct_widgetindex widgetIndex, const S
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto& widg = w->widgets[widgetIndex];
|
const auto& widg = w->widgets[widgetIndex];
|
||||||
rct_scroll* scroll = &w->scrolls[scroll_id];
|
auto& scroll = w->scrolls[scroll_id];
|
||||||
|
|
||||||
int32_t widget_width = widg.width() - 1;
|
int32_t widget_width = widg.width() - 1;
|
||||||
if (scroll->flags & VSCROLLBAR_VISIBLE)
|
if (scroll.flags & VSCROLLBAR_VISIBLE)
|
||||||
widget_width -= SCROLLBAR_WIDTH + 1;
|
widget_width -= SCROLLBAR_WIDTH + 1;
|
||||||
int32_t widget_content_width = std::max(scroll->h_right - widget_width, 0);
|
int32_t widget_content_width = std::max(scroll.h_right - widget_width, 0);
|
||||||
|
|
||||||
int32_t widget_height = widg.bottom - widg.top - 1;
|
int32_t widget_height = widg.bottom - widg.top - 1;
|
||||||
if (scroll->flags & HSCROLLBAR_VISIBLE)
|
if (scroll.flags & HSCROLLBAR_VISIBLE)
|
||||||
widget_height -= SCROLLBAR_WIDTH + 1;
|
widget_height -= SCROLLBAR_WIDTH + 1;
|
||||||
int32_t widget_content_height = std::max(scroll->v_bottom - widget_height, 0);
|
int32_t widget_content_height = std::max(scroll.v_bottom - widget_height, 0);
|
||||||
|
|
||||||
switch (scroll_area)
|
switch (scroll_area)
|
||||||
{
|
{
|
||||||
case SCROLL_PART_HSCROLLBAR_LEFT:
|
case SCROLL_PART_HSCROLLBAR_LEFT:
|
||||||
scroll->h_left = std::max(scroll->h_left - 3, 0);
|
scroll.h_left = std::max(scroll.h_left - 3, 0);
|
||||||
break;
|
break;
|
||||||
case SCROLL_PART_HSCROLLBAR_RIGHT:
|
case SCROLL_PART_HSCROLLBAR_RIGHT:
|
||||||
scroll->h_left = std::min(scroll->h_left + 3, widget_content_width);
|
scroll.h_left = std::min(scroll.h_left + 3, widget_content_width);
|
||||||
break;
|
break;
|
||||||
case SCROLL_PART_HSCROLLBAR_LEFT_TROUGH:
|
case SCROLL_PART_HSCROLLBAR_LEFT_TROUGH:
|
||||||
scroll->h_left = std::max(scroll->h_left - widget_width, 0);
|
scroll.h_left = std::max(scroll.h_left - widget_width, 0);
|
||||||
break;
|
break;
|
||||||
case SCROLL_PART_HSCROLLBAR_RIGHT_TROUGH:
|
case SCROLL_PART_HSCROLLBAR_RIGHT_TROUGH:
|
||||||
scroll->h_left = std::min(scroll->h_left + widget_width, widget_content_width);
|
scroll.h_left = std::min(scroll.h_left + widget_width, widget_content_width);
|
||||||
break;
|
break;
|
||||||
case SCROLL_PART_VSCROLLBAR_TOP:
|
case SCROLL_PART_VSCROLLBAR_TOP:
|
||||||
scroll->v_top = std::max(scroll->v_top - 3, 0);
|
scroll.v_top = std::max(scroll.v_top - 3, 0);
|
||||||
break;
|
break;
|
||||||
case SCROLL_PART_VSCROLLBAR_BOTTOM:
|
case SCROLL_PART_VSCROLLBAR_BOTTOM:
|
||||||
scroll->v_top = std::min(scroll->v_top + 3, widget_content_height);
|
scroll.v_top = std::min(scroll.v_top + 3, widget_content_height);
|
||||||
break;
|
break;
|
||||||
case SCROLL_PART_VSCROLLBAR_TOP_TROUGH:
|
case SCROLL_PART_VSCROLLBAR_TOP_TROUGH:
|
||||||
scroll->v_top = std::max(scroll->v_top - widget_height, 0);
|
scroll.v_top = std::max(scroll.v_top - widget_height, 0);
|
||||||
break;
|
break;
|
||||||
case SCROLL_PART_VSCROLLBAR_BOTTOM_TROUGH:
|
case SCROLL_PART_VSCROLLBAR_BOTTOM_TROUGH:
|
||||||
scroll->v_top = std::min(scroll->v_top + widget_height, widget_content_height);
|
scroll.v_top = std::min(scroll.v_top + widget_height, widget_content_height);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -744,32 +744,33 @@ static void InputScrollEnd()
|
|||||||
static void InputScrollPartUpdateHThumb(rct_window* w, rct_widgetindex widgetIndex, int32_t x, int32_t scroll_id)
|
static void InputScrollPartUpdateHThumb(rct_window* w, rct_widgetindex widgetIndex, int32_t x, int32_t scroll_id)
|
||||||
{
|
{
|
||||||
const auto& widget = w->widgets[widgetIndex];
|
const auto& widget = w->widgets[widgetIndex];
|
||||||
|
auto& scroll = w->scrolls[scroll_id];
|
||||||
|
|
||||||
if (window_find_by_number(w->classification, w->number) != nullptr)
|
if (window_find_by_number(w->classification, w->number) != nullptr)
|
||||||
{
|
{
|
||||||
int32_t newLeft;
|
int32_t newLeft;
|
||||||
newLeft = w->scrolls[scroll_id].h_right;
|
newLeft = scroll.h_right;
|
||||||
newLeft *= x;
|
newLeft *= x;
|
||||||
x = widget.width() - 21;
|
x = widget.width() - 21;
|
||||||
if (w->scrolls[scroll_id].flags & VSCROLLBAR_VISIBLE)
|
if (scroll.flags & VSCROLLBAR_VISIBLE)
|
||||||
x -= SCROLLBAR_WIDTH + 1;
|
x -= SCROLLBAR_WIDTH + 1;
|
||||||
newLeft /= x;
|
newLeft /= x;
|
||||||
x = newLeft;
|
x = newLeft;
|
||||||
w->scrolls[scroll_id].flags |= HSCROLLBAR_THUMB_PRESSED;
|
scroll.flags |= HSCROLLBAR_THUMB_PRESSED;
|
||||||
newLeft = w->scrolls[scroll_id].h_left;
|
newLeft = scroll.h_left;
|
||||||
newLeft += x;
|
newLeft += x;
|
||||||
if (newLeft < 0)
|
if (newLeft < 0)
|
||||||
newLeft = 0;
|
newLeft = 0;
|
||||||
x = widget.width() - 1;
|
x = widget.width() - 1;
|
||||||
if (w->scrolls[scroll_id].flags & VSCROLLBAR_VISIBLE)
|
if (scroll.flags & VSCROLLBAR_VISIBLE)
|
||||||
x -= SCROLLBAR_WIDTH + 1;
|
x -= SCROLLBAR_WIDTH + 1;
|
||||||
x *= -1;
|
x *= -1;
|
||||||
x += w->scrolls[scroll_id].h_right;
|
x += scroll.h_right;
|
||||||
if (x < 0)
|
if (x < 0)
|
||||||
x = 0;
|
x = 0;
|
||||||
if (newLeft > x)
|
if (newLeft > x)
|
||||||
newLeft = x;
|
newLeft = x;
|
||||||
w->scrolls[scroll_id].h_left = newLeft;
|
scroll.h_left = newLeft;
|
||||||
WidgetScrollUpdateThumbs(w, widgetIndex);
|
WidgetScrollUpdateThumbs(w, widgetIndex);
|
||||||
widget_invalidate_by_number(w->classification, w->number, widgetIndex);
|
widget_invalidate_by_number(w->classification, w->number, widgetIndex);
|
||||||
}
|
}
|
||||||
@@ -783,32 +784,33 @@ static void InputScrollPartUpdateVThumb(rct_window* w, rct_widgetindex widgetInd
|
|||||||
{
|
{
|
||||||
assert(w != nullptr);
|
assert(w != nullptr);
|
||||||
const auto& widget = w->widgets[widgetIndex];
|
const auto& widget = w->widgets[widgetIndex];
|
||||||
|
auto& scroll = w->scrolls[scroll_id];
|
||||||
|
|
||||||
if (window_find_by_number(w->classification, w->number) != nullptr)
|
if (window_find_by_number(w->classification, w->number) != nullptr)
|
||||||
{
|
{
|
||||||
int32_t newTop;
|
int32_t newTop;
|
||||||
newTop = w->scrolls[scroll_id].v_bottom;
|
newTop = scroll.v_bottom;
|
||||||
newTop *= y;
|
newTop *= y;
|
||||||
y = widget.height() - 21;
|
y = widget.height() - 21;
|
||||||
if (w->scrolls[scroll_id].flags & HSCROLLBAR_VISIBLE)
|
if (scroll.flags & HSCROLLBAR_VISIBLE)
|
||||||
y -= SCROLLBAR_WIDTH + 1;
|
y -= SCROLLBAR_WIDTH + 1;
|
||||||
newTop /= y;
|
newTop /= y;
|
||||||
y = newTop;
|
y = newTop;
|
||||||
w->scrolls[scroll_id].flags |= VSCROLLBAR_THUMB_PRESSED;
|
scroll.flags |= VSCROLLBAR_THUMB_PRESSED;
|
||||||
newTop = w->scrolls[scroll_id].v_top;
|
newTop = scroll.v_top;
|
||||||
newTop += y;
|
newTop += y;
|
||||||
if (newTop < 0)
|
if (newTop < 0)
|
||||||
newTop = 0;
|
newTop = 0;
|
||||||
y = widget.height() - 1;
|
y = widget.height() - 1;
|
||||||
if (w->scrolls[scroll_id].flags & HSCROLLBAR_VISIBLE)
|
if (scroll.flags & HSCROLLBAR_VISIBLE)
|
||||||
y -= SCROLLBAR_WIDTH + 1;
|
y -= SCROLLBAR_WIDTH + 1;
|
||||||
y *= -1;
|
y *= -1;
|
||||||
y += w->scrolls[scroll_id].v_bottom;
|
y += scroll.v_bottom;
|
||||||
if (y < 0)
|
if (y < 0)
|
||||||
y = 0;
|
y = 0;
|
||||||
if (newTop > y)
|
if (newTop > y)
|
||||||
newTop = y;
|
newTop = y;
|
||||||
w->scrolls[scroll_id].v_top = newTop;
|
scroll.v_top = newTop;
|
||||||
WidgetScrollUpdateThumbs(w, widgetIndex);
|
WidgetScrollUpdateThumbs(w, widgetIndex);
|
||||||
widget_invalidate_by_number(w->classification, w->number, widgetIndex);
|
widget_invalidate_by_number(w->classification, w->number, widgetIndex);
|
||||||
}
|
}
|
||||||
@@ -823,9 +825,10 @@ static void InputScrollPartUpdateHLeft(rct_window* w, rct_widgetindex widgetInde
|
|||||||
assert(w != nullptr);
|
assert(w != nullptr);
|
||||||
if (window_find_by_number(w->classification, w->number) != nullptr)
|
if (window_find_by_number(w->classification, w->number) != nullptr)
|
||||||
{
|
{
|
||||||
w->scrolls[scroll_id].flags |= HSCROLLBAR_LEFT_PRESSED;
|
auto& scroll = w->scrolls[scroll_id];
|
||||||
if (w->scrolls[scroll_id].h_left >= 3)
|
scroll.flags |= HSCROLLBAR_LEFT_PRESSED;
|
||||||
w->scrolls[scroll_id].h_left -= 3;
|
if (scroll.h_left >= 3)
|
||||||
|
scroll.h_left -= 3;
|
||||||
WidgetScrollUpdateThumbs(w, widgetIndex);
|
WidgetScrollUpdateThumbs(w, widgetIndex);
|
||||||
widget_invalidate_by_number(w->classification, w->number, widgetIndex);
|
widget_invalidate_by_number(w->classification, w->number, widgetIndex);
|
||||||
}
|
}
|
||||||
@@ -841,17 +844,18 @@ static void InputScrollPartUpdateHRight(rct_window* w, rct_widgetindex widgetInd
|
|||||||
const auto& widget = w->widgets[widgetIndex];
|
const auto& widget = w->widgets[widgetIndex];
|
||||||
if (window_find_by_number(w->classification, w->number) != nullptr)
|
if (window_find_by_number(w->classification, w->number) != nullptr)
|
||||||
{
|
{
|
||||||
w->scrolls[scroll_id].flags |= HSCROLLBAR_RIGHT_PRESSED;
|
auto& scroll = w->scrolls[scroll_id];
|
||||||
w->scrolls[scroll_id].h_left += 3;
|
scroll.flags |= HSCROLLBAR_RIGHT_PRESSED;
|
||||||
|
scroll.h_left += 3;
|
||||||
int32_t newLeft = widget.width() - 1;
|
int32_t newLeft = widget.width() - 1;
|
||||||
if (w->scrolls[scroll_id].flags & VSCROLLBAR_VISIBLE)
|
if (scroll.flags & VSCROLLBAR_VISIBLE)
|
||||||
newLeft -= SCROLLBAR_WIDTH + 1;
|
newLeft -= SCROLLBAR_WIDTH + 1;
|
||||||
newLeft *= -1;
|
newLeft *= -1;
|
||||||
newLeft += w->scrolls[scroll_id].h_right;
|
newLeft += scroll.h_right;
|
||||||
if (newLeft < 0)
|
if (newLeft < 0)
|
||||||
newLeft = 0;
|
newLeft = 0;
|
||||||
if (w->scrolls[scroll_id].h_left > newLeft)
|
if (scroll.h_left > newLeft)
|
||||||
w->scrolls[scroll_id].h_left = newLeft;
|
scroll.h_left = newLeft;
|
||||||
WidgetScrollUpdateThumbs(w, widgetIndex);
|
WidgetScrollUpdateThumbs(w, widgetIndex);
|
||||||
widget_invalidate_by_number(w->classification, w->number, widgetIndex);
|
widget_invalidate_by_number(w->classification, w->number, widgetIndex);
|
||||||
}
|
}
|
||||||
@@ -866,9 +870,10 @@ static void InputScrollPartUpdateVTop(rct_window* w, rct_widgetindex widgetIndex
|
|||||||
assert(w != nullptr);
|
assert(w != nullptr);
|
||||||
if (window_find_by_number(w->classification, w->number) != nullptr)
|
if (window_find_by_number(w->classification, w->number) != nullptr)
|
||||||
{
|
{
|
||||||
w->scrolls[scroll_id].flags |= VSCROLLBAR_UP_PRESSED;
|
auto& scroll = w->scrolls[scroll_id];
|
||||||
if (w->scrolls[scroll_id].v_top >= 3)
|
scroll.flags |= VSCROLLBAR_UP_PRESSED;
|
||||||
w->scrolls[scroll_id].v_top -= 3;
|
if (scroll.v_top >= 3)
|
||||||
|
scroll.v_top -= 3;
|
||||||
WidgetScrollUpdateThumbs(w, widgetIndex);
|
WidgetScrollUpdateThumbs(w, widgetIndex);
|
||||||
widget_invalidate_by_number(w->classification, w->number, widgetIndex);
|
widget_invalidate_by_number(w->classification, w->number, widgetIndex);
|
||||||
}
|
}
|
||||||
@@ -884,17 +889,18 @@ static void InputScrollPartUpdateVBottom(rct_window* w, rct_widgetindex widgetIn
|
|||||||
const auto& widget = w->widgets[widgetIndex];
|
const auto& widget = w->widgets[widgetIndex];
|
||||||
if (window_find_by_number(w->classification, w->number) != nullptr)
|
if (window_find_by_number(w->classification, w->number) != nullptr)
|
||||||
{
|
{
|
||||||
w->scrolls[scroll_id].flags |= VSCROLLBAR_DOWN_PRESSED;
|
auto& scroll = w->scrolls[scroll_id];
|
||||||
w->scrolls[scroll_id].v_top += 3;
|
scroll.flags |= VSCROLLBAR_DOWN_PRESSED;
|
||||||
|
scroll.v_top += 3;
|
||||||
int32_t newTop = widget.height() - 1;
|
int32_t newTop = widget.height() - 1;
|
||||||
if (w->scrolls[scroll_id].flags & HSCROLLBAR_VISIBLE)
|
if (scroll.flags & HSCROLLBAR_VISIBLE)
|
||||||
newTop -= SCROLLBAR_WIDTH + 1;
|
newTop -= SCROLLBAR_WIDTH + 1;
|
||||||
newTop *= -1;
|
newTop *= -1;
|
||||||
newTop += w->scrolls[scroll_id].v_bottom;
|
newTop += scroll.v_bottom;
|
||||||
if (newTop < 0)
|
if (newTop < 0)
|
||||||
newTop = 0;
|
newTop = 0;
|
||||||
if (w->scrolls[scroll_id].v_top > newTop)
|
if (scroll.v_top > newTop)
|
||||||
w->scrolls[scroll_id].v_top = newTop;
|
scroll.v_top = newTop;
|
||||||
WidgetScrollUpdateThumbs(w, widgetIndex);
|
WidgetScrollUpdateThumbs(w, widgetIndex);
|
||||||
widget_invalidate_by_number(w->classification, w->number, widgetIndex);
|
widget_invalidate_by_number(w->classification, w->number, widgetIndex);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,9 +36,9 @@ static void WidgetCheckboxDraw(rct_drawpixelinfo* dpi, rct_window* w, rct_widget
|
|||||||
static void WidgetCloseboxDraw(rct_drawpixelinfo* dpi, rct_window* w, rct_widgetindex widgetIndex);
|
static void WidgetCloseboxDraw(rct_drawpixelinfo* dpi, rct_window* w, rct_widgetindex widgetIndex);
|
||||||
static void WidgetScrollDraw(rct_drawpixelinfo* dpi, rct_window* w, rct_widgetindex widgetIndex);
|
static void WidgetScrollDraw(rct_drawpixelinfo* dpi, rct_window* w, rct_widgetindex widgetIndex);
|
||||||
static void WidgetHScrollbarDraw(
|
static void WidgetHScrollbarDraw(
|
||||||
rct_drawpixelinfo* dpi, rct_scroll* scroll, int32_t l, int32_t t, int32_t r, int32_t b, int32_t colour);
|
rct_drawpixelinfo* dpi, const rct_scroll& scroll, int32_t l, int32_t t, int32_t r, int32_t b, int32_t colour);
|
||||||
static void WidgetVScrollbarDraw(
|
static void WidgetVScrollbarDraw(
|
||||||
rct_drawpixelinfo* dpi, rct_scroll* scroll, int32_t l, int32_t t, int32_t r, int32_t b, int32_t colour);
|
rct_drawpixelinfo* dpi, const rct_scroll& scroll, int32_t l, int32_t t, int32_t r, int32_t b, int32_t colour);
|
||||||
static void WidgetDrawImage(rct_drawpixelinfo* dpi, rct_window* w, rct_widgetindex widgetIndex);
|
static void WidgetDrawImage(rct_drawpixelinfo* dpi, rct_window* w, rct_widgetindex widgetIndex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -652,7 +652,7 @@ static void WidgetScrollDraw(rct_drawpixelinfo* dpi, rct_window* w, rct_widgetin
|
|||||||
// Get the widget
|
// Get the widget
|
||||||
int32_t scrollIndex = window_get_scroll_data_index(w, widgetIndex);
|
int32_t scrollIndex = window_get_scroll_data_index(w, widgetIndex);
|
||||||
const auto& widget = w->widgets[widgetIndex];
|
const auto& widget = w->widgets[widgetIndex];
|
||||||
rct_scroll* scroll = &w->scrolls[scrollIndex];
|
const auto& scroll = w->scrolls[scrollIndex];
|
||||||
|
|
||||||
// Resolve the absolute ltrb
|
// Resolve the absolute ltrb
|
||||||
ScreenCoordsXY topLeft = w->windowPos + ScreenCoordsXY{ widget.left, widget.top };
|
ScreenCoordsXY topLeft = w->windowPos + ScreenCoordsXY{ widget.left, widget.top };
|
||||||
@@ -671,22 +671,22 @@ static void WidgetScrollDraw(rct_drawpixelinfo* dpi, rct_window* w, rct_widgetin
|
|||||||
bottomRight.y--;
|
bottomRight.y--;
|
||||||
|
|
||||||
// Horizontal scrollbar
|
// Horizontal scrollbar
|
||||||
if (scroll->flags & HSCROLLBAR_VISIBLE)
|
if (scroll.flags & HSCROLLBAR_VISIBLE)
|
||||||
WidgetHScrollbarDraw(
|
WidgetHScrollbarDraw(
|
||||||
dpi, scroll, topLeft.x, bottomRight.y - SCROLLBAR_WIDTH,
|
dpi, scroll, topLeft.x, bottomRight.y - SCROLLBAR_WIDTH,
|
||||||
((scroll->flags & VSCROLLBAR_VISIBLE) ? bottomRight.x - (SCROLLBAR_WIDTH + 1) : bottomRight.x), bottomRight.y,
|
((scroll.flags & VSCROLLBAR_VISIBLE) ? bottomRight.x - (SCROLLBAR_WIDTH + 1) : bottomRight.x), bottomRight.y,
|
||||||
colour);
|
colour);
|
||||||
|
|
||||||
// Vertical scrollbar
|
// Vertical scrollbar
|
||||||
if (scroll->flags & VSCROLLBAR_VISIBLE)
|
if (scroll.flags & VSCROLLBAR_VISIBLE)
|
||||||
WidgetVScrollbarDraw(
|
WidgetVScrollbarDraw(
|
||||||
dpi, scroll, bottomRight.x - SCROLLBAR_WIDTH, topLeft.y, bottomRight.x,
|
dpi, scroll, bottomRight.x - SCROLLBAR_WIDTH, topLeft.y, bottomRight.x,
|
||||||
((scroll->flags & HSCROLLBAR_VISIBLE) ? bottomRight.y - (SCROLLBAR_WIDTH + 1) : bottomRight.y), colour);
|
((scroll.flags & HSCROLLBAR_VISIBLE) ? bottomRight.y - (SCROLLBAR_WIDTH + 1) : bottomRight.y), colour);
|
||||||
|
|
||||||
// Contents
|
// Contents
|
||||||
if (scroll->flags & HSCROLLBAR_VISIBLE)
|
if (scroll.flags & HSCROLLBAR_VISIBLE)
|
||||||
bottomRight.y -= (SCROLLBAR_WIDTH + 1);
|
bottomRight.y -= (SCROLLBAR_WIDTH + 1);
|
||||||
if (scroll->flags & VSCROLLBAR_VISIBLE)
|
if (scroll.flags & VSCROLLBAR_VISIBLE)
|
||||||
bottomRight.x -= (SCROLLBAR_WIDTH + 1);
|
bottomRight.x -= (SCROLLBAR_WIDTH + 1);
|
||||||
|
|
||||||
bottomRight.y++;
|
bottomRight.y++;
|
||||||
@@ -702,8 +702,8 @@ static void WidgetScrollDraw(rct_drawpixelinfo* dpi, rct_window* w, rct_widgetin
|
|||||||
int32_t cb = std::min<int32_t>(dpi->y + dpi->height, bottomRight.y);
|
int32_t cb = std::min<int32_t>(dpi->y + dpi->height, bottomRight.y);
|
||||||
|
|
||||||
// Set the respective dpi attributes
|
// Set the respective dpi attributes
|
||||||
scroll_dpi.x = cl - topLeft.x + scroll->h_left;
|
scroll_dpi.x = cl - topLeft.x + scroll.h_left;
|
||||||
scroll_dpi.y = ct - topLeft.y + scroll->v_top;
|
scroll_dpi.y = ct - topLeft.y + scroll.v_top;
|
||||||
scroll_dpi.width = cr - cl;
|
scroll_dpi.width = cr - cl;
|
||||||
scroll_dpi.height = cb - ct;
|
scroll_dpi.height = cb - ct;
|
||||||
scroll_dpi.bits += cl - dpi->x;
|
scroll_dpi.bits += cl - dpi->x;
|
||||||
@@ -716,7 +716,7 @@ static void WidgetScrollDraw(rct_drawpixelinfo* dpi, rct_window* w, rct_widgetin
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void WidgetHScrollbarDraw(
|
static void WidgetHScrollbarDraw(
|
||||||
rct_drawpixelinfo* dpi, rct_scroll* scroll, int32_t l, int32_t t, int32_t r, int32_t b, int32_t colour)
|
rct_drawpixelinfo* dpi, const rct_scroll& scroll, int32_t l, int32_t t, int32_t r, int32_t b, int32_t colour)
|
||||||
{
|
{
|
||||||
colour &= 0x7F;
|
colour &= 0x7F;
|
||||||
// Trough
|
// Trough
|
||||||
@@ -729,7 +729,7 @@ static void WidgetHScrollbarDraw(
|
|||||||
|
|
||||||
// Left button
|
// Left button
|
||||||
{
|
{
|
||||||
uint8_t flags = (scroll->flags & HSCROLLBAR_LEFT_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0;
|
uint8_t flags = (scroll.flags & HSCROLLBAR_LEFT_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0;
|
||||||
|
|
||||||
gfx_fill_rect_inset(dpi, { { l, t }, { l + (SCROLLBAR_WIDTH - 1), b } }, colour, flags);
|
gfx_fill_rect_inset(dpi, { { l, t }, { l + (SCROLLBAR_WIDTH - 1), b } }, colour, flags);
|
||||||
gfx_draw_string(dpi, { l + 1, t }, static_cast<const char*>(BlackLeftArrowString), {});
|
gfx_draw_string(dpi, { l + 1, t }, static_cast<const char*>(BlackLeftArrowString), {});
|
||||||
@@ -737,16 +737,16 @@ static void WidgetHScrollbarDraw(
|
|||||||
|
|
||||||
// Thumb
|
// Thumb
|
||||||
{
|
{
|
||||||
int16_t left = std::max(l + SCROLLBAR_WIDTH, l + scroll->h_thumb_left - 1);
|
int16_t left = std::max(l + SCROLLBAR_WIDTH, l + scroll.h_thumb_left - 1);
|
||||||
int16_t right = std::min(r - SCROLLBAR_WIDTH, l + scroll->h_thumb_right - 1);
|
int16_t right = std::min(r - SCROLLBAR_WIDTH, l + scroll.h_thumb_right - 1);
|
||||||
uint8_t flags = (scroll->flags & HSCROLLBAR_THUMB_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0;
|
uint8_t flags = (scroll.flags & HSCROLLBAR_THUMB_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0;
|
||||||
|
|
||||||
gfx_fill_rect_inset(dpi, { { left, t }, { right, b } }, colour, flags);
|
gfx_fill_rect_inset(dpi, { { left, t }, { right, b } }, colour, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Right button
|
// Right button
|
||||||
{
|
{
|
||||||
uint8_t flags = (scroll->flags & HSCROLLBAR_RIGHT_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0;
|
uint8_t flags = (scroll.flags & HSCROLLBAR_RIGHT_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0;
|
||||||
|
|
||||||
gfx_fill_rect_inset(dpi, { { r - (SCROLLBAR_WIDTH - 1), t }, { r, b } }, colour, flags);
|
gfx_fill_rect_inset(dpi, { { r - (SCROLLBAR_WIDTH - 1), t }, { r, b } }, colour, flags);
|
||||||
gfx_draw_string(dpi, { r - 6, t }, static_cast<const char*>(BlackRightArrowString), {});
|
gfx_draw_string(dpi, { r - 6, t }, static_cast<const char*>(BlackRightArrowString), {});
|
||||||
@@ -754,7 +754,7 @@ static void WidgetHScrollbarDraw(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void WidgetVScrollbarDraw(
|
static void WidgetVScrollbarDraw(
|
||||||
rct_drawpixelinfo* dpi, rct_scroll* scroll, int32_t l, int32_t t, int32_t r, int32_t b, int32_t colour)
|
rct_drawpixelinfo* dpi, const rct_scroll& scroll, int32_t l, int32_t t, int32_t r, int32_t b, int32_t colour)
|
||||||
{
|
{
|
||||||
colour &= 0x7F;
|
colour &= 0x7F;
|
||||||
// Trough
|
// Trough
|
||||||
@@ -768,20 +768,20 @@ static void WidgetVScrollbarDraw(
|
|||||||
// Up button
|
// Up button
|
||||||
gfx_fill_rect_inset(
|
gfx_fill_rect_inset(
|
||||||
dpi, { { l, t }, { r, t + (SCROLLBAR_WIDTH - 1) } }, colour,
|
dpi, { { l, t }, { r, t + (SCROLLBAR_WIDTH - 1) } }, colour,
|
||||||
((scroll->flags & VSCROLLBAR_UP_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0));
|
((scroll.flags & VSCROLLBAR_UP_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0));
|
||||||
gfx_draw_string(dpi, { l + 1, t - 1 }, static_cast<const char*>(BlackUpArrowString), {});
|
gfx_draw_string(dpi, { l + 1, t - 1 }, static_cast<const char*>(BlackUpArrowString), {});
|
||||||
|
|
||||||
// Thumb
|
// Thumb
|
||||||
gfx_fill_rect_inset(
|
gfx_fill_rect_inset(
|
||||||
dpi,
|
dpi,
|
||||||
{ { l, std::max(t + SCROLLBAR_WIDTH, t + scroll->v_thumb_top - 1) },
|
{ { l, std::max(t + SCROLLBAR_WIDTH, t + scroll.v_thumb_top - 1) },
|
||||||
{ r, std::min(b - SCROLLBAR_WIDTH, t + scroll->v_thumb_bottom - 1) } },
|
{ r, std::min(b - SCROLLBAR_WIDTH, t + scroll.v_thumb_bottom - 1) } },
|
||||||
colour, ((scroll->flags & VSCROLLBAR_THUMB_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0));
|
colour, ((scroll.flags & VSCROLLBAR_THUMB_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0));
|
||||||
|
|
||||||
// Down button
|
// Down button
|
||||||
gfx_fill_rect_inset(
|
gfx_fill_rect_inset(
|
||||||
dpi, { { l, b - (SCROLLBAR_WIDTH - 1) }, { r, b } }, colour,
|
dpi, { { l, b - (SCROLLBAR_WIDTH - 1) }, { r, b } }, colour,
|
||||||
((scroll->flags & VSCROLLBAR_DOWN_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0));
|
((scroll.flags & VSCROLLBAR_DOWN_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0));
|
||||||
gfx_draw_string(dpi, { l + 1, b - (SCROLLBAR_WIDTH - 1) }, static_cast<const char*>(BlackDownArrowString), {});
|
gfx_draw_string(dpi, { l + 1, b - (SCROLLBAR_WIDTH - 1) }, static_cast<const char*>(BlackDownArrowString), {});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -929,14 +929,14 @@ void WidgetScrollGetPart(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((w->scrolls[*scroll_id].flags & HSCROLLBAR_VISIBLE)
|
const auto& scroll = w->scrolls[*scroll_id];
|
||||||
&& screenCoords.y >= (w->windowPos.y + widget->bottom - (SCROLLBAR_WIDTH + 1)))
|
if ((scroll.flags & HSCROLLBAR_VISIBLE) && screenCoords.y >= (w->windowPos.y + widget->bottom - (SCROLLBAR_WIDTH + 1)))
|
||||||
{
|
{
|
||||||
// horizontal scrollbar
|
// horizontal scrollbar
|
||||||
int32_t rightOffset = 0;
|
int32_t rightOffset = 0;
|
||||||
int32_t iteratorLeft = widget->left + w->windowPos.x + SCROLLBAR_WIDTH;
|
int32_t iteratorLeft = widget->left + w->windowPos.x + SCROLLBAR_WIDTH;
|
||||||
int32_t iteratorRight = widget->right + w->windowPos.x - SCROLLBAR_WIDTH;
|
int32_t iteratorRight = widget->right + w->windowPos.x - SCROLLBAR_WIDTH;
|
||||||
if (!(w->scrolls[*scroll_id].flags & VSCROLLBAR_VISIBLE))
|
if (!(scroll.flags & VSCROLLBAR_VISIBLE))
|
||||||
{
|
{
|
||||||
rightOffset = SCROLLBAR_WIDTH + 1;
|
rightOffset = SCROLLBAR_WIDTH + 1;
|
||||||
}
|
}
|
||||||
@@ -953,11 +953,11 @@ void WidgetScrollGetPart(
|
|||||||
{
|
{
|
||||||
*output_scroll_area = SCROLL_PART_HSCROLLBAR_RIGHT;
|
*output_scroll_area = SCROLL_PART_HSCROLLBAR_RIGHT;
|
||||||
}
|
}
|
||||||
else if (screenCoords.x < (widget->left + w->windowPos.x + w->scrolls[*scroll_id].h_thumb_left))
|
else if (screenCoords.x < (widget->left + w->windowPos.x + scroll.h_thumb_left))
|
||||||
{
|
{
|
||||||
*output_scroll_area = SCROLL_PART_HSCROLLBAR_LEFT_TROUGH;
|
*output_scroll_area = SCROLL_PART_HSCROLLBAR_LEFT_TROUGH;
|
||||||
}
|
}
|
||||||
else if (screenCoords.x > (widget->left + w->windowPos.x + w->scrolls[*scroll_id].h_thumb_right))
|
else if (screenCoords.x > (widget->left + w->windowPos.x + scroll.h_thumb_right))
|
||||||
{
|
{
|
||||||
*output_scroll_area = SCROLL_PART_HSCROLLBAR_RIGHT_TROUGH;
|
*output_scroll_area = SCROLL_PART_HSCROLLBAR_RIGHT_TROUGH;
|
||||||
}
|
}
|
||||||
@@ -966,15 +966,13 @@ void WidgetScrollGetPart(
|
|||||||
*output_scroll_area = SCROLL_PART_HSCROLLBAR_THUMB;
|
*output_scroll_area = SCROLL_PART_HSCROLLBAR_THUMB;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (
|
else if ((scroll.flags & VSCROLLBAR_VISIBLE) && (screenCoords.x >= w->windowPos.x + widget->right - (SCROLLBAR_WIDTH + 1)))
|
||||||
(w->scrolls[*scroll_id].flags & VSCROLLBAR_VISIBLE)
|
|
||||||
&& (screenCoords.x >= w->windowPos.x + widget->right - (SCROLLBAR_WIDTH + 1)))
|
|
||||||
{
|
{
|
||||||
// vertical scrollbar
|
// vertical scrollbar
|
||||||
int32_t bottomOffset = 0;
|
int32_t bottomOffset = 0;
|
||||||
int32_t iteratorTop = widget->top + w->windowPos.y + SCROLLBAR_WIDTH;
|
int32_t iteratorTop = widget->top + w->windowPos.y + SCROLLBAR_WIDTH;
|
||||||
int32_t iteratorBottom = widget->bottom + w->windowPos.y;
|
int32_t iteratorBottom = widget->bottom + w->windowPos.y;
|
||||||
if (w->scrolls[*scroll_id].flags & HSCROLLBAR_VISIBLE)
|
if (scroll.flags & HSCROLLBAR_VISIBLE)
|
||||||
{
|
{
|
||||||
bottomOffset = (SCROLLBAR_WIDTH + 1);
|
bottomOffset = (SCROLLBAR_WIDTH + 1);
|
||||||
}
|
}
|
||||||
@@ -991,11 +989,11 @@ void WidgetScrollGetPart(
|
|||||||
{
|
{
|
||||||
*output_scroll_area = SCROLL_PART_VSCROLLBAR_BOTTOM;
|
*output_scroll_area = SCROLL_PART_VSCROLLBAR_BOTTOM;
|
||||||
}
|
}
|
||||||
else if (screenCoords.y < (widget->top + w->windowPos.y + w->scrolls[*scroll_id].v_thumb_top))
|
else if (screenCoords.y < (widget->top + w->windowPos.y + scroll.v_thumb_top))
|
||||||
{
|
{
|
||||||
*output_scroll_area = SCROLL_PART_VSCROLLBAR_TOP_TROUGH;
|
*output_scroll_area = SCROLL_PART_VSCROLLBAR_TOP_TROUGH;
|
||||||
}
|
}
|
||||||
else if (screenCoords.y > (widget->top + w->windowPos.y + w->scrolls[*scroll_id].v_thumb_bottom))
|
else if (screenCoords.y > (widget->top + w->windowPos.y + scroll.v_thumb_bottom))
|
||||||
{
|
{
|
||||||
*output_scroll_area = SCROLL_PART_VSCROLLBAR_BOTTOM_TROUGH;
|
*output_scroll_area = SCROLL_PART_VSCROLLBAR_BOTTOM_TROUGH;
|
||||||
}
|
}
|
||||||
@@ -1017,8 +1015,8 @@ void WidgetScrollGetPart(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
retScreenCoords.x += w->scrolls[*scroll_id].h_left - 1;
|
retScreenCoords.x += scroll.h_left - 1;
|
||||||
retScreenCoords.y += w->scrolls[*scroll_id].v_top - 1;
|
retScreenCoords.y += scroll.v_top - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -356,25 +356,25 @@ static rct_widget* WindowGetScrollWidget(rct_window* w, int32_t scrollIndex)
|
|||||||
*/
|
*/
|
||||||
static void WindowScrollWheelInput(rct_window* w, int32_t scrollIndex, int32_t wheel)
|
static void WindowScrollWheelInput(rct_window* w, int32_t scrollIndex, int32_t wheel)
|
||||||
{
|
{
|
||||||
rct_scroll* scroll = &w->scrolls[scrollIndex];
|
auto& scroll = w->scrolls[scrollIndex];
|
||||||
rct_widget* widget = WindowGetScrollWidget(w, scrollIndex);
|
rct_widget* widget = WindowGetScrollWidget(w, scrollIndex);
|
||||||
rct_widgetindex widgetIndex = WindowGetWidgetIndex(w, widget);
|
rct_widgetindex widgetIndex = WindowGetWidgetIndex(w, widget);
|
||||||
|
|
||||||
if (scroll->flags & VSCROLLBAR_VISIBLE)
|
if (scroll.flags & VSCROLLBAR_VISIBLE)
|
||||||
{
|
{
|
||||||
int32_t size = widget->height() - 1;
|
int32_t size = widget->height() - 1;
|
||||||
if (scroll->flags & HSCROLLBAR_VISIBLE)
|
if (scroll.flags & HSCROLLBAR_VISIBLE)
|
||||||
size -= 11;
|
size -= 11;
|
||||||
size = std::max(0, scroll->v_bottom - size);
|
size = std::max(0, scroll.v_bottom - size);
|
||||||
scroll->v_top = std::min(std::max(0, scroll->v_top + wheel), size);
|
scroll.v_top = std::min(std::max(0, scroll.v_top + wheel), size);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int32_t size = widget->width() - 1;
|
int32_t size = widget->width() - 1;
|
||||||
if (scroll->flags & VSCROLLBAR_VISIBLE)
|
if (scroll.flags & VSCROLLBAR_VISIBLE)
|
||||||
size -= 11;
|
size -= 11;
|
||||||
size = std::max(0, scroll->h_right - size);
|
size = std::max(0, scroll.h_right - size);
|
||||||
scroll->h_left = std::min(std::max(0, scroll->h_left + wheel), size);
|
scroll.h_left = std::min(std::max(0, scroll.h_left + wheel), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
WidgetScrollUpdateThumbs(w, widgetIndex);
|
WidgetScrollUpdateThumbs(w, widgetIndex);
|
||||||
@@ -394,8 +394,8 @@ static int32_t WindowWheelInput(rct_window* w, int32_t wheel)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Originally always checked first scroll view, bug maybe?
|
// Originally always checked first scroll view, bug maybe?
|
||||||
rct_scroll* scroll = &w->scrolls[i];
|
const auto& scroll = w->scrolls[i];
|
||||||
if (scroll->flags & (HSCROLLBAR_VISIBLE | VSCROLLBAR_VISIBLE))
|
if (scroll.flags & (HSCROLLBAR_VISIBLE | VSCROLLBAR_VISIBLE))
|
||||||
{
|
{
|
||||||
WindowScrollWheelInput(w, i, wheel);
|
WindowScrollWheelInput(w, i, wheel);
|
||||||
return 1;
|
return 1;
|
||||||
@@ -542,8 +542,8 @@ void WindowAllWheelInput()
|
|||||||
if (widget.type == WindowWidgetType::Scroll)
|
if (widget.type == WindowWidgetType::Scroll)
|
||||||
{
|
{
|
||||||
int32_t scrollIndex = WindowGetScrollIndex(w, widgetIndex);
|
int32_t scrollIndex = WindowGetScrollIndex(w, widgetIndex);
|
||||||
rct_scroll* scroll = &w->scrolls[scrollIndex];
|
const auto& scroll = w->scrolls[scrollIndex];
|
||||||
if (scroll->flags & (HSCROLLBAR_VISIBLE | VSCROLLBAR_VISIBLE))
|
if (scroll.flags & (HSCROLLBAR_VISIBLE | VSCROLLBAR_VISIBLE))
|
||||||
{
|
{
|
||||||
WindowScrollWheelInput(w, WindowGetScrollIndex(w, widgetIndex), pixel_scroll);
|
WindowScrollWheelInput(w, WindowGetScrollIndex(w, widgetIndex), pixel_scroll);
|
||||||
return;
|
return;
|
||||||
@@ -577,7 +577,6 @@ void ApplyScreenSaverLockSetting()
|
|||||||
void WindowInitScrollWidgets(rct_window* w)
|
void WindowInitScrollWidgets(rct_window* w)
|
||||||
{
|
{
|
||||||
rct_widget* widget;
|
rct_widget* widget;
|
||||||
rct_scroll* scroll;
|
|
||||||
int32_t widget_index, scroll_index;
|
int32_t widget_index, scroll_index;
|
||||||
int32_t width, height;
|
int32_t width, height;
|
||||||
|
|
||||||
@@ -591,20 +590,20 @@ void WindowInitScrollWidgets(rct_window* w)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
scroll = &w->scrolls[scroll_index];
|
auto& scroll = w->scrolls[scroll_index];
|
||||||
scroll->flags = 0;
|
scroll.flags = 0;
|
||||||
width = 0;
|
width = 0;
|
||||||
height = 0;
|
height = 0;
|
||||||
window_get_scroll_size(w, scroll_index, &width, &height);
|
window_get_scroll_size(w, scroll_index, &width, &height);
|
||||||
scroll->h_left = 0;
|
scroll.h_left = 0;
|
||||||
scroll->h_right = width + 1;
|
scroll.h_right = width + 1;
|
||||||
scroll->v_top = 0;
|
scroll.v_top = 0;
|
||||||
scroll->v_bottom = height + 1;
|
scroll.v_bottom = height + 1;
|
||||||
|
|
||||||
if (widget->content & SCROLL_HORIZONTAL)
|
if (widget->content & SCROLL_HORIZONTAL)
|
||||||
scroll->flags |= HSCROLLBAR_VISIBLE;
|
scroll.flags |= HSCROLLBAR_VISIBLE;
|
||||||
if (widget->content & SCROLL_VERTICAL)
|
if (widget->content & SCROLL_VERTICAL)
|
||||||
scroll->flags |= VSCROLLBAR_VISIBLE;
|
scroll.flags |= VSCROLLBAR_VISIBLE;
|
||||||
|
|
||||||
WidgetScrollUpdateThumbs(w, widget_index);
|
WidgetScrollUpdateThumbs(w, widget_index);
|
||||||
|
|
||||||
|
|||||||
@@ -1474,10 +1474,10 @@ static void window_options_audio_dropdown(rct_window* w, rct_widgetindex widgetI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t get_scroll_percentage(rct_widget* widget, rct_scroll* scroll)
|
static uint8_t get_scroll_percentage(const rct_widget& widget, const rct_scroll& scroll)
|
||||||
{
|
{
|
||||||
uint8_t width = widget->width() - 1;
|
uint8_t width = widget.width() - 1;
|
||||||
return static_cast<float>(scroll->h_left) / (scroll->h_right - width) * 100;
|
return static_cast<float>(scroll.h_left) / (scroll.h_right - width) * 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void window_options_audio_update(rct_window* w)
|
static void window_options_audio_update(rct_window* w)
|
||||||
@@ -1486,10 +1486,9 @@ static void window_options_audio_update(rct_window* w)
|
|||||||
|
|
||||||
if (w->page == WINDOW_OPTIONS_PAGE_AUDIO)
|
if (w->page == WINDOW_OPTIONS_PAGE_AUDIO)
|
||||||
{
|
{
|
||||||
rct_widget* widget;
|
const auto& masterVolumeWidget = window_options_audio_widgets[WIDX_MASTER_VOLUME];
|
||||||
|
const auto& masterVolumeScroll = w->scrolls[0];
|
||||||
widget = &window_options_audio_widgets[WIDX_MASTER_VOLUME];
|
uint8_t master_volume = get_scroll_percentage(masterVolumeWidget, masterVolumeScroll);
|
||||||
uint8_t master_volume = get_scroll_percentage(widget, &w->scrolls[0]);
|
|
||||||
if (master_volume != gConfigSound.master_volume)
|
if (master_volume != gConfigSound.master_volume)
|
||||||
{
|
{
|
||||||
gConfigSound.master_volume = master_volume;
|
gConfigSound.master_volume = master_volume;
|
||||||
@@ -1497,8 +1496,9 @@ static void window_options_audio_update(rct_window* w)
|
|||||||
widget_invalidate(w, WIDX_MASTER_VOLUME);
|
widget_invalidate(w, WIDX_MASTER_VOLUME);
|
||||||
}
|
}
|
||||||
|
|
||||||
widget = &window_options_audio_widgets[WIDX_SOUND_VOLUME];
|
const auto& soundVolumeWidget = window_options_audio_widgets[WIDX_MASTER_VOLUME];
|
||||||
uint8_t sound_volume = get_scroll_percentage(widget, &w->scrolls[1]);
|
const auto& soundVolumeScroll = w->scrolls[1];
|
||||||
|
uint8_t sound_volume = get_scroll_percentage(soundVolumeWidget, soundVolumeScroll);
|
||||||
if (sound_volume != gConfigSound.sound_volume)
|
if (sound_volume != gConfigSound.sound_volume)
|
||||||
{
|
{
|
||||||
gConfigSound.sound_volume = sound_volume;
|
gConfigSound.sound_volume = sound_volume;
|
||||||
@@ -1506,8 +1506,9 @@ static void window_options_audio_update(rct_window* w)
|
|||||||
widget_invalidate(w, WIDX_SOUND_VOLUME);
|
widget_invalidate(w, WIDX_SOUND_VOLUME);
|
||||||
}
|
}
|
||||||
|
|
||||||
widget = &window_options_audio_widgets[WIDX_MUSIC_VOLUME];
|
const auto& musicVolumeWidget = window_options_audio_widgets[WIDX_MASTER_VOLUME];
|
||||||
uint8_t ride_music_volume = get_scroll_percentage(widget, &w->scrolls[2]);
|
const auto& musicVolumeScroll = w->scrolls[2];
|
||||||
|
uint8_t ride_music_volume = get_scroll_percentage(musicVolumeWidget, musicVolumeScroll);
|
||||||
if (ride_music_volume != gConfigSound.ride_music_volume)
|
if (ride_music_volume != gConfigSound.ride_music_volume)
|
||||||
{
|
{
|
||||||
gConfigSound.ride_music_volume = ride_music_volume;
|
gConfigSound.ride_music_volume = ride_music_volume;
|
||||||
@@ -1524,11 +1525,11 @@ static void window_options_audio_scrollgetsize(rct_window* w, int32_t scrollInde
|
|||||||
|
|
||||||
static void initialize_scroll_position(rct_window* w, rct_widgetindex widget_index, int32_t scroll_id, uint8_t volume)
|
static void initialize_scroll_position(rct_window* w, rct_widgetindex widget_index, int32_t scroll_id, uint8_t volume)
|
||||||
{
|
{
|
||||||
rct_widget* widget = &window_options_audio_widgets[widget_index];
|
const auto& widget = window_options_audio_widgets[widget_index];
|
||||||
rct_scroll* scroll = &w->scrolls[scroll_id];
|
auto& scroll = w->scrolls[scroll_id];
|
||||||
|
|
||||||
int widget_size = scroll->h_right - (widget->width() - 1);
|
int32_t widget_size = scroll.h_right - (widget.width() - 1);
|
||||||
scroll->h_left = ceil(volume / 100.0f * widget_size);
|
scroll.h_left = ceil(volume / 100.0f * widget_size);
|
||||||
|
|
||||||
WidgetScrollUpdateThumbs(w, widget_index);
|
WidgetScrollUpdateThumbs(w, widget_index);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -568,7 +568,6 @@ void window_update_scroll_widgets(rct_window* w)
|
|||||||
{
|
{
|
||||||
int32_t scrollIndex, width, height, scrollPositionChanged;
|
int32_t scrollIndex, width, height, scrollPositionChanged;
|
||||||
rct_widgetindex widgetIndex;
|
rct_widgetindex widgetIndex;
|
||||||
rct_scroll* scroll;
|
|
||||||
rct_widget* widget;
|
rct_widget* widget;
|
||||||
|
|
||||||
widgetIndex = 0;
|
widgetIndex = 0;
|
||||||
@@ -579,32 +578,32 @@ void window_update_scroll_widgets(rct_window* w)
|
|||||||
if (widget->type != WindowWidgetType::Scroll)
|
if (widget->type != WindowWidgetType::Scroll)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
scroll = &w->scrolls[scrollIndex];
|
auto& scroll = w->scrolls[scrollIndex];
|
||||||
width = 0;
|
width = 0;
|
||||||
height = 0;
|
height = 0;
|
||||||
window_get_scroll_size(w, scrollIndex, &width, &height);
|
window_get_scroll_size(w, scrollIndex, &width, &height);
|
||||||
if (height == 0)
|
if (height == 0)
|
||||||
{
|
{
|
||||||
scroll->v_top = 0;
|
scroll.v_top = 0;
|
||||||
}
|
}
|
||||||
else if (width == 0)
|
else if (width == 0)
|
||||||
{
|
{
|
||||||
scroll->h_left = 0;
|
scroll.h_left = 0;
|
||||||
}
|
}
|
||||||
width++;
|
width++;
|
||||||
height++;
|
height++;
|
||||||
|
|
||||||
scrollPositionChanged = 0;
|
scrollPositionChanged = 0;
|
||||||
if ((widget->content & SCROLL_HORIZONTAL) && width != scroll->h_right)
|
if ((widget->content & SCROLL_HORIZONTAL) && width != scroll.h_right)
|
||||||
{
|
{
|
||||||
scrollPositionChanged = 1;
|
scrollPositionChanged = 1;
|
||||||
scroll->h_right = width;
|
scroll.h_right = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((widget->content & SCROLL_VERTICAL) && height != scroll->v_bottom)
|
if ((widget->content & SCROLL_VERTICAL) && height != scroll.v_bottom)
|
||||||
{
|
{
|
||||||
scrollPositionChanged = 1;
|
scrollPositionChanged = 1;
|
||||||
scroll->v_bottom = height;
|
scroll.v_bottom = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scrollPositionChanged)
|
if (scrollPositionChanged)
|
||||||
@@ -1292,8 +1291,9 @@ void window_resize(rct_window* w, int32_t dw, int32_t dh)
|
|||||||
// Update scroll widgets
|
// Update scroll widgets
|
||||||
for (int32_t i = 0; i < 3; i++)
|
for (int32_t i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
w->scrolls[i].h_right = WINDOW_SCROLL_UNDEFINED;
|
auto& scroll = w->scrolls[i];
|
||||||
w->scrolls[i].v_bottom = WINDOW_SCROLL_UNDEFINED;
|
scroll.h_right = WINDOW_SCROLL_UNDEFINED;
|
||||||
|
scroll.v_bottom = WINDOW_SCROLL_UNDEFINED;
|
||||||
}
|
}
|
||||||
window_update_scroll_widgets(w);
|
window_update_scroll_widgets(w);
|
||||||
|
|
||||||
@@ -2183,63 +2183,63 @@ rct_windowclass window_get_classification(rct_window* window)
|
|||||||
void WidgetScrollUpdateThumbs(rct_window* w, rct_widgetindex widget_index)
|
void WidgetScrollUpdateThumbs(rct_window* w, rct_widgetindex widget_index)
|
||||||
{
|
{
|
||||||
const auto& widget = w->widgets[widget_index];
|
const auto& widget = w->widgets[widget_index];
|
||||||
rct_scroll* scroll = &w->scrolls[window_get_scroll_data_index(w, widget_index)];
|
auto& scroll = w->scrolls[window_get_scroll_data_index(w, widget_index)];
|
||||||
|
|
||||||
if (scroll->flags & HSCROLLBAR_VISIBLE)
|
if (scroll.flags & HSCROLLBAR_VISIBLE)
|
||||||
{
|
{
|
||||||
int32_t view_size = widget.width() - 21;
|
int32_t view_size = widget.width() - 21;
|
||||||
if (scroll->flags & VSCROLLBAR_VISIBLE)
|
if (scroll.flags & VSCROLLBAR_VISIBLE)
|
||||||
view_size -= 11;
|
view_size -= 11;
|
||||||
int32_t x = scroll->h_left * view_size;
|
int32_t x = scroll.h_left * view_size;
|
||||||
if (scroll->h_right != 0)
|
if (scroll.h_right != 0)
|
||||||
x /= scroll->h_right;
|
x /= scroll.h_right;
|
||||||
scroll->h_thumb_left = x + 11;
|
scroll.h_thumb_left = x + 11;
|
||||||
|
|
||||||
x = widget.width() - 2;
|
x = widget.width() - 2;
|
||||||
if (scroll->flags & VSCROLLBAR_VISIBLE)
|
if (scroll.flags & VSCROLLBAR_VISIBLE)
|
||||||
x -= 11;
|
x -= 11;
|
||||||
x += scroll->h_left;
|
x += scroll.h_left;
|
||||||
if (scroll->h_right != 0)
|
if (scroll.h_right != 0)
|
||||||
x = (x * view_size) / scroll->h_right;
|
x = (x * view_size) / scroll.h_right;
|
||||||
x += 11;
|
x += 11;
|
||||||
view_size += 10;
|
view_size += 10;
|
||||||
scroll->h_thumb_right = std::min(x, view_size);
|
scroll.h_thumb_right = std::min(x, view_size);
|
||||||
|
|
||||||
if (scroll->h_thumb_right - scroll->h_thumb_left < 20)
|
if (scroll.h_thumb_right - scroll.h_thumb_left < 20)
|
||||||
{
|
{
|
||||||
double barPosition = (scroll->h_thumb_right * 1.0) / view_size;
|
double barPosition = (scroll.h_thumb_right * 1.0) / view_size;
|
||||||
|
|
||||||
scroll->h_thumb_left = static_cast<uint16_t>(std::lround(scroll->h_thumb_left - (20 * barPosition)));
|
scroll.h_thumb_left = static_cast<uint16_t>(std::lround(scroll.h_thumb_left - (20 * barPosition)));
|
||||||
scroll->h_thumb_right = static_cast<uint16_t>(std::lround(scroll->h_thumb_right + (20 * (1 - barPosition))));
|
scroll.h_thumb_right = static_cast<uint16_t>(std::lround(scroll.h_thumb_right + (20 * (1 - barPosition))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scroll->flags & VSCROLLBAR_VISIBLE)
|
if (scroll.flags & VSCROLLBAR_VISIBLE)
|
||||||
{
|
{
|
||||||
int32_t view_size = widget.height() - 21;
|
int32_t view_size = widget.height() - 21;
|
||||||
if (scroll->flags & HSCROLLBAR_VISIBLE)
|
if (scroll.flags & HSCROLLBAR_VISIBLE)
|
||||||
view_size -= 11;
|
view_size -= 11;
|
||||||
int32_t y = scroll->v_top * view_size;
|
int32_t y = scroll.v_top * view_size;
|
||||||
if (scroll->v_bottom != 0)
|
if (scroll.v_bottom != 0)
|
||||||
y /= scroll->v_bottom;
|
y /= scroll.v_bottom;
|
||||||
scroll->v_thumb_top = y + 11;
|
scroll.v_thumb_top = y + 11;
|
||||||
|
|
||||||
y = widget.height() - 2;
|
y = widget.height() - 2;
|
||||||
if (scroll->flags & HSCROLLBAR_VISIBLE)
|
if (scroll.flags & HSCROLLBAR_VISIBLE)
|
||||||
y -= 11;
|
y -= 11;
|
||||||
y += scroll->v_top;
|
y += scroll.v_top;
|
||||||
if (scroll->v_bottom != 0)
|
if (scroll.v_bottom != 0)
|
||||||
y = (y * view_size) / scroll->v_bottom;
|
y = (y * view_size) / scroll.v_bottom;
|
||||||
y += 11;
|
y += 11;
|
||||||
view_size += 10;
|
view_size += 10;
|
||||||
scroll->v_thumb_bottom = std::min(y, view_size);
|
scroll.v_thumb_bottom = std::min(y, view_size);
|
||||||
|
|
||||||
if (scroll->v_thumb_bottom - scroll->v_thumb_top < 20)
|
if (scroll.v_thumb_bottom - scroll.v_thumb_top < 20)
|
||||||
{
|
{
|
||||||
double barPosition = (scroll->v_thumb_bottom * 1.0) / view_size;
|
double barPosition = (scroll.v_thumb_bottom * 1.0) / view_size;
|
||||||
|
|
||||||
scroll->v_thumb_top = static_cast<uint16_t>(std::lround(scroll->v_thumb_top - (20 * barPosition)));
|
scroll.v_thumb_top = static_cast<uint16_t>(std::lround(scroll.v_thumb_top - (20 * barPosition)));
|
||||||
scroll->v_thumb_bottom = static_cast<uint16_t>(std::lround(scroll->v_thumb_bottom + (20 * (1 - barPosition))));
|
scroll.v_thumb_bottom = static_cast<uint16_t>(std::lround(scroll.v_thumb_bottom + (20 * (1 - barPosition))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user