From cff722a4af5978dbe6d251ffd10d8bb714e227ad Mon Sep 17 00:00:00 2001 From: Anthony Nicholls Date: Fri, 3 Mar 2023 10:17:48 +0000 Subject: [PATCH] GUI Basics: Refactor juce_gui_basics file structure - Created a new detail namespace - Moved shared module implementation details into the detail namespace - Split dependencies so source files only rely on details in the detail namespace - Removed all code from the juce_gui_basics.cpp file --- .../Builds/Android/app/CMakeLists.txt | 44 +- .../VisualStudio2017/DemoRunner_App.vcxproj | 28 +- .../DemoRunner_App.vcxproj.filters | 69 +- .../VisualStudio2019/DemoRunner_App.vcxproj | 28 +- .../DemoRunner_App.vcxproj.filters | 69 +- .../VisualStudio2022/DemoRunner_App.vcxproj | 28 +- .../DemoRunner_App.vcxproj.filters | 69 +- .../Builds/Android/app/CMakeLists.txt | 44 +- .../AudioPerformanceTest_App.vcxproj | 28 +- .../AudioPerformanceTest_App.vcxproj.filters | 69 +- .../Builds/Android/app/CMakeLists.txt | 44 +- .../AudioPluginHost_App.vcxproj | 28 +- .../AudioPluginHost_App.vcxproj.filters | 69 +- .../AudioPluginHost_App.vcxproj | 28 +- .../AudioPluginHost_App.vcxproj.filters | 69 +- .../AudioPluginHost_App.vcxproj | 28 +- .../AudioPluginHost_App.vcxproj.filters | 69 +- .../Builds/Android/app/CMakeLists.txt | 44 +- .../NetworkGraphicsDemo_App.vcxproj | 28 +- .../NetworkGraphicsDemo_App.vcxproj.filters | 69 +- .../VisualStudio2017/Projucer_App.vcxproj | 28 +- .../Projucer_App.vcxproj.filters | 69 +- .../VisualStudio2019/Projucer_App.vcxproj | 28 +- .../Projucer_App.vcxproj.filters | 69 +- .../VisualStudio2022/Projucer_App.vcxproj | 28 +- .../Projucer_App.vcxproj.filters | 69 +- .../UnitTestRunner_ConsoleApp.vcxproj | 28 +- .../UnitTestRunner_ConsoleApp.vcxproj.filters | 69 +- .../UnitTestRunner_ConsoleApp.vcxproj | 28 +- .../UnitTestRunner_ConsoleApp.vcxproj.filters | 69 +- .../UnitTestRunner_ConsoleApp.vcxproj | 28 +- .../UnitTestRunner_ConsoleApp.vcxproj.filters | 69 +- .../WindowsDLL_StaticLibrary.vcxproj | 28 +- .../WindowsDLL_StaticLibrary.vcxproj.filters | 69 +- .../enums/juce_AccessibilityEvent.h | 2 +- .../enums/juce_AccessibilityRole.h | 2 +- .../juce_AccessibilityHandler.cpp | 46 +- .../application/juce_Application.cpp | 6 +- .../juce_gui_basics/buttons/juce_Button.cpp | 93 +-- .../buttons/juce_HyperlinkButton.cpp | 2 +- .../buttons/juce_ToggleButton.cpp | 2 +- .../juce_ApplicationCommandManager.cpp | 2 +- .../components/juce_Component.cpp | 443 ++---------- .../components/juce_Component.h | 11 +- .../components/juce_FocusTraverser.cpp | 114 +-- .../components/juce_ModalComponentManager.cpp | 2 +- .../juce_gui_basics/desktop/juce_Desktop.cpp | 2 +- .../juce_gui_basics/desktop/juce_Desktop.h | 6 +- .../detail/juce_AccessibilityHelpers.cpp | 33 + .../detail/juce_AccessibilityHelpers.h | 70 ++ .../detail/juce_AlertWindowHelpers.h | 115 +++ .../detail/juce_ButtonAccessibilityHandler.h | 125 ++++ .../detail/juce_ComponentHelpers.h | 255 +++++++ .../detail/juce_CustomMouseCursorInfo.h | 35 + .../detail/juce_FocusHelpers.h | 117 ++++ .../detail/juce_FocusRestorer.h | 46 ++ .../detail/juce_LookAndFeelHelpers.h | 62 ++ .../detail/juce_MouseInputSourceImpl.h | 589 ++++++++++++++++ .../detail/juce_MouseInputSourceList.h | 154 ++++ .../{mouse => detail}/juce_PointerState.h | 9 +- .../detail/juce_ScalingHelpers.h | 123 ++++ .../detail/juce_ScopedMessageBoxImpl.h | 123 ++++ .../detail/juce_ScopedMessageBoxInterface.h | 60 ++ ...e_ToolbarItemDragAndDropOverlayComponent.h | 118 ++++ .../detail/juce_TopLevelWindowManager.h | 136 ++++ .../detail/juce_ViewportHelpers.h | 49 ++ .../detail/juce_WindowingHelpers.h | 54 ++ .../filebrowser/juce_FileBrowserComponent.cpp | 2 +- .../filebrowser/juce_FileChooser.cpp | 2 +- .../filebrowser/juce_FileChooserDialogBox.cpp | 2 +- .../filebrowser/juce_FileListComponent.cpp | 5 +- .../filebrowser/juce_FileTreeComponent.cpp | 2 +- modules/juce_gui_basics/juce_gui_basics.cpp | 429 ++++-------- modules/juce_gui_basics/juce_gui_basics.h | 16 +- .../keyboard/juce_KeyboardFocusTraverser.cpp | 16 +- .../juce_gui_basics/layout/juce_Viewport.cpp | 19 +- .../lookandfeel/juce_LookAndFeel_V2.cpp | 75 +- .../lookandfeel/juce_LookAndFeel_V4.cpp | 4 +- .../juce_gui_basics/menus/juce_PopupMenu.cpp | 2 +- .../misc/juce_DropShadower.cpp | 2 +- .../mouse/juce_MouseCursor.cpp | 2 +- .../juce_gui_basics/mouse/juce_MouseCursor.h | 2 +- .../mouse/juce_MouseInputSource.cpp | 655 +----------------- .../mouse/juce_MouseInputSource.h | 9 +- .../accessibility/juce_Accessibility.cpp | 33 + .../juce_android_Accessibility.cpp | 54 +- .../accessibility/juce_ios_Accessibility.mm | 22 +- .../accessibility/juce_mac_Accessibility.mm | 16 +- .../juce_mac_AccessibilitySharedCode.mm | 10 +- .../juce_win32_Accessibility.cpp | 22 +- .../juce_win32_AccessibilityElement.cpp | 6 +- .../juce_win32_UIAGridItemProvider.h | 2 +- .../juce_win32_UIAGridProvider.h | 2 +- .../accessibility/juce_win32_UIAProviders.h | 2 +- .../juce_ScopedDPIAwarenessDisabler.cpp | 34 + .../native/juce_android_NativeMessageBox.cpp | 4 +- .../native/juce_android_Windowing.cpp | 12 +- .../native/juce_ios_NativeMessageBox.mm | 4 +- .../native/juce_ios_UIViewComponentPeer.mm | 12 +- .../native/juce_ios_Windowing.mm | 12 +- .../native/juce_linux_NativeMessageBox.cpp | 6 +- .../native/juce_linux_Windowing.cpp | 16 +- .../native/juce_mac_CGMetalLayerRenderer.h | 2 +- .../native/juce_mac_FileChooser.mm | 4 +- .../native/juce_mac_MainMenu.mm | 4 +- .../native/juce_mac_MouseCursor.mm | 6 +- .../native/juce_mac_NSViewComponentPeer.mm | 14 +- .../native/juce_mac_NativeMessageBox.mm | 4 +- .../native/juce_mac_Windowing.mm | 4 +- .../native/juce_win32_FileChooser.cpp | 2 +- .../native/juce_win32_NativeMessageBox.cpp | 6 +- .../native/juce_win32_Windowing.cpp | 88 ++- .../native/x11/juce_linux_X11_DragAndDrop.cpp | 2 +- .../native/x11/juce_linux_X11_Symbols.cpp | 2 +- .../native/x11/juce_linux_X11_Symbols.h | 2 +- .../juce_gui_basics/widgets/juce_ListBox.cpp | 2 +- .../juce_gui_basics/widgets/juce_Toolbar.cpp | 2 +- .../widgets/juce_ToolbarItemComponent.cpp | 95 +-- .../widgets/juce_ToolbarItemComponent.h | 3 +- .../windows/juce_AlertWindow.cpp | 87 +-- .../windows/juce_CallOutBox.cpp | 4 +- .../windows/juce_ComponentPeer.cpp | 6 +- .../windows/juce_DialogWindow.cpp | 2 +- .../windows/juce_NativeMessageBox.cpp | 16 +- .../windows/juce_ScopedMessageBox.cpp | 137 +--- .../windows/juce_ScopedMessageBox.h | 8 +- .../windows/juce_TooltipWindow.cpp | 6 +- .../windows/juce_TopLevelWindow.cpp | 116 +--- .../windows/juce_TopLevelWindow.h | 2 +- 129 files changed, 4458 insertions(+), 2318 deletions(-) create mode 100644 modules/juce_gui_basics/detail/juce_AccessibilityHelpers.cpp create mode 100644 modules/juce_gui_basics/detail/juce_AccessibilityHelpers.h create mode 100644 modules/juce_gui_basics/detail/juce_AlertWindowHelpers.h create mode 100644 modules/juce_gui_basics/detail/juce_ButtonAccessibilityHandler.h create mode 100644 modules/juce_gui_basics/detail/juce_ComponentHelpers.h create mode 100644 modules/juce_gui_basics/detail/juce_CustomMouseCursorInfo.h create mode 100644 modules/juce_gui_basics/detail/juce_FocusHelpers.h create mode 100644 modules/juce_gui_basics/detail/juce_FocusRestorer.h create mode 100644 modules/juce_gui_basics/detail/juce_LookAndFeelHelpers.h create mode 100644 modules/juce_gui_basics/detail/juce_MouseInputSourceImpl.h create mode 100644 modules/juce_gui_basics/detail/juce_MouseInputSourceList.h rename modules/juce_gui_basics/{mouse => detail}/juce_PointerState.h (96%) create mode 100644 modules/juce_gui_basics/detail/juce_ScalingHelpers.h create mode 100644 modules/juce_gui_basics/detail/juce_ScopedMessageBoxImpl.h create mode 100644 modules/juce_gui_basics/detail/juce_ScopedMessageBoxInterface.h create mode 100644 modules/juce_gui_basics/detail/juce_ToolbarItemDragAndDropOverlayComponent.h create mode 100644 modules/juce_gui_basics/detail/juce_TopLevelWindowManager.h create mode 100644 modules/juce_gui_basics/detail/juce_ViewportHelpers.h create mode 100644 modules/juce_gui_basics/detail/juce_WindowingHelpers.h create mode 100644 modules/juce_gui_basics/native/accessibility/juce_Accessibility.cpp create mode 100644 modules/juce_gui_basics/native/juce_ScopedDPIAwarenessDisabler.cpp diff --git a/examples/DemoRunner/Builds/Android/app/CMakeLists.txt b/examples/DemoRunner/Builds/Android/app/CMakeLists.txt index dbc4c0f338..ede5f8cc82 100644 --- a/examples/DemoRunner/Builds/Android/app/CMakeLists.txt +++ b/examples/DemoRunner/Builds/Android/app/CMakeLists.txt @@ -1581,6 +1581,25 @@ add_library( ${BINARY_NAME} "../../../../../modules/juce_gui_basics/desktop/juce_Desktop.h" "../../../../../modules/juce_gui_basics/desktop/juce_Displays.cpp" "../../../../../modules/juce_gui_basics/desktop/juce_Displays.h" + "../../../../../modules/juce_gui_basics/detail/juce_AccessibilityHelpers.cpp" + "../../../../../modules/juce_gui_basics/detail/juce_AccessibilityHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_AlertWindowHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_ButtonAccessibilityHandler.h" + "../../../../../modules/juce_gui_basics/detail/juce_ComponentHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_CustomMouseCursorInfo.h" + "../../../../../modules/juce_gui_basics/detail/juce_FocusHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_FocusRestorer.h" + "../../../../../modules/juce_gui_basics/detail/juce_LookAndFeelHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_MouseInputSourceImpl.h" + "../../../../../modules/juce_gui_basics/detail/juce_MouseInputSourceList.h" + "../../../../../modules/juce_gui_basics/detail/juce_PointerState.h" + "../../../../../modules/juce_gui_basics/detail/juce_ScalingHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_ScopedMessageBoxImpl.h" + "../../../../../modules/juce_gui_basics/detail/juce_ScopedMessageBoxInterface.h" + "../../../../../modules/juce_gui_basics/detail/juce_ToolbarItemDragAndDropOverlayComponent.h" + "../../../../../modules/juce_gui_basics/detail/juce_TopLevelWindowManager.h" + "../../../../../modules/juce_gui_basics/detail/juce_ViewportHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_WindowingHelpers.h" "../../../../../modules/juce_gui_basics/drawables/juce_Drawable.cpp" "../../../../../modules/juce_gui_basics/drawables/juce_Drawable.h" "../../../../../modules/juce_gui_basics/drawables/juce_DrawableComposite.cpp" @@ -1721,10 +1740,10 @@ add_library( ${BINARY_NAME} "../../../../../modules/juce_gui_basics/mouse/juce_MouseInputSource.h" "../../../../../modules/juce_gui_basics/mouse/juce_MouseListener.cpp" "../../../../../modules/juce_gui_basics/mouse/juce_MouseListener.h" - "../../../../../modules/juce_gui_basics/mouse/juce_PointerState.h" "../../../../../modules/juce_gui_basics/mouse/juce_SelectedItemSet.h" "../../../../../modules/juce_gui_basics/mouse/juce_TextDragAndDropTarget.h" "../../../../../modules/juce_gui_basics/mouse/juce_TooltipClient.h" + "../../../../../modules/juce_gui_basics/native/accessibility/juce_Accessibility.cpp" "../../../../../modules/juce_gui_basics/native/accessibility/juce_AccessibilityTextHelpers.h" "../../../../../modules/juce_gui_basics/native/accessibility/juce_AccessibilityTextHelpers_test.cpp" "../../../../../modules/juce_gui_basics/native/accessibility/juce_android_Accessibility.cpp" @@ -1777,6 +1796,7 @@ add_library( ${BINARY_NAME} "../../../../../modules/juce_gui_basics/native/juce_mac_PerScreenDisplayLinks.h" "../../../../../modules/juce_gui_basics/native/juce_mac_Windowing.mm" "../../../../../modules/juce_gui_basics/native/juce_MultiTouchMapper.h" + "../../../../../modules/juce_gui_basics/native/juce_ScopedDPIAwarenessDisabler.cpp" "../../../../../modules/juce_gui_basics/native/juce_ScopedDPIAwarenessDisabler.h" "../../../../../modules/juce_gui_basics/native/juce_win32_DragAndDrop.cpp" "../../../../../modules/juce_gui_basics/native/juce_win32_FileChooser.cpp" @@ -3573,6 +3593,25 @@ set_source_files_properties( "../../../../../modules/juce_gui_basics/desktop/juce_Desktop.h" "../../../../../modules/juce_gui_basics/desktop/juce_Displays.cpp" "../../../../../modules/juce_gui_basics/desktop/juce_Displays.h" + "../../../../../modules/juce_gui_basics/detail/juce_AccessibilityHelpers.cpp" + "../../../../../modules/juce_gui_basics/detail/juce_AccessibilityHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_AlertWindowHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_ButtonAccessibilityHandler.h" + "../../../../../modules/juce_gui_basics/detail/juce_ComponentHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_CustomMouseCursorInfo.h" + "../../../../../modules/juce_gui_basics/detail/juce_FocusHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_FocusRestorer.h" + "../../../../../modules/juce_gui_basics/detail/juce_LookAndFeelHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_MouseInputSourceImpl.h" + "../../../../../modules/juce_gui_basics/detail/juce_MouseInputSourceList.h" + "../../../../../modules/juce_gui_basics/detail/juce_PointerState.h" + "../../../../../modules/juce_gui_basics/detail/juce_ScalingHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_ScopedMessageBoxImpl.h" + "../../../../../modules/juce_gui_basics/detail/juce_ScopedMessageBoxInterface.h" + "../../../../../modules/juce_gui_basics/detail/juce_ToolbarItemDragAndDropOverlayComponent.h" + "../../../../../modules/juce_gui_basics/detail/juce_TopLevelWindowManager.h" + "../../../../../modules/juce_gui_basics/detail/juce_ViewportHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_WindowingHelpers.h" "../../../../../modules/juce_gui_basics/drawables/juce_Drawable.cpp" "../../../../../modules/juce_gui_basics/drawables/juce_Drawable.h" "../../../../../modules/juce_gui_basics/drawables/juce_DrawableComposite.cpp" @@ -3713,10 +3752,10 @@ set_source_files_properties( "../../../../../modules/juce_gui_basics/mouse/juce_MouseInputSource.h" "../../../../../modules/juce_gui_basics/mouse/juce_MouseListener.cpp" "../../../../../modules/juce_gui_basics/mouse/juce_MouseListener.h" - "../../../../../modules/juce_gui_basics/mouse/juce_PointerState.h" "../../../../../modules/juce_gui_basics/mouse/juce_SelectedItemSet.h" "../../../../../modules/juce_gui_basics/mouse/juce_TextDragAndDropTarget.h" "../../../../../modules/juce_gui_basics/mouse/juce_TooltipClient.h" + "../../../../../modules/juce_gui_basics/native/accessibility/juce_Accessibility.cpp" "../../../../../modules/juce_gui_basics/native/accessibility/juce_AccessibilityTextHelpers.h" "../../../../../modules/juce_gui_basics/native/accessibility/juce_AccessibilityTextHelpers_test.cpp" "../../../../../modules/juce_gui_basics/native/accessibility/juce_android_Accessibility.cpp" @@ -3769,6 +3808,7 @@ set_source_files_properties( "../../../../../modules/juce_gui_basics/native/juce_mac_PerScreenDisplayLinks.h" "../../../../../modules/juce_gui_basics/native/juce_mac_Windowing.mm" "../../../../../modules/juce_gui_basics/native/juce_MultiTouchMapper.h" + "../../../../../modules/juce_gui_basics/native/juce_ScopedDPIAwarenessDisabler.cpp" "../../../../../modules/juce_gui_basics/native/juce_ScopedDPIAwarenessDisabler.h" "../../../../../modules/juce_gui_basics/native/juce_win32_DragAndDrop.cpp" "../../../../../modules/juce_gui_basics/native/juce_win32_FileChooser.cpp" diff --git a/examples/DemoRunner/Builds/VisualStudio2017/DemoRunner_App.vcxproj b/examples/DemoRunner/Builds/VisualStudio2017/DemoRunner_App.vcxproj index 9225fc3ad9..c6460aa6e3 100644 --- a/examples/DemoRunner/Builds/VisualStudio2017/DemoRunner_App.vcxproj +++ b/examples/DemoRunner/Builds/VisualStudio2017/DemoRunner_App.vcxproj @@ -2117,6 +2117,9 @@ true + + true + true @@ -2312,6 +2315,9 @@ true + + true + true @@ -2357,6 +2363,9 @@ true + + true + true @@ -3536,6 +3545,24 @@ + + + + + + + + + + + + + + + + + + @@ -3611,7 +3638,6 @@ - diff --git a/examples/DemoRunner/Builds/VisualStudio2017/DemoRunner_App.vcxproj.filters b/examples/DemoRunner/Builds/VisualStudio2017/DemoRunner_App.vcxproj.filters index f010e3d56e..3e6166388e 100644 --- a/examples/DemoRunner/Builds/VisualStudio2017/DemoRunner_App.vcxproj.filters +++ b/examples/DemoRunner/Builds/VisualStudio2017/DemoRunner_App.vcxproj.filters @@ -572,6 +572,9 @@ {B331BC33-9770-3DB5-73F2-BC2469ECCF7F} + + {3B09E947-B78C-1758-E072-7FD67F8DCB00} + {46A17AC9-0BFF-B5CE-26D6-B9D1992C88AC} @@ -2755,6 +2758,9 @@ JUCE Modules\juce_gui_basics\desktop + + JUCE Modules\juce_gui_basics\detail + JUCE Modules\juce_gui_basics\drawables @@ -2950,6 +2956,9 @@ JUCE Modules\juce_gui_basics\mouse + + JUCE Modules\juce_gui_basics\native\accessibility + JUCE Modules\juce_gui_basics\native\accessibility @@ -3034,6 +3043,9 @@ JUCE Modules\juce_gui_basics\native + + JUCE Modules\juce_gui_basics\native + JUCE Modules\juce_gui_basics\native @@ -5934,6 +5946,60 @@ JUCE Modules\juce_gui_basics\desktop + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + JUCE Modules\juce_gui_basics\drawables @@ -6159,9 +6225,6 @@ JUCE Modules\juce_gui_basics\mouse - - JUCE Modules\juce_gui_basics\mouse - JUCE Modules\juce_gui_basics\mouse diff --git a/examples/DemoRunner/Builds/VisualStudio2019/DemoRunner_App.vcxproj b/examples/DemoRunner/Builds/VisualStudio2019/DemoRunner_App.vcxproj index 67b0e05218..e158b92d94 100644 --- a/examples/DemoRunner/Builds/VisualStudio2019/DemoRunner_App.vcxproj +++ b/examples/DemoRunner/Builds/VisualStudio2019/DemoRunner_App.vcxproj @@ -2117,6 +2117,9 @@ true + + true + true @@ -2312,6 +2315,9 @@ true + + true + true @@ -2357,6 +2363,9 @@ true + + true + true @@ -3536,6 +3545,24 @@ + + + + + + + + + + + + + + + + + + @@ -3611,7 +3638,6 @@ - diff --git a/examples/DemoRunner/Builds/VisualStudio2019/DemoRunner_App.vcxproj.filters b/examples/DemoRunner/Builds/VisualStudio2019/DemoRunner_App.vcxproj.filters index 3f34230cf3..5cbdc7a19c 100644 --- a/examples/DemoRunner/Builds/VisualStudio2019/DemoRunner_App.vcxproj.filters +++ b/examples/DemoRunner/Builds/VisualStudio2019/DemoRunner_App.vcxproj.filters @@ -572,6 +572,9 @@ {B331BC33-9770-3DB5-73F2-BC2469ECCF7F} + + {3B09E947-B78C-1758-E072-7FD67F8DCB00} + {46A17AC9-0BFF-B5CE-26D6-B9D1992C88AC} @@ -2755,6 +2758,9 @@ JUCE Modules\juce_gui_basics\desktop + + JUCE Modules\juce_gui_basics\detail + JUCE Modules\juce_gui_basics\drawables @@ -2950,6 +2956,9 @@ JUCE Modules\juce_gui_basics\mouse + + JUCE Modules\juce_gui_basics\native\accessibility + JUCE Modules\juce_gui_basics\native\accessibility @@ -3034,6 +3043,9 @@ JUCE Modules\juce_gui_basics\native + + JUCE Modules\juce_gui_basics\native + JUCE Modules\juce_gui_basics\native @@ -5934,6 +5946,60 @@ JUCE Modules\juce_gui_basics\desktop + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + JUCE Modules\juce_gui_basics\drawables @@ -6159,9 +6225,6 @@ JUCE Modules\juce_gui_basics\mouse - - JUCE Modules\juce_gui_basics\mouse - JUCE Modules\juce_gui_basics\mouse diff --git a/examples/DemoRunner/Builds/VisualStudio2022/DemoRunner_App.vcxproj b/examples/DemoRunner/Builds/VisualStudio2022/DemoRunner_App.vcxproj index fc7239d2d6..0cf2ba1895 100644 --- a/examples/DemoRunner/Builds/VisualStudio2022/DemoRunner_App.vcxproj +++ b/examples/DemoRunner/Builds/VisualStudio2022/DemoRunner_App.vcxproj @@ -2117,6 +2117,9 @@ true + + true + true @@ -2312,6 +2315,9 @@ true + + true + true @@ -2357,6 +2363,9 @@ true + + true + true @@ -3536,6 +3545,24 @@ + + + + + + + + + + + + + + + + + + @@ -3611,7 +3638,6 @@ - diff --git a/examples/DemoRunner/Builds/VisualStudio2022/DemoRunner_App.vcxproj.filters b/examples/DemoRunner/Builds/VisualStudio2022/DemoRunner_App.vcxproj.filters index 2d94bbf3cf..c182128782 100644 --- a/examples/DemoRunner/Builds/VisualStudio2022/DemoRunner_App.vcxproj.filters +++ b/examples/DemoRunner/Builds/VisualStudio2022/DemoRunner_App.vcxproj.filters @@ -572,6 +572,9 @@ {B331BC33-9770-3DB5-73F2-BC2469ECCF7F} + + {3B09E947-B78C-1758-E072-7FD67F8DCB00} + {46A17AC9-0BFF-B5CE-26D6-B9D1992C88AC} @@ -2755,6 +2758,9 @@ JUCE Modules\juce_gui_basics\desktop + + JUCE Modules\juce_gui_basics\detail + JUCE Modules\juce_gui_basics\drawables @@ -2950,6 +2956,9 @@ JUCE Modules\juce_gui_basics\mouse + + JUCE Modules\juce_gui_basics\native\accessibility + JUCE Modules\juce_gui_basics\native\accessibility @@ -3034,6 +3043,9 @@ JUCE Modules\juce_gui_basics\native + + JUCE Modules\juce_gui_basics\native + JUCE Modules\juce_gui_basics\native @@ -5934,6 +5946,60 @@ JUCE Modules\juce_gui_basics\desktop + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + JUCE Modules\juce_gui_basics\drawables @@ -6159,9 +6225,6 @@ JUCE Modules\juce_gui_basics\mouse - - JUCE Modules\juce_gui_basics\mouse - JUCE Modules\juce_gui_basics\mouse diff --git a/extras/AudioPerformanceTest/Builds/Android/app/CMakeLists.txt b/extras/AudioPerformanceTest/Builds/Android/app/CMakeLists.txt index 6fd1ab0a84..7acdeb2331 100644 --- a/extras/AudioPerformanceTest/Builds/Android/app/CMakeLists.txt +++ b/extras/AudioPerformanceTest/Builds/Android/app/CMakeLists.txt @@ -1358,6 +1358,25 @@ add_library( ${BINARY_NAME} "../../../../../modules/juce_gui_basics/desktop/juce_Desktop.h" "../../../../../modules/juce_gui_basics/desktop/juce_Displays.cpp" "../../../../../modules/juce_gui_basics/desktop/juce_Displays.h" + "../../../../../modules/juce_gui_basics/detail/juce_AccessibilityHelpers.cpp" + "../../../../../modules/juce_gui_basics/detail/juce_AccessibilityHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_AlertWindowHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_ButtonAccessibilityHandler.h" + "../../../../../modules/juce_gui_basics/detail/juce_ComponentHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_CustomMouseCursorInfo.h" + "../../../../../modules/juce_gui_basics/detail/juce_FocusHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_FocusRestorer.h" + "../../../../../modules/juce_gui_basics/detail/juce_LookAndFeelHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_MouseInputSourceImpl.h" + "../../../../../modules/juce_gui_basics/detail/juce_MouseInputSourceList.h" + "../../../../../modules/juce_gui_basics/detail/juce_PointerState.h" + "../../../../../modules/juce_gui_basics/detail/juce_ScalingHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_ScopedMessageBoxImpl.h" + "../../../../../modules/juce_gui_basics/detail/juce_ScopedMessageBoxInterface.h" + "../../../../../modules/juce_gui_basics/detail/juce_ToolbarItemDragAndDropOverlayComponent.h" + "../../../../../modules/juce_gui_basics/detail/juce_TopLevelWindowManager.h" + "../../../../../modules/juce_gui_basics/detail/juce_ViewportHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_WindowingHelpers.h" "../../../../../modules/juce_gui_basics/drawables/juce_Drawable.cpp" "../../../../../modules/juce_gui_basics/drawables/juce_Drawable.h" "../../../../../modules/juce_gui_basics/drawables/juce_DrawableComposite.cpp" @@ -1498,10 +1517,10 @@ add_library( ${BINARY_NAME} "../../../../../modules/juce_gui_basics/mouse/juce_MouseInputSource.h" "../../../../../modules/juce_gui_basics/mouse/juce_MouseListener.cpp" "../../../../../modules/juce_gui_basics/mouse/juce_MouseListener.h" - "../../../../../modules/juce_gui_basics/mouse/juce_PointerState.h" "../../../../../modules/juce_gui_basics/mouse/juce_SelectedItemSet.h" "../../../../../modules/juce_gui_basics/mouse/juce_TextDragAndDropTarget.h" "../../../../../modules/juce_gui_basics/mouse/juce_TooltipClient.h" + "../../../../../modules/juce_gui_basics/native/accessibility/juce_Accessibility.cpp" "../../../../../modules/juce_gui_basics/native/accessibility/juce_AccessibilityTextHelpers.h" "../../../../../modules/juce_gui_basics/native/accessibility/juce_AccessibilityTextHelpers_test.cpp" "../../../../../modules/juce_gui_basics/native/accessibility/juce_android_Accessibility.cpp" @@ -1554,6 +1573,7 @@ add_library( ${BINARY_NAME} "../../../../../modules/juce_gui_basics/native/juce_mac_PerScreenDisplayLinks.h" "../../../../../modules/juce_gui_basics/native/juce_mac_Windowing.mm" "../../../../../modules/juce_gui_basics/native/juce_MultiTouchMapper.h" + "../../../../../modules/juce_gui_basics/native/juce_ScopedDPIAwarenessDisabler.cpp" "../../../../../modules/juce_gui_basics/native/juce_ScopedDPIAwarenessDisabler.h" "../../../../../modules/juce_gui_basics/native/juce_win32_DragAndDrop.cpp" "../../../../../modules/juce_gui_basics/native/juce_win32_FileChooser.cpp" @@ -3048,6 +3068,25 @@ set_source_files_properties( "../../../../../modules/juce_gui_basics/desktop/juce_Desktop.h" "../../../../../modules/juce_gui_basics/desktop/juce_Displays.cpp" "../../../../../modules/juce_gui_basics/desktop/juce_Displays.h" + "../../../../../modules/juce_gui_basics/detail/juce_AccessibilityHelpers.cpp" + "../../../../../modules/juce_gui_basics/detail/juce_AccessibilityHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_AlertWindowHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_ButtonAccessibilityHandler.h" + "../../../../../modules/juce_gui_basics/detail/juce_ComponentHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_CustomMouseCursorInfo.h" + "../../../../../modules/juce_gui_basics/detail/juce_FocusHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_FocusRestorer.h" + "../../../../../modules/juce_gui_basics/detail/juce_LookAndFeelHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_MouseInputSourceImpl.h" + "../../../../../modules/juce_gui_basics/detail/juce_MouseInputSourceList.h" + "../../../../../modules/juce_gui_basics/detail/juce_PointerState.h" + "../../../../../modules/juce_gui_basics/detail/juce_ScalingHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_ScopedMessageBoxImpl.h" + "../../../../../modules/juce_gui_basics/detail/juce_ScopedMessageBoxInterface.h" + "../../../../../modules/juce_gui_basics/detail/juce_ToolbarItemDragAndDropOverlayComponent.h" + "../../../../../modules/juce_gui_basics/detail/juce_TopLevelWindowManager.h" + "../../../../../modules/juce_gui_basics/detail/juce_ViewportHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_WindowingHelpers.h" "../../../../../modules/juce_gui_basics/drawables/juce_Drawable.cpp" "../../../../../modules/juce_gui_basics/drawables/juce_Drawable.h" "../../../../../modules/juce_gui_basics/drawables/juce_DrawableComposite.cpp" @@ -3188,10 +3227,10 @@ set_source_files_properties( "../../../../../modules/juce_gui_basics/mouse/juce_MouseInputSource.h" "../../../../../modules/juce_gui_basics/mouse/juce_MouseListener.cpp" "../../../../../modules/juce_gui_basics/mouse/juce_MouseListener.h" - "../../../../../modules/juce_gui_basics/mouse/juce_PointerState.h" "../../../../../modules/juce_gui_basics/mouse/juce_SelectedItemSet.h" "../../../../../modules/juce_gui_basics/mouse/juce_TextDragAndDropTarget.h" "../../../../../modules/juce_gui_basics/mouse/juce_TooltipClient.h" + "../../../../../modules/juce_gui_basics/native/accessibility/juce_Accessibility.cpp" "../../../../../modules/juce_gui_basics/native/accessibility/juce_AccessibilityTextHelpers.h" "../../../../../modules/juce_gui_basics/native/accessibility/juce_AccessibilityTextHelpers_test.cpp" "../../../../../modules/juce_gui_basics/native/accessibility/juce_android_Accessibility.cpp" @@ -3244,6 +3283,7 @@ set_source_files_properties( "../../../../../modules/juce_gui_basics/native/juce_mac_PerScreenDisplayLinks.h" "../../../../../modules/juce_gui_basics/native/juce_mac_Windowing.mm" "../../../../../modules/juce_gui_basics/native/juce_MultiTouchMapper.h" + "../../../../../modules/juce_gui_basics/native/juce_ScopedDPIAwarenessDisabler.cpp" "../../../../../modules/juce_gui_basics/native/juce_ScopedDPIAwarenessDisabler.h" "../../../../../modules/juce_gui_basics/native/juce_win32_DragAndDrop.cpp" "../../../../../modules/juce_gui_basics/native/juce_win32_FileChooser.cpp" diff --git a/extras/AudioPerformanceTest/Builds/VisualStudio2022/AudioPerformanceTest_App.vcxproj b/extras/AudioPerformanceTest/Builds/VisualStudio2022/AudioPerformanceTest_App.vcxproj index a0e4089561..e2060f8754 100644 --- a/extras/AudioPerformanceTest/Builds/VisualStudio2022/AudioPerformanceTest_App.vcxproj +++ b/extras/AudioPerformanceTest/Builds/VisualStudio2022/AudioPerformanceTest_App.vcxproj @@ -1828,6 +1828,9 @@ true + + true + true @@ -2023,6 +2026,9 @@ true + + true + true @@ -2068,6 +2074,9 @@ true + + true + true @@ -3035,6 +3044,24 @@ + + + + + + + + + + + + + + + + + + @@ -3110,7 +3137,6 @@ - diff --git a/extras/AudioPerformanceTest/Builds/VisualStudio2022/AudioPerformanceTest_App.vcxproj.filters b/extras/AudioPerformanceTest/Builds/VisualStudio2022/AudioPerformanceTest_App.vcxproj.filters index 2112c2ec5a..ca1dbf842a 100644 --- a/extras/AudioPerformanceTest/Builds/VisualStudio2022/AudioPerformanceTest_App.vcxproj.filters +++ b/extras/AudioPerformanceTest/Builds/VisualStudio2022/AudioPerformanceTest_App.vcxproj.filters @@ -494,6 +494,9 @@ {B331BC33-9770-3DB5-73F2-BC2469ECCF7F} + + {3B09E947-B78C-1758-E072-7FD67F8DCB00} + {46A17AC9-0BFF-B5CE-26D6-B9D1992C88AC} @@ -2329,6 +2332,9 @@ JUCE Modules\juce_gui_basics\desktop + + JUCE Modules\juce_gui_basics\detail + JUCE Modules\juce_gui_basics\drawables @@ -2524,6 +2530,9 @@ JUCE Modules\juce_gui_basics\mouse + + JUCE Modules\juce_gui_basics\native\accessibility + JUCE Modules\juce_gui_basics\native\accessibility @@ -2608,6 +2617,9 @@ JUCE Modules\juce_gui_basics\native + + JUCE Modules\juce_gui_basics\native + JUCE Modules\juce_gui_basics\native @@ -5049,6 +5061,60 @@ JUCE Modules\juce_gui_basics\desktop + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + JUCE Modules\juce_gui_basics\drawables @@ -5274,9 +5340,6 @@ JUCE Modules\juce_gui_basics\mouse - - JUCE Modules\juce_gui_basics\mouse - JUCE Modules\juce_gui_basics\mouse diff --git a/extras/AudioPluginHost/Builds/Android/app/CMakeLists.txt b/extras/AudioPluginHost/Builds/Android/app/CMakeLists.txt index 10e1f096d4..809107a655 100644 --- a/extras/AudioPluginHost/Builds/Android/app/CMakeLists.txt +++ b/extras/AudioPluginHost/Builds/Android/app/CMakeLists.txt @@ -1490,6 +1490,25 @@ add_library( ${BINARY_NAME} "../../../../../modules/juce_gui_basics/desktop/juce_Desktop.h" "../../../../../modules/juce_gui_basics/desktop/juce_Displays.cpp" "../../../../../modules/juce_gui_basics/desktop/juce_Displays.h" + "../../../../../modules/juce_gui_basics/detail/juce_AccessibilityHelpers.cpp" + "../../../../../modules/juce_gui_basics/detail/juce_AccessibilityHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_AlertWindowHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_ButtonAccessibilityHandler.h" + "../../../../../modules/juce_gui_basics/detail/juce_ComponentHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_CustomMouseCursorInfo.h" + "../../../../../modules/juce_gui_basics/detail/juce_FocusHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_FocusRestorer.h" + "../../../../../modules/juce_gui_basics/detail/juce_LookAndFeelHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_MouseInputSourceImpl.h" + "../../../../../modules/juce_gui_basics/detail/juce_MouseInputSourceList.h" + "../../../../../modules/juce_gui_basics/detail/juce_PointerState.h" + "../../../../../modules/juce_gui_basics/detail/juce_ScalingHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_ScopedMessageBoxImpl.h" + "../../../../../modules/juce_gui_basics/detail/juce_ScopedMessageBoxInterface.h" + "../../../../../modules/juce_gui_basics/detail/juce_ToolbarItemDragAndDropOverlayComponent.h" + "../../../../../modules/juce_gui_basics/detail/juce_TopLevelWindowManager.h" + "../../../../../modules/juce_gui_basics/detail/juce_ViewportHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_WindowingHelpers.h" "../../../../../modules/juce_gui_basics/drawables/juce_Drawable.cpp" "../../../../../modules/juce_gui_basics/drawables/juce_Drawable.h" "../../../../../modules/juce_gui_basics/drawables/juce_DrawableComposite.cpp" @@ -1630,10 +1649,10 @@ add_library( ${BINARY_NAME} "../../../../../modules/juce_gui_basics/mouse/juce_MouseInputSource.h" "../../../../../modules/juce_gui_basics/mouse/juce_MouseListener.cpp" "../../../../../modules/juce_gui_basics/mouse/juce_MouseListener.h" - "../../../../../modules/juce_gui_basics/mouse/juce_PointerState.h" "../../../../../modules/juce_gui_basics/mouse/juce_SelectedItemSet.h" "../../../../../modules/juce_gui_basics/mouse/juce_TextDragAndDropTarget.h" "../../../../../modules/juce_gui_basics/mouse/juce_TooltipClient.h" + "../../../../../modules/juce_gui_basics/native/accessibility/juce_Accessibility.cpp" "../../../../../modules/juce_gui_basics/native/accessibility/juce_AccessibilityTextHelpers.h" "../../../../../modules/juce_gui_basics/native/accessibility/juce_AccessibilityTextHelpers_test.cpp" "../../../../../modules/juce_gui_basics/native/accessibility/juce_android_Accessibility.cpp" @@ -1686,6 +1705,7 @@ add_library( ${BINARY_NAME} "../../../../../modules/juce_gui_basics/native/juce_mac_PerScreenDisplayLinks.h" "../../../../../modules/juce_gui_basics/native/juce_mac_Windowing.mm" "../../../../../modules/juce_gui_basics/native/juce_MultiTouchMapper.h" + "../../../../../modules/juce_gui_basics/native/juce_ScopedDPIAwarenessDisabler.cpp" "../../../../../modules/juce_gui_basics/native/juce_ScopedDPIAwarenessDisabler.h" "../../../../../modules/juce_gui_basics/native/juce_win32_DragAndDrop.cpp" "../../../../../modules/juce_gui_basics/native/juce_win32_FileChooser.cpp" @@ -3335,6 +3355,25 @@ set_source_files_properties( "../../../../../modules/juce_gui_basics/desktop/juce_Desktop.h" "../../../../../modules/juce_gui_basics/desktop/juce_Displays.cpp" "../../../../../modules/juce_gui_basics/desktop/juce_Displays.h" + "../../../../../modules/juce_gui_basics/detail/juce_AccessibilityHelpers.cpp" + "../../../../../modules/juce_gui_basics/detail/juce_AccessibilityHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_AlertWindowHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_ButtonAccessibilityHandler.h" + "../../../../../modules/juce_gui_basics/detail/juce_ComponentHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_CustomMouseCursorInfo.h" + "../../../../../modules/juce_gui_basics/detail/juce_FocusHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_FocusRestorer.h" + "../../../../../modules/juce_gui_basics/detail/juce_LookAndFeelHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_MouseInputSourceImpl.h" + "../../../../../modules/juce_gui_basics/detail/juce_MouseInputSourceList.h" + "../../../../../modules/juce_gui_basics/detail/juce_PointerState.h" + "../../../../../modules/juce_gui_basics/detail/juce_ScalingHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_ScopedMessageBoxImpl.h" + "../../../../../modules/juce_gui_basics/detail/juce_ScopedMessageBoxInterface.h" + "../../../../../modules/juce_gui_basics/detail/juce_ToolbarItemDragAndDropOverlayComponent.h" + "../../../../../modules/juce_gui_basics/detail/juce_TopLevelWindowManager.h" + "../../../../../modules/juce_gui_basics/detail/juce_ViewportHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_WindowingHelpers.h" "../../../../../modules/juce_gui_basics/drawables/juce_Drawable.cpp" "../../../../../modules/juce_gui_basics/drawables/juce_Drawable.h" "../../../../../modules/juce_gui_basics/drawables/juce_DrawableComposite.cpp" @@ -3475,10 +3514,10 @@ set_source_files_properties( "../../../../../modules/juce_gui_basics/mouse/juce_MouseInputSource.h" "../../../../../modules/juce_gui_basics/mouse/juce_MouseListener.cpp" "../../../../../modules/juce_gui_basics/mouse/juce_MouseListener.h" - "../../../../../modules/juce_gui_basics/mouse/juce_PointerState.h" "../../../../../modules/juce_gui_basics/mouse/juce_SelectedItemSet.h" "../../../../../modules/juce_gui_basics/mouse/juce_TextDragAndDropTarget.h" "../../../../../modules/juce_gui_basics/mouse/juce_TooltipClient.h" + "../../../../../modules/juce_gui_basics/native/accessibility/juce_Accessibility.cpp" "../../../../../modules/juce_gui_basics/native/accessibility/juce_AccessibilityTextHelpers.h" "../../../../../modules/juce_gui_basics/native/accessibility/juce_AccessibilityTextHelpers_test.cpp" "../../../../../modules/juce_gui_basics/native/accessibility/juce_android_Accessibility.cpp" @@ -3531,6 +3570,7 @@ set_source_files_properties( "../../../../../modules/juce_gui_basics/native/juce_mac_PerScreenDisplayLinks.h" "../../../../../modules/juce_gui_basics/native/juce_mac_Windowing.mm" "../../../../../modules/juce_gui_basics/native/juce_MultiTouchMapper.h" + "../../../../../modules/juce_gui_basics/native/juce_ScopedDPIAwarenessDisabler.cpp" "../../../../../modules/juce_gui_basics/native/juce_ScopedDPIAwarenessDisabler.h" "../../../../../modules/juce_gui_basics/native/juce_win32_DragAndDrop.cpp" "../../../../../modules/juce_gui_basics/native/juce_win32_FileChooser.cpp" diff --git a/extras/AudioPluginHost/Builds/VisualStudio2017/AudioPluginHost_App.vcxproj b/extras/AudioPluginHost/Builds/VisualStudio2017/AudioPluginHost_App.vcxproj index 8814e5140b..f59f630000 100644 --- a/extras/AudioPluginHost/Builds/VisualStudio2017/AudioPluginHost_App.vcxproj +++ b/extras/AudioPluginHost/Builds/VisualStudio2017/AudioPluginHost_App.vcxproj @@ -1965,6 +1965,9 @@ true + + true + true @@ -2160,6 +2163,9 @@ true + + true + true @@ -2205,6 +2211,9 @@ true + + true + true @@ -3272,6 +3281,24 @@ + + + + + + + + + + + + + + + + + + @@ -3347,7 +3374,6 @@ - diff --git a/extras/AudioPluginHost/Builds/VisualStudio2017/AudioPluginHost_App.vcxproj.filters b/extras/AudioPluginHost/Builds/VisualStudio2017/AudioPluginHost_App.vcxproj.filters index 258dfd0aab..bf33d16e66 100644 --- a/extras/AudioPluginHost/Builds/VisualStudio2017/AudioPluginHost_App.vcxproj.filters +++ b/extras/AudioPluginHost/Builds/VisualStudio2017/AudioPluginHost_App.vcxproj.filters @@ -536,6 +536,9 @@ {B331BC33-9770-3DB5-73F2-BC2469ECCF7F} + + {3B09E947-B78C-1758-E072-7FD67F8DCB00} + {46A17AC9-0BFF-B5CE-26D6-B9D1992C88AC} @@ -2539,6 +2542,9 @@ JUCE Modules\juce_gui_basics\desktop + + JUCE Modules\juce_gui_basics\detail + JUCE Modules\juce_gui_basics\drawables @@ -2734,6 +2740,9 @@ JUCE Modules\juce_gui_basics\mouse + + JUCE Modules\juce_gui_basics\native\accessibility + JUCE Modules\juce_gui_basics\native\accessibility @@ -2818,6 +2827,9 @@ JUCE Modules\juce_gui_basics\native + + JUCE Modules\juce_gui_basics\native + JUCE Modules\juce_gui_basics\native @@ -5490,6 +5502,60 @@ JUCE Modules\juce_gui_basics\desktop + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + JUCE Modules\juce_gui_basics\drawables @@ -5715,9 +5781,6 @@ JUCE Modules\juce_gui_basics\mouse - - JUCE Modules\juce_gui_basics\mouse - JUCE Modules\juce_gui_basics\mouse diff --git a/extras/AudioPluginHost/Builds/VisualStudio2019/AudioPluginHost_App.vcxproj b/extras/AudioPluginHost/Builds/VisualStudio2019/AudioPluginHost_App.vcxproj index 5e1f9b37c8..7d78468c22 100644 --- a/extras/AudioPluginHost/Builds/VisualStudio2019/AudioPluginHost_App.vcxproj +++ b/extras/AudioPluginHost/Builds/VisualStudio2019/AudioPluginHost_App.vcxproj @@ -1965,6 +1965,9 @@ true + + true + true @@ -2160,6 +2163,9 @@ true + + true + true @@ -2205,6 +2211,9 @@ true + + true + true @@ -3272,6 +3281,24 @@ + + + + + + + + + + + + + + + + + + @@ -3347,7 +3374,6 @@ - diff --git a/extras/AudioPluginHost/Builds/VisualStudio2019/AudioPluginHost_App.vcxproj.filters b/extras/AudioPluginHost/Builds/VisualStudio2019/AudioPluginHost_App.vcxproj.filters index 76f824c054..e5d60e4800 100644 --- a/extras/AudioPluginHost/Builds/VisualStudio2019/AudioPluginHost_App.vcxproj.filters +++ b/extras/AudioPluginHost/Builds/VisualStudio2019/AudioPluginHost_App.vcxproj.filters @@ -536,6 +536,9 @@ {B331BC33-9770-3DB5-73F2-BC2469ECCF7F} + + {3B09E947-B78C-1758-E072-7FD67F8DCB00} + {46A17AC9-0BFF-B5CE-26D6-B9D1992C88AC} @@ -2539,6 +2542,9 @@ JUCE Modules\juce_gui_basics\desktop + + JUCE Modules\juce_gui_basics\detail + JUCE Modules\juce_gui_basics\drawables @@ -2734,6 +2740,9 @@ JUCE Modules\juce_gui_basics\mouse + + JUCE Modules\juce_gui_basics\native\accessibility + JUCE Modules\juce_gui_basics\native\accessibility @@ -2818,6 +2827,9 @@ JUCE Modules\juce_gui_basics\native + + JUCE Modules\juce_gui_basics\native + JUCE Modules\juce_gui_basics\native @@ -5490,6 +5502,60 @@ JUCE Modules\juce_gui_basics\desktop + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + JUCE Modules\juce_gui_basics\drawables @@ -5715,9 +5781,6 @@ JUCE Modules\juce_gui_basics\mouse - - JUCE Modules\juce_gui_basics\mouse - JUCE Modules\juce_gui_basics\mouse diff --git a/extras/AudioPluginHost/Builds/VisualStudio2022/AudioPluginHost_App.vcxproj b/extras/AudioPluginHost/Builds/VisualStudio2022/AudioPluginHost_App.vcxproj index c1c68a7b2b..38a6868588 100644 --- a/extras/AudioPluginHost/Builds/VisualStudio2022/AudioPluginHost_App.vcxproj +++ b/extras/AudioPluginHost/Builds/VisualStudio2022/AudioPluginHost_App.vcxproj @@ -1965,6 +1965,9 @@ true + + true + true @@ -2160,6 +2163,9 @@ true + + true + true @@ -2205,6 +2211,9 @@ true + + true + true @@ -3272,6 +3281,24 @@ + + + + + + + + + + + + + + + + + + @@ -3347,7 +3374,6 @@ - diff --git a/extras/AudioPluginHost/Builds/VisualStudio2022/AudioPluginHost_App.vcxproj.filters b/extras/AudioPluginHost/Builds/VisualStudio2022/AudioPluginHost_App.vcxproj.filters index f525b9226c..6915dddcb8 100644 --- a/extras/AudioPluginHost/Builds/VisualStudio2022/AudioPluginHost_App.vcxproj.filters +++ b/extras/AudioPluginHost/Builds/VisualStudio2022/AudioPluginHost_App.vcxproj.filters @@ -536,6 +536,9 @@ {B331BC33-9770-3DB5-73F2-BC2469ECCF7F} + + {3B09E947-B78C-1758-E072-7FD67F8DCB00} + {46A17AC9-0BFF-B5CE-26D6-B9D1992C88AC} @@ -2539,6 +2542,9 @@ JUCE Modules\juce_gui_basics\desktop + + JUCE Modules\juce_gui_basics\detail + JUCE Modules\juce_gui_basics\drawables @@ -2734,6 +2740,9 @@ JUCE Modules\juce_gui_basics\mouse + + JUCE Modules\juce_gui_basics\native\accessibility + JUCE Modules\juce_gui_basics\native\accessibility @@ -2818,6 +2827,9 @@ JUCE Modules\juce_gui_basics\native + + JUCE Modules\juce_gui_basics\native + JUCE Modules\juce_gui_basics\native @@ -5490,6 +5502,60 @@ JUCE Modules\juce_gui_basics\desktop + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + JUCE Modules\juce_gui_basics\drawables @@ -5715,9 +5781,6 @@ JUCE Modules\juce_gui_basics\mouse - - JUCE Modules\juce_gui_basics\mouse - JUCE Modules\juce_gui_basics\mouse diff --git a/extras/NetworkGraphicsDemo/Builds/Android/app/CMakeLists.txt b/extras/NetworkGraphicsDemo/Builds/Android/app/CMakeLists.txt index 9c525cc70e..b5c03ad1de 100644 --- a/extras/NetworkGraphicsDemo/Builds/Android/app/CMakeLists.txt +++ b/extras/NetworkGraphicsDemo/Builds/Android/app/CMakeLists.txt @@ -1377,6 +1377,25 @@ add_library( ${BINARY_NAME} "../../../../../modules/juce_gui_basics/desktop/juce_Desktop.h" "../../../../../modules/juce_gui_basics/desktop/juce_Displays.cpp" "../../../../../modules/juce_gui_basics/desktop/juce_Displays.h" + "../../../../../modules/juce_gui_basics/detail/juce_AccessibilityHelpers.cpp" + "../../../../../modules/juce_gui_basics/detail/juce_AccessibilityHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_AlertWindowHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_ButtonAccessibilityHandler.h" + "../../../../../modules/juce_gui_basics/detail/juce_ComponentHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_CustomMouseCursorInfo.h" + "../../../../../modules/juce_gui_basics/detail/juce_FocusHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_FocusRestorer.h" + "../../../../../modules/juce_gui_basics/detail/juce_LookAndFeelHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_MouseInputSourceImpl.h" + "../../../../../modules/juce_gui_basics/detail/juce_MouseInputSourceList.h" + "../../../../../modules/juce_gui_basics/detail/juce_PointerState.h" + "../../../../../modules/juce_gui_basics/detail/juce_ScalingHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_ScopedMessageBoxImpl.h" + "../../../../../modules/juce_gui_basics/detail/juce_ScopedMessageBoxInterface.h" + "../../../../../modules/juce_gui_basics/detail/juce_ToolbarItemDragAndDropOverlayComponent.h" + "../../../../../modules/juce_gui_basics/detail/juce_TopLevelWindowManager.h" + "../../../../../modules/juce_gui_basics/detail/juce_ViewportHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_WindowingHelpers.h" "../../../../../modules/juce_gui_basics/drawables/juce_Drawable.cpp" "../../../../../modules/juce_gui_basics/drawables/juce_Drawable.h" "../../../../../modules/juce_gui_basics/drawables/juce_DrawableComposite.cpp" @@ -1517,10 +1536,10 @@ add_library( ${BINARY_NAME} "../../../../../modules/juce_gui_basics/mouse/juce_MouseInputSource.h" "../../../../../modules/juce_gui_basics/mouse/juce_MouseListener.cpp" "../../../../../modules/juce_gui_basics/mouse/juce_MouseListener.h" - "../../../../../modules/juce_gui_basics/mouse/juce_PointerState.h" "../../../../../modules/juce_gui_basics/mouse/juce_SelectedItemSet.h" "../../../../../modules/juce_gui_basics/mouse/juce_TextDragAndDropTarget.h" "../../../../../modules/juce_gui_basics/mouse/juce_TooltipClient.h" + "../../../../../modules/juce_gui_basics/native/accessibility/juce_Accessibility.cpp" "../../../../../modules/juce_gui_basics/native/accessibility/juce_AccessibilityTextHelpers.h" "../../../../../modules/juce_gui_basics/native/accessibility/juce_AccessibilityTextHelpers_test.cpp" "../../../../../modules/juce_gui_basics/native/accessibility/juce_android_Accessibility.cpp" @@ -1573,6 +1592,7 @@ add_library( ${BINARY_NAME} "../../../../../modules/juce_gui_basics/native/juce_mac_PerScreenDisplayLinks.h" "../../../../../modules/juce_gui_basics/native/juce_mac_Windowing.mm" "../../../../../modules/juce_gui_basics/native/juce_MultiTouchMapper.h" + "../../../../../modules/juce_gui_basics/native/juce_ScopedDPIAwarenessDisabler.cpp" "../../../../../modules/juce_gui_basics/native/juce_ScopedDPIAwarenessDisabler.h" "../../../../../modules/juce_gui_basics/native/juce_win32_DragAndDrop.cpp" "../../../../../modules/juce_gui_basics/native/juce_win32_FileChooser.cpp" @@ -3147,6 +3167,25 @@ set_source_files_properties( "../../../../../modules/juce_gui_basics/desktop/juce_Desktop.h" "../../../../../modules/juce_gui_basics/desktop/juce_Displays.cpp" "../../../../../modules/juce_gui_basics/desktop/juce_Displays.h" + "../../../../../modules/juce_gui_basics/detail/juce_AccessibilityHelpers.cpp" + "../../../../../modules/juce_gui_basics/detail/juce_AccessibilityHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_AlertWindowHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_ButtonAccessibilityHandler.h" + "../../../../../modules/juce_gui_basics/detail/juce_ComponentHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_CustomMouseCursorInfo.h" + "../../../../../modules/juce_gui_basics/detail/juce_FocusHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_FocusRestorer.h" + "../../../../../modules/juce_gui_basics/detail/juce_LookAndFeelHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_MouseInputSourceImpl.h" + "../../../../../modules/juce_gui_basics/detail/juce_MouseInputSourceList.h" + "../../../../../modules/juce_gui_basics/detail/juce_PointerState.h" + "../../../../../modules/juce_gui_basics/detail/juce_ScalingHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_ScopedMessageBoxImpl.h" + "../../../../../modules/juce_gui_basics/detail/juce_ScopedMessageBoxInterface.h" + "../../../../../modules/juce_gui_basics/detail/juce_ToolbarItemDragAndDropOverlayComponent.h" + "../../../../../modules/juce_gui_basics/detail/juce_TopLevelWindowManager.h" + "../../../../../modules/juce_gui_basics/detail/juce_ViewportHelpers.h" + "../../../../../modules/juce_gui_basics/detail/juce_WindowingHelpers.h" "../../../../../modules/juce_gui_basics/drawables/juce_Drawable.cpp" "../../../../../modules/juce_gui_basics/drawables/juce_Drawable.h" "../../../../../modules/juce_gui_basics/drawables/juce_DrawableComposite.cpp" @@ -3287,10 +3326,10 @@ set_source_files_properties( "../../../../../modules/juce_gui_basics/mouse/juce_MouseInputSource.h" "../../../../../modules/juce_gui_basics/mouse/juce_MouseListener.cpp" "../../../../../modules/juce_gui_basics/mouse/juce_MouseListener.h" - "../../../../../modules/juce_gui_basics/mouse/juce_PointerState.h" "../../../../../modules/juce_gui_basics/mouse/juce_SelectedItemSet.h" "../../../../../modules/juce_gui_basics/mouse/juce_TextDragAndDropTarget.h" "../../../../../modules/juce_gui_basics/mouse/juce_TooltipClient.h" + "../../../../../modules/juce_gui_basics/native/accessibility/juce_Accessibility.cpp" "../../../../../modules/juce_gui_basics/native/accessibility/juce_AccessibilityTextHelpers.h" "../../../../../modules/juce_gui_basics/native/accessibility/juce_AccessibilityTextHelpers_test.cpp" "../../../../../modules/juce_gui_basics/native/accessibility/juce_android_Accessibility.cpp" @@ -3343,6 +3382,7 @@ set_source_files_properties( "../../../../../modules/juce_gui_basics/native/juce_mac_PerScreenDisplayLinks.h" "../../../../../modules/juce_gui_basics/native/juce_mac_Windowing.mm" "../../../../../modules/juce_gui_basics/native/juce_MultiTouchMapper.h" + "../../../../../modules/juce_gui_basics/native/juce_ScopedDPIAwarenessDisabler.cpp" "../../../../../modules/juce_gui_basics/native/juce_ScopedDPIAwarenessDisabler.h" "../../../../../modules/juce_gui_basics/native/juce_win32_DragAndDrop.cpp" "../../../../../modules/juce_gui_basics/native/juce_win32_FileChooser.cpp" diff --git a/extras/NetworkGraphicsDemo/Builds/VisualStudio2022/NetworkGraphicsDemo_App.vcxproj b/extras/NetworkGraphicsDemo/Builds/VisualStudio2022/NetworkGraphicsDemo_App.vcxproj index a880d852c3..baea5bd303 100644 --- a/extras/NetworkGraphicsDemo/Builds/VisualStudio2022/NetworkGraphicsDemo_App.vcxproj +++ b/extras/NetworkGraphicsDemo/Builds/VisualStudio2022/NetworkGraphicsDemo_App.vcxproj @@ -1849,6 +1849,9 @@ true + + true + true @@ -2044,6 +2047,9 @@ true + + true + true @@ -2089,6 +2095,9 @@ true + + true + true @@ -3133,6 +3142,24 @@ + + + + + + + + + + + + + + + + + + @@ -3208,7 +3235,6 @@ - diff --git a/extras/NetworkGraphicsDemo/Builds/VisualStudio2022/NetworkGraphicsDemo_App.vcxproj.filters b/extras/NetworkGraphicsDemo/Builds/VisualStudio2022/NetworkGraphicsDemo_App.vcxproj.filters index 9a85ed821d..aeccc83a27 100644 --- a/extras/NetworkGraphicsDemo/Builds/VisualStudio2022/NetworkGraphicsDemo_App.vcxproj.filters +++ b/extras/NetworkGraphicsDemo/Builds/VisualStudio2022/NetworkGraphicsDemo_App.vcxproj.filters @@ -503,6 +503,9 @@ {B331BC33-9770-3DB5-73F2-BC2469ECCF7F} + + {3B09E947-B78C-1758-E072-7FD67F8DCB00} + {46A17AC9-0BFF-B5CE-26D6-B9D1992C88AC} @@ -2383,6 +2386,9 @@ JUCE Modules\juce_gui_basics\desktop + + JUCE Modules\juce_gui_basics\detail + JUCE Modules\juce_gui_basics\drawables @@ -2578,6 +2584,9 @@ JUCE Modules\juce_gui_basics\mouse + + JUCE Modules\juce_gui_basics\native\accessibility + JUCE Modules\juce_gui_basics\native\accessibility @@ -2662,6 +2671,9 @@ JUCE Modules\juce_gui_basics\native + + JUCE Modules\juce_gui_basics\native + JUCE Modules\juce_gui_basics\native @@ -5211,6 +5223,60 @@ JUCE Modules\juce_gui_basics\desktop + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + JUCE Modules\juce_gui_basics\drawables @@ -5436,9 +5502,6 @@ JUCE Modules\juce_gui_basics\mouse - - JUCE Modules\juce_gui_basics\mouse - JUCE Modules\juce_gui_basics\mouse diff --git a/extras/Projucer/Builds/VisualStudio2017/Projucer_App.vcxproj b/extras/Projucer/Builds/VisualStudio2017/Projucer_App.vcxproj index 6e59412877..216bd729c5 100644 --- a/extras/Projucer/Builds/VisualStudio2017/Projucer_App.vcxproj +++ b/extras/Projucer/Builds/VisualStudio2017/Projucer_App.vcxproj @@ -1082,6 +1082,9 @@ true + + true + true @@ -1277,6 +1280,9 @@ true + + true + true @@ -1322,6 +1328,9 @@ true + + true + true @@ -2020,6 +2029,24 @@ + + + + + + + + + + + + + + + + + + @@ -2095,7 +2122,6 @@ - diff --git a/extras/Projucer/Builds/VisualStudio2017/Projucer_App.vcxproj.filters b/extras/Projucer/Builds/VisualStudio2017/Projucer_App.vcxproj.filters index 9e4bb0c69c..157e0746ab 100644 --- a/extras/Projucer/Builds/VisualStudio2017/Projucer_App.vcxproj.filters +++ b/extras/Projucer/Builds/VisualStudio2017/Projucer_App.vcxproj.filters @@ -248,6 +248,9 @@ {B331BC33-9770-3DB5-73F2-BC2469ECCF7F} + + {3B09E947-B78C-1758-E072-7FD67F8DCB00} + {46A17AC9-0BFF-B5CE-26D6-B9D1992C88AC} @@ -1402,6 +1405,9 @@ JUCE Modules\juce_gui_basics\desktop + + JUCE Modules\juce_gui_basics\detail + JUCE Modules\juce_gui_basics\drawables @@ -1597,6 +1603,9 @@ JUCE Modules\juce_gui_basics\mouse + + JUCE Modules\juce_gui_basics\native\accessibility + JUCE Modules\juce_gui_basics\native\accessibility @@ -1681,6 +1690,9 @@ JUCE Modules\juce_gui_basics\native + + JUCE Modules\juce_gui_basics\native + JUCE Modules\juce_gui_basics\native @@ -3321,6 +3333,60 @@ JUCE Modules\juce_gui_basics\desktop + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + JUCE Modules\juce_gui_basics\drawables @@ -3546,9 +3612,6 @@ JUCE Modules\juce_gui_basics\mouse - - JUCE Modules\juce_gui_basics\mouse - JUCE Modules\juce_gui_basics\mouse diff --git a/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj b/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj index aa320a2acc..5fc7453fb3 100644 --- a/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj +++ b/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj @@ -1082,6 +1082,9 @@ true + + true + true @@ -1277,6 +1280,9 @@ true + + true + true @@ -1322,6 +1328,9 @@ true + + true + true @@ -2020,6 +2029,24 @@ + + + + + + + + + + + + + + + + + + @@ -2095,7 +2122,6 @@ - diff --git a/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj.filters b/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj.filters index d4fe2e995c..995dfb64f8 100644 --- a/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj.filters +++ b/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj.filters @@ -248,6 +248,9 @@ {B331BC33-9770-3DB5-73F2-BC2469ECCF7F} + + {3B09E947-B78C-1758-E072-7FD67F8DCB00} + {46A17AC9-0BFF-B5CE-26D6-B9D1992C88AC} @@ -1402,6 +1405,9 @@ JUCE Modules\juce_gui_basics\desktop + + JUCE Modules\juce_gui_basics\detail + JUCE Modules\juce_gui_basics\drawables @@ -1597,6 +1603,9 @@ JUCE Modules\juce_gui_basics\mouse + + JUCE Modules\juce_gui_basics\native\accessibility + JUCE Modules\juce_gui_basics\native\accessibility @@ -1681,6 +1690,9 @@ JUCE Modules\juce_gui_basics\native + + JUCE Modules\juce_gui_basics\native + JUCE Modules\juce_gui_basics\native @@ -3321,6 +3333,60 @@ JUCE Modules\juce_gui_basics\desktop + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + JUCE Modules\juce_gui_basics\drawables @@ -3546,9 +3612,6 @@ JUCE Modules\juce_gui_basics\mouse - - JUCE Modules\juce_gui_basics\mouse - JUCE Modules\juce_gui_basics\mouse diff --git a/extras/Projucer/Builds/VisualStudio2022/Projucer_App.vcxproj b/extras/Projucer/Builds/VisualStudio2022/Projucer_App.vcxproj index ed8bbc15ad..0a0a0068e6 100644 --- a/extras/Projucer/Builds/VisualStudio2022/Projucer_App.vcxproj +++ b/extras/Projucer/Builds/VisualStudio2022/Projucer_App.vcxproj @@ -1082,6 +1082,9 @@ true + + true + true @@ -1277,6 +1280,9 @@ true + + true + true @@ -1322,6 +1328,9 @@ true + + true + true @@ -2020,6 +2029,24 @@ + + + + + + + + + + + + + + + + + + @@ -2095,7 +2122,6 @@ - diff --git a/extras/Projucer/Builds/VisualStudio2022/Projucer_App.vcxproj.filters b/extras/Projucer/Builds/VisualStudio2022/Projucer_App.vcxproj.filters index 7828b5f98f..77ec31ee2c 100644 --- a/extras/Projucer/Builds/VisualStudio2022/Projucer_App.vcxproj.filters +++ b/extras/Projucer/Builds/VisualStudio2022/Projucer_App.vcxproj.filters @@ -248,6 +248,9 @@ {B331BC33-9770-3DB5-73F2-BC2469ECCF7F} + + {3B09E947-B78C-1758-E072-7FD67F8DCB00} + {46A17AC9-0BFF-B5CE-26D6-B9D1992C88AC} @@ -1402,6 +1405,9 @@ JUCE Modules\juce_gui_basics\desktop + + JUCE Modules\juce_gui_basics\detail + JUCE Modules\juce_gui_basics\drawables @@ -1597,6 +1603,9 @@ JUCE Modules\juce_gui_basics\mouse + + JUCE Modules\juce_gui_basics\native\accessibility + JUCE Modules\juce_gui_basics\native\accessibility @@ -1681,6 +1690,9 @@ JUCE Modules\juce_gui_basics\native + + JUCE Modules\juce_gui_basics\native + JUCE Modules\juce_gui_basics\native @@ -3321,6 +3333,60 @@ JUCE Modules\juce_gui_basics\desktop + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + JUCE Modules\juce_gui_basics\drawables @@ -3546,9 +3612,6 @@ JUCE Modules\juce_gui_basics\mouse - - JUCE Modules\juce_gui_basics\mouse - JUCE Modules\juce_gui_basics\mouse diff --git a/extras/UnitTestRunner/Builds/VisualStudio2017/UnitTestRunner_ConsoleApp.vcxproj b/extras/UnitTestRunner/Builds/VisualStudio2017/UnitTestRunner_ConsoleApp.vcxproj index 1fde377032..879bcff019 100644 --- a/extras/UnitTestRunner/Builds/VisualStudio2017/UnitTestRunner_ConsoleApp.vcxproj +++ b/extras/UnitTestRunner/Builds/VisualStudio2017/UnitTestRunner_ConsoleApp.vcxproj @@ -1973,6 +1973,9 @@ true + + true + true @@ -2168,6 +2171,9 @@ true + + true + true @@ -2213,6 +2219,9 @@ true + + true + true @@ -3338,6 +3347,24 @@ + + + + + + + + + + + + + + + + + + @@ -3413,7 +3440,6 @@ - diff --git a/extras/UnitTestRunner/Builds/VisualStudio2017/UnitTestRunner_ConsoleApp.vcxproj.filters b/extras/UnitTestRunner/Builds/VisualStudio2017/UnitTestRunner_ConsoleApp.vcxproj.filters index 13b7a8acfd..323134bb30 100644 --- a/extras/UnitTestRunner/Builds/VisualStudio2017/UnitTestRunner_ConsoleApp.vcxproj.filters +++ b/extras/UnitTestRunner/Builds/VisualStudio2017/UnitTestRunner_ConsoleApp.vcxproj.filters @@ -536,6 +536,9 @@ {B331BC33-9770-3DB5-73F2-BC2469ECCF7F} + + {3B09E947-B78C-1758-E072-7FD67F8DCB00} + {46A17AC9-0BFF-B5CE-26D6-B9D1992C88AC} @@ -2563,6 +2566,9 @@ JUCE Modules\juce_gui_basics\desktop + + JUCE Modules\juce_gui_basics\detail + JUCE Modules\juce_gui_basics\drawables @@ -2758,6 +2764,9 @@ JUCE Modules\juce_gui_basics\mouse + + JUCE Modules\juce_gui_basics\native\accessibility + JUCE Modules\juce_gui_basics\native\accessibility @@ -2842,6 +2851,9 @@ JUCE Modules\juce_gui_basics\native + + JUCE Modules\juce_gui_basics\native + JUCE Modules\juce_gui_basics\native @@ -5580,6 +5592,60 @@ JUCE Modules\juce_gui_basics\desktop + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + JUCE Modules\juce_gui_basics\drawables @@ -5805,9 +5871,6 @@ JUCE Modules\juce_gui_basics\mouse - - JUCE Modules\juce_gui_basics\mouse - JUCE Modules\juce_gui_basics\mouse diff --git a/extras/UnitTestRunner/Builds/VisualStudio2019/UnitTestRunner_ConsoleApp.vcxproj b/extras/UnitTestRunner/Builds/VisualStudio2019/UnitTestRunner_ConsoleApp.vcxproj index e214a03745..85e1ca15c0 100644 --- a/extras/UnitTestRunner/Builds/VisualStudio2019/UnitTestRunner_ConsoleApp.vcxproj +++ b/extras/UnitTestRunner/Builds/VisualStudio2019/UnitTestRunner_ConsoleApp.vcxproj @@ -1973,6 +1973,9 @@ true + + true + true @@ -2168,6 +2171,9 @@ true + + true + true @@ -2213,6 +2219,9 @@ true + + true + true @@ -3338,6 +3347,24 @@ + + + + + + + + + + + + + + + + + + @@ -3413,7 +3440,6 @@ - diff --git a/extras/UnitTestRunner/Builds/VisualStudio2019/UnitTestRunner_ConsoleApp.vcxproj.filters b/extras/UnitTestRunner/Builds/VisualStudio2019/UnitTestRunner_ConsoleApp.vcxproj.filters index 1436726ae2..8069f81efa 100644 --- a/extras/UnitTestRunner/Builds/VisualStudio2019/UnitTestRunner_ConsoleApp.vcxproj.filters +++ b/extras/UnitTestRunner/Builds/VisualStudio2019/UnitTestRunner_ConsoleApp.vcxproj.filters @@ -536,6 +536,9 @@ {B331BC33-9770-3DB5-73F2-BC2469ECCF7F} + + {3B09E947-B78C-1758-E072-7FD67F8DCB00} + {46A17AC9-0BFF-B5CE-26D6-B9D1992C88AC} @@ -2563,6 +2566,9 @@ JUCE Modules\juce_gui_basics\desktop + + JUCE Modules\juce_gui_basics\detail + JUCE Modules\juce_gui_basics\drawables @@ -2758,6 +2764,9 @@ JUCE Modules\juce_gui_basics\mouse + + JUCE Modules\juce_gui_basics\native\accessibility + JUCE Modules\juce_gui_basics\native\accessibility @@ -2842,6 +2851,9 @@ JUCE Modules\juce_gui_basics\native + + JUCE Modules\juce_gui_basics\native + JUCE Modules\juce_gui_basics\native @@ -5580,6 +5592,60 @@ JUCE Modules\juce_gui_basics\desktop + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + JUCE Modules\juce_gui_basics\drawables @@ -5805,9 +5871,6 @@ JUCE Modules\juce_gui_basics\mouse - - JUCE Modules\juce_gui_basics\mouse - JUCE Modules\juce_gui_basics\mouse diff --git a/extras/UnitTestRunner/Builds/VisualStudio2022/UnitTestRunner_ConsoleApp.vcxproj b/extras/UnitTestRunner/Builds/VisualStudio2022/UnitTestRunner_ConsoleApp.vcxproj index 092d6fcc41..143e6c3d33 100644 --- a/extras/UnitTestRunner/Builds/VisualStudio2022/UnitTestRunner_ConsoleApp.vcxproj +++ b/extras/UnitTestRunner/Builds/VisualStudio2022/UnitTestRunner_ConsoleApp.vcxproj @@ -1973,6 +1973,9 @@ true + + true + true @@ -2168,6 +2171,9 @@ true + + true + true @@ -2213,6 +2219,9 @@ true + + true + true @@ -3338,6 +3347,24 @@ + + + + + + + + + + + + + + + + + + @@ -3413,7 +3440,6 @@ - diff --git a/extras/UnitTestRunner/Builds/VisualStudio2022/UnitTestRunner_ConsoleApp.vcxproj.filters b/extras/UnitTestRunner/Builds/VisualStudio2022/UnitTestRunner_ConsoleApp.vcxproj.filters index 96b6db3302..3a0dc531b3 100644 --- a/extras/UnitTestRunner/Builds/VisualStudio2022/UnitTestRunner_ConsoleApp.vcxproj.filters +++ b/extras/UnitTestRunner/Builds/VisualStudio2022/UnitTestRunner_ConsoleApp.vcxproj.filters @@ -536,6 +536,9 @@ {B331BC33-9770-3DB5-73F2-BC2469ECCF7F} + + {3B09E947-B78C-1758-E072-7FD67F8DCB00} + {46A17AC9-0BFF-B5CE-26D6-B9D1992C88AC} @@ -2563,6 +2566,9 @@ JUCE Modules\juce_gui_basics\desktop + + JUCE Modules\juce_gui_basics\detail + JUCE Modules\juce_gui_basics\drawables @@ -2758,6 +2764,9 @@ JUCE Modules\juce_gui_basics\mouse + + JUCE Modules\juce_gui_basics\native\accessibility + JUCE Modules\juce_gui_basics\native\accessibility @@ -2842,6 +2851,9 @@ JUCE Modules\juce_gui_basics\native + + JUCE Modules\juce_gui_basics\native + JUCE Modules\juce_gui_basics\native @@ -5580,6 +5592,60 @@ JUCE Modules\juce_gui_basics\desktop + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + JUCE Modules\juce_gui_basics\drawables @@ -5805,9 +5871,6 @@ JUCE Modules\juce_gui_basics\mouse - - JUCE Modules\juce_gui_basics\mouse - JUCE Modules\juce_gui_basics\mouse diff --git a/extras/WindowsDLL/Builds/VisualStudio2022/WindowsDLL_StaticLibrary.vcxproj b/extras/WindowsDLL/Builds/VisualStudio2022/WindowsDLL_StaticLibrary.vcxproj index fa596c7548..d0029cd575 100644 --- a/extras/WindowsDLL/Builds/VisualStudio2022/WindowsDLL_StaticLibrary.vcxproj +++ b/extras/WindowsDLL/Builds/VisualStudio2022/WindowsDLL_StaticLibrary.vcxproj @@ -1848,6 +1848,9 @@ true + + true + true @@ -2043,6 +2046,9 @@ true + + true + true @@ -2088,6 +2094,9 @@ true + + true + true @@ -3109,6 +3118,24 @@ + + + + + + + + + + + + + + + + + + @@ -3184,7 +3211,6 @@ - diff --git a/extras/WindowsDLL/Builds/VisualStudio2022/WindowsDLL_StaticLibrary.vcxproj.filters b/extras/WindowsDLL/Builds/VisualStudio2022/WindowsDLL_StaticLibrary.vcxproj.filters index 916710fb1b..39eb32ba1a 100644 --- a/extras/WindowsDLL/Builds/VisualStudio2022/WindowsDLL_StaticLibrary.vcxproj.filters +++ b/extras/WindowsDLL/Builds/VisualStudio2022/WindowsDLL_StaticLibrary.vcxproj.filters @@ -497,6 +497,9 @@ {B331BC33-9770-3DB5-73F2-BC2469ECCF7F} + + {3B09E947-B78C-1758-E072-7FD67F8DCB00} + {46A17AC9-0BFF-B5CE-26D6-B9D1992C88AC} @@ -2380,6 +2383,9 @@ JUCE Modules\juce_gui_basics\desktop + + JUCE Modules\juce_gui_basics\detail + JUCE Modules\juce_gui_basics\drawables @@ -2575,6 +2581,9 @@ JUCE Modules\juce_gui_basics\mouse + + JUCE Modules\juce_gui_basics\native\accessibility + JUCE Modules\juce_gui_basics\native\accessibility @@ -2659,6 +2668,9 @@ JUCE Modules\juce_gui_basics\native + + JUCE Modules\juce_gui_basics\native + JUCE Modules\juce_gui_basics\native @@ -5178,6 +5190,60 @@ JUCE Modules\juce_gui_basics\desktop + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + + + JUCE Modules\juce_gui_basics\detail + JUCE Modules\juce_gui_basics\drawables @@ -5403,9 +5469,6 @@ JUCE Modules\juce_gui_basics\mouse - - JUCE Modules\juce_gui_basics\mouse - JUCE Modules\juce_gui_basics\mouse diff --git a/modules/juce_gui_basics/accessibility/enums/juce_AccessibilityEvent.h b/modules/juce_gui_basics/accessibility/enums/juce_AccessibilityEvent.h index 159f11e0b4..5da54b64ed 100644 --- a/modules/juce_gui_basics/accessibility/enums/juce_AccessibilityEvent.h +++ b/modules/juce_gui_basics/accessibility/enums/juce_AccessibilityEvent.h @@ -78,4 +78,4 @@ enum class AccessibilityEvent rowSelectionChanged }; -} +} // namespace juce diff --git a/modules/juce_gui_basics/accessibility/enums/juce_AccessibilityRole.h b/modules/juce_gui_basics/accessibility/enums/juce_AccessibilityRole.h index d80c5a1e91..76a068ad49 100644 --- a/modules/juce_gui_basics/accessibility/enums/juce_AccessibilityRole.h +++ b/modules/juce_gui_basics/accessibility/enums/juce_AccessibilityRole.h @@ -68,4 +68,4 @@ enum class AccessibilityRole unspecified }; -} +} // namespace juce diff --git a/modules/juce_gui_basics/accessibility/juce_AccessibilityHandler.cpp b/modules/juce_gui_basics/accessibility/juce_AccessibilityHandler.cpp index 2ec625207e..a0c5abb9b6 100644 --- a/modules/juce_gui_basics/accessibility/juce_AccessibilityHandler.cpp +++ b/modules/juce_gui_basics/accessibility/juce_AccessibilityHandler.cpp @@ -28,30 +28,6 @@ namespace juce AccessibilityHandler* AccessibilityHandler::currentlyFocusedHandler = nullptr; -enum class InternalAccessibilityEvent -{ - elementCreated, - elementDestroyed, - elementMovedOrResized, - focusChanged, - windowOpened, - windowClosed -}; - -void notifyAccessibilityEventInternal (const AccessibilityHandler&, InternalAccessibilityEvent); - -inline String getAccessibleApplicationOrPluginName() -{ - #if defined (JucePlugin_Name) - return JucePlugin_Name; - #else - if (auto* app = JUCEApplicationBase::getInstance()) - return app->getApplicationName(); - - return "JUCE Application"; - #endif -} - AccessibilityHandler::AccessibilityHandler (Component& comp, AccessibilityRole accessibilityRole, AccessibilityActions accessibilityActions, @@ -68,7 +44,7 @@ AccessibilityHandler::AccessibilityHandler (Component& comp, AccessibilityHandler::~AccessibilityHandler() { giveAwayFocus(); - notifyAccessibilityEventInternal (*this, InternalAccessibilityEvent::elementDestroyed); + detail::AccessibilityHelpers::notifyAccessibilityEvent (*this, detail::AccessibilityHelpers::Event::elementDestroyed); } //============================================================================== @@ -320,13 +296,13 @@ void AccessibilityHandler::grabFocusInternal (bool canTryParent) void AccessibilityHandler::giveAwayFocusInternal() const { currentlyFocusedHandler = nullptr; - notifyAccessibilityEventInternal (*this, InternalAccessibilityEvent::focusChanged); + detail::AccessibilityHelpers::notifyAccessibilityEvent (*this, detail::AccessibilityHelpers::Event::focusChanged); } void AccessibilityHandler::takeFocus() { currentlyFocusedHandler = this; - notifyAccessibilityEventInternal (*this, InternalAccessibilityEvent::focusChanged); + detail::AccessibilityHelpers::notifyAccessibilityEvent (*this, detail::AccessibilityHelpers::Event::focusChanged); if ((component.isShowing() || component.isOnDesktop()) && component.getWantsKeyboardFocus() @@ -336,4 +312,20 @@ void AccessibilityHandler::takeFocus() } } +std::unique_ptr AccessibilityHandler::createNativeImpl (AccessibilityHandler& handler) +{ + #if JUCE_NATIVE_ACCESSIBILITY_INCLUDED + return std::make_unique (handler); + #else + ignoreUnused (handler); + return nullptr; + #endif +} + +#if ! JUCE_NATIVE_ACCESSIBILITY_INCLUDED + void AccessibilityHandler::notifyAccessibilityEvent (AccessibilityEvent) const {} + void AccessibilityHandler::postAnnouncement (const String&, AnnouncementPriority) {} + AccessibilityNativeHandle* AccessibilityHandler::getNativeImplementation() const { return nullptr; } +#endif + } // namespace juce diff --git a/modules/juce_gui_basics/application/juce_Application.cpp b/modules/juce_gui_basics/application/juce_Application.cpp index 5e0844ba5c..bd342bdf85 100644 --- a/modules/juce_gui_basics/application/juce_Application.cpp +++ b/modules/juce_gui_basics/application/juce_Application.cpp @@ -83,16 +83,12 @@ bool JUCEApplication::perform (const InvocationInfo& info) } //============================================================================== -#if JUCE_MAC - extern void juce_initialiseMacMainMenu(); -#endif - bool JUCEApplication::initialiseApp() { if (JUCEApplicationBase::initialiseApp()) { #if JUCE_MAC - juce_initialiseMacMainMenu(); // (needs to get the app's name) + initialiseMacMainMenu(); // (needs to get the app's name) #endif return true; diff --git a/modules/juce_gui_basics/buttons/juce_Button.cpp b/modules/juce_gui_basics/buttons/juce_Button.cpp index b66b88c2a2..0dd5ce9f80 100644 --- a/modules/juce_gui_basics/buttons/juce_Button.cpp +++ b/modules/juce_gui_basics/buttons/juce_Button.cpp @@ -715,100 +715,9 @@ void Button::repeatTimerCallback() } } -//============================================================================== -class ButtonAccessibilityHandler : public AccessibilityHandler -{ -public: - explicit ButtonAccessibilityHandler (Button& buttonToWrap, AccessibilityRole roleIn) - : AccessibilityHandler (buttonToWrap, - isRadioButton (buttonToWrap) ? AccessibilityRole::radioButton : roleIn, - getAccessibilityActions (buttonToWrap), - getAccessibilityInterfaces (buttonToWrap)), - button (buttonToWrap) - { - } - - AccessibleState getCurrentState() const override - { - auto state = AccessibilityHandler::getCurrentState(); - - if (button.isToggleable()) - { - state = state.withCheckable(); - - if (button.getToggleState()) - state = state.withChecked(); - } - - return state; - } - - String getTitle() const override - { - auto title = AccessibilityHandler::getTitle(); - - if (title.isEmpty()) - return button.getButtonText(); - - return title; - } - - String getHelp() const override { return button.getTooltip(); } - -private: - class ButtonValueInterface : public AccessibilityTextValueInterface - { - public: - explicit ButtonValueInterface (Button& buttonToWrap) - : button (buttonToWrap) - { - } - - bool isReadOnly() const override { return true; } - String getCurrentValueAsString() const override { return button.getToggleState() ? "On" : "Off"; } - void setValueAsString (const String&) override {} - - private: - Button& button; - - //============================================================================== - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ButtonValueInterface) - }; - - static bool isRadioButton (const Button& button) noexcept - { - return button.getRadioGroupId() != 0; - } - - static AccessibilityActions getAccessibilityActions (Button& button) - { - auto actions = AccessibilityActions().addAction (AccessibilityActionType::press, - [&button] { button.triggerClick(); }); - - if (button.isToggleable()) - actions = actions.addAction (AccessibilityActionType::toggle, - [&button] { button.setToggleState (! button.getToggleState(), sendNotification); }); - - return actions; - } - - static Interfaces getAccessibilityInterfaces (Button& button) - { - if (button.isToggleable()) - return { std::make_unique (button) }; - - return {}; - } - - Button& button; - - //============================================================================== - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ButtonAccessibilityHandler) -}; - std::unique_ptr Button::createAccessibilityHandler() { - return std::make_unique (*this, AccessibilityRole::button); + return std::make_unique (*this, AccessibilityRole::button); } } // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_HyperlinkButton.cpp b/modules/juce_gui_basics/buttons/juce_HyperlinkButton.cpp index a5f5440f47..962e694979 100644 --- a/modules/juce_gui_basics/buttons/juce_HyperlinkButton.cpp +++ b/modules/juce_gui_basics/buttons/juce_HyperlinkButton.cpp @@ -123,7 +123,7 @@ void HyperlinkButton::paintButton (Graphics& g, std::unique_ptr HyperlinkButton::createAccessibilityHandler() { - return std::make_unique (*this, AccessibilityRole::hyperlink); + return std::make_unique (*this, AccessibilityRole::hyperlink); } } // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_ToggleButton.cpp b/modules/juce_gui_basics/buttons/juce_ToggleButton.cpp index 0461ea12dd..74fe6d34fd 100644 --- a/modules/juce_gui_basics/buttons/juce_ToggleButton.cpp +++ b/modules/juce_gui_basics/buttons/juce_ToggleButton.cpp @@ -59,7 +59,7 @@ void ToggleButton::colourChanged() std::unique_ptr ToggleButton::createAccessibilityHandler() { - return std::make_unique (*this, AccessibilityRole::toggleButton); + return std::make_unique (*this, AccessibilityRole::toggleButton); } } // namespace juce diff --git a/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp b/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp index bfa089b381..db6f1bbbcc 100644 --- a/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp +++ b/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp @@ -270,7 +270,7 @@ ApplicationCommandTarget* ApplicationCommandManager::findDefaultComponentTarget( // getting a bit desperate now: try all desktop comps.. for (int i = desktop.getNumComponents(); --i >= 0;) if (auto* component = desktop.getComponent (i)) - if (isForegroundOrEmbeddedProcess (component)) + if (detail::WindowingHelpers::isForegroundOrEmbeddedProcess (component)) if (auto* peer = component->getPeer()) if (auto* target = findTargetForComponent (peer->getLastFocusedSubcomponent())) return target; diff --git a/modules/juce_gui_basics/components/juce_Component.cpp b/modules/juce_gui_basics/components/juce_Component.cpp index 9f8d9d7426..99ccdfeb52 100644 --- a/modules/juce_gui_basics/components/juce_Component.cpp +++ b/modules/juce_gui_basics/components/juce_Component.cpp @@ -23,6 +23,11 @@ ============================================================================== */ +#define JUCE_ASSERT_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN \ + jassert ((MessageManager::getInstanceWithoutCreating() != nullptr \ + && MessageManager::getInstanceWithoutCreating()->currentThreadHasLockedMessageManager()) \ + || getPeer() == nullptr); + namespace juce { @@ -158,343 +163,6 @@ private: JUCE_DECLARE_NON_COPYABLE (MouseListenerList) }; -//============================================================================== -struct FocusRestorer -{ - FocusRestorer() : lastFocus (Component::getCurrentlyFocusedComponent()) {} - - ~FocusRestorer() - { - if (lastFocus != nullptr - && lastFocus->isShowing() - && ! lastFocus->isCurrentlyBlockedByAnotherModalComponent()) - lastFocus->grabKeyboardFocus(); - } - - WeakReference lastFocus; - - JUCE_DECLARE_NON_COPYABLE (FocusRestorer) -}; - -//============================================================================== -struct ScalingHelpers -{ - template - static PointOrRect unscaledScreenPosToScaled (float scale, PointOrRect pos) noexcept - { - return scale != 1.0f ? pos / scale : pos; - } - - template - static PointOrRect scaledScreenPosToUnscaled (float scale, PointOrRect pos) noexcept - { - return scale != 1.0f ? pos * scale : pos; - } - - // For these, we need to avoid getSmallestIntegerContainer being used, which causes - // judder when moving windows - static Rectangle unscaledScreenPosToScaled (float scale, Rectangle pos) noexcept - { - return scale != 1.0f ? Rectangle (roundToInt ((float) pos.getX() / scale), - roundToInt ((float) pos.getY() / scale), - roundToInt ((float) pos.getWidth() / scale), - roundToInt ((float) pos.getHeight() / scale)) : pos; - } - - static Rectangle scaledScreenPosToUnscaled (float scale, Rectangle pos) noexcept - { - return scale != 1.0f ? Rectangle (roundToInt ((float) pos.getX() * scale), - roundToInt ((float) pos.getY() * scale), - roundToInt ((float) pos.getWidth() * scale), - roundToInt ((float) pos.getHeight() * scale)) : pos; - } - - static Rectangle unscaledScreenPosToScaled (float scale, Rectangle pos) noexcept - { - return scale != 1.0f ? Rectangle (pos.getX() / scale, - pos.getY() / scale, - pos.getWidth() / scale, - pos.getHeight() / scale) : pos; - } - - static Rectangle scaledScreenPosToUnscaled (float scale, Rectangle pos) noexcept - { - return scale != 1.0f ? Rectangle (pos.getX() * scale, - pos.getY() * scale, - pos.getWidth() * scale, - pos.getHeight() * scale) : pos; - } - - template - static PointOrRect unscaledScreenPosToScaled (PointOrRect pos) noexcept - { - return unscaledScreenPosToScaled (Desktop::getInstance().getGlobalScaleFactor(), pos); - } - - template - static PointOrRect scaledScreenPosToUnscaled (PointOrRect pos) noexcept - { - return scaledScreenPosToUnscaled (Desktop::getInstance().getGlobalScaleFactor(), pos); - } - - template - static PointOrRect unscaledScreenPosToScaled (const Component& comp, PointOrRect pos) noexcept - { - return unscaledScreenPosToScaled (comp.getDesktopScaleFactor(), pos); - } - - template - static PointOrRect scaledScreenPosToUnscaled (const Component& comp, PointOrRect pos) noexcept - { - return scaledScreenPosToUnscaled (comp.getDesktopScaleFactor(), pos); - } - - static Point addPosition (Point p, const Component& c) noexcept { return p + c.getPosition(); } - static Rectangle addPosition (Rectangle p, const Component& c) noexcept { return p + c.getPosition(); } - static Point addPosition (Point p, const Component& c) noexcept { return p + c.getPosition().toFloat(); } - static Rectangle addPosition (Rectangle p, const Component& c) noexcept { return p + c.getPosition().toFloat(); } - static Point subtractPosition (Point p, const Component& c) noexcept { return p - c.getPosition(); } - static Rectangle subtractPosition (Rectangle p, const Component& c) noexcept { return p - c.getPosition(); } - static Point subtractPosition (Point p, const Component& c) noexcept { return p - c.getPosition().toFloat(); } - static Rectangle subtractPosition (Rectangle p, const Component& c) noexcept { return p - c.getPosition().toFloat(); } - - static Point screenPosToLocalPos (Component& comp, Point pos) - { - if (auto* peer = comp.getPeer()) - { - pos = peer->globalToLocal (pos); - auto& peerComp = peer->getComponent(); - return comp.getLocalPoint (&peerComp, unscaledScreenPosToScaled (peerComp, pos)); - } - - return comp.getLocalPoint (nullptr, unscaledScreenPosToScaled (comp, pos)); - } -}; - -static const char colourPropertyPrefix[] = "jcclr_"; - -//============================================================================== -struct Component::ComponentHelpers -{ - #if JUCE_MODAL_LOOPS_PERMITTED - static void* runModalLoopCallback (void* userData) - { - return (void*) (pointer_sized_int) static_cast (userData)->runModalLoop(); - } - #endif - - static Identifier getColourPropertyID (int colourID) - { - char buffer[32]; - auto* end = buffer + numElementsInArray (buffer) - 1; - auto* t = end; - *t = 0; - - for (auto v = (uint32) colourID;;) - { - *--t = "0123456789abcdef" [v & 15]; - v >>= 4; - - if (v == 0) - break; - } - - for (int i = (int) sizeof (colourPropertyPrefix) - 1; --i >= 0;) - *--t = colourPropertyPrefix[i]; - - return t; - } - - //============================================================================== - static bool hitTest (Component& comp, Point localPoint) - { - const auto intPoint = localPoint.roundToInt(); - return Rectangle { comp.getWidth(), comp.getHeight() }.contains (intPoint) - && comp.hitTest (intPoint.x, intPoint.y); - } - - // converts an unscaled position within a peer to the local position within that peer's component - template - static PointOrRect rawPeerPositionToLocal (const Component& comp, PointOrRect pos) noexcept - { - if (comp.isTransformed()) - pos = pos.transformedBy (comp.getTransform().inverted()); - - return ScalingHelpers::unscaledScreenPosToScaled (comp, pos); - } - - // converts a position within a peer's component to the unscaled position within the peer - template - static PointOrRect localPositionToRawPeerPos (const Component& comp, PointOrRect pos) noexcept - { - if (comp.isTransformed()) - pos = pos.transformedBy (comp.getTransform()); - - return ScalingHelpers::scaledScreenPosToUnscaled (comp, pos); - } - - template - static PointOrRect convertFromParentSpace (const Component& comp, const PointOrRect pointInParentSpace) - { - const auto transformed = comp.affineTransform != nullptr ? pointInParentSpace.transformedBy (comp.affineTransform->inverted()) - : pointInParentSpace; - - if (comp.isOnDesktop()) - { - if (auto* peer = comp.getPeer()) - return ScalingHelpers::unscaledScreenPosToScaled (comp, peer->globalToLocal (ScalingHelpers::scaledScreenPosToUnscaled (transformed))); - - jassertfalse; - return transformed; - } - - if (comp.getParentComponent() == nullptr) - return ScalingHelpers::subtractPosition (ScalingHelpers::unscaledScreenPosToScaled (comp, ScalingHelpers::scaledScreenPosToUnscaled (transformed)), comp); - - return ScalingHelpers::subtractPosition (transformed, comp); - } - - template - static PointOrRect convertToParentSpace (const Component& comp, const PointOrRect pointInLocalSpace) - { - const auto preTransform = [&] - { - if (comp.isOnDesktop()) - { - if (auto* peer = comp.getPeer()) - return ScalingHelpers::unscaledScreenPosToScaled (peer->localToGlobal (ScalingHelpers::scaledScreenPosToUnscaled (comp, pointInLocalSpace))); - - jassertfalse; - return pointInLocalSpace; - } - - if (comp.getParentComponent() == nullptr) - return ScalingHelpers::unscaledScreenPosToScaled (ScalingHelpers::scaledScreenPosToUnscaled (comp, ScalingHelpers::addPosition (pointInLocalSpace, comp))); - - return ScalingHelpers::addPosition (pointInLocalSpace, comp); - }(); - - return comp.affineTransform != nullptr ? preTransform.transformedBy (*comp.affineTransform) - : preTransform; - } - - template - static PointOrRect convertFromDistantParentSpace (const Component* parent, const Component& target, PointOrRect coordInParent) - { - auto* directParent = target.getParentComponent(); - jassert (directParent != nullptr); - - if (directParent == parent) - return convertFromParentSpace (target, coordInParent); - - JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6011) - return convertFromParentSpace (target, convertFromDistantParentSpace (parent, *directParent, coordInParent)); - JUCE_END_IGNORE_WARNINGS_MSVC - } - - template - static PointOrRect convertCoordinate (const Component* target, const Component* source, PointOrRect p) - { - while (source != nullptr) - { - if (source == target) - return p; - - JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6011) - - if (source->isParentOf (target)) - return convertFromDistantParentSpace (source, *target, p); - - JUCE_END_IGNORE_WARNINGS_MSVC - - p = convertToParentSpace (*source, p); - source = source->getParentComponent(); - } - - jassert (source == nullptr); - if (target == nullptr) - return p; - - auto* topLevelComp = target->getTopLevelComponent(); - - p = convertFromParentSpace (*topLevelComp, p); - - if (topLevelComp == target) - return p; - - return convertFromDistantParentSpace (topLevelComp, *target, p); - } - - static bool clipObscuredRegions (const Component& comp, Graphics& g, - const Rectangle clipRect, Point delta) - { - bool wasClipped = false; - - for (int i = comp.childComponentList.size(); --i >= 0;) - { - auto& child = *comp.childComponentList.getUnchecked(i); - - if (child.isVisible() && ! child.isTransformed()) - { - auto newClip = clipRect.getIntersection (child.boundsRelativeToParent); - - if (! newClip.isEmpty()) - { - if (child.isOpaque() && child.componentTransparency == 0) - { - g.excludeClipRegion (newClip + delta); - wasClipped = true; - } - else - { - auto childPos = child.getPosition(); - - if (clipObscuredRegions (child, g, newClip - childPos, childPos + delta)) - wasClipped = true; - } - } - } - } - - return wasClipped; - } - - static Rectangle getParentOrMainMonitorBounds (const Component& comp) - { - if (auto* p = comp.getParentComponent()) - return p->getLocalBounds(); - - return Desktop::getInstance().getDisplays().getPrimaryDisplay()->userArea; - } - - static void releaseAllCachedImageResources (Component& c) - { - if (auto* cached = c.getCachedComponentImage()) - cached->releaseResources(); - - for (auto* child : c.childComponentList) - releaseAllCachedImageResources (*child); - } - - //============================================================================== - static bool modalWouldBlockComponent (const Component& maybeBlocked, Component* modal) - { - return modal != nullptr - && modal != &maybeBlocked - && ! modal->isParentOf (&maybeBlocked) - && ! modal->canModalEventBeSentToComponent (&maybeBlocked); - } - - template - static void sendMouseEventToComponentsThatAreBlockedByModal (Component& modal, Function&& function) - { - for (auto& ms : Desktop::getInstance().getMouseSources()) - if (auto* c = ms.getComponentUnderMouse()) - if (modalWouldBlockComponent (*c, &modal)) - (c->*function) (ms, ScalingHelpers::screenPosToLocalPos (*c, ms.getScreenPosition()), Time::getCurrentTime()); - } -}; - //============================================================================== Component::Component() noexcept : componentFlags (0) @@ -574,7 +242,7 @@ void Component::setVisible (bool shouldBeVisible) if (! shouldBeVisible) { - ComponentHelpers::releaseAllCachedImageResources (*this); + detail::ComponentHelpers::releaseAllCachedImageResources (*this); if (hasKeyboardFocus (true)) { @@ -664,8 +332,8 @@ void Component::addToDesktop (int styleWanted, void* nativeWindowToAttachTo) jmax (1, getHeight())); #endif - const auto unscaledPosition = ScalingHelpers::scaledScreenPosToUnscaled (getScreenPosition()); - const auto topLeft = ScalingHelpers::unscaledScreenPosToScaled (*this, unscaledPosition); + const auto unscaledPosition = detail::ScalingHelpers::scaledScreenPosToUnscaled (getScreenPosition()); + const auto topLeft = detail::ScalingHelpers::unscaledScreenPosToScaled (*this, unscaledPosition); bool wasFullscreen = false; bool wasMinimised = false; @@ -747,7 +415,7 @@ void Component::addToDesktop (int styleWanted, void* nativeWindowToAttachTo) internalHierarchyChanged(); if (auto* handler = getAccessibilityHandler()) - notifyAccessibilityEventInternal (*handler, InternalAccessibilityEvent::windowOpened); + detail::AccessibilityHelpers::notifyAccessibilityEvent (*handler, detail::AccessibilityHelpers::Event::windowOpened); } } } @@ -761,9 +429,9 @@ void Component::removeFromDesktop() if (flags.hasHeavyweightPeerFlag) { if (auto* handler = getAccessibilityHandler()) - notifyAccessibilityEventInternal (*handler, InternalAccessibilityEvent::windowClosed); + detail::AccessibilityHelpers::notifyAccessibilityEvent (*handler, detail::AccessibilityHelpers::Event::windowClosed); - ComponentHelpers::releaseAllCachedImageResources (*this); + detail::ComponentHelpers::releaseAllCachedImageResources (*this); auto* peer = ComponentPeer::getPeerFor (this); jassert (peer != nullptr); @@ -1115,15 +783,15 @@ int Component::getScreenY() const { return getScreenPositi Point Component::getScreenPosition() const { return localPointToGlobal (Point()); } Rectangle Component::getScreenBounds() const { return localAreaToGlobal (getLocalBounds()); } -Point Component::getLocalPoint (const Component* source, Point point) const { return ComponentHelpers::convertCoordinate (this, source, point); } -Point Component::getLocalPoint (const Component* source, Point point) const { return ComponentHelpers::convertCoordinate (this, source, point); } -Rectangle Component::getLocalArea (const Component* source, Rectangle area) const { return ComponentHelpers::convertCoordinate (this, source, area); } -Rectangle Component::getLocalArea (const Component* source, Rectangle area) const { return ComponentHelpers::convertCoordinate (this, source, area); } +Point Component::getLocalPoint (const Component* source, Point point) const { return detail::ComponentHelpers::convertCoordinate (this, source, point); } +Point Component::getLocalPoint (const Component* source, Point point) const { return detail::ComponentHelpers::convertCoordinate (this, source, point); } +Rectangle Component::getLocalArea (const Component* source, Rectangle area) const { return detail::ComponentHelpers::convertCoordinate (this, source, area); } +Rectangle Component::getLocalArea (const Component* source, Rectangle area) const { return detail::ComponentHelpers::convertCoordinate (this, source, area); } -Point Component::localPointToGlobal (Point point) const { return ComponentHelpers::convertCoordinate (nullptr, this, point); } -Point Component::localPointToGlobal (Point point) const { return ComponentHelpers::convertCoordinate (nullptr, this, point); } -Rectangle Component::localAreaToGlobal (Rectangle area) const { return ComponentHelpers::convertCoordinate (nullptr, this, area); } -Rectangle Component::localAreaToGlobal (Rectangle area) const { return ComponentHelpers::convertCoordinate (nullptr, this, area); } +Point Component::localPointToGlobal (Point point) const { return detail::ComponentHelpers::convertCoordinate (nullptr, this, point); } +Point Component::localPointToGlobal (Point point) const { return detail::ComponentHelpers::convertCoordinate (nullptr, this, point); } +Rectangle Component::localAreaToGlobal (Rectangle area) const { return detail::ComponentHelpers::convertCoordinate (nullptr, this, area); } +Rectangle Component::localAreaToGlobal (Rectangle area) const { return detail::ComponentHelpers::convertCoordinate (nullptr, this, area); } //============================================================================== void Component::setBounds (int x, int y, int w, int h) @@ -1238,7 +906,7 @@ void Component::sendMovedResizedMessages (bool wasMoved, bool wasResized) if ((wasMoved || wasResized) && ! checker.shouldBailOut()) if (auto* handler = getAccessibilityHandler()) - notifyAccessibilityEventInternal (*handler, InternalAccessibilityEvent::elementMovedOrResized); + detail::AccessibilityHelpers::notifyAccessibilityEvent (*handler, detail::AccessibilityHelpers::Event::elementMovedOrResized); } void Component::setSize (int w, int h) { setBounds (getX(), getY(), w, h); } @@ -1271,7 +939,7 @@ void Component::setBoundsRelative (float x, float y, float w, float h) void Component::centreWithSize (int width, int height) { - auto parentArea = ComponentHelpers::getParentOrMainMonitorBounds (*this) + auto parentArea = detail::ComponentHelpers::getParentOrMainMonitorBounds (*this) .transformedBy (getTransform().inverted()); setBounds (parentArea.getCentreX() - width / 2, @@ -1281,7 +949,7 @@ void Component::centreWithSize (int width, int height) void Component::setBoundsInset (BorderSize borders) { - setBounds (borders.subtractedFrom (ComponentHelpers::getParentOrMainMonitorBounds (*this))); + setBounds (borders.subtractedFrom (detail::ComponentHelpers::getParentOrMainMonitorBounds (*this))); } void Component::setBoundsToFit (Rectangle targetArea, Justification justification, bool onlyReduceInSize) @@ -1391,7 +1059,7 @@ bool Component::hitTest (int x, int y) auto& child = *childComponentList.getUnchecked (i); if (child.isVisible() - && ComponentHelpers::hitTest (child, ComponentHelpers::convertFromParentSpace (child, Point (x, y).toFloat()))) + && detail::ComponentHelpers::hitTest (child, detail::ComponentHelpers::convertFromParentSpace (child, Point (x, y).toFloat()))) return true; } } @@ -1420,14 +1088,14 @@ bool Component::contains (Point point) bool Component::contains (Point point) { - if (ComponentHelpers::hitTest (*this, point)) + if (detail::ComponentHelpers::hitTest (*this, point)) { if (parentComponent != nullptr) - return parentComponent->contains (ComponentHelpers::convertToParentSpace (*this, point)); + return parentComponent->contains (detail::ComponentHelpers::convertToParentSpace (*this, point)); if (flags.hasHeavyweightPeerFlag) if (auto* peer = getPeer()) - return peer->contains (ComponentHelpers::localPositionToRawPeerPos (*this, point).roundToInt(), true); + return peer->contains (detail::ComponentHelpers::localPositionToRawPeerPos (*this, point).roundToInt(), true); } return false; @@ -1456,13 +1124,13 @@ Component* Component::getComponentAt (Point position) Component* Component::getComponentAt (Point position) { - if (flags.visibleFlag && ComponentHelpers::hitTest (*this, position)) + if (flags.visibleFlag && detail::ComponentHelpers::hitTest (*this, position)) { for (int i = childComponentList.size(); --i >= 0;) { auto* child = childComponentList.getUnchecked (i); - child = child->getComponentAt (ComponentHelpers::convertFromParentSpace (*child, position)); + child = child->getComponentAt (detail::ComponentHelpers::convertFromParentSpace (*child, position)); if (child != nullptr) return child; @@ -1579,7 +1247,7 @@ Component* Component::removeChildComponent (int index, bool sendParentEvents, bo childComponentList.remove (index); child->parentComponent = nullptr; - ComponentHelpers::releaseAllCachedImageResources (*child); + detail::ComponentHelpers::releaseAllCachedImageResources (*child); // (NB: there are obscure situations where child->isShowing() = false, but it still has the focus) if (child->hasKeyboardFocus (true)) @@ -1732,7 +1400,7 @@ int Component::runModalLoop() { // use a callback so this can be called from non-gui threads return (int) (pointer_sized_int) MessageManager::getInstance() - ->callFunctionOnMessageThread (&ComponentHelpers::runModalLoopCallback, this); + ->callFunctionOnMessageThread (&detail::ComponentHelpers::runModalLoopCallback, this); } if (! isCurrentlyModal (false)) @@ -1758,7 +1426,7 @@ void Component::enterModalState (bool shouldTakeKeyboardFocus, // While this component is in modal state it may block other components from receiving // mouseExit events. To keep mouseEnter and mouseExit calls balanced on these components, // we must manually force the mouse to "leave" blocked components. - ComponentHelpers::sendMouseEventToComponentsThatAreBlockedByModal (*this, &Component::internalMouseExit); + detail::ComponentHelpers::sendMouseEventToComponentsThatAreBlockedByModal (*this, &Component::internalMouseExit); if (safeReference == nullptr) { @@ -1799,7 +1467,7 @@ void Component::exitModalState (int returnValue) // mouseEnter events. To keep mouseEnter and mouseExit calls balanced on these components, // we must manually force the mouse to "enter" blocked components. if (deletionChecker != nullptr) - ComponentHelpers::sendMouseEventToComponentsThatAreBlockedByModal (*deletionChecker, &Component::internalMouseEnter); + detail::ComponentHelpers::sendMouseEventToComponentsThatAreBlockedByModal (*deletionChecker, &Component::internalMouseEnter); } else { @@ -1822,7 +1490,7 @@ bool Component::isCurrentlyModal (bool onlyConsiderForemostModalComponent) const bool Component::isCurrentlyBlockedByAnotherModalComponent() const { - return ComponentHelpers::modalWouldBlockComponent (*this, getCurrentlyModalComponent()); + return detail::ComponentHelpers::modalWouldBlockComponent (*this, getCurrentlyModalComponent()); } int JUCE_CALLTYPE Component::getNumCurrentlyModalComponents() noexcept @@ -1923,7 +1591,7 @@ void Component::repaint (Rectangle area) void Component::repaintParent() { if (parentComponent != nullptr) - parentComponent->internalRepaint (ComponentHelpers::convertToParentSpace (*this, getLocalBounds())); + parentComponent->internalRepaint (detail::ComponentHelpers::convertToParentSpace (*this, getLocalBounds())); } void Component::internalRepaint (Rectangle area) @@ -1965,7 +1633,7 @@ void Component::internalRepaintUnchecked (Rectangle area, bool isEntireComp else { if (parentComponent != nullptr) - parentComponent->internalRepaint (ComponentHelpers::convertToParentSpace (*this, area)); + parentComponent->internalRepaint (detail::ComponentHelpers::convertToParentSpace (*this, area)); } } } @@ -2006,7 +1674,7 @@ void Component::paintComponentAndChildren (Graphics& g) { Graphics::ScopedSaveState ss (g); - if (! (ComponentHelpers::clipObscuredRegions (*this, g, clipBounds, {}) && g.isClipEmpty())) + if (! (detail::ComponentHelpers::clipObscuredRegions (*this, g, clipBounds, {}) && g.isClipEmpty())) paint (g); } @@ -2209,7 +1877,7 @@ void Component::sendLookAndFeelChange() Colour Component::findColour (int colourID, bool inheritFromParent) const { - if (auto* v = properties.getVarPointer (ComponentHelpers::getColourPropertyID (colourID))) + if (auto* v = properties.getVarPointer (detail::ComponentHelpers::getColourPropertyID (colourID))) return Colour ((uint32) static_cast (*v)); if (inheritFromParent && parentComponent != nullptr @@ -2221,18 +1889,18 @@ Colour Component::findColour (int colourID, bool inheritFromParent) const bool Component::isColourSpecified (int colourID) const { - return properties.contains (ComponentHelpers::getColourPropertyID (colourID)); + return properties.contains (detail::ComponentHelpers::getColourPropertyID (colourID)); } void Component::removeColour (int colourID) { - if (properties.remove (ComponentHelpers::getColourPropertyID (colourID))) + if (properties.remove (detail::ComponentHelpers::getColourPropertyID (colourID))) colourChanged(); } void Component::setColour (int colourID, Colour colour) { - if (properties.set (ComponentHelpers::getColourPropertyID (colourID), (int) colour.getARGB())) + if (properties.set (detail::ComponentHelpers::getColourPropertyID (colourID), (int) colour.getARGB())) colourChanged(); } @@ -2244,7 +1912,7 @@ void Component::copyAllExplicitColoursTo (Component& target) const { auto name = properties.getName(i); - if (name.toString().startsWith (colourPropertyPrefix)) + if (name.toString().startsWith (detail::colourPropertyPrefix)) if (target.properties.set (name, properties [name])) changed = true; } @@ -2405,7 +2073,7 @@ void Component::internalMouseEnter (MouseInputSource source, Point relati repaint(); const auto me = makeMouseEvent (source, - PointerState().withPosition (relativePos), + detail::PointerState().withPosition (relativePos), source.getCurrentModifiers(), this, this, @@ -2442,7 +2110,7 @@ void Component::internalMouseExit (MouseInputSource source, Point relativ flags.cachedMouseInsideComponent = false; const auto me = makeMouseEvent (source, - PointerState().withPosition (relativePos), + detail::PointerState().withPosition (relativePos), source.getCurrentModifiers(), this, this, @@ -2462,7 +2130,9 @@ void Component::internalMouseExit (MouseInputSource source, Point relativ MouseListenerList::sendMouseEvent (checker, &MouseListener::mouseExit); } -void Component::internalMouseDown (MouseInputSource source, const PointerState& relativePointerState, Time time) +void Component::internalMouseDown (MouseInputSource source, + const detail::PointerState& relativePointerState, + Time time) { auto& desktop = Desktop::getInstance(); @@ -2531,7 +2201,10 @@ void Component::internalMouseDown (MouseInputSource source, const PointerState& MouseListenerList::sendMouseEvent (checker, &MouseListener::mouseDown); } -void Component::internalMouseUp (MouseInputSource source, const PointerState& relativePointerState, Time time, const ModifierKeys oldModifiers) +void Component::internalMouseUp (MouseInputSource source, + const detail::PointerState& relativePointerState, + Time time, + const ModifierKeys oldModifiers) { if (flags.mouseDownWasBlocked && isCurrentlyBlockedByAnotherModalComponent()) return; @@ -2579,7 +2252,7 @@ void Component::internalMouseUp (MouseInputSource source, const PointerState& re } } -void Component::internalMouseDrag (MouseInputSource source, const PointerState& relativePointerState, Time time) +void Component::internalMouseDrag (MouseInputSource source, const detail::PointerState& relativePointerState, Time time) { if (! isCurrentlyBlockedByAnotherModalComponent()) { @@ -2618,7 +2291,7 @@ void Component::internalMouseMove (MouseInputSource source, Point relativ else { const auto me = makeMouseEvent (source, - PointerState().withPosition (relativePos), + detail::PointerState().withPosition (relativePos), source.getCurrentModifiers(), this, this, @@ -2646,7 +2319,7 @@ void Component::internalMouseWheel (MouseInputSource source, Point relati auto& desktop = Desktop::getInstance(); const auto me = makeMouseEvent (source, - PointerState().withPosition (relativePos), + detail::PointerState().withPosition (relativePos), source.getCurrentModifiers(), this, this, @@ -2683,7 +2356,7 @@ void Component::internalMagnifyGesture (MouseInputSource source, Point re auto& desktop = Desktop::getInstance(); const auto me = makeMouseEvent (source, - PointerState().withPosition (relativePos), + detail::PointerState().withPosition (relativePos), source.getCurrentModifiers(), this, this, @@ -2884,16 +2557,16 @@ Component* Component::findKeyboardFocusContainer() const return findContainer (this, &Component::isKeyboardFocusContainer); } -static const Identifier juce_explicitFocusOrderId ("_jexfo"); +static const Identifier explicitFocusOrderId ("_jexfo"); int Component::getExplicitFocusOrder() const { - return properties [juce_explicitFocusOrderId]; + return properties [explicitFocusOrderId]; } void Component::setExplicitFocusOrder (int newFocusOrderIndex) { - properties.set (juce_explicitFocusOrderId, newFocusOrderIndex); + properties.set (explicitFocusOrderId, newFocusOrderIndex); } std::unique_ptr Component::createFocusTraverser() @@ -3300,7 +2973,7 @@ AccessibilityHandler* Component::getAccessibilityHandler() // created, the if() predicate above should evaluate to false on recursive calls, // terminating the recursion. if (accessibilityHandler != nullptr) - notifyAccessibilityEventInternal (*accessibilityHandler, InternalAccessibilityEvent::elementCreated); + detail::AccessibilityHelpers::notifyAccessibilityEvent (*accessibilityHandler, detail::AccessibilityHelpers::Event::elementCreated); else jassertfalse; // createAccessibilityHandler must return non-null } diff --git a/modules/juce_gui_basics/components/juce_Component.h b/modules/juce_gui_basics/components/juce_Component.h index da3a4a1666..32116127e1 100644 --- a/modules/juce_gui_basics/components/juce_Component.h +++ b/modules/juce_gui_basics/components/juce_Component.h @@ -2535,7 +2535,7 @@ private: //============================================================================== friend class ComponentPeer; - friend class MouseInputSourceInternal; + friend class detail::MouseInputSourceImpl; #ifndef DOXYGEN static Component* currentlyFocusedComponent; @@ -2604,9 +2604,9 @@ private: //============================================================================== void internalMouseEnter (MouseInputSource, Point, Time); void internalMouseExit (MouseInputSource, Point, Time); - void internalMouseDown (MouseInputSource, const PointerState&, Time); - void internalMouseUp (MouseInputSource, const PointerState&, Time, const ModifierKeys oldModifiers); - void internalMouseDrag (MouseInputSource, const PointerState&, Time); + void internalMouseDown (MouseInputSource, const detail::PointerState&, Time); + void internalMouseUp (MouseInputSource, const detail::PointerState&, Time, const ModifierKeys oldModifiers); + void internalMouseDrag (MouseInputSource, const detail::PointerState&, Time); void internalMouseMove (MouseInputSource, Point, Time); void internalMouseWheel (MouseInputSource, Point, Time, const MouseWheelDetails&); void internalMagnifyGesture (MouseInputSource, Point, Time, float); @@ -2635,8 +2635,7 @@ private: void sendEnablementChangeMessage(); void sendVisibilityChangeMessage(); - struct ComponentHelpers; - friend struct ComponentHelpers; + friend struct detail::ComponentHelpers; /* Components aren't allowed to have copy constructors, as this would mess up parent hierarchies. You might need to give your subclasses a private dummy constructor to avoid compiler warnings. diff --git a/modules/juce_gui_basics/components/juce_FocusTraverser.cpp b/modules/juce_gui_basics/components/juce_FocusTraverser.cpp index 188c33d6e8..34e5093687 100644 --- a/modules/juce_gui_basics/components/juce_FocusTraverser.cpp +++ b/modules/juce_gui_basics/components/juce_FocusTraverser.cpp @@ -26,111 +26,25 @@ namespace juce { -namespace FocusHelpers -{ - static int getOrder (const Component* c) - { - auto order = c->getExplicitFocusOrder(); - return order > 0 ? order : std::numeric_limits::max(); - } - - template - static void findAllComponents (Component* parent, - std::vector& components, - FocusContainerFn isFocusContainer) - { - if (parent == nullptr || parent->getNumChildComponents() == 0) - return; - - std::vector localComponents; - - for (auto* c : parent->getChildren()) - if (c->isVisible() && c->isEnabled()) - localComponents.push_back (c); - - const auto compareComponents = [&] (const Component* a, const Component* b) - { - const auto getComponentOrderAttributes = [] (const Component* c) - { - return std::make_tuple (getOrder (c), - c->isAlwaysOnTop() ? 0 : 1, - c->getY(), - c->getX()); - }; - - return getComponentOrderAttributes (a) < getComponentOrderAttributes (b); - }; - - // This will sort so that they are ordered in terms of explicit focus, - // always on top, left-to-right, and then top-to-bottom. - std::stable_sort (localComponents.begin(), localComponents.end(), compareComponents); - - for (auto* c : localComponents) - { - components.push_back (c); - - if (! (c->*isFocusContainer)()) - findAllComponents (c, components, isFocusContainer); - } - } - - enum class NavigationDirection { forwards, backwards }; - - template - static Component* navigateFocus (Component* current, - Component* focusContainer, - NavigationDirection direction, - FocusContainerFn isFocusContainer) - { - if (focusContainer != nullptr) - { - std::vector components; - findAllComponents (focusContainer, components, isFocusContainer); - - const auto iter = std::find (components.cbegin(), components.cend(), current); - - if (iter == components.cend()) - return nullptr; - - switch (direction) - { - case NavigationDirection::forwards: - if (iter != std::prev (components.cend())) - return *std::next (iter); - - break; - - case NavigationDirection::backwards: - if (iter != components.cbegin()) - return *std::prev (iter); - - break; - } - } - - return nullptr; - } -} - //============================================================================== Component* FocusTraverser::getNextComponent (Component* current) { jassert (current != nullptr); - return FocusHelpers::navigateFocus (current, - current->findFocusContainer(), - FocusHelpers::NavigationDirection::forwards, - &Component::isFocusContainer); + return detail::FocusHelpers::navigateFocus (current, + current->findFocusContainer(), + detail::FocusHelpers::NavigationDirection::forwards, + &Component::isFocusContainer); } Component* FocusTraverser::getPreviousComponent (Component* current) { jassert (current != nullptr); - return FocusHelpers::navigateFocus (current, - current->findFocusContainer(), - FocusHelpers::NavigationDirection::backwards, - &Component::isFocusContainer); + return detail::FocusHelpers::navigateFocus (current, + current->findFocusContainer(), + detail::FocusHelpers::NavigationDirection::backwards, + &Component::isFocusContainer); } Component* FocusTraverser::getDefaultComponent (Component* parentComponent) @@ -138,9 +52,9 @@ Component* FocusTraverser::getDefaultComponent (Component* parentComponent) if (parentComponent != nullptr) { std::vector components; - FocusHelpers::findAllComponents (parentComponent, - components, - &Component::isFocusContainer); + detail::FocusHelpers::findAllComponents (parentComponent, + components, + &Component::isFocusContainer); if (! components.empty()) return components.front(); @@ -152,9 +66,9 @@ Component* FocusTraverser::getDefaultComponent (Component* parentComponent) std::vector FocusTraverser::getAllComponents (Component* parentComponent) { std::vector components; - FocusHelpers::findAllComponents (parentComponent, - components, - &Component::isFocusContainer); + detail::FocusHelpers::findAllComponents (parentComponent, + components, + &Component::isFocusContainer); return components; } diff --git a/modules/juce_gui_basics/components/juce_ModalComponentManager.cpp b/modules/juce_gui_basics/components/juce_ModalComponentManager.cpp index 5d1287a7c1..c085568600 100644 --- a/modules/juce_gui_basics/components/juce_ModalComponentManager.cpp +++ b/modules/juce_gui_basics/components/juce_ModalComponentManager.cpp @@ -269,7 +269,7 @@ int ModalComponentManager::runEventLoopForCurrentComponent() if (auto* currentlyModal = getModalComponent (0)) { - FocusRestorer focusRestorer; + detail::FocusRestorer focusRestorer; bool finished = false; attachCallback (currentlyModal, ModalCallbackFunction::create ([&] (int r) { returnValue = r; finished = true; })); diff --git a/modules/juce_gui_basics/desktop/juce_Desktop.cpp b/modules/juce_gui_basics/desktop/juce_Desktop.cpp index 6382c52bb7..d1c2212e1b 100644 --- a/modules/juce_gui_basics/desktop/juce_Desktop.cpp +++ b/modules/juce_gui_basics/desktop/juce_Desktop.cpp @@ -27,7 +27,7 @@ namespace juce { Desktop::Desktop() - : mouseSources (new MouseInputSource::SourceList()), + : mouseSources (new detail::MouseInputSourceList()), masterScaleFactor ((float) getDefaultMasterScale()), nativeDarkModeChangeDetectorImpl (createNativeDarkModeChangeDetectorImpl()) { diff --git a/modules/juce_gui_basics/desktop/juce_Desktop.h b/modules/juce_gui_basics/desktop/juce_Desktop.h index 45388b32a3..91df79e992 100644 --- a/modules/juce_gui_basics/desktop/juce_Desktop.h +++ b/modules/juce_gui_basics/desktop/juce_Desktop.h @@ -410,12 +410,12 @@ private: friend class Component; friend class ComponentPeer; - friend class MouseInputSourceInternal; + friend class detail::MouseInputSourceImpl; friend class DeletedAtShutdown; - friend class TopLevelWindowManager; + friend class detail::TopLevelWindowManager; friend class Displays; - std::unique_ptr mouseSources; + std::unique_ptr mouseSources; ListenerList mouseListeners; ListenerList focusListeners; diff --git a/modules/juce_gui_basics/detail/juce_AccessibilityHelpers.cpp b/modules/juce_gui_basics/detail/juce_AccessibilityHelpers.cpp new file mode 100644 index 0000000000..b912bf6b1b --- /dev/null +++ b/modules/juce_gui_basics/detail/juce_AccessibilityHelpers.cpp @@ -0,0 +1,33 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + By using JUCE, you agree to the terms of both the JUCE 7 End-User License + Agreement and JUCE Privacy Policy. + + End User License Agreement: www.juce.com/juce-7-licence + Privacy Policy: www.juce.com/juce-privacy-policy + + Or: You may also use this code under the terms of the GPL v3 (see + www.gnu.org/licenses). + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce::detail +{ + +#if ! JUCE_NATIVE_ACCESSIBILITY_INCLUDED + void AccessibilityHelpers::notifyAccessibilityEvent (const AccessibilityHandler&, Event) {} +#endif + +} // namespace juce::detail diff --git a/modules/juce_gui_basics/detail/juce_AccessibilityHelpers.h b/modules/juce_gui_basics/detail/juce_AccessibilityHelpers.h new file mode 100644 index 0000000000..5cbe1d43cf --- /dev/null +++ b/modules/juce_gui_basics/detail/juce_AccessibilityHelpers.h @@ -0,0 +1,70 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + By using JUCE, you agree to the terms of both the JUCE 7 End-User License + Agreement and JUCE Privacy Policy. + + End User License Agreement: www.juce.com/juce-7-licence + Privacy Policy: www.juce.com/juce-privacy-policy + + Or: You may also use this code under the terms of the GPL v3 (see + www.gnu.org/licenses). + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce::detail +{ + +struct AccessibilityHelpers +{ + AccessibilityHelpers() = delete; + + enum class Event + { + elementCreated, + elementDestroyed, + elementMovedOrResized, + focusChanged, + windowOpened, + windowClosed + }; + + static void notifyAccessibilityEvent (const AccessibilityHandler&, Event); + + static String getApplicationOrPluginName() + { + #if defined (JucePlugin_Name) + return JucePlugin_Name; + #else + if (auto* app = JUCEApplicationBase::getInstance()) + return app->getApplicationName(); + + return "JUCE Application"; + #endif + } + + template + static const AccessibilityHandler* getEnclosingHandlerWithInterface (const AccessibilityHandler* handler, MemberFn fn) + { + if (handler == nullptr) + return nullptr; + + if ((handler->*fn)() != nullptr) + return handler; + + return getEnclosingHandlerWithInterface (handler->getParent(), fn); + } +}; + +} // namespace juce::detail diff --git a/modules/juce_gui_basics/detail/juce_AlertWindowHelpers.h b/modules/juce_gui_basics/detail/juce_AlertWindowHelpers.h new file mode 100644 index 0000000000..c9a4fa4feb --- /dev/null +++ b/modules/juce_gui_basics/detail/juce_AlertWindowHelpers.h @@ -0,0 +1,115 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + By using JUCE, you agree to the terms of both the JUCE 7 End-User License + Agreement and JUCE Privacy Policy. + + End User License Agreement: www.juce.com/juce-7-licence + Privacy Policy: www.juce.com/juce-privacy-policy + + Or: You may also use this code under the terms of the GPL v3 (see + www.gnu.org/licenses). + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce::detail +{ + +struct AlertWindowHelpers +{ + AlertWindowHelpers() = delete; + + static std::unique_ptr create (const MessageBoxOptions& opts) + { + class AlertWindowImpl : public detail::ScopedMessageBoxInterface + { + public: + explicit AlertWindowImpl (const MessageBoxOptions& opts) : options (opts) {} + + void runAsync (std::function recipient) override + { + if (auto* comp = setUpAlert()) + comp->enterModalState (true, ModalCallbackFunction::create (std::move (recipient)), true); + else + NullCheckedInvocation::invoke (recipient, 0); + } + + int runSync() override + { + #if JUCE_MODAL_LOOPS_PERMITTED + if (auto comp = rawToUniquePtr (setUpAlert())) + return comp->runModalLoop(); + #endif + + jassertfalse; + return 0; + } + + void close() override + { + if (alert != nullptr) + if (alert->isCurrentlyModal()) + alert->exitModalState(); + + alert = nullptr; + } + + private: + Component* setUpAlert() + { + auto* component = options.getAssociatedComponent(); + + auto& lf = component != nullptr ? component->getLookAndFeel() + : LookAndFeel::getDefaultLookAndFeel(); + + alert = lf.createAlertWindow (options.getTitle(), + options.getMessage(), + options.getButtonText (0), + options.getButtonText (1), + options.getButtonText (2), + options.getIconType(), + options.getNumButtons(), + component); + + if (alert == nullptr) + { + // You have to return an alert box! + jassertfalse; + return nullptr; + } + + if (auto* parent = options.getParentComponent()) + { + parent->addAndMakeVisible (alert); + + if (options.getAssociatedComponent() == nullptr) + alert->setCentrePosition (parent->getLocalBounds().getCentre()); + } + + alert->setAlwaysOnTop (detail::WindowingHelpers::areThereAnyAlwaysOnTopWindows()); + + return alert; + } + + const MessageBoxOptions options; + Component::SafePointer alert; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AlertWindowImpl) + }; + + return std::make_unique (opts); + } +}; + +} // namespace juce::detail diff --git a/modules/juce_gui_basics/detail/juce_ButtonAccessibilityHandler.h b/modules/juce_gui_basics/detail/juce_ButtonAccessibilityHandler.h new file mode 100644 index 0000000000..82dabc7003 --- /dev/null +++ b/modules/juce_gui_basics/detail/juce_ButtonAccessibilityHandler.h @@ -0,0 +1,125 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + By using JUCE, you agree to the terms of both the JUCE 7 End-User License + Agreement and JUCE Privacy Policy. + + End User License Agreement: www.juce.com/juce-7-licence + Privacy Policy: www.juce.com/juce-privacy-policy + + Or: You may also use this code under the terms of the GPL v3 (see + www.gnu.org/licenses). + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce::detail +{ + +//============================================================================== +class ButtonAccessibilityHandler : public AccessibilityHandler +{ +public: + ButtonAccessibilityHandler (Button& buttonToWrap, AccessibilityRole roleIn) + : AccessibilityHandler (buttonToWrap, + isRadioButton (buttonToWrap) ? AccessibilityRole::radioButton : roleIn, + getAccessibilityActions (buttonToWrap), + getAccessibilityInterfaces (buttonToWrap)), + button (buttonToWrap) + {} + + + AccessibleState getCurrentState() const override + { + auto state = AccessibilityHandler::getCurrentState(); + + if (button.isToggleable()) + { + state = state.withCheckable(); + + if (button.getToggleState()) + state = state.withChecked(); + } + + return state; + } + + + String getTitle() const override + { + auto title = AccessibilityHandler::getTitle(); + + if (title.isEmpty()) + return button.getButtonText(); + + return title; + } + + String getHelp() const override + { + return button.getTooltip(); + } + + +private: + class ButtonValueInterface : public AccessibilityTextValueInterface + { + public: + explicit ButtonValueInterface (Button& buttonToWrap) + : button (buttonToWrap) + { + } + + bool isReadOnly() const override { return true; } + String getCurrentValueAsString() const override { return button.getToggleState() ? "On" : "Off"; } + void setValueAsString (const String&) override {} + + private: + Button& button; + + //============================================================================== + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ButtonValueInterface) + }; + + static bool isRadioButton (const Button& button) noexcept + { + return button.getRadioGroupId() != 0; + } + + static AccessibilityActions getAccessibilityActions (Button& button) + { + auto actions = AccessibilityActions().addAction (AccessibilityActionType::press, + [&button] { button.triggerClick(); }); + + if (button.isToggleable()) + actions = actions.addAction (AccessibilityActionType::toggle, + [&button] { button.setToggleState (! button.getToggleState(), sendNotification); }); + + return actions; + } + + static Interfaces getAccessibilityInterfaces (Button& button) + { + if (button.isToggleable()) + return { std::make_unique (button) }; + + return {}; + } + + Button& button; + + //============================================================================== + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ButtonAccessibilityHandler) +}; + +} // namespace juce::detail diff --git a/modules/juce_gui_basics/detail/juce_ComponentHelpers.h b/modules/juce_gui_basics/detail/juce_ComponentHelpers.h new file mode 100644 index 0000000000..adb50b7455 --- /dev/null +++ b/modules/juce_gui_basics/detail/juce_ComponentHelpers.h @@ -0,0 +1,255 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + By using JUCE, you agree to the terms of both the JUCE 7 End-User License + Agreement and JUCE Privacy Policy. + + End User License Agreement: www.juce.com/juce-7-licence + Privacy Policy: www.juce.com/juce-privacy-policy + + Or: You may also use this code under the terms of the GPL v3 (see + www.gnu.org/licenses). + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce::detail +{ + +constexpr char colourPropertyPrefix[] = "jcclr_"; + +//============================================================================== +struct ComponentHelpers +{ + using SH = ScalingHelpers; + + #if JUCE_MODAL_LOOPS_PERMITTED + static void* runModalLoopCallback (void* userData) + { + return (void*) (pointer_sized_int) static_cast (userData)->runModalLoop(); + } + #endif + + static Identifier getColourPropertyID (int colourID) + { + char buffer[32]; + auto* end = buffer + numElementsInArray (buffer) - 1; + auto* t = end; + *t = 0; + + for (auto v = (uint32) colourID;;) + { + *--t = "0123456789abcdef" [v & 15]; + v >>= 4; + + if (v == 0) + break; + } + + for (int i = (int) sizeof (colourPropertyPrefix) - 1; --i >= 0;) + *--t = colourPropertyPrefix[i]; + + return t; + } + + //============================================================================== + static bool hitTest (Component& comp, Point localPoint) + { + const auto intPoint = localPoint.roundToInt(); + return Rectangle { comp.getWidth(), comp.getHeight() }.contains (intPoint) + && comp.hitTest (intPoint.x, intPoint.y); + } + + // converts an unscaled position within a peer to the local position within that peer's component + template + static PointOrRect rawPeerPositionToLocal (const Component& comp, PointOrRect pos) noexcept + { + if (comp.isTransformed()) + pos = pos.transformedBy (comp.getTransform().inverted()); + + return SH::unscaledScreenPosToScaled (comp, pos); + } + + // converts a position within a peer's component to the unscaled position within the peer + template + static PointOrRect localPositionToRawPeerPos (const Component& comp, PointOrRect pos) noexcept + { + if (comp.isTransformed()) + pos = pos.transformedBy (comp.getTransform()); + + return SH::scaledScreenPosToUnscaled (comp, pos); + } + + template + static PointOrRect convertFromParentSpace (const Component& comp, const PointOrRect pointInParentSpace) + { + const auto transformed = comp.affineTransform != nullptr ? pointInParentSpace.transformedBy (comp.affineTransform->inverted()) + : pointInParentSpace; + + if (comp.isOnDesktop()) + { + if (auto* peer = comp.getPeer()) + return SH::unscaledScreenPosToScaled (comp, peer->globalToLocal (SH::scaledScreenPosToUnscaled (transformed))); + + jassertfalse; + return transformed; + } + + if (comp.getParentComponent() == nullptr) + return SH::subtractPosition (SH::unscaledScreenPosToScaled (comp, SH::scaledScreenPosToUnscaled (transformed)), comp); + + return SH::subtractPosition (transformed, comp); + } + + template + static PointOrRect convertToParentSpace (const Component& comp, const PointOrRect pointInLocalSpace) + { + const auto preTransform = [&] + { + if (comp.isOnDesktop()) + { + if (auto* peer = comp.getPeer()) + return SH::unscaledScreenPosToScaled (peer->localToGlobal (SH::scaledScreenPosToUnscaled (comp, pointInLocalSpace))); + + jassertfalse; + return pointInLocalSpace; + } + + if (comp.getParentComponent() == nullptr) + return SH::unscaledScreenPosToScaled (SH::scaledScreenPosToUnscaled (comp, SH::addPosition (pointInLocalSpace, comp))); + + return SH::addPosition (pointInLocalSpace, comp); + }(); + + return comp.affineTransform != nullptr ? preTransform.transformedBy (*comp.affineTransform) + : preTransform; + } + + template + static PointOrRect convertFromDistantParentSpace (const Component* parent, const Component& target, PointOrRect coordInParent) + { + auto* directParent = target.getParentComponent(); + jassert (directParent != nullptr); + + if (directParent == parent) + return convertFromParentSpace (target, coordInParent); + + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6011) + return convertFromParentSpace (target, convertFromDistantParentSpace (parent, *directParent, coordInParent)); + JUCE_END_IGNORE_WARNINGS_MSVC + } + + template + static PointOrRect convertCoordinate (const Component* target, const Component* source, PointOrRect p) + { + while (source != nullptr) + { + if (source == target) + return p; + + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6011) + + if (source->isParentOf (target)) + return convertFromDistantParentSpace (source, *target, p); + + JUCE_END_IGNORE_WARNINGS_MSVC + + p = convertToParentSpace (*source, p); + source = source->getParentComponent(); + } + + jassert (source == nullptr); + if (target == nullptr) + return p; + + auto* topLevelComp = target->getTopLevelComponent(); + + p = convertFromParentSpace (*topLevelComp, p); + + if (topLevelComp == target) + return p; + + return convertFromDistantParentSpace (topLevelComp, *target, p); + } + + static bool clipObscuredRegions (const Component& comp, Graphics& g, + const Rectangle clipRect, Point delta) + { + bool wasClipped = false; + + for (int i = comp.childComponentList.size(); --i >= 0;) + { + auto& child = *comp.childComponentList.getUnchecked(i); + + if (child.isVisible() && ! child.isTransformed()) + { + auto newClip = clipRect.getIntersection (child.boundsRelativeToParent); + + if (! newClip.isEmpty()) + { + if (child.isOpaque() && child.componentTransparency == 0) + { + g.excludeClipRegion (newClip + delta); + wasClipped = true; + } + else + { + auto childPos = child.getPosition(); + + if (clipObscuredRegions (child, g, newClip - childPos, childPos + delta)) + wasClipped = true; + } + } + } + } + + return wasClipped; + } + + static Rectangle getParentOrMainMonitorBounds (const Component& comp) + { + if (auto* p = comp.getParentComponent()) + return p->getLocalBounds(); + + return Desktop::getInstance().getDisplays().getPrimaryDisplay()->userArea; + } + + static void releaseAllCachedImageResources (Component& c) + { + if (auto* cached = c.getCachedComponentImage()) + cached->releaseResources(); + + for (auto* child : c.childComponentList) + releaseAllCachedImageResources (*child); + } + + //============================================================================== + static bool modalWouldBlockComponent (const Component& maybeBlocked, Component* modal) + { + return modal != nullptr + && modal != &maybeBlocked + && ! modal->isParentOf (&maybeBlocked) + && ! modal->canModalEventBeSentToComponent (&maybeBlocked); + } + + template + static void sendMouseEventToComponentsThatAreBlockedByModal (Component& modal, Function&& function) + { + for (auto& ms : Desktop::getInstance().getMouseSources()) + if (auto* c = ms.getComponentUnderMouse()) + if (modalWouldBlockComponent (*c, &modal)) + (c->*function) (ms, SH::screenPosToLocalPos (*c, ms.getScreenPosition()), Time::getCurrentTime()); + } +}; + +} // namespace juce::detail diff --git a/modules/juce_gui_basics/detail/juce_CustomMouseCursorInfo.h b/modules/juce_gui_basics/detail/juce_CustomMouseCursorInfo.h new file mode 100644 index 0000000000..573307f0e8 --- /dev/null +++ b/modules/juce_gui_basics/detail/juce_CustomMouseCursorInfo.h @@ -0,0 +1,35 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + By using JUCE, you agree to the terms of both the JUCE 7 End-User License + Agreement and JUCE Privacy Policy. + + End User License Agreement: www.juce.com/juce-7-licence + Privacy Policy: www.juce.com/juce-privacy-policy + + Or: You may also use this code under the terms of the GPL v3 (see + www.gnu.org/licenses). + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce::detail +{ + +struct CustomMouseCursorInfo +{ + ScaledImage image; + Point hotspot; +}; + +} // namespace juce::detail diff --git a/modules/juce_gui_basics/detail/juce_FocusHelpers.h b/modules/juce_gui_basics/detail/juce_FocusHelpers.h new file mode 100644 index 0000000000..7b7489630a --- /dev/null +++ b/modules/juce_gui_basics/detail/juce_FocusHelpers.h @@ -0,0 +1,117 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + By using JUCE, you agree to the terms of both the JUCE 7 End-User License + Agreement and JUCE Privacy Policy. + + End User License Agreement: www.juce.com/juce-7-licence + Privacy Policy: www.juce.com/juce-privacy-policy + + Or: You may also use this code under the terms of the GPL v3 (see + www.gnu.org/licenses). + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce::detail +{ + +struct FocusHelpers +{ + FocusHelpers() = delete; + + static int getOrder (const Component* c) + { + auto order = c->getExplicitFocusOrder(); + return order > 0 ? order : std::numeric_limits::max(); + } + + template + static void findAllComponents (Component* parent, + std::vector& components, + FocusContainerFn isFocusContainer) + { + if (parent == nullptr || parent->getNumChildComponents() == 0) + return; + + std::vector localComponents; + + for (auto* c : parent->getChildren()) + if (c->isVisible() && c->isEnabled()) + localComponents.push_back (c); + + const auto compareComponents = [&] (const Component* a, const Component* b) + { + const auto getComponentOrderAttributes = [] (const Component* c) + { + return std::make_tuple (getOrder (c), + c->isAlwaysOnTop() ? 0 : 1, + c->getY(), + c->getX()); + }; + + return getComponentOrderAttributes (a) < getComponentOrderAttributes (b); + }; + + // This will sort so that they are ordered in terms of explicit focus, + // always on top, left-to-right, and then top-to-bottom. + std::stable_sort (localComponents.begin(), localComponents.end(), compareComponents); + + for (auto* c : localComponents) + { + components.push_back (c); + + if (! (c->*isFocusContainer)()) + findAllComponents (c, components, isFocusContainer); + } + } + + enum class NavigationDirection { forwards, backwards }; + + template + static Component* navigateFocus (Component* current, + Component* focusContainer, + NavigationDirection direction, + FocusContainerFn isFocusContainer) + { + if (focusContainer != nullptr) + { + std::vector components; + findAllComponents (focusContainer, components, isFocusContainer); + + const auto iter = std::find (components.cbegin(), components.cend(), current); + + if (iter == components.cend()) + return nullptr; + + switch (direction) + { + case NavigationDirection::forwards: + if (iter != std::prev (components.cend())) + return *std::next (iter); + + break; + + case NavigationDirection::backwards: + if (iter != components.cbegin()) + return *std::prev (iter); + + break; + } + } + + return nullptr; + } +}; + +} // namespace juce::detail diff --git a/modules/juce_gui_basics/detail/juce_FocusRestorer.h b/modules/juce_gui_basics/detail/juce_FocusRestorer.h new file mode 100644 index 0000000000..ff1367714c --- /dev/null +++ b/modules/juce_gui_basics/detail/juce_FocusRestorer.h @@ -0,0 +1,46 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + By using JUCE, you agree to the terms of both the JUCE 7 End-User License + Agreement and JUCE Privacy Policy. + + End User License Agreement: www.juce.com/juce-7-licence + Privacy Policy: www.juce.com/juce-privacy-policy + + Or: You may also use this code under the terms of the GPL v3 (see + www.gnu.org/licenses). + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce::detail +{ + +struct FocusRestorer +{ + FocusRestorer() : lastFocus (Component::getCurrentlyFocusedComponent()) {} + + ~FocusRestorer() + { + if (lastFocus != nullptr + && lastFocus->isShowing() + && ! lastFocus->isCurrentlyBlockedByAnotherModalComponent()) + lastFocus->grabKeyboardFocus(); + } + + WeakReference lastFocus; + + JUCE_DECLARE_NON_COPYABLE (FocusRestorer) +}; + +} // namespace juce::detail diff --git a/modules/juce_gui_basics/detail/juce_LookAndFeelHelpers.h b/modules/juce_gui_basics/detail/juce_LookAndFeelHelpers.h new file mode 100644 index 0000000000..1f90fadd29 --- /dev/null +++ b/modules/juce_gui_basics/detail/juce_LookAndFeelHelpers.h @@ -0,0 +1,62 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + By using JUCE, you agree to the terms of both the JUCE 7 End-User License + Agreement and JUCE Privacy Policy. + + End User License Agreement: www.juce.com/juce-7-licence + Privacy Policy: www.juce.com/juce-privacy-policy + + Or: You may also use this code under the terms of the GPL v3 (see + www.gnu.org/licenses). + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce::detail +{ + +struct LookAndFeelHelpers +{ + LookAndFeelHelpers() = delete; + + static Colour createBaseColour (Colour buttonColour, + bool hasKeyboardFocus, + bool shouldDrawButtonAsHighlighted, + bool shouldDrawButtonAsDown) noexcept + { + const float sat = hasKeyboardFocus ? 1.3f : 0.9f; + const Colour baseColour (buttonColour.withMultipliedSaturation (sat)); + + if (shouldDrawButtonAsDown) return baseColour.contrasting (0.2f); + if (shouldDrawButtonAsHighlighted) return baseColour.contrasting (0.1f); + + return baseColour; + } + + static TextLayout layoutTooltipText (const String& text, Colour colour) noexcept + { + const float tooltipFontSize = 13.0f; + const int maxToolTipWidth = 400; + + AttributedString s; + s.setJustification (Justification::centred); + s.append (text, Font (tooltipFontSize, Font::bold), colour); + + TextLayout tl; + tl.createLayoutWithBalancedLineLengths (s, (float) maxToolTipWidth); + return tl; + } +}; + +} // namespace juce::detail diff --git a/modules/juce_gui_basics/detail/juce_MouseInputSourceImpl.h b/modules/juce_gui_basics/detail/juce_MouseInputSourceImpl.h new file mode 100644 index 0000000000..14b3aec7e0 --- /dev/null +++ b/modules/juce_gui_basics/detail/juce_MouseInputSourceImpl.h @@ -0,0 +1,589 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + By using JUCE, you agree to the terms of both the JUCE 7 End-User License + Agreement and JUCE Privacy Policy. + + End User License Agreement: www.juce.com/juce-7-licence + Privacy Policy: www.juce.com/juce-privacy-policy + + Or: You may also use this code under the terms of the GPL v3 (see + www.gnu.org/licenses). + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce::detail +{ + +class MouseInputSourceImpl : private AsyncUpdater +{ +public: + using SH = ScalingHelpers; + + MouseInputSourceImpl (int i, MouseInputSource::InputSourceType type) + : index (i), + inputType (type) + {} + + //============================================================================== + bool isDragging() const noexcept + { + return buttonState.isAnyMouseButtonDown(); + } + + Component* getComponentUnderMouse() const noexcept + { + return componentUnderMouse.get(); + } + + ModifierKeys getCurrentModifiers() const noexcept + { + return ModifierKeys::currentModifiers + .withoutMouseButtons() + .withFlags (buttonState.getRawFlags()); + } + + ComponentPeer* getPeer() noexcept + { + if (! ComponentPeer::isValidPeer (lastPeer)) + lastPeer = nullptr; + + return lastPeer; + } + + static Component* findComponentAt (Point screenPos, ComponentPeer* peer) + { + if (! ComponentPeer::isValidPeer (peer)) + return nullptr; + + auto relativePos = SH::unscaledScreenPosToScaled (peer->getComponent(), + peer->globalToLocal (screenPos)); + auto& comp = peer->getComponent(); + + // (the contains() call is needed to test for overlapping desktop windows) + if (comp.contains (relativePos)) + return comp.getComponentAt (relativePos); + + return nullptr; + } + + Point getScreenPosition() const noexcept + { + // This needs to return the live position if possible, but it mustn't update the lastScreenPos + // value, because that can cause continuity problems. + return SH::unscaledScreenPosToScaled (getRawScreenPosition()); + } + + Point getRawScreenPosition() const noexcept + { + return unboundedMouseOffset + (inputType != MouseInputSource::InputSourceType::touch ? MouseInputSource::getCurrentRawMousePosition() + : lastPointerState.position); + } + + void setScreenPosition (Point p) + { + MouseInputSource::setRawMousePosition (SH::scaledScreenPosToUnscaled (p)); + } + + //============================================================================== + #if JUCE_DUMP_MOUSE_EVENTS + #define JUCE_MOUSE_EVENT_DBG(desc, screenPos) DBG ("Mouse " << desc << " #" << index \ + << ": " << SH::screenPosToLocalPos (comp, screenPos).toString() \ + << " - Comp: " << String::toHexString ((pointer_sized_int) &comp)); + #else + #define JUCE_MOUSE_EVENT_DBG(desc, screenPos) + #endif + + void sendMouseEnter (Component& comp, const detail::PointerState& pointerState, Time time) + { + JUCE_MOUSE_EVENT_DBG ("enter", pointerState.position) + comp.internalMouseEnter (MouseInputSource (this), + SH::screenPosToLocalPos (comp, pointerState.position), + time); + } + + void sendMouseExit (Component& comp, const detail::PointerState& pointerState, Time time) + { + JUCE_MOUSE_EVENT_DBG ("exit", pointerState.position) + comp.internalMouseExit (MouseInputSource (this), + SH::screenPosToLocalPos (comp, pointerState.position), + time); + } + + void sendMouseMove (Component& comp, const detail::PointerState& pointerState, Time time) + { + JUCE_MOUSE_EVENT_DBG ("move", pointerState.position) + comp.internalMouseMove (MouseInputSource (this), + SH::screenPosToLocalPos (comp, pointerState.position), + time); + } + + void sendMouseDown (Component& comp, const detail::PointerState& pointerState, Time time) + { + JUCE_MOUSE_EVENT_DBG ("down", pointerState.position) + comp.internalMouseDown (MouseInputSource (this), + pointerState.withPosition (SH::screenPosToLocalPos (comp, pointerState.position)), + time); + } + + void sendMouseDrag (Component& comp, const detail::PointerState& pointerState, Time time) + { + JUCE_MOUSE_EVENT_DBG ("drag", pointerState.position) + comp.internalMouseDrag (MouseInputSource (this), + pointerState.withPosition (SH::screenPosToLocalPos (comp, pointerState.position)), + time); + } + + void sendMouseUp (Component& comp, const detail::PointerState& pointerState, Time time, ModifierKeys oldMods) + { + JUCE_MOUSE_EVENT_DBG ("up", pointerState.position) + comp.internalMouseUp (MouseInputSource (this), + pointerState.withPosition (SH::screenPosToLocalPos (comp, pointerState.position)), + time, + oldMods); + } + + void sendMouseWheel (Component& comp, Point screenPos, Time time, const MouseWheelDetails& wheel) + { + JUCE_MOUSE_EVENT_DBG ("wheel", screenPos) + comp.internalMouseWheel (MouseInputSource (this), + SH::screenPosToLocalPos (comp, screenPos), + time, + wheel); + } + + void sendMagnifyGesture (Component& comp, Point screenPos, Time time, float amount) + { + JUCE_MOUSE_EVENT_DBG ("magnify", screenPos) + comp.internalMagnifyGesture (MouseInputSource (this), + SH::screenPosToLocalPos (comp, screenPos), + time, + amount); + } + + #undef JUCE_MOUSE_EVENT_DBG + + //============================================================================== + // (returns true if the button change caused a modal event loop) + bool setButtons (const detail::PointerState& pointerState, Time time, ModifierKeys newButtonState) + { + if (buttonState == newButtonState) + return false; + + // (avoid sending a spurious mouse-drag when we receive a mouse-up) + if (! (isDragging() && ! newButtonState.isAnyMouseButtonDown())) + setPointerState (pointerState, time, false); + + // (ignore secondary clicks when there's already a button down) + if (buttonState.isAnyMouseButtonDown() == newButtonState.isAnyMouseButtonDown()) + { + buttonState = newButtonState; + return false; + } + + auto lastCounter = mouseEventCounter; + + if (buttonState.isAnyMouseButtonDown()) + { + if (auto* current = getComponentUnderMouse()) + { + auto oldMods = getCurrentModifiers(); + buttonState = newButtonState; // must change this before calling sendMouseUp, in case it runs a modal loop + + sendMouseUp (*current, pointerState.withPositionOffset (unboundedMouseOffset), time, oldMods); + + if (lastCounter != mouseEventCounter) + return true; // if a modal loop happened, then newButtonState is no longer valid. + } + + enableUnboundedMouseMovement (false, false); + } + + buttonState = newButtonState; + + if (buttonState.isAnyMouseButtonDown()) + { + Desktop::getInstance().incrementMouseClickCounter(); + + if (auto* current = getComponentUnderMouse()) + { + registerMouseDown (pointerState.position, time, *current, buttonState, + inputType == MouseInputSource::InputSourceType::touch); + sendMouseDown (*current, pointerState, time); + } + } + + return lastCounter != mouseEventCounter; + } + + void setComponentUnderMouse (Component* newComponent, const detail::PointerState& pointerState, Time time) + { + auto* current = getComponentUnderMouse(); + + if (newComponent != current) + { + WeakReference safeNewComp (newComponent); + auto originalButtonState = buttonState; + + if (current != nullptr) + { + WeakReference safeOldComp (current); + setButtons (pointerState, time, ModifierKeys()); + + if (auto oldComp = safeOldComp.get()) + { + componentUnderMouse = safeNewComp; + sendMouseExit (*oldComp, pointerState, time); + } + + buttonState = originalButtonState; + } + + componentUnderMouse = safeNewComp.get(); + current = safeNewComp.get(); + + if (current != nullptr) + sendMouseEnter (*current, pointerState, time); + + revealCursor (false); + setButtons (pointerState, time, originalButtonState); + } + } + + void setPeer (ComponentPeer& newPeer, const detail::PointerState& pointerState, Time time) + { + if (&newPeer != lastPeer && ( findComponentAt (pointerState.position, &newPeer) != nullptr + || findComponentAt (pointerState.position, lastPeer) == nullptr)) + { + setComponentUnderMouse (nullptr, pointerState, time); + lastPeer = &newPeer; + setComponentUnderMouse (findComponentAt (pointerState.position, getPeer()), pointerState, time); + } + } + + void setPointerState (const detail::PointerState& newPointerState, Time time, bool forceUpdate) + { + const auto& newScreenPos = newPointerState.position; + + if (! isDragging()) + setComponentUnderMouse (findComponentAt (newScreenPos, getPeer()), newPointerState, time); + + if ((newPointerState != lastPointerState) || forceUpdate) + { + cancelPendingUpdate(); + + if (newPointerState.position != MouseInputSource::offscreenMousePos) + lastPointerState = newPointerState; + + if (auto* current = getComponentUnderMouse()) + { + if (isDragging()) + { + registerMouseDrag (newScreenPos); + sendMouseDrag (*current, newPointerState.withPositionOffset (unboundedMouseOffset), time); + + if (isUnboundedMouseModeOn) + handleUnboundedDrag (*current); + } + else + { + sendMouseMove (*current, newPointerState, time); + } + } + + revealCursor (false); + } + } + + //============================================================================== + void handleEvent (ComponentPeer& newPeer, Point positionWithinPeer, Time time, + const ModifierKeys newMods, float newPressure, float newOrientation, PenDetails pen) + { + lastTime = time; + ++mouseEventCounter; + const auto pointerState = detail::PointerState().withPosition (newPeer.localToGlobal (positionWithinPeer)) + .withPressure (newPressure) + .withOrientation (newOrientation) + .withRotation (MouseInputSource::defaultRotation) + .withTiltX (pen.tiltX) + .withTiltY (pen.tiltY); + + if (isDragging() && newMods.isAnyMouseButtonDown()) + { + setPointerState (pointerState, time, false); + } + else + { + setPeer (newPeer, pointerState, time); + + if (auto* peer = getPeer()) + { + if (setButtons (pointerState, time, newMods)) + return; // some modal events have been dispatched, so the current event is now out-of-date + + peer = getPeer(); + + if (peer != nullptr) + setPointerState (pointerState, time, false); + } + } + } + + Component* getTargetForGesture (ComponentPeer& peer, Point positionWithinPeer, + Time time, Point& screenPos) + { + lastTime = time; + ++mouseEventCounter; + + screenPos = peer.localToGlobal (positionWithinPeer); + const auto pointerState = lastPointerState.withPosition (screenPos); + setPeer (peer, pointerState, time); + setPointerState (pointerState, time, false); + triggerFakeMove(); + + return getComponentUnderMouse(); + } + + void handleWheel (ComponentPeer& peer, Point positionWithinPeer, + Time time, const MouseWheelDetails& wheel) + { + Desktop::getInstance().incrementMouseWheelCounter(); + Point screenPos; + + // This will make sure that when the wheel spins in its inertial phase, any events + // continue to be sent to the last component that the mouse was over when it was being + // actively controlled by the user. This avoids confusion when scrolling through nested + // scrollable components. + if (lastNonInertialWheelTarget == nullptr || ! wheel.isInertial) + lastNonInertialWheelTarget = getTargetForGesture (peer, positionWithinPeer, time, screenPos); + else + screenPos = peer.localToGlobal (positionWithinPeer); + + if (auto target = lastNonInertialWheelTarget.get()) + sendMouseWheel (*target, screenPos, time, wheel); + } + + void handleMagnifyGesture (ComponentPeer& peer, Point positionWithinPeer, + Time time, const float scaleFactor) + { + Point screenPos; + + if (auto* current = getTargetForGesture (peer, positionWithinPeer, time, screenPos)) + sendMagnifyGesture (*current, screenPos, time, scaleFactor); + } + + //============================================================================== + Time getLastMouseDownTime() const noexcept + { + return mouseDowns[0].time; + } + + Point getLastMouseDownPosition() const noexcept + { + return SH::unscaledScreenPosToScaled (mouseDowns[0].position); + } + + int getNumberOfMultipleClicks() const noexcept + { + int numClicks = 1; + + if (! isLongPressOrDrag()) + { + for (int i = 1; i < numElementsInArray (mouseDowns); ++i) + { + if (mouseDowns[0].canBePartOfMultipleClickWith (mouseDowns[i], MouseEvent::getDoubleClickTimeout() * jmin (i, 2))) + ++numClicks; + else + break; + } + } + + return numClicks; + } + + bool isLongPressOrDrag() const noexcept + { + return movedSignificantly || + lastTime > (mouseDowns[0].time + RelativeTime::milliseconds (300)); + } + + bool hasMovedSignificantlySincePressed() const noexcept + { + return movedSignificantly; + } + + // Deprecated method + bool hasMouseMovedSignificantlySincePressed() const noexcept + { + return isLongPressOrDrag(); + } + + //============================================================================== + void triggerFakeMove() + { + triggerAsyncUpdate(); + } + + void handleAsyncUpdate() override + { + setPointerState (lastPointerState, + jmax (lastTime, Time::getCurrentTime()), true); + } + + //============================================================================== + void enableUnboundedMouseMovement (bool enable, bool keepCursorVisibleUntilOffscreen) + { + enable = enable && isDragging(); + isCursorVisibleUntilOffscreen = keepCursorVisibleUntilOffscreen; + + if (enable != isUnboundedMouseModeOn) + { + if ((! enable) && ((! isCursorVisibleUntilOffscreen) || ! unboundedMouseOffset.isOrigin())) + { + // when released, return the mouse to within the component's bounds + if (auto* current = getComponentUnderMouse()) + setScreenPosition (current->getScreenBounds().toFloat() + .getConstrainedPoint (SH::unscaledScreenPosToScaled (lastPointerState.position))); + } + + isUnboundedMouseModeOn = enable; + unboundedMouseOffset = {}; + + revealCursor (true); + } + } + + void handleUnboundedDrag (Component& current) + { + auto componentScreenBounds = SH::scaledScreenPosToUnscaled (current.getParentMonitorArea() + .reduced (2, 2) + .toFloat()); + + if (! componentScreenBounds.contains (lastPointerState.position)) + { + auto componentCentre = current.getScreenBounds().toFloat().getCentre(); + unboundedMouseOffset += (lastPointerState.position - SH::scaledScreenPosToUnscaled (componentCentre)); + setScreenPosition (componentCentre); + } + else if (isCursorVisibleUntilOffscreen + && (! unboundedMouseOffset.isOrigin()) + && componentScreenBounds.contains (lastPointerState.position + unboundedMouseOffset)) + { + MouseInputSource::setRawMousePosition (lastPointerState.position + unboundedMouseOffset); + unboundedMouseOffset = {}; + } + } + + //============================================================================== + void showMouseCursor (MouseCursor cursor, bool forcedUpdate) + { + if (isUnboundedMouseModeOn && ((! unboundedMouseOffset.isOrigin()) || ! isCursorVisibleUntilOffscreen)) + { + cursor = MouseCursor::NoCursor; + forcedUpdate = true; + } + + if (forcedUpdate || cursor.getHandle() != currentCursorHandle) + { + currentCursorHandle = cursor.getHandle(); + cursor.showInWindow (getPeer()); + } + } + + void hideCursor() + { + showMouseCursor (MouseCursor::NoCursor, true); + } + + void revealCursor (bool forcedUpdate) + { + MouseCursor mc (MouseCursor::NormalCursor); + + if (auto* current = getComponentUnderMouse()) + mc = current->getLookAndFeel().getMouseCursorFor (*current); + + showMouseCursor (mc, forcedUpdate); + } + + //============================================================================== + const int index; + const MouseInputSource::InputSourceType inputType; + Point unboundedMouseOffset; // NB: these are unscaled coords + detail::PointerState lastPointerState; + ModifierKeys buttonState; + + bool isUnboundedMouseModeOn = false, isCursorVisibleUntilOffscreen = false; + +private: + WeakReference componentUnderMouse, lastNonInertialWheelTarget; + ComponentPeer* lastPeer = nullptr; + + void* currentCursorHandle = nullptr; + int mouseEventCounter = 0; + + struct RecentMouseDown + { + RecentMouseDown() = default; + + Point position; + Time time; + ModifierKeys buttons; + uint32 peerID = 0; + bool isTouch = false; + + bool canBePartOfMultipleClickWith (const RecentMouseDown& other, int maxTimeBetweenMs) const noexcept + { + return time - other.time < RelativeTime::milliseconds (maxTimeBetweenMs) + && std::abs (position.x - other.position.x) < (float) getPositionToleranceForInputType() + && std::abs (position.y - other.position.y) < (float) getPositionToleranceForInputType() + && buttons == other.buttons + && peerID == other.peerID; + } + + int getPositionToleranceForInputType() const noexcept { return isTouch ? 25 : 8; } + }; + + RecentMouseDown mouseDowns[4]; + Time lastTime; + bool movedSignificantly = false; + + void registerMouseDown (Point screenPos, Time time, Component& component, + const ModifierKeys modifiers, bool isTouchSource) noexcept + { + for (int i = numElementsInArray (mouseDowns); --i > 0;) + mouseDowns[i] = mouseDowns[i - 1]; + + mouseDowns[0].position = screenPos; + mouseDowns[0].time = time; + mouseDowns[0].buttons = modifiers.withOnlyMouseButtons(); + mouseDowns[0].isTouch = isTouchSource; + + if (auto* peer = component.getPeer()) + mouseDowns[0].peerID = peer->getUniqueID(); + else + mouseDowns[0].peerID = 0; + + movedSignificantly = false; + lastNonInertialWheelTarget = nullptr; + } + + void registerMouseDrag (Point screenPos) noexcept + { + movedSignificantly = movedSignificantly || mouseDowns[0].position.getDistanceFrom (screenPos) >= 4; + } + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MouseInputSourceImpl) +}; + +} // namespace juce::detail diff --git a/modules/juce_gui_basics/detail/juce_MouseInputSourceList.h b/modules/juce_gui_basics/detail/juce_MouseInputSourceList.h new file mode 100644 index 0000000000..f47a7bb95e --- /dev/null +++ b/modules/juce_gui_basics/detail/juce_MouseInputSourceList.h @@ -0,0 +1,154 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + By using JUCE, you agree to the terms of both the JUCE 7 End-User License + Agreement and JUCE Privacy Policy. + + End User License Agreement: www.juce.com/juce-7-licence + Privacy Policy: www.juce.com/juce-privacy-policy + + Or: You may also use this code under the terms of the GPL v3 (see + www.gnu.org/licenses). + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce::detail +{ + +class MouseInputSourceList : public Timer +{ +public: + MouseInputSourceList() + { + #if JUCE_ANDROID || JUCE_IOS + auto mainMouseInputType = MouseInputSource::InputSourceType::touch; + #else + auto mainMouseInputType = MouseInputSource::InputSourceType::mouse; + #endif + + addSource (0, mainMouseInputType); + } + + MouseInputSource* addSource (int index, MouseInputSource::InputSourceType type) + { + auto* s = new MouseInputSourceImpl (index, type); + sources.add (s); + sourceArray.add (MouseInputSource (s)); + + return &sourceArray.getReference (sourceArray.size() - 1); + } + + MouseInputSource* getMouseSource (int index) noexcept + { + return isPositiveAndBelow (index, sourceArray.size()) ? &sourceArray.getReference (index) + : nullptr; + } + + MouseInputSource* getOrCreateMouseInputSource (MouseInputSource::InputSourceType type, int touchIndex = 0) + { + if (type == MouseInputSource::InputSourceType::mouse + || type == MouseInputSource::InputSourceType::pen) + { + for (auto& m : sourceArray) + if (type == m.getType()) + return &m; + + addSource (0, type); + } + else if (type == MouseInputSource::InputSourceType::touch) + { + jassert (0 <= touchIndex && touchIndex < 100); // sanity-check on number of fingers + + for (auto& m : sourceArray) + if (type == m.getType() && touchIndex == m.getIndex()) + return &m; + + if (canUseTouch()) + return addSource (touchIndex, type); + } + + return nullptr; + } + + int getNumDraggingMouseSources() const noexcept + { + int num = 0; + + for (auto* s : sources) + if (s->isDragging()) + ++num; + + return num; + } + + MouseInputSource* getDraggingMouseSource (int index) noexcept + { + int num = 0; + + for (auto& s : sourceArray) + { + if (s.isDragging()) + { + if (index == num) + return &s; + + ++num; + } + } + + return nullptr; + } + + void beginDragAutoRepeat (int interval) + { + if (interval > 0) + { + if (getTimerInterval() != interval) + startTimer (interval); + } + else + { + stopTimer(); + } + } + + void timerCallback() override + { + bool anyDragging = false; + + for (auto* s : sources) + { + // NB: when doing auto-repeat, we need to force an update of the current position and button state, + // because on some OSes the queue can get overloaded with messages so that mouse-events don't get through.. + if (s->isDragging() && ComponentPeer::getCurrentModifiersRealtime().isAnyMouseButtonDown()) + { + s->lastPointerState.position = s->getRawScreenPosition(); + s->triggerFakeMove(); + anyDragging = true; + } + } + + if (! anyDragging) + stopTimer(); + } + + OwnedArray sources; + Array sourceArray; + +private: + bool addSource(); + bool canUseTouch() const; +}; + +} // namespace juce::detail diff --git a/modules/juce_gui_basics/mouse/juce_PointerState.h b/modules/juce_gui_basics/detail/juce_PointerState.h similarity index 96% rename from modules/juce_gui_basics/mouse/juce_PointerState.h rename to modules/juce_gui_basics/detail/juce_PointerState.h index 97fd53bc02..30bce9c0ee 100644 --- a/modules/juce_gui_basics/mouse/juce_PointerState.h +++ b/modules/juce_gui_basics/detail/juce_PointerState.h @@ -23,11 +23,9 @@ ============================================================================== */ -namespace juce +namespace juce::detail { -#ifndef DOXYGEN - class PointerState { auto tie() const noexcept @@ -103,7 +101,4 @@ inline auto makeMouseEvent (MouseInputSource source, mouseWasDragged); } - -#endif - -} // namespace juce +} // namespace juce::detail diff --git a/modules/juce_gui_basics/detail/juce_ScalingHelpers.h b/modules/juce_gui_basics/detail/juce_ScalingHelpers.h new file mode 100644 index 0000000000..528cdaa6e4 --- /dev/null +++ b/modules/juce_gui_basics/detail/juce_ScalingHelpers.h @@ -0,0 +1,123 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + By using JUCE, you agree to the terms of both the JUCE 7 End-User License + Agreement and JUCE Privacy Policy. + + End User License Agreement: www.juce.com/juce-7-licence + Privacy Policy: www.juce.com/juce-privacy-policy + + Or: You may also use this code under the terms of the GPL v3 (see + www.gnu.org/licenses). + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce::detail +{ + +struct ScalingHelpers +{ + template + static PointOrRect unscaledScreenPosToScaled (float scale, PointOrRect pos) noexcept + { + return scale != 1.0f ? pos / scale : pos; + } + + template + static PointOrRect scaledScreenPosToUnscaled (float scale, PointOrRect pos) noexcept + { + return scale != 1.0f ? pos * scale : pos; + } + + // For these, we need to avoid getSmallestIntegerContainer being used, which causes + // judder when moving windows + static Rectangle unscaledScreenPosToScaled (float scale, Rectangle pos) noexcept + { + return scale != 1.0f ? Rectangle (roundToInt ((float) pos.getX() / scale), + roundToInt ((float) pos.getY() / scale), + roundToInt ((float) pos.getWidth() / scale), + roundToInt ((float) pos.getHeight() / scale)) : pos; + } + + static Rectangle scaledScreenPosToUnscaled (float scale, Rectangle pos) noexcept + { + return scale != 1.0f ? Rectangle (roundToInt ((float) pos.getX() * scale), + roundToInt ((float) pos.getY() * scale), + roundToInt ((float) pos.getWidth() * scale), + roundToInt ((float) pos.getHeight() * scale)) : pos; + } + + static Rectangle unscaledScreenPosToScaled (float scale, Rectangle pos) noexcept + { + return scale != 1.0f ? Rectangle (pos.getX() / scale, + pos.getY() / scale, + pos.getWidth() / scale, + pos.getHeight() / scale) : pos; + } + + static Rectangle scaledScreenPosToUnscaled (float scale, Rectangle pos) noexcept + { + return scale != 1.0f ? Rectangle (pos.getX() * scale, + pos.getY() * scale, + pos.getWidth() * scale, + pos.getHeight() * scale) : pos; + } + + template + static PointOrRect unscaledScreenPosToScaled (PointOrRect pos) noexcept + { + return unscaledScreenPosToScaled (Desktop::getInstance().getGlobalScaleFactor(), pos); + } + + template + static PointOrRect scaledScreenPosToUnscaled (PointOrRect pos) noexcept + { + return scaledScreenPosToUnscaled (Desktop::getInstance().getGlobalScaleFactor(), pos); + } + + template + static PointOrRect unscaledScreenPosToScaled (const Component& comp, PointOrRect pos) noexcept + { + return unscaledScreenPosToScaled (comp.getDesktopScaleFactor(), pos); + } + + template + static PointOrRect scaledScreenPosToUnscaled (const Component& comp, PointOrRect pos) noexcept + { + return scaledScreenPosToUnscaled (comp.getDesktopScaleFactor(), pos); + } + + static Point addPosition (Point p, const Component& c) noexcept { return p + c.getPosition(); } + static Rectangle addPosition (Rectangle p, const Component& c) noexcept { return p + c.getPosition(); } + static Point addPosition (Point p, const Component& c) noexcept { return p + c.getPosition().toFloat(); } + static Rectangle addPosition (Rectangle p, const Component& c) noexcept { return p + c.getPosition().toFloat(); } + static Point subtractPosition (Point p, const Component& c) noexcept { return p - c.getPosition(); } + static Rectangle subtractPosition (Rectangle p, const Component& c) noexcept { return p - c.getPosition(); } + static Point subtractPosition (Point p, const Component& c) noexcept { return p - c.getPosition().toFloat(); } + static Rectangle subtractPosition (Rectangle p, const Component& c) noexcept { return p - c.getPosition().toFloat(); } + + static Point screenPosToLocalPos (Component& comp, Point pos) + { + if (auto* peer = comp.getPeer()) + { + pos = peer->globalToLocal (pos); + auto& peerComp = peer->getComponent(); + return comp.getLocalPoint (&peerComp, unscaledScreenPosToScaled (peerComp, pos)); + } + + return comp.getLocalPoint (nullptr, unscaledScreenPosToScaled (comp, pos)); + } +}; + +} // namespace juce::detail diff --git a/modules/juce_gui_basics/detail/juce_ScopedMessageBoxImpl.h b/modules/juce_gui_basics/detail/juce_ScopedMessageBoxImpl.h new file mode 100644 index 0000000000..661e183a1e --- /dev/null +++ b/modules/juce_gui_basics/detail/juce_ScopedMessageBoxImpl.h @@ -0,0 +1,123 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + By using JUCE, you agree to the terms of both the JUCE 7 End-User License + Agreement and JUCE Privacy Policy. + + End User License Agreement: www.juce.com/juce-7-licence + Privacy Policy: www.juce.com/juce-privacy-policy + + Or: You may also use this code under the terms of the GPL v3 (see + www.gnu.org/licenses). + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce::detail +{ + +//============================================================================== +class ScopedMessageBoxImpl : private AsyncUpdater +{ +public: + static ScopedMessageBox show (std::unique_ptr&& native, + std::function callback) + { + return ScopedMessageBox (runAsync (std::move (native), + rawToUniquePtr (ModalCallbackFunction::create (std::move (callback))))); + } + + static int showUnmanaged (std::unique_ptr&& native, + ModalComponentManager::Callback* cb) + { + #if JUCE_MODAL_LOOPS_PERMITTED + if (cb == nullptr) + return runSync (std::move (native)); + #endif + + runAsync (std::move (native), rawToUniquePtr (cb)); + + return 0; + } + + ~ScopedMessageBoxImpl() override + { + cancelPendingUpdate(); + } + + void close() + { + cancelPendingUpdate(); + nativeImplementation->close(); + self.reset(); + } + +private: + static std::shared_ptr runAsync (std::unique_ptr&& p, + std::unique_ptr&& c) + { + std::shared_ptr result (new ScopedMessageBoxImpl (std::move (p), std::move (c))); + result->self = result; + result->triggerAsyncUpdate(); + return result; + } + + static int runSync (std::unique_ptr&& p) + { + auto local = std::move (p); + return local != nullptr ? local->runSync() : 0; + } + + explicit ScopedMessageBoxImpl (std::unique_ptr&& p) + : ScopedMessageBoxImpl (std::move (p), nullptr) {} + + ScopedMessageBoxImpl (std::unique_ptr&& p, + std::unique_ptr&& c) + : callback (std::move (c)), nativeImplementation (std::move (p)) {} + + void handleAsyncUpdate() override + { + nativeImplementation->runAsync ([weakRecipient = std::weak_ptr (self)] (int result) + { + const auto notifyRecipient = [result, weakRecipient] + { + if (const auto locked = weakRecipient.lock()) + { + if (auto* cb = locked->callback.get()) + cb->modalStateFinished (result); + + locked->self.reset(); + } + }; + + if (MessageManager::getInstance()->isThisTheMessageThread()) + notifyRecipient(); + else + MessageManager::callAsync (notifyRecipient); + }); + } + + std::unique_ptr callback; + std::unique_ptr nativeImplementation; + + /* The 'old' native message box API doesn't have a concept of message box owners. + Instead, message boxes have to clean up after themselves, once they're done displaying. + To allow this mode of usage, the implementation keeps an owning reference to itself, + which is cleared once the message box is closed or asked to quit. To display a native + message box without a scoped lifetime, just create a Pimpl instance without using + the ScopedMessageBox wrapper, and the Pimpl will destroy itself after it is dismissed. + */ + std::shared_ptr self; +}; + +} // namespace juce::detail diff --git a/modules/juce_gui_basics/detail/juce_ScopedMessageBoxInterface.h b/modules/juce_gui_basics/detail/juce_ScopedMessageBoxInterface.h new file mode 100644 index 0000000000..c7c1981cba --- /dev/null +++ b/modules/juce_gui_basics/detail/juce_ScopedMessageBoxInterface.h @@ -0,0 +1,60 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + By using JUCE, you agree to the terms of both the JUCE 7 End-User License + Agreement and JUCE Privacy Policy. + + End User License Agreement: www.juce.com/juce-7-licence + Privacy Policy: www.juce.com/juce-privacy-policy + + Or: You may also use this code under the terms of the GPL v3 (see + www.gnu.org/licenses). + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce::detail +{ + +/* + Instances of this type can show and dismiss a message box. + + This is an interface rather than a concrete type so that platforms can pick an implementation at + runtime if necessary. +*/ +struct ScopedMessageBoxInterface +{ + virtual ~ScopedMessageBoxInterface() = default; + + /* Shows the message box. + + When the message box exits normally, it should send the result to the passed-in function. + The passed-in function is safe to call from any thread at any time. + */ + virtual void runAsync (std::function) = 0; + + /* Shows the message box and blocks. */ + virtual int runSync() = 0; + + /* Forcefully closes the message box. + + This will be called when the message box handle has fallen out of scope. + If the message box has already been closed by the user, this shouldn't do anything. + */ + virtual void close() = 0; + + /* Implemented differently for each platform. */ + static std::unique_ptr create (const MessageBoxOptions& options); +}; + +} // namespace juce::detail diff --git a/modules/juce_gui_basics/detail/juce_ToolbarItemDragAndDropOverlayComponent.h b/modules/juce_gui_basics/detail/juce_ToolbarItemDragAndDropOverlayComponent.h new file mode 100644 index 0000000000..cbeb2bd749 --- /dev/null +++ b/modules/juce_gui_basics/detail/juce_ToolbarItemDragAndDropOverlayComponent.h @@ -0,0 +1,118 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + By using JUCE, you agree to the terms of both the JUCE 7 End-User License + Agreement and JUCE Privacy Policy. + + End User License Agreement: www.juce.com/juce-7-licence + Privacy Policy: www.juce.com/juce-privacy-policy + + Or: You may also use this code under the terms of the GPL v3 (see + www.gnu.org/licenses). + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce::detail +{ + +class ToolbarItemDragAndDropOverlayComponent : public Component +{ +public: + ToolbarItemDragAndDropOverlayComponent() + : isDragging (false) + { + setAlwaysOnTop (true); + setRepaintsOnMouseActivity (true); + setMouseCursor (MouseCursor::DraggingHandCursor); + } + + void paint (Graphics& g) override + { + if (ToolbarItemComponent* const tc = getToolbarItemComponent()) + { + if (isMouseOverOrDragging() + && tc->getEditingMode() == ToolbarItemComponent::editableOnToolbar) + { + g.setColour (findColour (Toolbar::editingModeOutlineColourId, true)); + g.drawRect (getLocalBounds(), jmin (2, (getWidth() - 1) / 2, + (getHeight() - 1) / 2)); + } + } + } + + void mouseDown (const MouseEvent& e) override + { + isDragging = false; + + if (ToolbarItemComponent* const tc = getToolbarItemComponent()) + { + tc->dragOffsetX = e.x; + tc->dragOffsetY = e.y; + } + } + + void mouseDrag (const MouseEvent& e) override + { + if (e.mouseWasDraggedSinceMouseDown() && ! isDragging) + { + isDragging = true; + + if (DragAndDropContainer* const dnd = DragAndDropContainer::findParentDragContainerFor (this)) + { + dnd->startDragging (Toolbar::toolbarDragDescriptor, getParentComponent(), ScaledImage(), true, nullptr, &e.source); + + if (ToolbarItemComponent* const tc = getToolbarItemComponent()) + { + tc->isBeingDragged = true; + + if (tc->getEditingMode() == ToolbarItemComponent::editableOnToolbar) + tc->setVisible (false); + } + } + } + } + + void mouseUp (const MouseEvent&) override + { + isDragging = false; + + if (ToolbarItemComponent* const tc = getToolbarItemComponent()) + { + tc->isBeingDragged = false; + + if (Toolbar* const tb = tc->getToolbar()) + tb->updateAllItemPositions (true); + else if (tc->getEditingMode() == ToolbarItemComponent::editableOnToolbar) + delete tc; + } + } + + void parentSizeChanged() override + { + setBounds (0, 0, getParentWidth(), getParentHeight()); + } + +private: + //============================================================================== + bool isDragging; + + ToolbarItemComponent* getToolbarItemComponent() const noexcept + { + return dynamic_cast (getParentComponent()); + } + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ToolbarItemDragAndDropOverlayComponent) +}; + +} // namespace juce::detail diff --git a/modules/juce_gui_basics/detail/juce_TopLevelWindowManager.h b/modules/juce_gui_basics/detail/juce_TopLevelWindowManager.h new file mode 100644 index 0000000000..797c696e78 --- /dev/null +++ b/modules/juce_gui_basics/detail/juce_TopLevelWindowManager.h @@ -0,0 +1,136 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + By using JUCE, you agree to the terms of both the JUCE 7 End-User License + Agreement and JUCE Privacy Policy. + + End User License Agreement: www.juce.com/juce-7-licence + Privacy Policy: www.juce.com/juce-privacy-policy + + Or: You may also use this code under the terms of the GPL v3 (see + www.gnu.org/licenses). + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce::detail +{ + +/** Keeps track of the active top level window. */ +class TopLevelWindowManager : private Timer, + private DeletedAtShutdown +{ +public: + TopLevelWindowManager() = default; + + ~TopLevelWindowManager() override + { + clearSingletonInstance(); + } + + JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (TopLevelWindowManager) + + static void checkCurrentlyFocusedTopLevelWindow() + { + if (auto* wm = TopLevelWindowManager::getInstanceWithoutCreating()) + wm->checkFocusAsync(); + } + + void checkFocusAsync() + { + startTimer (10); + } + + void checkFocus() + { + startTimer (jmin (1731, getTimerInterval() * 2)); + + auto* newActive = findCurrentlyActiveWindow(); + + if (newActive != currentActive) + { + currentActive = newActive; + + for (int i = windows.size(); --i >= 0;) + if (auto* tlw = windows[i]) + tlw->setWindowActive (isWindowActive (tlw)); + + Desktop::getInstance().triggerFocusCallback(); + } + } + + bool addWindow (TopLevelWindow* const w) + { + windows.add (w); + checkFocusAsync(); + + return isWindowActive (w); + } + + void removeWindow (TopLevelWindow* const w) + { + checkFocusAsync(); + + if (currentActive == w) + currentActive = nullptr; + + windows.removeFirstMatchingValue (w); + + if (windows.isEmpty()) + deleteInstance(); + } + + Array windows; + +private: + TopLevelWindow* currentActive = nullptr; + + void timerCallback() override + { + checkFocus(); + } + + bool isWindowActive (TopLevelWindow* const tlw) const + { + return (tlw == currentActive + || tlw->isParentOf (currentActive) + || tlw->hasKeyboardFocus (true)) + && tlw->isShowing(); + } + + TopLevelWindow* findCurrentlyActiveWindow() const + { + if (Process::isForegroundProcess()) + { + auto* focusedComp = Component::getCurrentlyFocusedComponent(); + auto* w = dynamic_cast (focusedComp); + + if (w == nullptr && focusedComp != nullptr) + w = focusedComp->findParentComponentOfClass(); + + if (w == nullptr) + w = currentActive; + + if (w != nullptr && w->isShowing()) + return w; + } + + return nullptr; + } + + JUCE_DECLARE_NON_COPYABLE (TopLevelWindowManager) +}; + +JUCE_IMPLEMENT_SINGLETON (TopLevelWindowManager) + +} // namespace juce::detail diff --git a/modules/juce_gui_basics/detail/juce_ViewportHelpers.h b/modules/juce_gui_basics/detail/juce_ViewportHelpers.h new file mode 100644 index 0000000000..2e9ab9197d --- /dev/null +++ b/modules/juce_gui_basics/detail/juce_ViewportHelpers.h @@ -0,0 +1,49 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + By using JUCE, you agree to the terms of both the JUCE 7 End-User License + Agreement and JUCE Privacy Policy. + + End User License Agreement: www.juce.com/juce-7-licence + Privacy Policy: www.juce.com/juce-privacy-policy + + Or: You may also use this code under the terms of the GPL v3 (see + www.gnu.org/licenses). + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce::detail +{ + +struct ViewportHelpers +{ + ViewportHelpers() = delete; + + static bool wouldScrollOnEvent (const Viewport* vp, const MouseInputSource& src) + { + if (vp != nullptr) + { + switch (vp->getScrollOnDragMode()) + { + case Viewport::ScrollOnDragMode::all: return true; + case Viewport::ScrollOnDragMode::nonHover: return ! src.canHover(); + case Viewport::ScrollOnDragMode::never: return false; + } + } + + return false; + } +}; + +} // namespace juce::detail diff --git a/modules/juce_gui_basics/detail/juce_WindowingHelpers.h b/modules/juce_gui_basics/detail/juce_WindowingHelpers.h new file mode 100644 index 0000000000..93f9dd8c0c --- /dev/null +++ b/modules/juce_gui_basics/detail/juce_WindowingHelpers.h @@ -0,0 +1,54 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + By using JUCE, you agree to the terms of both the JUCE 7 End-User License + Agreement and JUCE Privacy Policy. + + End User License Agreement: www.juce.com/juce-7-licence + Privacy Policy: www.juce.com/juce-privacy-policy + + Or: You may also use this code under the terms of the GPL v3 (see + www.gnu.org/licenses). + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce::detail +{ + +struct WindowingHelpers +{ + WindowingHelpers() = delete; + + static Image createIconForFile (const File& file); + + static bool areThereAnyAlwaysOnTopWindows(); + + #if JUCE_WINDOWS + static bool isEmbeddedInForegroundProcess (Component* c); + static bool isWindowOnCurrentVirtualDesktop (void*); + #else + static bool isEmbeddedInForegroundProcess (Component*) { return false; } + static bool isWindowOnCurrentVirtualDesktop (void*) { return true; } + #endif + + /* Returns true if this process is in the foreground, or if the viewComponent + is embedded into a window owned by the foreground process. + */ + static bool isForegroundOrEmbeddedProcess (Component* viewComponent) + { + return Process::isForegroundProcess() || isEmbeddedInForegroundProcess (viewComponent); + } +}; + +} // namespace juce::detail diff --git a/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp index 13e4f9d764..b56172e477 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp @@ -605,7 +605,7 @@ void FileBrowserComponent::getRoots (StringArray& rootNames, StringArray& rootPa void FileBrowserComponent::timerCallback() { - const auto isProcessActive = isForegroundOrEmbeddedProcess (this); + const auto isProcessActive = detail::WindowingHelpers::isForegroundOrEmbeddedProcess (this); if (wasProcessActive != isProcessActive) { diff --git a/modules/juce_gui_basics/filebrowser/juce_FileChooser.cpp b/modules/juce_gui_basics/filebrowser/juce_FileChooser.cpp index a85f57ee16..00b111f093 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileChooser.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FileChooser.cpp @@ -165,7 +165,7 @@ bool FileChooser::browseForDirectory() bool FileChooser::showDialog (const int flags, FilePreviewComponent* const previewComp) { - FocusRestorer focusRestorer; + detail::FocusRestorer focusRestorer; pimpl = createPimpl (flags, previewComp); pimpl->runModally(); diff --git a/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp b/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp index f531da182d..4e62b1519f 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp @@ -115,7 +115,7 @@ FileChooserDialogBox::FileChooserDialogBox (const String& name, if (parentComp != nullptr) parentComp->addAndMakeVisible (this); else - setAlwaysOnTop (juce_areThereAnyAlwaysOnTopWindows()); + setAlwaysOnTop (detail::WindowingHelpers::areThereAnyAlwaysOnTopWindows()); } FileChooserDialogBox::~FileChooserDialogBox() diff --git a/modules/juce_gui_basics/filebrowser/juce_FileListComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_FileListComponent.cpp index 073feb9ed0..c35a8fc8ff 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileListComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FileListComponent.cpp @@ -26,9 +26,6 @@ namespace juce { -Image juce_createIconForFile (const File& file); - - //============================================================================== FileListComponent::FileListComponent (DirectoryContentsList& listToShow) : ListBox ({}, this), @@ -217,7 +214,7 @@ private: if (im.isNull() && ! onlyUpdateIfCached) { - im = juce_createIconForFile (file); + im = detail::WindowingHelpers::createIconForFile (file); if (im.isValid()) ImageCache::addImageToCache (im, hashCode); diff --git a/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp index 916193cfd7..69eb78a6be 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp @@ -261,7 +261,7 @@ private: if (im.isNull() && ! onlyUpdateIfCached) { - im = juce_createIconForFile (file); + im = detail::WindowingHelpers::createIconForFile (file); if (im.isValid()) ImageCache::addImageToCache (im, hashCode); diff --git a/modules/juce_gui_basics/juce_gui_basics.cpp b/modules/juce_gui_basics/juce_gui_basics.cpp index cf089966df..22f53641d1 100644 --- a/modules/juce_gui_basics/juce_gui_basics.cpp +++ b/modules/juce_gui_basics/juce_gui_basics.cpp @@ -107,180 +107,26 @@ #endif //============================================================================== -#define JUCE_ASSERT_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN \ - jassert ((MessageManager::getInstanceWithoutCreating() != nullptr \ - && MessageManager::getInstanceWithoutCreating()->currentThreadHasLockedMessageManager()) \ - || getPeer() == nullptr); - -namespace juce -{ - bool juce_areThereAnyAlwaysOnTopWindows(); - - bool isEmbeddedInForegroundProcess (Component* c); - - #if ! JUCE_WINDOWS - bool isEmbeddedInForegroundProcess (Component*) { return false; } - #endif - - /* Returns true if this process is in the foreground, or if the viewComponent - is embedded into a window owned by the foreground process. - */ - static bool isForegroundOrEmbeddedProcess (Component* viewComponent) - { - return Process::isForegroundProcess() || isEmbeddedInForegroundProcess (viewComponent); - } - - bool isWindowOnCurrentVirtualDesktop (void*); - - struct CustomMouseCursorInfo - { - ScaledImage image; - Point hotspot; - }; - - template - static const AccessibilityHandler* getEnclosingHandlerWithInterface (const AccessibilityHandler* handler, MemberFn fn) - { - if (handler == nullptr) - return nullptr; - - if ((handler->*fn)() != nullptr) - return handler; - - return getEnclosingHandlerWithInterface (handler->getParent(), fn); - } -} // namespace juce - -#include "mouse/juce_PointerState.h" - -#include "accessibility/juce_AccessibilityHandler.cpp" -#include "components/juce_Component.cpp" -#include "components/juce_ComponentListener.cpp" -#include "components/juce_FocusTraverser.cpp" -#include "mouse/juce_MouseInputSource.cpp" -#include "desktop/juce_Displays.cpp" -#include "desktop/juce_Desktop.cpp" -#include "components/juce_ModalComponentManager.cpp" -#include "mouse/juce_ComponentDragger.cpp" -#include "mouse/juce_DragAndDropContainer.cpp" -#include "mouse/juce_MouseEvent.cpp" -#include "mouse/juce_MouseInactivityDetector.cpp" -#include "mouse/juce_MouseListener.cpp" -#include "keyboard/juce_CaretComponent.cpp" -#include "keyboard/juce_KeyboardFocusTraverser.cpp" -#include "keyboard/juce_KeyListener.cpp" -#include "keyboard/juce_KeyPress.cpp" -#include "keyboard/juce_ModifierKeys.cpp" -#include "buttons/juce_ArrowButton.cpp" -#include "buttons/juce_Button.cpp" -#include "buttons/juce_DrawableButton.cpp" -#include "buttons/juce_HyperlinkButton.cpp" -#include "buttons/juce_ImageButton.cpp" -#include "buttons/juce_ShapeButton.cpp" -#include "buttons/juce_TextButton.cpp" -#include "buttons/juce_ToggleButton.cpp" -#include "buttons/juce_ToolbarButton.cpp" -#include "drawables/juce_Drawable.cpp" -#include "drawables/juce_DrawableComposite.cpp" -#include "drawables/juce_DrawableImage.cpp" -#include "drawables/juce_DrawablePath.cpp" -#include "drawables/juce_DrawableRectangle.cpp" -#include "drawables/juce_DrawableShape.cpp" -#include "drawables/juce_DrawableText.cpp" -#include "drawables/juce_SVGParser.cpp" -#include "filebrowser/juce_DirectoryContentsDisplayComponent.cpp" -#include "filebrowser/juce_DirectoryContentsList.cpp" -#include "filebrowser/juce_FileBrowserComponent.cpp" -#include "filebrowser/juce_FileChooser.cpp" -#include "filebrowser/juce_FileChooserDialogBox.cpp" -#include "filebrowser/juce_FileListComponent.cpp" -#include "filebrowser/juce_FilenameComponent.cpp" -#include "filebrowser/juce_FileSearchPathListComponent.cpp" -#include "filebrowser/juce_FileTreeComponent.cpp" -#include "filebrowser/juce_ImagePreviewComponent.cpp" -#include "filebrowser/juce_ContentSharer.cpp" -#include "layout/juce_ComponentAnimator.cpp" -#include "layout/juce_ComponentBoundsConstrainer.cpp" -#include "layout/juce_ComponentBuilder.cpp" -#include "layout/juce_ComponentMovementWatcher.cpp" -#include "layout/juce_ConcertinaPanel.cpp" -#include "layout/juce_GroupComponent.cpp" -#include "layout/juce_MultiDocumentPanel.cpp" -#include "layout/juce_ResizableBorderComponent.cpp" -#include "layout/juce_ResizableCornerComponent.cpp" -#include "layout/juce_ResizableEdgeComponent.cpp" -#include "layout/juce_ScrollBar.cpp" -#include "layout/juce_SidePanel.cpp" -#include "layout/juce_StretchableLayoutManager.cpp" -#include "layout/juce_StretchableLayoutResizerBar.cpp" -#include "layout/juce_StretchableObjectResizer.cpp" -#include "layout/juce_TabbedButtonBar.cpp" -#include "layout/juce_TabbedComponent.cpp" -#include "layout/juce_Viewport.cpp" -#include "lookandfeel/juce_LookAndFeel.cpp" -#include "lookandfeel/juce_LookAndFeel_V2.cpp" -#include "lookandfeel/juce_LookAndFeel_V1.cpp" -#include "lookandfeel/juce_LookAndFeel_V3.cpp" -#include "lookandfeel/juce_LookAndFeel_V4.cpp" -#include "menus/juce_MenuBarComponent.cpp" -#include "menus/juce_BurgerMenuComponent.cpp" -#include "menus/juce_MenuBarModel.cpp" -#include "menus/juce_PopupMenu.cpp" -#include "positioning/juce_MarkerList.cpp" -#include "positioning/juce_RelativeCoordinate.cpp" -#include "positioning/juce_RelativeCoordinatePositioner.cpp" -#include "positioning/juce_RelativeParallelogram.cpp" -#include "positioning/juce_RelativePoint.cpp" -#include "positioning/juce_RelativePointPath.cpp" -#include "positioning/juce_RelativeRectangle.cpp" -#include "properties/juce_BooleanPropertyComponent.cpp" -#include "properties/juce_ButtonPropertyComponent.cpp" -#include "properties/juce_ChoicePropertyComponent.cpp" -#include "properties/juce_PropertyComponent.cpp" -#include "properties/juce_PropertyPanel.cpp" -#include "properties/juce_SliderPropertyComponent.cpp" -#include "properties/juce_TextPropertyComponent.cpp" -#include "properties/juce_MultiChoicePropertyComponent.cpp" -#include "widgets/juce_ComboBox.cpp" -#include "widgets/juce_ImageComponent.cpp" -#include "widgets/juce_Label.cpp" -#include "widgets/juce_ListBox.cpp" -#include "widgets/juce_ProgressBar.cpp" -#include "widgets/juce_Slider.cpp" -#include "widgets/juce_TableHeaderComponent.cpp" -#include "widgets/juce_TableListBox.cpp" -#include "widgets/juce_TextEditor.cpp" -#include "widgets/juce_ToolbarItemComponent.cpp" -#include "widgets/juce_Toolbar.cpp" -#include "widgets/juce_ToolbarItemPalette.cpp" -#include "widgets/juce_TreeView.cpp" -#include "windows/juce_MessageBoxOptions.cpp" -#include "windows/juce_ScopedMessageBox.cpp" -#include "windows/juce_AlertWindow.cpp" -#include "windows/juce_NativeMessageBox.cpp" -#include "windows/juce_CallOutBox.cpp" -#include "windows/juce_ComponentPeer.cpp" -#include "windows/juce_DialogWindow.cpp" -#include "windows/juce_DocumentWindow.cpp" -#include "windows/juce_ResizableWindow.cpp" -#include "windows/juce_ThreadWithProgressWindow.cpp" -#include "windows/juce_TooltipWindow.cpp" -#include "windows/juce_TopLevelWindow.cpp" -#include "windows/juce_VBlankAttachement.cpp" -#include "commands/juce_ApplicationCommandInfo.cpp" -#include "commands/juce_ApplicationCommandManager.cpp" -#include "commands/juce_ApplicationCommandTarget.cpp" -#include "commands/juce_KeyPressMappingSet.cpp" -#include "application/juce_Application.cpp" -#include "misc/juce_BubbleComponent.cpp" -#include "misc/juce_DropShadower.cpp" -#include "misc/juce_FocusOutline.cpp" -#include "misc/juce_JUCESplashScreen.cpp" - -#include "layout/juce_FlexBox.cpp" -#include "layout/juce_GridItem.cpp" -#include "layout/juce_Grid.cpp" +#include "detail/juce_AccessibilityHelpers.h" +#include "detail/juce_ButtonAccessibilityHandler.h" +#include "detail/juce_ScalingHelpers.h" +#include "detail/juce_ComponentHelpers.h" +#include "detail/juce_FocusHelpers.h" +#include "detail/juce_FocusRestorer.h" +#include "detail/juce_ViewportHelpers.h" +#include "detail/juce_LookAndFeelHelpers.h" +#include "detail/juce_PointerState.h" +#include "detail/juce_CustomMouseCursorInfo.h" +#include "detail/juce_MouseInputSourceImpl.h" +#include "detail/juce_MouseInputSourceList.h" +#include "detail/juce_ToolbarItemDragAndDropOverlayComponent.h" +#include "detail/juce_ScopedMessageBoxInterface.h" +#include "detail/juce_ScopedMessageBoxImpl.h" +#include "detail/juce_WindowingHelpers.h" +#include "detail/juce_AlertWindowHelpers.h" +#include "detail/juce_TopLevelWindowManager.h" +//============================================================================== #if JUCE_IOS || JUCE_WINDOWS #include "native/juce_MultiTouchMapper.h" #endif @@ -345,27 +191,6 @@ namespace juce #elif JUCE_ANDROID -namespace juce -{ -static jobject makeAndroidRect (Rectangle r) -{ - return getEnv()->NewObject (AndroidRect, - AndroidRect.constructor, - r.getX(), - r.getY(), - r.getRight(), - r.getBottom()); -} - -static jobject makeAndroidPoint (Point p) -{ - return getEnv()->NewObject (AndroidPoint, - AndroidPoint.create, - p.getX(), - p.getY()); -} -} // namespace juce - #include "juce_core/files/juce_common_MimeTypes.h" #include "native/accessibility/juce_android_Accessibility.cpp" #include "native/juce_android_Windowing.cpp" @@ -378,93 +203,141 @@ static jobject makeAndroidPoint (Point p) #endif -namespace juce -{ - #if ! JUCE_NATIVE_ACCESSIBILITY_INCLUDED - class AccessibilityHandler::AccessibilityNativeImpl { public: AccessibilityNativeImpl (AccessibilityHandler&) {} }; - void AccessibilityHandler::notifyAccessibilityEvent (AccessibilityEvent) const {} - void AccessibilityHandler::postAnnouncement (const String&, AnnouncementPriority) {} - AccessibilityNativeHandle* AccessibilityHandler::getNativeImplementation() const { return nullptr; } - void notifyAccessibilityEventInternal (const AccessibilityHandler&, InternalAccessibilityEvent) {} - std::unique_ptr AccessibilityHandler::createNativeImpl (AccessibilityHandler&) - { - return nullptr; - } - #else - std::unique_ptr AccessibilityHandler::createNativeImpl (AccessibilityHandler& handler) - { - return std::make_unique (handler); - } - #endif -} - //============================================================================== -#if JUCE_WINDOWS -namespace juce -{ - -JUCE_COMCLASS (JuceIVirtualDesktopManager, "a5cd92ff-29be-454c-8d04-d82879fb3f1b") : public IUnknown -{ -public: - virtual HRESULT STDMETHODCALLTYPE IsWindowOnCurrentVirtualDesktop( - __RPC__in HWND topLevelWindow, - __RPC__out BOOL * onCurrentDesktop) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetWindowDesktopId( - __RPC__in HWND topLevelWindow, - __RPC__out GUID * desktopId) = 0; - - virtual HRESULT STDMETHODCALLTYPE MoveWindowToDesktop( - __RPC__in HWND topLevelWindow, - __RPC__in REFGUID desktopId) = 0; -}; - -JUCE_COMCLASS (JuceVirtualDesktopManager, "aa509086-5ca9-4c25-8f95-589d3c07b48a"); - -} // namespace juce - -#ifdef __CRT_UUID_DECL -__CRT_UUID_DECL (juce::JuceIVirtualDesktopManager, 0xa5cd92ff, 0x29be, 0x454c, 0x8d, 0x04, 0xd8, 0x28, 0x79, 0xfb, 0x3f, 0x1b) -__CRT_UUID_DECL (juce::JuceVirtualDesktopManager, 0xaa509086, 0x5ca9, 0x4c25, 0x8f, 0x95, 0x58, 0x9d, 0x3c, 0x07, 0xb4, 0x8a) -#endif - -bool juce::isWindowOnCurrentVirtualDesktop (void* x) -{ - if (x == nullptr) - return false; - - static auto* desktopManager = [] - { - JuceIVirtualDesktopManager* result = nullptr; - - JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wlanguage-extension-token") - - if (SUCCEEDED (CoCreateInstance (__uuidof (JuceVirtualDesktopManager), nullptr, CLSCTX_ALL, IID_PPV_ARGS (&result)))) - return result; - - JUCE_END_IGNORE_WARNINGS_GCC_LIKE - - return static_cast (nullptr); - }(); - - BOOL current = false; - - if (auto* dm = desktopManager) - if (SUCCEEDED (dm->IsWindowOnCurrentVirtualDesktop (static_cast (x), ¤t))) - return current != false; - - return true; -} - -#else - bool juce::isWindowOnCurrentVirtualDesktop (void*) { return true; } - juce::ScopedDPIAwarenessDisabler::ScopedDPIAwarenessDisabler() { ignoreUnused (previousContext); } - juce::ScopedDPIAwarenessDisabler::~ScopedDPIAwarenessDisabler() {} -#endif - // Depends on types defined in platform-specific windowing files #include "mouse/juce_MouseCursor.cpp" #if JUCE_UNIT_TESTS -#include "native/accessibility/juce_AccessibilityTextHelpers_test.cpp" + #include "native/accessibility/juce_AccessibilityTextHelpers_test.cpp" #endif + +//============================================================================== +#include "accessibility/juce_AccessibilityHandler.cpp" +#include "application/juce_Application.cpp" +#include "buttons/juce_ArrowButton.cpp" +#include "buttons/juce_Button.cpp" +#include "buttons/juce_DrawableButton.cpp" +#include "buttons/juce_HyperlinkButton.cpp" +#include "buttons/juce_ImageButton.cpp" +#include "buttons/juce_ShapeButton.cpp" +#include "buttons/juce_TextButton.cpp" +#include "buttons/juce_ToggleButton.cpp" +#include "buttons/juce_ToolbarButton.cpp" +#include "commands/juce_ApplicationCommandInfo.cpp" +#include "commands/juce_ApplicationCommandManager.cpp" +#include "commands/juce_ApplicationCommandTarget.cpp" +#include "commands/juce_KeyPressMappingSet.cpp" +#include "components/juce_Component.cpp" +#include "components/juce_ComponentListener.cpp" +#include "components/juce_FocusTraverser.cpp" +#include "components/juce_ModalComponentManager.cpp" +#include "desktop/juce_Desktop.cpp" +#include "desktop/juce_Displays.cpp" +#include "detail/juce_AccessibilityHelpers.cpp" +#include "drawables/juce_Drawable.cpp" +#include "drawables/juce_DrawableComposite.cpp" +#include "drawables/juce_DrawableImage.cpp" +#include "drawables/juce_DrawablePath.cpp" +#include "drawables/juce_DrawableRectangle.cpp" +#include "drawables/juce_DrawableShape.cpp" +#include "drawables/juce_DrawableText.cpp" +#include "drawables/juce_SVGParser.cpp" +#include "filebrowser/juce_ContentSharer.cpp" +#include "filebrowser/juce_DirectoryContentsDisplayComponent.cpp" +#include "filebrowser/juce_DirectoryContentsList.cpp" +#include "filebrowser/juce_FileBrowserComponent.cpp" +#include "filebrowser/juce_FileChooser.cpp" +#include "filebrowser/juce_FileChooserDialogBox.cpp" +#include "filebrowser/juce_FileListComponent.cpp" +#include "filebrowser/juce_FileSearchPathListComponent.cpp" +#include "filebrowser/juce_FileTreeComponent.cpp" +#include "filebrowser/juce_FilenameComponent.cpp" +#include "filebrowser/juce_ImagePreviewComponent.cpp" +#include "keyboard/juce_CaretComponent.cpp" +#include "keyboard/juce_KeyListener.cpp" +#include "keyboard/juce_KeyPress.cpp" +#include "keyboard/juce_KeyboardFocusTraverser.cpp" +#include "keyboard/juce_ModifierKeys.cpp" +#include "layout/juce_ComponentAnimator.cpp" +#include "layout/juce_ComponentBoundsConstrainer.cpp" +#include "layout/juce_ComponentBuilder.cpp" +#include "layout/juce_ComponentMovementWatcher.cpp" +#include "layout/juce_ConcertinaPanel.cpp" +#include "layout/juce_FlexBox.cpp" +#include "layout/juce_Grid.cpp" +#include "layout/juce_GridItem.cpp" +#include "layout/juce_GroupComponent.cpp" +#include "layout/juce_MultiDocumentPanel.cpp" +#include "layout/juce_ResizableBorderComponent.cpp" +#include "layout/juce_ResizableCornerComponent.cpp" +#include "layout/juce_ResizableEdgeComponent.cpp" +#include "layout/juce_ScrollBar.cpp" +#include "layout/juce_SidePanel.cpp" +#include "layout/juce_StretchableLayoutManager.cpp" +#include "layout/juce_StretchableLayoutResizerBar.cpp" +#include "layout/juce_StretchableObjectResizer.cpp" +#include "layout/juce_TabbedButtonBar.cpp" +#include "layout/juce_TabbedComponent.cpp" +#include "layout/juce_Viewport.cpp" +#include "lookandfeel/juce_LookAndFeel.cpp" +#include "lookandfeel/juce_LookAndFeel_V1.cpp" +#include "lookandfeel/juce_LookAndFeel_V2.cpp" +#include "lookandfeel/juce_LookAndFeel_V3.cpp" +#include "lookandfeel/juce_LookAndFeel_V4.cpp" +#include "menus/juce_BurgerMenuComponent.cpp" +#include "menus/juce_MenuBarComponent.cpp" +#include "menus/juce_MenuBarModel.cpp" +#include "menus/juce_PopupMenu.cpp" +#include "misc/juce_BubbleComponent.cpp" +#include "misc/juce_DropShadower.cpp" +#include "misc/juce_FocusOutline.cpp" +#include "misc/juce_JUCESplashScreen.cpp" +#include "mouse/juce_ComponentDragger.cpp" +#include "mouse/juce_DragAndDropContainer.cpp" +#include "mouse/juce_MouseEvent.cpp" +#include "mouse/juce_MouseInactivityDetector.cpp" +#include "mouse/juce_MouseInputSource.cpp" +#include "mouse/juce_MouseListener.cpp" +#include "native/accessibility/juce_Accessibility.cpp" +#include "native/juce_ScopedDPIAwarenessDisabler.cpp" +#include "positioning/juce_MarkerList.cpp" +#include "positioning/juce_RelativeCoordinate.cpp" +#include "positioning/juce_RelativeCoordinatePositioner.cpp" +#include "positioning/juce_RelativeParallelogram.cpp" +#include "positioning/juce_RelativePoint.cpp" +#include "positioning/juce_RelativePointPath.cpp" +#include "positioning/juce_RelativeRectangle.cpp" +#include "properties/juce_BooleanPropertyComponent.cpp" +#include "properties/juce_ButtonPropertyComponent.cpp" +#include "properties/juce_ChoicePropertyComponent.cpp" +#include "properties/juce_MultiChoicePropertyComponent.cpp" +#include "properties/juce_PropertyComponent.cpp" +#include "properties/juce_PropertyPanel.cpp" +#include "properties/juce_SliderPropertyComponent.cpp" +#include "properties/juce_TextPropertyComponent.cpp" +#include "widgets/juce_ComboBox.cpp" +#include "widgets/juce_ImageComponent.cpp" +#include "widgets/juce_Label.cpp" +#include "widgets/juce_ListBox.cpp" +#include "widgets/juce_ProgressBar.cpp" +#include "widgets/juce_Slider.cpp" +#include "widgets/juce_TableHeaderComponent.cpp" +#include "widgets/juce_TableListBox.cpp" +#include "widgets/juce_TextEditor.cpp" +#include "widgets/juce_Toolbar.cpp" +#include "widgets/juce_ToolbarItemComponent.cpp" +#include "widgets/juce_ToolbarItemPalette.cpp" +#include "widgets/juce_TreeView.cpp" +#include "windows/juce_AlertWindow.cpp" +#include "windows/juce_CallOutBox.cpp" +#include "windows/juce_ComponentPeer.cpp" +#include "windows/juce_DialogWindow.cpp" +#include "windows/juce_DocumentWindow.cpp" +#include "windows/juce_MessageBoxOptions.cpp" +#include "windows/juce_NativeMessageBox.cpp" +#include "windows/juce_ResizableWindow.cpp" +#include "windows/juce_ScopedMessageBox.cpp" +#include "windows/juce_ThreadWithProgressWindow.cpp" +#include "windows/juce_TooltipWindow.cpp" +#include "windows/juce_TopLevelWindow.cpp" +#include "windows/juce_VBlankAttachement.cpp" diff --git a/modules/juce_gui_basics/juce_gui_basics.h b/modules/juce_gui_basics/juce_gui_basics.h index 6f76a2c50b..7592d839a7 100644 --- a/modules/juce_gui_basics/juce_gui_basics.h +++ b/modules/juce_gui_basics/juce_gui_basics.h @@ -127,7 +127,6 @@ namespace juce class Component; class LookAndFeel; class MouseInputSource; - class MouseInputSourceInternal; class ComponentPeer; class MouseEvent; struct MouseWheelDetails; @@ -161,7 +160,6 @@ namespace juce class Displays; class AccessibilityHandler; class KeyboardFocusTraverser; - class PointerState; class FlexBox; class Grid; @@ -170,7 +168,19 @@ namespace juce #if JUCE_MAC || JUCE_WINDOWS || JUCE_LINUX || JUCE_BSD Image createSnapshotOfNativeWindow (void* nativeWindowHandle); #endif -} + + namespace detail + { + struct ComponentHelpers; + class MouseInputSourceImpl; + class MouseInputSourceList; + class PointerState; + class ScopedMessageBoxImpl; + class ToolbarItemDragAndDropOverlayComponent; + class TopLevelWindowManager; + } // namespace detail + +} // namespace juce #include "mouse/juce_MouseCursor.h" #include "mouse/juce_MouseListener.h" diff --git a/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.cpp b/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.cpp index 0aab730be0..f0d5e681b7 100644 --- a/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.cpp +++ b/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.cpp @@ -35,10 +35,10 @@ namespace KeyboardFocusTraverserHelpers } static Component* traverse (Component* current, Component* container, - FocusHelpers::NavigationDirection direction) + detail::FocusHelpers::NavigationDirection direction) { - if (auto* comp = FocusHelpers::navigateFocus (current, container, direction, - &Component::isKeyboardFocusContainer)) + if (auto* comp = detail::FocusHelpers::navigateFocus (current, container, direction, + &Component::isKeyboardFocusContainer)) { if (isKeyboardFocusable (comp, container)) return comp; @@ -53,13 +53,13 @@ namespace KeyboardFocusTraverserHelpers Component* KeyboardFocusTraverser::getNextComponent (Component* current) { return KeyboardFocusTraverserHelpers::traverse (current, current->findKeyboardFocusContainer(), - FocusHelpers::NavigationDirection::forwards); + detail::FocusHelpers::NavigationDirection::forwards); } Component* KeyboardFocusTraverser::getPreviousComponent (Component* current) { return KeyboardFocusTraverserHelpers::traverse (current, current->findKeyboardFocusContainer(), - FocusHelpers::NavigationDirection::backwards); + detail::FocusHelpers::NavigationDirection::backwards); } Component* KeyboardFocusTraverser::getDefaultComponent (Component* parentComponent) @@ -74,9 +74,9 @@ Component* KeyboardFocusTraverser::getDefaultComponent (Component* parentCompone std::vector KeyboardFocusTraverser::getAllComponents (Component* parentComponent) { std::vector components; - FocusHelpers::findAllComponents (parentComponent, - components, - &Component::isKeyboardFocusContainer); + detail::FocusHelpers::findAllComponents (parentComponent, + components, + &Component::isKeyboardFocusContainer); auto removePredicate = [parentComponent] (const Component* comp) { diff --git a/modules/juce_gui_basics/layout/juce_Viewport.cpp b/modules/juce_gui_basics/layout/juce_Viewport.cpp index e227a2ea4b..e79c10dece 100644 --- a/modules/juce_gui_basics/layout/juce_Viewport.cpp +++ b/modules/juce_gui_basics/layout/juce_Viewport.cpp @@ -26,21 +26,6 @@ namespace juce { -static bool viewportWouldScrollOnEvent (const Viewport* vp, const MouseInputSource& src) noexcept -{ - if (vp != nullptr) - { - switch (vp->getScrollOnDragMode()) - { - case Viewport::ScrollOnDragMode::all: return true; - case Viewport::ScrollOnDragMode::nonHover: return ! src.canHover(); - case Viewport::ScrollOnDragMode::never: return false; - } - } - - return false; -} - using ViewportDragPosition = AnimatedPosition; struct Viewport::DragToScrollListener : private MouseListener, @@ -75,7 +60,7 @@ struct Viewport::DragToScrollListener : private MouseListener, void mouseDown (const MouseEvent& e) override { - if (! isGlobalMouseListener && viewportWouldScrollOnEvent (&viewport, e.source)) + if (! isGlobalMouseListener && detail::ViewportHelpers::wouldScrollOnEvent (&viewport, e.source)) { offsetX.setPosition (offsetX.getPosition()); offsetY.setPosition (offsetY.getPosition()); @@ -98,7 +83,7 @@ struct Viewport::DragToScrollListener : private MouseListener, { auto totalOffset = e.getEventRelativeTo (&viewport).getOffsetFromDragStart().toFloat(); - if (! isDragging && totalOffset.getDistanceFromOrigin() > 8.0f && viewportWouldScrollOnEvent (&viewport, e.source)) + if (! isDragging && totalOffset.getDistanceFromOrigin() > 8.0f && detail::ViewportHelpers::wouldScrollOnEvent (&viewport, e.source)) { isDragging = true; diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp index d0e86e63b7..b34c319ffd 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp @@ -26,37 +26,6 @@ namespace juce { -namespace LookAndFeelHelpers -{ - static Colour createBaseColour (Colour buttonColour, - bool hasKeyboardFocus, - bool shouldDrawButtonAsHighlighted, - bool shouldDrawButtonAsDown) noexcept - { - const float sat = hasKeyboardFocus ? 1.3f : 0.9f; - const Colour baseColour (buttonColour.withMultipliedSaturation (sat)); - - if (shouldDrawButtonAsDown) return baseColour.contrasting (0.2f); - if (shouldDrawButtonAsHighlighted) return baseColour.contrasting (0.1f); - - return baseColour; - } - - static TextLayout layoutTooltipText (const String& text, Colour colour) noexcept - { - const float tooltipFontSize = 13.0f; - const int maxToolTipWidth = 400; - - AttributedString s; - s.setJustification (Justification::centred); - s.append (text, Font (tooltipFontSize, Font::bold), colour); - - TextLayout tl; - tl.createLayoutWithBalancedLineLengths (s, (float) maxToolTipWidth); - return tl; - } -} - //============================================================================== LookAndFeel_V2::LookAndFeel_V2() { @@ -259,10 +228,10 @@ void LookAndFeel_V2::drawButtonBackground (Graphics& g, const float indentT = button.isConnectedOnTop() ? 0.1f : halfThickness; const float indentB = button.isConnectedOnBottom() ? 0.1f : halfThickness; - const Colour baseColour (LookAndFeelHelpers::createBaseColour (backgroundColour, - button.hasKeyboardFocus (true), - shouldDrawButtonAsHighlighted, - shouldDrawButtonAsDown) + const Colour baseColour (detail::LookAndFeelHelpers::createBaseColour (backgroundColour, + button.hasKeyboardFocus (true), + shouldDrawButtonAsHighlighted, + shouldDrawButtonAsDown) .withMultipliedAlpha (button.isEnabled() ? 1.0f : 0.5f)); drawGlassLozenge (g, @@ -320,9 +289,9 @@ void LookAndFeel_V2::drawTickBox (Graphics& g, Component& component, const float boxSize = w * 0.7f; drawGlassSphere (g, x, y + (h - boxSize) * 0.5f, boxSize, - LookAndFeelHelpers::createBaseColour (component.findColour (TextButton::buttonColourId) - .withMultipliedAlpha (isEnabled ? 1.0f : 0.5f), - true, shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown), + detail::LookAndFeelHelpers::createBaseColour (component.findColour (TextButton::buttonColourId) + .withMultipliedAlpha (isEnabled ? 1.0f : 0.5f), + true, shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown), isEnabled ? ((shouldDrawButtonAsDown || shouldDrawButtonAsHighlighted) ? 1.1f : 0.5f) : 0.3f); if (ticked) @@ -1110,8 +1079,8 @@ int LookAndFeel_V2::getMenuWindowFlags() void LookAndFeel_V2::drawMenuBarBackground (Graphics& g, int width, int height, bool, MenuBarComponent& menuBar) { - auto baseColour = LookAndFeelHelpers::createBaseColour (menuBar.findColour (PopupMenu::backgroundColourId), - false, false, false); + auto baseColour = detail::LookAndFeelHelpers::createBaseColour (menuBar.findColour (PopupMenu::backgroundColourId), + false, false, false); if (menuBar.isEnabled()) drawShinyButtonShape (g, -4.0f, 0.0f, (float) width + 8.0f, (float) height, @@ -1237,9 +1206,9 @@ void LookAndFeel_V2::drawComboBox (Graphics& g, int width, int height, const boo auto outlineThickness = box.isEnabled() ? (isMouseButtonDown ? 1.2f : 0.5f) : 0.3f; - auto baseColour = LookAndFeelHelpers::createBaseColour (box.findColour (ComboBox::buttonColourId), - box.hasKeyboardFocus (true), - false, isMouseButtonDown) + auto baseColour = detail::LookAndFeelHelpers::createBaseColour (box.findColour (ComboBox::buttonColourId), + box.hasKeyboardFocus (true), + false, isMouseButtonDown) .withMultipliedAlpha (box.isEnabled() ? 1.0f : 0.5f); drawGlassLozenge (g, @@ -1404,10 +1373,10 @@ void LookAndFeel_V2::drawLinearSliderThumb (Graphics& g, int x, int y, int width { auto sliderRadius = (float) (getSliderThumbRadius (slider) - 2); - auto knobColour = LookAndFeelHelpers::createBaseColour (slider.findColour (Slider::thumbColourId), - slider.hasKeyboardFocus (false) && slider.isEnabled(), - slider.isMouseOverOrDragging() && slider.isEnabled(), - slider.isMouseButtonDown() && slider.isEnabled()); + auto knobColour = detail::LookAndFeelHelpers::createBaseColour (slider.findColour (Slider::thumbColourId), + slider.hasKeyboardFocus (false) && slider.isEnabled(), + slider.isMouseOverOrDragging() && slider.isEnabled(), + slider.isMouseButtonDown() && slider.isEnabled()); const float outlineThickness = slider.isEnabled() ? 0.8f : 0.3f; @@ -1496,10 +1465,10 @@ void LookAndFeel_V2::drawLinearSlider (Graphics& g, int x, int y, int width, int { const bool isMouseOver = slider.isMouseOverOrDragging() && slider.isEnabled(); - auto baseColour = LookAndFeelHelpers::createBaseColour (slider.findColour (Slider::thumbColourId) - .withMultipliedSaturation (slider.isEnabled() ? 1.0f : 0.5f), - false, isMouseOver, - isMouseOver || slider.isMouseButtonDown()); + auto baseColour = detail::LookAndFeelHelpers::createBaseColour (slider.findColour (Slider::thumbColourId) + .withMultipliedSaturation (slider.isEnabled() ? 1.0f : 0.5f), + false, isMouseOver, + isMouseOver || slider.isMouseButtonDown()); drawShinyButtonShape (g, (float) x, @@ -1726,7 +1695,7 @@ Slider::SliderLayout LookAndFeel_V2::getSliderLayout (Slider& slider) //============================================================================== Rectangle LookAndFeel_V2::getTooltipBounds (const String& tipText, Point screenPos, Rectangle parentArea) { - const TextLayout tl (LookAndFeelHelpers::layoutTooltipText (tipText, Colours::black)); + const TextLayout tl (detail::LookAndFeelHelpers::layoutTooltipText (tipText, Colours::black)); auto w = (int) (tl.getWidth() + 14.0f); auto h = (int) (tl.getHeight() + 6.0f); @@ -1746,7 +1715,7 @@ void LookAndFeel_V2::drawTooltip (Graphics& g, const String& text, int width, in g.drawRect (0, 0, width, height, 1); #endif - LookAndFeelHelpers::layoutTooltipText (text, findColour (TooltipWindow::textColourId)) + detail::LookAndFeelHelpers::layoutTooltipText (text, findColour (TooltipWindow::textColourId)) .draw (g, Rectangle ((float) width, (float) height)); } diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp index d400073ad6..bbcb196db0 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp @@ -1133,8 +1133,8 @@ void LookAndFeel_V4::drawTooltip (Graphics& g, const String& text, int width, in g.setColour (findColour (TooltipWindow::outlineColourId)); g.drawRoundedRectangle (bounds.toFloat().reduced (0.5f, 0.5f), cornerSize, 1.0f); - LookAndFeelHelpers::layoutTooltipText (text, findColour (TooltipWindow::textColourId)) - .draw (g, { static_cast (width), static_cast (height) }); + detail::LookAndFeelHelpers::layoutTooltipText (text, findColour (TooltipWindow::textColourId)) + .draw (g, { static_cast (width), static_cast (height) }); } //============================================================================== diff --git a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp index 046d889fa2..913f0d8683 100644 --- a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp +++ b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp @@ -797,7 +797,7 @@ struct MenuWindow : public Component bool doesAnyJuceCompHaveFocus() { - if (! isForegroundOrEmbeddedProcess (componentAttachedTo)) + if (! detail::WindowingHelpers::isForegroundOrEmbeddedProcess (componentAttachedTo)) return false; if (Component::getCurrentlyFocusedComponent() != nullptr) diff --git a/modules/juce_gui_basics/misc/juce_DropShadower.cpp b/modules/juce_gui_basics/misc/juce_DropShadower.cpp index 384331d12d..df5a1bb811 100644 --- a/modules/juce_gui_basics/misc/juce_DropShadower.cpp +++ b/modules/juce_gui_basics/misc/juce_DropShadower.cpp @@ -136,7 +136,7 @@ private: if (! component.wasObjectDeleted() && isWindows && component->isOnDesktop()) { startTimerHz (5); - return ! isWindowOnCurrentVirtualDesktop (component->getWindowHandle()); + return ! detail::WindowingHelpers::isWindowOnCurrentVirtualDesktop (component->getWindowHandle()); } stopTimer(); diff --git a/modules/juce_gui_basics/mouse/juce_MouseCursor.cpp b/modules/juce_gui_basics/mouse/juce_MouseCursor.cpp index 0be0e0c4e6..5d5192fbb4 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseCursor.cpp +++ b/modules/juce_gui_basics/mouse/juce_MouseCursor.cpp @@ -75,7 +75,7 @@ public: MouseCursor::StandardCursorType getType() const noexcept { return standardType; } private: - CustomMouseCursorInfo info; + detail::CustomMouseCursorInfo info; PlatformSpecificHandle handle; const MouseCursor::StandardCursorType standardType; const bool standard; diff --git a/modules/juce_gui_basics/mouse/juce_MouseCursor.h b/modules/juce_gui_basics/mouse/juce_MouseCursor.h index 2db3a5dfd0..310e5f6057 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseCursor.h +++ b/modules/juce_gui_basics/mouse/juce_MouseCursor.h @@ -180,7 +180,7 @@ private: class PlatformSpecificHandle; - friend class MouseInputSourceInternal; + friend class detail::MouseInputSourceImpl; void showInWindow (ComponentPeer*) const; PlatformSpecificHandle* getHandle() const noexcept; diff --git a/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp b/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp index 646cdd1932..06d694effa 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp +++ b/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp @@ -26,538 +26,8 @@ namespace juce { -class MouseInputSourceInternal : private AsyncUpdater -{ -public: - MouseInputSourceInternal (int i, MouseInputSource::InputSourceType type) : index (i), inputType (type) - { - } - - //============================================================================== - bool isDragging() const noexcept - { - return buttonState.isAnyMouseButtonDown(); - } - - Component* getComponentUnderMouse() const noexcept - { - return componentUnderMouse.get(); - } - - ModifierKeys getCurrentModifiers() const noexcept - { - return ModifierKeys::currentModifiers.withoutMouseButtons().withFlags (buttonState.getRawFlags()); - } - - ComponentPeer* getPeer() noexcept - { - if (! ComponentPeer::isValidPeer (lastPeer)) - lastPeer = nullptr; - - return lastPeer; - } - - static Component* findComponentAt (Point screenPos, ComponentPeer* peer) - { - if (! ComponentPeer::isValidPeer (peer)) - return nullptr; - - auto relativePos = ScalingHelpers::unscaledScreenPosToScaled (peer->getComponent(), - peer->globalToLocal (screenPos)); - auto& comp = peer->getComponent(); - - // (the contains() call is needed to test for overlapping desktop windows) - if (comp.contains (relativePos)) - return comp.getComponentAt (relativePos); - - return nullptr; - } - - Point getScreenPosition() const noexcept - { - // This needs to return the live position if possible, but it mustn't update the lastScreenPos - // value, because that can cause continuity problems. - return ScalingHelpers::unscaledScreenPosToScaled (getRawScreenPosition()); - } - - Point getRawScreenPosition() const noexcept - { - return unboundedMouseOffset + (inputType != MouseInputSource::InputSourceType::touch ? MouseInputSource::getCurrentRawMousePosition() - : lastPointerState.position); - } - - void setScreenPosition (Point p) - { - MouseInputSource::setRawMousePosition (ScalingHelpers::scaledScreenPosToUnscaled (p)); - } - - //============================================================================== - #if JUCE_DUMP_MOUSE_EVENTS - #define JUCE_MOUSE_EVENT_DBG(desc, screenPos) DBG ("Mouse " << desc << " #" << index \ - << ": " << ScalingHelpers::screenPosToLocalPos (comp, screenPos).toString() \ - << " - Comp: " << String::toHexString ((pointer_sized_int) &comp)); - #else - #define JUCE_MOUSE_EVENT_DBG(desc, screenPos) - #endif - - void sendMouseEnter (Component& comp, const PointerState& pointerState, Time time) - { - JUCE_MOUSE_EVENT_DBG ("enter", pointerState.position) - comp.internalMouseEnter (MouseInputSource (this), ScalingHelpers::screenPosToLocalPos (comp, pointerState.position), time); - } - - void sendMouseExit (Component& comp, const PointerState& pointerState, Time time) - { - JUCE_MOUSE_EVENT_DBG ("exit", pointerState.position) - comp.internalMouseExit (MouseInputSource (this), ScalingHelpers::screenPosToLocalPos (comp, pointerState.position), time); - } - - void sendMouseMove (Component& comp, const PointerState& pointerState, Time time) - { - JUCE_MOUSE_EVENT_DBG ("move", pointerState.position) - comp.internalMouseMove (MouseInputSource (this), ScalingHelpers::screenPosToLocalPos (comp, pointerState.position), time); - } - - void sendMouseDown (Component& comp, const PointerState& pointerState, Time time) - { - JUCE_MOUSE_EVENT_DBG ("down", pointerState.position) - comp.internalMouseDown (MouseInputSource (this), - pointerState.withPosition (ScalingHelpers::screenPosToLocalPos (comp, pointerState.position)), - time); - } - - void sendMouseDrag (Component& comp, const PointerState& pointerState, Time time) - { - JUCE_MOUSE_EVENT_DBG ("drag", pointerState.position) - comp.internalMouseDrag (MouseInputSource (this), - pointerState.withPosition (ScalingHelpers::screenPosToLocalPos (comp, pointerState.position)), - time); - } - - void sendMouseUp (Component& comp, const PointerState& pointerState, Time time, ModifierKeys oldMods) - { - JUCE_MOUSE_EVENT_DBG ("up", pointerState.position) - comp.internalMouseUp (MouseInputSource (this), - pointerState.withPosition (ScalingHelpers::screenPosToLocalPos (comp, pointerState.position)), - time, - oldMods); - } - - void sendMouseWheel (Component& comp, Point screenPos, Time time, const MouseWheelDetails& wheel) - { - JUCE_MOUSE_EVENT_DBG ("wheel", screenPos) - comp.internalMouseWheel (MouseInputSource (this), ScalingHelpers::screenPosToLocalPos (comp, screenPos), time, wheel); - } - - void sendMagnifyGesture (Component& comp, Point screenPos, Time time, float amount) - { - JUCE_MOUSE_EVENT_DBG ("magnify", screenPos) - comp.internalMagnifyGesture (MouseInputSource (this), ScalingHelpers::screenPosToLocalPos (comp, screenPos), time, amount); - } - - //============================================================================== - // (returns true if the button change caused a modal event loop) - bool setButtons (const PointerState& pointerState, Time time, ModifierKeys newButtonState) - { - if (buttonState == newButtonState) - return false; - - // (avoid sending a spurious mouse-drag when we receive a mouse-up) - if (! (isDragging() && ! newButtonState.isAnyMouseButtonDown())) - setPointerState (pointerState, time, false); - - // (ignore secondary clicks when there's already a button down) - if (buttonState.isAnyMouseButtonDown() == newButtonState.isAnyMouseButtonDown()) - { - buttonState = newButtonState; - return false; - } - - auto lastCounter = mouseEventCounter; - - if (buttonState.isAnyMouseButtonDown()) - { - if (auto* current = getComponentUnderMouse()) - { - auto oldMods = getCurrentModifiers(); - buttonState = newButtonState; // must change this before calling sendMouseUp, in case it runs a modal loop - - sendMouseUp (*current, pointerState.withPositionOffset (unboundedMouseOffset), time, oldMods); - - if (lastCounter != mouseEventCounter) - return true; // if a modal loop happened, then newButtonState is no longer valid. - } - - enableUnboundedMouseMovement (false, false); - } - - buttonState = newButtonState; - - if (buttonState.isAnyMouseButtonDown()) - { - Desktop::getInstance().incrementMouseClickCounter(); - - if (auto* current = getComponentUnderMouse()) - { - registerMouseDown (pointerState.position, time, *current, buttonState, - inputType == MouseInputSource::InputSourceType::touch); - sendMouseDown (*current, pointerState, time); - } - } - - return lastCounter != mouseEventCounter; - } - - void setComponentUnderMouse (Component* newComponent, const PointerState& pointerState, Time time) - { - auto* current = getComponentUnderMouse(); - - if (newComponent != current) - { - WeakReference safeNewComp (newComponent); - auto originalButtonState = buttonState; - - if (current != nullptr) - { - WeakReference safeOldComp (current); - setButtons (pointerState, time, ModifierKeys()); - - if (auto oldComp = safeOldComp.get()) - { - componentUnderMouse = safeNewComp; - sendMouseExit (*oldComp, pointerState, time); - } - - buttonState = originalButtonState; - } - - componentUnderMouse = safeNewComp.get(); - current = safeNewComp.get(); - - if (current != nullptr) - sendMouseEnter (*current, pointerState, time); - - revealCursor (false); - setButtons (pointerState, time, originalButtonState); - } - } - - void setPeer (ComponentPeer& newPeer, const PointerState& pointerState, Time time) - { - if (&newPeer != lastPeer && ( findComponentAt (pointerState.position, &newPeer) != nullptr - || findComponentAt (pointerState.position, lastPeer) == nullptr)) - { - setComponentUnderMouse (nullptr, pointerState, time); - lastPeer = &newPeer; - setComponentUnderMouse (findComponentAt (pointerState.position, getPeer()), pointerState, time); - } - } - - void setPointerState (const PointerState& newPointerState, Time time, bool forceUpdate) - { - const auto& newScreenPos = newPointerState.position; - - if (! isDragging()) - setComponentUnderMouse (findComponentAt (newScreenPos, getPeer()), newPointerState, time); - - if ((newPointerState != lastPointerState) || forceUpdate) - { - cancelPendingUpdate(); - - if (newPointerState.position != MouseInputSource::offscreenMousePos) - lastPointerState = newPointerState; - - if (auto* current = getComponentUnderMouse()) - { - if (isDragging()) - { - registerMouseDrag (newScreenPos); - sendMouseDrag (*current, newPointerState.withPositionOffset (unboundedMouseOffset), time); - - if (isUnboundedMouseModeOn) - handleUnboundedDrag (*current); - } - else - { - sendMouseMove (*current, newPointerState, time); - } - } - - revealCursor (false); - } - } - - //============================================================================== - void handleEvent (ComponentPeer& newPeer, Point positionWithinPeer, Time time, - const ModifierKeys newMods, float newPressure, float newOrientation, PenDetails pen) - { - lastTime = time; - ++mouseEventCounter; - const auto pointerState = PointerState().withPosition (newPeer.localToGlobal (positionWithinPeer)) - .withPressure (newPressure) - .withOrientation (newOrientation) - .withRotation (MouseInputSource::defaultRotation) - .withTiltX (pen.tiltX) - .withTiltY (pen.tiltY); - - if (isDragging() && newMods.isAnyMouseButtonDown()) - { - setPointerState (pointerState, time, false); - } - else - { - setPeer (newPeer, pointerState, time); - - if (auto* peer = getPeer()) - { - if (setButtons (pointerState, time, newMods)) - return; // some modal events have been dispatched, so the current event is now out-of-date - - peer = getPeer(); - - if (peer != nullptr) - setPointerState (pointerState, time, false); - } - } - } - - Component* getTargetForGesture (ComponentPeer& peer, Point positionWithinPeer, - Time time, Point& screenPos) - { - lastTime = time; - ++mouseEventCounter; - - screenPos = peer.localToGlobal (positionWithinPeer); - const auto pointerState = lastPointerState.withPosition (screenPos); - setPeer (peer, pointerState, time); - setPointerState (pointerState, time, false); - triggerFakeMove(); - - return getComponentUnderMouse(); - } - - void handleWheel (ComponentPeer& peer, Point positionWithinPeer, - Time time, const MouseWheelDetails& wheel) - { - Desktop::getInstance().incrementMouseWheelCounter(); - Point screenPos; - - // This will make sure that when the wheel spins in its inertial phase, any events - // continue to be sent to the last component that the mouse was over when it was being - // actively controlled by the user. This avoids confusion when scrolling through nested - // scrollable components. - if (lastNonInertialWheelTarget == nullptr || ! wheel.isInertial) - lastNonInertialWheelTarget = getTargetForGesture (peer, positionWithinPeer, time, screenPos); - else - screenPos = peer.localToGlobal (positionWithinPeer); - - if (auto target = lastNonInertialWheelTarget.get()) - sendMouseWheel (*target, screenPos, time, wheel); - } - - void handleMagnifyGesture (ComponentPeer& peer, Point positionWithinPeer, - Time time, const float scaleFactor) - { - Point screenPos; - - if (auto* current = getTargetForGesture (peer, positionWithinPeer, time, screenPos)) - sendMagnifyGesture (*current, screenPos, time, scaleFactor); - } - - //============================================================================== - Time getLastMouseDownTime() const noexcept { return mouseDowns[0].time; } - Point getLastMouseDownPosition() const noexcept { return ScalingHelpers::unscaledScreenPosToScaled (mouseDowns[0].position); } - - int getNumberOfMultipleClicks() const noexcept - { - int numClicks = 1; - - if (! isLongPressOrDrag()) - { - for (int i = 1; i < numElementsInArray (mouseDowns); ++i) - { - if (mouseDowns[0].canBePartOfMultipleClickWith (mouseDowns[i], MouseEvent::getDoubleClickTimeout() * jmin (i, 2))) - ++numClicks; - else - break; - } - } - - return numClicks; - } - - bool isLongPressOrDrag() const noexcept - { - return movedSignificantly || lastTime > mouseDowns[0].time + RelativeTime::milliseconds (300); - } - - bool hasMovedSignificantlySincePressed() const noexcept - { - return movedSignificantly; - } - - // Deprecated method - bool hasMouseMovedSignificantlySincePressed() const noexcept - { - return isLongPressOrDrag(); - } - - //============================================================================== - void triggerFakeMove() - { - triggerAsyncUpdate(); - } - - void handleAsyncUpdate() override - { - setPointerState (lastPointerState, jmax (lastTime, Time::getCurrentTime()), true); - } - - //============================================================================== - void enableUnboundedMouseMovement (bool enable, bool keepCursorVisibleUntilOffscreen) - { - enable = enable && isDragging(); - isCursorVisibleUntilOffscreen = keepCursorVisibleUntilOffscreen; - - if (enable != isUnboundedMouseModeOn) - { - if ((! enable) && ((! isCursorVisibleUntilOffscreen) || ! unboundedMouseOffset.isOrigin())) - { - // when released, return the mouse to within the component's bounds - if (auto* current = getComponentUnderMouse()) - setScreenPosition (current->getScreenBounds().toFloat() - .getConstrainedPoint (ScalingHelpers::unscaledScreenPosToScaled (lastPointerState.position))); - } - - isUnboundedMouseModeOn = enable; - unboundedMouseOffset = {}; - - revealCursor (true); - } - } - - void handleUnboundedDrag (Component& current) - { - auto componentScreenBounds = ScalingHelpers::scaledScreenPosToUnscaled (current.getParentMonitorArea().reduced (2, 2).toFloat()); - - if (! componentScreenBounds.contains (lastPointerState.position)) - { - auto componentCentre = current.getScreenBounds().toFloat().getCentre(); - unboundedMouseOffset += (lastPointerState.position - ScalingHelpers::scaledScreenPosToUnscaled (componentCentre)); - setScreenPosition (componentCentre); - } - else if (isCursorVisibleUntilOffscreen - && (! unboundedMouseOffset.isOrigin()) - && componentScreenBounds.contains (lastPointerState.position + unboundedMouseOffset)) - { - MouseInputSource::setRawMousePosition (lastPointerState.position + unboundedMouseOffset); - unboundedMouseOffset = {}; - } - } - - //============================================================================== - void showMouseCursor (MouseCursor cursor, bool forcedUpdate) - { - if (isUnboundedMouseModeOn && ((! unboundedMouseOffset.isOrigin()) || ! isCursorVisibleUntilOffscreen)) - { - cursor = MouseCursor::NoCursor; - forcedUpdate = true; - } - - if (forcedUpdate || cursor.getHandle() != currentCursorHandle) - { - currentCursorHandle = cursor.getHandle(); - cursor.showInWindow (getPeer()); - } - } - - void hideCursor() - { - showMouseCursor (MouseCursor::NoCursor, true); - } - - void revealCursor (bool forcedUpdate) - { - MouseCursor mc (MouseCursor::NormalCursor); - - if (auto* current = getComponentUnderMouse()) - mc = current->getLookAndFeel().getMouseCursorFor (*current); - - showMouseCursor (mc, forcedUpdate); - } - - //============================================================================== - const int index; - const MouseInputSource::InputSourceType inputType; - Point unboundedMouseOffset; // NB: these are unscaled coords - PointerState lastPointerState; - ModifierKeys buttonState; - - bool isUnboundedMouseModeOn = false, isCursorVisibleUntilOffscreen = false; - -private: - WeakReference componentUnderMouse, lastNonInertialWheelTarget; - ComponentPeer* lastPeer = nullptr; - - void* currentCursorHandle = nullptr; - int mouseEventCounter = 0; - - struct RecentMouseDown - { - RecentMouseDown() = default; - - Point position; - Time time; - ModifierKeys buttons; - uint32 peerID = 0; - bool isTouch = false; - - bool canBePartOfMultipleClickWith (const RecentMouseDown& other, int maxTimeBetweenMs) const noexcept - { - return time - other.time < RelativeTime::milliseconds (maxTimeBetweenMs) - && std::abs (position.x - other.position.x) < (float) getPositionToleranceForInputType() - && std::abs (position.y - other.position.y) < (float) getPositionToleranceForInputType() - && buttons == other.buttons - && peerID == other.peerID; - } - - int getPositionToleranceForInputType() const noexcept { return isTouch ? 25 : 8; } - }; - - RecentMouseDown mouseDowns[4]; - Time lastTime; - bool movedSignificantly = false; - - void registerMouseDown (Point screenPos, Time time, Component& component, - const ModifierKeys modifiers, bool isTouchSource) noexcept - { - for (int i = numElementsInArray (mouseDowns); --i > 0;) - mouseDowns[i] = mouseDowns[i - 1]; - - mouseDowns[0].position = screenPos; - mouseDowns[0].time = time; - mouseDowns[0].buttons = modifiers.withOnlyMouseButtons(); - mouseDowns[0].isTouch = isTouchSource; - - if (auto* peer = component.getPeer()) - mouseDowns[0].peerID = peer->getUniqueID(); - else - mouseDowns[0].peerID = 0; - - movedSignificantly = false; - lastNonInertialWheelTarget = nullptr; - } - - void registerMouseDrag (Point screenPos) noexcept - { - movedSignificantly = movedSignificantly || mouseDowns[0].position.getDistanceFrom (screenPos) >= 4; - } - - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MouseInputSourceInternal) -}; - //============================================================================== -MouseInputSource::MouseInputSource (MouseInputSourceInternal* s) noexcept : pimpl (s) {} +MouseInputSource::MouseInputSource (detail::MouseInputSourceImpl* s) noexcept : pimpl (s) {} MouseInputSource::MouseInputSource (const MouseInputSource& other) noexcept : pimpl (other.pimpl) {} MouseInputSource::~MouseInputSource() noexcept {} @@ -632,127 +102,4 @@ const Point MouseInputSource::offscreenMousePos { -10.0f, -10.0f }; // Deprecated method bool MouseInputSource::hasMouseMovedSignificantlySincePressed() const noexcept { return pimpl->hasMouseMovedSignificantlySincePressed(); } -//============================================================================== -struct MouseInputSource::SourceList : public Timer -{ - SourceList() - { - #if JUCE_ANDROID || JUCE_IOS - auto mainMouseInputType = MouseInputSource::InputSourceType::touch; - #else - auto mainMouseInputType = MouseInputSource::InputSourceType::mouse; - #endif - - addSource (0, mainMouseInputType); - } - - bool addSource(); - bool canUseTouch(); - - MouseInputSource* addSource (int index, MouseInputSource::InputSourceType type) - { - auto* s = new MouseInputSourceInternal (index, type); - sources.add (s); - sourceArray.add (MouseInputSource (s)); - - return &sourceArray.getReference (sourceArray.size() - 1); - } - - MouseInputSource* getMouseSource (int index) noexcept - { - return isPositiveAndBelow (index, sourceArray.size()) ? &sourceArray.getReference (index) - : nullptr; - } - - MouseInputSource* getOrCreateMouseInputSource (MouseInputSource::InputSourceType type, int touchIndex = 0) - { - if (type == MouseInputSource::InputSourceType::mouse || type == MouseInputSource::InputSourceType::pen) - { - for (auto& m : sourceArray) - if (type == m.getType()) - return &m; - - addSource (0, type); - } - else if (type == MouseInputSource::InputSourceType::touch) - { - jassert (0 <= touchIndex && touchIndex < 100); // sanity-check on number of fingers - - for (auto& m : sourceArray) - if (type == m.getType() && touchIndex == m.getIndex()) - return &m; - - if (canUseTouch()) - return addSource (touchIndex, type); - } - - return nullptr; - } - - int getNumDraggingMouseSources() const noexcept - { - int num = 0; - - for (auto* s : sources) - if (s->isDragging()) - ++num; - - return num; - } - - MouseInputSource* getDraggingMouseSource (int index) noexcept - { - int num = 0; - - for (auto& s : sourceArray) - { - if (s.isDragging()) - { - if (index == num) - return &s; - - ++num; - } - } - - return nullptr; - } - - void beginDragAutoRepeat (int interval) - { - if (interval > 0) - { - if (getTimerInterval() != interval) - startTimer (interval); - } - else - { - stopTimer(); - } - } - - void timerCallback() override - { - bool anyDragging = false; - - for (auto* s : sources) - { - // NB: when doing auto-repeat, we need to force an update of the current position and button state, - // because on some OSes the queue can get overloaded with messages so that mouse-events don't get through.. - if (s->isDragging() && ComponentPeer::getCurrentModifiersRealtime().isAnyMouseButtonDown()) - { - s->lastPointerState.position = s->getRawScreenPosition(); - s->triggerFakeMove(); - anyDragging = true; - } - } - - if (! anyDragging) - stopTimer(); - } - - OwnedArray sources; - Array sourceArray; -}; - } // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_MouseInputSource.h b/modules/juce_gui_basics/mouse/juce_MouseInputSource.h index 945295b040..55ae44d408 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseInputSource.h +++ b/modules/juce_gui_basics/mouse/juce_MouseInputSource.h @@ -288,12 +288,11 @@ private: //============================================================================== friend class ComponentPeer; friend class Desktop; - friend class MouseInputSourceInternal; - MouseInputSourceInternal* pimpl; + friend class detail::MouseInputSourceList; + friend class detail::MouseInputSourceImpl; + detail::MouseInputSourceImpl* pimpl; - struct SourceList; - - explicit MouseInputSource (MouseInputSourceInternal*) noexcept; + explicit MouseInputSource (detail::MouseInputSourceImpl*) noexcept; void handleEvent (ComponentPeer&, Point, int64 time, ModifierKeys, float, float, const PenDetails&); void handleWheel (ComponentPeer&, Point, int64 time, const MouseWheelDetails&); void handleMagnifyGesture (ComponentPeer&, Point, int64 time, float scaleFactor); diff --git a/modules/juce_gui_basics/native/accessibility/juce_Accessibility.cpp b/modules/juce_gui_basics/native/accessibility/juce_Accessibility.cpp new file mode 100644 index 0000000000..19499c9495 --- /dev/null +++ b/modules/juce_gui_basics/native/accessibility/juce_Accessibility.cpp @@ -0,0 +1,33 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + By using JUCE, you agree to the terms of both the JUCE 7 End-User License + Agreement and JUCE Privacy Policy. + + End User License Agreement: www.juce.com/juce-7-licence + Privacy Policy: www.juce.com/juce-privacy-policy + + Or: You may also use this code under the terms of the GPL v3 (see + www.gnu.org/licenses). + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce +{ + +#if ! JUCE_NATIVE_ACCESSIBILITY_INCLUDED + class AccessibilityHandler::AccessibilityNativeImpl { public: AccessibilityNativeImpl (AccessibilityHandler&) {} }; +#endif + +} // namespace juce diff --git a/modules/juce_gui_basics/native/accessibility/juce_android_Accessibility.cpp b/modules/juce_gui_basics/native/accessibility/juce_android_Accessibility.cpp index 324cd48856..7c7029a2b1 100644 --- a/modules/juce_gui_basics/native/accessibility/juce_android_Accessibility.cpp +++ b/modules/juce_gui_basics/native/accessibility/juce_android_Accessibility.cpp @@ -142,18 +142,6 @@ static jmethodID nodeInfoSetTextSelection = nullptr; static jmethodID nodeInfoSetLiveRegion = nullptr; static jmethodID accessibilityEventSetContentChangeTypes = nullptr; -template -static AccessibilityHandler* getEnclosingHandlerWithInterface (AccessibilityHandler* handler, MemberFn fn) -{ - if (handler == nullptr) - return nullptr; - - if ((handler->*fn)() != nullptr) - return handler; - - return getEnclosingHandlerWithInterface (handler->getParent(), fn); -} - static void loadSDKDependentMethods() { static bool hasChecked = false; @@ -235,6 +223,24 @@ static jobject getSourceView (const AccessibilityHandler& handler) return nullptr; } +static jobject makeAndroidRect (Rectangle r) +{ + return getEnv()->NewObject (AndroidRect, + AndroidRect.constructor, + r.getX(), + r.getY(), + r.getRight(), + r.getBottom()); +} + +static jobject makeAndroidPoint (Point p) +{ + return getEnv()->NewObject (AndroidPoint, + AndroidPoint.create, + p.getX(), + p.getY()); +} + //============================================================================== class AccessibilityNativeHandle { @@ -477,7 +483,7 @@ public: env->CallVoidMethod (info, AndroidAccessibilityNodeInfo19.setCollectionInfo, collectionInfo.get()); } - if (auto* enclosingTableHandler = getEnclosingHandlerWithInterface (&accessibilityHandler, &AccessibilityHandler::getTableInterface)) + if (auto* enclosingTableHandler = detail::AccessibilityHelpers::getEnclosingHandlerWithInterface (&accessibilityHandler, &AccessibilityHandler::getTableInterface)) { auto* interface = enclosingTableHandler->getTableInterface(); jassert (interface != nullptr); @@ -926,12 +932,12 @@ AccessibilityNativeHandle* AccessibilityHandler::getNativeImplementation() const return nativeImpl.get(); } -void notifyAccessibilityEventInternal (const AccessibilityHandler& handler, - InternalAccessibilityEvent eventType) +void detail::AccessibilityHelpers::notifyAccessibilityEvent (const AccessibilityHandler& handler, + Event eventType) { - if (eventType == InternalAccessibilityEvent::elementCreated - || eventType == InternalAccessibilityEvent::elementDestroyed - || eventType == InternalAccessibilityEvent::elementMovedOrResized) + if (eventType == Event::elementCreated + || eventType == Event::elementDestroyed + || eventType == Event::elementMovedOrResized) { if (auto* parent = handler.getParent()) AccessibilityNativeHandle::sendAccessibilityEventImpl (*parent, TYPE_WINDOW_CONTENT_CHANGED, CONTENT_CHANGE_TYPE_SUBTREE); @@ -943,15 +949,15 @@ void notifyAccessibilityEventInternal (const AccessibilityHandler& handler, { switch (eventType) { - case InternalAccessibilityEvent::focusChanged: + case Event::focusChanged: return handler.hasFocus (false) ? TYPE_VIEW_ACCESSIBILITY_FOCUSED : TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED; - case InternalAccessibilityEvent::elementCreated: - case InternalAccessibilityEvent::elementDestroyed: - case InternalAccessibilityEvent::elementMovedOrResized: - case InternalAccessibilityEvent::windowOpened: - case InternalAccessibilityEvent::windowClosed: + case Event::elementCreated: + case Event::elementDestroyed: + case Event::elementMovedOrResized: + case Event::windowOpened: + case Event::windowClosed: break; } diff --git a/modules/juce_gui_basics/native/accessibility/juce_ios_Accessibility.mm b/modules/juce_gui_basics/native/accessibility/juce_ios_Accessibility.mm index beddd314cc..38dda05858 100644 --- a/modules/juce_gui_basics/native/accessibility/juce_ios_Accessibility.mm +++ b/modules/juce_gui_basics/native/accessibility/juce_ios_Accessibility.mm @@ -123,7 +123,7 @@ private: { addMethod (@selector (accessibilityDataTableCellElementForRow:column:), [] (id self, SEL, NSUInteger row, NSUInteger column) -> id { - if (auto* tableHandler = getEnclosingHandlerWithInterface (getHandler (self), &AccessibilityHandler::getTableInterface)) + if (auto* tableHandler = detail::AccessibilityHelpers::getEnclosingHandlerWithInterface (getHandler (self), &AccessibilityHandler::getTableInterface)) if (auto* tableInterface = tableHandler->getTableInterface()) if (auto* cellHandler = tableInterface->getCellHandler ((int) row, (int) column)) if (auto* parent = getAccessibleParent (cellHandler)) @@ -137,7 +137,7 @@ private: addMethod (@selector (accessibilityHeaderElementsForColumn:), [] (id self, SEL, NSUInteger column) -> NSArray* { - if (auto* tableHandler = getEnclosingHandlerWithInterface (getHandler (self), &AccessibilityHandler::getTableInterface)) + if (auto* tableHandler = detail::AccessibilityHelpers::getEnclosingHandlerWithInterface (getHandler (self), &AccessibilityHandler::getTableInterface)) { if (auto* tableInterface = tableHandler->getTableInterface()) { @@ -245,7 +245,7 @@ private: { const auto isTableCell = [&] { - if (auto* tableHandler = getEnclosingHandlerWithInterface (&handlerRef, &AccessibilityHandler::getTableInterface)) + if (auto* tableHandler = detail::AccessibilityHelpers::getEnclosingHandlerWithInterface (&handlerRef, &AccessibilityHandler::getTableInterface)) { if (auto* tableInterface = tableHandler->getTableInterface()) { @@ -619,19 +619,19 @@ static void sendAccessibilityEvent (UIAccessibilityNotifications notification, i UIAccessibilityPostNotification (notification, argument); } -void notifyAccessibilityEventInternal (const AccessibilityHandler& handler, InternalAccessibilityEvent eventType) +void detail::AccessibilityHelpers::notifyAccessibilityEvent (const AccessibilityHandler& handler, Event eventType) { auto notification = [eventType] { switch (eventType) { - case InternalAccessibilityEvent::elementCreated: - case InternalAccessibilityEvent::elementDestroyed: - case InternalAccessibilityEvent::elementMovedOrResized: - case InternalAccessibilityEvent::focusChanged: return UIAccessibilityLayoutChangedNotification; + case Event::elementCreated: + case Event::elementDestroyed: + case Event::elementMovedOrResized: + case Event::focusChanged: return UIAccessibilityLayoutChangedNotification; - case InternalAccessibilityEvent::windowOpened: - case InternalAccessibilityEvent::windowClosed: return UIAccessibilityScreenChangedNotification; + case Event::windowOpened: + case Event::windowClosed: return UIAccessibilityScreenChangedNotification; } return UIAccessibilityNotifications{}; @@ -639,7 +639,7 @@ void notifyAccessibilityEventInternal (const AccessibilityHandler& handler, Inte if (notification != UIAccessibilityNotifications{}) { - const bool moveToHandler = (eventType == InternalAccessibilityEvent::focusChanged && handler.hasFocus (false)); + const bool moveToHandler = (eventType == Event::focusChanged && handler.hasFocus (false)); sendAccessibilityEvent (notification, moveToHandler ? static_cast (handler.getNativeImplementation()) : nil); diff --git a/modules/juce_gui_basics/native/accessibility/juce_mac_Accessibility.mm b/modules/juce_gui_basics/native/accessibility/juce_mac_Accessibility.mm index d7d62d9431..93d7f47584 100644 --- a/modules/juce_gui_basics/native/accessibility/juce_mac_Accessibility.mm +++ b/modules/juce_gui_basics/native/accessibility/juce_mac_Accessibility.mm @@ -499,7 +499,7 @@ private: { if (auto* handler = getHandler (self)) { - if (auto* tableHandler = getEnclosingHandlerWithInterface (handler, &AccessibilityHandler::getTableInterface)) + if (auto* tableHandler = detail::AccessibilityHelpers::getEnclosingHandlerWithInterface (handler, &AccessibilityHandler::getTableInterface)) { if (auto* tableInterface = tableHandler->getTableInterface()) { @@ -863,18 +863,18 @@ static NSAccessibilityNotificationName layoutChangedNotification() return layoutChangedString; } -void notifyAccessibilityEventInternal (const AccessibilityHandler& handler, InternalAccessibilityEvent eventType) +void detail::AccessibilityHelpers::notifyAccessibilityEvent (const AccessibilityHandler& handler, Event eventType) { auto notification = [eventType] { switch (eventType) { - case InternalAccessibilityEvent::elementCreated: return NSAccessibilityCreatedNotification; - case InternalAccessibilityEvent::elementDestroyed: return NSAccessibilityUIElementDestroyedNotification; - case InternalAccessibilityEvent::elementMovedOrResized: return layoutChangedNotification(); - case InternalAccessibilityEvent::focusChanged: return NSAccessibilityFocusedUIElementChangedNotification; - case InternalAccessibilityEvent::windowOpened: return NSAccessibilityWindowCreatedNotification; - case InternalAccessibilityEvent::windowClosed: break; + case Event::elementCreated: return NSAccessibilityCreatedNotification; + case Event::elementDestroyed: return NSAccessibilityUIElementDestroyedNotification; + case Event::elementMovedOrResized: return layoutChangedNotification(); + case Event::focusChanged: return NSAccessibilityFocusedUIElementChangedNotification; + case Event::windowOpened: return NSAccessibilityWindowCreatedNotification; + case Event::windowClosed: break; } return NSAccessibilityNotificationName{}; diff --git a/modules/juce_gui_basics/native/accessibility/juce_mac_AccessibilitySharedCode.mm b/modules/juce_gui_basics/native/accessibility/juce_mac_AccessibilitySharedCode.mm index f487d894c7..456e3afe94 100644 --- a/modules/juce_gui_basics/native/accessibility/juce_mac_AccessibilitySharedCode.mm +++ b/modules/juce_gui_basics/native/accessibility/juce_mac_AccessibilitySharedCode.mm @@ -183,7 +183,7 @@ protected: auto title = handler->getTitle(); if (title.isEmpty() && handler->getComponent().isOnDesktop()) - title = getAccessibleApplicationOrPluginName(); + title = detail::AccessibilityHelpers::getApplicationOrPluginName(); NSString* nsString = juceStringToNS (title); @@ -214,7 +214,7 @@ protected: static NSInteger getAccessibilityRowCount (id self, SEL) { - if (auto* tableHandler = getEnclosingHandlerWithInterface (getHandler (self), &AccessibilityHandler::getTableInterface)) + if (auto* tableHandler = detail::AccessibilityHelpers::getEnclosingHandlerWithInterface (getHandler (self), &AccessibilityHandler::getTableInterface)) if (auto* tableInterface = tableHandler->getTableInterface()) return tableInterface->getNumRows(); @@ -223,7 +223,7 @@ protected: static NSInteger getAccessibilityColumnCount (id self, SEL) { - if (auto* tableHandler = getEnclosingHandlerWithInterface (getHandler (self), &AccessibilityHandler::getTableInterface)) + if (auto* tableHandler = detail::AccessibilityHelpers::getEnclosingHandlerWithInterface (getHandler (self), &AccessibilityHandler::getTableInterface)) if (auto* tableInterface = tableHandler->getTableInterface()) return tableInterface->getNumColumns(); @@ -240,7 +240,7 @@ protected: if (handler == nullptr) return notFound; - auto* tableHandler = getEnclosingHandlerWithInterface (getHandler (self), &AccessibilityHandler::getTableInterface); + auto* tableHandler = detail::AccessibilityHelpers::getEnclosingHandlerWithInterface (getHandler (self), &AccessibilityHandler::getTableInterface); if (tableHandler == nullptr) return notFound; @@ -271,4 +271,4 @@ protected: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AccessibleObjCClass) }; -} +} // namespace juce diff --git a/modules/juce_gui_basics/native/accessibility/juce_win32_Accessibility.cpp b/modules/juce_gui_basics/native/accessibility/juce_win32_Accessibility.cpp index 01d383c03d..6974d4bf17 100644 --- a/modules/juce_gui_basics/native/accessibility/juce_win32_Accessibility.cpp +++ b/modules/juce_gui_basics/native/accessibility/juce_win32_Accessibility.cpp @@ -153,12 +153,12 @@ void sendAccessibilityPropertyChangedEvent (const AccessibilityHandler& handler, }); } -void notifyAccessibilityEventInternal (const AccessibilityHandler& handler, InternalAccessibilityEvent eventType) +void detail::AccessibilityHelpers::notifyAccessibilityEvent (const AccessibilityHandler& handler, Event eventType) { using namespace ComTypes::Constants; - if (eventType == InternalAccessibilityEvent::elementCreated - || eventType == InternalAccessibilityEvent::elementDestroyed) + if (eventType == Event::elementCreated + || eventType == Event::elementDestroyed) { if (auto* parent = handler.getParent()) sendAccessibilityAutomationEvent (*parent, UIA_LayoutInvalidatedEventId); @@ -166,8 +166,8 @@ void notifyAccessibilityEventInternal (const AccessibilityHandler& handler, Inte return; } - if (eventType == InternalAccessibilityEvent::windowOpened - || eventType == InternalAccessibilityEvent::windowClosed) + if (eventType == Event::windowOpened + || eventType == Event::windowClosed) { if (auto* peer = handler.getComponent().getPeer()) if ((peer->getStyleFlags() & ComponentPeer::windowHasTitleBar) == 0) @@ -178,12 +178,12 @@ void notifyAccessibilityEventInternal (const AccessibilityHandler& handler, Inte { switch (eventType) { - case InternalAccessibilityEvent::focusChanged: return UIA_AutomationFocusChangedEventId; - case InternalAccessibilityEvent::windowOpened: return UIA_Window_WindowOpenedEventId; - case InternalAccessibilityEvent::windowClosed: return UIA_Window_WindowClosedEventId; - case InternalAccessibilityEvent::elementCreated: - case InternalAccessibilityEvent::elementDestroyed: - case InternalAccessibilityEvent::elementMovedOrResized: break; + case Event::focusChanged: return UIA_AutomationFocusChangedEventId; + case Event::windowOpened: return UIA_Window_WindowOpenedEventId; + case Event::windowClosed: return UIA_Window_WindowClosedEventId; + case Event::elementCreated: + case Event::elementDestroyed: + case Event::elementMovedOrResized: break; } return {}; diff --git a/modules/juce_gui_basics/native/accessibility/juce_win32_AccessibilityElement.cpp b/modules/juce_gui_basics/native/accessibility/juce_win32_AccessibilityElement.cpp index 8b13c317db..014afa4c54 100644 --- a/modules/juce_gui_basics/native/accessibility/juce_win32_AccessibilityElement.cpp +++ b/modules/juce_gui_basics/native/accessibility/juce_win32_AccessibilityElement.cpp @@ -58,7 +58,7 @@ public: JUCE_COMCALL ScrollIntoView() override { - if (auto* handler = getEnclosingHandlerWithInterface (&getHandler(), &AccessibilityHandler::getTableInterface)) + if (auto* handler = detail::AccessibilityHelpers::getEnclosingHandlerWithInterface (&getHandler(), &AccessibilityHandler::getTableInterface)) { if (auto* tableInterface = handler->getTableInterface()) { @@ -194,7 +194,7 @@ JUCE_COMRESULT AccessibilityNativeHandle::GetPatternProvider (PATTERNID pId, IUn const auto isListOrTableCell = [] (auto& handler) { - if (auto* tableHandler = getEnclosingHandlerWithInterface (&handler, &AccessibilityHandler::getTableInterface)) + if (auto* tableHandler = detail::AccessibilityHelpers::getEnclosingHandlerWithInterface (&handler, &AccessibilityHandler::getTableInterface)) { if (auto* tableInterface = tableHandler->getTableInterface()) { @@ -627,7 +627,7 @@ String AccessibilityNativeHandle::getElementName() const auto name = accessibilityHandler.getTitle(); if (name.isEmpty() && isFragmentRoot()) - return getAccessibleApplicationOrPluginName(); + return detail::AccessibilityHelpers::getApplicationOrPluginName(); return name; } diff --git a/modules/juce_gui_basics/native/accessibility/juce_win32_UIAGridItemProvider.h b/modules/juce_gui_basics/native/accessibility/juce_win32_UIAGridItemProvider.h index 494dfeb26c..8e603e7a68 100644 --- a/modules/juce_gui_basics/native/accessibility/juce_win32_UIAGridItemProvider.h +++ b/modules/juce_gui_basics/native/accessibility/juce_win32_UIAGridItemProvider.h @@ -122,7 +122,7 @@ private: { return withCheckedComArgs (pRetVal, *this, [&]() -> HRESULT { - if (auto* handler = getEnclosingHandlerWithInterface (&getHandler(), &AccessibilityHandler::getTableInterface)) + if (auto* handler = detail::AccessibilityHelpers::getEnclosingHandlerWithInterface (&getHandler(), &AccessibilityHandler::getTableInterface)) if (handler->getTableInterface() != nullptr && callback (*handler)) return S_OK; diff --git a/modules/juce_gui_basics/native/accessibility/juce_win32_UIAGridProvider.h b/modules/juce_gui_basics/native/accessibility/juce_win32_UIAGridProvider.h index ef17dd5ecf..8848b9ab9c 100644 --- a/modules/juce_gui_basics/native/accessibility/juce_win32_UIAGridProvider.h +++ b/modules/juce_gui_basics/native/accessibility/juce_win32_UIAGridProvider.h @@ -136,7 +136,7 @@ private: { return withCheckedComArgs (pRetVal, *this, [&]() -> HRESULT { - if (auto* tableHandler = getEnclosingHandlerWithInterface (&getHandler(), &AccessibilityHandler::getTableInterface)) + if (auto* tableHandler = detail::AccessibilityHelpers::getEnclosingHandlerWithInterface (&getHandler(), &AccessibilityHandler::getTableInterface)) if (auto* tableInterface = tableHandler->getTableInterface()) return callback (*tableInterface); diff --git a/modules/juce_gui_basics/native/accessibility/juce_win32_UIAProviders.h b/modules/juce_gui_basics/native/accessibility/juce_win32_UIAProviders.h index 06bede9d93..9ad14e419e 100644 --- a/modules/juce_gui_basics/native/accessibility/juce_win32_UIAProviders.h +++ b/modules/juce_gui_basics/native/accessibility/juce_win32_UIAProviders.h @@ -27,7 +27,7 @@ namespace juce { void sendAccessibilityAutomationEvent (const AccessibilityHandler&, EVENTID); void sendAccessibilityPropertyChangedEvent (const AccessibilityHandler&, PROPERTYID, VARIANT); -} +} // namespace juce #include "juce_win32_UIAProviderBase.h" #include "juce_win32_UIAExpandCollapseProvider.h" diff --git a/modules/juce_gui_basics/native/juce_ScopedDPIAwarenessDisabler.cpp b/modules/juce_gui_basics/native/juce_ScopedDPIAwarenessDisabler.cpp new file mode 100644 index 0000000000..c6ef5a5320 --- /dev/null +++ b/modules/juce_gui_basics/native/juce_ScopedDPIAwarenessDisabler.cpp @@ -0,0 +1,34 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2022 - Raw Material Software Limited + + JUCE is an open source library subject to commercial or open-source + licensing. + + By using JUCE, you agree to the terms of both the JUCE 7 End-User License + Agreement and JUCE Privacy Policy. + + End User License Agreement: www.juce.com/juce-7-licence + Privacy Policy: www.juce.com/juce-privacy-policy + + Or: You may also use this code under the terms of the GPL v3 (see + www.gnu.org/licenses). + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce +{ + +#if ! JUCE_WINDOWS + ScopedDPIAwarenessDisabler::ScopedDPIAwarenessDisabler() { ignoreUnused (previousContext); } + ScopedDPIAwarenessDisabler::~ScopedDPIAwarenessDisabler() {} +#endif + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_android_NativeMessageBox.cpp b/modules/juce_gui_basics/native/juce_android_NativeMessageBox.cpp index fc428aa344..d981ca8e23 100644 --- a/modules/juce_gui_basics/native/juce_android_NativeMessageBox.cpp +++ b/modules/juce_gui_basics/native/juce_android_NativeMessageBox.cpp @@ -23,7 +23,7 @@ ============================================================================== */ -namespace juce +namespace juce::detail { std::unique_ptr ScopedMessageBoxInterface::create (const MessageBoxOptions& options) @@ -112,4 +112,4 @@ std::unique_ptr ScopedMessageBoxInterface::create (co return std::make_unique (options); } -} // namespace juce +} // namespace juce::detail diff --git a/modules/juce_gui_basics/native/juce_android_Windowing.cpp b/modules/juce_gui_basics/native/juce_android_Windowing.cpp index fbb2c74af6..cd48e76429 100644 --- a/modules/juce_gui_basics/native/juce_android_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_android_Windowing.cpp @@ -2264,13 +2264,13 @@ Desktop::DisplayOrientation Desktop::getCurrentOrientation() const return upright; } -bool MouseInputSource::SourceList::addSource() +bool detail::MouseInputSourceList::addSource() { addSource (sources.size(), MouseInputSource::InputSourceType::touch); return true; } -bool MouseInputSource::SourceList::canUseTouch() +bool detail::MouseInputSourceList::canUseTouch() const { return true; } @@ -2446,7 +2446,7 @@ void Desktop::allowedOrientationsChanged() } //============================================================================== -bool juce_areThereAnyAlwaysOnTopWindows() +bool detail::WindowingHelpers::areThereAnyAlwaysOnTopWindows() { return false; } @@ -2621,9 +2621,9 @@ void Displays::findDisplays (float masterScale) } //============================================================================== -Image juce_createIconForFile (const File& /*file*/) +Image detail::WindowingHelpers::createIconForFile (const File& /*file*/) { - return Image(); + return {}; } //============================================================================== @@ -2631,7 +2631,7 @@ class MouseCursor::PlatformSpecificHandle { public: PlatformSpecificHandle (const MouseCursor::StandardCursorType) {} - PlatformSpecificHandle (const CustomMouseCursorInfo&) {} + PlatformSpecificHandle (const detail::CustomMouseCursorInfo&) {} static void showInWindow (PlatformSpecificHandle*, ComponentPeer*) {} }; diff --git a/modules/juce_gui_basics/native/juce_ios_NativeMessageBox.mm b/modules/juce_gui_basics/native/juce_ios_NativeMessageBox.mm index 17a1a8bfe8..37d0c1c5e1 100644 --- a/modules/juce_gui_basics/native/juce_ios_NativeMessageBox.mm +++ b/modules/juce_gui_basics/native/juce_ios_NativeMessageBox.mm @@ -23,7 +23,7 @@ ============================================================================== */ -namespace juce +namespace juce::detail { std::unique_ptr ScopedMessageBoxInterface::create (const MessageBoxOptions& options) @@ -107,4 +107,4 @@ std::unique_ptr ScopedMessageBoxInterface::create (co return std::make_unique (options); } -} // namespace juce +} // namespace juce::detail diff --git a/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm index be3e8a6ee5..c2fa37f45d 100644 --- a/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm @@ -1317,7 +1317,7 @@ static bool doKeysUp (UIViewComponentPeer* owner, NSSet* presses, UIPr if (auto* comp = dynamic_cast (target)) { const auto areaOnDesktop = comp->localAreaToGlobal (target->getCaretRectangle()); - return convertToCGRect (ScalingHelpers::scaledScreenPosToUnscaled (areaOnDesktop)); + return convertToCGRect (detail::ScalingHelpers::scaledScreenPosToUnscaled (areaOnDesktop)); } } @@ -1337,7 +1337,7 @@ static bool doKeysUp (UIViewComponentPeer* owner, NSSet* presses, UIPr { if (auto* comp = dynamic_cast (target)) { - const auto pointOnDesktop = ScalingHelpers::unscaledScreenPosToScaled (convertToPointFloat (point)); + const auto pointOnDesktop = detail::ScalingHelpers::unscaledScreenPosToScaled (convertToPointFloat (point)); return target->getCharIndexForPoint (comp->getLocalPoint (nullptr, pointOnDesktop).roundToInt()); } } @@ -1464,7 +1464,7 @@ static bool doKeysUp (UIViewComponentPeer* owner, NSSet* presses, UIPr if (! list.isEmpty()) { const auto areaOnDesktop = comp->localAreaToGlobal (list.getRectangle (0)); - return convertToCGRect (ScalingHelpers::scaledScreenPosToUnscaled (areaOnDesktop)); + return convertToCGRect (detail::ScalingHelpers::scaledScreenPosToUnscaled (areaOnDesktop)); } } } @@ -1485,7 +1485,7 @@ static bool doKeysUp (UIViewComponentPeer* owner, NSSet* presses, UIPr for (const auto& rect : list) { const auto areaOnDesktop = comp->localAreaToGlobal (rect); - const auto nativeArea = convertToCGRect (ScalingHelpers::scaledScreenPosToUnscaled (areaOnDesktop)); + const auto nativeArea = convertToCGRect (detail::ScalingHelpers::scaledScreenPosToUnscaled (areaOnDesktop)); [result addObject: [JuceUITextSelectionRect withRect: nativeArea]]; } @@ -1812,7 +1812,7 @@ void UIViewComponentPeer::setFullScreen (bool shouldBeFullScreen) // (can't call the component's setBounds method because that'll reset our fullscreen flag) if (! r.isEmpty()) - setBounds (ScalingHelpers::scaledScreenPosToUnscaled (component, r), shouldBeFullScreen); + setBounds (detail::ScalingHelpers::scaledScreenPosToUnscaled (component, r), shouldBeFullScreen); component.repaint(); } @@ -1855,7 +1855,7 @@ void UIViewComponentPeer::updateScreenBounds() bool UIViewComponentPeer::contains (Point localPos, bool trueIfInAChildWindow) const { - if (! ScalingHelpers::scaledScreenPosToUnscaled (component, component.getLocalBounds()).contains (localPos)) + if (! detail::ScalingHelpers::scaledScreenPosToUnscaled (component, component.getLocalBounds()).contains (localPos)) return false; UIView* v = [view hitTest: convertToCGPoint (localPos) diff --git a/modules/juce_gui_basics/native/juce_ios_Windowing.mm b/modules/juce_gui_basics/native/juce_ios_Windowing.mm index c940bcbe7a..2fe0069dfa 100644 --- a/modules/juce_gui_basics/native/juce_ios_Windowing.mm +++ b/modules/juce_gui_basics/native/juce_ios_Windowing.mm @@ -35,7 +35,7 @@ namespace juce // This is an internal list of callbacks (but currently used between modules) Array appBecomingInactiveCallbacks; -} +} // namespace juce #if JUCE_PUSH_NOTIFICATIONS @interface JuceAppStartupDelegate : NSObject @@ -499,15 +499,15 @@ bool Desktop::isScreenSaverEnabled() } //============================================================================== -bool juce_areThereAnyAlwaysOnTopWindows() +bool detail::WindowingHelpers::areThereAnyAlwaysOnTopWindows() { return false; } //============================================================================== -Image juce_createIconForFile (const File&) +Image detail::WindowingHelpers::createIconForFile (const File&) { - return Image(); + return {}; } //============================================================================== @@ -523,13 +523,13 @@ String SystemClipboard::getTextFromClipboard() } //============================================================================== -bool MouseInputSource::SourceList::addSource() +bool detail::MouseInputSourceList::addSource() { addSource (sources.size(), MouseInputSource::InputSourceType::touch); return true; } -bool MouseInputSource::SourceList::canUseTouch() +bool detail::MouseInputSourceList::canUseTouch() const { return true; } diff --git a/modules/juce_gui_basics/native/juce_linux_NativeMessageBox.cpp b/modules/juce_gui_basics/native/juce_linux_NativeMessageBox.cpp index c3a27fb16f..bdae465a8e 100644 --- a/modules/juce_gui_basics/native/juce_linux_NativeMessageBox.cpp +++ b/modules/juce_gui_basics/native/juce_linux_NativeMessageBox.cpp @@ -23,7 +23,7 @@ ============================================================================== */ -namespace juce +namespace juce::detail { std::unique_ptr ScopedMessageBoxInterface::create (const MessageBoxOptions& options) @@ -35,7 +35,7 @@ std::unique_ptr ScopedMessageBoxInterface::create (co { public: explicit MessageBox (const MessageBoxOptions& options) - : inner (createAlertWindowImpl (options)), + : inner (detail::AlertWindowHelpers::create (options)), numButtons (options.getNumButtons()) {} void runAsync (std::function fn) override @@ -66,4 +66,4 @@ std::unique_ptr ScopedMessageBoxInterface::create (co return std::make_unique (options); } -} // namespace juce +} // namespace juce::detail diff --git a/modules/juce_gui_basics/native/juce_linux_Windowing.cpp b/modules/juce_gui_basics/native/juce_linux_Windowing.cpp index e7bc85984d..a386fc8931 100644 --- a/modules/juce_gui_basics/native/juce_linux_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_linux_Windowing.cpp @@ -28,7 +28,7 @@ namespace juce //============================================================================== static int numAlwaysOnTopPeers = 0; -bool juce_areThereAnyAlwaysOnTopWindows() { return numAlwaysOnTopPeers > 0; } +bool detail::WindowingHelpers::areThereAnyAlwaysOnTopWindows() { return numAlwaysOnTopPeers > 0; } //============================================================================== class LinuxComponentPeer : public ComponentPeer, @@ -217,7 +217,7 @@ public: : Desktop::getInstance().getDisplays().getDisplayForRect (bounds)->userArea; if (! r.isEmpty()) - setBounds (ScalingHelpers::scaledScreenPosToUnscaled (component, r), shouldBeFullScreen); + setBounds (detail::ScalingHelpers::scaledScreenPosToUnscaled (component, r), shouldBeFullScreen); component.repaint(); } @@ -468,7 +468,7 @@ private: // This issue only occurs right after peer creation, when the image is // null. Updating when only the width or height is changed would lead to // incorrect behaviour. - peer.forceSetBounds (ScalingHelpers::scaledScreenPosToUnscaled (peer.component, + peer.forceSetBounds (detail::ScalingHelpers::scaledScreenPosToUnscaled (peer.component, peer.component.getBoundsInParent()), peer.isFullScreen()); } @@ -716,7 +716,7 @@ Desktop::DisplayOrientation Desktop::getCurrentOrientation() const { return upr void Desktop::allowedOrientationsChanged() {} //============================================================================== -bool MouseInputSource::SourceList::addSource() +bool detail::MouseInputSourceList::addSource() { if (sources.isEmpty()) { @@ -727,7 +727,7 @@ bool MouseInputSource::SourceList::addSource() return false; } -bool MouseInputSource::SourceList::canUseTouch() +bool detail::MouseInputSourceList::canUseTouch() const { return false; } @@ -749,7 +749,7 @@ public: explicit PlatformSpecificHandle (const MouseCursor::StandardCursorType type) : cursorHandle (makeHandle (type)) {} - explicit PlatformSpecificHandle (const CustomMouseCursorInfo& info) + explicit PlatformSpecificHandle (const detail::CustomMouseCursorInfo& info) : cursorHandle (makeHandle (info)) {} ~PlatformSpecificHandle() @@ -767,7 +767,7 @@ public: } private: - static Cursor makeHandle (const CustomMouseCursorInfo& info) + static Cursor makeHandle (const detail::CustomMouseCursorInfo& info) { const auto image = info.image.getImage(); return XWindowSystem::getInstance()->createCustomMouseCursorInfo (image.rescaled ((int) (image.getWidth() / info.image.getScale()), @@ -852,7 +852,7 @@ void LookAndFeel::playAlertSound() } //============================================================================== -Image juce_createIconForFile (const File&) +Image detail::WindowingHelpers::createIconForFile (const File&) { return {}; } diff --git a/modules/juce_gui_basics/native/juce_mac_CGMetalLayerRenderer.h b/modules/juce_gui_basics/native/juce_mac_CGMetalLayerRenderer.h index bfa8f0cb8a..392d3475b6 100644 --- a/modules/juce_gui_basics/native/juce_mac_CGMetalLayerRenderer.h +++ b/modules/juce_gui_basics/native/juce_mac_CGMetalLayerRenderer.h @@ -406,4 +406,4 @@ private: JUCE_END_IGNORE_WARNINGS_GCC_LIKE -} +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_mac_FileChooser.mm b/modules/juce_gui_basics/native/juce_mac_FileChooser.mm index ddb7df440c..55e087054c 100644 --- a/modules/juce_gui_basics/native/juce_mac_FileChooser.mm +++ b/modules/juce_gui_basics/native/juce_mac_FileChooser.mm @@ -179,7 +179,7 @@ public: { if (panel != nil) { - setAlwaysOnTop (juce_areThereAnyAlwaysOnTopWindows()); + setAlwaysOnTop (detail::WindowingHelpers::areThereAnyAlwaysOnTopWindows()); addToDesktop (0); enterModalState (true); @@ -415,4 +415,4 @@ bool FileChooser::isPlatformDialogAvailable() #endif } -} +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_mac_MainMenu.mm b/modules/juce_gui_basics/native/juce_mac_MainMenu.mm index 9c89a04493..dd0004328c 100644 --- a/modules/juce_gui_basics/native/juce_mac_MainMenu.mm +++ b/modules/juce_gui_basics/native/juce_mac_MainMenu.mm @@ -825,7 +825,7 @@ static void mainMenuTrackingChanged (bool isTracking) } } -void juce_initialiseMacMainMenu() +static void initialiseMacMainMenu() { menuTrackingChangedCallback = mainMenuTrackingChanged; @@ -837,7 +837,7 @@ void juce_initialiseMacMainMenu() NSMenu* createNSMenu (const PopupMenu&, const String&, int, int, bool); NSMenu* createNSMenu (const PopupMenu& menu, const String& name, int topLevelMenuId, int topLevelIndex, bool addDelegate) { - juce_initialiseMacMainMenu(); + initialiseMacMainMenu(); if (auto* mm = JuceMainMenuHandler::instance) return mm->createMenu (menu, name, topLevelMenuId, topLevelIndex, addDelegate); diff --git a/modules/juce_gui_basics/native/juce_mac_MouseCursor.mm b/modules/juce_gui_basics/native/juce_mac_MouseCursor.mm index 4d5370085c..73cb3b03aa 100644 --- a/modules/juce_gui_basics/native/juce_mac_MouseCursor.mm +++ b/modules/juce_gui_basics/native/juce_mac_MouseCursor.mm @@ -35,7 +35,7 @@ public: PlatformSpecificHandle (const MouseCursor::StandardCursorType type) : cursorHandle (createCursor (type)) {} - PlatformSpecificHandle (const CustomMouseCursorInfo& info) + PlatformSpecificHandle (const detail::CustomMouseCursorInfo& info) : cursorHandle (createCursor (info)) {} ~PlatformSpecificHandle() @@ -109,7 +109,7 @@ private: return fromNSImage (resultImage, NSMakePoint (hotspotX, hotspotY)); } } - static NSCursor* createCursor (const CustomMouseCursorInfo& info) + static NSCursor* createCursor (const detail::CustomMouseCursorInfo& info) { return fromNSImage (imageToNSImage (info.image), NSMakePoint (info.hotspot.x, info.hotspot.y)); @@ -187,7 +187,7 @@ class MouseCursor::PlatformSpecificHandle { public: PlatformSpecificHandle (const MouseCursor::StandardCursorType) {} - PlatformSpecificHandle (const CustomMouseCursorInfo&) {} + PlatformSpecificHandle (const detail::CustomMouseCursorInfo&) {} static void showInWindow (PlatformSpecificHandle*, ComponentPeer*) {} }; diff --git a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index 4a1f24670e..970adb46b0 100644 --- a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -1261,8 +1261,8 @@ public: const auto scale = getComponent().getDesktopScaleFactor(); - auto pos = ScalingHelpers::unscaledScreenPosToScaled (scale, convertToRectInt (flippedScreenRect (r))); - const auto original = ScalingHelpers::unscaledScreenPosToScaled (scale, convertToRectInt (flippedScreenRect ([window frame]))); + auto pos = detail::ScalingHelpers::unscaledScreenPosToScaled (scale, convertToRectInt (flippedScreenRect (r))); + const auto original = detail::ScalingHelpers::unscaledScreenPosToScaled (scale, convertToRectInt (flippedScreenRect ([window frame]))); const auto screenBounds = Desktop::getInstance().getDisplays().getTotalBounds (true); @@ -1281,7 +1281,7 @@ public: constrainer->checkBounds (pos, original, screenBounds, isStretchingTop, isStretchingLeft, isStretchingBottom, isStretchingRight); - return flippedScreenRect (makeNSRect (ScalingHelpers::scaledScreenPosToUnscaled (scale, pos))); + return flippedScreenRect (makeNSRect (detail::ScalingHelpers::scaledScreenPosToUnscaled (scale, pos))); } static void showArrowCursorIfNeeded() @@ -1450,7 +1450,7 @@ public: const auto p = localToGlobal (convertToPointFloat ([view convertPoint: [sender draggingLocation] fromView: nil])); ComponentPeer::DragInfo dragInfo; - dragInfo.position = ScalingHelpers::screenPosToLocalPos (component, p).roundToInt(); + dragInfo.position = detail::ScalingHelpers::screenPosToLocalPos (component, p).roundToInt(); if (contentType == NSPasteboardTypeString) dragInfo.text = nsStringToJuce ([pasteboard stringForType: NSPasteboardTypeString]); @@ -2382,7 +2382,7 @@ struct JuceNSViewClass : public NSViewComponentPeerWrapper> : target->getTextBounds (codePointRange).getRectangle (0); const auto areaOnDesktop = comp->localAreaToGlobal (rect); - return flippedScreenRect (makeNSRect (ScalingHelpers::scaledScreenPosToUnscaled (areaOnDesktop))); + return flippedScreenRect (makeNSRect (detail::ScalingHelpers::scaledScreenPosToUnscaled (areaOnDesktop))); } } } @@ -2771,7 +2771,7 @@ bool KeyPress::isKeyCurrentlyDown (int keyCode) } //============================================================================== -bool MouseInputSource::SourceList::addSource() +bool detail::MouseInputSourceList::addSource() { if (sources.size() == 0) { @@ -2782,7 +2782,7 @@ bool MouseInputSource::SourceList::addSource() return false; } -bool MouseInputSource::SourceList::canUseTouch() +bool detail::MouseInputSourceList::canUseTouch() const { return false; } diff --git a/modules/juce_gui_basics/native/juce_mac_NativeMessageBox.mm b/modules/juce_gui_basics/native/juce_mac_NativeMessageBox.mm index 3d406a0373..359607e080 100644 --- a/modules/juce_gui_basics/native/juce_mac_NativeMessageBox.mm +++ b/modules/juce_gui_basics/native/juce_mac_NativeMessageBox.mm @@ -23,7 +23,7 @@ ============================================================================== */ -namespace juce +namespace juce::detail { std::unique_ptr ScopedMessageBoxInterface::create (const MessageBoxOptions& options) @@ -131,4 +131,4 @@ std::unique_ptr ScopedMessageBoxInterface::create (co return std::make_unique (options); } -} // namespace juce +} // namespace juce::detail diff --git a/modules/juce_gui_basics/native/juce_mac_Windowing.mm b/modules/juce_gui_basics/native/juce_mac_Windowing.mm index 3c54104ef2..3e129ea706 100644 --- a/modules/juce_gui_basics/native/juce_mac_Windowing.mm +++ b/modules/juce_gui_basics/native/juce_mac_Windowing.mm @@ -465,7 +465,7 @@ void Displays::findDisplays (const float masterScale) } //============================================================================== -bool juce_areThereAnyAlwaysOnTopWindows() +bool detail::WindowingHelpers::areThereAnyAlwaysOnTopWindows() { for (NSWindow* window in [NSApp windows]) if ([window level] > NSNormalWindowLevel) @@ -498,7 +498,7 @@ static void releaseImageAfterDrawing() [NSGraphicsContext restoreGraphicsState]; } -Image juce_createIconForFile (const File& file) +Image detail::WindowingHelpers::createIconForFile (const File& file) { JUCE_AUTORELEASEPOOL { diff --git a/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp b/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp index fbd57db499..80a82ebaeb 100644 --- a/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp +++ b/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp @@ -793,7 +793,7 @@ public: 0, 0); setOpaque (true); - setAlwaysOnTop (juce_areThereAnyAlwaysOnTopWindows()); + setAlwaysOnTop (detail::WindowingHelpers::areThereAnyAlwaysOnTopWindows()); addToDesktop (0); } diff --git a/modules/juce_gui_basics/native/juce_win32_NativeMessageBox.cpp b/modules/juce_gui_basics/native/juce_win32_NativeMessageBox.cpp index a2bfab41b4..574905cc93 100644 --- a/modules/juce_gui_basics/native/juce_win32_NativeMessageBox.cpp +++ b/modules/juce_gui_basics/native/juce_win32_NativeMessageBox.cpp @@ -23,7 +23,7 @@ ============================================================================== */ -namespace juce +namespace juce::detail { #if JUCE_MSVC @@ -175,7 +175,7 @@ std::unique_ptr ScopedMessageBoxInterface::create (co { // this window can get lost behind JUCE windows which are set to be alwaysOnTop // so if there are any set it to be topmost - const auto topmostFlag = juce_areThereAnyAlwaysOnTopWindows() ? MB_TOPMOST : 0; + const auto topmostFlag = detail::WindowingHelpers::areThereAnyAlwaysOnTopWindows() ? MB_TOPMOST : 0; const auto iconFlags = [&]() -> decltype (topmostFlag) { @@ -345,4 +345,4 @@ std::unique_ptr ScopedMessageBoxInterface::create (co return std::make_unique (options, (UINT) extraFlags); } -} // namespace juce +} // namespace juce::detail diff --git a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp index cbb71b7bda..0e9f0a8824 100644 --- a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp @@ -1947,7 +1947,7 @@ public: ShowWindow (hwnd, SW_SHOWNORMAL); if (! boundsCopy.isEmpty()) - setBounds (ScalingHelpers::scaledScreenPosToUnscaled (component, boundsCopy), false); + setBounds (detail::ScalingHelpers::scaledScreenPosToUnscaled (component, boundsCopy), false); } else { @@ -2253,7 +2253,7 @@ public: { const auto originalPos = pointFromPOINT ({ mousePos.x, mousePos.y }); const auto logicalPos = convertPhysicalScreenPointToLogical (originalPos, peer.hwnd); - return ScalingHelpers::screenPosToLocalPos (peer.component, logicalPos.toFloat()); + return detail::ScalingHelpers::screenPosToLocalPos (peer.component, logicalPos.toFloat()); } struct DroppedData @@ -3654,7 +3654,7 @@ private: Rectangle getCurrentScaledBounds() const { - return ScalingHelpers::unscaledScreenPosToScaled (component, windowBorder.addedTo (ScalingHelpers::scaledScreenPosToUnscaled (component, component.getBounds()))); + return detail::ScalingHelpers::unscaledScreenPosToScaled (component, windowBorder.addedTo (detail::ScalingHelpers::scaledScreenPosToUnscaled (component, component.getBounds()))); } LRESULT handleSizeConstraining (RECT& r, const WPARAM wParam) @@ -3662,7 +3662,7 @@ private: if (isConstrainedNativeWindow()) { const auto logicalBounds = convertPhysicalScreenRectangleToLogical (rectangleFromRECT (r).toFloat(), hwnd); - auto pos = ScalingHelpers::unscaledScreenPosToScaled (component, logicalBounds).toNearestInt(); + auto pos = detail::ScalingHelpers::unscaledScreenPosToScaled (component, logicalBounds).toNearestInt(); const auto original = getCurrentScaledBounds(); @@ -3673,7 +3673,7 @@ private: wParam == WMSZ_BOTTOM || wParam == WMSZ_BOTTOMLEFT || wParam == WMSZ_BOTTOMRIGHT, wParam == WMSZ_RIGHT || wParam == WMSZ_TOPRIGHT || wParam == WMSZ_BOTTOMRIGHT); - r = RECTFromRectangle (convertLogicalScreenRectangleToPhysical (ScalingHelpers::scaledScreenPosToUnscaled (component, pos.toFloat()).toNearestInt(), hwnd)); + r = RECTFromRectangle (convertLogicalScreenRectangleToPhysical (detail::ScalingHelpers::scaledScreenPosToUnscaled (component, pos.toFloat()).toNearestInt(), hwnd)); } return TRUE; @@ -3688,7 +3688,7 @@ private: && ! Component::isMouseButtonDownAnywhere()) { const auto logicalBounds = convertPhysicalScreenRectangleToLogical (rectangleFromRECT ({ wp.x, wp.y, wp.x + wp.cx, wp.y + wp.cy }).toFloat(), hwnd); - auto pos = ScalingHelpers::unscaledScreenPosToScaled (component, logicalBounds).toNearestInt(); + auto pos = detail::ScalingHelpers::unscaledScreenPosToScaled (component, logicalBounds).toNearestInt(); const auto original = getCurrentScaledBounds(); @@ -3699,7 +3699,7 @@ private: pos.getY() == original.getY() && pos.getBottom() != original.getBottom(), pos.getX() == original.getX() && pos.getRight() != original.getRight()); - auto physicalBounds = convertLogicalScreenRectangleToPhysical (ScalingHelpers::scaledScreenPosToUnscaled (component, pos.toFloat()), hwnd); + auto physicalBounds = convertLogicalScreenRectangleToPhysical (detail::ScalingHelpers::scaledScreenPosToUnscaled (component, pos.toFloat()), hwnd); auto getNewPositionIfNotRoundingError = [] (int posIn, float newPos) { @@ -3903,7 +3903,7 @@ private: forceDisplayUpdate(); if (fullScreen && ! isMinimised()) - setWindowPos (hwnd, ScalingHelpers::scaledScreenPosToUnscaled (component, Desktop::getInstance().getDisplays() + setWindowPos (hwnd, detail::ScalingHelpers::scaledScreenPosToUnscaled (component, Desktop::getInstance().getDisplays() .getDisplayForRect (component.getScreenBounds())->userArea), SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOSENDCHANGING); @@ -4150,7 +4150,7 @@ private: else Desktop::getInstance().setKioskModeComponent (nullptr); // turn kiosk mode off if we lose focus - juce_checkCurrentlyFocusedTopLevelWindow(); + detail::TopLevelWindowManager::checkCurrentlyFocusedTopLevelWindow(); modifiersAtLastCallback = -1; return 0; @@ -4747,7 +4747,7 @@ static DWORD getProcess (HWND hwnd) /* Returns true if the viewComponent is embedded into a window owned by the foreground process. */ -bool isEmbeddedInForegroundProcess (Component* c) +bool detail::WindowingHelpers::isEmbeddedInForegroundProcess (Component* c) { if (c == nullptr) return false; @@ -4799,7 +4799,7 @@ static BOOL CALLBACK enumAlwaysOnTopWindows (HWND hwnd, LPARAM lParam) return TRUE; } -bool juce_areThereAnyAlwaysOnTopWindows() +bool detail::WindowingHelpers::areThereAnyAlwaysOnTopWindows() { bool anyAlwaysOnTopFound = false; EnumWindows (&enumAlwaysOnTopWindows, (LPARAM) &anyAlwaysOnTopFound); @@ -4807,7 +4807,7 @@ bool juce_areThereAnyAlwaysOnTopWindows() } //============================================================================== -bool MouseInputSource::SourceList::addSource() +bool detail::MouseInputSourceList::addSource() { auto numSources = sources.size(); @@ -4821,7 +4821,7 @@ bool MouseInputSource::SourceList::addSource() return false; } -bool MouseInputSource::SourceList::canUseTouch() +bool detail::MouseInputSourceList::canUseTouch() const { return canUseMultiTouch(); } @@ -5117,7 +5117,7 @@ static auto extractFileHICON (const File& file) &iconNum) }; } -Image juce_createIconForFile (const File& file) +Image detail::WindowingHelpers::createIconForFile (const File& file) { if (const auto icon = extractFileHICON (file)) return IconConverters::createImageFromHICON (icon.get()); @@ -5132,7 +5132,7 @@ public: explicit PlatformSpecificHandle (const MouseCursor::StandardCursorType type) : impl (makeHandle (type)) {} - explicit PlatformSpecificHandle (const CustomMouseCursorInfo& info) + explicit PlatformSpecificHandle (const detail::CustomMouseCursorInfo& info) : impl (makeHandle (info)) {} static void showInWindow (PlatformSpecificHandle* handle, ComponentPeer* peer) @@ -5168,7 +5168,7 @@ private: class ImageImpl : public Impl { public: - explicit ImageImpl (const CustomMouseCursorInfo& infoIn) : info (infoIn) {} + explicit ImageImpl (const detail::CustomMouseCursorInfo& infoIn) : info (infoIn) {} HCURSOR getCursor (ComponentPeer& peer) override { @@ -5206,7 +5206,7 @@ private: using CursorPtr = std::unique_ptr, CursorDestructor>; - const CustomMouseCursorInfo info; + const detail::CustomMouseCursorInfo info; std::map cursorsBySize; }; @@ -5253,7 +5253,7 @@ private: static constexpr auto unityCursorSize = 32; - static std::unique_ptr makeHandle (const CustomMouseCursorInfo& info) + static std::unique_ptr makeHandle (const detail::CustomMouseCursorInfo& info) { return std::make_unique (info); } @@ -5329,4 +5329,56 @@ private: //============================================================================== JUCE_END_IGNORE_WARNINGS_GCC_LIKE +//============================================================================== +JUCE_COMCLASS (JuceIVirtualDesktopManager, "a5cd92ff-29be-454c-8d04-d82879fb3f1b") : public IUnknown +{ +public: + virtual HRESULT STDMETHODCALLTYPE IsWindowOnCurrentVirtualDesktop( + __RPC__in HWND topLevelWindow, + __RPC__out BOOL * onCurrentDesktop) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetWindowDesktopId( + __RPC__in HWND topLevelWindow, + __RPC__out GUID * desktopId) = 0; + + virtual HRESULT STDMETHODCALLTYPE MoveWindowToDesktop( + __RPC__in HWND topLevelWindow, + __RPC__in REFGUID desktopId) = 0; +}; + +JUCE_COMCLASS (JuceVirtualDesktopManager, "aa509086-5ca9-4c25-8f95-589d3c07b48a"); + } // namespace juce + +#ifdef __CRT_UUID_DECL +__CRT_UUID_DECL (juce::JuceIVirtualDesktopManager, 0xa5cd92ff, 0x29be, 0x454c, 0x8d, 0x04, 0xd8, 0x28, 0x79, 0xfb, 0x3f, 0x1b) +__CRT_UUID_DECL (juce::JuceVirtualDesktopManager, 0xaa509086, 0x5ca9, 0x4c25, 0x8f, 0x95, 0x58, 0x9d, 0x3c, 0x07, 0xb4, 0x8a) +#endif + +bool juce::detail::WindowingHelpers::isWindowOnCurrentVirtualDesktop (void* x) +{ + if (x == nullptr) + return false; + + static auto* desktopManager = [] + { + JuceIVirtualDesktopManager* result = nullptr; + + JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wlanguage-extension-token") + + if (SUCCEEDED (CoCreateInstance (__uuidof (JuceVirtualDesktopManager), nullptr, CLSCTX_ALL, IID_PPV_ARGS (&result)))) + return result; + + JUCE_END_IGNORE_WARNINGS_GCC_LIKE + + return static_cast (nullptr); + }(); + + BOOL current = false; + + if (auto* dm = desktopManager) + if (SUCCEEDED (dm->IsWindowOnCurrentVirtualDesktop (static_cast (x), ¤t))) + return current != false; + + return true; +} diff --git a/modules/juce_gui_basics/native/x11/juce_linux_X11_DragAndDrop.cpp b/modules/juce_gui_basics/native/x11/juce_linux_X11_DragAndDrop.cpp index 058e8cae05..6b48495a84 100644 --- a/modules/juce_gui_basics/native/x11/juce_linux_X11_DragAndDrop.cpp +++ b/modules/juce_gui_basics/native/x11/juce_linux_X11_DragAndDrop.cpp @@ -159,7 +159,7 @@ public: const auto displays = Desktop::getInstance().getDisplays(); const auto logicalPos = displays.physicalToLogical (Point ((int) clientMsg.data.l[2] >> 16, (int) clientMsg.data.l[2] & 0xffff)); - const auto dropPos = ScalingHelpers::screenPosToLocalPos (peer->getComponent(), logicalPos.toFloat()).roundToInt(); + const auto dropPos = detail::ScalingHelpers::screenPosToLocalPos (peer->getComponent(), logicalPos.toFloat()).roundToInt(); const auto& atoms = getAtoms(); diff --git a/modules/juce_gui_basics/native/x11/juce_linux_X11_Symbols.cpp b/modules/juce_gui_basics/native/x11/juce_linux_X11_Symbols.cpp index 4b2e24eede..d800ab41e1 100644 --- a/modules/juce_gui_basics/native/x11/juce_linux_X11_Symbols.cpp +++ b/modules/juce_gui_basics/native/x11/juce_linux_X11_Symbols.cpp @@ -237,4 +237,4 @@ bool X11Symbols::loadAllSymbols() //============================================================================== JUCE_IMPLEMENT_SINGLETON (X11Symbols) -} +} // namespace juce diff --git a/modules/juce_gui_basics/native/x11/juce_linux_X11_Symbols.h b/modules/juce_gui_basics/native/x11/juce_linux_X11_Symbols.h index 74d70fa674..31cfdd5e1d 100644 --- a/modules/juce_gui_basics/native/x11/juce_linux_X11_Symbols.h +++ b/modules/juce_gui_basics/native/x11/juce_linux_X11_Symbols.h @@ -617,4 +617,4 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (X11Symbols) }; -} +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_ListBox.cpp b/modules/juce_gui_basics/widgets/juce_ListBox.cpp index 5a4fd98760..f0e3e8365d 100644 --- a/modules/juce_gui_basics/widgets/juce_ListBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_ListBox.cpp @@ -92,7 +92,7 @@ public: const auto select = getOwner().getRowSelectedOnMouseDown() && ! selected - && ! viewportWouldScrollOnEvent (getOwner().getViewport(), e.source) ; + && ! detail::ViewportHelpers::wouldScrollOnEvent (getOwner().getViewport(), e.source) ; if (select) asBase().performSelection (e, false); else diff --git a/modules/juce_gui_basics/widgets/juce_Toolbar.cpp b/modules/juce_gui_basics/widgets/juce_Toolbar.cpp index f32a5a69dc..e1f39c040b 100644 --- a/modules/juce_gui_basics/widgets/juce_Toolbar.cpp +++ b/modules/juce_gui_basics/widgets/juce_Toolbar.cpp @@ -682,7 +682,7 @@ public: bool canModalEventBeSentToComponent (const Component* comp) override { return toolbar.isParentOf (comp) - || dynamic_cast (comp) != nullptr; + || dynamic_cast (comp) != nullptr; } void positionNearBar() diff --git a/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp b/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp index 9c921740ae..2605f77525 100644 --- a/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp +++ b/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp @@ -29,97 +29,6 @@ namespace juce ToolbarItemFactory::ToolbarItemFactory() {} ToolbarItemFactory::~ToolbarItemFactory() {} -//============================================================================== -class ToolbarItemComponent::ItemDragAndDropOverlayComponent : public Component -{ -public: - ItemDragAndDropOverlayComponent() - : isDragging (false) - { - setAlwaysOnTop (true); - setRepaintsOnMouseActivity (true); - setMouseCursor (MouseCursor::DraggingHandCursor); - } - - void paint (Graphics& g) override - { - if (ToolbarItemComponent* const tc = getToolbarItemComponent()) - { - if (isMouseOverOrDragging() - && tc->getEditingMode() == ToolbarItemComponent::editableOnToolbar) - { - g.setColour (findColour (Toolbar::editingModeOutlineColourId, true)); - g.drawRect (getLocalBounds(), jmin (2, (getWidth() - 1) / 2, - (getHeight() - 1) / 2)); - } - } - } - - void mouseDown (const MouseEvent& e) override - { - isDragging = false; - - if (ToolbarItemComponent* const tc = getToolbarItemComponent()) - { - tc->dragOffsetX = e.x; - tc->dragOffsetY = e.y; - } - } - - void mouseDrag (const MouseEvent& e) override - { - if (e.mouseWasDraggedSinceMouseDown() && ! isDragging) - { - isDragging = true; - - if (DragAndDropContainer* const dnd = DragAndDropContainer::findParentDragContainerFor (this)) - { - dnd->startDragging (Toolbar::toolbarDragDescriptor, getParentComponent(), ScaledImage(), true, nullptr, &e.source); - - if (ToolbarItemComponent* const tc = getToolbarItemComponent()) - { - tc->isBeingDragged = true; - - if (tc->getEditingMode() == ToolbarItemComponent::editableOnToolbar) - tc->setVisible (false); - } - } - } - } - - void mouseUp (const MouseEvent&) override - { - isDragging = false; - - if (ToolbarItemComponent* const tc = getToolbarItemComponent()) - { - tc->isBeingDragged = false; - - if (Toolbar* const tb = tc->getToolbar()) - tb->updateAllItemPositions (true); - else if (tc->getEditingMode() == ToolbarItemComponent::editableOnToolbar) - delete tc; - } - } - - void parentSizeChanged() override - { - setBounds (0, 0, getParentWidth(), getParentHeight()); - } - -private: - //============================================================================== - bool isDragging; - - ToolbarItemComponent* getToolbarItemComponent() const noexcept - { - return dynamic_cast (getParentComponent()); - } - - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ItemDragAndDropOverlayComponent) -}; - - //============================================================================== ToolbarItemComponent::ToolbarItemComponent (const int itemId_, const String& labelText, @@ -230,7 +139,7 @@ void ToolbarItemComponent::setEditingMode (const ToolbarEditingMode newMode) } else if (overlayComp == nullptr) { - overlayComp.reset (new ItemDragAndDropOverlayComponent()); + overlayComp.reset (new detail::ToolbarItemDragAndDropOverlayComponent()); addAndMakeVisible (overlayComp.get()); overlayComp->parentSizeChanged(); } @@ -249,7 +158,7 @@ std::unique_ptr ToolbarItemComponent::createAccessibilityH if (! shouldItemBeAccessible) return createIgnoredAccessibilityHandler (*this); - return std::make_unique (*this, AccessibilityRole::button); + return std::make_unique (*this, AccessibilityRole::button); } } // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.h b/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.h index 2143d8d83a..9ba8938af4 100644 --- a/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.h +++ b/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.h @@ -192,8 +192,7 @@ public: private: friend class Toolbar; - class ItemDragAndDropOverlayComponent; - friend class ItemDragAndDropOverlayComponent; + friend class detail::ToolbarItemDragAndDropOverlayComponent; const int itemId; ToolbarEditingMode mode; diff --git a/modules/juce_gui_basics/windows/juce_AlertWindow.cpp b/modules/juce_gui_basics/windows/juce_AlertWindow.cpp index 6f80650ab0..802bae7a3d 100644 --- a/modules/juce_gui_basics/windows/juce_AlertWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_AlertWindow.cpp @@ -35,90 +35,9 @@ static juce_wchar getDefaultPasswordChar() noexcept #endif } -static std::unique_ptr createAlertWindowImpl (const MessageBoxOptions& opts) -{ - class AlertWindowImpl : public ScopedMessageBoxInterface - { - public: - explicit AlertWindowImpl (const MessageBoxOptions& opts) : options (opts) {} - - void runAsync (std::function recipient) override - { - if (auto* comp = setUpAlert()) - comp->enterModalState (true, ModalCallbackFunction::create (std::move (recipient)), true); - else - NullCheckedInvocation::invoke (recipient, 0); - } - - int runSync() override - { - #if JUCE_MODAL_LOOPS_PERMITTED - if (auto comp = rawToUniquePtr (setUpAlert())) - return comp->runModalLoop(); - #endif - - jassertfalse; - return 0; - } - - void close() override - { - if (alert != nullptr) - if (alert->isCurrentlyModal()) - alert->exitModalState(); - - alert = nullptr; - } - - private: - Component* setUpAlert() - { - auto* component = options.getAssociatedComponent(); - - auto& lf = component != nullptr ? component->getLookAndFeel() - : LookAndFeel::getDefaultLookAndFeel(); - - alert = lf.createAlertWindow (options.getTitle(), - options.getMessage(), - options.getButtonText (0), - options.getButtonText (1), - options.getButtonText (2), - options.getIconType(), - options.getNumButtons(), - component); - - if (alert == nullptr) - { - // You have to return an alert box! - jassertfalse; - return nullptr; - } - - if (auto* parent = options.getParentComponent()) - { - parent->addAndMakeVisible (alert); - - if (options.getAssociatedComponent() == nullptr) - alert->setCentrePosition (parent->getLocalBounds().getCentre()); - } - - alert->setAlwaysOnTop (juce_areThereAnyAlwaysOnTopWindows()); - - return alert; - } - - const MessageBoxOptions options; - Component::SafePointer alert; - - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AlertWindowImpl) - }; - - return std::make_unique (opts); -} - static int showAlertWindowUnmanaged (const MessageBoxOptions& opts, ModalComponentManager::Callback* cb) { - return ScopedMessageBox::Pimpl::showUnmanaged (createAlertWindowImpl (opts), cb); + return detail::ScopedMessageBoxImpl::showUnmanaged (detail::AlertWindowHelpers::create (opts), cb); } //============================================================================== @@ -131,7 +50,7 @@ AlertWindow::AlertWindow (const String& title, associatedComponent (comp), desktopScale (comp != nullptr ? Component::getApproximateScaleFactorForComponent (comp) : 1.0f) { - setAlwaysOnTop (juce_areThereAnyAlwaysOnTopWindows()); + setAlwaysOnTop (detail::WindowingHelpers::areThereAnyAlwaysOnTopWindows()); accessibleMessageLabel.setColour (Label::textColourId, Colours::transparentBlack); accessibleMessageLabel.setColour (Label::backgroundColourId, Colours::transparentBlack); @@ -774,7 +693,7 @@ ScopedMessageBox AlertWindow::showScopedAsync (const MessageBoxOptions& options, if (LookAndFeel::getDefaultLookAndFeel().isUsingNativeAlertWindows()) return NativeMessageBox::showScopedAsync (options, std::move (callback)); - return ScopedMessageBox::Pimpl::show (createAlertWindowImpl (options), std::move (callback)); + return detail::ScopedMessageBoxImpl::show (detail::AlertWindowHelpers::create (options), std::move (callback)); } //============================================================================== diff --git a/modules/juce_gui_basics/windows/juce_CallOutBox.cpp b/modules/juce_gui_basics/windows/juce_CallOutBox.cpp index db1a8d488b..3bb6c5306b 100644 --- a/modules/juce_gui_basics/windows/juce_CallOutBox.cpp +++ b/modules/juce_gui_basics/windows/juce_CallOutBox.cpp @@ -39,7 +39,7 @@ CallOutBox::CallOutBox (Component& c, Rectangle area, Component* const pare } else { - setAlwaysOnTop (juce_areThereAnyAlwaysOnTopWindows()); + setAlwaysOnTop (detail::WindowingHelpers::areThereAnyAlwaysOnTopWindows()); updatePosition (area, Desktop::getInstance().getDisplays().getDisplayForRect (area)->userArea); addToDesktop (ComponentPeer::windowIsTemporary); @@ -67,7 +67,7 @@ public: void timerCallback() override { - if (! isForegroundOrEmbeddedProcess (&callout)) + if (! detail::WindowingHelpers::isForegroundOrEmbeddedProcess (&callout)) callout.dismiss(); } diff --git a/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp b/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp index fdb36953ba..0bd3784ed1 100644 --- a/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp +++ b/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp @@ -74,7 +74,7 @@ bool ComponentPeer::isValidPeer (const ComponentPeer* const peer) noexcept void ComponentPeer::updateBounds() { - setBounds (ScalingHelpers::scaledScreenPosToUnscaled (component, component.getBoundsInParent()), false); + setBounds (detail::ScalingHelpers::scaledScreenPosToUnscaled (component, component.getBoundsInParent()), false); } bool ComponentPeer::isKioskMode() const @@ -315,7 +315,7 @@ void ComponentPeer::handleMovedOrResized() { const WeakReference deletionChecker (&component); - auto newBounds = Component::ComponentHelpers::rawPeerPositionToLocal (component, getBounds()); + auto newBounds = detail::ComponentHelpers::rawPeerPositionToLocal (component, getBounds()); auto oldBounds = component.getBounds(); const bool wasMoved = (oldBounds.getPosition() != newBounds.getPosition()); @@ -430,7 +430,7 @@ Rectangle ComponentPeer::globalToLocal (const Rectangle& screenPos Rectangle ComponentPeer::getAreaCoveredBy (const Component& subComponent) const { - return ScalingHelpers::scaledScreenPosToUnscaled + return detail::ScalingHelpers::scaledScreenPosToUnscaled (component, component.getLocalArea (&subComponent, subComponent.getLocalBounds())); } diff --git a/modules/juce_gui_basics/windows/juce_DialogWindow.cpp b/modules/juce_gui_basics/windows/juce_DialogWindow.cpp index c2da248cf6..561041f320 100644 --- a/modules/juce_gui_basics/windows/juce_DialogWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_DialogWindow.cpp @@ -92,7 +92,7 @@ public: setResizable (options.resizable, options.useBottomRightCornerResizer); setUsingNativeTitleBar (options.useNativeTitleBar); - setAlwaysOnTop (juce_areThereAnyAlwaysOnTopWindows()); + setAlwaysOnTop (detail::WindowingHelpers::areThereAnyAlwaysOnTopWindows()); } void closeButtonPressed() override diff --git a/modules/juce_gui_basics/windows/juce_NativeMessageBox.cpp b/modules/juce_gui_basics/windows/juce_NativeMessageBox.cpp index f06e76aca6..f6925f6d6e 100644 --- a/modules/juce_gui_basics/windows/juce_NativeMessageBox.cpp +++ b/modules/juce_gui_basics/windows/juce_NativeMessageBox.cpp @@ -34,14 +34,14 @@ enum class ResultCodeMappingMode // are N buttons then button X will return ((X + 1) % N). }; -static std::unique_ptr makeNativeMessageBoxWithMappedResult (const MessageBoxOptions& opts, - ResultCodeMappingMode mode) +static std::unique_ptr makeNativeMessageBoxWithMappedResult (const MessageBoxOptions& opts, + ResultCodeMappingMode mode) { - class Adapter : public ScopedMessageBoxInterface + class Adapter : public detail::ScopedMessageBoxInterface { public: explicit Adapter (const MessageBoxOptions& options) - : inner (ScopedMessageBoxInterface::create (options)), + : inner (detail::ScopedMessageBoxInterface::create (options)), numButtons (options.getNumButtons()) {} void runAsync (std::function fn) override @@ -65,11 +65,11 @@ static std::unique_ptr makeNativeMessageBoxWithMapped private: static int map (int button, int numButtons) { return (button + 1) % numButtons; } - std::unique_ptr inner; + std::unique_ptr inner; int numButtons = 0; }; - return mode == ResultCodeMappingMode::plainIndex ? ScopedMessageBoxInterface::create (opts) + return mode == ResultCodeMappingMode::plainIndex ? detail::ScopedMessageBoxInterface::create (opts) : std::make_unique (opts); } @@ -78,7 +78,7 @@ static int showNativeBoxUnmanaged (const MessageBoxOptions& opts, ResultCodeMappingMode mode) { auto implementation = makeNativeMessageBoxWithMappedResult (opts, mode); - return ScopedMessageBox::Pimpl::showUnmanaged (std::move (implementation), cb); + return detail::ScopedMessageBoxImpl::showUnmanaged (std::move (implementation), cb); } #if JUCE_MODAL_LOOPS_PERMITTED @@ -152,7 +152,7 @@ void JUCE_CALLTYPE NativeMessageBox::showAsync (const MessageBoxOptions& options ScopedMessageBox NativeMessageBox::showScopedAsync (const MessageBoxOptions& options, std::function callback) { auto implementation = makeNativeMessageBoxWithMappedResult (options, ResultCodeMappingMode::alertWindow); - return ScopedMessageBox::Pimpl::show (std::move (implementation), std::move (callback)); + return detail::ScopedMessageBoxImpl::show (std::move (implementation), std::move (callback)); } } // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_ScopedMessageBox.cpp b/modules/juce_gui_basics/windows/juce_ScopedMessageBox.cpp index 6bddfe4837..d86ee0491e 100644 --- a/modules/juce_gui_basics/windows/juce_ScopedMessageBox.cpp +++ b/modules/juce_gui_basics/windows/juce_ScopedMessageBox.cpp @@ -26,134 +26,11 @@ namespace juce { -/* - Instances of this type can show and dismiss a message box. - - This is an interface rather than a concrete type so that platforms can pick an implementation at - runtime if necessary. -*/ -struct ScopedMessageBoxInterface -{ - virtual ~ScopedMessageBoxInterface() = default; - - /* Shows the message box. - - When the message box exits normally, it should send the result to the passed-in function. - The passed-in function is safe to call from any thread at any time. - */ - virtual void runAsync (std::function) = 0; - - /* Shows the message box and blocks. */ - virtual int runSync() = 0; - - /* Forcefully closes the message box. - - This will be called when the message box handle has fallen out of scope. - If the message box has already been closed by the user, this shouldn't do anything. - */ - virtual void close() = 0; - - /* Implemented differently for each platform. */ - static std::unique_ptr create (const MessageBoxOptions& options); -}; - -//============================================================================== -class ScopedMessageBox::Pimpl : private AsyncUpdater -{ -public: - static ScopedMessageBox show (std::unique_ptr&& native, std::function callback) - { - return ScopedMessageBox (runAsync (std::move (native), rawToUniquePtr (ModalCallbackFunction::create (std::move (callback))))); - } - - static int showUnmanaged (std::unique_ptr&& native, - ModalComponentManager::Callback* cb) - { - #if JUCE_MODAL_LOOPS_PERMITTED - if (cb == nullptr) - return runSync (std::move (native)); - #endif - - runAsync (std::move (native), rawToUniquePtr (cb)); - - return 0; - } - - ~Pimpl() override - { - cancelPendingUpdate(); - } - - void close() - { - cancelPendingUpdate(); - nativeImplementation->close(); - self.reset(); - } - -private: - static std::shared_ptr runAsync (std::unique_ptr&& p, - std::unique_ptr&& c) - { - std::shared_ptr result (new Pimpl (std::move (p), std::move (c))); - result->self = result; - result->triggerAsyncUpdate(); - return result; - } - - static int runSync (std::unique_ptr&& p) - { - auto local = std::move (p); - return local != nullptr ? local->runSync() : 0; - } - - explicit Pimpl (std::unique_ptr&& p) - : Pimpl (std::move (p), nullptr) {} - - Pimpl (std::unique_ptr&& p, - std::unique_ptr&& c) - : callback (std::move (c)), nativeImplementation (std::move (p)) {} - - void handleAsyncUpdate() override - { - nativeImplementation->runAsync ([weakRecipient = std::weak_ptr (self)] (int result) - { - const auto notifyRecipient = [result, weakRecipient] - { - if (const auto locked = weakRecipient.lock()) - { - if (auto* cb = locked->callback.get()) - cb->modalStateFinished (result); - - locked->self.reset(); - } - }; - - if (MessageManager::getInstance()->isThisTheMessageThread()) - notifyRecipient(); - else - MessageManager::callAsync (notifyRecipient); - }); - } - - std::unique_ptr callback; - std::unique_ptr nativeImplementation; - - /* The 'old' native message box API doesn't have a concept of message box owners. - Instead, message boxes have to clean up after themselves, once they're done displaying. - To allow this mode of usage, the implementation keeps an owning reference to itself, - which is cleared once the message box is closed or asked to quit. To display a native - message box without a scoped lifetime, just create a Pimpl instance without using - the ScopedMessageBox wrapper, and the Pimpl will destroy itself after it is dismissed. - */ - std::shared_ptr self; -}; - //============================================================================== ScopedMessageBox::ScopedMessageBox() = default; -ScopedMessageBox::ScopedMessageBox (std::shared_ptr p) - : pimpl (std::move (p)) {} +ScopedMessageBox::ScopedMessageBox (std::shared_ptr i) + : impl (std::move (i)) {} ScopedMessageBox::~ScopedMessageBox() noexcept { @@ -161,21 +38,21 @@ ScopedMessageBox::~ScopedMessageBox() noexcept } ScopedMessageBox::ScopedMessageBox (ScopedMessageBox&& other) noexcept - : pimpl (std::exchange (other.pimpl, nullptr)) {} + : impl (std::exchange (other.impl, nullptr)) {} ScopedMessageBox& ScopedMessageBox::operator= (ScopedMessageBox&& other) noexcept { ScopedMessageBox temp (std::move (other)); - std::swap (temp.pimpl, pimpl); + std::swap (temp.impl, impl); return *this; } void ScopedMessageBox::close() { - if (pimpl != nullptr) - pimpl->close(); + if (impl != nullptr) + impl->close(); - pimpl.reset(); + impl.reset(); } } // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_ScopedMessageBox.h b/modules/juce_gui_basics/windows/juce_ScopedMessageBox.h index 841643312a..d1234bb1c1 100644 --- a/modules/juce_gui_basics/windows/juce_ScopedMessageBox.h +++ b/modules/juce_gui_basics/windows/juce_ScopedMessageBox.h @@ -55,13 +55,11 @@ public: */ void close(); - /** @internal */ - class Pimpl; - private: - explicit ScopedMessageBox (std::shared_ptr); + friend detail::ScopedMessageBoxImpl; + explicit ScopedMessageBox (std::shared_ptr); - std::shared_ptr pimpl; + std::shared_ptr impl; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ScopedMessageBox) }; diff --git a/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp b/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp index 6668448de8..6b167196b8 100644 --- a/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp @@ -116,8 +116,8 @@ void TooltipWindow::displayTipInternal (Point screenPos, const String& tip, } else { - const auto physicalPos = ScalingHelpers::scaledScreenPosToUnscaled (screenPos); - const auto scaledPos = ScalingHelpers::unscaledScreenPosToScaled (*this, physicalPos); + const auto physicalPos = detail::ScalingHelpers::scaledScreenPosToUnscaled (screenPos); + const auto scaledPos = detail::ScalingHelpers::unscaledScreenPosToScaled (*this, physicalPos); updatePosition (tip, scaledPos, Desktop::getInstance().getDisplays().getDisplayForPoint (screenPos)->userArea); addToDesktop (ComponentPeer::windowHasDropShadow @@ -151,7 +151,7 @@ void TooltipWindow::displayTipInternal (Point screenPos, const String& tip, String TooltipWindow::getTipFor (Component& c) { - if (isForegroundOrEmbeddedProcess (&c) + if (detail::WindowingHelpers::isForegroundOrEmbeddedProcess (&c) && ! ModifierKeys::currentModifiers.isAnyMouseButtonDown()) { if (auto* ttc = dynamic_cast (&c)) diff --git a/modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp b/modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp index 106adb16dc..ad0e624efc 100644 --- a/modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp @@ -26,110 +26,6 @@ namespace juce { -/** Keeps track of the active top level window. */ -class TopLevelWindowManager : private Timer, - private DeletedAtShutdown -{ -public: - TopLevelWindowManager() {} - ~TopLevelWindowManager() override { clearSingletonInstance(); } - - JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (TopLevelWindowManager) - - void checkFocusAsync() - { - startTimer (10); - } - - void checkFocus() - { - startTimer (jmin (1731, getTimerInterval() * 2)); - - auto* newActive = findCurrentlyActiveWindow(); - - if (newActive != currentActive) - { - currentActive = newActive; - - for (int i = windows.size(); --i >= 0;) - if (auto* tlw = windows[i]) - tlw->setWindowActive (isWindowActive (tlw)); - - Desktop::getInstance().triggerFocusCallback(); - } - } - - bool addWindow (TopLevelWindow* const w) - { - windows.add (w); - checkFocusAsync(); - - return isWindowActive (w); - } - - void removeWindow (TopLevelWindow* const w) - { - checkFocusAsync(); - - if (currentActive == w) - currentActive = nullptr; - - windows.removeFirstMatchingValue (w); - - if (windows.isEmpty()) - deleteInstance(); - } - - Array windows; - -private: - TopLevelWindow* currentActive = nullptr; - - void timerCallback() override - { - checkFocus(); - } - - bool isWindowActive (TopLevelWindow* const tlw) const - { - return (tlw == currentActive - || tlw->isParentOf (currentActive) - || tlw->hasKeyboardFocus (true)) - && tlw->isShowing(); - } - - TopLevelWindow* findCurrentlyActiveWindow() const - { - if (Process::isForegroundProcess()) - { - auto* focusedComp = Component::getCurrentlyFocusedComponent(); - auto* w = dynamic_cast (focusedComp); - - if (w == nullptr && focusedComp != nullptr) - w = focusedComp->findParentComponentOfClass(); - - if (w == nullptr) - w = currentActive; - - if (w != nullptr && w->isShowing()) - return w; - } - - return nullptr; - } - - JUCE_DECLARE_NON_COPYABLE (TopLevelWindowManager) -}; - -JUCE_IMPLEMENT_SINGLETON (TopLevelWindowManager) - -void juce_checkCurrentlyFocusedTopLevelWindow(); -void juce_checkCurrentlyFocusedTopLevelWindow() -{ - if (auto* wm = TopLevelWindowManager::getInstanceWithoutCreating()) - wm->checkFocusAsync(); -} - //============================================================================== TopLevelWindow::TopLevelWindow (const String& name, const bool shouldAddToDesktop) : Component (name) @@ -145,19 +41,19 @@ TopLevelWindow::TopLevelWindow (const String& name, const bool shouldAddToDeskto setWantsKeyboardFocus (true); setBroughtToFrontOnMouseClick (true); - isCurrentlyActive = TopLevelWindowManager::getInstance()->addWindow (this); + isCurrentlyActive = detail::TopLevelWindowManager::getInstance()->addWindow (this); } TopLevelWindow::~TopLevelWindow() { shadower = nullptr; - TopLevelWindowManager::getInstance()->removeWindow (this); + detail::TopLevelWindowManager::getInstance()->removeWindow (this); } //============================================================================== void TopLevelWindow::focusOfChildComponentChanged (FocusChangeType) { - auto* wm = TopLevelWindowManager::getInstance(); + auto* wm = detail::TopLevelWindowManager::getInstance(); if (hasKeyboardFocus (true)) wm->checkFocus(); @@ -239,7 +135,7 @@ void TopLevelWindow::setUsingNativeTitleBar (const bool shouldUseNativeTitleBar) { if (useNativeTitleBar != shouldUseNativeTitleBar) { - FocusRestorer focusRestorer; + detail::FocusRestorer focusRestorer; useNativeTitleBar = shouldUseNativeTitleBar; recreateDesktopWindow(); sendLookAndFeelChange(); @@ -320,12 +216,12 @@ void TopLevelWindow::centreAroundComponent (Component* c, const int width, const //============================================================================== int TopLevelWindow::getNumTopLevelWindows() noexcept { - return TopLevelWindowManager::getInstance()->windows.size(); + return detail::TopLevelWindowManager::getInstance()->windows.size(); } TopLevelWindow* TopLevelWindow::getTopLevelWindow (const int index) noexcept { - return TopLevelWindowManager::getInstance()->windows [index]; + return detail::TopLevelWindowManager::getInstance()->windows [index]; } TopLevelWindow* TopLevelWindow::getActiveTopLevelWindow() noexcept diff --git a/modules/juce_gui_basics/windows/juce_TopLevelWindow.h b/modules/juce_gui_basics/windows/juce_TopLevelWindow.h index cea30cccac..c8ea061d52 100644 --- a/modules/juce_gui_basics/windows/juce_TopLevelWindow.h +++ b/modules/juce_gui_basics/windows/juce_TopLevelWindow.h @@ -154,7 +154,7 @@ protected: void visibilityChanged() override; private: - friend class TopLevelWindowManager; + friend class detail::TopLevelWindowManager; friend class ResizableWindow; bool useDropShadow = true, useNativeTitleBar = false, isCurrentlyActive = false; std::unique_ptr shadower;