diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-09-21 22:17:53 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-09-21 22:17:53 +0300 |
commit | c113930a66efb7a2a8a1bab62e110dafb5b21209 (patch) | |
tree | 785adc1f0953756a5d2c8120c592d5b9d795bce5 | |
parent | 2bf206181e8e3ce6d1b7e899de7c4cc04778a087 (diff) |
Added build options for popup/macOS menus
-rw-r--r-- | CMakeLists.txt | 10 | ||||
-rw-r--r-- | src/defs.h | 4 | ||||
-rw-r--r-- | src/ui/util.c | 6 | ||||
-rw-r--r-- | src/ui/window.c | 2 |
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 | |||
45 | option (ENABLE_IDLE_SLEEP "While idle, sleep in the main thread instead of waiting for events" ON) | 45 | option (ENABLE_IDLE_SLEEP "While idle, sleep in the main thread instead of waiting for events" ON) |
46 | option (ENABLE_IPC "Use IPC to communicate between running instances" ON) | 46 | option (ENABLE_IPC "Use IPC to communicate between running instances" ON) |
47 | option (ENABLE_KERNING "Enable kerning in font renderer (slower)" ON) | 47 | option (ENABLE_KERNING "Enable kerning in font renderer (slower)" ON) |
48 | option (ENABLE_MAC_MENUS "Use native context menus (macOS)" ON) | ||
48 | option (ENABLE_MOBILE_PHONE "Use the phone mobile UI design instead of desktop UI" OFF) | 49 | option (ENABLE_MOBILE_PHONE "Use the phone mobile UI design instead of desktop UI" OFF) |
49 | option (ENABLE_MOBILE_TABLET "Use the tablet mobile UI design instead of desktop UI" OFF) | 50 | option (ENABLE_MOBILE_TABLET "Use the tablet mobile UI design instead of desktop UI" OFF) |
50 | option (ENABLE_MPG123 "Use mpg123 for decoding MPEG audio" ON) | 51 | option (ENABLE_MPG123 "Use mpg123 for decoding MPEG audio" ON) |
52 | option (ENABLE_POPUP_MENUS "Use popup windows for context menus (if OFF, menus are confined inside main window)" ON) | ||
51 | option (ENABLE_RELATIVE_EMBED "Resources should always be found via relative path" OFF) | 53 | option (ENABLE_RELATIVE_EMBED "Resources should always be found via relative path" OFF) |
52 | option (ENABLE_RESIZE_DRAW "Force window to redraw during resizing" ${DEFAULT_RESIZE_DRAW}) | 54 | option (ENABLE_RESIZE_DRAW "Force window to redraw during resizing" ${DEFAULT_RESIZE_DRAW}) |
53 | option (ENABLE_RESOURCE_EMBED "Embed resources inside the executable" OFF) | 55 | option (ENABLE_RESOURCE_EMBED "Embed resources inside the executable" OFF) |
54 | option (ENABLE_WEBP "Use libwebp to decode .webp images (via pkg-config)" ON) | 56 | option (ENABLE_WEBP "Use libwebp to decode .webp images (via pkg-config)" ON) |
55 | option (ENABLE_WINDOWPOS_FIX "Set position after showing window (workaround for SDL bug)" OFF) | 57 | option (ENABLE_WINDOWPOS_FIX "Set position after showing window (workaround for SDL bug)" OFF) |
56 | option (ENABLE_X11_SWRENDER "Use software rendering under X11" OFF) | 58 | option (ENABLE_X11_SWRENDER "Use software rendering (X11)" OFF) |
57 | 59 | ||
58 | include (BuildType.cmake) | 60 | include (BuildType.cmake) |
59 | include (res/Embed.cmake) | 61 | include (res/Embed.cmake) |
@@ -328,10 +330,16 @@ endif () | |||
328 | if (ENABLE_KERNING) | 330 | if (ENABLE_KERNING) |
329 | target_compile_definitions (app PUBLIC LAGRANGE_ENABLE_KERNING=1) | 331 | target_compile_definitions (app PUBLIC LAGRANGE_ENABLE_KERNING=1) |
330 | endif () | 332 | endif () |
333 | if (ENABLE_MAC_MENUS) | ||
334 | target_compile_definitions (app PUBLIC LAGRANGE_ENABLE_MAC_MENUS=1) | ||
335 | endif () | ||
331 | if (ENABLE_MPG123 AND MPG123_FOUND) | 336 | if (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) |
334 | endif () | 339 | endif () |
340 | if (ENABLE_POPUP_MENUS) | ||
341 | target_compile_definitions (app PUBLIC LAGRANGE_ENABLE_POPUP_MENUS=1) | ||
342 | endif () | ||
335 | if (ENABLE_RESIZE_DRAW) | 343 | if (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) |
337 | endif () | 345 | endif () |
@@ -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 | ||
977 | iLocalDef iBool isUsingMenuPopupWindows_(void) { | 977 | iLocalDef 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 | ||
981 | void releaseNativeMenu_Widget(iWidget *d) { | 985 | void 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); |