1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-23 15:52:55 +01:00

Add a window method to resize dropdowns

This commit is contained in:
Michael Bernardi
2023-06-26 03:21:54 +02:00
committed by Michael Bernardi
parent 22996b5fe8
commit 29c3f08b69
4 changed files with 24 additions and 2 deletions

View File

@@ -205,6 +205,11 @@ public:
height = min_height;
}
widgets[WIDX_SORT].left = width - 60;
widgets[WIDX_SORT].right = width - 60 + 54;
ResizeDropdown(WIDX_CURRENT_INFORMATION_TYPE, { 150, 46 }, { width - 216, DROPDOWN_HEIGHT });
// Refreshing the list can be a very intensive operation
// owing to its use of ride_has_any_track_elements().
// This makes sure it's only refreshed every 64 ticks.

View File

@@ -2158,7 +2158,7 @@ void WindowBase::ResizeSpinner(WidgetIndex widgetIndex, const ScreenCoordsXY& or
widgets[widgetIndex].right = right;
widgets[widgetIndex].bottom = bottom;
widgets[widgetIndex + 1].left = right - size.height;
widgets[widgetIndex + 1].left = right - size.height; // subtract height to maintain aspect ratio
widgets[widgetIndex + 1].top = origin.y + 1;
widgets[widgetIndex + 1].right = right - 1;
widgets[widgetIndex + 1].bottom = bottom - 1;
@@ -2167,4 +2167,19 @@ void WindowBase::ResizeSpinner(WidgetIndex widgetIndex, const ScreenCoordsXY& or
widgets[widgetIndex + 2].top = origin.y + 1;
widgets[widgetIndex + 2].right = right - size.height - 1;
widgets[widgetIndex + 2].bottom = bottom - 1;
}
}
void WindowBase::ResizeDropdown(WidgetIndex widgetIndex, const ScreenCoordsXY& origin, const ScreenSize& size)
{
auto right = origin.x + size.width - 1;
auto bottom = origin.y + size.height - 1;
widgets[widgetIndex].left = origin.x;
widgets[widgetIndex].top = origin.y;
widgets[widgetIndex].right = right;
widgets[widgetIndex].bottom = bottom;
widgets[widgetIndex + 1].left = right - size.height + 1; // subtract height to maintain aspect ratio
widgets[widgetIndex + 1].top = origin.y + 1;
widgets[widgetIndex + 1].right = right - 1;
widgets[widgetIndex + 1].bottom = bottom - 1;
}

View File

@@ -45,6 +45,7 @@ constexpr uint8_t CloseButtonWidth = 10;
#define TABLE_CELL_HEIGHT 12
#define BUTTON_FACE_HEIGHT 12
#define SPINNER_HEIGHT 12
#define DROPDOWN_HEIGHT 12
#define TEXT_INPUT_SIZE 1024
#define TOP_TOOLBAR_HEIGHT 27

View File

@@ -172,6 +172,7 @@ struct WindowBase
void ResizeFrameWithPage();
void ResizeSpinner(WidgetIndex widgetIndex, const ScreenCoordsXY& origin, const ScreenSize& size);
void ResizeDropdown(WidgetIndex widgetIndex, const ScreenCoordsXY& origin, const ScreenSize& size);
};
#ifdef __WARN_SUGGEST_FINAL_METHODS__