mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-23 06:53:43 +00:00
Keep level editor windows in screen bounds
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include "House.h"
|
||||
#include "InputManager.h"
|
||||
#include "ObjectEdit.h"
|
||||
#include "Rect2i.h"
|
||||
#include "WindowManager.h"
|
||||
|
||||
|
||||
@@ -30,6 +31,7 @@ void HandleIdleTask (void);
|
||||
void IncrementMode (void);
|
||||
|
||||
|
||||
|
||||
long lastUp, incrementModeTime;
|
||||
UInt32 doubleTime;
|
||||
Point lastWhere;
|
||||
@@ -440,6 +442,22 @@ void HandleSplashResolutionChange(void)
|
||||
//DumpScreenOn(&justRoomsRect);
|
||||
}
|
||||
|
||||
void KeepWindowInBounds(Window *window)
|
||||
{
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
PortabilityLayer::Rect2i windowRect = PortabilityLayer::WindowManager::GetInstance()->GetWindowFullRect(window);
|
||||
|
||||
int32_t topNudge = std::max<int32_t>(kScoreboardTall - windowRect.Top(), 0);
|
||||
int32_t bottomNudge = std::min<int32_t>(thisMac.fullScreen.bottom - windowRect.Bottom(), 0);
|
||||
int32_t leftNudge = std::max<int32_t>(-windowRect.Left(), 0);
|
||||
int32_t rightNudge = std::min<int32_t>(thisMac.fullScreen.right - windowRect.Right(), 0);
|
||||
|
||||
window->m_wmX += leftNudge + rightNudge;
|
||||
window->m_wmY += topNudge + bottomNudge;
|
||||
}
|
||||
|
||||
void HandleEditorResolutionChange(void)
|
||||
{
|
||||
FlushResolutionChange();
|
||||
@@ -461,6 +479,10 @@ void HandleEditorResolutionChange(void)
|
||||
|
||||
if (mapWindow)
|
||||
PortabilityLayer::WindowManager::GetInstance()->PutWindowBehind(mapWindow, PortabilityLayer::WindowManager::GetInstance()->GetPutInFrontSentinel());
|
||||
|
||||
KeepWindowInBounds(mainWindow);
|
||||
KeepWindowInBounds(toolsWindow);
|
||||
KeepWindowInBounds(mapWindow);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- HandleIdleTask
|
||||
|
@@ -32,7 +32,7 @@
|
||||
void DrawOnSplash (DrawSurface *surface);
|
||||
void SetPaletteToGrays (void);
|
||||
void HardDrawMainWindow (void);
|
||||
|
||||
void KeepWindowInBounds(Window *window);
|
||||
|
||||
CTabHandle theCTab;
|
||||
PixMapHandle thePMap;
|
||||
@@ -207,6 +207,8 @@ void OpenMainWindow (void)
|
||||
whichRoom = GetFirstRoomNumber();
|
||||
CopyRoomToThisRoom(whichRoom);
|
||||
ReflectCurrentRoom(false);
|
||||
|
||||
KeepWindowInBounds(mainWindow);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -40,6 +40,7 @@ void LiveVScrollAction (ControlHandle, short);
|
||||
Boolean QueryNewRoom (void);
|
||||
void CreateNailOffscreen (void);
|
||||
void KillNailOffscreen (void);
|
||||
void KeepWindowInBounds (Window *window);
|
||||
|
||||
Rect nailSrcRect, activeRoomRect, wasActiveRoomRect;
|
||||
Rect mapHScrollRect, mapVScrollRect, mapCenterRect;
|
||||
@@ -430,6 +431,8 @@ void OpenMapWindow (void)
|
||||
CenterMapOnRoom(thisRoom->suite, thisRoom->floor);
|
||||
|
||||
UpdateMapWindow();
|
||||
|
||||
KeepWindowInBounds(mapWindow);
|
||||
}
|
||||
|
||||
UpdateMapCheckmark(true);
|
||||
|
@@ -61,6 +61,7 @@ void FrameSelectedTool (DrawSurface *);
|
||||
void DrawToolName (DrawSurface *);
|
||||
void DrawToolTiles (DrawSurface *);
|
||||
void SwitchToolModes (short);
|
||||
void KeepWindowInBounds (Window *window);
|
||||
|
||||
|
||||
Rect toolsWindowRect, toolSrcRect, toolTextRect;
|
||||
@@ -350,6 +351,8 @@ void OpenToolsWindow (void)
|
||||
|
||||
SwitchToolModes(toolMode);
|
||||
toolSelected = kSelectTool;
|
||||
|
||||
KeepWindowInBounds(toolsWindow);
|
||||
}
|
||||
|
||||
UpdateToolsCheckmark(true);
|
||||
|
@@ -14,6 +14,7 @@
|
||||
#include "QDManager.h"
|
||||
#include "QDPixMap.h"
|
||||
#include "PLTimeTaggedVOSEvent.h"
|
||||
#include "Rect2i.h"
|
||||
#include "Vec2i.h"
|
||||
#include "WindowDef.h"
|
||||
|
||||
@@ -129,6 +130,7 @@ namespace PortabilityLayer
|
||||
void DestroyWindow(Window *window) override;
|
||||
void DragWindow(Window *window, const Point &startPoint, const Rect &constraintRect) override;
|
||||
void SetWindowTitle(Window *window, const PLPasStr &title) override;
|
||||
Rect2i GetWindowFullRect(Window *window) const override;
|
||||
|
||||
void RenderFrame(IGpDisplayDriver *displayDriver) override;
|
||||
|
||||
@@ -797,6 +799,18 @@ namespace PortabilityLayer
|
||||
static_cast<WindowImpl*>(window)->SetTitle(title);
|
||||
}
|
||||
|
||||
Rect2i WindowManagerImpl::GetWindowFullRect(Window *window) const
|
||||
{
|
||||
WindowImpl *windowImpl = static_cast<WindowImpl*>(window);
|
||||
|
||||
uint16_t padding[WindowChromeSides::kCount];
|
||||
windowImpl->GetChromePadding(padding);
|
||||
|
||||
const Rect portRect = windowImpl->m_surface.m_port.GetRect();
|
||||
|
||||
return Rect2i(window->m_wmY - padding[WindowChromeSides::kTop], window->m_wmX - padding[WindowChromeSides::kLeft], window->m_wmY + portRect.Height() + padding[WindowChromeSides::kBottom], window->m_wmX + portRect.Width() + padding[WindowChromeSides::kRight]);
|
||||
}
|
||||
|
||||
void WindowManagerImpl::RenderFrame(IGpDisplayDriver *displayDriver)
|
||||
{
|
||||
PortabilityLayer::DisplayDeviceManager *dd = PortabilityLayer::DisplayDeviceManager::GetInstance();
|
||||
|
@@ -14,6 +14,7 @@ struct Window;
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
struct WindowDef;
|
||||
struct Rect2i;
|
||||
|
||||
class WindowManager
|
||||
{
|
||||
@@ -29,6 +30,7 @@ namespace PortabilityLayer
|
||||
virtual void DestroyWindow(Window *window) = 0;
|
||||
virtual void DragWindow(Window *window, const Point &startPoint, const Rect &constraintRect) = 0;
|
||||
virtual void SetWindowTitle(Window *window, const PLPasStr &title) = 0;
|
||||
virtual Rect2i GetWindowFullRect(Window *window) const = 0;
|
||||
|
||||
virtual void RenderFrame(IGpDisplayDriver *displayDriver) = 0;
|
||||
|
||||
|
Reference in New Issue
Block a user