1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-22 23:33:04 +01:00

Prefer const ref to send ScreenCoordsXY over

This commit is contained in:
Tulio Leao
2020-02-28 23:43:29 -03:00
parent 4c2a0f279b
commit 9bcd20e0e6
56 changed files with 429 additions and 414 deletions

View File

@@ -396,7 +396,7 @@ void window_close_all_except_flags(uint16_t flags)
*
* rct2: 0x006EA845
*/
rct_window* window_find_from_point(ScreenCoordsXY screenCoords)
rct_window* window_find_from_point(const ScreenCoordsXY& screenCoords)
{
for (auto it = g_window_list.rbegin(); it != g_window_list.rend(); it++)
{
@@ -426,7 +426,7 @@ rct_window* window_find_from_point(ScreenCoordsXY screenCoords)
* returns widget_index (edx)
* EDI NEEDS TO BE SET TO w->widgets[widget_index] AFTER
*/
rct_widgetindex window_find_widget_from_point(rct_window* w, ScreenCoordsXY screenCoords)
rct_widgetindex window_find_widget_from_point(rct_window* w, const ScreenCoordsXY& screenCoords)
{
// Invalidate the window
window_event_invalidate_call(w);
@@ -1256,12 +1256,12 @@ void window_draw_viewport(rct_drawpixelinfo* dpi, rct_window* w)
viewport_render(dpi, w->viewport, dpi->x, dpi->y, dpi->x + dpi->width, dpi->y + dpi->height);
}
void window_set_position(rct_window* w, ScreenCoordsXY screenCoords)
void window_set_position(rct_window* w, const ScreenCoordsXY& screenCoords)
{
window_move_position(w, ScreenCoordsXY(screenCoords.x - w->x, screenCoords.y - w->y));
}
void window_move_position(rct_window* w, ScreenCoordsXY deltaCoords)
void window_move_position(rct_window* w, const ScreenCoordsXY& deltaCoords)
{
if (deltaCoords.x == 0 && deltaCoords.y == 0)
return;
@@ -1448,25 +1448,25 @@ void window_event_unknown_08_call(rct_window* w)
w->event_handlers->unknown_08(w);
}
void window_event_tool_update_call(rct_window* w, rct_widgetindex widgetIndex, ScreenCoordsXY screenCoords)
void window_event_tool_update_call(rct_window* w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords)
{
if (w->event_handlers->tool_update != nullptr)
w->event_handlers->tool_update(w, widgetIndex, screenCoords);
}
void window_event_tool_down_call(rct_window* w, rct_widgetindex widgetIndex, ScreenCoordsXY screenCoords)
void window_event_tool_down_call(rct_window* w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords)
{
if (w->event_handlers->tool_down != nullptr)
w->event_handlers->tool_down(w, widgetIndex, screenCoords);
}
void window_event_tool_drag_call(rct_window* w, rct_widgetindex widgetIndex, ScreenCoordsXY screenCoords)
void window_event_tool_drag_call(rct_window* w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords)
{
if (w->event_handlers->tool_drag != nullptr)
w->event_handlers->tool_drag(w, widgetIndex, screenCoords);
}
void window_event_tool_up_call(rct_window* w, rct_widgetindex widgetIndex, ScreenCoordsXY screenCoords)
void window_event_tool_up_call(rct_window* w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords)
{
if (w->event_handlers->tool_up != nullptr)
w->event_handlers->tool_up(w, widgetIndex, screenCoords);
@@ -1492,19 +1492,19 @@ void window_get_scroll_size(rct_window* w, int32_t scrollIndex, int32_t* width,
}
}
void window_event_scroll_mousedown_call(rct_window* w, int32_t scrollIndex, ScreenCoordsXY screenCoords)
void window_event_scroll_mousedown_call(rct_window* w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords)
{
if (w->event_handlers->scroll_mousedown != nullptr)
w->event_handlers->scroll_mousedown(w, scrollIndex, screenCoords);
}
void window_event_scroll_mousedrag_call(rct_window* w, int32_t scrollIndex, ScreenCoordsXY screenCoords)
void window_event_scroll_mousedrag_call(rct_window* w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords)
{
if (w->event_handlers->scroll_mousedrag != nullptr)
w->event_handlers->scroll_mousedrag(w, scrollIndex, screenCoords);
}
void window_event_scroll_mouseover_call(rct_window* w, int32_t scrollIndex, ScreenCoordsXY screenCoords)
void window_event_scroll_mouseover_call(rct_window* w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords)
{
if (w->event_handlers->scroll_mouseover != nullptr)
w->event_handlers->scroll_mouseover(w, scrollIndex, screenCoords);
@@ -1536,7 +1536,7 @@ rct_string_id window_event_tooltip_call(rct_window* w, rct_widgetindex widgetInd
return result;
}
int32_t window_event_cursor_call(rct_window* w, rct_widgetindex widgetIndex, ScreenCoordsXY screenCoords)
int32_t window_event_cursor_call(rct_window* w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords)
{
int32_t cursorId = CURSOR_ARROW;
if (w->event_handlers->cursor != nullptr)
@@ -1544,7 +1544,7 @@ int32_t window_event_cursor_call(rct_window* w, rct_widgetindex widgetIndex, Scr
return cursorId;
}
void window_event_moved_call(rct_window* w, ScreenCoordsXY screenCoords)
void window_event_moved_call(rct_window* w, const ScreenCoordsXY& screenCoords)
{
if (w->event_handlers->moved != nullptr)
w->event_handlers->moved(w, screenCoords);
@@ -1876,18 +1876,19 @@ static void window_snap_bottom(rct_window* w, int32_t proximity)
w->y = topMost - w->height;
}
void window_move_and_snap(rct_window* w, ScreenCoordsXY newWindowCoords, int32_t snapProximity)
void window_move_and_snap(rct_window* w, const ScreenCoordsXY& newWindowCoords, int32_t snapProximity)
{
int32_t originalX = w->x;
int32_t originalY = w->y;
int32_t minY = (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) ? 1 : TOP_TOOLBAR_HEIGHT + 2;
newWindowCoords.y = std::clamp(newWindowCoords.y, minY, context_get_height() - 34);
auto destinationCords = newWindowCoords;
destinationCords.y = std::clamp(destinationCords.y, minY, context_get_height() - 34);
if (snapProximity > 0)
{
w->x = newWindowCoords.x;
w->y = newWindowCoords.y;
w->x = destinationCords.x;
w->y = destinationCords.y;
window_snap_right(w, snapProximity);
window_snap_bottom(w, snapProximity);
@@ -1897,13 +1898,13 @@ void window_move_and_snap(rct_window* w, ScreenCoordsXY newWindowCoords, int32_t
if (w->x == originalX && w->y == originalY)
return;
newWindowCoords.x = w->x;
newWindowCoords.y = w->y;
destinationCords.x = w->x;
destinationCords.y = w->y;
w->x = originalX;
w->y = originalY;
}
window_set_position(w, newWindowCoords);
window_set_position(w, destinationCords);
}
int32_t window_can_resize(rct_window* w)