sdl2_frt/src/video
Sam Lantinga 7a3ae59037 Fixed bug 4877 - Add support for loading menus from a nib/xib instead of building a hardcoded minimum set
Eric Shepherd

Currently, SDL on Cocoa macOS creates a rudimentary menu bar programmatically if none is already present when the app is registered during setup.

SDL could be much more easily and flexibly used on macOS if upon finding that no menus are currently in place, it first looked for the application's main menu nib or xib file and, if found, loaded that instead of programmatically building the menus.

This would then let developers simply drop in a nib file with a menu bar defined in it and it would be installed and used automatically.

Attached is a patch that does just this. It changes the SDL_cocoaevents.m file to:

* In Cocoa_RegisterApp(), before calling CreateApplicationMenus(), it calls a new function, LoadMainMenuNibIfAvailable(), which attempts to load and install the main menu nib file, using the nib name fetched from the Info.plist file. If that succeeds, LoadMainMenuNibIfAvailable() returns true; otherwise false.
* If LMMNIA() returns false, CreateApplicationMenus() is called to programmatically build the menus as before.
* Otherwise, we're done, and using the menus from the nib/xib file!

I made these changes to support a project I'm working on, and felt they were useful enough to be worth offering them for uplift. They should have zero impact on existing projects' behavior, but make Cocoa SDL development miles easier.
2019-12-03 07:12:55 -08:00
..
android Android: some readability: redundant casts, deads stores, redundant control flow 2019-10-31 15:53:10 +01:00
arm ARM: NEON assembly optimization for SDL_FillRect 2019-10-24 21:17:52 -04:00
cocoa Fixed bug 4877 - Add support for loading menus from a nib/xib instead of building a hardcoded minimum set 2019-12-03 07:12:55 -08:00
directfb use SDL_zeroa at more places where the argument is an array. 2019-07-31 05:11:40 +03:00
dummy Updated copyright for 2019 2019-01-04 22:01:14 -08:00
emscripten Add a windowID field to SDL_TouchFingerEvent (bug #4331). 2019-08-01 18:22:12 -03:00
haiku haiku: Disable pointer history 2019-12-03 02:49:01 -05:00
khronos Added Vulkan headers version 1.1.91 2018-11-06 16:57:07 -08:00
kmsdrm KMSDRM_GLES_SwapWindow: fix non-vsync case 2019-09-06 08:44:46 -07:00
nacl Updated copyright for 2019 2019-01-04 22:01:14 -08:00
offscreen offscreen: Add new video driver backend Offscreen 2019-09-24 16:36:48 -04:00
pandora Updated copyright for 2019 2019-01-04 22:01:14 -08:00
psp Updated copyright for 2019 2019-01-04 22:01:14 -08:00
qnx Fixed mingw Windows build, since SDL_vulkan_internal.h includes windows.h 2017-08-28 00:43:14 -07:00
raspberry RPI_FreeCursor: set global_cursor to NULL to prevent double-free (bug 4769) 2019-08-26 18:41:40 +03:00
uikit iOS: remove some unused code, minor code style cleanup. 2019-10-27 11:41:48 -03:00
vivante video: Add Vulkan support for vivante fb 2019-05-19 10:36:44 -07:00
wayland Wayland: touch events, use of memory after it is freed 2019-10-30 21:12:36 +01:00
windows Fixed bug 4840 - Read of uninitialized memory in DXGI_LoadDLL (Thanks!) 2019-10-23 09:26:27 +02:00
winrt WinRT: fix a link-time error when building UWP + x64 2019-10-02 14:55:02 -04:00
x11 Fixed bug 4819 - Attempting to create an OpenGL ES context with unachievable MSAA parameters under X11 dooms the program 2019-11-16 22:35:48 -08:00
yuv2rgb yuv: Patched to make static analysis happy (warned about unused variable). 2018-06-25 13:14:52 -04:00
SDL_blit_0.c Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_blit_1.c Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_blit_A.c ARM: NEON assembly optimization for function BlitARGBto565PixelAlpha 2019-10-24 21:17:38 -04:00
SDL_blit_auto.c BlitAuto: remove redundant cast to the same type 2019-10-30 14:37:06 +01:00
SDL_blit_auto.h Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_blit_copy.c Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_blit_copy.h Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_blit_N.c Readability: remove redundant return, continue, enum declaration 2019-10-30 15:36:17 +01:00
SDL_blit_slow.c Readability: remove redundant cast to the same type 2019-10-30 15:13:55 +01:00
SDL_blit_slow.h Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_blit.c Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_blit.h Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_bmp.c SDL_bmp.c: remove unused variable warnings 2019-09-05 10:08:47 +02:00
SDL_clipboard.c Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_egl_c.h offscreen: Avoid using EGLDeviceEXT as it causes issues with older platforms, which is just a void* 2019-09-24 17:27:51 -04:00
SDL_egl.c Android: remove eglGetProcAdded busted comment (bug #4040) 2019-10-23 11:07:11 +02:00
SDL_fillrect.c Use fill_function for FillRect SIMD/NEON (bug 4365) 2019-10-29 16:13:41 +01:00
SDL_pixels_c.h Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_pixels.c Added SDL_PIXELFORMAT_BGR444 2019-11-02 22:58:52 +00:00
SDL_rect_c.h Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_rect.c Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_RLEaccel_c.h Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_RLEaccel.c Fix const warning in RLE getpix functions 2019-10-30 16:17:59 +01:00
SDL_shape_internals.h Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_shape.c Readability: remove redundant cast to the same type 2019-10-30 15:13:55 +01:00
SDL_stretch.c Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_surface.c Fixed whitespace 2019-10-18 08:56:54 -07:00
SDL_sysvideo.h offscreen: Add new video driver backend Offscreen 2019-09-24 16:36:48 -04:00
SDL_video.c haiku: Rename BE_* entities to HAIKU_* 2019-11-12 17:24:37 -05:00
SDL_vulkan_internal.h video: Add Vulkan support for vivante fb 2019-05-19 10:36:44 -07:00
SDL_vulkan_utils.c vulkan: Fixed use-after-free bug. 2019-06-12 15:37:07 -04:00
SDL_yuv_c.h Updated copyright for 2019 2019-01-04 22:01:14 -08:00
SDL_yuv.c Android: minor warning 2019-08-30 09:00:06 +02:00
sdlgenblit.pl BlitAuto: remove redundant cast to the same type 2019-10-30 14:37:06 +01:00