Showing zoom button on Mac non-resizable window

Hello,

Is there an easy way to show and define behaviours of Mac window control
buttons without having ot use SDL_RESIZABLE?
In particular, I don’t want my window resizable (so I’m not using
SDL_RESIZABLE). A consequence of this is that the green zoom button does
not appear. However, I need that button; when pressed, my app would go to
fullscreen.

If I set SDL_RESIZABLE, the button shows up and I could redefine the resize
and button behaviours. However, I end up getting that little Mac resize
triangle on the bottom right corner of my window which I don’t want. So,
ideally I’d just like to turn on the zoom button and redefine its behaviour
without setting SDL_RESIZABLE. Is this possible?

Thanks,

Ryan

There is probably a way to do this, but you are probably going to be
side stepping SDL to achieve this.

In general (outside of SDL), what you describe seems possible. The
Calculator.app behaves kind of like this. You can’t resize it, but the
green button transforms the calculator between Basic, Scientific, and
Programmer modes.

I sadly don’t have time to actually try implementing any of this, but
I suspect you might start defining SDL_RESIZABLE and then try turning
things off.

A quick search through the NSWindow documentation shows this method:

  • (void)setShowsResizeIndicator:(BOOL)showResizeIndicator
    Specifies whether the receiver’s resize indicator is visible

I’m hoping this will just turn off the resize indicator in the
bottom-right corner. But if not, or if you need to start with
SDL_RESIZABLE off, it looks like there are masks for this stuff.
NSWindowZoomButton (part of NSWindowButton enum) and
NSResizableWindowMask turn up. You’ll need to track down the API calls
that work with this.

Finally, to control what happens on ‘Zoom’, I don’t think SDL offers
anything here either (maybe I’m wrong). So you’ll need to define what
to do. It looks like NSWindow responds to the following delegate on
zoom:

  • (NSRect)windowWillUseStandardFrame:(NSWindow *)sender
    defaultFrame:(NSRect)defaultFrame
    Invoked by the zoom: method while determining a frame the sender may
    be zoomed to.

So you’ll want to define this delegate and prepare for your fullscreen
switch. However, it looks like this delegate is actually just part 1
of a 6 part chain of events. And it looks like this method was
designed to return a new size for your window, not necessarily switch
to fullscreen.

So if you can’t switch to fullscreen directly from here, then you
might need to set a NSNotification or push a custom event into the
SDL_Event loop so you know to switch to fullscreen later.

I suspect a convenient place to drop all this code is in the SDLMain.m file.

If you get all this working, I would certainly like to see your code.
Maybe we can add it to the list of Xcode project templates we provide
(some of which demonstrate tighter Cocoa integration like this).

Good luck,
Eric

Thanks for the info :slight_smile:
If I get this working (IF) I’ll post something.

Thanks,

Ryan

“E. Wing” wrote in message
news:3c7e3c8a0606211542j6788d3fcj91e5dcb5e698f482 at mail.gmail.com…> There is probably a way to do this, but you are probably going to be

side stepping SDL to achieve this.

In general (outside of SDL), what you describe seems possible. The
Calculator.app behaves kind of like this. You can’t resize it, but the
green button transforms the calculator between Basic, Scientific, and
Programmer modes.

I sadly don’t have time to actually try implementing any of this, but
I suspect you might start defining SDL_RESIZABLE and then try turning
things off.

A quick search through the NSWindow documentation shows this method:

  • (void)setShowsResizeIndicator:(BOOL)showResizeIndicator
    Specifies whether the receiver’s resize indicator is visible

I’m hoping this will just turn off the resize indicator in the
bottom-right corner. But if not, or if you need to start with
SDL_RESIZABLE off, it looks like there are masks for this stuff.
NSWindowZoomButton (part of NSWindowButton enum) and
NSResizableWindowMask turn up. You’ll need to track down the API calls
that work with this.

Finally, to control what happens on ‘Zoom’, I don’t think SDL offers
anything here either (maybe I’m wrong). So you’ll need to define what
to do. It looks like NSWindow responds to the following delegate on
zoom:

  • (NSRect)windowWillUseStandardFrame:(NSWindow *)sender
    defaultFrame:(NSRect)defaultFrame
    Invoked by the zoom: method while determining a frame the sender may
    be zoomed to.

So you’ll want to define this delegate and prepare for your fullscreen
switch. However, it looks like this delegate is actually just part 1
of a 6 part chain of events. And it looks like this method was
designed to return a new size for your window, not necessarily switch
to fullscreen.

So if you can’t switch to fullscreen directly from here, then you
might need to set a NSNotification or push a custom event into the
SDL_Event loop so you know to switch to fullscreen later.

I suspect a convenient place to drop all this code is in the SDLMain.m
file.

If you get all this working, I would certainly like to see your code.
Maybe we can add it to the list of Xcode project templates we provide
(some of which demonstrate tighter Cocoa integration like this).

Good luck,
Eric

Hi,

Well, I finally got around to trying a couple things.
Right after the SDL_SetVideoMode call, I did the following:

NSWindow* window = [NSApp mainWindow];
NSButton* button = [window standardWindowButton:NSWindowZoomButton];
[window setShowsResizeIndicator:YES]; // I don’t really want the resize
indicator…I’m just doing this to see what happens.
[button display];

Unfortunately, these calls didn’t change anything.
How exactly does SDL turn off things in the first place?

Thanks,

Ryan

“E. Wing” wrote in message
news:3c7e3c8a0606211542j6788d3fcj91e5dcb5e698f482 at mail.gmail.com…> There is probably a way to do this, but you are probably going to be

side stepping SDL to achieve this.

In general (outside of SDL), what you describe seems possible. The
Calculator.app behaves kind of like this. You can’t resize it, but the
green button transforms the calculator between Basic, Scientific, and
Programmer modes.

I sadly don’t have time to actually try implementing any of this, but
I suspect you might start defining SDL_RESIZABLE and then try turning
things off.

A quick search through the NSWindow documentation shows this method:

  • (void)setShowsResizeIndicator:(BOOL)showResizeIndicator
    Specifies whether the receiver’s resize indicator is visible

I’m hoping this will just turn off the resize indicator in the
bottom-right corner. But if not, or if you need to start with
SDL_RESIZABLE off, it looks like there are masks for this stuff.
NSWindowZoomButton (part of NSWindowButton enum) and
NSResizableWindowMask turn up. You’ll need to track down the API calls
that work with this.

Finally, to control what happens on ‘Zoom’, I don’t think SDL offers
anything here either (maybe I’m wrong). So you’ll need to define what
to do. It looks like NSWindow responds to the following delegate on
zoom:

  • (NSRect)windowWillUseStandardFrame:(NSWindow *)sender
    defaultFrame:(NSRect)defaultFrame
    Invoked by the zoom: method while determining a frame the sender may
    be zoomed to.

So you’ll want to define this delegate and prepare for your fullscreen
switch. However, it looks like this delegate is actually just part 1
of a 6 part chain of events. And it looks like this method was
designed to return a new size for your window, not necessarily switch
to fullscreen.

So if you can’t switch to fullscreen directly from here, then you
might need to set a NSNotification or push a custom event into the
SDL_Event loop so you know to switch to fullscreen later.

I suspect a convenient place to drop all this code is in the SDLMain.m
file.

If you get all this working, I would certainly like to see your code.
Maybe we can add it to the list of Xcode project templates we provide
(some of which demonstrate tighter Cocoa integration like this).

Good luck,
Eric