From b0a7bcc37e0ac95aaae6af83c5099a0df0e7d0ae Mon Sep 17 00:00:00 2001 From: drug007 Date: Thu, 4 Jul 2024 18:46:34 +0300 Subject: [PATCH] Fix #45 Broken window resizing --- source/nanogui/screen.d | 8 ++++---- source/nanogui/sdlbackend.d | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/source/nanogui/screen.d b/source/nanogui/screen.d index 9bc13ee..e56ce20 100644 --- a/source/nanogui/screen.d +++ b/source/nanogui/screen.d @@ -387,14 +387,14 @@ class Screen : Widget } /// Window resize event handler - bool resizeEvent(Vector2i size) + bool resizeEvent(Vector2i sz) { + size = sz/mScale; + mNeedToDraw = true; if (mResizeCallback) { mResizeCallback(size); - mNeedToDraw = true; - return true; } - return false; + return true; } Logger logger() { return null; }; diff --git a/source/nanogui/sdlbackend.d b/source/nanogui/sdlbackend.d index daaa196..eeee3bf 100644 --- a/source/nanogui/sdlbackend.d +++ b/source/nanogui/sdlbackend.d @@ -144,6 +144,13 @@ class SdlBackend : Screen return super.mouseButtonCallbackEvent(btn, action, modifiers, Clock.currTime.stdTime); }; + _sdlApp.onResize = delegate(int w, int h) + { + mLastInteraction = Clock.currTime.stdTime; + + resizeEvent(Vector2i(w, h)); + }; + _sdlApp.onKeyboardChar = delegate(dchar codepoint) { return keyboardCharacterEvent(codepoint);