mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-24 08:15:50 +00:00
Added SDL_SetWindowAspectRatio() and SDL_GetWindowAspectRatio()
Fixes https://github.com/libsdl-org/SDL/issues/1573
This commit is contained in:
@@ -76,6 +76,8 @@ typedef struct
|
||||
int window_minH;
|
||||
int window_maxW;
|
||||
int window_maxH;
|
||||
float window_min_aspect;
|
||||
float window_max_aspect;
|
||||
int logical_w;
|
||||
int logical_h;
|
||||
SDL_bool auto_scale_content;
|
||||
@@ -84,6 +86,7 @@ typedef struct
|
||||
float scale;
|
||||
int depth;
|
||||
float refresh_rate;
|
||||
SDL_bool fill_usable_bounds;
|
||||
SDL_bool fullscreen_exclusive;
|
||||
SDL_DisplayMode fullscreen_mode;
|
||||
int num_windows;
|
||||
|
||||
@@ -1346,9 +1346,6 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetWindowPosition(SDL_Window *window, int *x
|
||||
/**
|
||||
* Request that the size of a window's client area be set.
|
||||
*
|
||||
* NULL can safely be passed as the `w` or `h` parameter if the width or
|
||||
* height value is not desired.
|
||||
*
|
||||
* If, at the time of this request, the window in a fixed-size state, such as
|
||||
* maximized or fullscreen, the request will be deferred until the window
|
||||
* exits this state and becomes resizable again.
|
||||
@@ -1385,9 +1382,6 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetWindowSize(SDL_Window *window, int w, int
|
||||
/**
|
||||
* Get the size of a window's client area.
|
||||
*
|
||||
* NULL can safely be passed as the `w` or `h` parameter if the width or
|
||||
* height value is not desired.
|
||||
*
|
||||
* The window pixel size may differ from its window coordinate size if the
|
||||
* window is on a high pixel density display. Use SDL_GetWindowSizeInPixels()
|
||||
* or SDL_GetRenderOutputSize() to get the real client area size in pixels.
|
||||
@@ -1406,6 +1400,55 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetWindowSize(SDL_Window *window, int w, int
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetWindowSize(SDL_Window *window, int *w, int *h);
|
||||
|
||||
/**
|
||||
* Request that the aspect ratio of a window's client area be set.
|
||||
*
|
||||
* The aspect ratio is the ratio of width divided by height, e.g. 2560x1600 would be 1.6. Larger aspect ratios are wider and smaller aspect ratios are narrower.
|
||||
*
|
||||
* If, at the time of this request, the window in a fixed-size state, such as
|
||||
* maximized or fullscreen, the request will be deferred until the window
|
||||
* exits this state and becomes resizable again.
|
||||
*
|
||||
* On some windowing systems, this request is asynchronous and the new window
|
||||
* aspect ratio may not have have been applied immediately upon the return of this
|
||||
* function. If an immediate change is required, call SDL_SyncWindow() to
|
||||
* block until the changes have taken effect.
|
||||
*
|
||||
* When the window size changes, an SDL_EVENT_WINDOW_RESIZED event will be
|
||||
* emitted with the new window dimensions. Note that the new dimensions may
|
||||
* not match the exact aspect ratio requested, as some windowing systems can restrict
|
||||
* the window size in certain scenarios (e.g. constraining the size of the
|
||||
* content area to remain within the usable desktop bounds). Additionally, as
|
||||
* this is just a request, it can be denied by the windowing system.
|
||||
*
|
||||
* \param window the window to change
|
||||
* \param min_aspect the minimum aspect ratio of the window, or 0.0f for no limit
|
||||
* \param max_aspect the maximum aspect ratio of the window, or 0.0f for no limit
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetWindowAspectRatio
|
||||
* \sa SDL_SyncWindow
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetWindowAspectRatio(SDL_Window *window, float min_aspect, float max_aspect);
|
||||
|
||||
/**
|
||||
* Get the size of a window's client area.
|
||||
*
|
||||
* \param window the window to query the width and height from
|
||||
* \param min_aspect a pointer filled in with the minimum aspect ratio of the window, may be NULL
|
||||
* \param max_aspect a pointer filled in with the maximum aspect ratio of the window, may be NULL
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_SetWindowAspectRatio
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetWindowAspectRatio(SDL_Window *window, float *min_aspect, float *max_aspect);
|
||||
|
||||
/**
|
||||
* Get the size of a window's borders (decorations) around the client area.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user