Add window resize handling on Mac

This commit is contained in:
Wojtek Figat
2022-01-18 16:51:03 +01:00
parent 54db90e040
commit dd5bad1dfe
2 changed files with 19 additions and 0 deletions

View File

@@ -181,6 +181,13 @@ Vector2 GetMousePosition(MacWindow* window, NSEvent* event)
Window->Close(ClosingReason::User);
}
- (void)windowDidResize:(NSNotification*)notification
{
NSView* view = [self contentView];
NSRect contextRect = [view frame];
Window->CheckForResize((float)contextRect.size.width, (float)contextRect.size.height);
}
- (void)setWindow:(MacWindow*)window
{
Window = window;
@@ -466,6 +473,16 @@ MacWindow::~MacWindow()
_window = nullptr;
}
void MacWindow::CheckForResize(float width, float height)
{
const Vector2 clientSize(width, height);
if (clientSize != _clientSize)
{
_clientSize = clientSize;
OnResize(width, height);
}
}
void* MacWindow::GetNativePtr() const
{
return _window;

View File

@@ -22,6 +22,8 @@ public:
MacWindow(const CreateWindowSettings& settings);
~MacWindow();
void CheckForResize(float width, float height);
public:
// [Window]