Is there any way of getting an event while the window is resizing to say that the window is, in fact, resizing ?
The current ones in SDL3 seem to be SDL_EVENT_WINDOW_RESIZED and SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED. Both of these get sent after the resize is completed.
The problem is that the current resize action does a ‘stretch’ of the window as you’re resizing it, but in my UI framework I have constraints to figure out how the various part of the window should resize themselves. In the example below, the right and left margins from the view to its parent (in this case the window’s content-view) are constrained to be fixed and the view-width itself is unconstrained, so resizing the window will commensurately resize the view.
All well and good, but the stretch effect doesn’t know about my constraints so there’s a s…t…r…e…t…c…h then SNAP! effect going on, which just looks … weird.
I tried using the event-watcher approach, registering for events on the window…
static BOOL resizingEventWatcher(void* data, SDL_Event* e)
{
if (e->type == SDL_EVENT_WINDOW_RESIZED)
{
SDL_Window* win = SDL_GetWindowFromID(e->window.windowID);
if (win == (SDL_Window*)data)
{
AZView *cv = [AZView contentViewForWindow:win];
int w = e->window.data1;
int h = e->window.data2;
NSNotificationCenter *nc = NSNotificationCenter.defaultCenter;
[nc postNotificationName:AZRootViewWillResizeNotification object:cv];
[cv setFrame:NSMakeRect(0,0,w,h)];
}
}
return 0;
}
… and I do indeed get the resize events as they happen, but taking the same actions as in the event-loop for SDL_EVENT_WINDOW_RESIZED doesn’t have any effect - I’m assuming the routine doing the s…t…r…e…t…c…h effect has grabbed the display output or something similar. My own redraws don’t happen, anyway, so the visual effect remains the same:
So, any ideas on how I could get a prettier resize ?
On a positive note, after a whole lot of boiler-plate framework setup code, I got my first widget yesterday evening… Drum roll please for … AZButton!