SetWindowSizeCallback: user configurable callback

This commit is contained in:
RandomErrorMessage 2020-06-17 00:20:38 -07:00
parent c078640fa5
commit fc587f755e
2 changed files with 12 additions and 0 deletions

View File

@ -373,6 +373,7 @@ typedef struct CoreData {
char **dropFilesPath; // Store dropped files paths as strings char **dropFilesPath; // Store dropped files paths as strings
int dropFilesCount; // Count dropped files strings int dropFilesCount; // Count dropped files strings
void (*sizeCallback)(int, int); // Additional user configurable window size callback
} Window; } Window;
#if defined(PLATFORM_ANDROID) #if defined(PLATFORM_ANDROID)
@ -1050,6 +1051,11 @@ void SetWindowMinSize(int width, int height)
#endif #endif
} }
// Set window size callback
void SetWindowSizeCallback(void (*callback)(int, int)) {
CORE.Window.sizeCallback = callback;
}
// Set window dimensions // Set window dimensions
// TODO: Issues on HighDPI scaling // TODO: Issues on HighDPI scaling
void SetWindowSize(int width, int height) 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 // NOTE: Postprocessing texture is not scaled to new size
CORE.Window.resized = true; CORE.Window.resized = true;
if (CORE.Window.sizeCallback)
CORE.Window.sizeCallback(width, height);
} }
// GLFW3 WindowIconify Callback, runs when window is minimized/restored // 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 // NOTE: Postprocessing texture is not scaled to new size
CORE.Window.resized = true; CORE.Window.resized = true;
if (CORE.Window.sizeCallback)
CORE.Window.sizeCallback(width, height);
} }
void UWPActivateGamepadEvent(int gamepad, bool active) void UWPActivateGamepadEvent(int gamepad, bool active)

View File

@ -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 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 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 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 void *GetWindowHandle(void); // Get native window handle
RLAPI int GetScreenWidth(void); // Get current screen width RLAPI int GetScreenWidth(void); // Get current screen width
RLAPI int GetScreenHeight(void); // Get current screen height RLAPI int GetScreenHeight(void); // Get current screen height