SetMinimumWindowSize for OS X
This commit is contained in:
parent
86a14db17a
commit
de7aeffa50
7 changed files with 82 additions and 12 deletions
|
@ -23,6 +23,10 @@ build
|
||||||
*.pbxuser
|
*.pbxuser
|
||||||
(^|/)build($|/)
|
(^|/)build($|/)
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
Xcode/SDL/SDL.xcodeproj/xcuserdata
|
||||||
|
Xcode/SDL/SDL.xcodeproj/project.xcworkspace/xcuserdata
|
||||||
|
Xcode/SDL/SDLTest.xcodeproj/xcuserdata
|
||||||
|
Xcode/SDL/SDLTest.xcodeproj/project.xcworkspace/xcuserdata
|
||||||
|
|
||||||
# for Visual C++
|
# for Visual C++
|
||||||
Debug
|
Debug
|
||||||
|
|
|
@ -518,6 +518,25 @@ extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_Window * window, int w,
|
||||||
extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window * window, int *w,
|
extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window * window, int *w,
|
||||||
int *h);
|
int *h);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set the minimum size of a window's client area.
|
||||||
|
*
|
||||||
|
* \note You can't change the minimum size of a fullscreen window, it
|
||||||
|
* automatically matches the size of the display mode.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetWindowMinimumSize()
|
||||||
|
*/
|
||||||
|
extern DECLSPEC void SDLCALL SDL_SetWindowMinimumSize(SDL_Window * window,
|
||||||
|
int min_w, int min_h);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Get the minimum size of a window's client area.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetWindowMinimumSize()
|
||||||
|
*/
|
||||||
|
extern DECLSPEC void SDLCALL SDL_GetWindowMinimumSize(SDL_Window * window,
|
||||||
|
int *w, int *h);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set the border state of a window.
|
* \brief Set the border state of a window.
|
||||||
*
|
*
|
||||||
|
|
|
@ -74,6 +74,7 @@ struct SDL_Window
|
||||||
char *title;
|
char *title;
|
||||||
int x, y;
|
int x, y;
|
||||||
int w, h;
|
int w, h;
|
||||||
|
int min_w, min_h;
|
||||||
Uint32 flags;
|
Uint32 flags;
|
||||||
|
|
||||||
/* Stored position and size for windowed mode */
|
/* Stored position and size for windowed mode */
|
||||||
|
@ -181,6 +182,7 @@ struct SDL_VideoDevice
|
||||||
void (*SetWindowIcon) (_THIS, SDL_Window * window, SDL_Surface * icon);
|
void (*SetWindowIcon) (_THIS, SDL_Window * window, SDL_Surface * icon);
|
||||||
void (*SetWindowPosition) (_THIS, SDL_Window * window);
|
void (*SetWindowPosition) (_THIS, SDL_Window * window);
|
||||||
void (*SetWindowSize) (_THIS, SDL_Window * window);
|
void (*SetWindowSize) (_THIS, SDL_Window * window);
|
||||||
|
void (*SetWindowMinimumSize) (_THIS, SDL_Window * window);
|
||||||
void (*ShowWindow) (_THIS, SDL_Window * window);
|
void (*ShowWindow) (_THIS, SDL_Window * window);
|
||||||
void (*HideWindow) (_THIS, SDL_Window * window);
|
void (*HideWindow) (_THIS, SDL_Window * window);
|
||||||
void (*RaiseWindow) (_THIS, SDL_Window * window);
|
void (*RaiseWindow) (_THIS, SDL_Window * window);
|
||||||
|
|
|
@ -1563,19 +1563,47 @@ SDL_GetWindowSize(SDL_Window * window, int *w, int *h)
|
||||||
CHECK_WINDOW_MAGIC(window, );
|
CHECK_WINDOW_MAGIC(window, );
|
||||||
|
|
||||||
if (_this && window && window->magic == &_this->window_magic) {
|
if (_this && window && window->magic == &_this->window_magic) {
|
||||||
if (w) {
|
|
||||||
*w = window->w;
|
*w = window->w;
|
||||||
}
|
|
||||||
if (h) {
|
|
||||||
*h = window->h;
|
*h = window->h;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
if (w) {
|
|
||||||
*w = 0;
|
void
|
||||||
|
SDL_SetWindowMinimumSize(SDL_Window * window, int min_w, int min_h)
|
||||||
|
{
|
||||||
|
CHECK_WINDOW_MAGIC(window, );
|
||||||
|
|
||||||
|
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
|
||||||
|
window->min_w = min_w;
|
||||||
|
window->min_h = min_h;
|
||||||
|
if (_this->SetWindowMinimumSize) {
|
||||||
|
_this->SetWindowMinimumSize(_this, window);
|
||||||
}
|
}
|
||||||
if (h) {
|
/* Ensure that window is not smaller than minimal size */
|
||||||
*h = 0;
|
SDL_SetWindowSize(window, SDL_max(window->w, window->min_w), SDL_max(window->h, window->min_h));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SDL_GetWindowMinimumSize(SDL_Window * window, int *min_w, int *min_h)
|
||||||
|
{
|
||||||
|
int dummy;
|
||||||
|
|
||||||
|
if (!min_w) {
|
||||||
|
min_w = &dummy;
|
||||||
|
}
|
||||||
|
if (!min_h) {
|
||||||
|
min_h = &dummy;
|
||||||
|
}
|
||||||
|
|
||||||
|
*min_w = 0;
|
||||||
|
*min_h = 0;
|
||||||
|
|
||||||
|
CHECK_WINDOW_MAGIC(window, );
|
||||||
|
|
||||||
|
if (_this && window && window->magic == &_this->window_magic) {
|
||||||
|
*min_w = window->min_w;
|
||||||
|
*min_h = window->min_h;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,7 @@ Cocoa_CreateDevice(int devindex)
|
||||||
device->SetWindowIcon = Cocoa_SetWindowIcon;
|
device->SetWindowIcon = Cocoa_SetWindowIcon;
|
||||||
device->SetWindowPosition = Cocoa_SetWindowPosition;
|
device->SetWindowPosition = Cocoa_SetWindowPosition;
|
||||||
device->SetWindowSize = Cocoa_SetWindowSize;
|
device->SetWindowSize = Cocoa_SetWindowSize;
|
||||||
|
device->SetWindowMinimumSize = Cocoa_SetWindowMinimumSize;
|
||||||
device->ShowWindow = Cocoa_ShowWindow;
|
device->ShowWindow = Cocoa_ShowWindow;
|
||||||
device->HideWindow = Cocoa_HideWindow;
|
device->HideWindow = Cocoa_HideWindow;
|
||||||
device->RaiseWindow = Cocoa_RaiseWindow;
|
device->RaiseWindow = Cocoa_RaiseWindow;
|
||||||
|
|
|
@ -94,6 +94,7 @@ extern void Cocoa_SetWindowTitle(_THIS, SDL_Window * window);
|
||||||
extern void Cocoa_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon);
|
extern void Cocoa_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon);
|
||||||
extern void Cocoa_SetWindowPosition(_THIS, SDL_Window * window);
|
extern void Cocoa_SetWindowPosition(_THIS, SDL_Window * window);
|
||||||
extern void Cocoa_SetWindowSize(_THIS, SDL_Window * window);
|
extern void Cocoa_SetWindowSize(_THIS, SDL_Window * window);
|
||||||
|
extern void Cocoa_SetWindowMinimumSize(_THIS, SDL_Window * window);
|
||||||
extern void Cocoa_ShowWindow(_THIS, SDL_Window * window);
|
extern void Cocoa_ShowWindow(_THIS, SDL_Window * window);
|
||||||
extern void Cocoa_HideWindow(_THIS, SDL_Window * window);
|
extern void Cocoa_HideWindow(_THIS, SDL_Window * window);
|
||||||
extern void Cocoa_RaiseWindow(_THIS, SDL_Window * window);
|
extern void Cocoa_RaiseWindow(_THIS, SDL_Window * window);
|
||||||
|
|
|
@ -730,6 +730,21 @@ Cocoa_SetWindowSize(_THIS, SDL_Window * window)
|
||||||
[pool release];
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Cocoa_SetWindowMinimumSize(_THIS, SDL_Window * window)
|
||||||
|
{
|
||||||
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
|
||||||
|
|
||||||
|
NSSize minSize;
|
||||||
|
minSize.width = window->min_w;
|
||||||
|
minSize.height = window->min_h;
|
||||||
|
|
||||||
|
[windata->nswindow setMinSize:minSize];
|
||||||
|
|
||||||
|
[pool release];
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Cocoa_ShowWindow(_THIS, SDL_Window * window)
|
Cocoa_ShowWindow(_THIS, SDL_Window * window)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue