From fc587f755e7d507ced9f85dce579425ec0fd2566 Mon Sep 17 00:00:00 2001 From: RandomErrorMessage <35673979+RandomErrorMessage@users.noreply.github.com> Date: Wed, 17 Jun 2020 00:20:38 -0700 Subject: [PATCH] SetWindowSizeCallback: user configurable callback --- src/core.c | 11 +++++++++++ src/raylib.h | 1 + 2 files changed, 12 insertions(+) diff --git a/src/core.c b/src/core.c index b180139db..ce99c6324 100644 --- a/src/core.c +++ b/src/core.c @@ -373,6 +373,7 @@ typedef struct CoreData { char **dropFilesPath; // Store dropped files paths as strings int dropFilesCount; // Count dropped files strings + void (*sizeCallback)(int, int); // Additional user configurable window size callback } Window; #if defined(PLATFORM_ANDROID) @@ -1050,6 +1051,11 @@ void SetWindowMinSize(int width, int height) #endif } +// Set window size callback +void SetWindowSizeCallback(void (*callback)(int, int)) { + CORE.Window.sizeCallback = callback; +} + // Set window dimensions // TODO: Issues on HighDPI scaling void SetWindowSize(int width, int height) @@ -3901,6 +3907,8 @@ static void WindowSizeCallback(GLFWwindow *window, int width, int height) // NOTE: Postprocessing texture is not scaled to new size CORE.Window.resized = true; + if (CORE.Window.sizeCallback) + CORE.Window.sizeCallback(width, height); } // GLFW3 WindowIconify Callback, runs when window is minimized/restored @@ -5234,6 +5242,9 @@ void UWPResizeEvent(int width, int height) // NOTE: Postprocessing texture is not scaled to new size CORE.Window.resized = true; + + if (CORE.Window.sizeCallback) + CORE.Window.sizeCallback(width, height); } void UWPActivateGamepadEvent(int gamepad, bool active) diff --git a/src/raylib.h b/src/raylib.h index 19591bdc2..4315d77bc 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -884,6 +884,7 @@ RLAPI void SetWindowPosition(int x, int y); // Set window RLAPI void SetWindowMonitor(int monitor); // Set monitor for the current window (fullscreen mode) RLAPI void SetWindowMinSize(int width, int height); // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE) RLAPI void SetWindowSize(int width, int height); // Set window dimensions +RLAPI void SetWindowSizeCallback(void (*callback)(int, int)); // Set window size callback RLAPI void *GetWindowHandle(void); // Get native window handle RLAPI int GetScreenWidth(void); // Get current screen width RLAPI int GetScreenHeight(void); // Get current screen height