summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-09-21 22:17:53 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-09-21 22:17:53 +0300
commitc113930a66efb7a2a8a1bab62e110dafb5b21209 (patch)
tree785adc1f0953756a5d2c8120c592d5b9d795bce5
parent2bf206181e8e3ce6d1b7e899de7c4cc04778a087 (diff)
Added build options for popup/macOS menus
-rw-r--r--CMakeLists.txt10
-rw-r--r--src/defs.h4
-rw-r--r--src/ui/util.c6
-rw-r--r--src/ui/window.c2
4 files changed, 18 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2b229442..d98cc700 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -45,15 +45,17 @@ option (ENABLE_HARFBUZZ_MINIMAL "Build the HarfBuzz library with minimal depende
45option (ENABLE_IDLE_SLEEP "While idle, sleep in the main thread instead of waiting for events" ON) 45option (ENABLE_IDLE_SLEEP "While idle, sleep in the main thread instead of waiting for events" ON)
46option (ENABLE_IPC "Use IPC to communicate between running instances" ON) 46option (ENABLE_IPC "Use IPC to communicate between running instances" ON)
47option (ENABLE_KERNING "Enable kerning in font renderer (slower)" ON) 47option (ENABLE_KERNING "Enable kerning in font renderer (slower)" ON)
48option (ENABLE_MAC_MENUS "Use native context menus (macOS)" ON)
48option (ENABLE_MOBILE_PHONE "Use the phone mobile UI design instead of desktop UI" OFF) 49option (ENABLE_MOBILE_PHONE "Use the phone mobile UI design instead of desktop UI" OFF)
49option (ENABLE_MOBILE_TABLET "Use the tablet mobile UI design instead of desktop UI" OFF) 50option (ENABLE_MOBILE_TABLET "Use the tablet mobile UI design instead of desktop UI" OFF)
50option (ENABLE_MPG123 "Use mpg123 for decoding MPEG audio" ON) 51option (ENABLE_MPG123 "Use mpg123 for decoding MPEG audio" ON)
52option (ENABLE_POPUP_MENUS "Use popup windows for context menus (if OFF, menus are confined inside main window)" ON)
51option (ENABLE_RELATIVE_EMBED "Resources should always be found via relative path" OFF) 53option (ENABLE_RELATIVE_EMBED "Resources should always be found via relative path" OFF)
52option (ENABLE_RESIZE_DRAW "Force window to redraw during resizing" ${DEFAULT_RESIZE_DRAW}) 54option (ENABLE_RESIZE_DRAW "Force window to redraw during resizing" ${DEFAULT_RESIZE_DRAW})
53option (ENABLE_RESOURCE_EMBED "Embed resources inside the executable" OFF) 55option (ENABLE_RESOURCE_EMBED "Embed resources inside the executable" OFF)
54option (ENABLE_WEBP "Use libwebp to decode .webp images (via pkg-config)" ON) 56option (ENABLE_WEBP "Use libwebp to decode .webp images (via pkg-config)" ON)
55option (ENABLE_WINDOWPOS_FIX "Set position after showing window (workaround for SDL bug)" OFF) 57option (ENABLE_WINDOWPOS_FIX "Set position after showing window (workaround for SDL bug)" OFF)
56option (ENABLE_X11_SWRENDER "Use software rendering under X11" OFF) 58option (ENABLE_X11_SWRENDER "Use software rendering (X11)" OFF)
57 59
58include (BuildType.cmake) 60include (BuildType.cmake)
59include (res/Embed.cmake) 61include (res/Embed.cmake)
@@ -328,10 +330,16 @@ endif ()
328if (ENABLE_KERNING) 330if (ENABLE_KERNING)
329 target_compile_definitions (app PUBLIC LAGRANGE_ENABLE_KERNING=1) 331 target_compile_definitions (app PUBLIC LAGRANGE_ENABLE_KERNING=1)
330endif () 332endif ()
333if (ENABLE_MAC_MENUS)
334 target_compile_definitions (app PUBLIC LAGRANGE_ENABLE_MAC_MENUS=1)
335endif ()
331if (ENABLE_MPG123 AND MPG123_FOUND) 336if (ENABLE_MPG123 AND MPG123_FOUND)
332 target_compile_definitions (app PUBLIC LAGRANGE_ENABLE_MPG123=1) 337 target_compile_definitions (app PUBLIC LAGRANGE_ENABLE_MPG123=1)
333 target_link_libraries (app PUBLIC PkgConfig::MPG123) 338 target_link_libraries (app PUBLIC PkgConfig::MPG123)
334endif () 339endif ()
340if (ENABLE_POPUP_MENUS)
341 target_compile_definitions (app PUBLIC LAGRANGE_ENABLE_POPUP_MENUS=1)
342endif ()
335if (ENABLE_RESIZE_DRAW) 343if (ENABLE_RESIZE_DRAW)
336 target_compile_definitions (app PUBLIC LAGRANGE_ENABLE_RESIZE_DRAW=1) 344 target_compile_definitions (app PUBLIC LAGRANGE_ENABLE_RESIZE_DRAW=1)
337endif () 345endif ()
diff --git a/src/defs.h b/src/defs.h
index 8b47790a..01bf2b3d 100644
--- a/src/defs.h
+++ b/src/defs.h
@@ -166,7 +166,9 @@ iLocalDef int acceptKeyMod_ReturnKeyBehavior(int behavior) {
166 166
167#if defined (iPlatformAppleDesktop) 167#if defined (iPlatformAppleDesktop)
168# define iHaveNativeMenus /* main menu */ 168# define iHaveNativeMenus /* main menu */
169# define iHaveNativeContextMenus 169# if defined (LAGRANGE_ENABLE_MAC_MENUS)
170# define iHaveNativeContextMenus
171# endif
170#endif 172#endif
171 173
172/* UI labels that depend on the platform */ 174/* UI labels that depend on the platform */
diff --git a/src/ui/util.c b/src/ui/util.c
index c75d7698..2b6ff929 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -975,7 +975,11 @@ void unselectAllNativeMenuItems_Widget(iWidget *menu) {
975} 975}
976 976
977iLocalDef iBool isUsingMenuPopupWindows_(void) { 977iLocalDef iBool isUsingMenuPopupWindows_(void) {
978#if defined (LAGRANGE_ENABLE_POPUP_MENUS)
978 return deviceType_App() == desktop_AppDeviceType; 979 return deviceType_App() == desktop_AppDeviceType;
980#else
981 return iFalse;
982#endif
979} 983}
980 984
981void releaseNativeMenu_Widget(iWidget *d) { 985void releaseNativeMenu_Widget(iWidget *d) {
@@ -1019,7 +1023,7 @@ void openMenuFlags_Widget(iWidget *d, iInt2 windowCoord, iBool postCommands) {
1019 removeChild_Widget(parent_Widget(d), d); /* we'll borrow the widget for a while */ 1023 removeChild_Widget(parent_Widget(d), d); /* we'll borrow the widget for a while */
1020 const float pixelRatio = get_Window()->pixelRatio; 1024 const float pixelRatio = get_Window()->pixelRatio;
1021 iInt2 menuPos = add_I2(get_MainWindow()->place.normalRect.pos, 1025 iInt2 menuPos = add_I2(get_MainWindow()->place.normalRect.pos,
1022 divf_I2(windowCoord, pixelRatio)); 1026 divf_I2(sub_I2(windowCoord, divi_I2(gap2_UI, 2)), pixelRatio));
1023 arrange_Widget(d); 1027 arrange_Widget(d);
1024 /* Check display bounds. */ { 1028 /* Check display bounds. */ {
1025 const iInt2 menuSize = divf_I2(d->rect.size, pixelRatio); 1029 const iInt2 menuSize = divf_I2(d->rect.size, pixelRatio);
diff --git a/src/ui/window.c b/src/ui/window.c
index 3f8faaea..8197afd4 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -913,7 +913,7 @@ iBool processEvent_Window(iWindow *d, const SDL_Event *ev) {
913 } 913 }
914 default: { 914 default: {
915 SDL_Event event = *ev; 915 SDL_Event event = *ev;
916 if (event.type == SDL_USEREVENT && isCommand_UserEvent(ev, "window.unfreeze")) { 916 if (event.type == SDL_USEREVENT && isCommand_UserEvent(ev, "window.unfreeze") && mw) {
917 mw->isDrawFrozen = iFalse; 917 mw->isDrawFrozen = iFalse;
918 if (SDL_GetWindowFlags(d->win) & SDL_WINDOW_HIDDEN) { 918 if (SDL_GetWindowFlags(d->win) & SDL_WINDOW_HIDDEN) {
919 SDL_ShowWindow(d->win); 919 SDL_ShowWindow(d->win);