|
This thread is locked; no one can reply to it. |
1
2
|
[al5] Setting the minimum and maximum window size? |
jmasterx
Member #11,410
October 2009
|
In the game that I will be planning to make, it will use Layouts and a few other things and I would like to make it so that the window can be no smaller than 320x240. Is it possible to do this? By this I mean, when you drag a corner of a window to re-size it, the window will stop becoming smaller when it hits a certain threshold. I'm aware of al_resize_display() but I was wondering if there was a way to prevent the window from resizing in the first place. Thanks Agui GUI API -> https://github.com/jmasterx/Agui |
Edgar Reynaldo
Major Reynaldo
May 2007
|
I would also like to see support for (at least) minimum and (maybe) maximum window size, without the window temporarily appearing smaller than the minimum or larger than the maximum. It would be a really nice feature. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Elias
Member #358
May 2000
|
I'd like it as well. I'll do the X11 version of it if someone makes the Windows version. Since we have al_set_new_window_position already, I guess a function similar to that would fit well into the API. -- |
Evert
Member #794
November 2000
|
The OS X version does this internally anyway (otherwise you can resize the window to something that's smaller than the titlebar and weirdness happens). |
Thomas Fjellstrom
Member #476
June 2000
|
I half expected you could implement this yourself by just not acknowledging resizes once it gets too small or large.. -- |
Evert
Member #794
November 2000
|
Thomas Fjellstrom said: I half expected you could implement this yourself by just not acknowledging resizes once it gets too small or large..
That's not quite the same thing though, isn't it? |
Matthew Leverton
Supreme Loser
January 1999
|
Thomas Fjellstrom said: I half expected you could implement this yourself by just not acknowledging resizes once it gets too small or large.. The window is still resized, even if you don't acknowledge it. There needs to be a function al_set_window_constraints(display, minw, minh, maxw, maxh). It doesn't need to affect explicit resizes. (Edit: maybe even an optional ratio parameter... Not sure what is easily supported by the underlying OS.) |
Thomas Fjellstrom
Member #476
June 2000
|
Or maybe allegro shouldn't allow the resize if it isn't acknowledged. But either way works. -- |
Matthew Leverton
Supreme Loser
January 1999
|
Thomas Fjellstrom said: Or maybe allegro shouldn't allow the resize if it isn't acknowledged. But either way works. That doesn't really work very well with events. Plus, you need to have the ability to clamp to the constraints. If the minimum width is 300, you wouldn't want an attempt to resize to 295 to be ignored completely... you'd want it to clamp to 300. |
Evert
Member #794
November 2000
|
Thomas Fjellstrom said: Or maybe allegro shouldn't allow the resize if it isn't acknowledged. That would be nice, but unfortunately the way it works (at least on OS X) is that the Window is resized, we get a "window resized" message, which Allegro passes on to the user, who then calls a function to synchronise the size of the backbuffer with whatever size it should be. |
jmasterx
Member #11,410
October 2009
|
Turns out this is dead easy in Windows: In the message loop, just handle the: WM_GETMINMAXINFO message and just fill out the MINMAXINFO structure. http://msdn.microsoft.com/en-us/library/ms632626%28v=vs.85%29.aspx Agui GUI API -> https://github.com/jmasterx/Agui |
Matthew Leverton
Supreme Loser
January 1999
|
One of the comments says: Quote: It should be noted, that the values specified in the MINMAXINFO structure are the client plus non-client (including the caption and borders) size of the window. Most Windows programmers know this, but it isn't really noted here. But that's not how Allegro should work if at all possible. The value specified should be the internal (buffer) size. |
Thomas Fjellstrom
Member #476
June 2000
|
Evert said: That would be nice, but unfortunately the way it works (at least on OS X) is that the Window is resized, we get a "window resized" message, which Allegro passes on to the user, who then calls a function to synchronise the size of the backbuffer with whatever size it should be. That's odd. I expected it to give you a "Begin Resize" event that you can ignore, or call a function, or return a special variable to cancel the resize (or clamp it). Matthew Leverton said: But that's not how Allegro should work if at all possible. The value specified should be the internal (buffer) size. It's not that hard to do the math, just fetch the non-client border size, and combine it with the numbers specified by the user with the new function. -- |
jmasterx
Member #11,410
October 2009
|
But can't you just use: GetSystemMetrics(SM_CYBORDER); // get the border width and then do the math so the struct is correct? Agui GUI API -> https://github.com/jmasterx/Agui |
Evert
Member #794
November 2000
|
Thomas Fjellstrom said: I expected it to give you a "Begin Resize" event that you can ignore, or call a function, or return a special variable to cancel the resize (or clamp it). Well, ok, you do get viewWillStartLiveResize`/`viewDidEndLiveResize, but you can't cancel the resize. |
jmasterx
Member #11,410
October 2009
|
For OSX can't you simply do: [theWindow setMaxSize:windowMaxSize]; Agui GUI API -> https://github.com/jmasterx/Agui |
Evert
Member #794
November 2000
|
jmasterx said: [theWindow setMaxSize:windowMaxSize]; Yes. I didn't mean to imply it'd be in any way difficult. |
jmasterx
Member #11,410
October 2009
|
Okay great! Looks like the only one that would be left is Linux! It would be nice if this feature could make it into 5.03 ; it feels like it should be part of 5 and not just >= 5.1 . Agui GUI API -> https://github.com/jmasterx/Agui |
Thomas Fjellstrom
Member #476
June 2000
|
As long as it can be done without breaking Binary Compatibility, it could be added to 5.0.x -- |
Arthur Kalliokoski
Second in Command
February 2005
|
jmasterx said: Looks like the only one that would be left is Linux! xdisplay.c already has hints->min_width = hints->max_width = hints->base_width = d->w; hints->min_height = hints->max_height = hints->base_height = d->h;
They all watch too much MSNBC... they get ideas. |
Thomas Fjellstrom
Member #476
June 2000
|
Yeah, it wouldn't be that hard to support. -- |
jmasterx
Member #11,410
October 2009
|
Evert said: Well, ok, you do get viewWillStartLiveResize`/`viewDidEndLiveResize, but you can't cancel the resize. I think that Allegro should still integrate the resize begin and resize end though. Not for the min max size, but to add consistency when resizing. What I mean is, right now in OSX and I think Linux, the Window resizes in real time, but in Windows it just awkwardly stretches what was there until you let go of the mouse. What this could allow is to blit a black rectangle before the resize begins so that while it is resizing the screen is black across all platforms. Agui GUI API -> https://github.com/jmasterx/Agui |
Evert
Member #794
November 2000
|
jmasterx said: I think that Allegro should still integrate the resize begin and resize end though.
What do you mean? Quote: What I mean is, right now in OSX and I think Linux, the Window resizes in real time, but in Windows it just awkwardly stretches what was there until you let go of the mouse. On OS X, I think there's a flag that controls the behaviour of the window while it resizes. Not sure though, but it would make sense. Would then also make sense to have the same on other platforms. |
jmasterx
Member #11,410
October 2009
|
What I mean is that, for example, in Windows, I can drag around the Window for 8 hours, but I will not get a single ALLEGRO_EVENT_DISPLAY_RESIZED event until I let go my mouse. So I have no way to blit that black rectangle. My biggest issue is that in Windows the old contents is stretched while resizing which I find ugly, I'd rather have control of what I see when it is resizing and that I can make it consistent across all platforms. Agui GUI API -> https://github.com/jmasterx/Agui |
Elias
Member #358
May 2000
|
In X11 it's up to the window manager how to resize. E.g. in compiz I can set it to only show a transparent rectangle while resizing then send a single resize message to the application when I let go, or I can set it to stretch, or to constantly send 100ds of messages to the application during the resize. The application itself doesn't know which way is being used (at least not by default, possibly there's a way to override it somehow). Anyway, I agree that the Windows behavior should be changed and if we can have three events for resize_start, resize_in_progress and resize_done (or a flag in the ALLEGRO_EVENT_DISPLAY_RESIZED event indicating which of the three it is), all the better. -- |
|
1
2
|