1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-20 13:33:02 +01:00

Fix #11961: Plugins: ViewportWidget unable to be moved or resized (#11997)

- Ensure child controls for dropdown and spinners are moved.
- Ensure viewport bounds are re-calculated if widget is moved / resized.
This commit is contained in:
Ted John
2020-06-19 19:20:58 +01:00
committed by GitHub
parent ea9dd60b91
commit 5a7fbc8054
2 changed files with 115 additions and 11 deletions

View File

@@ -754,12 +754,13 @@ namespace OpenRCT2::Ui::Windows
auto widgetInfo = customInfo.GetCustomWidgetDesc(w, *viewportWidgetIndex);
if (widgetInfo != nullptr)
{
if (w->viewport == nullptr)
auto left = w->windowPos.x + viewportWidget->left + 1;
auto top = w->windowPos.y + viewportWidget->top + 1;
auto width = (viewportWidget->right - viewportWidget->left) - 1;
auto height = (viewportWidget->bottom - viewportWidget->top) - 1;
auto viewport = w->viewport;
if (viewport == nullptr)
{
auto left = w->windowPos.x + viewportWidget->left + 1;
auto top = w->windowPos.y + viewportWidget->top + 1;
auto width = (viewportWidget->right - viewportWidget->left) - 1;
auto height = (viewportWidget->bottom - viewportWidget->top) - 1;
auto mapX = 0;
auto mapY = 0;
auto mapZ = 0;
@@ -769,6 +770,20 @@ namespace OpenRCT2::Ui::Windows
w->flags |= WF_NO_SCROLLING;
w->Invalidate();
}
else
{
if (viewport->pos.x != left || viewport->pos.y != top || viewport->width != width
|| viewport->height != height)
{
viewport->pos.x = left;
viewport->pos.y = top;
viewport->width = width;
viewport->height = height;
viewport->view_width = width * viewport->zoom;
viewport->view_height = height * viewport->zoom;
w->Invalidate();
}
}
}
}
}