mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-14 12:09:36 +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
|
||||
|
||||
Reference in New Issue
Block a user