diff --git a/src/openrct2-ui/WindowManager.cpp b/src/openrct2-ui/WindowManager.cpp index a4afe0520f..09674f8b80 100644 --- a/src/openrct2-ui/WindowManager.cpp +++ b/src/openrct2-ui/WindowManager.cpp @@ -840,7 +840,7 @@ public: std::unique_ptr&& wp, WindowClass cls, ScreenCoordsXY pos, int32_t width, int32_t height, uint32_t flags) override { - // auto titleBarHeight = (flags & WF_NO_TITLE_BAR) ? 0 : GetTitleBarHeight(); + height += getTitleHeightDiff(); if (flags & WF_AUTO_POSITION) { @@ -854,6 +854,8 @@ public: } } + height -= getTitleHeightDiff(); + // Check if there are any window slots left // include kWindowLimitReserved for items such as the main viewport and toolbars to not appear to be counted. if (g_window_list.size() >= static_cast(Config::Get().general.WindowLimit + kWindowLimitReserved)) diff --git a/src/openrct2-ui/interface/Widget.cpp b/src/openrct2-ui/interface/Widget.cpp index cf57526556..0bdab08dfc 100644 --- a/src/openrct2-ui/interface/Widget.cpp +++ b/src/openrct2-ui/interface/Widget.cpp @@ -569,7 +569,7 @@ namespace OpenRCT2::Ui if (Config::Get().interface.WindowButtonsOnTheLeft) topLeft.x += kCloseButtonSize; if (Config::Get().interface.EnlargedUi) - topLeft.y += 6; + topLeft.y += kTitleHeightLarge / 4; DrawTextEllipsised( dpi, topLeft, width, widget->text, Formatter::Common(), @@ -601,17 +601,15 @@ namespace OpenRCT2::Ui // Draw the button GfxFillRectInset(dpi, { topLeft, bottomRight }, colour, press); - if (widget.text == kStringIdNone) + if (widget.string == nullptr) return; topLeft = w.windowPos + ScreenCoordsXY{ widget.midX() - 1, std::max(widget.top, widget.midY() - 5) }; if (WidgetIsDisabled(w, widgetIndex)) colour.setFlag(ColourFlag::inset, true); - ; - DrawTextEllipsised( - dpi, topLeft, widget.width() - 2, widget.text, Formatter::Common(), { colour, TextAlignment::CENTRE }); + DrawText(dpi, topLeft, { colour, TextAlignment::CENTRE }, widget.string); } /** diff --git a/src/openrct2-ui/interface/Window.cpp b/src/openrct2-ui/interface/Window.cpp index 647e0c391d..a6c0b77e3c 100644 --- a/src/openrct2-ui/interface/Window.cpp +++ b/src/openrct2-ui/interface/Window.cpp @@ -470,57 +470,6 @@ namespace OpenRCT2 this, callWidget, title, description, descriptionArgs, existingText, existingArgs, maxLength); } - int32_t Window::ResizeFrame() - { - // Frame - widgets[0].right = width - 1; - widgets[0].bottom = height - 1; - - // Title - widgets[1].right = width - 2; - - // Close button - auto closeButtonSize = Config::Get().interface.EnlargedUi ? kCloseButtonSizeTouch : kCloseButtonSize; - if (Config::Get().interface.WindowButtonsOnTheLeft) - { - widgets[2].left = 2; - widgets[2].right = 2 + closeButtonSize; - } - else - { - widgets[2].left = width - 3 - closeButtonSize; - widgets[2].right = width - 3; - } - - auto defaultHeight = OpenRCT2::Ui::Windows::GetTitleBarHeight(); - auto currentHeight = widgets[1].height(); - auto heightDifference = defaultHeight - currentHeight; - if (heightDifference != 0) - { - widgets[1].bottom += heightDifference; - widgets[2].bottom += heightDifference; - - for (size_t i = 3; i < widgets.size(); i++) - { - widgets[i].top += heightDifference; - widgets[i].bottom += heightDifference; - } - } - - return heightDifference; - } - - int32_t Window::ResizeFrameWithPage() - { - auto heightDifference = ResizeFrame(); - - constexpr auto pageBackgroundOffset = 3; - widgets[pageBackgroundOffset].right = width - 1; - widgets[pageBackgroundOffset].bottom = height - 1; - - return heightDifference; - } - void Window::ResizeSpinner(WidgetIndex widgetIndex, const ScreenCoordsXY& origin, const ScreenSize& size) { auto right = origin.x + size.width - 1; @@ -714,6 +663,7 @@ namespace OpenRCT2::Ui::Windows w.height = std::clamp(w.height + dh, w.min_height, w.max_height); w.OnResize(); + w.ResizeFrame(); w.OnPrepareDraw(); // Update scroll widgets @@ -1025,18 +975,22 @@ namespace OpenRCT2::Ui::Windows }); } - bool WindowSetResize(WindowBase& w, const ScreenSize minSize, const ScreenSize maxSize) + bool WindowSetResize(WindowBase& w, ScreenSize minSize, ScreenSize maxSize) { - w.min_width = minSize.width; - w.min_height = minSize.height; - w.max_width = maxSize.width; - w.max_height = maxSize.height; + w.min_width = std::min(minSize.width, maxSize.width); + w.min_height = std::min(minSize.height, maxSize.height); + w.max_width = std::max(minSize.width, maxSize.width); + w.max_height = std::max(minSize.height, maxSize.height); + + if (Config::Get().interface.EnlargedUi) + { + w.min_height += getTitleHeightDiff(); + w.max_height += getTitleHeightDiff(); + } // Clamp width and height to minimum and maximum - int16_t width = std::clamp( - w.width, std::min(minSize.width, maxSize.width), std::max(minSize.width, maxSize.width)); - int16_t height = std::clamp( - w.height, std::min(minSize.height, maxSize.height), std::max(minSize.height, maxSize.height)); + int16_t width = std::clamp(w.width, w.min_width, w.max_width); + int16_t height = std::clamp(w.height, w.min_height, w.max_height); // Resize window if size has changed if (w.width != width || w.height != height) @@ -1044,6 +998,7 @@ namespace OpenRCT2::Ui::Windows w.Invalidate(); w.width = width; w.height = height; + w.ResizeFrame(); w.Invalidate(); return true; } @@ -1158,10 +1113,4 @@ namespace OpenRCT2::Ui::Windows else WindowZoomOut(*mainWindow, atCursor); } - - int16_t GetTitleBarHeight() - { - return Config::Get().interface.EnlargedUi ? 24 : 12; - } - } // namespace OpenRCT2::Ui::Windows diff --git a/src/openrct2-ui/interface/Window.h b/src/openrct2-ui/interface/Window.h index 45a55fd417..59d40bcbcf 100644 --- a/src/openrct2-ui/interface/Window.h +++ b/src/openrct2-ui/interface/Window.h @@ -16,6 +16,8 @@ struct TextInputSession; namespace OpenRCT2 { + constexpr ScreenSize kMaxWindowSize = { 5000, 5000 }; + struct Window : WindowBase { void OnDraw(DrawPixelInfo& dpi) override; @@ -40,9 +42,6 @@ namespace OpenRCT2 WidgetIndex callWidget, StringId title, StringId description, const Formatter& descriptionArgs, StringId existingText, uintptr_t existingArgs, int32_t maxLength); - int32_t ResizeFrame(); - int32_t ResizeFrameWithPage(); - void ResizeSpinner(WidgetIndex widgetIndex, const ScreenCoordsXY& origin, const ScreenSize& size); void ResizeDropdown(WidgetIndex widgetIndex, const ScreenCoordsXY& origin, const ScreenSize& size); }; @@ -80,7 +79,7 @@ namespace OpenRCT2::Ui::Windows void WindowMoveAndSnap(WindowBase& w, ScreenCoordsXY newWindowCoords, int32_t snapProximity); void WindowRelocateWindows(int32_t width, int32_t height); - bool WindowSetResize(WindowBase& w, const ScreenSize minSize, const ScreenSize maxSize); + bool WindowSetResize(WindowBase& w, ScreenSize minSize, ScreenSize maxSize); bool WindowCanResize(const WindowBase& w); void InvalidateAllWindowsAfterInput(); @@ -91,6 +90,4 @@ namespace OpenRCT2::Ui::Windows void WindowZoomIn(WindowBase& w, bool atCursor); void WindowZoomOut(WindowBase& w, bool atCursor); void MainWindowZoom(bool zoomIn, bool atCursor); - - int16_t GetTitleBarHeight(); } // namespace OpenRCT2::Ui::Windows diff --git a/src/openrct2-ui/scripting/CustomWindow.cpp b/src/openrct2-ui/scripting/CustomWindow.cpp index 574c9e9e0d..5d220a63cb 100644 --- a/src/openrct2-ui/scripting/CustomWindow.cpp +++ b/src/openrct2-ui/scripting/CustomWindow.cpp @@ -425,8 +425,8 @@ namespace OpenRCT2::Ui::Windows { min_width = _info.Desc.MinWidth.value_or(0); min_height = _info.Desc.MinHeight.value_or(0); - max_width = _info.Desc.MaxWidth.value_or(std::numeric_limits::max()); - max_height = _info.Desc.MaxHeight.value_or(std::numeric_limits::max()); + max_width = _info.Desc.MaxWidth.value_or(kMaxWindowSize.width); + max_height = _info.Desc.MaxHeight.value_or(kMaxWindowSize.height); } RefreshWidgets(); } @@ -438,16 +438,6 @@ namespace OpenRCT2::Ui::Windows void OnResize() override { - if (width < min_width) - { - Invalidate(); - width = min_width; - } - if (height < min_height) - { - Invalidate(); - height = min_height; - } UpdateViewport(); } diff --git a/src/openrct2-ui/scripting/ScWidget.hpp b/src/openrct2-ui/scripting/ScWidget.hpp index 80e8f95649..01dd8d9672 100644 --- a/src/openrct2-ui/scripting/ScWidget.hpp +++ b/src/openrct2-ui/scripting/ScWidget.hpp @@ -167,7 +167,7 @@ namespace OpenRCT2::Scripting auto widget = GetWidget(); if (widget != nullptr) { - return widget->top; + return widget->top - getTitleHeightDiff(); } return 0; } @@ -176,6 +176,7 @@ namespace OpenRCT2::Scripting auto widget = GetWidget(); if (widget != nullptr) { + value += getTitleHeightDiff(); auto delta = value - widget->top; Invalidate(); diff --git a/src/openrct2-ui/scripting/ScWindow.hpp b/src/openrct2-ui/scripting/ScWindow.hpp index c497a7c673..c416bd8d2c 100644 --- a/src/openrct2-ui/scripting/ScWindow.hpp +++ b/src/openrct2-ui/scripting/ScWindow.hpp @@ -97,14 +97,8 @@ namespace OpenRCT2::Scripting auto w = GetWindow(); if (w != nullptr) { - if (WindowCanResize(*w)) - { - WindowResizeByDelta(*w, value - w->width, 0); - } - else - { - WindowSetResize(*w, { value, w->min_height }, { value, w->max_height }); - } + w->width = value; + WindowSetResize(*w, { w->min_width, w->min_height }, { w->max_width, w->max_height }); } } int32_t height_get() const @@ -112,7 +106,7 @@ namespace OpenRCT2::Scripting auto w = GetWindow(); if (w != nullptr) { - return w->height; + return w->height - getTitleHeightDiff(); } return 0; } @@ -121,14 +115,8 @@ namespace OpenRCT2::Scripting auto w = GetWindow(); if (w != nullptr) { - if (WindowCanResize(*w)) - { - WindowResizeByDelta(*w, 0, value - w->height); - } - else - { - WindowSetResize(*w, { w->min_width, value }, { w->max_width, value }); - } + w->height = value + getTitleHeightDiff(); + WindowSetResize(*w, { w->min_width, w->min_height }, { w->max_width, w->max_height }); } } int32_t minWidth_get() const diff --git a/src/openrct2-ui/windows/About.cpp b/src/openrct2-ui/windows/About.cpp index c76396c182..3ae6369ee3 100644 --- a/src/openrct2-ui/windows/About.cpp +++ b/src/openrct2-ui/windows/About.cpp @@ -180,17 +180,17 @@ namespace OpenRCT2::Ui::Windows int32_t newHeight = 0; if (page == WINDOW_ABOUT_PAGE_OPENRCT2) { - newHeight = DrawOpenRCT2Info(dpi) + kPadding + 1; + newHeight = DrawOpenRCT2Info(dpi) + kPadding; } else if (page == WINDOW_ABOUT_PAGE_RCT2) { - newHeight = DrawRCT2Info(dpi) + kPadding + 1; + newHeight = DrawRCT2Info(dpi) + kPadding; } if (newHeight != height) { Invalidate(); - widgets[WIDX_PAGE_BACKGROUND].bottom = newHeight - 1; + widgets[WIDX_PAGE_BACKGROUND].bottom = newHeight; widgets[WIDX_BACKGROUND].bottom = newHeight; height = newHeight; } @@ -206,8 +206,9 @@ namespace OpenRCT2::Ui::Windows page = p; frame_no = 0; pressed_widgets = 0; - SetWidgets(_windowAboutPageWidgets[p]); + WindowSetResize(*this, { WW, WH }, { WW, WH }); + SetWidgets(_windowAboutPageWidgets[p]); switch (p) { @@ -218,9 +219,6 @@ namespace OpenRCT2::Ui::Windows pressed_widgets |= (1uLL << WIDX_TAB_ABOUT_RCT2); break; } - - InitScrollWidgets(); - Invalidate(); } int32_t DrawOpenRCT2Info(DrawPixelInfo& dpi) @@ -283,11 +281,6 @@ namespace OpenRCT2::Ui::Windows return textCoords.y - windowPos.y; } - - void OnPrepareDraw() override - { - ResizeFrameWithPage(); - } }; /** diff --git a/src/openrct2-ui/windows/AssetPacks.cpp b/src/openrct2-ui/windows/AssetPacks.cpp index c78c48e8e3..36e71e10cc 100644 --- a/src/openrct2-ui/windows/AssetPacks.cpp +++ b/src/openrct2-ui/windows/AssetPacks.cpp @@ -151,8 +151,6 @@ namespace OpenRCT2::Ui::Windows void OnPrepareDraw() override { - ResizeFrame(); - auto& list = widgets[WIDX_LIST]; list.left = 6; list.top = widgets[WIDX_TITLE].height() + 8 + 11 + 3; diff --git a/src/openrct2-ui/windows/Banner.cpp b/src/openrct2-ui/windows/Banner.cpp index e4979adba7..2c7e881983 100644 --- a/src/openrct2-ui/windows/Banner.cpp +++ b/src/openrct2-ui/windows/Banner.cpp @@ -280,8 +280,6 @@ namespace OpenRCT2::Ui::Windows return; } - ResizeFrame(); - Widget& colourBtn = widgets[WIDX_MAIN_COLOUR]; colourBtn.type = WindowWidgetType::Empty; @@ -303,11 +301,6 @@ namespace OpenRCT2::Ui::Windows Widget& dropDownWidget = widgets[WIDX_TEXT_COLOUR_DROPDOWN]; dropDownWidget.text = BannerColouredTextFormats[banner->text_colour]; } - - void OnResize() override - { - ResizeFrame(); - } }; /** diff --git a/src/openrct2-ui/windows/Changelog.cpp b/src/openrct2-ui/windows/Changelog.cpp index e360791a23..560ae51aea 100644 --- a/src/openrct2-ui/windows/Changelog.cpp +++ b/src/openrct2-ui/windows/Changelog.cpp @@ -149,7 +149,6 @@ namespace OpenRCT2::Ui::Windows void OnPrepareDraw() override { - ResizeFrameWithPage(); widgets[WIDX_SCROLL].right = width - 3; widgets[WIDX_SCROLL].bottom = height - 22; widgets[WIDX_OPEN_URL].bottom = height - 5; diff --git a/src/openrct2-ui/windows/Cheats.cpp b/src/openrct2-ui/windows/Cheats.cpp index 470237123c..4f37179d65 100644 --- a/src/openrct2-ui/windows/Cheats.cpp +++ b/src/openrct2-ui/windows/Cheats.cpp @@ -763,11 +763,13 @@ static StringId window_cheats_page_titles[] = { } maxY += 6; - Invalidate(); - WindowInitScrollWidgets(*this); - height = maxY; - ResizeFrameWithPage(); - Invalidate(); + if (maxY != height) + { + Invalidate(); + height = maxY; + ResizeFrame(); + Invalidate(); + } } void UpdateTabPositions() @@ -1349,11 +1351,6 @@ static StringId window_cheats_page_titles[] = { break; } } - - void OnResize() override - { - ResizeFrameWithPage(); - } }; WindowBase* CheatsOpen() diff --git a/src/openrct2-ui/windows/ClearScenery.cpp b/src/openrct2-ui/windows/ClearScenery.cpp index ab6d1eeb6c..7ba9e5b35b 100644 --- a/src/openrct2-ui/windows/ClearScenery.cpp +++ b/src/openrct2-ui/windows/ClearScenery.cpp @@ -77,6 +77,7 @@ namespace OpenRCT2::Ui::Windows void OnOpen() override { SetWidgets(window_clear_scenery_widgets); + hold_down_widgets = (1uLL << WIDX_INCREMENT) | (1uLL << WIDX_DECREMENT); WindowInitScrollWidgets(*this); WindowPushOthersBelow(*this); @@ -207,11 +208,6 @@ namespace OpenRCT2::Ui::Windows } } - void OnResize() override - { - ResizeFrame(); - } - ClearAction GetClearAction() { auto range = MapRange(gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y); diff --git a/src/openrct2-ui/windows/CustomCurrency.cpp b/src/openrct2-ui/windows/CustomCurrency.cpp index 2a5fdd2035..782ed8cc1e 100644 --- a/src/openrct2-ui/windows/CustomCurrency.cpp +++ b/src/openrct2-ui/windows/CustomCurrency.cpp @@ -222,11 +222,6 @@ namespace OpenRCT2::Ui::Windows : STR_SUFFIX; DrawTextBasic(dpi, drawPos, stringId, {}, { colours[1] }); } - - void OnResize() override - { - ResizeFrame(); - } }; WindowBase* CustomCurrencyOpen() diff --git a/src/openrct2-ui/windows/DemolishRidePrompt.cpp b/src/openrct2-ui/windows/DemolishRidePrompt.cpp index bad78bbfab..2300910f3f 100644 --- a/src/openrct2-ui/windows/DemolishRidePrompt.cpp +++ b/src/openrct2-ui/windows/DemolishRidePrompt.cpp @@ -92,11 +92,6 @@ namespace OpenRCT2::Ui::Windows DrawTextWrapped(dpi, stringCoords, WW - 4, stringId, ft, { TextAlignment::CENTRE }); } } - - void OnResize() override - { - ResizeFrame(); - } }; WindowBase* RideDemolishPromptOpen(const Ride& ride) diff --git a/src/openrct2-ui/windows/EditorInventionsList.cpp b/src/openrct2-ui/windows/EditorInventionsList.cpp index d0fb68ea01..b465868f7d 100644 --- a/src/openrct2-ui/windows/EditorInventionsList.cpp +++ b/src/openrct2-ui/windows/EditorInventionsList.cpp @@ -450,8 +450,6 @@ namespace OpenRCT2::Ui::Windows widgets[WIDX_CLOSE].type = gLegacyScene == LegacyScene::scenarioEditor ? WindowWidgetType::Empty : WindowWidgetType::CloseBox; - ResizeFrameWithPage(); - int16_t scrollListHeight = (height - 88) / 2; widgets[WIDX_PRE_RESEARCHED_SCROLL].bottom = 60 + scrollListHeight; diff --git a/src/openrct2-ui/windows/EditorObjectSelection.cpp b/src/openrct2-ui/windows/EditorObjectSelection.cpp index e44e0535e6..6efb47c2fd 100644 --- a/src/openrct2-ui/windows/EditorObjectSelection.cpp +++ b/src/openrct2-ui/windows/EditorObjectSelection.cpp @@ -844,7 +844,6 @@ namespace OpenRCT2::Ui::Windows void OnPrepareDraw() override { // Resize widgets - ResizeFrameWithPage(); widgets[WIDX_LIST].right = width - 309; widgets[WIDX_LIST].bottom = height - 14; widgets[WIDX_PREVIEW].left = width - 209; diff --git a/src/openrct2-ui/windows/EditorParkEntrance.cpp b/src/openrct2-ui/windows/EditorParkEntrance.cpp index a1cd5a40e0..42610742d0 100644 --- a/src/openrct2-ui/windows/EditorParkEntrance.cpp +++ b/src/openrct2-ui/windows/EditorParkEntrance.cpp @@ -284,8 +284,6 @@ namespace OpenRCT2::Ui::Windows void OnPrepareDraw() override { - ResizeFrameWithPage(); - widgets[WIDX_LIST].right = width - 30; widgets[WIDX_LIST].bottom = height - 5; } diff --git a/src/openrct2-ui/windows/EditorScenarioOptions.cpp b/src/openrct2-ui/windows/EditorScenarioOptions.cpp index e7e9ceac6b..1833535066 100644 --- a/src/openrct2-ui/windows/EditorScenarioOptions.cpp +++ b/src/openrct2-ui/windows/EditorScenarioOptions.cpp @@ -576,11 +576,6 @@ namespace OpenRCT2::Ui::Windows SetWidgetPressed(WIDX_TAB_1 + page, true); } - void AnchorBorderWidgets() - { - ResizeFrameWithPage(); - } - void DrawTabImages(DrawPixelInfo& dpi) { Widget* widget; @@ -1086,8 +1081,6 @@ namespace OpenRCT2::Ui::Windows : WindowWidgetType::CloseBox; SetWidgetPressed(WIDX_HARD_PARK_RATING, gameState.park.Flags & PARK_FLAGS_DIFFICULT_PARK_RATING); - - AnchorBorderWidgets(); } /** @@ -1255,7 +1248,6 @@ namespace OpenRCT2::Ui::Windows void ScenarioDetailsOnPrepareDraw() { SetPressedTab(); - AnchorBorderWidgets(); } void ScenarioDetailsOnDraw(DrawPixelInfo& dpi) @@ -1662,8 +1654,6 @@ namespace OpenRCT2::Ui::Windows widgets[WIDX_CLOSE].type = gLegacyScene == LegacyScene::scenarioEditor ? WindowWidgetType::Empty : WindowWidgetType::CloseBox; - - AnchorBorderWidgets(); } void FinancialDraw(DrawPixelInfo& dpi) @@ -1951,8 +1941,6 @@ namespace OpenRCT2::Ui::Windows : WindowWidgetType::CloseBox; SetWidgetPressed(WIDX_HARD_GUEST_GENERATION, gameState.park.Flags & PARK_FLAGS_DIFFICULT_GUEST_GENERATION); - - AnchorBorderWidgets(); } void GuestsDraw(DrawPixelInfo& dpi) @@ -2152,8 +2140,6 @@ namespace OpenRCT2::Ui::Windows widgets[WIDX_CLOSE].type = gLegacyScene == LegacyScene::scenarioEditor ? WindowWidgetType::Empty : WindowWidgetType::CloseBox; - - AnchorBorderWidgets(); } void LandDraw(DrawPixelInfo& dpi) @@ -2285,8 +2271,6 @@ namespace OpenRCT2::Ui::Windows widgets[WIDX_CLOSE].type = gLegacyScene == LegacyScene::scenarioEditor ? WindowWidgetType::Empty : WindowWidgetType::CloseBox; - - AnchorBorderWidgets(); } /** diff --git a/src/openrct2-ui/windows/Finances.cpp b/src/openrct2-ui/windows/Finances.cpp index 0478e393f3..002e6a7984 100644 --- a/src/openrct2-ui/windows/Finances.cpp +++ b/src/openrct2-ui/windows/Finances.cpp @@ -327,9 +327,6 @@ namespace OpenRCT2::Ui::Windows case WINDOW_FINANCES_PAGE_RESEARCH: WindowResearchFundingPrepareDraw(this, WIDX_RESEARCH_FUNDING); return; - default: - return; - case WINDOW_FINANCES_PAGE_VALUE_GRAPH: graphPageWidget = &widgets[WIDX_PAGE_BACKGROUND]; centredGraph = false; @@ -345,6 +342,8 @@ namespace OpenRCT2::Ui::Windows centredGraph = true; _graphProps.series = getGameState().cashHistory; break; + default: + return; } OnPrepareDrawGraph(graphPageWidget, centredGraph); } @@ -488,12 +487,7 @@ namespace OpenRCT2::Ui::Windows page = p; frame_no = 0; - hold_down_widgets = _windowFinancesPageHoldDownWidgets[p]; - pressed_widgets = 0; - SetWidgets(_windowFinancesPageWidgets[p]); - SetDisabledTabs(); Invalidate(); - if (p == WINDOW_FINANCES_PAGE_RESEARCH) { width = WW_RESEARCH; @@ -511,9 +505,12 @@ namespace OpenRCT2::Ui::Windows || p == WINDOW_FINANCES_PAGE_FINANCIAL_GRAPH) { flags |= WF_RESIZABLE; - WindowSetResize( - *this, { WW_OTHER_TABS, kHeightOtherTabs }, - { std::numeric_limits::max(), std::numeric_limits::max() }); + + // We need to compensate for the enlarged title bar for windows that do not + // constrain the window height between tabs (e.g. chart tabs) + height -= getTitleHeightDiff(); + + WindowSetResize(*this, { WW_OTHER_TABS, kHeightOtherTabs }, kMaxWindowSize); } else { @@ -521,7 +518,14 @@ namespace OpenRCT2::Ui::Windows height = kHeightOtherTabs; flags &= ~WF_RESIZABLE; } - OnResize(); + + SetWidgets(_windowFinancesPageWidgets[p]); + SetDisabledTabs(); + + hold_down_widgets = _windowFinancesPageHoldDownWidgets[p]; + pressed_widgets = 0; + + ResizeFrame(); OnPrepareDraw(); InitScrollWidgets(); @@ -875,11 +879,6 @@ namespace OpenRCT2::Ui::Windows DrawTabImage(dpi, WINDOW_FINANCES_PAGE_MARKETING, SPR_TAB_FINANCES_MARKETING_0); DrawTabImage(dpi, WINDOW_FINANCES_PAGE_RESEARCH, SPR_TAB_FINANCES_RESEARCH_0); } - - void OnResize() override - { - ResizeFrameWithPage(); - } }; static FinancesWindow* FinancesWindowOpen(uint8_t page) diff --git a/src/openrct2-ui/windows/Footpath.cpp b/src/openrct2-ui/windows/Footpath.cpp index ee18a0d9d2..3f46d4ec14 100644 --- a/src/openrct2-ui/windows/Footpath.cpp +++ b/src/openrct2-ui/windows/Footpath.cpp @@ -1616,11 +1616,6 @@ namespace OpenRCT2::Ui::Windows OnMouseDown(WIDX_CONSTRUCT); } - void OnResize() override - { - ResizeFrame(); - } - #pragma endregion }; diff --git a/src/openrct2-ui/windows/Guest.cpp b/src/openrct2-ui/windows/Guest.cpp index 3d4e40d3d3..66570eee1b 100644 --- a/src/openrct2-ui/windows/Guest.cpp +++ b/src/openrct2-ui/windows/Guest.cpp @@ -452,7 +452,6 @@ namespace OpenRCT2::Ui::Windows maxSize.width = std::max(minSize.width, maxSize.width); WindowSetResize(*this, minSize, maxSize); - ResizeFrameWithPage(); } void OnPrepareDrawCommon() diff --git a/src/openrct2-ui/windows/GuestList.cpp b/src/openrct2-ui/windows/GuestList.cpp index 7beff84bb2..35c6ed2ba5 100644 --- a/src/openrct2-ui/windows/GuestList.cpp +++ b/src/openrct2-ui/windows/GuestList.cpp @@ -405,7 +405,6 @@ namespace OpenRCT2::Ui::Windows if (_selectedTab == TabId::Individual && _selectedFilter) widgets[WIDX_MAP].type = WindowWidgetType::FlatBtn; - ResizeFrameWithPage(); widgets[WIDX_GUEST_LIST].right = width - 4; widgets[WIDX_GUEST_LIST].bottom = height - 15; widgets[WIDX_MAP].left = 273 - 350 + width; diff --git a/src/openrct2-ui/windows/InstallTrack.cpp b/src/openrct2-ui/windows/InstallTrack.cpp index f4a8975b77..340cfa731b 100644 --- a/src/openrct2-ui/windows/InstallTrack.cpp +++ b/src/openrct2-ui/windows/InstallTrack.cpp @@ -354,11 +354,6 @@ namespace OpenRCT2::Ui::Windows } } - void OnResize() override - { - ResizeFrame(); - } - private: void UpdatePreview() { diff --git a/src/openrct2-ui/windows/Land.cpp b/src/openrct2-ui/windows/Land.cpp index 3bdd367d89..1fb6462017 100644 --- a/src/openrct2-ui/windows/Land.cpp +++ b/src/openrct2-ui/windows/Land.cpp @@ -90,6 +90,7 @@ namespace OpenRCT2::Ui::Windows void OnOpen() override { SetWidgets(window_land_widgets); + hold_down_widgets = (1uLL << WIDX_DECREMENT) | (1uLL << WIDX_INCREMENT); WindowInitScrollWidgets(*this); WindowPushOthersBelow(*this); @@ -325,11 +326,6 @@ namespace OpenRCT2::Ui::Windows } } - void OnResize() override - { - ResizeFrame(); - } - private: /** * diff --git a/src/openrct2-ui/windows/LandRights.cpp b/src/openrct2-ui/windows/LandRights.cpp index 27ded676af..42740c1d88 100644 --- a/src/openrct2-ui/windows/LandRights.cpp +++ b/src/openrct2-ui/windows/LandRights.cpp @@ -127,6 +127,7 @@ namespace OpenRCT2::Ui::Windows void OnOpen() override { SetWidgets(window_land_rights_widgets); + hold_down_widgets = (1uLL << WIDX_INCREMENT) | (1uLL << WIDX_DECREMENT); WindowInitScrollWidgets(*this); WindowPushOthersBelow(*this); @@ -386,7 +387,6 @@ namespace OpenRCT2::Ui::Windows if (windowPos.x + width > ContextGetWidth()) windowPos.x = ContextGetWidth() - width; - ResizeFrame(); Invalidate(); } diff --git a/src/openrct2-ui/windows/LoadSave.cpp b/src/openrct2-ui/windows/LoadSave.cpp index e64ce7a970..fd4a16a09e 100644 --- a/src/openrct2-ui/windows/LoadSave.cpp +++ b/src/openrct2-ui/windows/LoadSave.cpp @@ -570,7 +570,7 @@ namespace OpenRCT2::Ui::Windows auto& config = Config::Get().general; config.FileBrowserWidth = width; - config.FileBrowserHeight = height; + config.FileBrowserHeight = height - getTitleHeightDiff(); } void OnUpdate() override @@ -584,8 +584,6 @@ namespace OpenRCT2::Ui::Windows void OnPrepareDraw() override { - ResizeFrameWithPage(); - auto toolbarXPos = width - 5; for (auto widgetIndex = 3; widgetIndex >= 0; widgetIndex--) { diff --git a/src/openrct2-ui/windows/Map.cpp b/src/openrct2-ui/windows/Map.cpp index 1b6afc6885..eaaacf700b 100644 --- a/src/openrct2-ui/windows/Map.cpp +++ b/src/openrct2-ui/windows/Map.cpp @@ -619,7 +619,6 @@ namespace OpenRCT2::Ui::Windows SetWidgetDisabled(WIDX_MAP_SIZE_LINK, gameState.mapSize.x != gameState.mapSize.y); // Resize widgets to window size - ResizeFrameWithPage(); ResizeMiniMap(); widgets[WIDX_MAP_SIZE_SPINNER_Y].top = height - 15; @@ -1205,6 +1204,8 @@ namespace OpenRCT2::Ui::Windows height = std::min(height, maxWindowHeight); _adjustedForSandboxMode = isEditorOrSandbox(); + + ResizeFrame(); } void ResetMaxWindowDimensions() diff --git a/src/openrct2-ui/windows/MapGen.cpp b/src/openrct2-ui/windows/MapGen.cpp index 23f4cf0dde..932f6ad556 100644 --- a/src/openrct2-ui/windows/MapGen.cpp +++ b/src/openrct2-ui/windows/MapGen.cpp @@ -281,8 +281,8 @@ namespace OpenRCT2::Ui::Windows frame_no = 0; RemoveViewport(); - hold_down_widgets = HoldDownWidgets[newPage]; SetWidgets(PageWidgets[newPage]); + hold_down_widgets = HoldDownWidgets[newPage]; disabled_widgets = PageDisabledWidgets[newPage]; pressed_widgets = PressedWidgets[newPage]; @@ -1526,7 +1526,7 @@ namespace OpenRCT2::Ui::Windows void OnResize() override { - ResizeFrameWithPage(); + WindowSetResize(*this, kWindowSize, kWindowSize); } }; diff --git a/src/openrct2-ui/windows/MapTooltip.cpp b/src/openrct2-ui/windows/MapTooltip.cpp index 0d6e24e928..89ad1cbb27 100644 --- a/src/openrct2-ui/windows/MapTooltip.cpp +++ b/src/openrct2-ui/windows/MapTooltip.cpp @@ -128,7 +128,8 @@ namespace OpenRCT2::Ui::Windows else { w = windowMgr->Create( - WindowClass::MapTooltip, pos, width, height, WF_STICK_TO_FRONT | WF_TRANSPARENT | WF_NO_BACKGROUND); + WindowClass::MapTooltip, pos, width, height, + WF_STICK_TO_FRONT | WF_TRANSPARENT | WF_NO_BACKGROUND | WF_NO_TITLE_BAR); } } } // namespace OpenRCT2::Ui::Windows diff --git a/src/openrct2-ui/windows/MazeConstruction.cpp b/src/openrct2-ui/windows/MazeConstruction.cpp index 3a2720e5d7..88e6ef4429 100644 --- a/src/openrct2-ui/windows/MazeConstruction.cpp +++ b/src/openrct2-ui/windows/MazeConstruction.cpp @@ -166,7 +166,6 @@ namespace OpenRCT2::Ui::Windows void OnResize() override { - ResizeFrameWithPage(); uint64_t disabledWidgets = 0; if (_rideConstructionState == RideConstructionState::Place) { diff --git a/src/openrct2-ui/windows/Multiplayer.cpp b/src/openrct2-ui/windows/Multiplayer.cpp index a46ca3e47b..aae6e8e919 100644 --- a/src/openrct2-ui/windows/Multiplayer.cpp +++ b/src/openrct2-ui/windows/Multiplayer.cpp @@ -395,7 +395,6 @@ namespace OpenRCT2::Ui::Windows { ResetPressedWidgets(); SetWidgetPressed(WIDX_TAB1 + page, true); - ResizeFrameWithPage(); switch (page) { case WINDOW_MULTIPLAYER_PAGE_INFORMATION: diff --git a/src/openrct2-ui/windows/NetworkStatus.cpp b/src/openrct2-ui/windows/NetworkStatus.cpp index c0db7ace63..8283382452 100644 --- a/src/openrct2-ui/windows/NetworkStatus.cpp +++ b/src/openrct2-ui/windows/NetworkStatus.cpp @@ -35,9 +35,8 @@ namespace OpenRCT2::Ui::Windows public: void OnOpen() override { - SetWidgets(window_network_status_widgets); - WindowInitScrollWidgets(*this); WindowSetResize(*this, { 320, 90 }, { 320, 90 }); + SetWidgets(window_network_status_widgets); frame_no = 0; page = 0; @@ -86,18 +85,15 @@ namespace OpenRCT2::Ui::Windows } } - void OnPrepareDraw() override - { - ResizeFrame(); - } - void OnDraw(DrawPixelInfo& dpi) override { WindowDrawWidgets(*this, dpi); thread_local std::string _buffer; + _buffer.assign("{WHITE}"); _buffer += _windowNetworkStatusText; GfxClipString(_buffer.data(), widgets[WIDX_BACKGROUND].right - 50, FontStyle::Medium); + ScreenCoordsXY screenCoords(windowPos.x + (width / 2), windowPos.y + (height / 2)); screenCoords.x -= GfxGetStringWidth(_buffer, FontStyle::Medium) / 2; DrawText(dpi, screenCoords, { COLOUR_BLACK }, _buffer.c_str()); diff --git a/src/openrct2-ui/windows/NewCampaign.cpp b/src/openrct2-ui/windows/NewCampaign.cpp index d87f4d62f3..02d39ce376 100644 --- a/src/openrct2-ui/windows/NewCampaign.cpp +++ b/src/openrct2-ui/windows/NewCampaign.cpp @@ -390,11 +390,6 @@ namespace OpenRCT2::Ui::Windows DrawTextBasic(dpi, screenCoords, STR_MARKETING_TOTAL_COST, ft); } - void OnResize() override - { - ResizeFrame(); - } - int16_t GetCampaignType() const { return Campaign.campaign_type; diff --git a/src/openrct2-ui/windows/NewRide.cpp b/src/openrct2-ui/windows/NewRide.cpp index 5c4318e05a..81b25e3c1f 100644 --- a/src/openrct2-ui/windows/NewRide.cpp +++ b/src/openrct2-ui/windows/NewRide.cpp @@ -862,16 +862,12 @@ namespace OpenRCT2::Ui::Windows // Handle new window size if (width != newWidth || height != newHeight) { - Invalidate(); + ScreenSize newSize = { newWidth, newHeight }; + WindowSetResize(*this, newSize, newSize); + OnResize(); - // Resize widgets to new window size - width = newWidth; - height = newHeight; - ResizeFrameWithPage(); widgets[WIDX_GROUP_BY_TRACK_TYPE].left = newWidth - 8 - GroupByTrackTypeWidth; widgets[WIDX_GROUP_BY_TRACK_TYPE].right = newWidth - 8; - - Invalidate(); } InitScrollWidgets(); diff --git a/src/openrct2-ui/windows/News.cpp b/src/openrct2-ui/windows/News.cpp index c77d57a3ae..5efa39ea53 100644 --- a/src/openrct2-ui/windows/News.cpp +++ b/src/openrct2-ui/windows/News.cpp @@ -315,11 +315,6 @@ namespace OpenRCT2::Ui::Windows i++; } } - - void OnResize() override - { - ResizeFrame(); - } }; WindowBase* NewsOpen() diff --git a/src/openrct2-ui/windows/NewsOptions.cpp b/src/openrct2-ui/windows/NewsOptions.cpp index d1dd48761c..dd787e218f 100644 --- a/src/openrct2-ui/windows/NewsOptions.cpp +++ b/src/openrct2-ui/windows/NewsOptions.cpp @@ -264,11 +264,6 @@ namespace OpenRCT2::Ui::Windows return configValue; } - void OnResize() override - { - ResizeFrameWithPage(); - } - static constexpr int32_t TabAnimationDivisor[3] = { 1, // Park 4, // Ride diff --git a/src/openrct2-ui/windows/ObjectLoadError.cpp b/src/openrct2-ui/windows/ObjectLoadError.cpp index 3354c0d03e..419902beec 100644 --- a/src/openrct2-ui/windows/ObjectLoadError.cpp +++ b/src/openrct2-ui/windows/ObjectLoadError.cpp @@ -556,11 +556,6 @@ namespace OpenRCT2::Ui::Windows } } - void OnResize() override - { - ResizeFrame(); - } - void Initialise(utf8* path, const size_t numMissingObjects, const ObjectEntryDescriptor* missingObjects) { _invalidEntries = std::vector(missingObjects, missingObjects + numMissingObjects); diff --git a/src/openrct2-ui/windows/Options.cpp b/src/openrct2-ui/windows/Options.cpp index d88c8b1329..675e936c45 100644 --- a/src/openrct2-ui/windows/Options.cpp +++ b/src/openrct2-ui/windows/Options.cpp @@ -675,13 +675,15 @@ namespace OpenRCT2::Ui::Windows const auto& widget = widgets[widgetIdx]; y = std::max(y, widget.bottom); } - height = y + 6; - ResizeFrameWithPage(); - } + y += 6; - void OnResize() override - { - ResizeFrameWithPage(); + if (height != y) + { + Invalidate(); + height = y; + ResizeFrame(); + Invalidate(); + } } void CommonUpdate() @@ -1618,6 +1620,7 @@ namespace OpenRCT2::Ui::Windows Config::Save(); Invalidate(); windowMgr->InvalidateAll(); + WindowVisitEach([](WindowBase* w) { w->ResizeFrame(); }); break; case WIDX_TOUCH_ENHANCEMENTS: Config::Get().interface.TouchEnhancements ^= 1; @@ -2117,8 +2120,8 @@ namespace OpenRCT2::Ui::Windows SetWidgets(window_options_page_widgets[page]); Invalidate(); - OnResize(); OnPrepareDraw(); + OnResize(); InitScrollWidgets(); Invalidate(); } diff --git a/src/openrct2-ui/windows/Park.cpp b/src/openrct2-ui/windows/Park.cpp index 69e748d898..b4f493277f 100644 --- a/src/openrct2-ui/windows/Park.cpp +++ b/src/openrct2-ui/windows/Park.cpp @@ -514,7 +514,6 @@ namespace OpenRCT2::Ui::Windows void OnPrepareDrawEntrance() { const auto& gameState = getGameState(); - SetWidgets(_pagedWidgets[page]); InitScrollWidgets(); SetPressedTab(); @@ -548,7 +547,6 @@ namespace OpenRCT2::Ui::Windows widgets[WIDX_BUY_LAND_RIGHTS].type = WindowWidgetType::FlatBtn; WindowAlignTabs(this, WIDX_TAB_1, WIDX_TAB_7); - AnchorBorderWidgets(); // Anchor entrance page specific widgets widgets[WIDX_VIEWPORT].right = width - 26; @@ -677,7 +675,7 @@ namespace OpenRCT2::Ui::Windows void OnResizeRating() { flags |= WF_RESIZABLE; - WindowSetResize(*this, { 268, 174 + 9 }, { 2000, 2000 }); + WindowSetResize(*this, { 268, 174 + 9 }, kMaxWindowSize); } void OnUpdateRating() @@ -696,7 +694,6 @@ namespace OpenRCT2::Ui::Windows PrepareWindowTitleText(); WindowAlignTabs(this, WIDX_TAB_1, WIDX_TAB_7); - AnchorBorderWidgets(); _ratingProps.min = 0; _ratingProps.max = 1000; @@ -745,7 +742,7 @@ namespace OpenRCT2::Ui::Windows void OnResizeGuests() { flags |= WF_RESIZABLE; - WindowSetResize(*this, { 268, 174 + 9 }, { 2000, 2000 }); + WindowSetResize(*this, { 268, 174 + 9 }, kMaxWindowSize); } void OnUpdateGuests() @@ -765,7 +762,6 @@ namespace OpenRCT2::Ui::Windows PrepareWindowTitleText(); WindowAlignTabs(this, WIDX_TAB_1, WIDX_TAB_7); - AnchorBorderWidgets(); const auto& gameState = getGameState(); _guestProps.series = gameState.guestsInParkHistory; @@ -892,7 +888,6 @@ namespace OpenRCT2::Ui::Windows } WindowAlignTabs(this, WIDX_TAB_1, WIDX_TAB_7); - AnchorBorderWidgets(); } void OnDrawPrice(DrawPixelInfo& dpi) @@ -953,7 +948,6 @@ namespace OpenRCT2::Ui::Windows PrepareWindowTitleText(); WindowAlignTabs(this, WIDX_TAB_1, WIDX_TAB_7); - AnchorBorderWidgets(); } void OnDrawStats(DrawPixelInfo& dpi) @@ -1080,7 +1074,6 @@ namespace OpenRCT2::Ui::Windows widgets[WIDX_ENTER_NAME].type = WindowWidgetType::Empty; WindowAlignTabs(this, WIDX_TAB_1, WIDX_TAB_7); - AnchorBorderWidgets(); } void OnDrawObjective(DrawPixelInfo& dpi) @@ -1146,7 +1139,6 @@ namespace OpenRCT2::Ui::Windows PrepareWindowTitleText(); WindowAlignTabs(this, WIDX_TAB_1, WIDX_TAB_7); - AnchorBorderWidgets(); } void OnDrawAwards(DrawPixelInfo& dpi) @@ -1201,6 +1193,13 @@ namespace OpenRCT2::Ui::Windows Invalidate(); InitScrollWidgets(); + if (page == WINDOW_PARK_PAGE_GUESTS || WINDOW_PARK_PAGE_RATING) + { + // We need to compensate for the enlarged title bar for windows that do not + // constrain the window height between tabs (e.g. chart tabs) + height -= getTitleHeightDiff(); + } + OnResize(); OnPrepareDraw(); OnUpdate(); @@ -1208,11 +1207,6 @@ namespace OpenRCT2::Ui::Windows viewport->flags |= VIEWPORT_FLAG_SOUND_ON; } - void AnchorBorderWidgets() - { - ResizeFrameWithPage(); - } - void SetPressedTab() { for (int32_t i = WIDX_TAB_1; i <= WIDX_TAB_7; i++) diff --git a/src/openrct2-ui/windows/PatrolArea.cpp b/src/openrct2-ui/windows/PatrolArea.cpp index 137b74098a..a06d3199ee 100644 --- a/src/openrct2-ui/windows/PatrolArea.cpp +++ b/src/openrct2-ui/windows/PatrolArea.cpp @@ -58,6 +58,7 @@ namespace OpenRCT2::Ui::Windows void OnOpen() override { SetWidgets(PatrolAreaWidgets); + hold_down_widgets = (1uLL << WIDX_INCREMENT) | (1uLL << WIDX_DECREMENT); WindowInitScrollWidgets(*this); WindowPushOthersBelow(*this); @@ -285,11 +286,6 @@ namespace OpenRCT2::Ui::Windows auto coords = FootpathGetCoordinatesFromPos(pos, nullptr, nullptr); return coords.IsNull() ? std::nullopt : std::make_optional(coords); } - - void OnResize() override - { - ResizeFrame(); - } }; WindowBase* PatrolAreaOpen(EntityId staffId) diff --git a/src/openrct2-ui/windows/Player.cpp b/src/openrct2-ui/windows/Player.cpp index 675be0e2d1..a913b62773 100644 --- a/src/openrct2-ui/windows/Player.cpp +++ b/src/openrct2-ui/windows/Player.cpp @@ -379,7 +379,6 @@ namespace OpenRCT2::Ui::Windows UpdateTitle(); - ResizeFrameWithPage(); widgets[WIDX_LOCATE].right = width - 2; widgets[WIDX_LOCATE].left = width - 25; widgets[WIDX_KICK].right = width - 2; @@ -592,8 +591,6 @@ namespace OpenRCT2::Ui::Windows UpdateTitle(); - ResizeFrameWithPage(); - WindowAlignTabs(this, WIDX_TAB_1, WIDX_TAB_2); } diff --git a/src/openrct2-ui/windows/ProgressWindow.cpp b/src/openrct2-ui/windows/ProgressWindow.cpp index 6a11c9c12a..4ebc4b3889 100644 --- a/src/openrct2-ui/windows/ProgressWindow.cpp +++ b/src/openrct2-ui/windows/ProgressWindow.cpp @@ -83,14 +83,14 @@ namespace OpenRCT2::Ui::Windows void OnOpen() override { Audio::StopSFX(); + SetWidgets(kProgressWindowWidgets); - WindowInitScrollWidgets(*this); WindowSetResize(*this, { kWindowWidth, kWindowHeight }, { kWindowWidth, kWindowHeight }); frame_no = 0; ApplyStyle(); - OnResize(); + ResizeFrame(); } void OnClose() override @@ -119,11 +119,10 @@ namespace OpenRCT2::Ui::Windows void OnPrepareDraw() override { if (_onClose != nullptr) - widgets[WIDX_CLOSE].type = WindowWidgetType::Button; + widgets[WIDX_CLOSE].type = WindowWidgetType::CloseBox; else widgets[WIDX_CLOSE].type = WindowWidgetType::Empty; - ResizeFrame(); PrepareCaption(); } diff --git a/src/openrct2-ui/windows/RefurbishRidePrompt.cpp b/src/openrct2-ui/windows/RefurbishRidePrompt.cpp index cb1286a740..a29138870a 100644 --- a/src/openrct2-ui/windows/RefurbishRidePrompt.cpp +++ b/src/openrct2-ui/windows/RefurbishRidePrompt.cpp @@ -91,16 +91,6 @@ namespace OpenRCT2::Ui::Windows DrawTextWrapped(dpi, stringCoords, WW - 4, stringId, ft, { TextAlignment::CENTRE }); } } - - void OnPrepareDraw() override - { - ResizeFrame(); - } - - void OnResize() override - { - ResizeFrame(); - } }; WindowBase* RideRefurbishPromptOpen(const Ride& ride) diff --git a/src/openrct2-ui/windows/Research.cpp b/src/openrct2-ui/windows/Research.cpp index 65c2bd940b..a4754c04dc 100644 --- a/src/openrct2-ui/windows/Research.cpp +++ b/src/openrct2-ui/windows/Research.cpp @@ -132,12 +132,6 @@ namespace OpenRCT2::Ui::Windows page = newPageIndex; frame_no = 0; - RemoveViewport(); - - hold_down_widgets = 0; - SetWidgets(window_research_page_widgets[newPageIndex]); - disabled_widgets = 0; - pressed_widgets = 0; Invalidate(); if (newPageIndex == WINDOW_RESEARCH_PAGE_DEVELOPMENT) @@ -150,10 +144,12 @@ namespace OpenRCT2::Ui::Windows width = WW_FUNDING; height = WH_FUNDING; } - OnResize(); - - InitScrollWidgets(); Invalidate(); + + SetWidgets(window_research_page_widgets[newPageIndex]); + hold_down_widgets = 0; + disabled_widgets = 0; + pressed_widgets = 0; } private: @@ -272,11 +268,6 @@ namespace OpenRCT2::Ui::Windows } } - void OnResize() override - { - ResizeFrameWithPage(); - } - void DrawTabImage(DrawPixelInfo& dpi, int32_t tabPage, int32_t spriteIndex) { WidgetIndex widgetIndex = WIDX_TAB_1 + tabPage; diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index c58d753e2d..ac9969a6a7 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -815,6 +815,7 @@ namespace OpenRCT2::Ui::Windows break; } } + void OnUpdate() override { switch (page) @@ -1473,11 +1474,6 @@ namespace OpenRCT2::Ui::Windows pressed_widgets |= 1LL << (WIDX_TAB_1 + page); } - void AnchorBorderWidgets() - { - ResizeFrameWithPage(); - } - #pragma region Main std::optional GetStationIndexFromViewSelection() const @@ -2368,8 +2364,6 @@ namespace OpenRCT2::Ui::Windows + WidgetIsPressed(*this, WIDX_OPEN_LIGHT); widgets[WIDX_OPEN_LIGHT].image = ImageId(openLightImage); - AnchorBorderWidgets(); - const int32_t offset = gameState.cheats.allowArbitraryRideTypeChanges ? 15 : 0; // Anchor main page specific widgets widgets[WIDX_VIEWPORT].right = width - 26; @@ -2660,7 +2654,7 @@ namespace OpenRCT2::Ui::Windows void VehicleResize() { - auto bottom = widgets[WIDX_VEHICLE_TRAINS].bottom + 6; + auto bottom = widgets[WIDX_VEHICLE_TRAINS].bottom + 6 - getTitleBarDiffNormal(); WindowSetResize(*this, { kMinimumWindowWidth, bottom }, { kMinimumWindowWidth, bottom }); } @@ -2858,7 +2852,6 @@ namespace OpenRCT2::Ui::Windows ride->formatNameTo(ft); - AnchorBorderWidgets(); WindowAlignTabs(this, WIDX_TAB_1, WIDX_TAB_10); if (abs(ride->numCarsPerTrain - rideEntry->zero_cars) == 1) @@ -2942,7 +2935,7 @@ namespace OpenRCT2::Ui::Windows { auto heightIncrease = minimumPreviewStart - widgets[WIDX_VEHICLE_TRAINS_PREVIEW].top; height += heightIncrease; - ResizeFrameWithPage(); + ResizeFrame(); for (auto i = EnumValue(WIDX_VEHICLE_TRAINS_PREVIEW); i <= WIDX_VEHICLE_CARS_PER_TRAIN_DECREASE; i++) { @@ -3205,7 +3198,7 @@ namespace OpenRCT2::Ui::Windows void OperatingResize() { - auto bottom = widgets[WIDX_SYNCHRONISE_WITH_ADJACENT_STATIONS_CHECKBOX].bottom + 6; + auto bottom = widgets[WIDX_SYNCHRONISE_WITH_ADJACENT_STATIONS_CHECKBOX].bottom + 6 - getTitleBarDiffNormal(); WindowSetResize(*this, { kMinimumWindowWidth, bottom }, { kMinimumWindowWidth, bottom }); } @@ -3686,7 +3679,6 @@ namespace OpenRCT2::Ui::Windows widgets[WIDX_MODE_TWEAK_DECREASE].type = WindowWidgetType::Empty; } - AnchorBorderWidgets(); WindowAlignTabs(this, WIDX_TAB_1, WIDX_TAB_10); } @@ -3776,7 +3768,7 @@ namespace OpenRCT2::Ui::Windows void MaintenanceResize() { - auto bottom = widgets[WIDX_LOCATE_MECHANIC].bottom + 6; + auto bottom = widgets[WIDX_LOCATE_MECHANIC].bottom + 6 - getTitleBarDiffNormal(); WindowSetResize(*this, { kMinimumWindowWidth, bottom }, { kMinimumWindowWidth, bottom }); } @@ -4009,7 +4001,6 @@ namespace OpenRCT2::Ui::Windows widgets[WIDX_INSPECTION_INTERVAL].text = kRideInspectionIntervalNames[ride->inspectionInterval]; - AnchorBorderWidgets(); WindowAlignTabs(this, WIDX_TAB_1, WIDX_TAB_10); if (Config::Get().general.DebuggingTools && NetworkGetMode() == NETWORK_MODE_NONE) @@ -4307,7 +4298,7 @@ namespace OpenRCT2::Ui::Windows void ColourResize() { - auto bottom = widgets[WIDX_VEHICLE_PREVIEW].bottom + 6; + auto bottom = widgets[WIDX_VEHICLE_PREVIEW].bottom + 6 - getTitleBarDiffNormal(); WindowSetResize(*this, { kMinimumWindowWidth, bottom }, { kMinimumWindowWidth, bottom }); } @@ -4817,7 +4808,6 @@ namespace OpenRCT2::Ui::Windows ft.Increment(14); ft.Add(ColourSchemeNames[colourScheme]); - AnchorBorderWidgets(); WindowAlignTabs(this, WIDX_TAB_1, WIDX_TAB_10); } @@ -5243,7 +5233,6 @@ namespace OpenRCT2::Ui::Windows disabled_widgets |= (1uLL << WIDX_MUSIC) | (1uLL << WIDX_MUSIC_DROPDOWN) | (1uLL << WIDX_MUSIC_DATA); } - AnchorBorderWidgets(); WindowAlignTabs(this, WIDX_TAB_1, WIDX_TAB_10); } @@ -5616,7 +5605,6 @@ namespace OpenRCT2::Ui::Windows } } - AnchorBorderWidgets(); WindowAlignTabs(this, WIDX_TAB_1, WIDX_TAB_10); } @@ -5910,7 +5898,7 @@ namespace OpenRCT2::Ui::Windows void GraphsResize() { - WindowSetResize(*this, { kMinimumWindowWidth, 182 }, { std::numeric_limits::max(), 450 }); + WindowSetResize(*this, { kMinimumWindowWidth, 182 }, { kMaxWindowSize.width, 450 }); } void GraphsOnMouseDown(WidgetIndex widgetIndex) @@ -6061,7 +6049,6 @@ namespace OpenRCT2::Ui::Windows widgets[WIDX_GRAPH_VERTICAL].bottom = y; widgets[WIDX_GRAPH_LATERAL].bottom = y; - AnchorBorderWidgets(); WindowAlignTabs(this, WIDX_TAB_1, WIDX_TAB_10); } @@ -6623,7 +6610,6 @@ namespace OpenRCT2::Ui::Windows widgets[WIDX_SECONDARY_PRICE].text = STR_FREE; } - AnchorBorderWidgets(); WindowAlignTabs(this, WIDX_TAB_1, WIDX_TAB_10); } @@ -6822,7 +6808,6 @@ namespace OpenRCT2::Ui::Windows widgets[WIDX_SHOW_GUESTS_QUEUING].type = WindowWidgetType::FlatBtn; } - AnchorBorderWidgets(); WindowAlignTabs(this, WIDX_TAB_1, WIDX_TAB_10); } } diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index dd6fd264d4..f2900d2d67 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -332,7 +332,6 @@ namespace OpenRCT2::Ui::Windows void OnResize() override { - ResizeFrame(); WindowRideConstructionUpdateEnabledTrackPieces(); auto currentRide = GetRide(_currentRideIndex); diff --git a/src/openrct2-ui/windows/RideList.cpp b/src/openrct2-ui/windows/RideList.cpp index c46e3788aa..2227989fe7 100644 --- a/src/openrct2-ui/windows/RideList.cpp +++ b/src/openrct2-ui/windows/RideList.cpp @@ -465,8 +465,6 @@ namespace OpenRCT2::Ui::Windows else pressed_widgets &= ~(1uLL << WIDX_QUICK_DEMOLISH); - ResizeFrameWithPage(); - widgets[WIDX_LIST].right = width - 26; widgets[WIDX_LIST].bottom = height - 15; widgets[WIDX_OPEN_CLOSE_ALL].right = width - 2; diff --git a/src/openrct2-ui/windows/SavePrompt.cpp b/src/openrct2-ui/windows/SavePrompt.cpp index e23fb73b44..e07bdf6515 100644 --- a/src/openrct2-ui/windows/SavePrompt.cpp +++ b/src/openrct2-ui/windows/SavePrompt.cpp @@ -196,11 +196,6 @@ namespace OpenRCT2::Ui::Windows { DrawWidgets(dpi); } - - void OnResize() override - { - ResizeFrame(); - } }; WindowBase* SavePromptOpen() diff --git a/src/openrct2-ui/windows/ScenarioSelect.cpp b/src/openrct2-ui/windows/ScenarioSelect.cpp index 5a05351f2a..3f9b1fd7ee 100644 --- a/src/openrct2-ui/windows/ScenarioSelect.cpp +++ b/src/openrct2-ui/windows/ScenarioSelect.cpp @@ -359,7 +359,6 @@ namespace OpenRCT2::Ui::Windows pressed_widgets |= 1LL << (selected_tab + WIDX_TAB1); - ResizeFrameWithPage(); const int32_t bottomMargin = Config::Get().general.DebuggingTools ? 17 : 5; widgets[WIDX_SCENARIOLIST].right = width - kPreviewPaneWidth; widgets[WIDX_SCENARIOLIST].bottom = height - bottomMargin; diff --git a/src/openrct2-ui/windows/Scenery.cpp b/src/openrct2-ui/windows/Scenery.cpp index 56bb99659b..59d5e74a5a 100644 --- a/src/openrct2-ui/windows/Scenery.cpp +++ b/src/openrct2-ui/windows/Scenery.cpp @@ -68,7 +68,7 @@ namespace OpenRCT2::Ui::Windows { static constexpr StringId WINDOW_TITLE = kStringIdNone; constexpr int32_t WINDOW_SCENERY_MIN_WIDTH = 634; - constexpr int32_t WINDOW_SCENERY_MIN_HEIGHT = 195; + constexpr int32_t WINDOW_SCENERY_MIN_HEIGHT = 195 - kTitleHeightNormal; constexpr int32_t SCENERY_BUTTON_WIDTH = 66; constexpr int32_t SCENERY_BUTTON_HEIGHT = 80; constexpr int32_t InitTabPosX = 3; @@ -370,7 +370,7 @@ namespace OpenRCT2::Ui::Windows ContentUpdateScroll(); } - ResizeFrameWithPage(); + ResizeFrame(); } void OnMouseDown(WidgetIndex widgetIndex) override @@ -637,6 +637,8 @@ namespace OpenRCT2::Ui::Windows void OnPrepareDraw() override { + _actualMinHeight = WINDOW_SCENERY_MIN_HEIGHT + getTitleBarHeight(); + // Set the window title StringId titleStringId = STR_MISCELLANEOUS; const auto tabIndex = _activeTabIndex; @@ -802,7 +804,7 @@ namespace OpenRCT2::Ui::Windows } } - ResizeFrameWithPage(); + ResizeFrame(); widgets[WIDX_SCENERY_LIST].right = windowWidth - 26; widgets[WIDX_SCENERY_LIST].bottom = height - 24; @@ -1369,15 +1371,12 @@ namespace OpenRCT2::Ui::Windows // Add the base widgets SetWidgets(WindowSceneryBaseWidgets); - // Add tabs - _actualMinHeight = WINDOW_SCENERY_MIN_HEIGHT; - int32_t xInit = InitTabPosX; - int32_t tabsInThisRow = 0; - auto hasMisc = GetSceneryTabInfoForMisc() != nullptr; auto maxTabsInThisRow = MaxTabsPerRow - 1 - (hasMisc ? 1 : 0); - ScreenCoordsXY pos = { xInit, InitTabPosY }; + // Add tabs + int32_t tabsInThisRow = 0; + ScreenCoordsXY pos = { InitTabPosX, InitTabPosY + getTitleHeightDiff() }; for (const auto& tabInfo : _tabEntries) { auto widget = MakeTab(pos, STR_STRING_DEFINED_TOOLTIP); @@ -1409,7 +1408,7 @@ namespace OpenRCT2::Ui::Windows tabsInThisRow++; if (tabsInThisRow >= maxTabsInThisRow) { - pos.x = xInit; + pos.x = InitTabPosX; pos.y += TabHeight; tabsInThisRow = 0; _actualMinHeight += TabHeight; diff --git a/src/openrct2-ui/windows/SceneryScatter.cpp b/src/openrct2-ui/windows/SceneryScatter.cpp index 5ea51def92..261399abfb 100644 --- a/src/openrct2-ui/windows/SceneryScatter.cpp +++ b/src/openrct2-ui/windows/SceneryScatter.cpp @@ -58,6 +58,7 @@ namespace OpenRCT2::Ui::Windows void OnOpen() override { SetWidgets(_sceneryScatterWidgets); + hold_down_widgets = (1uLL << WIDX_INCREMENT) | (1uLL << WIDX_DECREMENT); WindowInitScrollWidgets(*this); WindowPushOthersBelow(*this); @@ -193,11 +194,6 @@ namespace OpenRCT2::Ui::Windows dpi, screenCoords - ScreenCoordsXY{ 0, 2 }, STR_LAND_TOOL_SIZE_VALUE, ft, { TextAlignment::CENTRE }); } } - - void OnResize() override - { - ResizeFrame(); - } }; WindowBase* SceneryScatterOpen() diff --git a/src/openrct2-ui/windows/ServerList.cpp b/src/openrct2-ui/windows/ServerList.cpp index 678a71c5b5..54f7f2c608 100644 --- a/src/openrct2-ui/windows/ServerList.cpp +++ b/src/openrct2-ui/windows/ServerList.cpp @@ -515,8 +515,6 @@ namespace OpenRCT2::Ui::Windows void OnPrepareDraw() override { - ResizeFrame(); - int32_t margin = 6; int32_t buttonHeight = 13; int32_t buttonTop = height - margin - buttonHeight - 13; diff --git a/src/openrct2-ui/windows/ServerStart.cpp b/src/openrct2-ui/windows/ServerStart.cpp index 8858520ba0..dea9861890 100644 --- a/src/openrct2-ui/windows/ServerStart.cpp +++ b/src/openrct2-ui/windows/ServerStart.cpp @@ -248,11 +248,6 @@ namespace OpenRCT2::Ui::Windows dpi, windowPos + ScreenCoordsXY{ 6, widgets[WIDX_MAXPLAYERS].top }, STR_MAX_PLAYERS, {}, { colours[1] }); } - void OnResize() override - { - ResizeFrame(); - } - private: char _port[7]; char _name[65]; diff --git a/src/openrct2-ui/windows/ShortcutKeys.cpp b/src/openrct2-ui/windows/ShortcutKeys.cpp index 5b70eed15f..26a6ef1135 100644 --- a/src/openrct2-ui/windows/ShortcutKeys.cpp +++ b/src/openrct2-ui/windows/ShortcutKeys.cpp @@ -189,8 +189,6 @@ namespace OpenRCT2::Ui::Windows InitialiseTabs(); InitialiseWidgets(); InitialiseList(); - - WindowSetResize(*this, { WW, WH }, { WW_SC_MAX, WH_SC_MAX }); } void OnClose() override @@ -201,7 +199,7 @@ namespace OpenRCT2::Ui::Windows void OnResize() override { - WindowSetResize(*this, { min_width, min_height }, { max_width, max_height }); + WindowSetResize(*this, { WW, WH }, { WW_SC_MAX, WH_SC_MAX }); } void OnUpdate() override @@ -240,7 +238,6 @@ namespace OpenRCT2::Ui::Windows void OnPrepareDraw() override { - ResizeFrameWithPage(); widgets[WIDX_SCROLL].right = width - 5; widgets[WIDX_SCROLL].bottom = height - 19; widgets[WIDX_RESET].top = height - 16; @@ -458,6 +455,7 @@ namespace OpenRCT2::Ui::Windows } WindowInitScrollWidgets(*this); + ResizeFrame(); } void SetTab(size_t index) diff --git a/src/openrct2-ui/windows/Sign.cpp b/src/openrct2-ui/windows/Sign.cpp index f22bd394f2..ba93eddeca 100644 --- a/src/openrct2-ui/windows/Sign.cpp +++ b/src/openrct2-ui/windows/Sign.cpp @@ -322,11 +322,6 @@ namespace OpenRCT2::Ui::Windows viewport->flags = Config::Get().general.AlwaysShowGridlines ? VIEWPORT_FLAG_GRIDLINES : VIEWPORT_FLAG_NONE; Invalidate(); } - - void OnResize() override - { - ResizeFrame(); - } }; /** diff --git a/src/openrct2-ui/windows/Staff.cpp b/src/openrct2-ui/windows/Staff.cpp index b48cb9f891..eb770c0710 100644 --- a/src/openrct2-ui/windows/Staff.cpp +++ b/src/openrct2-ui/windows/Staff.cpp @@ -355,8 +355,6 @@ namespace OpenRCT2::Ui::Windows auto ft = Formatter::Common(); staff->FormatNameTo(ft); - - ResizeFrameWithPage(); } void CommonPrepareDrawAfter() diff --git a/src/openrct2-ui/windows/StaffFirePrompt.cpp b/src/openrct2-ui/windows/StaffFirePrompt.cpp index 40a6a3eb0c..38e0cab90a 100644 --- a/src/openrct2-ui/windows/StaffFirePrompt.cpp +++ b/src/openrct2-ui/windows/StaffFirePrompt.cpp @@ -89,11 +89,6 @@ namespace OpenRCT2::Ui::Windows ScreenCoordsXY textCoords(windowPos + ScreenCoordsXY{ WW / 2, (WH / 2) - 3 }); DrawTextWrapped(dpi, textCoords, WW - 4, STR_FIRE_STAFF_ID, ft, { TextAlignment::CENTRE }); } - - void OnResize() override - { - ResizeFrame(); - } }; WindowBase* StaffFirePromptOpen(Peep* peep) diff --git a/src/openrct2-ui/windows/StaffList.cpp b/src/openrct2-ui/windows/StaffList.cpp index ffc89ece0c..8614a47f8b 100644 --- a/src/openrct2-ui/windows/StaffList.cpp +++ b/src/openrct2-ui/windows/StaffList.cpp @@ -165,11 +165,6 @@ namespace OpenRCT2::Ui::Windows } } - void OnResize() override - { - ResizeFrameWithPage(); - } - void OnUpdate() override { auto animPeepType = AnimationPeepType(static_cast(_selectedTab) + 1); @@ -263,7 +258,6 @@ namespace OpenRCT2::Ui::Windows } SetWidgetPressed(WIDX_STAFF_LIST_QUICK_FIRE, _quickFireMode); - ResizeFrameWithPage(); widgets[WIDX_STAFF_LIST_LIST].right = width - 4; widgets[WIDX_STAFF_LIST_LIST].bottom = height - 15; widgets[WIDX_STAFF_LIST_QUICK_FIRE].left = width - 77; diff --git a/src/openrct2-ui/windows/TextInput.cpp b/src/openrct2-ui/windows/TextInput.cpp index 404bf0b78a..24d9197889 100644 --- a/src/openrct2-ui/windows/TextInput.cpp +++ b/src/openrct2-ui/windows/TextInput.cpp @@ -306,12 +306,10 @@ namespace OpenRCT2::Ui::Windows // String length needs to add 12 either side of box +13 for cursor when max length. int32_t numLines{}; GfxWrapString(text, WW - (24 + 13), FontStyle::Medium, nullptr, &numLines); - return numLines * 10 + WH; - } - void OnResize() override - { - ResizeFrame(); + const auto textHeight = numLines * 10; + const auto addedTitleHeight = getTitleBarHeight() - kTitleHeightNormal; + return WH + textHeight + addedTitleHeight; } private: diff --git a/src/openrct2-ui/windows/Themes.cpp b/src/openrct2-ui/windows/Themes.cpp index a9fadfeaf8..0bf07607bf 100644 --- a/src/openrct2-ui/windows/Themes.cpp +++ b/src/openrct2-ui/windows/Themes.cpp @@ -289,8 +289,6 @@ namespace OpenRCT2::Ui::Windows { WindowSetResize(*this, { 320, 270 }, { 320, 450 }); } - - ResizeFrameWithPage(); } void OnUpdate() override @@ -319,7 +317,6 @@ namespace OpenRCT2::Ui::Windows _buttonIndex = -1; } - ResizeFrameWithPage(); widgets[WIDX_THEMES_LIST].right = width - 4; widgets[WIDX_THEMES_LIST].bottom = height - 0x0F; diff --git a/src/openrct2-ui/windows/TileInspector.cpp b/src/openrct2-ui/windows/TileInspector.cpp index cb3f5a2c32..40815e794a 100644 --- a/src/openrct2-ui/windows/TileInspector.cpp +++ b/src/openrct2-ui/windows/TileInspector.cpp @@ -763,7 +763,6 @@ static uint64_t PageDisabledWidgets[] = { Invalidate(); height = min_height; } - ResizeFrame(); } void OnMouseDown(WidgetIndex widgetIndex) override diff --git a/src/openrct2-ui/windows/Tooltip.cpp b/src/openrct2-ui/windows/Tooltip.cpp index e802b2f374..5d3f2349a8 100644 --- a/src/openrct2-ui/windows/Tooltip.cpp +++ b/src/openrct2-ui/windows/Tooltip.cpp @@ -34,19 +34,17 @@ namespace OpenRCT2::Ui::Windows private: u8string _tooltipText; int16_t _tooltipNumLines = 1; + int32_t _textWidth; + int32_t _textHeight; public: TooltipWindow(const OpenRCT2String& message, ScreenCoordsXY screenCoords) { - int32_t textWidth = FormatTextForTooltip(message); - int32_t textHeight = ((_tooltipNumLines + 1) * FontGetLineHeight(FontStyle::Small)); + _textWidth = FormatTextForTooltip(message); + _textHeight = ((_tooltipNumLines + 1) * FontGetLineHeight(FontStyle::Small)); - width = textWidth + 5; - height = textHeight + 4; - - SetWidgets(_tooltipWidgets); - widgets[WIDX_BACKGROUND].right = width; - widgets[WIDX_BACKGROUND].bottom = height; + width = _textWidth + 5; + height = _textHeight + 4; UpdatePosition(screenCoords); } @@ -87,6 +85,14 @@ namespace OpenRCT2::Ui::Windows void OnOpen() override { + SetWidgets(_tooltipWidgets); + + width = _textWidth + 5; + height = _textHeight + 4; + + widgets[WIDX_BACKGROUND].right = width; + widgets[WIDX_BACKGROUND].bottom = height; + ResetTooltipNotShown(); } diff --git a/src/openrct2-ui/windows/TrackDesignManage.cpp b/src/openrct2-ui/windows/TrackDesignManage.cpp index b9a9d31bc3..043c0b8498 100644 --- a/src/openrct2-ui/windows/TrackDesignManage.cpp +++ b/src/openrct2-ui/windows/TrackDesignManage.cpp @@ -72,11 +72,6 @@ namespace OpenRCT2::Ui::Windows void OnMouseUp(WidgetIndex widgetIndex) override; void OnTextInput(WidgetIndex widgetIndex, std::string_view text) override; void OnDraw(DrawPixelInfo& dpi) override; - - void OnResize() override - { - ResizeFrame(); - } }; class TrackDeletePromptWindow final : public Window @@ -93,11 +88,6 @@ namespace OpenRCT2::Ui::Windows void OnOpen() override; void OnMouseUp(WidgetIndex widgetIndex) override; void OnDraw(DrawPixelInfo& dpi) override; - - void OnResize() override - { - ResizeFrame(); - } }; static void WindowTrackDeletePromptOpen(TrackDesignFileRef* tdFileRef); diff --git a/src/openrct2-ui/windows/TrackDesignPlace.cpp b/src/openrct2-ui/windows/TrackDesignPlace.cpp index 428957b005..dd8bd7b452 100644 --- a/src/openrct2-ui/windows/TrackDesignPlace.cpp +++ b/src/openrct2-ui/windows/TrackDesignPlace.cpp @@ -363,11 +363,6 @@ namespace OpenRCT2::Ui::Windows } } - void OnResize() override - { - ResizeFrame(); - } - void ClearProvisionalTemporarily() { if (_hasPlacementGhost) diff --git a/src/openrct2-ui/windows/TrackList.cpp b/src/openrct2-ui/windows/TrackList.cpp index 73aa327eea..19b7f5939c 100644 --- a/src/openrct2-ui/windows/TrackList.cpp +++ b/src/openrct2-ui/windows/TrackList.cpp @@ -740,11 +740,6 @@ namespace OpenRCT2::Ui::Windows } } - void OnResize() override - { - ResizeFrame(); - } - void SetIsBeingUpdated(const bool beingUpdated) { _selectedItemIsBeingUpdated = beingUpdated; diff --git a/src/openrct2-ui/windows/Transparency.cpp b/src/openrct2-ui/windows/Transparency.cpp index 25fa6d37a4..bd00a96d4f 100644 --- a/src/openrct2-ui/windows/Transparency.cpp +++ b/src/openrct2-ui/windows/Transparency.cpp @@ -240,11 +240,6 @@ namespace OpenRCT2::Ui::Windows Config::Get().general.InvisibleSupports = wflags & VIEWPORT_FLAG_INVISIBLE_SUPPORTS; Config::Save(); } - - void OnResize() override - { - ResizeFrame(); - } }; WindowBase* TransparencyOpen() diff --git a/src/openrct2-ui/windows/ViewClipping.cpp b/src/openrct2-ui/windows/ViewClipping.cpp index df733c2294..8f07e3b3d2 100644 --- a/src/openrct2-ui/windows/ViewClipping.cpp +++ b/src/openrct2-ui/windows/ViewClipping.cpp @@ -362,6 +362,7 @@ namespace OpenRCT2::Ui::Windows void OnOpen() override { SetWidgets(_viewClippingWidgets); + this->hold_down_widgets = (1uLL << WIDX_CLIP_HEIGHT_INCREASE) | (1uL << WIDX_CLIP_HEIGHT_DECREASE); WindowInitScrollWidgets(*this); @@ -383,11 +384,6 @@ namespace OpenRCT2::Ui::Windows } } - void OnResize() override - { - ResizeFrame(); - } - private: void OnClose() override { diff --git a/src/openrct2-ui/windows/Viewport.cpp b/src/openrct2-ui/windows/Viewport.cpp index 565053fcc3..ad93b9906d 100644 --- a/src/openrct2-ui/windows/Viewport.cpp +++ b/src/openrct2-ui/windows/Viewport.cpp @@ -187,7 +187,6 @@ namespace OpenRCT2::Ui::Windows void OnPrepareDraw() override { - ResizeFrameWithPage(); widgets[WIDX_ZOOM_IN].left = width - 27; widgets[WIDX_ZOOM_IN].right = width - 2; widgets[WIDX_ZOOM_OUT].left = width - 27; diff --git a/src/openrct2-ui/windows/Water.cpp b/src/openrct2-ui/windows/Water.cpp index 48d67d6fa7..cb90bf988c 100644 --- a/src/openrct2-ui/windows/Water.cpp +++ b/src/openrct2-ui/windows/Water.cpp @@ -58,6 +58,7 @@ namespace OpenRCT2::Ui::Windows void OnOpen() override { SetWidgets(_waterWidgets); + hold_down_widgets = (1uLL << WIDX_INCREMENT) | (1uLL << WIDX_DECREMENT); WindowInitScrollWidgets(*this); WindowPushOthersBelow(*this); @@ -185,11 +186,6 @@ namespace OpenRCT2::Ui::Windows } } - void OnResize() override - { - ResizeFrame(); - } - void OnToolUpdate(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords) override { switch (widgetIndex) diff --git a/src/openrct2/interface/Widget.h b/src/openrct2/interface/Widget.h index 1aabb45ae2..cffcd2f979 100644 --- a/src/openrct2/interface/Widget.h +++ b/src/openrct2/interface/Widget.h @@ -151,6 +151,9 @@ namespace OpenRCT2 } }; + constexpr uint8_t kTitleHeightNormal = 13; + constexpr uint8_t kTitleHeightLarge = 24; + constexpr uint8_t kCloseButtonSize = 10; constexpr uint8_t kCloseButtonSizeTouch = 20; diff --git a/src/openrct2/interface/Window.cpp b/src/openrct2/interface/Window.cpp index aaadad021a..e81d6ed363 100644 --- a/src/openrct2/interface/Window.cpp +++ b/src/openrct2/interface/Window.cpp @@ -975,6 +975,19 @@ static constexpr float kWindowScrollLocations[][2] = { return w->viewport; } + int16_t getTitleBarHeight() + { + return Config::Get().interface.EnlargedUi ? kTitleHeightLarge : kTitleHeightNormal; + } + + int16_t getTitleHeightDiff() + { + if (Config::Get().interface.EnlargedUi) + return kTitleHeightLarge - kTitleHeightNormal; + else + return 0; + } + // TODO: declared in WindowManager.h; move when refactors continue Ui::IWindowManager* Ui::GetWindowManager() { diff --git a/src/openrct2/interface/Window.h b/src/openrct2/interface/Window.h index 9b910c24d6..63f98e3a3d 100644 --- a/src/openrct2/interface/Window.h +++ b/src/openrct2/interface/Window.h @@ -349,4 +349,6 @@ namespace OpenRCT2 void WindowFollowSprite(WindowBase& w, EntityId spriteIndex); void WindowUnfollowSprite(WindowBase& w); + int16_t getTitleBarHeight(); + int16_t getTitleHeightDiff(); } // namespace OpenRCT2 diff --git a/src/openrct2/interface/WindowBase.cpp b/src/openrct2/interface/WindowBase.cpp index 439464eec1..a042c943ce 100644 --- a/src/openrct2/interface/WindowBase.cpp +++ b/src/openrct2/interface/WindowBase.cpp @@ -1,5 +1,6 @@ #include "WindowBase.h" +#include "../config/Config.h" #include "../entity/EntityList.h" #include "../entity/EntityRegistry.h" #include "Cursors.h" @@ -31,10 +32,98 @@ namespace OpenRCT2 { widgets.clear(); widgets.insert(widgets.end(), newWidgets.begin(), newWidgets.end()); + + ResizeFrame(); } CursorID WindowBase::OnCursor(WidgetIndex, const ScreenCoordsXY&, CursorID) { return CursorID::Arrow; } + + static inline void repositionCloseButton(Widget& closeButton, int32_t windowWidth) + { + auto closeButtonSize = Config::Get().interface.EnlargedUi ? kCloseButtonSizeTouch : kCloseButtonSize; + if (Config::Get().interface.WindowButtonsOnTheLeft) + { + closeButton.left = 2; + closeButton.right = 2 + closeButtonSize; + } + else + { + closeButton.left = windowWidth - 3 - closeButtonSize; + closeButton.right = windowWidth - 3; + } + } + + void WindowBase::ResizeFrame() + { + if (widgets.size() < 3) + return; + + // Frame + auto& frameWidget = widgets[0]; + if (frameWidget.type == WindowWidgetType::Frame) + { + frameWidget.right = width - 1; + frameWidget.bottom = height - 1; + } + + // Title/caption + auto& titleWidget = widgets[1]; + bool hasTitleWidget = titleWidget.type == WindowWidgetType::Caption; + if (hasTitleWidget) + titleWidget.right = width - 2; + + // Close button + auto& closeButton = widgets[2]; + if (closeButton.type == WindowWidgetType::CloseBox || closeButton.type == WindowWidgetType::Empty) + repositionCloseButton(closeButton, width); + + // Page/resize widget + if (widgets.size() >= 4) + { + auto& pageWidget = widgets[3]; + if (pageWidget.type == WindowWidgetType::Resize) + { + pageWidget.right = width - 1; + pageWidget.bottom = height - 1; + } + } + + // Figure out if we need to push the other widgets down to accommodate a resized title/caption + auto preferredHeight = getTitleBarHeight(); + auto currentHeight = titleWidget.height(); + auto heightDifference = preferredHeight - currentHeight; + + if (!hasTitleWidget || heightDifference == 0) + return; + + Invalidate(); + + // Offset title and close button + titleWidget.bottom += heightDifference; + closeButton.bottom += heightDifference; + + height += heightDifference; + min_height += heightDifference; + max_height += heightDifference; + + Invalidate(); + + // Resize frame again to match new height + frameWidget.bottom = height - 1; + + // Offset body widgets + // NB: we're offsetting page widget as well! + for (WidgetIndex i = 3; i < widgets.size(); i++) + { + widgets[i].top += heightDifference; + widgets[i].bottom += heightDifference; + } + + // Offset viewport + if (viewport != nullptr) + viewport->pos.y += heightDifference; + } } // namespace OpenRCT2 diff --git a/src/openrct2/interface/WindowBase.h b/src/openrct2/interface/WindowBase.h index cf73442a65..05555b9e73 100644 --- a/src/openrct2/interface/WindowBase.h +++ b/src/openrct2/interface/WindowBase.h @@ -113,6 +113,7 @@ namespace OpenRCT2 void Invalidate(); void RemoveViewport(); void SetWidgets(const std::span newWidgets); + void ResizeFrame(); WindowBase() = default; WindowBase(WindowBase&) = delete;