I use SDL2, and I would like to put menus in the menubar. The way the system likes to do it: top of the screen on the Mac, top of the window on Windows, etc. Is there any facility in SDL2 to access these system-style menus? Or has anyone written an add-on to do so?
I have heard of people embedding SDL inside Qt and windows apps, so I
suspect you could use something like SDL_CreateWindowFrom https://wiki.libsdl.org/SDL_CreateWindowFrom. I’m sure there is someone
on here more information, but that gives you a clear path forward, I think.On Thu, Jan 26, 2017 at 5:23 PM, joymaker wrote:
I use SDL2, and I would like to put menus in the menubar. The way the
system likes to do it: top of the screen on the Mac, top of the window on
Windows, etc. Is there any facility in SDL2 to access these system-style
menus? Or has anyone written an add-on to do so?
I don’t think a small crossplatform solution that just provides a
menubar exists.
You could use GTK or Qt or WxWidgets, but that seems like a huge
dependency for such a simple thing.
FWIW, SDL :: View topic - Adding drop-down menus to SDL surface window? has some
information on how to do this on Windows
There probably is a standard way to do this on OSX, too.
For Linux (or Unices using X11 in general) it#s harder, because there
menubars are provided by Qt, GTK or whatever you’re using.
I use SDL2, and I would like to put menus in the menubar. The way the
system likes to do it: top of the screen on the Mac, top of the window
on Windows, etc. Is there any facility in SDL2 to access these
system-style menus? Or has anyone written an add-on to do so?
For at least Windows and Mac OS X where the system has a known framework to provide menus, could there be an API to construct a menu and attach it to a window? The API could loosely wrap HMENU in Windows and NSMenu in Mac OS X.
I’m currently doing such an abstraction through a heavily modified SDL1 library in DOSBox-X, perhaps it could serve as a starting point? It is written to draw it’s own menus if neither Windows nor Mac OS X because I’d rather not make GTK+ or Qt a dependency of DOSBox-X. SDL2 builds have drawn their own menus so far.
Additional support code for Mac OS X:
I’m asking if it can be made part of the standard library instead of letting the in-tree copy of SDL2 bitrot with custom modifications that deviate from this active project. There are clearly contributers to DOSBox-X that would like to see system menus in both SDL1 and SDL2 builds.