mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-24 00:03:11 +01:00
Move more Ui functions to Ui library (#22444)
* Move various methods into the ui library * Move various zoom functions to ui
This commit is contained in:
@@ -554,7 +554,7 @@ public:
|
|||||||
if (abs(gesturePixels) > tolerance)
|
if (abs(gesturePixels) > tolerance)
|
||||||
{
|
{
|
||||||
_gestureRadius = 0;
|
_gestureRadius = 0;
|
||||||
MainWindowZoom(gesturePixels > 0, true);
|
Windows::MainWindowZoom(gesturePixels > 0, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <openrct2-ui/windows/Window.h>
|
#include <openrct2-ui/windows/Window.h>
|
||||||
#include <openrct2/Context.h>
|
#include <openrct2/Context.h>
|
||||||
|
#include <openrct2/GameState.h>
|
||||||
#include <openrct2/Input.h>
|
#include <openrct2/Input.h>
|
||||||
#include <openrct2/OpenRCT2.h>
|
#include <openrct2/OpenRCT2.h>
|
||||||
#include <openrct2/audio/audio.h>
|
#include <openrct2/audio/audio.h>
|
||||||
@@ -318,9 +319,9 @@ static void WindowViewportWheelInput(WindowBase& w, int32_t wheel)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (wheel < 0)
|
if (wheel < 0)
|
||||||
WindowZoomIn(w, true);
|
Windows::WindowZoomIn(w, true);
|
||||||
else if (wheel > 0)
|
else if (wheel > 0)
|
||||||
WindowZoomOut(w, true);
|
Windows::WindowZoomOut(w, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isSpinnerGroup(WindowBase& w, WidgetIndex index, WindowWidgetType buttonType)
|
static bool isSpinnerGroup(WindowBase& w, WidgetIndex index, WindowWidgetType buttonType)
|
||||||
@@ -481,48 +482,6 @@ void ApplyScreenSaverLockSetting()
|
|||||||
Config::Get().general.DisableScreensaver ? SDL_DisableScreenSaver() : SDL_EnableScreenSaver();
|
Config::Get().general.DisableScreensaver ? SDL_DisableScreenSaver() : SDL_EnableScreenSaver();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* rct2: 0x006EB15C
|
|
||||||
*/
|
|
||||||
void WindowDrawWidgets(WindowBase& w, DrawPixelInfo& dpi)
|
|
||||||
{
|
|
||||||
Widget* widget;
|
|
||||||
WidgetIndex widgetIndex;
|
|
||||||
|
|
||||||
if ((w.flags & WF_TRANSPARENT) && !(w.flags & WF_NO_BACKGROUND))
|
|
||||||
GfxFilterRect(
|
|
||||||
dpi, { w.windowPos, w.windowPos + ScreenCoordsXY{ w.width - 1, w.height - 1 } }, FilterPaletteID::Palette51);
|
|
||||||
|
|
||||||
// todo: some code missing here? Between 006EB18C and 006EB260
|
|
||||||
|
|
||||||
widgetIndex = 0;
|
|
||||||
for (widget = w.widgets; widget->type != WindowWidgetType::Last; widget++)
|
|
||||||
{
|
|
||||||
if (widget->IsVisible())
|
|
||||||
{
|
|
||||||
// Check if widget is outside the draw region
|
|
||||||
if (w.windowPos.x + widget->left < dpi.x + dpi.width && w.windowPos.x + widget->right >= dpi.x)
|
|
||||||
{
|
|
||||||
if (w.windowPos.y + widget->top < dpi.y + dpi.height && w.windowPos.y + widget->bottom >= dpi.y)
|
|
||||||
{
|
|
||||||
w.OnDrawWidget(widgetIndex, dpi);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
widgetIndex++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo: something missing here too? Between 006EC32B and 006EC369
|
|
||||||
|
|
||||||
if (w.flags & WF_WHITE_BORDER_MASK)
|
|
||||||
{
|
|
||||||
GfxFillRectInset(
|
|
||||||
dpi, { w.windowPos, w.windowPos + ScreenCoordsXY{ w.width - 1, w.height - 1 } }, { COLOUR_WHITE },
|
|
||||||
INSET_RECT_FLAG_FILL_NONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* rct2: 0x006EA776
|
* rct2: 0x006EA776
|
||||||
@@ -543,9 +502,21 @@ static void WindowInvalidatePressedImageButton(const WindowBase& w)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Window::ScrollToViewport()
|
||||||
|
{
|
||||||
|
if (viewport == nullptr || !focus.has_value())
|
||||||
|
return;
|
||||||
|
|
||||||
|
CoordsXYZ newCoords = focus.value().GetPos();
|
||||||
|
|
||||||
|
auto mainWindow = WindowGetMain();
|
||||||
|
if (mainWindow != nullptr)
|
||||||
|
WindowScrollToLocation(*mainWindow, newCoords);
|
||||||
|
}
|
||||||
|
|
||||||
void Window::OnDraw(DrawPixelInfo& dpi)
|
void Window::OnDraw(DrawPixelInfo& dpi)
|
||||||
{
|
{
|
||||||
WindowDrawWidgets(*this, dpi);
|
Windows::WindowDrawWidgets(*this, dpi);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::OnDrawWidget(WidgetIndex widgetIndex, DrawPixelInfo& dpi)
|
void Window::OnDrawWidget(WidgetIndex widgetIndex, DrawPixelInfo& dpi)
|
||||||
@@ -605,7 +576,7 @@ void Window::SetCheckboxValue(WidgetIndex widgetIndex, bool value)
|
|||||||
|
|
||||||
void Window::DrawWidgets(DrawPixelInfo& dpi)
|
void Window::DrawWidgets(DrawPixelInfo& dpi)
|
||||||
{
|
{
|
||||||
WindowDrawWidgets(*this, dpi);
|
Windows::WindowDrawWidgets(*this, dpi);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::Close()
|
void Window::Close()
|
||||||
@@ -658,6 +629,69 @@ void Window::TextInputOpen(
|
|||||||
this, callWidget, title, description, descriptionArgs, existingText, existingArgs, maxLength);
|
this, callWidget, title, description, descriptionArgs, existingText, existingArgs, maxLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Window::ResizeFrame()
|
||||||
|
{
|
||||||
|
// Frame
|
||||||
|
widgets[0].right = width - 1;
|
||||||
|
widgets[0].bottom = height - 1;
|
||||||
|
// Title
|
||||||
|
widgets[1].right = width - 2;
|
||||||
|
// Close button
|
||||||
|
if (Config::Get().interface.WindowButtonsOnTheLeft)
|
||||||
|
{
|
||||||
|
widgets[2].left = 2;
|
||||||
|
widgets[2].right = 2 + kCloseButtonWidth;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
widgets[2].left = width - 3 - kCloseButtonWidth;
|
||||||
|
widgets[2].right = width - 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Window::ResizeFrameWithPage()
|
||||||
|
{
|
||||||
|
ResizeFrame();
|
||||||
|
// Page background
|
||||||
|
widgets[3].right = width - 1;
|
||||||
|
widgets[3].bottom = height - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Window::ResizeSpinner(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; // 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;
|
||||||
|
|
||||||
|
widgets[widgetIndex + 2].left = right - size.height * 2;
|
||||||
|
widgets[widgetIndex + 2].top = origin.y + 1;
|
||||||
|
widgets[widgetIndex + 2].right = right - size.height - 1;
|
||||||
|
widgets[widgetIndex + 2].bottom = bottom - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Window::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;
|
||||||
|
}
|
||||||
|
|
||||||
void WindowAlignTabs(WindowBase* w, WidgetIndex start_tab_id, WidgetIndex end_tab_id)
|
void WindowAlignTabs(WindowBase* w, WidgetIndex start_tab_id, WidgetIndex end_tab_id)
|
||||||
{
|
{
|
||||||
int32_t i, x = w->widgets[start_tab_id].left;
|
int32_t i, x = w->widgets[start_tab_id].left;
|
||||||
@@ -1255,4 +1289,98 @@ namespace OpenRCT2::Ui::Windows
|
|||||||
w->OnResize();
|
w->OnResize();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* rct2: 0x00685BE1
|
||||||
|
*
|
||||||
|
* @param dpi (edi)
|
||||||
|
* @param w (esi)
|
||||||
|
*/
|
||||||
|
void WindowDrawViewport(DrawPixelInfo& dpi, WindowBase& w)
|
||||||
|
{
|
||||||
|
ViewportRender(dpi, w.viewport, { { dpi.x, dpi.y }, { dpi.x + dpi.width, dpi.y + dpi.height } });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* rct2: 0x006EB15C
|
||||||
|
*/
|
||||||
|
void WindowDrawWidgets(WindowBase& w, DrawPixelInfo& dpi)
|
||||||
|
{
|
||||||
|
Widget* widget;
|
||||||
|
WidgetIndex widgetIndex;
|
||||||
|
|
||||||
|
if ((w.flags & WF_TRANSPARENT) && !(w.flags & WF_NO_BACKGROUND))
|
||||||
|
GfxFilterRect(
|
||||||
|
dpi, { w.windowPos, w.windowPos + ScreenCoordsXY{ w.width - 1, w.height - 1 } }, FilterPaletteID::Palette51);
|
||||||
|
|
||||||
|
// todo: some code missing here? Between 006EB18C and 006EB260
|
||||||
|
|
||||||
|
widgetIndex = 0;
|
||||||
|
for (widget = w.widgets; widget->type != WindowWidgetType::Last; widget++)
|
||||||
|
{
|
||||||
|
if (widget->IsVisible())
|
||||||
|
{
|
||||||
|
// Check if widget is outside the draw region
|
||||||
|
if (w.windowPos.x + widget->left < dpi.x + dpi.width && w.windowPos.x + widget->right >= dpi.x)
|
||||||
|
{
|
||||||
|
if (w.windowPos.y + widget->top < dpi.y + dpi.height && w.windowPos.y + widget->bottom >= dpi.y)
|
||||||
|
{
|
||||||
|
w.OnDrawWidget(widgetIndex, dpi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
widgetIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// todo: something missing here too? Between 006EC32B and 006EC369
|
||||||
|
|
||||||
|
if (w.flags & WF_WHITE_BORDER_MASK)
|
||||||
|
{
|
||||||
|
GfxFillRectInset(
|
||||||
|
dpi, { w.windowPos, w.windowPos + ScreenCoordsXY{ w.width - 1, w.height - 1 } }, { COLOUR_WHITE },
|
||||||
|
INSET_RECT_FLAG_FILL_NONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* rct2: 0x006887A6
|
||||||
|
*/
|
||||||
|
void WindowZoomIn(WindowBase& w, bool atCursor)
|
||||||
|
{
|
||||||
|
WindowZoomSet(w, w.viewport->zoom - 1, atCursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* rct2: 0x006887E0
|
||||||
|
*/
|
||||||
|
void WindowZoomOut(WindowBase& w, bool atCursor)
|
||||||
|
{
|
||||||
|
WindowZoomSet(w, w.viewport->zoom + 1, atCursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindowZoom(bool zoomIn, bool atCursor)
|
||||||
|
{
|
||||||
|
auto* mainWindow = WindowGetMain();
|
||||||
|
if (mainWindow == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR && GetGameState().EditorStep != EditorStep::LandscapeEditor)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (zoomIn)
|
||||||
|
WindowZoomIn(*mainWindow, atCursor);
|
||||||
|
else
|
||||||
|
WindowZoomOut(*mainWindow, atCursor);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace OpenRCT2::Ui::Windows
|
} // namespace OpenRCT2::Ui::Windows
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ struct Window : WindowBase
|
|||||||
virtual void OnDraw(DrawPixelInfo& dpi) override;
|
virtual void OnDraw(DrawPixelInfo& dpi) override;
|
||||||
virtual void OnDrawWidget(WidgetIndex widgetIndex, DrawPixelInfo& dpi) override;
|
virtual void OnDrawWidget(WidgetIndex widgetIndex, DrawPixelInfo& dpi) override;
|
||||||
|
|
||||||
|
void ScrollToViewport();
|
||||||
void InitScrollWidgets();
|
void InitScrollWidgets();
|
||||||
void InvalidateWidget(WidgetIndex widgetIndex);
|
void InvalidateWidget(WidgetIndex widgetIndex);
|
||||||
bool IsWidgetDisabled(WidgetIndex widgetIndex) const;
|
bool IsWidgetDisabled(WidgetIndex widgetIndex) const;
|
||||||
@@ -36,6 +37,12 @@ struct Window : WindowBase
|
|||||||
void TextInputOpen(
|
void TextInputOpen(
|
||||||
WidgetIndex callWidget, StringId title, StringId description, const Formatter& descriptionArgs, StringId existingText,
|
WidgetIndex callWidget, StringId title, StringId description, const Formatter& descriptionArgs, StringId existingText,
|
||||||
uintptr_t existingArgs, int32_t maxLength);
|
uintptr_t existingArgs, int32_t maxLength);
|
||||||
|
|
||||||
|
void ResizeFrame();
|
||||||
|
void ResizeFrameWithPage();
|
||||||
|
|
||||||
|
void ResizeSpinner(WidgetIndex widgetIndex, const ScreenCoordsXY& origin, const ScreenSize& size);
|
||||||
|
void ResizeDropdown(WidgetIndex widgetIndex, const ScreenCoordsXY& origin, const ScreenSize& size);
|
||||||
};
|
};
|
||||||
|
|
||||||
void WindowAllWheelInput();
|
void WindowAllWheelInput();
|
||||||
@@ -136,4 +143,11 @@ namespace OpenRCT2::Ui::Windows
|
|||||||
bool WindowCanResize(const WindowBase& w);
|
bool WindowCanResize(const WindowBase& w);
|
||||||
|
|
||||||
void InvalidateAllWindowsAfterInput();
|
void InvalidateAllWindowsAfterInput();
|
||||||
|
|
||||||
|
void WindowDrawWidgets(WindowBase& w, DrawPixelInfo& dpi);
|
||||||
|
void WindowDrawViewport(DrawPixelInfo& dpi, WindowBase& w);
|
||||||
|
|
||||||
|
void WindowZoomIn(WindowBase& w, bool atCursor);
|
||||||
|
void WindowZoomOut(WindowBase& w, bool atCursor);
|
||||||
|
void MainWindowZoom(bool zoomIn, bool atCursor);
|
||||||
} // namespace OpenRCT2::Ui::Windows
|
} // namespace OpenRCT2::Ui::Windows
|
||||||
|
|||||||
@@ -960,45 +960,6 @@ void WindowZoomSet(WindowBase& w, ZoomLevel zoomLevel, bool atCursor)
|
|||||||
w.Invalidate();
|
w.Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* rct2: 0x006887A6
|
|
||||||
*/
|
|
||||||
void WindowZoomIn(WindowBase& w, bool atCursor)
|
|
||||||
{
|
|
||||||
WindowZoomSet(w, w.viewport->zoom - 1, atCursor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* rct2: 0x006887E0
|
|
||||||
*/
|
|
||||||
void WindowZoomOut(WindowBase& w, bool atCursor)
|
|
||||||
{
|
|
||||||
WindowZoomSet(w, w.viewport->zoom + 1, atCursor);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindowZoom(bool zoomIn, bool atCursor)
|
|
||||||
{
|
|
||||||
auto* mainWindow = WindowGetMain();
|
|
||||||
if (mainWindow == nullptr)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR && GetGameState().EditorStep != EditorStep::LandscapeEditor)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (zoomIn)
|
|
||||||
WindowZoomIn(*mainWindow, atCursor);
|
|
||||||
else
|
|
||||||
WindowZoomOut(*mainWindow, atCursor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Splits a drawing of a window into regions that can be seen and are not hidden
|
* Splits a drawing of a window into regions that can be seen and are not hidden
|
||||||
* by other opaque overlapping windows.
|
* by other opaque overlapping windows.
|
||||||
@@ -1142,18 +1103,6 @@ static void WindowDrawSingle(DrawPixelInfo& dpi, WindowBase& w, int32_t left, in
|
|||||||
w.OnDraw(copy);
|
w.OnDraw(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* rct2: 0x00685BE1
|
|
||||||
*
|
|
||||||
* @param dpi (edi)
|
|
||||||
* @param w (esi)
|
|
||||||
*/
|
|
||||||
void WindowDrawViewport(DrawPixelInfo& dpi, WindowBase& w)
|
|
||||||
{
|
|
||||||
ViewportRender(dpi, w.viewport, { { dpi.x, dpi.y }, { dpi.x + dpi.width, dpi.y + dpi.height } });
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* rct2: 0x006EE212
|
* rct2: 0x006EE212
|
||||||
@@ -1481,66 +1430,3 @@ Viewport* WindowGetViewport(WindowBase* w)
|
|||||||
|
|
||||||
return w->viewport;
|
return w->viewport;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowBase::ResizeFrame()
|
|
||||||
{
|
|
||||||
// Frame
|
|
||||||
widgets[0].right = width - 1;
|
|
||||||
widgets[0].bottom = height - 1;
|
|
||||||
// Title
|
|
||||||
widgets[1].right = width - 2;
|
|
||||||
// Close button
|
|
||||||
if (Config::Get().interface.WindowButtonsOnTheLeft)
|
|
||||||
{
|
|
||||||
widgets[2].left = 2;
|
|
||||||
widgets[2].right = 2 + kCloseButtonWidth;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
widgets[2].left = width - 3 - kCloseButtonWidth;
|
|
||||||
widgets[2].right = width - 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowBase::ResizeFrameWithPage()
|
|
||||||
{
|
|
||||||
ResizeFrame();
|
|
||||||
// Page background
|
|
||||||
widgets[3].right = width - 1;
|
|
||||||
widgets[3].bottom = height - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowBase::ResizeSpinner(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; // 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;
|
|
||||||
|
|
||||||
widgets[widgetIndex + 2].left = right - size.height * 2;
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -540,14 +540,9 @@ void WindowViewportGetMapCoordsByCursor(
|
|||||||
void WindowViewportCentreTileAroundCursor(WindowBase& w, int32_t map_x, int32_t map_y, int32_t offset_x, int32_t offset_y);
|
void WindowViewportCentreTileAroundCursor(WindowBase& w, int32_t map_x, int32_t map_y, int32_t offset_x, int32_t offset_y);
|
||||||
void WindowCheckAllValidZoom();
|
void WindowCheckAllValidZoom();
|
||||||
void WindowZoomSet(WindowBase& w, ZoomLevel zoomLevel, bool atCursor);
|
void WindowZoomSet(WindowBase& w, ZoomLevel zoomLevel, bool atCursor);
|
||||||
void WindowZoomIn(WindowBase& w, bool atCursor);
|
|
||||||
void WindowZoomOut(WindowBase& w, bool atCursor);
|
|
||||||
void MainWindowZoom(bool zoomIn, bool atCursor);
|
|
||||||
|
|
||||||
void WindowDrawAll(DrawPixelInfo& dpi, int32_t left, int32_t top, int32_t right, int32_t bottom);
|
void WindowDrawAll(DrawPixelInfo& dpi, int32_t left, int32_t top, int32_t right, int32_t bottom);
|
||||||
void WindowDraw(DrawPixelInfo& dpi, WindowBase& w, int32_t left, int32_t top, int32_t right, int32_t bottom);
|
void WindowDraw(DrawPixelInfo& dpi, WindowBase& w, int32_t left, int32_t top, int32_t right, int32_t bottom);
|
||||||
void WindowDrawWidgets(WindowBase& w, DrawPixelInfo& dpi);
|
|
||||||
void WindowDrawViewport(DrawPixelInfo& dpi, WindowBase& w);
|
|
||||||
|
|
||||||
bool ToolSet(const WindowBase& w, WidgetIndex widgetIndex, Tool tool);
|
bool ToolSet(const WindowBase& w, WidgetIndex widgetIndex, Tool tool);
|
||||||
void ToolCancel();
|
void ToolCancel();
|
||||||
|
|||||||
@@ -11,18 +11,6 @@ void WindowBase::SetLocation(const CoordsXYZ& coords)
|
|||||||
flags &= ~WF_SCROLLING_TO_LOCATION;
|
flags &= ~WF_SCROLLING_TO_LOCATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowBase::ScrollToViewport()
|
|
||||||
{
|
|
||||||
if (viewport == nullptr || !focus.has_value())
|
|
||||||
return;
|
|
||||||
|
|
||||||
CoordsXYZ newCoords = focus.value().GetPos();
|
|
||||||
|
|
||||||
auto mainWindow = WindowGetMain();
|
|
||||||
if (mainWindow != nullptr)
|
|
||||||
WindowScrollToLocation(*mainWindow, newCoords);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowBase::Invalidate()
|
void WindowBase::Invalidate()
|
||||||
{
|
{
|
||||||
GfxSetDirtyBlocks({ windowPos, windowPos + ScreenCoordsXY{ width, height } });
|
GfxSetDirtyBlocks({ windowPos, windowPos + ScreenCoordsXY{ width, height } });
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ struct WindowBase
|
|||||||
EntityId viewport_smart_follow_sprite{ EntityId::GetNull() }; // Handles setting viewport target sprite etc
|
EntityId viewport_smart_follow_sprite{ EntityId::GetNull() }; // Handles setting viewport target sprite etc
|
||||||
|
|
||||||
void SetLocation(const CoordsXYZ& coords);
|
void SetLocation(const CoordsXYZ& coords);
|
||||||
void ScrollToViewport();
|
|
||||||
void Invalidate();
|
void Invalidate();
|
||||||
void RemoveViewport();
|
void RemoveViewport();
|
||||||
|
|
||||||
@@ -166,12 +165,6 @@ struct WindowBase
|
|||||||
virtual void OnLanguageChange()
|
virtual void OnLanguageChange()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResizeFrame();
|
|
||||||
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__
|
#ifdef __WARN_SUGGEST_FINAL_METHODS__
|
||||||
|
|||||||
Reference in New Issue
Block a user