From fed4f37736945cef967909ea3e24d4fc75ea4e8b Mon Sep 17 00:00:00 2001 From: Evgeny Gorodetskiy Date: Sun, 29 Nov 2026 18:15:26 +0300 Subject: [PATCH 1/7] Refactor Platform modules into groups by platform support Restructure Modules/Platform from CMake modules which supported all platforms at once into bunches of modules grouped by platform support, mirroring the Modules/Graphics/RHI layout: Interfaces --> Base --> { Windows | Linux | MacOS | iOS } --> Impl Common ----------------------------------------^ Exactly one platform group is added to the build, selected by the target platform in Modules/Platform/CMakeLists.txt. Only the Impl group targets are meant to be linked from other domains, so all target names used outside Modules/Platform are unchanged: MethanePlatformApp, MethanePlatformAppView, MethanePlatformInputKeyboard and MethanePlatformUtils. App module split: - Interfaces/App (MethanePlatformAppInterface) - Platform::IApp - Base/App (MethanePlatformAppBase) - Platform::Base::App (was AppBase) - Windows/App (MethanePlatformAppWindows) - Platform::Windows::App (was AppWin) - Linux/App (MethanePlatformAppLinux) - Platform::Linux::App (was AppLin) - MacOS/App (MethanePlatformAppMacOS) - Platform::MacOS::App (was AppMac) - iOS/App (MethanePlatformAppIOS) - Platform::iOS::App (was AppIOS) - Common/App (MethanePlatformAppCommon) - Platform::AppController - Impl/App (MethanePlatformApp) - Platform::App alias AppView, Input and Utils modules are regrouped the same way, with the per-platform AppEnvironment, AppViewMetal, Keyboard and Utils headers and sources moved under their platform group, and the platform-independent Mouse, Controllers and ActionControllers modules moved under Common. Platform dispatch #includes are removed from Methane/Platform/Utils.h and Methane/Platform/Input/Keyboard.h, which now live in the Base group and carry only platform-independent declarations; the native Keyboard::NativeKey struct and the platform utility functions are included directly from the platform group headers by the platform-specific code that needs them. Platform::AppSettings setters moved from Base/App.cpp into the Interfaces/App module, next to the struct they belong to. Verified on Windows with the VS2022-Win64-DX and VS2022-Win64-VK presets (Debug build clean, 493/493 unit tests passing). Linux, MacOS and iOS sources are updated accordingly but still have to be verified natively. Refs #165 Co-Authored-By: Claude Opus 5 --- .codecov.yml | 8 +- Apps/01-HelloTriangle/README.md | 2 +- Apps/02-HelloCube/README.md | 2 +- Apps/03-TexturedCube/README.md | 2 +- Apps/04-ShadowCube/README.md | 2 +- Apps/05-Typography/README.md | 4 +- Apps/06-CubeMapArray/README.md | 2 +- Apps/07-ParallelRendering/README.md | 4 +- .../App/Include/Methane/Graphics/AppBase.h | 2 +- Modules/Graphics/App/README.md | 8 +- .../Methane/Graphics/AppController.cpp | 2 +- Modules/Platform/App/CMakeLists.txt | 151 ---------------- Modules/Platform/App/README.md | 55 ------ .../App/Sources/Methane/Platform/IApp.cpp | 3 - Modules/Platform/AppView/CMakeLists.txt | 107 ------------ Modules/Platform/Apple/CMakeLists.txt | 1 + Modules/Platform/Apple/Utils/CMakeLists.txt | 65 +++++++ .../Include/Methane/Platform/Apple/Types.hh | 0 .../Include/Methane/Platform/Apple/Utils.hh | 0 .../Sources/Methane/Platform/Apple/Utils.mm | 0 Modules/Platform/Base/App/CMakeLists.txt | 65 +++++++ .../App/Include/Methane/Platform/Base/App.h} | 30 ++-- .../Sources/Methane/Platform/Base/App.cpp} | 85 +++------ Modules/Platform/Base/CMakeLists.txt | 3 + Modules/Platform/Base/Input/CMakeLists.txt | 1 + .../{ => Base}/Input/Keyboard/CMakeLists.txt | 33 +--- .../Include/Methane/Platform/Input/Keyboard.h | 15 +- .../Methane/Platform/Input/Keyboard.cpp | 0 .../Platform/{ => Base}/Utils/CMakeLists.txt | 62 ++----- .../Utils/Include/Methane/Platform/Logger.h | 0 .../Utils/Include/Methane/Platform/Utils.h | 15 +- .../Utils/Sources/Methane/Platform/Utils.cpp | 0 Modules/Platform/CMakeLists.txt | 25 ++- Modules/Platform/Common/App/CMakeLists.txt | 57 +++++++ .../Include/Methane/Platform/AppController.h | 6 +- .../Methane/Platform/AppController.cpp | 2 +- Modules/Platform/Common/CMakeLists.txt | 2 + .../Input/ActionControllers/CMakeLists.txt | 2 +- .../Input/KeyboardActionControllerBase.hpp | 0 .../Input/MouseActionControllerBase.hpp | 0 .../{ => Common}/Input/CMakeLists.txt | 1 - .../Input/Controllers/CMakeLists.txt | 2 +- .../Methane/Platform/Input/Controller.h | 0 .../Methane/Platform/Input/ControllersPool.h | 0 .../Platform/Input/IActionController.h | 0 .../Methane/Platform/Input/IController.h | 0 .../Methane/Platform/Input/IHelpProvider.h | 0 .../Include/Methane/Platform/Input/State.h | 0 .../Platform/Input/ControllersPool.cpp | 0 .../Sources/Methane/Platform/Input/State.cpp | 0 .../{ => Common}/Input/Mouse/CMakeLists.txt | 2 +- .../Include/Methane/Platform/Input/Mouse.h | 0 .../Sources/Methane/Platform/Input/Mouse.cpp | 0 Modules/Platform/Impl/App/CMakeLists.txt | 51 ++++++ .../App/Include/Methane/Platform/App.h | 21 +-- Modules/Platform/Impl/App/README.md | 88 ++++++++++ Modules/Platform/Impl/AppView/CMakeLists.txt | 62 +++++++ .../Include/Methane/Platform/AppEnvironment.h | 8 +- .../Include/Methane/Platform/AppView.h | 4 +- .../Sources/Methane/Platform/AppView.cpp | 0 Modules/Platform/Impl/CMakeLists.txt | 4 + Modules/Platform/Impl/Input/CMakeLists.txt | 1 + .../Impl/Input/Keyboard/CMakeLists.txt | 23 +++ Modules/Platform/Impl/Utils/CMakeLists.txt | 22 +++ .../Platform/Interfaces/App/CMakeLists.txt | 55 ++++++ .../App/Include/Methane/Platform/IApp.h | 0 .../App/Sources/Methane/Platform/IApp.cpp | 65 +++++++ Modules/Platform/Interfaces/CMakeLists.txt | 1 + Modules/Platform/Linux/App/CMakeLists.txt | 76 +++++++++ .../App/Include/Methane/Platform/Linux/App.h} | 18 +- .../Sources/Methane/Platform/Linux/App.cpp} | 72 ++++---- .../Methane/Platform/Linux/MessageBox.cpp | 4 +- .../Methane/Platform/Linux/MessageBox.h | 4 +- .../Methane/Platform/Linux/XcbUtils.cpp | 2 +- .../Sources/Methane/Platform/Linux/XcbUtils.h | 1 + Modules/Platform/Linux/AppView/CMakeLists.txt | 35 ++++ .../Methane/Platform/Linux/AppEnvironment.h | 0 Modules/Platform/Linux/CMakeLists.txt | 4 + Modules/Platform/Linux/Input/CMakeLists.txt | 1 + .../Linux/Input/Keyboard/CMakeLists.txt | 59 +++++++ .../Methane/Platform/Input/Linux/Keyboard.h | 0 .../Methane/Platform/Input/Linux/Keyboard.cpp | 1 + Modules/Platform/Linux/Utils/CMakeLists.txt | 56 ++++++ .../Include/Methane/Platform/Linux/Utils.h | 0 .../Sources/Methane/Platform/Linux/Utils.cpp | 0 Modules/Platform/MacOS/App/CMakeLists.txt | 81 +++++++++ .../Include/Methane/Platform/MacOS/App.hh} | 22 +-- .../Sources/Methane/Platform/MacOS/App.mm} | 52 +++--- .../Methane/Platform/MacOS/AppDelegate.hh | 6 +- .../Methane/Platform/MacOS/AppDelegate.mm | 8 +- .../Platform/MacOS/AppViewController.hh | 6 +- .../Platform/MacOS/AppViewController.mm | 8 +- .../Methane/Platform/MacOS/WindowDelegate.hh | 4 +- .../Methane/Platform/MacOS/WindowDelegate.mm | 6 +- Modules/Platform/MacOS/AppView/CMakeLists.txt | 67 ++++++++ .../Methane/Platform/MacOS/AppEnvironment.hh | 0 .../Methane/Platform/MacOS/AppViewMetal.hh | 0 .../Methane/Platform/MacOS/AppViewMetal.mm | 0 Modules/Platform/MacOS/CMakeLists.txt | 3 + Modules/Platform/MacOS/Input/CMakeLists.txt | 1 + .../MacOS/Input/Keyboard/CMakeLists.txt | 66 +++++++ .../Methane/Platform/Input/MacOS/Keyboard.h | 0 .../Methane/Platform/Input/MacOS/Keyboard.mm | 1 + Modules/Platform/README.md | 161 +++++++++++++++--- Modules/Platform/Windows/App/CMakeLists.txt | 69 ++++++++ .../Include/Methane/Platform/Windows/App.h} | 18 +- .../Sources/Methane/Platform/Windows/App.cpp} | 70 ++++---- .../Platform/Windows/ConsoleStreams.cpp | 4 +- .../Methane/Platform/Windows/ConsoleStreams.h | 4 +- .../Platform/Windows/AppView/CMakeLists.txt | 35 ++++ .../Methane/Platform/Windows/AppEnvironment.h | 0 Modules/Platform/Windows/CMakeLists.txt | 4 + Modules/Platform/Windows/Input/CMakeLists.txt | 1 + .../Windows/Input/Keyboard/CMakeLists.txt | 57 +++++++ .../Methane/Platform/Input/Windows/Keyboard.h | 0 .../Platform/Input/Windows/Keyboard.cpp | 1 + Modules/Platform/Windows/Utils/CMakeLists.txt | 56 ++++++ .../Include/Methane/Platform/Windows/Utils.h | 0 .../Methane/Platform/Windows/Utils.cpp | 0 Modules/Platform/iOS/App/CMakeLists.txt | 78 +++++++++ .../App/Include/Methane/Platform/iOS/App.hh} | 22 +-- .../App/Sources/Methane/Platform/iOS/App.mm} | 52 +++--- .../Methane/Platform/iOS/AppDelegate.hh | 4 +- .../Methane/Platform/iOS/AppDelegate.mm | 6 +- .../Methane/Platform/iOS/AppViewController.hh | 6 +- .../Methane/Platform/iOS/AppViewController.mm | 10 +- Modules/Platform/iOS/AppView/CMakeLists.txt | 67 ++++++++ .../Methane/Platform/iOS/AppEnvironment.hh | 0 .../Methane/Platform/iOS/AppViewMetal.hh | 0 .../Methane/Platform/iOS/AppViewMetal.mm | 0 Modules/Platform/iOS/CMakeLists.txt | 2 + .../App/Include/Methane/UserInterface/App.hpp | 6 +- Tests/Platform/Input/README.md | 14 +- Tests/Platform/README.md | 12 +- 134 files changed, 1877 insertions(+), 779 deletions(-) delete mode 100644 Modules/Platform/App/CMakeLists.txt delete mode 100644 Modules/Platform/App/README.md delete mode 100644 Modules/Platform/App/Sources/Methane/Platform/IApp.cpp delete mode 100644 Modules/Platform/AppView/CMakeLists.txt create mode 100644 Modules/Platform/Apple/CMakeLists.txt create mode 100644 Modules/Platform/Apple/Utils/CMakeLists.txt rename Modules/Platform/{ => Apple}/Utils/Include/Methane/Platform/Apple/Types.hh (100%) rename Modules/Platform/{ => Apple}/Utils/Include/Methane/Platform/Apple/Utils.hh (100%) rename Modules/Platform/{ => Apple}/Utils/Sources/Methane/Platform/Apple/Utils.mm (100%) create mode 100644 Modules/Platform/Base/App/CMakeLists.txt rename Modules/Platform/{App/Include/Methane/Platform/AppBase.h => Base/App/Include/Methane/Platform/Base/App.h} (90%) rename Modules/Platform/{App/Sources/Methane/Platform/AppBase.cpp => Base/App/Sources/Methane/Platform/Base/App.cpp} (83%) create mode 100644 Modules/Platform/Base/CMakeLists.txt create mode 100644 Modules/Platform/Base/Input/CMakeLists.txt rename Modules/Platform/{ => Base}/Input/Keyboard/CMakeLists.txt (52%) rename Modules/Platform/{ => Base}/Input/Keyboard/Include/Methane/Platform/Input/Keyboard.h (97%) rename Modules/Platform/{ => Base}/Input/Keyboard/Sources/Methane/Platform/Input/Keyboard.cpp (100%) rename Modules/Platform/{ => Base}/Utils/CMakeLists.txt (51%) rename Modules/Platform/{ => Base}/Utils/Include/Methane/Platform/Logger.h (100%) rename Modules/Platform/{ => Base}/Utils/Include/Methane/Platform/Utils.h (91%) rename Modules/Platform/{ => Base}/Utils/Sources/Methane/Platform/Utils.cpp (100%) create mode 100644 Modules/Platform/Common/App/CMakeLists.txt rename Modules/Platform/{ => Common}/App/Include/Methane/Platform/AppController.h (94%) rename Modules/Platform/{ => Common}/App/Sources/Methane/Platform/AppController.cpp (95%) create mode 100644 Modules/Platform/Common/CMakeLists.txt rename Modules/Platform/{ => Common}/Input/ActionControllers/CMakeLists.txt (95%) rename Modules/Platform/{ => Common}/Input/ActionControllers/Include/Methane/Platform/Input/KeyboardActionControllerBase.hpp (100%) rename Modules/Platform/{ => Common}/Input/ActionControllers/Include/Methane/Platform/Input/MouseActionControllerBase.hpp (100%) rename Modules/Platform/{ => Common}/Input/CMakeLists.txt (76%) rename Modules/Platform/{ => Common}/Input/Controllers/CMakeLists.txt (96%) rename Modules/Platform/{ => Common}/Input/Controllers/Include/Methane/Platform/Input/Controller.h (100%) rename Modules/Platform/{ => Common}/Input/Controllers/Include/Methane/Platform/Input/ControllersPool.h (100%) rename Modules/Platform/{ => Common}/Input/Controllers/Include/Methane/Platform/Input/IActionController.h (100%) rename Modules/Platform/{ => Common}/Input/Controllers/Include/Methane/Platform/Input/IController.h (100%) rename Modules/Platform/{ => Common}/Input/Controllers/Include/Methane/Platform/Input/IHelpProvider.h (100%) rename Modules/Platform/{ => Common}/Input/Controllers/Include/Methane/Platform/Input/State.h (100%) rename Modules/Platform/{ => Common}/Input/Controllers/Sources/Methane/Platform/Input/ControllersPool.cpp (100%) rename Modules/Platform/{ => Common}/Input/Controllers/Sources/Methane/Platform/Input/State.cpp (100%) rename Modules/Platform/{ => Common}/Input/Mouse/CMakeLists.txt (95%) rename Modules/Platform/{ => Common}/Input/Mouse/Include/Methane/Platform/Input/Mouse.h (100%) rename Modules/Platform/{ => Common}/Input/Mouse/Sources/Methane/Platform/Input/Mouse.cpp (100%) create mode 100644 Modules/Platform/Impl/App/CMakeLists.txt rename Modules/Platform/{ => Impl}/App/Include/Methane/Platform/App.h (71%) create mode 100644 Modules/Platform/Impl/App/README.md create mode 100644 Modules/Platform/Impl/AppView/CMakeLists.txt rename Modules/Platform/{ => Impl}/AppView/Include/Methane/Platform/AppEnvironment.h (83%) rename Modules/Platform/{ => Impl}/AppView/Include/Methane/Platform/AppView.h (94%) rename Modules/Platform/{ => Impl}/AppView/Sources/Methane/Platform/AppView.cpp (100%) create mode 100644 Modules/Platform/Impl/CMakeLists.txt create mode 100644 Modules/Platform/Impl/Input/CMakeLists.txt create mode 100644 Modules/Platform/Impl/Input/Keyboard/CMakeLists.txt create mode 100644 Modules/Platform/Impl/Utils/CMakeLists.txt create mode 100644 Modules/Platform/Interfaces/App/CMakeLists.txt rename Modules/Platform/{ => Interfaces}/App/Include/Methane/Platform/IApp.h (100%) create mode 100644 Modules/Platform/Interfaces/App/Sources/Methane/Platform/IApp.cpp create mode 100644 Modules/Platform/Interfaces/CMakeLists.txt create mode 100644 Modules/Platform/Linux/App/CMakeLists.txt rename Modules/Platform/{App/Include/Methane/Platform/Linux/AppLin.h => Linux/App/Include/Methane/Platform/Linux/App.h} (91%) rename Modules/Platform/{App/Sources/Methane/Platform/Linux/AppLin.cpp => Linux/App/Sources/Methane/Platform/Linux/App.cpp} (90%) rename Modules/Platform/{ => Linux}/App/Sources/Methane/Platform/Linux/MessageBox.cpp (99%) rename Modules/Platform/{ => Linux}/App/Sources/Methane/Platform/Linux/MessageBox.h (96%) rename Modules/Platform/{ => Linux}/App/Sources/Methane/Platform/Linux/XcbUtils.cpp (99%) rename Modules/Platform/{ => Linux}/App/Sources/Methane/Platform/Linux/XcbUtils.h (99%) create mode 100644 Modules/Platform/Linux/AppView/CMakeLists.txt rename Modules/Platform/{ => Linux}/AppView/Include/Methane/Platform/Linux/AppEnvironment.h (100%) create mode 100644 Modules/Platform/Linux/CMakeLists.txt create mode 100644 Modules/Platform/Linux/Input/CMakeLists.txt create mode 100644 Modules/Platform/Linux/Input/Keyboard/CMakeLists.txt rename Modules/Platform/{ => Linux}/Input/Keyboard/Include/Methane/Platform/Input/Linux/Keyboard.h (100%) rename Modules/Platform/{ => Linux}/Input/Keyboard/Sources/Methane/Platform/Input/Linux/Keyboard.cpp (99%) create mode 100644 Modules/Platform/Linux/Utils/CMakeLists.txt rename Modules/Platform/{ => Linux}/Utils/Include/Methane/Platform/Linux/Utils.h (100%) rename Modules/Platform/{ => Linux}/Utils/Sources/Methane/Platform/Linux/Utils.cpp (100%) create mode 100644 Modules/Platform/MacOS/App/CMakeLists.txt rename Modules/Platform/{App/Include/Methane/Platform/MacOS/AppMac.hh => MacOS/App/Include/Methane/Platform/MacOS/App.hh} (82%) rename Modules/Platform/{App/Sources/Methane/Platform/MacOS/AppMac.mm => MacOS/App/Sources/Methane/Platform/MacOS/App.mm} (72%) rename Modules/Platform/{ => MacOS}/App/Sources/Methane/Platform/MacOS/AppDelegate.hh (83%) rename Modules/Platform/{ => MacOS}/App/Sources/Methane/Platform/MacOS/AppDelegate.mm (95%) rename Modules/Platform/{ => MacOS}/App/Sources/Methane/Platform/MacOS/AppViewController.hh (83%) rename Modules/Platform/{ => MacOS}/App/Sources/Methane/Platform/MacOS/AppViewController.mm (97%) rename Modules/Platform/{ => MacOS}/App/Sources/Methane/Platform/MacOS/WindowDelegate.hh (87%) rename Modules/Platform/{ => MacOS}/App/Sources/Methane/Platform/MacOS/WindowDelegate.mm (96%) create mode 100644 Modules/Platform/MacOS/AppView/CMakeLists.txt rename Modules/Platform/{ => MacOS}/AppView/Include/Methane/Platform/MacOS/AppEnvironment.hh (100%) rename Modules/Platform/{ => MacOS}/AppView/Include/Methane/Platform/MacOS/AppViewMetal.hh (100%) rename Modules/Platform/{ => MacOS}/AppView/Sources/Methane/Platform/MacOS/AppViewMetal.mm (100%) create mode 100644 Modules/Platform/MacOS/CMakeLists.txt create mode 100644 Modules/Platform/MacOS/Input/CMakeLists.txt create mode 100644 Modules/Platform/MacOS/Input/Keyboard/CMakeLists.txt rename Modules/Platform/{ => MacOS}/Input/Keyboard/Include/Methane/Platform/Input/MacOS/Keyboard.h (100%) rename Modules/Platform/{ => MacOS}/Input/Keyboard/Sources/Methane/Platform/Input/MacOS/Keyboard.mm (99%) create mode 100644 Modules/Platform/Windows/App/CMakeLists.txt rename Modules/Platform/{App/Include/Methane/Platform/Windows/AppWin.h => Windows/App/Include/Methane/Platform/Windows/App.h} (89%) rename Modules/Platform/{App/Sources/Methane/Platform/Windows/AppWin.cpp => Windows/App/Sources/Methane/Platform/Windows/App.cpp} (91%) rename Modules/Platform/{ => Windows}/App/Sources/Methane/Platform/Windows/ConsoleStreams.cpp (96%) rename Modules/Platform/{ => Windows}/App/Sources/Methane/Platform/Windows/ConsoleStreams.h (96%) create mode 100644 Modules/Platform/Windows/AppView/CMakeLists.txt rename Modules/Platform/{ => Windows}/AppView/Include/Methane/Platform/Windows/AppEnvironment.h (100%) create mode 100644 Modules/Platform/Windows/CMakeLists.txt create mode 100644 Modules/Platform/Windows/Input/CMakeLists.txt create mode 100644 Modules/Platform/Windows/Input/Keyboard/CMakeLists.txt rename Modules/Platform/{ => Windows}/Input/Keyboard/Include/Methane/Platform/Input/Windows/Keyboard.h (100%) rename Modules/Platform/{ => Windows}/Input/Keyboard/Sources/Methane/Platform/Input/Windows/Keyboard.cpp (99%) create mode 100644 Modules/Platform/Windows/Utils/CMakeLists.txt rename Modules/Platform/{ => Windows}/Utils/Include/Methane/Platform/Windows/Utils.h (100%) rename Modules/Platform/{ => Windows}/Utils/Sources/Methane/Platform/Windows/Utils.cpp (100%) create mode 100644 Modules/Platform/iOS/App/CMakeLists.txt rename Modules/Platform/{App/Include/Methane/Platform/iOS/AppIOS.hh => iOS/App/Include/Methane/Platform/iOS/App.hh} (78%) rename Modules/Platform/{App/Sources/Methane/Platform/iOS/AppIOS.mm => iOS/App/Sources/Methane/Platform/iOS/App.mm} (67%) rename Modules/Platform/{ => iOS}/App/Sources/Methane/Platform/iOS/AppDelegate.hh (93%) rename Modules/Platform/{ => iOS}/App/Sources/Methane/Platform/iOS/AppDelegate.mm (96%) rename Modules/Platform/{ => iOS}/App/Sources/Methane/Platform/iOS/AppViewController.hh (84%) rename Modules/Platform/{ => iOS}/App/Sources/Methane/Platform/iOS/AppViewController.mm (96%) create mode 100644 Modules/Platform/iOS/AppView/CMakeLists.txt rename Modules/Platform/{ => iOS}/AppView/Include/Methane/Platform/iOS/AppEnvironment.hh (100%) rename Modules/Platform/{ => iOS}/AppView/Include/Methane/Platform/iOS/AppViewMetal.hh (100%) rename Modules/Platform/{ => iOS}/AppView/Sources/Methane/Platform/iOS/AppViewMetal.mm (100%) create mode 100644 Modules/Platform/iOS/CMakeLists.txt diff --git a/.codecov.yml b/.codecov.yml index 64c08511f..f5c4be36c 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -55,20 +55,20 @@ component_management: - component_id: platform-utils name: Platform Utils paths: - - Modules/Platform/Utils/** + - Modules/Platform/*/Utils/** - component_id: platform-input name: Platform Input paths: - - Modules/Platform/Input/** + - Modules/Platform/*/Input/** - Tests/Platform/Input/** - component_id: platform-app-view name: Platform App-View paths: - - Modules/Platform/AppView/** + - Modules/Platform/*/AppView/** - component_id: platform-app name: Platform App paths: - - Modules/Platform/App/** + - Modules/Platform/*/App/** - component_id: graphics-types name: Graphics Types paths: diff --git a/Apps/01-HelloTriangle/README.md b/Apps/01-HelloTriangle/README.md index e5fd39637..f6b666a74 100644 --- a/Apps/01-HelloTriangle/README.md +++ b/Apps/01-HelloTriangle/README.md @@ -18,7 +18,7 @@ The tutorial covers the following Methane Kit features and techniques: ## Application Controls Common keyboard controls are enabled by the `Platform` and `Graphics` application controllers: -- [Methane::Platform::AppController](/Modules/Platform/App/README.md#platform-application-controller) +- [Methane::Platform::AppController](/Modules/Platform/Impl/App/README.md#platform-application-controller) - [Methane::Graphics::AppController, AppContextController](/Modules/Graphics/App/README.md#graphics-application-controllers) ## Application and Frame Class Definitions diff --git a/Apps/02-HelloCube/README.md b/Apps/02-HelloCube/README.md index 40b9c8c35..00470b4cd 100644 --- a/Apps/02-HelloCube/README.md +++ b/Apps/02-HelloCube/README.md @@ -24,7 +24,7 @@ The tutorial demonstrates the following Methane Kit features and techniques in a ## Application Controls Common keyboard controls are enabled by the `Platform` and `Graphics` application controllers: -- [Methane::Platform::AppController](/Modules/Platform/App/README.md#platform-application-controller) +- [Methane::Platform::AppController](/Modules/Platform/Impl/App/README.md#platform-application-controller) - [Methane::Graphics::AppController, AppContextController](/Modules/Graphics/App/README.md#graphics-application-controllers) ## Simple Cube Vertices Transformation on CPU diff --git a/Apps/03-TexturedCube/README.md b/Apps/03-TexturedCube/README.md index f98413502..99f17c61c 100644 --- a/Apps/03-TexturedCube/README.md +++ b/Apps/03-TexturedCube/README.md @@ -20,7 +20,7 @@ Tutorial demonstrates the following Methane Kit features in addition to those de ## Application Controls Common keyboard controls are enabled by the `Platform`, `Graphics` and `UserInterface` application controllers: -- [Methane::Platform::AppController](/Modules/Platform/App/README.md#platform-application-controller) +- [Methane::Platform::AppController](/Modules/Platform/Impl/App/README.md#platform-application-controller) - [Methane::Graphics::AppController, AppContextController](/Modules/Graphics/App/README.md#graphics-application-controllers) - [Methane::UserInterface::AppController](/Modules/UserInterface/App/README.md#user-interface-application-controllers) diff --git a/Apps/04-ShadowCube/README.md b/Apps/04-ShadowCube/README.md index d537d79a2..a003f29dd 100644 --- a/Apps/04-ShadowCube/README.md +++ b/Apps/04-ShadowCube/README.md @@ -22,7 +22,7 @@ Tutorial demonstrates the use of the following Methane Kit features in addition ## Application Controls Common keyboard controls are enabled by the `Platform`, `Graphics` and `UserInterface` application controllers: -- [Methane::Platform::AppController](/Modules/Platform/App/README.md#platform-application-controller) +- [Methane::Platform::AppController](/Modules/Platform/Impl/App/README.md#platform-application-controller) - [Methane::Graphics::AppController, AppContextController](/Modules/Graphics/App/README.md#graphics-application-controllers) - [Methane::UserInterface::AppController](/Modules/UserInterface/App/README.md#user-interface-application-controllers) diff --git a/Apps/05-Typography/README.md b/Apps/05-Typography/README.md index 2a057242e..916f498de 100644 --- a/Apps/05-Typography/README.md +++ b/Apps/05-Typography/README.md @@ -16,7 +16,7 @@ characters and words. Right-to-left and Arabic language character layout is not ## Application Controls Keyboard actions are enabled with [TypographyAppController](TypographyAppController.h) class -derived from [Platform::Input::Keyboard::ActionControllerBase](/Modules/Platform/Input/ActionControllers/Include/Methane/Platform/Input/KeyboardActionControllerBase.hpp): +derived from [Platform::Input::Keyboard::ActionControllerBase](/Modules/Platform/Common/Input/ActionControllers/Include/Methane/Platform/Input/KeyboardActionControllerBase.hpp): | Typography App Action | Keyboard Shortcut | |-----------------------------------------------------------------|-------------------| @@ -29,7 +29,7 @@ derived from [Platform::Input::Keyboard::ActionControllerBase](/Modules/Platform | Slowdown Typing | `-` | Common keyboard controls are enabled by the `Platform`, `Graphics` and `UserInterface` application controllers: -- [Methane::Platform::AppController](/Modules/Platform/App/README.md#platform-application-controller) +- [Methane::Platform::AppController](/Modules/Platform/Impl/App/README.md#platform-application-controller) - [Methane::Graphics::AppController, AppContextController](/Modules/Graphics/App/README.md#graphics-application-controllers) - [Methane::UserInterface::AppController](/Modules/UserInterface/App/README.md#user-interface-application-controllers) diff --git a/Apps/06-CubeMapArray/README.md b/Apps/06-CubeMapArray/README.md index 2824f1743..6a48adfaf 100644 --- a/Apps/06-CubeMapArray/README.md +++ b/Apps/06-CubeMapArray/README.md @@ -21,7 +21,7 @@ Tutorial demonstrates the following techniques: ## Application Controls Common keyboard controls are enabled by the `Platform`, `Graphics` and `UserInterface` application controllers: -- [Methane::Platform::AppController](/Modules/Platform/App/README.md#platform-application-controller) +- [Methane::Platform::AppController](/Modules/Platform/Impl/App/README.md#platform-application-controller) - [Methane::Graphics::AppController, AppContextController](/Modules/Graphics/App/README.md#graphics-application-controllers) - [Methane::UserInterface::AppController](/Modules/UserInterface/App/README.md#user-interface-application-controllers) diff --git a/Apps/07-ParallelRendering/README.md b/Apps/07-ParallelRendering/README.md index 3982be766..e9502a6b4 100644 --- a/Apps/07-ParallelRendering/README.md +++ b/Apps/07-ParallelRendering/README.md @@ -30,7 +30,7 @@ Tutorial demonstrates the following techniques: ## Application Controls Keyboard actions are enabled with [ParallelRenderingAppController](ParallelRenderingAppController.h) class -derived from [Platform::Input::Keyboard::ActionControllerBase](/Modules/Platform/Input/ActionControllers/Include/Methane/Platform/Input/KeyboardActionControllerBase.hpp): +derived from [Platform::Input::Keyboard::ActionControllerBase](/Modules/Platform/Common/Input/ActionControllers/Include/Methane/Platform/Input/KeyboardActionControllerBase.hpp): | Parallel Rendering App Action | Keyboard Shortcut | |-------------------------------|-------------------| @@ -41,7 +41,7 @@ derived from [Platform::Input::Keyboard::ActionControllerBase](/Modules/Platform | Decrease Render Threads Count | `[` | Common keyboard controls are enabled by the `Platform`, `Graphics` and `UserInterface` application controllers: -- [Methane::Platform::AppController](/Modules/Platform/App/README.md#platform-application-controller) +- [Methane::Platform::AppController](/Modules/Platform/Impl/App/README.md#platform-application-controller) - [Methane::Graphics::AppController, AppContextController](/Modules/Graphics/App/README.md#graphics-application-controllers) - [Methane::UserInterface::AppController](/Modules/UserInterface/App/README.md#user-interface-application-controllers) diff --git a/Modules/Graphics/App/Include/Methane/Graphics/AppBase.h b/Modules/Graphics/App/Include/Methane/Graphics/AppBase.h index 0142c5e58..ad4fe2a99 100644 --- a/Modules/Graphics/App/Include/Methane/Graphics/AppBase.h +++ b/Modules/Graphics/App/Include/Methane/Graphics/AppBase.h @@ -94,7 +94,7 @@ class AppBase // NOSONAR void CompleteInitialization() const; void WaitForRenderComplete() const; - // Platform::AppBase interface + // Platform::Base::App interface Platform::AppView GetView() const override { return m_context.GetAppView(); } // IContextCallback implementation diff --git a/Modules/Graphics/App/README.md b/Modules/Graphics/App/README.md index bafe1d355..c0949137f 100644 --- a/Modules/Graphics/App/README.md +++ b/Modules/Graphics/App/README.md @@ -1,6 +1,6 @@ # Graphics App -Graphics application rendering infrastructure implemented on top of [application platform abstraction](../../Platform/App) +Graphics application rendering infrastructure implemented on top of [application platform abstraction](../../Platform/Impl/App) and [graphics RHI API](../RHI). ## Graphics Application Base Class @@ -28,7 +28,7 @@ The following settings are available: ### [Graphics::App](Include/Methane/Graphics/App.hpp) -Graphics application base template class `Graphics::App` is derived from [Platform::App](../../Platform/App) +Graphics application base template class `Graphics::App` is derived from [Platform::App](../../Platform/Impl/App) extending it with common graphics application functionality implemented with [Graphics::RHI](../RHI) API: - Parsing graphics app and context settings from command line arguments. - Graphics render context initialization using provided settings. @@ -44,7 +44,7 @@ and extended with other frame-dependent resources in final applications. `Graphics::AppSettings` structure aggregates 3 setting structures passed all together to the `Graphics::App` constructor: - [Graphics::IApp::Settings](#graphicsiappincludemethanegraphicsapph) - graphics app settings described above -- [Platform::AppBase::Settings](../../Platform/App/README.md#platformappbaseincludemethaneplatformappbaseh) - platform app settings +- [Platform::AppSettings](../../Platform/Impl/App/README.md#platform-application-base-class) - platform app settings - [Graphics::RenderContextSettings](../RHI/Interface/Include/Methane/Graphics/IRenderContext.h) - render context settings Some parameters of the render context settings can be also changed with command line flags: @@ -60,7 +60,7 @@ Some parameters of the render context settings can be also changed with command ### [Graphics::AppController](Include/Methane/Graphics/AppController.h) -Graphics **application** controller is derived from [Platform application controller](../../Platform/App/README.md#platformappcontrollerincludemethaneplatformappcontrollerh) and +Graphics **application** controller is derived from [Platform application controller](../../Platform/Impl/App/README.md#platform-application-controller) and extends it with the following actions: | Application Action | Keyboard Shortcut | diff --git a/Modules/Graphics/App/Sources/Methane/Graphics/AppController.cpp b/Modules/Graphics/App/Sources/Methane/Graphics/AppController.cpp index de0f983df..707fda4a2 100644 --- a/Modules/Graphics/App/Sources/Methane/Graphics/AppController.cpp +++ b/Modules/Graphics/App/Sources/Methane/Graphics/AppController.cpp @@ -31,7 +31,7 @@ namespace Methane::Graphics AppController::AppController(IApp& application, const std::string& application_help, const Platform::AppController::ActionByKeyboardState& platform_action_by_keyboard_state, const Graphics::AppController::ActionByKeyboardState& graphics_action_by_keyboard_state) - : Platform::AppController(dynamic_cast(application), application_help, platform_action_by_keyboard_state) + : Platform::AppController(dynamic_cast(application), application_help, platform_action_by_keyboard_state) , pin::Keyboard::ActionControllerBase(graphics_action_by_keyboard_state, {}) , m_application(application) { } diff --git a/Modules/Platform/App/CMakeLists.txt b/Modules/Platform/App/CMakeLists.txt deleted file mode 100644 index 35f63828c..000000000 --- a/Modules/Platform/App/CMakeLists.txt +++ /dev/null @@ -1,151 +0,0 @@ -set(TARGET MethanePlatformApp) - -include(MethaneModules) - -get_module_dirs("Methane/Platform") - -if (WIN32) - - list(APPEND PLATFORM_HEADERS - ${INCLUDE_PLATFORM_OS_DIR}/AppWin.h - ) - - list(APPEND PLATFORM_SOURCES - ${SOURCES_PLATFORM_OS_DIR}/AppWin.cpp - ${SOURCES_PLATFORM_OS_DIR}/ConsoleStreams.h - ${SOURCES_PLATFORM_OS_DIR}/ConsoleStreams.cpp - ) - - list(APPEND PLATFORM_LIBRARIES - Shcore - ) - -elseif(APPLE) - - if (APPLE_MACOS) - list(APPEND PLATFORM_HEADERS - ${INCLUDE_PLATFORM_OS_DIR}/AppMac.hh - ${SOURCES_PLATFORM_OS_DIR}/WindowDelegate.hh - ) - list(APPEND PLATFORM_SOURCES - ${SOURCES_PLATFORM_OS_DIR}/AppMac.mm - ${SOURCES_PLATFORM_OS_DIR}/WindowDelegate.mm - ) - list(APPEND PLATFORM_LIBRARIES "-framework AppKit") - else() # iOS - list(APPEND PLATFORM_HEADERS - ${INCLUDE_PLATFORM_OS_DIR}/AppIOS.hh - ) - list(APPEND PLATFORM_SOURCES - ${SOURCES_PLATFORM_OS_DIR}/AppIOS.mm - ) - list(APPEND PLATFORM_LIBRARIES "-framework UIKit") - endif() # APPLE_MACOS - - list(APPEND PLATFORM_HEADERS - ${SOURCES_PLATFORM_OS_DIR}/AppDelegate.hh - ${SOURCES_PLATFORM_OS_DIR}/AppViewController.hh - ) - list(APPEND PLATFORM_SOURCES - ${SOURCES_PLATFORM_OS_DIR}/AppDelegate.mm - ${SOURCES_PLATFORM_OS_DIR}/AppViewController.mm - ) - -else(LINUX) - - list(APPEND PLATFORM_HEADERS - ${INCLUDE_PLATFORM_OS_DIR}/AppLin.h - ) - - list(APPEND PLATFORM_SOURCES - ${SOURCES_PLATFORM_OS_DIR}/AppLin.cpp - ${SOURCES_PLATFORM_OS_DIR}/MessageBox.h - ${SOURCES_PLATFORM_OS_DIR}/MessageBox.cpp - ${SOURCES_PLATFORM_OS_DIR}/XcbUtils.h - ${SOURCES_PLATFORM_OS_DIR}/XcbUtils.cpp - ) - - set(PLATFORM_LIBRARIES X11::X11 X11::X11_xcb X11::xcb X11::xcb_randr X11::xcb_sync STB) - -endif() - -list(APPEND HEADERS ${PLATFORM_HEADERS} - ${INCLUDE_DIR}/IApp.h - ${INCLUDE_DIR}/App.h - ${INCLUDE_DIR}/AppBase.h - ${INCLUDE_DIR}/AppController.h -) - -list(APPEND SOURCES ${PLATFORM_SOURCES} - ${SOURCES_DIR}/IApp.cpp - ${SOURCES_DIR}/AppBase.cpp - ${SOURCES_DIR}/AppController.cpp -) - -add_library(${TARGET} STATIC - ${HEADERS} - ${SOURCES} -) - -target_link_libraries(${TARGET} - PUBLIC - CLI11 - MethanePrimitives - MethaneInstrumentation - MethaneDataTypes - MethanePlatformAppView - MethanePlatformInputActionControllers - PRIVATE - MethaneBuildOptions - MethaneCommonPrecompiledHeaders - MethanePlatformUtils - MethaneDataProvider - TaskFlow - fmt - nowide - ${PLATFORM_LIBRARIES} -) - -target_compile_definitions(${TARGET} - PRIVATE - METHANE_RENDER_APP -) - -if(METHANE_PRECOMPILED_HEADERS_ENABLED) - target_precompile_headers(${TARGET} REUSE_FROM MethaneCommonPrecompiledHeaders) -endif() - -target_include_directories(${TARGET} - PRIVATE - Sources - PUBLIC - Include -) - -source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) - -set_target_properties(${TARGET} - PROPERTIES - FOLDER Modules/Platform - PUBLIC_HEADER "${HEADERS}" -) - -if (APPLE) - # Disable precompiled headers on MacOS for Objective-C files: - set_source_files_properties( - ${PLATFORM_SOURCES} - PROPERTIES - COMPILE_FLAGS -fobjc-arc - SKIP_PRECOMPILE_HEADERS ON - ) -endif() - -install(TARGETS ${TARGET} - PUBLIC_HEADER - DESTINATION ${INSTALL_INCLUDE_DIR} - COMPONENT Development - ARCHIVE - DESTINATION lib - COMPONENT Development -) - diff --git a/Modules/Platform/App/README.md b/Modules/Platform/App/README.md deleted file mode 100644 index 3f203b502..000000000 --- a/Modules/Platform/App/README.md +++ /dev/null @@ -1,55 +0,0 @@ -# Platform App - -Platform abstraction of the windowed application with main purpose for graphics content rendering. -Graphics rendering infrastructure itself is split into derived class defined in a separate library. - -### [Platform::App](Include/Methane/Platform/App.h) - -Defines alias type `Platform::App` pointing to one of platform-specific implementations of the `AppBase` abstract class: -- [Platform::AppWin](Include/Methane/Platform/Windows/AppWin.h) - Windows app implementation -- [Platform::AppLin](Include/Methane/Platform/Linux/AppLin.h) - Linux app implementation -- [Platform::AppMac](Include/Methane/Platform/MacOS/AppMac.hh) - MacOS app implementation -- [Platform::AppIOS](Include/Methane/Platform/iOS/AppIOS.hh) - iOS app implementation - -`Platform::App` should be used as a base class for any windowed Methane application. - -## Platform Application Base Classes - -### [Platform::AppBase](Include/Methane/Platform/AppBase.h) - -Base interface and platform-abstraction implementation of the application class with the following functionality: -- Initial application settings setup (see table below) -- Running application with a given command line arguments and parsing platform app settings from cmd arguments -- Live window resizing with frame re-render on resize iterations -- Switching window to full-screen mode -- Processing keyboard and mouse input via `Platform::Input::State` -- Adding [platform application controller](#platform-application-controller) to input state processor -- Setting title in window header -- Showing user alert in message box dialog -- Displaying application controls and command line help -- Shared parallel task execution engine with thread pool [Taskflow::Executor](../../../Externals/TaskFlow) - -The following settings are available in `Platform::AppBase::Settings` structure: - -| Setting | Type | Default Value | Cmd-Line Option | Description | -|----------------|----------|---------------|------------------|-----------------------| -| name | uint32_t | "" | | Application name displayed in window header | -| width | double | 0.8 | -w,--width | Main window width (if < 1.0 it is a ratio of desktop size; else size in pixels/dots) | -| height | double | 0.8 | -x,--height | Main window height (if < 1.0 it is a ratio of desktop size; else size in pixels/dots) | -| min_width | uint32_t | 640 | | Minimum window width in pixels/dots limited for resizing | -| min_height | uint32_t | 480 | | Minimum window height in pixels/dots limited for resizing | -| is_full_screen | bool | false | -f,--full-screen | Full-screen state of the main window | - -## Platform Application Controller - -### [Platform::AppController](Include/Methane/Platform/AppController.h) - -Platform application controller implements the following actions: - -| Action | Keyboard Shortcut | -|------------------------|---------------------| -| Show controls help | F1 | -| Show command-line help | F2 | -| Show parameters | F3 | -| Switch full-screen | LCtrl + F | -| Close application | LCtrl/LCmd + Q | diff --git a/Modules/Platform/App/Sources/Methane/Platform/IApp.cpp b/Modules/Platform/App/Sources/Methane/Platform/IApp.cpp deleted file mode 100644 index a261c9f3c..000000000 --- a/Modules/Platform/App/Sources/Methane/Platform/IApp.cpp +++ /dev/null @@ -1,3 +0,0 @@ -// -// Created by egorodet on 11/19/2022. -// diff --git a/Modules/Platform/AppView/CMakeLists.txt b/Modules/Platform/AppView/CMakeLists.txt deleted file mode 100644 index 1f1a9cc31..000000000 --- a/Modules/Platform/AppView/CMakeLists.txt +++ /dev/null @@ -1,107 +0,0 @@ -set(TARGET MethanePlatformAppView) - -include(MethaneModules) - -get_module_dirs("Methane/Platform") - -if (WIN32) - - list(APPEND PLATFORM_HEADERS - ${INCLUDE_PLATFORM_OS_DIR}/AppEnvironment.h - ) - -elseif(APPLE) - - list(APPEND PLATFORM_HEADERS - ${INCLUDE_PLATFORM_OS_DIR}/AppViewMetal.hh - ${INCLUDE_PLATFORM_OS_DIR}/AppEnvironment.hh - ) - - list(APPEND PLATFORM_SOURCES - ${SOURCES_PLATFORM_OS_DIR}/AppViewMetal.mm - ) - - list(APPEND PLATFORM_LIBRARIES - "-framework $,AppKit,UIKit>" - "-framework Metal" - "-framework QuartzCore" - ) - - # CLANG_ENABLE_OBJC_WEAK = YES - set_source_files_properties( - ${PLATFORM_SOURCES} - PROPERTIES - COMPILE_FLAGS -fobjc-weak - ) - -else() # Linux - - list(APPEND PLATFORM_HEADERS - ${INCLUDE_PLATFORM_OS_DIR}/AppEnvironment.h - ) - -endif() - -list(APPEND HEADERS - ${PLATFORM_HEADERS} - ${INCLUDE_DIR}/AppView.h - ${INCLUDE_DIR}/AppEnvironment.h -) - -list(APPEND SOURCES - ${PLATFORM_SOURCES} - ${SOURCES_DIR}/AppView.cpp -) - -add_library(${TARGET} STATIC - ${HEADERS} - ${SOURCES} -) - -target_link_libraries(${TARGET} - PRIVATE - MethaneBuildOptions - MethaneInstrumentation - MethaneDataTypes - ${PLATFORM_LIBRARIES} -) - -target_include_directories(${TARGET} - PRIVATE - Sources - PUBLIC - Include -) - -target_compile_definitions(${TARGET} - PRIVATE - $<$:METHANE_GPU_INSTRUMENTATION_ENABLED> -) - -source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) - -set_target_properties(${TARGET} - PROPERTIES - FOLDER Modules/Platform - PUBLIC_HEADER "${HEADERS}" -) - -if (APPLE) - # Disable precompiled headers and enable ARC on MacOS for Objective-C files: - set_source_files_properties( - ${PLATFORM_SOURCES} - PROPERTIES - COMPILE_FLAGS -fobjc-arc - SKIP_PRECOMPILE_HEADERS ON - ) -endif() - -install(TARGETS ${TARGET} - PUBLIC_HEADER - DESTINATION ${INSTALL_INCLUDE_DIR} - COMPONENT Development - ARCHIVE - DESTINATION lib - COMPONENT Development -) - diff --git a/Modules/Platform/Apple/CMakeLists.txt b/Modules/Platform/Apple/CMakeLists.txt new file mode 100644 index 000000000..e3ce185e0 --- /dev/null +++ b/Modules/Platform/Apple/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(Utils) diff --git a/Modules/Platform/Apple/Utils/CMakeLists.txt b/Modules/Platform/Apple/Utils/CMakeLists.txt new file mode 100644 index 000000000..6c829e754 --- /dev/null +++ b/Modules/Platform/Apple/Utils/CMakeLists.txt @@ -0,0 +1,65 @@ +set(TARGET MethanePlatformUtilsApple) + +include(MethaneModules) + +get_module_dirs("Methane/Platform") + +list(APPEND HEADERS + ${INCLUDE_PLATFORM_DIR}/Types.hh + ${INCLUDE_PLATFORM_DIR}/Utils.hh +) + +list(APPEND SOURCES + ${SOURCES_PLATFORM_DIR}/Utils.mm +) + +add_library(${TARGET} STATIC + ${HEADERS} + ${SOURCES} +) + +target_link_libraries(${TARGET} + PUBLIC + MethanePlatformUtilsBase + "-framework Foundation" + PRIVATE + MethaneBuildOptions + MethaneCommonPrecompiledHeaders + MethaneInstrumentation +) + +if(METHANE_PRECOMPILED_HEADERS_ENABLED) + target_precompile_headers(${TARGET} REUSE_FROM MethaneCommonPrecompiledHeaders) +endif() + +target_include_directories(${TARGET} + PRIVATE + Sources + PUBLIC + Include +) + +# Disable precompiled headers and enable ARC for Objective-C sources: +set_source_files_properties( + ${SOURCES} + PROPERTIES + COMPILE_FLAGS -fobjc-arc + SKIP_PRECOMPILE_HEADERS ON +) + +source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) + +set_target_properties(${TARGET} + PROPERTIES + FOLDER Modules/Platform/Apple + PUBLIC_HEADER "${HEADERS}" +) + +install(TARGETS ${TARGET} + PUBLIC_HEADER + DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_DIR} + COMPONENT Development + ARCHIVE + DESTINATION lib + COMPONENT Development +) diff --git a/Modules/Platform/Utils/Include/Methane/Platform/Apple/Types.hh b/Modules/Platform/Apple/Utils/Include/Methane/Platform/Apple/Types.hh similarity index 100% rename from Modules/Platform/Utils/Include/Methane/Platform/Apple/Types.hh rename to Modules/Platform/Apple/Utils/Include/Methane/Platform/Apple/Types.hh diff --git a/Modules/Platform/Utils/Include/Methane/Platform/Apple/Utils.hh b/Modules/Platform/Apple/Utils/Include/Methane/Platform/Apple/Utils.hh similarity index 100% rename from Modules/Platform/Utils/Include/Methane/Platform/Apple/Utils.hh rename to Modules/Platform/Apple/Utils/Include/Methane/Platform/Apple/Utils.hh diff --git a/Modules/Platform/Utils/Sources/Methane/Platform/Apple/Utils.mm b/Modules/Platform/Apple/Utils/Sources/Methane/Platform/Apple/Utils.mm similarity index 100% rename from Modules/Platform/Utils/Sources/Methane/Platform/Apple/Utils.mm rename to Modules/Platform/Apple/Utils/Sources/Methane/Platform/Apple/Utils.mm diff --git a/Modules/Platform/Base/App/CMakeLists.txt b/Modules/Platform/Base/App/CMakeLists.txt new file mode 100644 index 000000000..f78c5168d --- /dev/null +++ b/Modules/Platform/Base/App/CMakeLists.txt @@ -0,0 +1,65 @@ +set(TARGET MethanePlatformAppBase) + +include(MethaneModules) + +get_module_dirs("Methane/Platform") + +list(APPEND HEADERS + ${INCLUDE_DIR}/Base/App.h +) + +list(APPEND SOURCES + ${SOURCES_DIR}/Base/App.cpp +) + +add_library(${TARGET} STATIC + ${HEADERS} + ${SOURCES} +) + +target_link_libraries(${TARGET} + PUBLIC + CLI11 + MethanePrimitives + MethaneInstrumentation + MethaneDataTypes + MethanePlatformAppInterface + MethanePlatformAppView + MethanePlatformInputActionControllers + PRIVATE + MethaneBuildOptions + MethaneCommonPrecompiledHeaders + MethanePlatformUtils + MethaneDataProvider + TaskFlow + fmt + nowide +) + +if(METHANE_PRECOMPILED_HEADERS_ENABLED) + target_precompile_headers(${TARGET} REUSE_FROM MethaneCommonPrecompiledHeaders) +endif() + +target_include_directories(${TARGET} + PRIVATE + Sources + PUBLIC + Include +) + +source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) + +set_target_properties(${TARGET} + PROPERTIES + FOLDER Modules/Platform/Base + PUBLIC_HEADER "${HEADERS}" +) + +install(TARGETS ${TARGET} + PUBLIC_HEADER + DESTINATION ${INSTALL_INCLUDE_DIR}/Base + COMPONENT Development + ARCHIVE + DESTINATION lib + COMPONENT Development +) diff --git a/Modules/Platform/App/Include/Methane/Platform/AppBase.h b/Modules/Platform/Base/App/Include/Methane/Platform/Base/App.h similarity index 90% rename from Modules/Platform/App/Include/Methane/Platform/AppBase.h rename to Modules/Platform/Base/App/Include/Methane/Platform/Base/App.h index de1f2d9e4..12de95b92 100644 --- a/Modules/Platform/App/Include/Methane/Platform/AppBase.h +++ b/Modules/Platform/Base/App/Include/Methane/Platform/Base/App.h @@ -16,14 +16,14 @@ limitations under the License. ******************************************************************************* -FILE: Methane/Platform/AppBase.h +FILE: Methane/Platform/Base/App.h Base application interface and platform-independent implementation. ******************************************************************************/ #pragma once -#include "IApp.h" +#include #include #include @@ -41,22 +41,22 @@ namespace tf // NOSONAR class Executor; } -namespace Methane::Platform +namespace Methane::Platform::Base { -class AppBase // NOSONAR +class App // NOSONAR : public CLI::App , public IApp { public: - explicit AppBase(const Settings& settings); - ~AppBase() override; + explicit App(const Settings& settings); + ~App() override; - AppBase(const AppBase&) = delete; - AppBase(AppBase&&) = delete; + App(const App&) = delete; + App(App&&) = delete; - AppBase& operator=(const AppBase&) = delete; - AppBase& operator=(AppBase&&) = delete; + App& operator=(const App&) = delete; + App& operator=(App&&) = delete; // IApp overrides int Run(const RunArgs& args) override; @@ -73,10 +73,10 @@ class AppBase // NOSONAR void ShowParameters() override { /* no parameters are displayed by default, but can be overridden */ } bool InitContextWithErrorHandling(const Platform::AppEnvironment& env, const Data::FrameSize& frame_size) - { return ExecuteWithErrorHandling("Render Context Initialization", true, *this, &AppBase::InitContext, env, frame_size); } + { return ExecuteWithErrorHandling("Render Context Initialization", true, *this, &App::InitContext, env, frame_size); } - bool InitWithErrorHandling() { return ExecuteWithErrorHandling("Application Initialization", true, *this, &AppBase::Init); } - bool UpdateAndRenderWithErrorHandling() { return ExecuteWithErrorHandling("Application Rendering", false, *this, &AppBase::UpdateAndRender); } + bool InitWithErrorHandling() { return ExecuteWithErrorHandling("Application Initialization", true, *this, &App::Init); } + bool UpdateAndRenderWithErrorHandling() { return ExecuteWithErrorHandling("Application Rendering", false, *this, &App::UpdateAndRender); } template void ProcessInputWithErrorHandling(FuncType&& func_ptr, ArgTypes&&... args) @@ -92,7 +92,7 @@ class AppBase // NOSONAR bool HasError() const noexcept; protected: - // AppBase interface + // App interface virtual AppView GetView() const = 0; virtual void ShowAlert(const Message& msg); @@ -162,4 +162,4 @@ class AppBase // NOSONAR mutable UniquePtr m_parallel_executor_ptr; }; -} // namespace Methane::Platform +} // namespace Methane::Platform::Base diff --git a/Modules/Platform/App/Sources/Methane/Platform/AppBase.cpp b/Modules/Platform/Base/App/Sources/Methane/Platform/Base/App.cpp similarity index 83% rename from Modules/Platform/App/Sources/Methane/Platform/AppBase.cpp rename to Modules/Platform/Base/App/Sources/Methane/Platform/Base/App.cpp index 1cf1a4de2..6ad415b41 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/AppBase.cpp +++ b/Modules/Platform/Base/App/Sources/Methane/Platform/Base/App.cpp @@ -16,12 +16,12 @@ limitations under the License. ******************************************************************************* -FILE: Methane/Platform/AppBase.cpp +FILE: Methane/Platform/Base/App.cpp Base application interface and platform-independent implementation. ******************************************************************************/ -#include +#include #include #include #include @@ -39,7 +39,7 @@ Base application interface and platform-independent implementation. #include #include -namespace Methane::Platform +namespace Methane::Platform::Base { static bool WriteControllerHeaderToHelpStream(std::stringstream& help_stream, const Input::Controller& controller, bool is_first_controller) @@ -114,42 +114,7 @@ static CLI::Option& AddRectSizeOption(CLI::App &app, const std::string& name, Da return *option_ptr; } -IApp::Settings& IApp::Settings::SetName(std::string&& new_name) noexcept -{ - META_FUNCTION_TASK(); - name = std::move(new_name); - return *this; -} - -IApp::Settings& IApp::Settings::SetSize(Data::FloatSize&& new_size) noexcept -{ - META_FUNCTION_TASK(); - size = std::move(new_size); - return *this; -} - -IApp::Settings& IApp::Settings::SetMinSize(Data::FrameSize&& new_min_size) noexcept -{ - META_FUNCTION_TASK(); - min_size = std::move(new_min_size); - return *this; -} - -IApp::Settings& IApp::Settings::SetFullScreen(bool new_full_screen) noexcept -{ - META_FUNCTION_TASK(); - is_full_screen = new_full_screen; - return *this; -} - -IApp::Settings& IApp::Settings::SetIconProvider(Data::IProvider* new_icon_provider) noexcept -{ - META_FUNCTION_TASK(); - icon_provider_ptr = new_icon_provider; - return *this; -} - -AppBase::AppBase(const AppBase::Settings& settings) +App::App(const App::Settings& settings) : CLI::App(settings.name, GetExecutableFileName()) , m_settings(settings) { @@ -170,14 +135,14 @@ AppBase::AppBase(const AppBase::Settings& settings) #endif } -AppBase::~AppBase() +App::~App() { META_FUNCTION_TASK(); if (m_parallel_executor_ptr) m_parallel_executor_ptr->wait_for_all(); } -int AppBase::Run(const RunArgs& args) +int App::Run(const RunArgs& args) { META_FUNCTION_TASK(); try @@ -200,19 +165,19 @@ int AppBase::Run(const RunArgs& args) return 0; } -void AppBase::Init() +void App::Init() { META_FUNCTION_TASK(); m_initialized = true; } -void AppBase::ChangeWindowBounds(const Data::FrameRect& window_bounds) +void App::ChangeWindowBounds(const Data::FrameRect& window_bounds) { META_FUNCTION_TASK(); m_window_bounds = window_bounds; } -void AppBase::StartResizing() +void App::StartResizing() { META_FUNCTION_TASK(); META_CHECK_FALSE(m_is_resizing); @@ -221,7 +186,7 @@ void AppBase::StartResizing() META_LOG("\n========================== START RESIZING =========================="); } -void AppBase::EndResizing() +void App::EndResizing() { META_FUNCTION_TASK(); META_CHECK_TRUE(m_is_resizing); @@ -230,7 +195,7 @@ void AppBase::EndResizing() META_LOG("\n========================== END RESIZING =========================="); } -bool AppBase::Resize(const Data::FrameSize& frame_size, bool is_minimized) +bool App::Resize(const Data::FrameSize& frame_size, bool is_minimized) { META_FUNCTION_TASK(); const bool is_resizing = !is_minimized && m_frame_size != frame_size; @@ -249,7 +214,7 @@ bool AppBase::Resize(const Data::FrameSize& frame_size, bool is_minimized) return m_initialized && is_resizing && !HasError(); } -void AppBase::Alert(const Message& msg, bool deferred) +void App::Alert(const Message& msg, bool deferred) { META_FUNCTION_TASK(); if (!deferred) @@ -258,7 +223,7 @@ void AppBase::Alert(const Message& msg, bool deferred) m_deferred_message_ptr.reset(new Message(msg)); } -void AppBase::ShowAlert(const Message&) +void App::ShowAlert(const Message&) { META_FUNCTION_TASK(); @@ -267,13 +232,13 @@ void AppBase::ShowAlert(const Message&) m_input_state.ReleaseAllKeys(); } -bool AppBase::HasError() const noexcept +bool App::HasError() const noexcept { META_FUNCTION_TASK(); return m_deferred_message_ptr ? m_deferred_message_ptr->type == Message::Type::Error : false; } -tf::Executor& AppBase::GetParallelExecutor() const +tf::Executor& App::GetParallelExecutor() const { META_FUNCTION_TASK(); if (!m_parallel_executor_ptr) @@ -282,7 +247,7 @@ tf::Executor& AppBase::GetParallelExecutor() const return *m_parallel_executor_ptr; } -bool AppBase::SetFullScreen(bool is_full_screen) +bool App::SetFullScreen(bool is_full_screen) { META_FUNCTION_TASK(); if (m_settings.is_full_screen == is_full_screen) @@ -294,7 +259,7 @@ bool AppBase::SetFullScreen(bool is_full_screen) return true; } -bool AppBase::SetKeyboardFocus(bool has_keyboard_focus) +bool App::SetKeyboardFocus(bool has_keyboard_focus) { META_FUNCTION_TASK(); if (m_has_keyboard_focus == has_keyboard_focus) @@ -306,7 +271,7 @@ bool AppBase::SetKeyboardFocus(bool has_keyboard_focus) return true; } -std::string AppBase::GetControlsHelp() const +std::string App::GetControlsHelp() const { META_FUNCTION_TASK(); std::stringstream help_stream; @@ -344,34 +309,34 @@ std::string AppBase::GetControlsHelp() const return help_stream.str(); } -void AppBase::ShowControlsHelp() +void App::ShowControlsHelp() { META_FUNCTION_TASK(); Alert({ - AppBase::Message::Type::Information, + App::Message::Type::Information, "Application Controls Help", GetControlsHelp() }); } -void AppBase::ShowCommandLineHelp() +void App::ShowCommandLineHelp() { META_FUNCTION_TASK(); Alert({ - AppBase::Message::Type::Information, + App::Message::Type::Information, "Application Command-Line Help", GetCommandLineHelp() }); } -const AppBase::Message& AppBase::GetDeferredMessage() const +const App::Message& App::GetDeferredMessage() const { META_FUNCTION_TASK(); META_CHECK_NOT_NULL(m_deferred_message_ptr); return *m_deferred_message_ptr; } -bool AppBase::UpdateAndRender() +bool App::UpdateAndRender() { META_FUNCTION_TASK(); if (HasError() || m_is_resize_required_to_render) @@ -393,4 +358,4 @@ bool AppBase::UpdateAndRender() return true; } -} // namespace Methane::Platform +} // namespace Methane::Platform::Base diff --git a/Modules/Platform/Base/CMakeLists.txt b/Modules/Platform/Base/CMakeLists.txt new file mode 100644 index 000000000..ac2613cca --- /dev/null +++ b/Modules/Platform/Base/CMakeLists.txt @@ -0,0 +1,3 @@ +add_subdirectory(Utils) +add_subdirectory(Input) +add_subdirectory(App) diff --git a/Modules/Platform/Base/Input/CMakeLists.txt b/Modules/Platform/Base/Input/CMakeLists.txt new file mode 100644 index 000000000..df28aa576 --- /dev/null +++ b/Modules/Platform/Base/Input/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(Keyboard) diff --git a/Modules/Platform/Input/Keyboard/CMakeLists.txt b/Modules/Platform/Base/Input/Keyboard/CMakeLists.txt similarity index 52% rename from Modules/Platform/Input/Keyboard/CMakeLists.txt rename to Modules/Platform/Base/Input/Keyboard/CMakeLists.txt index 30e0deed9..a848c15f7 100644 --- a/Modules/Platform/Input/Keyboard/CMakeLists.txt +++ b/Modules/Platform/Base/Input/Keyboard/CMakeLists.txt @@ -1,21 +1,16 @@ -set(TARGET MethanePlatformInputKeyboard) +set(TARGET MethanePlatformInputKeyboardBase) include(MethaneModules) get_module_dirs("Methane/Platform/Input") -list(APPEND HEADERS ${INCLUDE_DIR}/Keyboard.h) -list(APPEND SOURCES ${SOURCES_DIR}/Keyboard.cpp) - -if (APPLE_MACOS) - list(APPEND HEADERS ${INCLUDE_PLATFORM_OS_DIR}/Keyboard.h) - list(APPEND PLATFORM_LIBRARIES "-framework AppKit") -endif() +list(APPEND HEADERS + ${INCLUDE_DIR}/Keyboard.h +) -if (NOT (APPLE_IOS OR APPLE_TVOS)) - list(APPEND HEADERS ${INCLUDE_PLATFORM_OS_DIR}/Keyboard.h) - list(APPEND SOURCES ${SOURCES_PLATFORM_OS_DIR}/Keyboard.${CPP_EXT}) -endif() +list(APPEND SOURCES + ${SOURCES_DIR}/Keyboard.cpp +) add_library(${TARGET} STATIC ${HEADERS} @@ -32,7 +27,6 @@ target_link_libraries(${TARGET} MethanePrimitives MethanePlatformUtils magic_enum - ${PLATFORM_LIBRARIES} ) if(METHANE_PRECOMPILED_HEADERS_ENABLED) @@ -42,7 +36,6 @@ endif() target_include_directories(${TARGET} PRIVATE Sources - $<$:${X11_xcb_INCLUDE_PATH} ${X11_X11_INCLUDE_PATH}> PUBLIC Include ) @@ -51,20 +44,10 @@ source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) set_target_properties(${TARGET} PROPERTIES - FOLDER Modules/Platform/Input + FOLDER Modules/Platform/Base PUBLIC_HEADER "${HEADERS}" ) -if (APPLE) - # Disable precompiled headers on MacOS for Objective-C files: - set_source_files_properties( - ${SOURCES_PLATFORM_OS_DIR}/Keyboard.mm - PROPERTIES - COMPILE_FLAGS -fobjc-arc - SKIP_PRECOMPILE_HEADERS ON - ) -endif() - install(TARGETS ${TARGET} PUBLIC_HEADER DESTINATION ${INSTALL_INCLUDE_DIR} diff --git a/Modules/Platform/Input/Keyboard/Include/Methane/Platform/Input/Keyboard.h b/Modules/Platform/Base/Input/Keyboard/Include/Methane/Platform/Input/Keyboard.h similarity index 97% rename from Modules/Platform/Input/Keyboard/Include/Methane/Platform/Input/Keyboard.h rename to Modules/Platform/Base/Input/Keyboard/Include/Methane/Platform/Input/Keyboard.h index 27d82ebe7..fd87f9f2d 100644 --- a/Modules/Platform/Input/Keyboard/Include/Methane/Platform/Input/Keyboard.h +++ b/Modules/Platform/Base/Input/Keyboard/Include/Methane/Platform/Input/Keyboard.h @@ -23,19 +23,8 @@ Platform abstraction of keyboard events. #pragma once -#if defined _WIN32 - -#include "Windows/Keyboard.h" - -#elif defined __APPLE__ - -#include "MacOS/Keyboard.h" - -#else - -#include "Linux/Keyboard.h" - -#endif +// NOTE: platform-specific Keyboard::NativeKey definition is provided by the +// /Keyboard.h> header of the platform module. #include #include diff --git a/Modules/Platform/Input/Keyboard/Sources/Methane/Platform/Input/Keyboard.cpp b/Modules/Platform/Base/Input/Keyboard/Sources/Methane/Platform/Input/Keyboard.cpp similarity index 100% rename from Modules/Platform/Input/Keyboard/Sources/Methane/Platform/Input/Keyboard.cpp rename to Modules/Platform/Base/Input/Keyboard/Sources/Methane/Platform/Input/Keyboard.cpp diff --git a/Modules/Platform/Utils/CMakeLists.txt b/Modules/Platform/Base/Utils/CMakeLists.txt similarity index 51% rename from Modules/Platform/Utils/CMakeLists.txt rename to Modules/Platform/Base/Utils/CMakeLists.txt index ee8b4eb5c..4058741f9 100644 --- a/Modules/Platform/Utils/CMakeLists.txt +++ b/Modules/Platform/Base/Utils/CMakeLists.txt @@ -1,33 +1,16 @@ -set(TARGET MethanePlatformUtils) +set(TARGET MethanePlatformUtilsBase) include(MethaneModules) get_module_dirs("Methane/Platform") -if(WIN32) - set(PLATFORM_HEADERS - ${INCLUDE_PLATFORM_DIR}/Utils.h - ) -elseif(APPLE) - set(PLATFORM_HEADERS - ${INCLUDE_PLATFORM_DIR}/Types.hh - ${INCLUDE_PLATFORM_DIR}/Utils.hh - ) -endif() - -set(HEADERS +list(APPEND HEADERS ${INCLUDE_DIR}/Utils.h ${INCLUDE_DIR}/Logger.h - ${PLATFORM_HEADERS} -) - -set(PLATFORM_SOURCES - ${SOURCES_PLATFORM_DIR}/Utils.${CPP_EXT} ) -set(SOURCES +list(APPEND SOURCES ${SOURCES_DIR}/Utils.cpp - ${PLATFORM_SOURCES} ) add_library(${TARGET} STATIC @@ -35,13 +18,6 @@ add_library(${TARGET} STATIC ${SOURCES} ) -target_include_directories(${TARGET} - PRIVATE - Sources - PUBLIC - Include -) - target_link_libraries(${TARGET} PUBLIC MethaneBuildOptions @@ -54,38 +30,21 @@ if(METHANE_PRECOMPILED_HEADERS_ENABLED) target_precompile_headers(${TARGET} REUSE_FROM MethaneCommonPrecompiledHeaders) endif() -if(APPLE) - - target_sources(${TARGET} - PRIVATE - ${INCLUDE_PLATFORM_DIR}/Types.hh - ) - - target_link_libraries(${TARGET} - PUBLIC - "-framework Foundation" - ) - -endif() +target_include_directories(${TARGET} + PRIVATE + Sources + PUBLIC + Include +) source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) set_target_properties(${TARGET} PROPERTIES - FOLDER Modules/Platform + FOLDER Modules/Platform/Base PUBLIC_HEADER "${HEADERS}" ) -if (APPLE) - # Disable precompiled headers on MacOS for Objective-C files: - set_source_files_properties( - ${PLATFORM_SOURCES} - PROPERTIES - COMPILE_FLAGS -fobjc-arc - SKIP_PRECOMPILE_HEADERS ON - ) -endif() - install(TARGETS ${TARGET} PUBLIC_HEADER DESTINATION ${INSTALL_INCLUDE_DIR} @@ -94,4 +53,3 @@ install(TARGETS ${TARGET} DESTINATION lib COMPONENT Development ) - diff --git a/Modules/Platform/Utils/Include/Methane/Platform/Logger.h b/Modules/Platform/Base/Utils/Include/Methane/Platform/Logger.h similarity index 100% rename from Modules/Platform/Utils/Include/Methane/Platform/Logger.h rename to Modules/Platform/Base/Utils/Include/Methane/Platform/Logger.h diff --git a/Modules/Platform/Utils/Include/Methane/Platform/Utils.h b/Modules/Platform/Base/Utils/Include/Methane/Platform/Utils.h similarity index 91% rename from Modules/Platform/Utils/Include/Methane/Platform/Utils.h rename to Modules/Platform/Base/Utils/Include/Methane/Platform/Utils.h index e76064716..88819f721 100644 --- a/Modules/Platform/Utils/Include/Methane/Platform/Utils.h +++ b/Modules/Platform/Base/Utils/Include/Methane/Platform/Utils.h @@ -23,19 +23,8 @@ Methane platform utility functions #pragma once -#if defined _WIN32 - -#include "Windows/Utils.h" - -#elif defined __APPLE__ - -#include "Apple/Utils.hh" - -#elif defined __linux__ - -#include "Linux/Utils.h" - -#endif +// NOTE: platform-specific utility functions are declared in the +// /Utils.h> header of the platform module. #include #include diff --git a/Modules/Platform/Utils/Sources/Methane/Platform/Utils.cpp b/Modules/Platform/Base/Utils/Sources/Methane/Platform/Utils.cpp similarity index 100% rename from Modules/Platform/Utils/Sources/Methane/Platform/Utils.cpp rename to Modules/Platform/Base/Utils/Sources/Methane/Platform/Utils.cpp diff --git a/Modules/Platform/CMakeLists.txt b/Modules/Platform/CMakeLists.txt index c4a08b63b..88cf6ffab 100644 --- a/Modules/Platform/CMakeLists.txt +++ b/Modules/Platform/CMakeLists.txt @@ -1,4 +1,21 @@ -add_subdirectory(App) -add_subdirectory(AppView) -add_subdirectory(Input) -add_subdirectory(Utils) +# Platform-independent module layers: +add_subdirectory(Interfaces) +add_subdirectory(Base) +add_subdirectory(Common) + +# Platform-specific module layer (only one is added depending on the target platform): +if(WIN32) + add_subdirectory(Windows) +elseif(APPLE) + add_subdirectory(Apple) + if(APPLE_MACOS) + add_subdirectory(MacOS) + else() # iOS / tvOS + add_subdirectory(iOS) + endif() +else() # Linux + add_subdirectory(Linux) +endif() + +# Final implementation layer binding platform-independent and platform-specific modules together: +add_subdirectory(Impl) diff --git a/Modules/Platform/Common/App/CMakeLists.txt b/Modules/Platform/Common/App/CMakeLists.txt new file mode 100644 index 000000000..78e88c6f1 --- /dev/null +++ b/Modules/Platform/Common/App/CMakeLists.txt @@ -0,0 +1,57 @@ +set(TARGET MethanePlatformAppCommon) + +include(MethaneModules) + +get_module_dirs("Methane/Platform") + +list(APPEND HEADERS + ${INCLUDE_DIR}/AppController.h +) + +list(APPEND SOURCES + ${SOURCES_DIR}/AppController.cpp +) + +add_library(${TARGET} STATIC + ${HEADERS} + ${SOURCES} +) + +target_link_libraries(${TARGET} + PUBLIC + MethanePlatformAppBase + PRIVATE + MethaneBuildOptions + MethaneCommonPrecompiledHeaders + MethaneInstrumentation + MethanePlatformUtils + fmt +) + +if(METHANE_PRECOMPILED_HEADERS_ENABLED) + target_precompile_headers(${TARGET} REUSE_FROM MethaneCommonPrecompiledHeaders) +endif() + +target_include_directories(${TARGET} + PRIVATE + Sources + PUBLIC + Include +) + +source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) + +set_target_properties(${TARGET} + PROPERTIES + FOLDER Modules/Platform/Common + PUBLIC_HEADER "${HEADERS}" +) + +install(TARGETS ${TARGET} + PUBLIC_HEADER + DESTINATION ${INSTALL_INCLUDE_DIR} + COMPONENT Development + ARCHIVE + DESTINATION lib + COMPONENT Development +) diff --git a/Modules/Platform/App/Include/Methane/Platform/AppController.h b/Modules/Platform/Common/App/Include/Methane/Platform/AppController.h similarity index 94% rename from Modules/Platform/App/Include/Methane/Platform/AppController.h rename to Modules/Platform/Common/App/Include/Methane/Platform/AppController.h index 74311e34f..4e949ba0b 100644 --- a/Modules/Platform/App/Include/Methane/Platform/AppController.h +++ b/Modules/Platform/Common/App/Include/Methane/Platform/AppController.h @@ -23,7 +23,7 @@ Base application controller providing commands like app close and help. #pragma once -#include +#include #include namespace Methane::Platform @@ -52,7 +52,7 @@ class AppController { { Input::Keyboard::OS::g_key_left_ctrl, Input::Keyboard::Key::Q }, AppAction::CloseApp }, }; - AppController(AppBase& application, const std::string& application_help, + AppController(Base::App& application, const std::string& application_help, const ActionByKeyboardState& action_by_keyboard_state = default_action_by_keyboard_state); // Input::Controller implementation @@ -66,7 +66,7 @@ class AppController std::string GetKeyboardActionName(AppAction action) const override; private: - AppBase& m_application; + Base::App& m_application; }; } // namespace Methane::Platform diff --git a/Modules/Platform/App/Sources/Methane/Platform/AppController.cpp b/Modules/Platform/Common/App/Sources/Methane/Platform/AppController.cpp similarity index 95% rename from Modules/Platform/App/Sources/Methane/Platform/AppController.cpp rename to Modules/Platform/Common/App/Sources/Methane/Platform/AppController.cpp index 71a21b5f9..614965c08 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/AppController.cpp +++ b/Modules/Platform/Common/App/Sources/Methane/Platform/AppController.cpp @@ -29,7 +29,7 @@ Base application controller providing commands like app close and help. namespace Methane::Platform { -AppController::AppController(AppBase& application, const std::string& application_help, const ActionByKeyboardState& action_by_keyboard_state) +AppController::AppController(Base::App& application, const std::string& application_help, const ActionByKeyboardState& action_by_keyboard_state) : Controller(application_help) , Input::Keyboard::ActionControllerBase(action_by_keyboard_state, {}) , m_application(application) diff --git a/Modules/Platform/Common/CMakeLists.txt b/Modules/Platform/Common/CMakeLists.txt new file mode 100644 index 000000000..c4c670218 --- /dev/null +++ b/Modules/Platform/Common/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(Input) +add_subdirectory(App) diff --git a/Modules/Platform/Input/ActionControllers/CMakeLists.txt b/Modules/Platform/Common/Input/ActionControllers/CMakeLists.txt similarity index 95% rename from Modules/Platform/Input/ActionControllers/CMakeLists.txt rename to Modules/Platform/Common/Input/ActionControllers/CMakeLists.txt index 4dce0311e..7c4723bdc 100644 --- a/Modules/Platform/Input/ActionControllers/CMakeLists.txt +++ b/Modules/Platform/Common/Input/ActionControllers/CMakeLists.txt @@ -33,7 +33,7 @@ source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS}) set_target_properties(${TARGET} PROPERTIES - FOLDER Modules/Platform/Input + FOLDER Modules/Platform/Common/Input PUBLIC_HEADER "${HEADERS}" ) diff --git a/Modules/Platform/Input/ActionControllers/Include/Methane/Platform/Input/KeyboardActionControllerBase.hpp b/Modules/Platform/Common/Input/ActionControllers/Include/Methane/Platform/Input/KeyboardActionControllerBase.hpp similarity index 100% rename from Modules/Platform/Input/ActionControllers/Include/Methane/Platform/Input/KeyboardActionControllerBase.hpp rename to Modules/Platform/Common/Input/ActionControllers/Include/Methane/Platform/Input/KeyboardActionControllerBase.hpp diff --git a/Modules/Platform/Input/ActionControllers/Include/Methane/Platform/Input/MouseActionControllerBase.hpp b/Modules/Platform/Common/Input/ActionControllers/Include/Methane/Platform/Input/MouseActionControllerBase.hpp similarity index 100% rename from Modules/Platform/Input/ActionControllers/Include/Methane/Platform/Input/MouseActionControllerBase.hpp rename to Modules/Platform/Common/Input/ActionControllers/Include/Methane/Platform/Input/MouseActionControllerBase.hpp diff --git a/Modules/Platform/Input/CMakeLists.txt b/Modules/Platform/Common/Input/CMakeLists.txt similarity index 76% rename from Modules/Platform/Input/CMakeLists.txt rename to Modules/Platform/Common/Input/CMakeLists.txt index 36a26e67b..8e76322ee 100644 --- a/Modules/Platform/Input/CMakeLists.txt +++ b/Modules/Platform/Common/Input/CMakeLists.txt @@ -1,4 +1,3 @@ add_subdirectory(Mouse) -add_subdirectory(Keyboard) add_subdirectory(Controllers) add_subdirectory(ActionControllers) diff --git a/Modules/Platform/Input/Controllers/CMakeLists.txt b/Modules/Platform/Common/Input/Controllers/CMakeLists.txt similarity index 96% rename from Modules/Platform/Input/Controllers/CMakeLists.txt rename to Modules/Platform/Common/Input/Controllers/CMakeLists.txt index 6a468e2f0..bec3fd1ae 100644 --- a/Modules/Platform/Input/Controllers/CMakeLists.txt +++ b/Modules/Platform/Common/Input/Controllers/CMakeLists.txt @@ -48,7 +48,7 @@ source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) set_target_properties(${TARGET} PROPERTIES - FOLDER Modules/Platform/Input + FOLDER Modules/Platform/Common/Input PUBLIC_HEADER "${HEADERS}" ) diff --git a/Modules/Platform/Input/Controllers/Include/Methane/Platform/Input/Controller.h b/Modules/Platform/Common/Input/Controllers/Include/Methane/Platform/Input/Controller.h similarity index 100% rename from Modules/Platform/Input/Controllers/Include/Methane/Platform/Input/Controller.h rename to Modules/Platform/Common/Input/Controllers/Include/Methane/Platform/Input/Controller.h diff --git a/Modules/Platform/Input/Controllers/Include/Methane/Platform/Input/ControllersPool.h b/Modules/Platform/Common/Input/Controllers/Include/Methane/Platform/Input/ControllersPool.h similarity index 100% rename from Modules/Platform/Input/Controllers/Include/Methane/Platform/Input/ControllersPool.h rename to Modules/Platform/Common/Input/Controllers/Include/Methane/Platform/Input/ControllersPool.h diff --git a/Modules/Platform/Input/Controllers/Include/Methane/Platform/Input/IActionController.h b/Modules/Platform/Common/Input/Controllers/Include/Methane/Platform/Input/IActionController.h similarity index 100% rename from Modules/Platform/Input/Controllers/Include/Methane/Platform/Input/IActionController.h rename to Modules/Platform/Common/Input/Controllers/Include/Methane/Platform/Input/IActionController.h diff --git a/Modules/Platform/Input/Controllers/Include/Methane/Platform/Input/IController.h b/Modules/Platform/Common/Input/Controllers/Include/Methane/Platform/Input/IController.h similarity index 100% rename from Modules/Platform/Input/Controllers/Include/Methane/Platform/Input/IController.h rename to Modules/Platform/Common/Input/Controllers/Include/Methane/Platform/Input/IController.h diff --git a/Modules/Platform/Input/Controllers/Include/Methane/Platform/Input/IHelpProvider.h b/Modules/Platform/Common/Input/Controllers/Include/Methane/Platform/Input/IHelpProvider.h similarity index 100% rename from Modules/Platform/Input/Controllers/Include/Methane/Platform/Input/IHelpProvider.h rename to Modules/Platform/Common/Input/Controllers/Include/Methane/Platform/Input/IHelpProvider.h diff --git a/Modules/Platform/Input/Controllers/Include/Methane/Platform/Input/State.h b/Modules/Platform/Common/Input/Controllers/Include/Methane/Platform/Input/State.h similarity index 100% rename from Modules/Platform/Input/Controllers/Include/Methane/Platform/Input/State.h rename to Modules/Platform/Common/Input/Controllers/Include/Methane/Platform/Input/State.h diff --git a/Modules/Platform/Input/Controllers/Sources/Methane/Platform/Input/ControllersPool.cpp b/Modules/Platform/Common/Input/Controllers/Sources/Methane/Platform/Input/ControllersPool.cpp similarity index 100% rename from Modules/Platform/Input/Controllers/Sources/Methane/Platform/Input/ControllersPool.cpp rename to Modules/Platform/Common/Input/Controllers/Sources/Methane/Platform/Input/ControllersPool.cpp diff --git a/Modules/Platform/Input/Controllers/Sources/Methane/Platform/Input/State.cpp b/Modules/Platform/Common/Input/Controllers/Sources/Methane/Platform/Input/State.cpp similarity index 100% rename from Modules/Platform/Input/Controllers/Sources/Methane/Platform/Input/State.cpp rename to Modules/Platform/Common/Input/Controllers/Sources/Methane/Platform/Input/State.cpp diff --git a/Modules/Platform/Input/Mouse/CMakeLists.txt b/Modules/Platform/Common/Input/Mouse/CMakeLists.txt similarity index 95% rename from Modules/Platform/Input/Mouse/CMakeLists.txt rename to Modules/Platform/Common/Input/Mouse/CMakeLists.txt index 015763c6c..98720b9d0 100644 --- a/Modules/Platform/Input/Mouse/CMakeLists.txt +++ b/Modules/Platform/Common/Input/Mouse/CMakeLists.txt @@ -36,7 +36,7 @@ source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) set_target_properties(${TARGET} PROPERTIES - FOLDER Modules/Platform/Input + FOLDER Modules/Platform/Common/Input PUBLIC_HEADER "${HEADERS}" ) diff --git a/Modules/Platform/Input/Mouse/Include/Methane/Platform/Input/Mouse.h b/Modules/Platform/Common/Input/Mouse/Include/Methane/Platform/Input/Mouse.h similarity index 100% rename from Modules/Platform/Input/Mouse/Include/Methane/Platform/Input/Mouse.h rename to Modules/Platform/Common/Input/Mouse/Include/Methane/Platform/Input/Mouse.h diff --git a/Modules/Platform/Input/Mouse/Sources/Methane/Platform/Input/Mouse.cpp b/Modules/Platform/Common/Input/Mouse/Sources/Methane/Platform/Input/Mouse.cpp similarity index 100% rename from Modules/Platform/Input/Mouse/Sources/Methane/Platform/Input/Mouse.cpp rename to Modules/Platform/Common/Input/Mouse/Sources/Methane/Platform/Input/Mouse.cpp diff --git a/Modules/Platform/Impl/App/CMakeLists.txt b/Modules/Platform/Impl/App/CMakeLists.txt new file mode 100644 index 000000000..d68e191ed --- /dev/null +++ b/Modules/Platform/Impl/App/CMakeLists.txt @@ -0,0 +1,51 @@ +set(TARGET MethanePlatformApp) + +include(MethaneModules) + +get_module_dirs("Methane/Platform") + +if(WIN32) + set(PLATFORM_APP_TARGET MethanePlatformAppWindows) +elseif(APPLE_MACOS) + set(PLATFORM_APP_TARGET MethanePlatformAppMacOS) +elseif(APPLE) + set(PLATFORM_APP_TARGET MethanePlatformAppIOS) +else() # Linux + set(PLATFORM_APP_TARGET MethanePlatformAppLinux) +endif() + +list(APPEND HEADERS + ${CMAKE_CURRENT_SOURCE_DIR}/${INCLUDE_DIR}/App.h +) + +add_library(${TARGET} INTERFACE) + +target_sources(${TARGET} + INTERFACE + ${HEADERS} +) + +target_include_directories(${TARGET} + INTERFACE + ${CMAKE_CURRENT_SOURCE_DIR}/Include +) + +target_link_libraries(${TARGET} + INTERFACE + ${PLATFORM_APP_TARGET} + MethanePlatformAppCommon +) + +source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS}) + +set_target_properties(${TARGET} + PROPERTIES + FOLDER Modules/Platform/Impl + PUBLIC_HEADER "${HEADERS}" +) + +install(TARGETS ${TARGET} + PUBLIC_HEADER + DESTINATION ${INSTALL_INCLUDE_DIR} + COMPONENT Development +) diff --git a/Modules/Platform/App/Include/Methane/Platform/App.h b/Modules/Platform/Impl/App/Include/Methane/Platform/App.h similarity index 71% rename from Modules/Platform/App/Include/Methane/Platform/App.h rename to Modules/Platform/Impl/App/Include/Methane/Platform/App.h index b85cc89f2..d0934636f 100644 --- a/Modules/Platform/App/Include/Methane/Platform/App.h +++ b/Modules/Platform/Impl/App/Include/Methane/Platform/App.h @@ -1,6 +1,6 @@ /****************************************************************************** -Copyright 2019-2020 Evgeny Gorodetskiy +Copyright 2019-2025 Evgeny Gorodetskiy Licensed under the Apache License, Version 2.0 (the "License"), you may not use this file except in compliance with the License. @@ -17,7 +17,8 @@ limitations under the License. ******************************************************************************* FILE: Methane/Platform/App.h -Methane platform application alias. +Methane platform application final implementation alias, which is bound to the +application class of the platform the library is built for. ******************************************************************************/ @@ -25,19 +26,19 @@ Methane platform application alias. #if defined _WIN32 -#include +#include #elif defined __APPLE__ #ifdef APPLE_MACOS -#include +#include #else -#include +#include #endif #elif defined __linux__ -#include +#include #endif @@ -46,19 +47,19 @@ namespace Methane::Platform #if defined _WIN32 -using App = AppWin; +using App = Windows::App; #elif defined __APPLE__ #ifdef APPLE_MACOS -using App = AppMac; +using App = MacOS::App; #else -using App = AppIOS; +using App = iOS::App; #endif #elif defined __linux__ -using App = AppLin; +using App = Linux::App; #endif diff --git a/Modules/Platform/Impl/App/README.md b/Modules/Platform/Impl/App/README.md new file mode 100644 index 000000000..3e249b752 --- /dev/null +++ b/Modules/Platform/Impl/App/README.md @@ -0,0 +1,88 @@ +# Platform App + +Platform abstraction of the windowed application with main purpose for graphics content rendering. +Graphics rendering infrastructure itself is split into derived class defined in a separate library. + +Platform application modules are grouped by platform support, similar to [Graphics RHI](../../../Graphics/RHI): + +``` +Interfaces/App ──> Base/App ──> { Windows | Linux | MacOS | iOS }/App ──> Impl/App + Common/App ──┘ +``` + +| Module | CMake Target | Description | +|--------------------------------------------------------|------------------------------|---------------------------------------------| +| [Interfaces/App](../../Interfaces/App) | MethanePlatformAppInterface | `Platform::IApp` interface and app settings | +| [Base/App](../../Base/App) | MethanePlatformAppBase | `Platform::Base::App` implementation | +| [Windows/App](../../Windows/App) | MethanePlatformAppWindows | `Platform::Windows::App` implementation | +| [Linux/App](../../Linux/App) | MethanePlatformAppLinux | `Platform::Linux::App` implementation | +| [MacOS/App](../../MacOS/App) | MethanePlatformAppMacOS | `Platform::MacOS::App` implementation | +| [iOS/App](../../iOS/App) | MethanePlatformAppIOS | `Platform::iOS::App` implementation | +| [Common/App](../../Common/App) | MethanePlatformAppCommon | `Platform::AppController` implementation | +| [Impl/App](.) | MethanePlatformApp | `Platform::App` final implementation alias | + +## Platform Application + +### Platform::App + +[Methane/Platform/App.h](Include/Methane/Platform/App.h) defines alias type `Platform::App` pointing +to one of the platform-specific implementations of the [Platform::Base::App](#platform-application-base-class) class: + +- [Platform::Windows::App](../../Windows/App/Include/Methane/Platform/Windows/App.h) - Windows app implementation +- [Platform::Linux::App](../../Linux/App/Include/Methane/Platform/Linux/App.h) - Linux app implementation +- [Platform::MacOS::App](../../MacOS/App/Include/Methane/Platform/MacOS/App.hh) - MacOS app implementation +- [Platform::iOS::App](../../iOS/App/Include/Methane/Platform/iOS/App.hh) - iOS app implementation + +`Platform::App` should be used as a base class for any windowed Methane application. + +## Platform Application Interface + +### Platform::IApp + +[Methane/Platform/IApp.h](../../Interfaces/App/Include/Methane/Platform/IApp.h) declares the `Platform::IApp` +interface implemented by the application classes, along with the `Platform::AppSettings`, `Platform::AppRunArgs` +and `Platform::AppMessage` structures shared by all application layers. + +## Platform Application Base Class + +### Platform::Base::App + +[Methane/Platform/Base/App.h](../../Base/App/Include/Methane/Platform/Base/App.h) contains the +platform-abstraction implementation of the application class with the following functionality: + +- Initial application settings setup (see table below) +- Running application with a given command line arguments and parsing platform app settings from cmd arguments +- Live window resizing with frame re-render on resize iterations +- Switching window to full-screen mode +- Processing keyboard and mouse input via `Platform::Input::State` +- Adding [platform application controller](#platform-application-controller) to input state processor +- Setting title in window header +- Showing user alert in message box dialog +- Displaying application controls and command line help +- Shared parallel task execution engine with thread pool [Taskflow::Executor](../../../../Externals/TaskFlow.cmake) + +The following settings are available in `Platform::AppSettings` structure: + +| Setting | Type | Default Value | Cmd-Line Option | Description | +|----------------|----------|---------------|------------------|-----------------------| +| name | uint32_t | "" | | Application name displayed in window header | +| width | double | 0.8 | -w,--width | Main window width (if < 1.0 it is a ratio of desktop size; else size in pixels/dots) | +| height | double | 0.8 | -x,--height | Main window height (if < 1.0 it is a ratio of desktop size; else size in pixels/dots) | +| min_width | uint32_t | 640 | | Minimum window width in pixels/dots limited for resizing | +| min_height | uint32_t | 480 | | Minimum window height in pixels/dots limited for resizing | +| is_full_screen | bool | false | -f,--full-screen | Full-screen state of the main window | + +## Platform Application Controller + +### Platform::AppController + +[Methane/Platform/AppController.h](../../Common/App/Include/Methane/Platform/AppController.h) implements +the following platform-independent actions: + +| Action | Keyboard Shortcut | +|------------------------|---------------------| +| Show controls help | F1 | +| Show command-line help | F2 | +| Show parameters | F3 | +| Switch full-screen | LCtrl + F | +| Close application | LCtrl/LCmd + Q | diff --git a/Modules/Platform/Impl/AppView/CMakeLists.txt b/Modules/Platform/Impl/AppView/CMakeLists.txt new file mode 100644 index 000000000..501752280 --- /dev/null +++ b/Modules/Platform/Impl/AppView/CMakeLists.txt @@ -0,0 +1,62 @@ +set(TARGET MethanePlatformAppView) + +include(MethaneModules) + +get_module_dirs("Methane/Platform") + +if(WIN32) + set(PLATFORM_APP_VIEW_TARGET MethanePlatformAppViewWindows) +elseif(APPLE_MACOS) + set(PLATFORM_APP_VIEW_TARGET MethanePlatformAppViewMacOS) +elseif(APPLE) + set(PLATFORM_APP_VIEW_TARGET MethanePlatformAppViewIOS) +else() # Linux + set(PLATFORM_APP_VIEW_TARGET MethanePlatformAppViewLinux) +endif() + +list(APPEND HEADERS + ${INCLUDE_DIR}/AppView.h + ${INCLUDE_DIR}/AppEnvironment.h +) + +list(APPEND SOURCES + ${SOURCES_DIR}/AppView.cpp +) + +add_library(${TARGET} STATIC + ${HEADERS} + ${SOURCES} +) + +target_link_libraries(${TARGET} + PUBLIC + ${PLATFORM_APP_VIEW_TARGET} + PRIVATE + MethaneBuildOptions + MethaneInstrumentation + MethaneDataTypes +) + +target_include_directories(${TARGET} + PRIVATE + Sources + PUBLIC + Include +) + +source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) + +set_target_properties(${TARGET} + PROPERTIES + FOLDER Modules/Platform/Impl + PUBLIC_HEADER "${HEADERS}" +) + +install(TARGETS ${TARGET} + PUBLIC_HEADER + DESTINATION ${INSTALL_INCLUDE_DIR} + COMPONENT Development + ARCHIVE + DESTINATION lib + COMPONENT Development +) diff --git a/Modules/Platform/AppView/Include/Methane/Platform/AppEnvironment.h b/Modules/Platform/Impl/AppView/Include/Methane/Platform/AppEnvironment.h similarity index 83% rename from Modules/Platform/AppView/Include/Methane/Platform/AppEnvironment.h rename to Modules/Platform/Impl/AppView/Include/Methane/Platform/AppEnvironment.h index 1422cc17c..7bdb33270 100644 --- a/Modules/Platform/AppView/Include/Methane/Platform/AppEnvironment.h +++ b/Modules/Platform/Impl/AppView/Include/Methane/Platform/AppEnvironment.h @@ -25,18 +25,18 @@ Methane application environment. #if defined(_WIN32) -#include "Windows/AppEnvironment.h" +#include #elif defined(__APPLE__) #ifdef APPLE_MACOS -#include "MacOS/AppEnvironment.hh" +#include #else -#include "iOS/AppEnvironment.hh" +#include #endif #elif defined __linux__ -#include "Linux/AppEnvironment.h" +#include #endif diff --git a/Modules/Platform/AppView/Include/Methane/Platform/AppView.h b/Modules/Platform/Impl/AppView/Include/Methane/Platform/AppView.h similarity index 94% rename from Modules/Platform/AppView/Include/Methane/Platform/AppView.h rename to Modules/Platform/Impl/AppView/Include/Methane/Platform/AppView.h index 58f478f88..b67872934 100644 --- a/Modules/Platform/AppView/Include/Methane/Platform/AppView.h +++ b/Modules/Platform/Impl/AppView/Include/Methane/Platform/AppView.h @@ -27,9 +27,9 @@ and by Methane App implementations. #ifdef __OBJC__ #ifdef APPLE_MACOS -#import "MacOS/AppViewMetal.hh" +#import #else -#import "iOS/AppViewMetal.hh" +#import #endif #else // __OBJC__ diff --git a/Modules/Platform/AppView/Sources/Methane/Platform/AppView.cpp b/Modules/Platform/Impl/AppView/Sources/Methane/Platform/AppView.cpp similarity index 100% rename from Modules/Platform/AppView/Sources/Methane/Platform/AppView.cpp rename to Modules/Platform/Impl/AppView/Sources/Methane/Platform/AppView.cpp diff --git a/Modules/Platform/Impl/CMakeLists.txt b/Modules/Platform/Impl/CMakeLists.txt new file mode 100644 index 000000000..2b7f51c09 --- /dev/null +++ b/Modules/Platform/Impl/CMakeLists.txt @@ -0,0 +1,4 @@ +add_subdirectory(Utils) +add_subdirectory(Input) +add_subdirectory(AppView) +add_subdirectory(App) diff --git a/Modules/Platform/Impl/Input/CMakeLists.txt b/Modules/Platform/Impl/Input/CMakeLists.txt new file mode 100644 index 000000000..df28aa576 --- /dev/null +++ b/Modules/Platform/Impl/Input/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(Keyboard) diff --git a/Modules/Platform/Impl/Input/Keyboard/CMakeLists.txt b/Modules/Platform/Impl/Input/Keyboard/CMakeLists.txt new file mode 100644 index 000000000..4cf6301d3 --- /dev/null +++ b/Modules/Platform/Impl/Input/Keyboard/CMakeLists.txt @@ -0,0 +1,23 @@ +set(TARGET MethanePlatformInputKeyboard) + +# NOTE: iOS and tvOS have no native keyboard event translation implementation +if(WIN32) + set(PLATFORM_KEYBOARD_TARGET MethanePlatformInputKeyboardWindows) +elseif(APPLE_MACOS) + set(PLATFORM_KEYBOARD_TARGET MethanePlatformInputKeyboardMacOS) +elseif(NOT APPLE) + set(PLATFORM_KEYBOARD_TARGET MethanePlatformInputKeyboardLinux) +endif() + +add_library(${TARGET} INTERFACE) + +target_link_libraries(${TARGET} + INTERFACE + MethanePlatformInputKeyboardBase + ${PLATFORM_KEYBOARD_TARGET} +) + +set_target_properties(${TARGET} + PROPERTIES + FOLDER Modules/Platform/Impl +) diff --git a/Modules/Platform/Impl/Utils/CMakeLists.txt b/Modules/Platform/Impl/Utils/CMakeLists.txt new file mode 100644 index 000000000..378777e4b --- /dev/null +++ b/Modules/Platform/Impl/Utils/CMakeLists.txt @@ -0,0 +1,22 @@ +set(TARGET MethanePlatformUtils) + +if(WIN32) + set(PLATFORM_UTILS_TARGET MethanePlatformUtilsWindows) +elseif(APPLE) + set(PLATFORM_UTILS_TARGET MethanePlatformUtilsApple) +else() # Linux + set(PLATFORM_UTILS_TARGET MethanePlatformUtilsLinux) +endif() + +add_library(${TARGET} INTERFACE) + +target_link_libraries(${TARGET} + INTERFACE + MethanePlatformUtilsBase + ${PLATFORM_UTILS_TARGET} +) + +set_target_properties(${TARGET} + PROPERTIES + FOLDER Modules/Platform/Impl +) diff --git a/Modules/Platform/Interfaces/App/CMakeLists.txt b/Modules/Platform/Interfaces/App/CMakeLists.txt new file mode 100644 index 000000000..9a8671db2 --- /dev/null +++ b/Modules/Platform/Interfaces/App/CMakeLists.txt @@ -0,0 +1,55 @@ +set(TARGET MethanePlatformAppInterface) + +include(MethaneModules) + +get_module_dirs("Methane/Platform") + +list(APPEND HEADERS + ${INCLUDE_DIR}/IApp.h +) + +list(APPEND SOURCES + ${SOURCES_DIR}/IApp.cpp +) + +add_library(${TARGET} STATIC + ${HEADERS} + ${SOURCES} +) + +target_link_libraries(${TARGET} + PUBLIC + MethaneDataTypes + PRIVATE + MethaneBuildOptions + MethaneCommonPrecompiledHeaders + MethaneInstrumentation +) + +if(METHANE_PRECOMPILED_HEADERS_ENABLED) + target_precompile_headers(${TARGET} REUSE_FROM MethaneCommonPrecompiledHeaders) +endif() + +target_include_directories(${TARGET} + PRIVATE + Sources + PUBLIC + Include +) + +source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) + +set_target_properties(${TARGET} + PROPERTIES + FOLDER Modules/Platform/Interfaces + PUBLIC_HEADER "${HEADERS}" +) + +install(TARGETS ${TARGET} + PUBLIC_HEADER + DESTINATION ${INSTALL_INCLUDE_DIR} + COMPONENT Development + ARCHIVE + DESTINATION lib + COMPONENT Development +) diff --git a/Modules/Platform/App/Include/Methane/Platform/IApp.h b/Modules/Platform/Interfaces/App/Include/Methane/Platform/IApp.h similarity index 100% rename from Modules/Platform/App/Include/Methane/Platform/IApp.h rename to Modules/Platform/Interfaces/App/Include/Methane/Platform/IApp.h diff --git a/Modules/Platform/Interfaces/App/Sources/Methane/Platform/IApp.cpp b/Modules/Platform/Interfaces/App/Sources/Methane/Platform/IApp.cpp new file mode 100644 index 000000000..c1a938679 --- /dev/null +++ b/Modules/Platform/Interfaces/App/Sources/Methane/Platform/IApp.cpp @@ -0,0 +1,65 @@ +/****************************************************************************** + +Copyright 2022-2025 Evgeny Gorodetskiy + +Licensed under the Apache License, Version 2.0 (the "License"), +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +******************************************************************************* + +FILE: Methane/Platform/IApp.cpp +Platform application settings implementation. + +******************************************************************************/ + +#include +#include + +namespace Methane::Platform +{ + +AppSettings& AppSettings::SetName(std::string&& new_name) noexcept +{ + META_FUNCTION_TASK(); + name = std::move(new_name); + return *this; +} + +AppSettings& AppSettings::SetSize(Data::FloatSize&& new_size) noexcept +{ + META_FUNCTION_TASK(); + size = std::move(new_size); + return *this; +} + +AppSettings& AppSettings::SetMinSize(Data::FrameSize&& new_min_size) noexcept +{ + META_FUNCTION_TASK(); + min_size = std::move(new_min_size); + return *this; +} + +AppSettings& AppSettings::SetFullScreen(bool new_full_screen) noexcept +{ + META_FUNCTION_TASK(); + is_full_screen = new_full_screen; + return *this; +} + +AppSettings& AppSettings::SetIconProvider(Data::IProvider* new_icon_provider) noexcept +{ + META_FUNCTION_TASK(); + icon_provider_ptr = new_icon_provider; + return *this; +} + +} // namespace Methane::Platform diff --git a/Modules/Platform/Interfaces/CMakeLists.txt b/Modules/Platform/Interfaces/CMakeLists.txt new file mode 100644 index 000000000..14c361067 --- /dev/null +++ b/Modules/Platform/Interfaces/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(App) diff --git a/Modules/Platform/Linux/App/CMakeLists.txt b/Modules/Platform/Linux/App/CMakeLists.txt new file mode 100644 index 000000000..ea07fb836 --- /dev/null +++ b/Modules/Platform/Linux/App/CMakeLists.txt @@ -0,0 +1,76 @@ +set(TARGET MethanePlatformAppLinux) + +include(MethaneModules) + +get_module_dirs("Methane/Platform") + +list(APPEND HEADERS + ${INCLUDE_PLATFORM_OS_DIR}/App.h +) + +list(APPEND SOURCES + ${SOURCES_PLATFORM_OS_DIR}/App.cpp + ${SOURCES_PLATFORM_OS_DIR}/MessageBox.h + ${SOURCES_PLATFORM_OS_DIR}/MessageBox.cpp + ${SOURCES_PLATFORM_OS_DIR}/XcbUtils.h + ${SOURCES_PLATFORM_OS_DIR}/XcbUtils.cpp +) + +add_library(${TARGET} STATIC + ${HEADERS} + ${SOURCES} +) + +target_link_libraries(${TARGET} + PUBLIC + MethanePlatformAppBase + MethanePlatformAppViewLinux + MethanePlatformInputKeyboardLinux + PRIVATE + MethaneBuildOptions + MethaneCommonPrecompiledHeaders + MethanePlatformUtilsLinux + MethaneDataProvider + fmt + nowide + X11::X11 + X11::X11_xcb + X11::xcb + X11::xcb_randr + X11::xcb_sync + STB +) + +target_compile_definitions(${TARGET} + PRIVATE + METHANE_RENDER_APP +) + +if(METHANE_PRECOMPILED_HEADERS_ENABLED) + target_precompile_headers(${TARGET} REUSE_FROM MethaneCommonPrecompiledHeaders) +endif() + +target_include_directories(${TARGET} + PRIVATE + Sources + ${SOURCES_PLATFORM_OS_DIR} + PUBLIC + Include +) + +source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) + +set_target_properties(${TARGET} + PROPERTIES + FOLDER Modules/Platform/Linux + PUBLIC_HEADER "${HEADERS}" +) + +install(TARGETS ${TARGET} + PUBLIC_HEADER + DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} + COMPONENT Development + ARCHIVE + DESTINATION lib + COMPONENT Development +) diff --git a/Modules/Platform/App/Include/Methane/Platform/Linux/AppLin.h b/Modules/Platform/Linux/App/Include/Methane/Platform/Linux/App.h similarity index 91% rename from Modules/Platform/App/Include/Methane/Platform/Linux/AppLin.h rename to Modules/Platform/Linux/App/Include/Methane/Platform/Linux/App.h index 14c322647..61e5a29b5 100644 --- a/Modules/Platform/App/Include/Methane/Platform/Linux/AppLin.h +++ b/Modules/Platform/Linux/App/Include/Methane/Platform/Linux/App.h @@ -16,14 +16,14 @@ limitations under the License. ******************************************************************************* -FILE: Methane/Platform/Linux/AppLin.h +FILE: Methane/Platform/Linux/App.h Linux application implementation. ******************************************************************************/ #pragma once -#include +#include #include #include #include @@ -34,18 +34,18 @@ Linux application implementation. #include #include -namespace Methane::Platform +namespace Methane::Platform::Linux { class MessageBox; -class AppLin : public AppBase // NOSONAR - this class requires destructor +class App : public Base::App // NOSONAR - this class requires destructor { public: - explicit AppLin(const Settings& settings); - ~AppLin() override; + explicit App(const Settings& settings); + ~App() override; - // AppBase interface + // Base::App interface int Run(const RunArgs& args) override; void Alert(const Message& msg, bool deferred = false) override; void SetWindowTitle(const std::string& title_text) override; @@ -55,7 +55,7 @@ class AppLin : public AppBase // NOSONAR - this class requires destructor void Close() override; protected: - // AppBase interface + // Base::App interface void ShowAlert(const Message& msg) override; private: @@ -98,4 +98,4 @@ class AppLin : public AppBase // NOSONAR - this class requires destructor Data::FrameSize m_windowed_frame_size; }; -} // namespace Methane::Platform +} // namespace Methane::Platform::Linux diff --git a/Modules/Platform/App/Sources/Methane/Platform/Linux/AppLin.cpp b/Modules/Platform/Linux/App/Sources/Methane/Platform/Linux/App.cpp similarity index 90% rename from Modules/Platform/App/Sources/Methane/Platform/Linux/AppLin.cpp rename to Modules/Platform/Linux/App/Sources/Methane/Platform/Linux/App.cpp index eb725b518..1d85f72be 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/Linux/AppLin.cpp +++ b/Modules/Platform/Linux/App/Sources/Methane/Platform/Linux/App.cpp @@ -16,7 +16,7 @@ limitations under the License. ******************************************************************************* -FILE: Methane/Platform/Linux/AppLin.cpp +FILE: Methane/Platform/Linux/App.cpp Linux application implementation. ******************************************************************************/ @@ -24,7 +24,7 @@ Linux application implementation. #include "MessageBox.h" #include "XcbUtils.h" -#include +#include #include #include #include @@ -38,11 +38,11 @@ Linux application implementation. #include #include -namespace Methane::Platform +namespace Methane::Platform::Linux { -AppLin::AppLin(const AppBase::Settings& settings) - : AppBase(settings) +App::App(const Base::App::Settings& settings) + : Base::App(settings) { META_FUNCTION_TASK(); @@ -66,7 +66,7 @@ AppLin::AppLin(const AppBase::Settings& settings) m_is_sync_supported = reply && reply->present; } -AppLin::~AppLin() +App::~App() { META_FUNCTION_TASK(); if (m_env.window) @@ -76,10 +76,10 @@ AppLin::~AppLin() xcb_disconnect(m_env.connection); } -int AppLin::Run(const RunArgs& args) +int App::Run(const RunArgs& args) { // Skip instrumentation META_FUNCTION_TASK() since this is the only root function running till application close - if (const int base_return_code = AppBase::Run(args); + if (const int base_return_code = Base::App::Run(args); base_return_code) return base_return_code; @@ -129,17 +129,17 @@ int AppLin::Run(const RunArgs& args) return 0; } -void AppLin::Alert(const Message& msg, bool deferred) +void App::Alert(const Message& msg, bool deferred) { META_FUNCTION_TASK(); - AppBase::Alert(msg, deferred); + Base::App::Alert(msg, deferred); if (!deferred) { ShowAlert(msg); } } -void AppLin::SetWindowTitle(const std::string& title_text) +void App::SetWindowTitle(const std::string& title_text) { META_FUNCTION_TASK(); if (!m_env.window) @@ -148,10 +148,10 @@ void AppLin::SetWindowTitle(const std::string& title_text) Linux::SetXcbWindowStringProperty(m_env.connection, m_env.window, XCB_ATOM_WM_NAME, title_text); } -bool AppLin::SetFullScreen(bool is_full_screen) +bool App::SetFullScreen(bool is_full_screen) { META_FUNCTION_TASK(); - if (!AppBase::SetFullScreen(is_full_screen) || !m_env.window) + if (!Base::App::SetFullScreen(is_full_screen) || !m_env.window) return false; xcb_client_message_event_t msg{0}; @@ -187,13 +187,13 @@ bool AppLin::SetFullScreen(bool is_full_screen) return true; } -float AppLin::GetContentScalingFactor() const +float App::GetContentScalingFactor() const { META_FUNCTION_TASK(); return static_cast(GetFontResolutionDpi()) / 96.F; } -uint32_t AppLin::GetFontResolutionDpi() const +uint32_t App::GetFontResolutionDpi() const { META_FUNCTION_TASK(); if (const char* display_res_str = XResourceManagerString(m_env.display); @@ -213,17 +213,17 @@ uint32_t AppLin::GetFontResolutionDpi() const return std::max(dpi_hor, dpi_ver); } -void AppLin::Close() +void App::Close() { META_FUNCTION_TASK(); m_is_event_processing = false; } -void AppLin::ShowAlert(const Message& message) +void App::ShowAlert(const Message& message) { META_FUNCTION_TASK(); GetMessageBox().Show(message); - AppBase::ShowAlert(message); + Base::App::ShowAlert(message); if (message.type == Message::Type::Error) { @@ -231,7 +231,7 @@ void AppLin::ShowAlert(const Message& message) } } -Data::FrameSize AppLin::InitWindow() +Data::FrameSize App::InitWindow() { META_FUNCTION_TASK(); const IApp::Settings& settings = GetPlatformAppSettings(); @@ -253,10 +253,10 @@ Data::FrameSize AppLin::InitWindow() // Calculate frame size relative to screen_id size in case of floating point value const uint16_t frame_width = settings.is_full_screen ? static_cast(m_env.primary_screen_rect.width) - : static_cast(AppBase::GetScaledSize(settings.size.GetWidth(), m_env.primary_screen_rect.width)); + : static_cast(Base::App::GetScaledSize(settings.size.GetWidth(), m_env.primary_screen_rect.width)); const uint16_t frame_height = settings.is_full_screen ? static_cast(m_env.primary_screen_rect.height) - : static_cast(AppBase::GetScaledSize(settings.size.GetHeight(), m_env.primary_screen_rect.height)); + : static_cast(Base::App::GetScaledSize(settings.size.GetHeight(), m_env.primary_screen_rect.height)); const int16_t pos_x = settings.is_full_screen ? static_cast(m_env.primary_screen_rect.x) @@ -320,7 +320,7 @@ Data::FrameSize AppLin::InitWindow() xcb_flush(m_env.connection); Data::FrameSize frame_size(frame_width, frame_height); - AppBase::Resize(frame_size, false); + Base::App::Resize(frame_size, false); return frame_size; } @@ -359,7 +359,7 @@ static void AddIconData(const Data::Chunk& icon_data, std::vector& com } } -void AppLin::SetWindowIcon(const Data::IProvider& icon_provider) +void App::SetWindowIcon(const Data::IProvider& icon_provider) { META_FUNCTION_TASK(); META_CHECK_NOT_NULL(m_env.window); @@ -376,7 +376,7 @@ void AppLin::SetWindowIcon(const Data::IProvider& icon_provider) Linux::SetXcbWindowAtomProperty(m_env.connection, m_env.window, "_NET_WM_ICON", XCB_ATOM_CARDINAL, combined_icons_data); } -void AppLin::ResizeWindow(const Data::FrameSize& frame_size, const Data::FrameSize& min_size, const Data::Point2I* position) +void App::ResizeWindow(const Data::FrameSize& frame_size, const Data::FrameSize& min_size, const Data::Point2I* position) { META_FUNCTION_TASK(); META_CHECK_NOT_NULL(m_env.window); @@ -413,7 +413,7 @@ void AppLin::ResizeWindow(const Data::FrameSize& frame_size, const Data::FrameSi xcb_flush(m_env.connection); } -void AppLin::HandleEvent(const xcb_generic_event_t& event) +void App::HandleEvent(const xcb_generic_event_t& event) { META_FUNCTION_TASK(); const uint8_t event_type = event.response_type & 0x7f; // NOSONAR @@ -472,7 +472,7 @@ void AppLin::HandleEvent(const xcb_generic_event_t& event) } } -void AppLin::OnClientEvent(const xcb_client_message_event_t& event) +void App::OnClientEvent(const xcb_client_message_event_t& event) { META_FUNCTION_TASK(); if (event.format != 32 || event.type != m_protocols_atom) @@ -493,7 +493,7 @@ void AppLin::OnClientEvent(const xcb_client_message_event_t& event) } } -void AppLin::UpdateSyncCounter() +void App::UpdateSyncCounter() { META_FUNCTION_TASK(); if (!m_is_sync_supported || (m_sync_value.lo == 0 && m_sync_value.hi == 0U)) @@ -508,7 +508,7 @@ void AppLin::UpdateSyncCounter() m_sync_state = SyncState::NotNeeded; } -void AppLin::OnWindowConfigured(const xcb_configure_notify_event_t& conf_event) +void App::OnWindowConfigured(const xcb_configure_notify_event_t& conf_event) { META_FUNCTION_TASK(); if (conf_event.window != m_env.window || @@ -524,7 +524,7 @@ void AppLin::OnWindowConfigured(const xcb_configure_notify_event_t& conf_event) Resize(Data::FrameSize(conf_event.width, conf_event.height), false); } -void AppLin::OnPropertyChanged(const xcb_property_notify_event_t& prop_event) +void App::OnPropertyChanged(const xcb_property_notify_event_t& prop_event) { META_FUNCTION_TASK(); if (prop_event.atom != m_state_atom || prop_event.window != m_env.window) @@ -546,14 +546,14 @@ void AppLin::OnPropertyChanged(const xcb_property_notify_event_t& prop_event) } } -void AppLin::OnKeyboardChanged(const xcb_key_press_event_t& key_press_event, Input::Keyboard::KeyState key_state) +void App::OnKeyboardChanged(const xcb_key_press_event_t& key_press_event, Input::Keyboard::KeyState key_state) { META_FUNCTION_TASK(); const Input::Keyboard::Key key = Linux::ConvertXcbKey(m_env.display, m_env.window, key_press_event.detail, key_press_event.state); ProcessInputWithErrorHandling(&Input::IActionController::OnKeyboardChanged, key, key_state); } -void AppLin::OnKeyboardMappingChanged(const xcb_mapping_notify_event_t& mapping_event) +void App::OnKeyboardMappingChanged(const xcb_mapping_notify_event_t& mapping_event) { META_FUNCTION_TASK(); XMappingEvent x_mapping_event{ 0 }; @@ -568,7 +568,7 @@ void AppLin::OnKeyboardMappingChanged(const xcb_mapping_notify_event_t& mapping_ XRefreshKeyboardMapping(&x_mapping_event); } -void AppLin::OnMouseButtonChanged(const xcb_button_press_event_t& button_press_event, Input::Mouse::ButtonState button_state) +void App::OnMouseButtonChanged(const xcb_button_press_event_t& button_press_event, Input::Mouse::ButtonState button_state) { META_FUNCTION_TASK(); using enum Input::Mouse::Button; @@ -592,21 +592,21 @@ void AppLin::OnMouseButtonChanged(const xcb_button_press_event_t& button_press_e } } -void AppLin::OnMouseMoved(const xcb_motion_notify_event_t& motion_event) +void App::OnMouseMoved(const xcb_motion_notify_event_t& motion_event) { META_FUNCTION_TASK(); const Input::Mouse::Position mouse_pos(motion_event.event_x, motion_event.event_y); ProcessInputWithErrorHandling(&Input::IActionController::OnMousePositionChanged, mouse_pos); } -void AppLin::OnMouseInWindowChanged(const xcb_enter_notify_event_t& enter_event, bool mouse_in_window) +void App::OnMouseInWindowChanged(const xcb_enter_notify_event_t& enter_event, bool mouse_in_window) { META_FUNCTION_TASK(); META_UNUSED(enter_event); ProcessInputWithErrorHandling(&Input::IActionController::OnMouseInWindowChanged, mouse_in_window); } -MessageBox& AppLin::GetMessageBox() +MessageBox& App::GetMessageBox() { META_FUNCTION_TASK(); if (!m_message_box_ptr) @@ -616,4 +616,4 @@ MessageBox& AppLin::GetMessageBox() return *m_message_box_ptr; } -} // namespace Methane::Platform \ No newline at end of file +} // namespace Methane::Platform::Linux \ No newline at end of file diff --git a/Modules/Platform/App/Sources/Methane/Platform/Linux/MessageBox.cpp b/Modules/Platform/Linux/App/Sources/Methane/Platform/Linux/MessageBox.cpp similarity index 99% rename from Modules/Platform/App/Sources/Methane/Platform/Linux/MessageBox.cpp rename to Modules/Platform/Linux/App/Sources/Methane/Platform/Linux/MessageBox.cpp index 009a8dbdb..acb376dd1 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/Linux/MessageBox.cpp +++ b/Modules/Platform/Linux/App/Sources/Methane/Platform/Linux/MessageBox.cpp @@ -34,7 +34,7 @@ Linux message box implementation with X11/XCB. #include -namespace Methane::Platform +namespace Methane::Platform::Linux { static const std::string_view g_default_font_name = "-*-fixed-medium-r-*--15-*-*-*-*-*-*-*"; @@ -375,4 +375,4 @@ void MessageBox::OnMouseButtonChanged(const xcb_button_press_event_t& button_pre } } -} // namespace Methane::Platform +} // namespace Methane::Platform::Linux diff --git a/Modules/Platform/App/Sources/Methane/Platform/Linux/MessageBox.h b/Modules/Platform/Linux/App/Sources/Methane/Platform/Linux/MessageBox.h similarity index 96% rename from Modules/Platform/App/Sources/Methane/Platform/Linux/MessageBox.h rename to Modules/Platform/Linux/App/Sources/Methane/Platform/Linux/MessageBox.h index ce4f7c362..ea7ef884b 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/Linux/MessageBox.h +++ b/Modules/Platform/Linux/App/Sources/Methane/Platform/Linux/MessageBox.h @@ -29,7 +29,7 @@ Linux message box implementation with X11/XCB. #include -namespace Methane::Platform +namespace Methane::Platform::Linux { class MessageBox // NOSONAR @@ -69,4 +69,4 @@ class MessageBox // NOSONAR bool m_is_event_processing = false; }; -} // namespace Methane::Platform +} // namespace Methane::Platform::Linux diff --git a/Modules/Platform/App/Sources/Methane/Platform/Linux/XcbUtils.cpp b/Modules/Platform/Linux/App/Sources/Methane/Platform/Linux/XcbUtils.cpp similarity index 99% rename from Modules/Platform/App/Sources/Methane/Platform/Linux/XcbUtils.cpp rename to Modules/Platform/Linux/App/Sources/Methane/Platform/Linux/XcbUtils.cpp index 9c5b21fe9..b3c11a408 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/Linux/XcbUtils.cpp +++ b/Modules/Platform/Linux/App/Sources/Methane/Platform/Linux/XcbUtils.cpp @@ -228,5 +228,5 @@ ScreenRect GetPrimaryMonitorRect(xcb_connection_t* connection, xcb_window_t root #endif } -} // namespace Methane::Platform +} // namespace Methane::Platform::Linux ; \ No newline at end of file diff --git a/Modules/Platform/App/Sources/Methane/Platform/Linux/XcbUtils.h b/Modules/Platform/Linux/App/Sources/Methane/Platform/Linux/XcbUtils.h similarity index 99% rename from Modules/Platform/App/Sources/Methane/Platform/Linux/XcbUtils.h rename to Modules/Platform/Linux/App/Sources/Methane/Platform/Linux/XcbUtils.h index c562ad81e..f4338f440 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/Linux/XcbUtils.h +++ b/Modules/Platform/Linux/App/Sources/Methane/Platform/Linux/XcbUtils.h @@ -25,6 +25,7 @@ X11/XCB utility functions. #include #include +#include #include #include diff --git a/Modules/Platform/Linux/AppView/CMakeLists.txt b/Modules/Platform/Linux/AppView/CMakeLists.txt new file mode 100644 index 000000000..144f5835c --- /dev/null +++ b/Modules/Platform/Linux/AppView/CMakeLists.txt @@ -0,0 +1,35 @@ +set(TARGET MethanePlatformAppViewLinux) + +include(MethaneModules) + +get_module_dirs("Methane/Platform") + +list(APPEND HEADERS + ${CMAKE_CURRENT_SOURCE_DIR}/${INCLUDE_PLATFORM_OS_DIR}/AppEnvironment.h +) + +add_library(${TARGET} INTERFACE) + +target_sources(${TARGET} + INTERFACE + ${HEADERS} +) + +target_include_directories(${TARGET} + INTERFACE + ${CMAKE_CURRENT_SOURCE_DIR}/Include +) + +source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS}) + +set_target_properties(${TARGET} + PROPERTIES + FOLDER Modules/Platform/Linux + PUBLIC_HEADER "${HEADERS}" +) + +install(TARGETS ${TARGET} + PUBLIC_HEADER + DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} + COMPONENT Development +) diff --git a/Modules/Platform/AppView/Include/Methane/Platform/Linux/AppEnvironment.h b/Modules/Platform/Linux/AppView/Include/Methane/Platform/Linux/AppEnvironment.h similarity index 100% rename from Modules/Platform/AppView/Include/Methane/Platform/Linux/AppEnvironment.h rename to Modules/Platform/Linux/AppView/Include/Methane/Platform/Linux/AppEnvironment.h diff --git a/Modules/Platform/Linux/CMakeLists.txt b/Modules/Platform/Linux/CMakeLists.txt new file mode 100644 index 000000000..2b7f51c09 --- /dev/null +++ b/Modules/Platform/Linux/CMakeLists.txt @@ -0,0 +1,4 @@ +add_subdirectory(Utils) +add_subdirectory(Input) +add_subdirectory(AppView) +add_subdirectory(App) diff --git a/Modules/Platform/Linux/Input/CMakeLists.txt b/Modules/Platform/Linux/Input/CMakeLists.txt new file mode 100644 index 000000000..df28aa576 --- /dev/null +++ b/Modules/Platform/Linux/Input/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(Keyboard) diff --git a/Modules/Platform/Linux/Input/Keyboard/CMakeLists.txt b/Modules/Platform/Linux/Input/Keyboard/CMakeLists.txt new file mode 100644 index 000000000..c6b96913d --- /dev/null +++ b/Modules/Platform/Linux/Input/Keyboard/CMakeLists.txt @@ -0,0 +1,59 @@ +set(TARGET MethanePlatformInputKeyboardLinux) + +include(MethaneModules) + +get_module_dirs("Methane/Platform/Input") + +list(APPEND HEADERS + ${INCLUDE_PLATFORM_OS_DIR}/Keyboard.h +) + +list(APPEND SOURCES + ${SOURCES_PLATFORM_OS_DIR}/Keyboard.cpp +) + +add_library(${TARGET} STATIC + ${HEADERS} + ${SOURCES} +) + +target_link_libraries(${TARGET} + PUBLIC + MethanePlatformInputKeyboardBase + PRIVATE + MethaneBuildOptions + MethaneCommonPrecompiledHeaders + MethanePrimitives + MethaneInstrumentation + magic_enum +) + +if(METHANE_PRECOMPILED_HEADERS_ENABLED) + target_precompile_headers(${TARGET} REUSE_FROM MethaneCommonPrecompiledHeaders) +endif() + +target_include_directories(${TARGET} + PRIVATE + Sources + ${X11_xcb_INCLUDE_PATH} + ${X11_X11_INCLUDE_PATH} + PUBLIC + Include +) + +source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) + +set_target_properties(${TARGET} + PROPERTIES + FOLDER Modules/Platform/Linux/Input + PUBLIC_HEADER "${HEADERS}" +) + +install(TARGETS ${TARGET} + PUBLIC_HEADER + DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} + COMPONENT Development + ARCHIVE + DESTINATION lib + COMPONENT Development +) diff --git a/Modules/Platform/Input/Keyboard/Include/Methane/Platform/Input/Linux/Keyboard.h b/Modules/Platform/Linux/Input/Keyboard/Include/Methane/Platform/Input/Linux/Keyboard.h similarity index 100% rename from Modules/Platform/Input/Keyboard/Include/Methane/Platform/Input/Linux/Keyboard.h rename to Modules/Platform/Linux/Input/Keyboard/Include/Methane/Platform/Input/Linux/Keyboard.h diff --git a/Modules/Platform/Input/Keyboard/Sources/Methane/Platform/Input/Linux/Keyboard.cpp b/Modules/Platform/Linux/Input/Keyboard/Sources/Methane/Platform/Input/Linux/Keyboard.cpp similarity index 99% rename from Modules/Platform/Input/Keyboard/Sources/Methane/Platform/Input/Linux/Keyboard.cpp rename to Modules/Platform/Linux/Input/Keyboard/Sources/Methane/Platform/Input/Linux/Keyboard.cpp index fac129afc..ac9216d1d 100644 --- a/Modules/Platform/Input/Keyboard/Sources/Methane/Platform/Input/Linux/Keyboard.cpp +++ b/Modules/Platform/Linux/Input/Keyboard/Sources/Methane/Platform/Input/Linux/Keyboard.cpp @@ -21,6 +21,7 @@ Linux platform specific types and implementation of Keyboard abstractions. ******************************************************************************/ +#include #include #include diff --git a/Modules/Platform/Linux/Utils/CMakeLists.txt b/Modules/Platform/Linux/Utils/CMakeLists.txt new file mode 100644 index 000000000..3264dc860 --- /dev/null +++ b/Modules/Platform/Linux/Utils/CMakeLists.txt @@ -0,0 +1,56 @@ +set(TARGET MethanePlatformUtilsLinux) + +include(MethaneModules) + +get_module_dirs("Methane/Platform") + +list(APPEND HEADERS + ${INCLUDE_PLATFORM_OS_DIR}/Utils.h +) + +list(APPEND SOURCES + ${SOURCES_PLATFORM_OS_DIR}/Utils.cpp +) + +add_library(${TARGET} STATIC + ${HEADERS} + ${SOURCES} +) + +target_link_libraries(${TARGET} + PUBLIC + MethanePlatformUtilsBase + PRIVATE + MethaneBuildOptions + MethaneCommonPrecompiledHeaders + MethaneInstrumentation + nowide +) + +if(METHANE_PRECOMPILED_HEADERS_ENABLED) + target_precompile_headers(${TARGET} REUSE_FROM MethaneCommonPrecompiledHeaders) +endif() + +target_include_directories(${TARGET} + PRIVATE + Sources + PUBLIC + Include +) + +source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) + +set_target_properties(${TARGET} + PROPERTIES + FOLDER Modules/Platform/Linux + PUBLIC_HEADER "${HEADERS}" +) + +install(TARGETS ${TARGET} + PUBLIC_HEADER + DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} + COMPONENT Development + ARCHIVE + DESTINATION lib + COMPONENT Development +) diff --git a/Modules/Platform/Utils/Include/Methane/Platform/Linux/Utils.h b/Modules/Platform/Linux/Utils/Include/Methane/Platform/Linux/Utils.h similarity index 100% rename from Modules/Platform/Utils/Include/Methane/Platform/Linux/Utils.h rename to Modules/Platform/Linux/Utils/Include/Methane/Platform/Linux/Utils.h diff --git a/Modules/Platform/Utils/Sources/Methane/Platform/Linux/Utils.cpp b/Modules/Platform/Linux/Utils/Sources/Methane/Platform/Linux/Utils.cpp similarity index 100% rename from Modules/Platform/Utils/Sources/Methane/Platform/Linux/Utils.cpp rename to Modules/Platform/Linux/Utils/Sources/Methane/Platform/Linux/Utils.cpp diff --git a/Modules/Platform/MacOS/App/CMakeLists.txt b/Modules/Platform/MacOS/App/CMakeLists.txt new file mode 100644 index 000000000..21d1b4fa0 --- /dev/null +++ b/Modules/Platform/MacOS/App/CMakeLists.txt @@ -0,0 +1,81 @@ +set(TARGET MethanePlatformAppMacOS) + +include(MethaneModules) + +get_module_dirs("Methane/Platform") + +list(APPEND HEADERS + ${INCLUDE_PLATFORM_OS_DIR}/App.hh + ${SOURCES_PLATFORM_OS_DIR}/AppDelegate.hh + ${SOURCES_PLATFORM_OS_DIR}/AppViewController.hh + ${SOURCES_PLATFORM_OS_DIR}/WindowDelegate.hh +) + +list(APPEND SOURCES + ${SOURCES_PLATFORM_OS_DIR}/App.mm + ${SOURCES_PLATFORM_OS_DIR}/AppDelegate.mm + ${SOURCES_PLATFORM_OS_DIR}/AppViewController.mm + ${SOURCES_PLATFORM_OS_DIR}/WindowDelegate.mm +) + +add_library(${TARGET} STATIC + ${HEADERS} + ${SOURCES} +) + +target_link_libraries(${TARGET} + PUBLIC + MethanePlatformAppBase + MethanePlatformAppViewMacOS + MethanePlatformInputKeyboardMacOS + "-framework AppKit" + PRIVATE + MethaneBuildOptions + MethaneCommonPrecompiledHeaders + MethanePlatformUtilsApple + MethaneDataProvider + fmt + nowide +) + +target_compile_definitions(${TARGET} + PRIVATE + METHANE_RENDER_APP +) + +if(METHANE_PRECOMPILED_HEADERS_ENABLED) + target_precompile_headers(${TARGET} REUSE_FROM MethaneCommonPrecompiledHeaders) +endif() + +target_include_directories(${TARGET} + PRIVATE + Sources + ${SOURCES_PLATFORM_OS_DIR} + PUBLIC + Include +) + +# Disable precompiled headers and enable ARC for Objective-C sources: +set_source_files_properties( + ${SOURCES} + PROPERTIES + COMPILE_FLAGS -fobjc-arc + SKIP_PRECOMPILE_HEADERS ON +) + +source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) + +set_target_properties(${TARGET} + PROPERTIES + FOLDER Modules/Platform/MacOS + PUBLIC_HEADER "${HEADERS}" +) + +install(TARGETS ${TARGET} + PUBLIC_HEADER + DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} + COMPONENT Development + ARCHIVE + DESTINATION lib + COMPONENT Development +) diff --git a/Modules/Platform/App/Include/Methane/Platform/MacOS/AppMac.hh b/Modules/Platform/MacOS/App/Include/Methane/Platform/MacOS/App.hh similarity index 82% rename from Modules/Platform/App/Include/Methane/Platform/MacOS/AppMac.hh rename to Modules/Platform/MacOS/App/Include/Methane/Platform/MacOS/App.hh index f535e4aeb..b9cccd0c7 100644 --- a/Modules/Platform/App/Include/Methane/Platform/MacOS/AppMac.hh +++ b/Modules/Platform/MacOS/App/Include/Methane/Platform/MacOS/App.hh @@ -16,14 +16,14 @@ limitations under the License. ******************************************************************************* -FILE: Methane/Platform/MacOS/AppMac.h +FILE: Methane/Platform/MacOS/App.hh MacOS application implementation. ******************************************************************************/ #pragma once -#include +#include #include #ifdef __OBJC__ @@ -46,17 +46,17 @@ using NSWindow = void; #endif // __OBJC__ -namespace Methane::Platform +namespace Methane::Platform::MacOS { -class AppMac : public AppBase +class App : public Base::App { public: - static AppMac* GetInstance(); + static App* GetInstance(); - explicit AppMac(const AppBase::Settings& settings); + explicit App(const Base::App::Settings& settings); - // AppBase interface + // Base::App interface void InitContext(const Platform::AppEnvironment& env, const Data::FrameSize& frame_size) override; int Run(const RunArgs& args) override; void Alert(const Message& msg, bool deferred = false) override; @@ -67,11 +67,11 @@ public: void Close() override; void SetWindow(NSWindow* ns_window); - bool SetFullScreenInternal(bool is_full_screen) { return AppBase::SetFullScreen(is_full_screen); } + bool SetFullScreenInternal(bool is_full_screen) { return Base::App::SetFullScreen(is_full_screen); } NSWindow* GetWindow() { return m_ns_window; } // NOSONAR protected: - // AppBase interface + // Base::App interface void ShowAlert(const Message& msg) override; private: @@ -79,7 +79,7 @@ private: AppDelegateType* m_ns_app_delegate = nullptr; // NOSONAR NSWindow* m_ns_window = nullptr; // NOSONAR - static AppMac* s_instance_ptr; + static App* s_instance_ptr; }; -} // namespace Methane::Platform +} // namespace Methane::Platform::MacOS diff --git a/Modules/Platform/App/Sources/Methane/Platform/MacOS/AppMac.mm b/Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/App.mm similarity index 72% rename from Modules/Platform/App/Sources/Methane/Platform/MacOS/AppMac.mm rename to Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/App.mm index 9dabede0f..b7ab56da3 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/MacOS/AppMac.mm +++ b/Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/App.mm @@ -16,41 +16,41 @@ ******************************************************************************* -FILE: Methane/Platform/MacOS/AppMac.mm +FILE: Methane/Platform/MacOS/App.mm MacOS application implementation. ******************************************************************************/ -#include +#include #include #include #include -namespace Methane::Platform +namespace Methane::Platform::MacOS { -AppMac* AppMac::s_instance_ptr = nullptr; +App* App::s_instance_ptr = nullptr; -static NSAlertStyle ConvertMessageTypeToNsAlertStyle(AppBase::Message::Type msg_type) +static NSAlertStyle ConvertMessageTypeToNsAlertStyle(Base::App::Message::Type msg_type) { META_FUNCTION_TASK(); switch(msg_type) { - case AppBase::Message::Type::Information: return NSAlertStyleInformational; - case AppBase::Message::Type::Warning: return NSAlertStyleWarning; - case AppBase::Message::Type::Error: return NSAlertStyleCritical; + case Base::App::Message::Type::Information: return NSAlertStyleInformational; + case Base::App::Message::Type::Warning: return NSAlertStyleWarning; + case Base::App::Message::Type::Error: return NSAlertStyleCritical; default: META_UNEXPECTED_RETURN(msg_type, NSAlertStyleInformational); } } -AppMac* AppMac::GetInstance() +App* App::GetInstance() { META_FUNCTION_TASK(); return s_instance_ptr; } -AppMac::AppMac(const AppBase::Settings& settings) - : AppBase(settings) +App::App(const Base::App::Settings& settings) + : Base::App(settings) , m_ns_app([NSApplication sharedApplication]) { META_FUNCTION_TASK(); @@ -58,7 +58,7 @@ static NSAlertStyle ConvertMessageTypeToNsAlertStyle(AppBase::Message::Type msg_ s_instance_ptr = this; } -void AppMac::InitContext(const Platform::AppEnvironment& /*env*/, const Data::FrameSize& /*frame_size*/) +void App::InitContext(const Platform::AppEnvironment& /*env*/, const Data::FrameSize& /*frame_size*/) { META_FUNCTION_TASK(); AppView app_view = GetView(); @@ -68,10 +68,10 @@ static NSAlertStyle ConvertMessageTypeToNsAlertStyle(AppBase::Message::Type msg_ [m_ns_window.contentView addSubview: app_view.native_view_ptr]; } -int AppMac::Run(const RunArgs& args) +int App::Run(const RunArgs& args) { META_FUNCTION_TASK(); - const int base_return_code = AppBase::Run(args); + const int base_return_code = Base::App::Run(args); if (base_return_code) return base_return_code; @@ -82,7 +82,7 @@ static NSAlertStyle ConvertMessageTypeToNsAlertStyle(AppBase::Message::Type msg_ return 0; } -void AppMac::Alert(const Message& msg, bool deferred) +void App::Alert(const Message& msg, bool deferred) { META_FUNCTION_TASK(); if (deferred) @@ -100,10 +100,10 @@ static NSAlertStyle ConvertMessageTypeToNsAlertStyle(AppBase::Message::Type msg_ ShowAlert(msg); } - AppBase::Alert(msg, deferred); + Base::App::Alert(msg, deferred); } -void AppMac::SetWindowTitle(const std::string& title_text) +void App::SetWindowTitle(const std::string& title_text) { META_FUNCTION_TASK(); NSString* ns_title_text = MacOS::ConvertToNsString(title_text); @@ -112,13 +112,13 @@ static NSAlertStyle ConvertMessageTypeToNsAlertStyle(AppBase::Message::Type msg_ }); } -void AppMac::SetWindow(NSWindow* ns_window) +void App::SetWindow(NSWindow* ns_window) { META_FUNCTION_TASK(); m_ns_window = ns_window; } -void AppMac::ShowAlert(const Message& msg) +void App::ShowAlert(const Message& msg) { META_FUNCTION_TASK(); META_CHECK_NOT_NULL(m_ns_app_delegate); @@ -127,13 +127,13 @@ static NSAlertStyle ConvertMessageTypeToNsAlertStyle(AppBase::Message::Type msg_ withInformation: MacOS::ConvertToNsString(msg.information) andStyle: ConvertMessageTypeToNsAlertStyle(msg.type)]; - AppBase::ShowAlert(msg); + Base::App::ShowAlert(msg); } -bool AppMac::SetFullScreen(bool is_full_screen) +bool App::SetFullScreen(bool is_full_screen) { META_FUNCTION_TASK(); - if (!AppBase::SetFullScreen(is_full_screen)) + if (!Base::App::SetFullScreen(is_full_screen)) return false; const NSApplicationPresentationOptions app_options = [m_ns_app presentationOptions]; @@ -145,22 +145,22 @@ static NSAlertStyle ConvertMessageTypeToNsAlertStyle(AppBase::Message::Type msg_ return true; } -float AppMac::GetContentScalingFactor() const +float App::GetContentScalingFactor() const { META_FUNCTION_TASK(); return static_cast(m_ns_window.backingScaleFactor); } -uint32_t AppMac::GetFontResolutionDpi() const +uint32_t App::GetFontResolutionDpi() const { META_FUNCTION_TASK(); return 72U * GetContentScalingFactor(); } -void AppMac::Close() +void App::Close() { META_FUNCTION_TASK(); [m_ns_window close]; } -} // namespace Methane::Platform +} // namespace Methane::Platform::MacOS diff --git a/Modules/Platform/App/Sources/Methane/Platform/MacOS/AppDelegate.hh b/Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/AppDelegate.hh similarity index 83% rename from Modules/Platform/App/Sources/Methane/Platform/MacOS/AppDelegate.hh rename to Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/AppDelegate.hh index bb21d58b6..f43a74cd7 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/MacOS/AppDelegate.hh +++ b/Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/AppDelegate.hh @@ -23,18 +23,18 @@ MacOS application delegate implementation. #include "AppViewController.hh" -#include +#include #import -namespace Methane::Platform { class AppMac; } +namespace Methane::Platform::MacOS { class App; } @interface AppDelegate : NSObject @property (nonatomic, strong, nonnull) IBOutlet AppViewController* viewController; @property (nonatomic, readwrite, nullable, retain) NSWindow* window; -- (id _Nullable) initWithApp : (Methane::Platform::AppMac* _Nonnull) app_ptr andSettings : (const Methane::Platform::AppBase::Settings* _Nonnull) settings_ptr; +- (id _Nullable) initWithApp : (Methane::Platform::MacOS::App* _Nonnull) app_ptr andSettings : (const Methane::Platform::Base::App::Settings* _Nonnull) settings_ptr; - (void) run; - (void) alert : (nonnull NSString*) ns_title withInformation: (nonnull NSString*) ns_info andStyle: (NSAlertStyle) ns_alert_style; diff --git a/Modules/Platform/App/Sources/Methane/Platform/MacOS/AppDelegate.mm b/Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/AppDelegate.mm similarity index 95% rename from Modules/Platform/App/Sources/Methane/Platform/MacOS/AppDelegate.mm rename to Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/AppDelegate.mm index 4dadad607..19cf1a84b 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/MacOS/AppDelegate.mm +++ b/Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/AppDelegate.mm @@ -25,7 +25,7 @@ #import "WindowDelegate.hh" -#include +#include #include #include #include @@ -40,7 +40,7 @@ @implementation AppDelegate @synthesize window = m_window; -- (id) initWithApp : (AppMac*) app_ptr andSettings : (const AppBase::Settings*) settings_ptr +- (id) initWithApp : (MacOS::App*) app_ptr andSettings : (const Base::App::Settings*) settings_ptr { META_FUNCTION_TASK(); self = [super init]; @@ -133,7 +133,7 @@ - (void) windowWillEnterFullScreen:(NSNotification *)notification { META_FUNCTION_TASK(); #pragma unused(notification) - AppMac* app_ptr = [self.viewController getApp]; + MacOS::App* app_ptr = [self.viewController getApp]; META_CHECK_NOT_NULL(app_ptr); app_ptr->SetFullScreenInternal(true); } @@ -142,7 +142,7 @@ - (void) windowWillExitFullScreen:(NSNotification *)notification { META_FUNCTION_TASK(); #pragma unused(notification) - AppMac* app_ptr = [self.viewController getApp]; + MacOS::App* app_ptr = [self.viewController getApp]; META_CHECK_NOT_NULL(app_ptr); app_ptr->SetFullScreenInternal(false); } diff --git a/Modules/Platform/App/Sources/Methane/Platform/MacOS/AppViewController.hh b/Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/AppViewController.hh similarity index 83% rename from Modules/Platform/App/Sources/Methane/Platform/MacOS/AppViewController.hh rename to Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/AppViewController.hh index 816169ed7..135444100 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/MacOS/AppViewController.hh +++ b/Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/AppViewController.hh @@ -23,13 +23,13 @@ MacOS application view controller implementation. #import -namespace Methane::Platform { class AppMac; } +namespace Methane::Platform::MacOS { class App; } @interface AppViewController : NativeViewController @property (nonatomic, readonly, nullable) NSWindow* window; -- (id _Nullable) initWithApp : (Methane::Platform::AppMac* _Nonnull) app_ptr andFrameRect : (NSRect) frame; -- (Methane::Platform::AppMac* _Nonnull) getApp; +- (id _Nullable) initWithApp : (Methane::Platform::MacOS::App* _Nonnull) app_ptr andFrameRect : (NSRect) frame; +- (Methane::Platform::MacOS::App* _Nonnull) getApp; @end diff --git a/Modules/Platform/App/Sources/Methane/Platform/MacOS/AppViewController.mm b/Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/AppViewController.mm similarity index 97% rename from Modules/Platform/App/Sources/Methane/Platform/MacOS/AppViewController.mm rename to Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/AppViewController.mm index ce3b142e7..bb84e86f2 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/MacOS/AppViewController.mm +++ b/Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/AppViewController.mm @@ -23,7 +23,7 @@ #import "AppViewController.hh" -#include +#include #include #include #include @@ -36,13 +36,13 @@ @implementation AppViewController { - pal::AppMac* m_app_ptr; + pal::MacOS::App* m_app_ptr; NSRect m_frame_rect; bool m_is_initialized; std::string m_error; } -- (id) initWithApp : (pal::AppMac*) app_ptr andFrameRect : (NSRect) frame_rect +- (id) initWithApp : (pal::MacOS::App*) app_ptr andFrameRect : (NSRect) frame_rect { META_FUNCTION_TASK(); @@ -63,7 +63,7 @@ -(NSWindow*) window return m_app_ptr ? m_app_ptr->GetWindow() : nil; } -- (pal::AppMac*) getApp +- (pal::MacOS::App*) getApp { return m_app_ptr; } diff --git a/Modules/Platform/App/Sources/Methane/Platform/MacOS/WindowDelegate.hh b/Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/WindowDelegate.hh similarity index 87% rename from Modules/Platform/App/Sources/Methane/Platform/MacOS/WindowDelegate.hh rename to Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/WindowDelegate.hh index b65081b99..6017b7fcc 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/MacOS/WindowDelegate.hh +++ b/Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/WindowDelegate.hh @@ -23,10 +23,10 @@ MacOS application delegate implementation. #import -namespace Methane { namespace Platform { class AppMac; } } +namespace Methane::Platform::MacOS { class App; } @interface WindowDelegate : NSObject -- (id _Nullable) initWithApp : (Methane::Platform::AppMac* _Nonnull) app_ptr; +- (id _Nullable) initWithApp : (Methane::Platform::MacOS::App* _Nonnull) app_ptr; @end diff --git a/Modules/Platform/App/Sources/Methane/Platform/MacOS/WindowDelegate.mm b/Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/WindowDelegate.mm similarity index 96% rename from Modules/Platform/App/Sources/Methane/Platform/MacOS/WindowDelegate.mm rename to Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/WindowDelegate.mm index f261a1344..0b1b72865 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/MacOS/WindowDelegate.mm +++ b/Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/WindowDelegate.mm @@ -23,7 +23,7 @@ #import "WindowDelegate.hh" -#include +#include #include #include @@ -32,11 +32,11 @@ @implementation WindowDelegate { - AppMac* m_app_ptr; + MacOS::App* m_app_ptr; Data::FrameSize m_frame_size; } -- (id) initWithApp : (AppMac*) app_ptr +- (id) initWithApp : (MacOS::App*) app_ptr { META_FUNCTION_TASK(); diff --git a/Modules/Platform/MacOS/AppView/CMakeLists.txt b/Modules/Platform/MacOS/AppView/CMakeLists.txt new file mode 100644 index 000000000..c1c3e97e0 --- /dev/null +++ b/Modules/Platform/MacOS/AppView/CMakeLists.txt @@ -0,0 +1,67 @@ +set(TARGET MethanePlatformAppViewMacOS) + +include(MethaneModules) + +get_module_dirs("Methane/Platform") + +list(APPEND HEADERS + ${INCLUDE_PLATFORM_OS_DIR}/AppEnvironment.hh + ${INCLUDE_PLATFORM_OS_DIR}/AppViewMetal.hh +) + +list(APPEND SOURCES + ${SOURCES_PLATFORM_OS_DIR}/AppViewMetal.mm +) + +add_library(${TARGET} STATIC + ${HEADERS} + ${SOURCES} +) + +target_link_libraries(${TARGET} + PUBLIC + "-framework AppKit" + "-framework Metal" + "-framework QuartzCore" + PRIVATE + MethaneBuildOptions + MethaneInstrumentation + MethaneDataTypes +) + +target_compile_definitions(${TARGET} + PRIVATE + $<$:METHANE_GPU_INSTRUMENTATION_ENABLED> +) + +target_include_directories(${TARGET} + PRIVATE + Sources + PUBLIC + Include +) + +# Disable precompiled headers, enable ARC and weak Objective-C references: +set_source_files_properties( + ${SOURCES} + PROPERTIES + COMPILE_FLAGS "-fobjc-arc -fobjc-weak" + SKIP_PRECOMPILE_HEADERS ON +) + +source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) + +set_target_properties(${TARGET} + PROPERTIES + FOLDER Modules/Platform/MacOS + PUBLIC_HEADER "${HEADERS}" +) + +install(TARGETS ${TARGET} + PUBLIC_HEADER + DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} + COMPONENT Development + ARCHIVE + DESTINATION lib + COMPONENT Development +) diff --git a/Modules/Platform/AppView/Include/Methane/Platform/MacOS/AppEnvironment.hh b/Modules/Platform/MacOS/AppView/Include/Methane/Platform/MacOS/AppEnvironment.hh similarity index 100% rename from Modules/Platform/AppView/Include/Methane/Platform/MacOS/AppEnvironment.hh rename to Modules/Platform/MacOS/AppView/Include/Methane/Platform/MacOS/AppEnvironment.hh diff --git a/Modules/Platform/AppView/Include/Methane/Platform/MacOS/AppViewMetal.hh b/Modules/Platform/MacOS/AppView/Include/Methane/Platform/MacOS/AppViewMetal.hh similarity index 100% rename from Modules/Platform/AppView/Include/Methane/Platform/MacOS/AppViewMetal.hh rename to Modules/Platform/MacOS/AppView/Include/Methane/Platform/MacOS/AppViewMetal.hh diff --git a/Modules/Platform/AppView/Sources/Methane/Platform/MacOS/AppViewMetal.mm b/Modules/Platform/MacOS/AppView/Sources/Methane/Platform/MacOS/AppViewMetal.mm similarity index 100% rename from Modules/Platform/AppView/Sources/Methane/Platform/MacOS/AppViewMetal.mm rename to Modules/Platform/MacOS/AppView/Sources/Methane/Platform/MacOS/AppViewMetal.mm diff --git a/Modules/Platform/MacOS/CMakeLists.txt b/Modules/Platform/MacOS/CMakeLists.txt new file mode 100644 index 000000000..421717e6f --- /dev/null +++ b/Modules/Platform/MacOS/CMakeLists.txt @@ -0,0 +1,3 @@ +add_subdirectory(Input) +add_subdirectory(AppView) +add_subdirectory(App) diff --git a/Modules/Platform/MacOS/Input/CMakeLists.txt b/Modules/Platform/MacOS/Input/CMakeLists.txt new file mode 100644 index 000000000..df28aa576 --- /dev/null +++ b/Modules/Platform/MacOS/Input/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(Keyboard) diff --git a/Modules/Platform/MacOS/Input/Keyboard/CMakeLists.txt b/Modules/Platform/MacOS/Input/Keyboard/CMakeLists.txt new file mode 100644 index 000000000..ebb8963d7 --- /dev/null +++ b/Modules/Platform/MacOS/Input/Keyboard/CMakeLists.txt @@ -0,0 +1,66 @@ +set(TARGET MethanePlatformInputKeyboardMacOS) + +include(MethaneModules) + +get_module_dirs("Methane/Platform/Input") + +list(APPEND HEADERS + ${INCLUDE_PLATFORM_OS_DIR}/Keyboard.h +) + +list(APPEND SOURCES + ${SOURCES_PLATFORM_OS_DIR}/Keyboard.mm +) + +add_library(${TARGET} STATIC + ${HEADERS} + ${SOURCES} +) + +target_link_libraries(${TARGET} + PUBLIC + MethanePlatformInputKeyboardBase + "-framework AppKit" + PRIVATE + MethaneBuildOptions + MethaneCommonPrecompiledHeaders + MethanePrimitives + MethaneInstrumentation + magic_enum +) + +if(METHANE_PRECOMPILED_HEADERS_ENABLED) + target_precompile_headers(${TARGET} REUSE_FROM MethaneCommonPrecompiledHeaders) +endif() + +target_include_directories(${TARGET} + PRIVATE + Sources + PUBLIC + Include +) + +# Disable precompiled headers and enable ARC for Objective-C sources: +set_source_files_properties( + ${SOURCES} + PROPERTIES + COMPILE_FLAGS -fobjc-arc + SKIP_PRECOMPILE_HEADERS ON +) + +source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) + +set_target_properties(${TARGET} + PROPERTIES + FOLDER Modules/Platform/MacOS/Input + PUBLIC_HEADER "${HEADERS}" +) + +install(TARGETS ${TARGET} + PUBLIC_HEADER + DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} + COMPONENT Development + ARCHIVE + DESTINATION lib + COMPONENT Development +) diff --git a/Modules/Platform/Input/Keyboard/Include/Methane/Platform/Input/MacOS/Keyboard.h b/Modules/Platform/MacOS/Input/Keyboard/Include/Methane/Platform/Input/MacOS/Keyboard.h similarity index 100% rename from Modules/Platform/Input/Keyboard/Include/Methane/Platform/Input/MacOS/Keyboard.h rename to Modules/Platform/MacOS/Input/Keyboard/Include/Methane/Platform/Input/MacOS/Keyboard.h diff --git a/Modules/Platform/Input/Keyboard/Sources/Methane/Platform/Input/MacOS/Keyboard.mm b/Modules/Platform/MacOS/Input/Keyboard/Sources/Methane/Platform/Input/MacOS/Keyboard.mm similarity index 99% rename from Modules/Platform/Input/Keyboard/Sources/Methane/Platform/Input/MacOS/Keyboard.mm rename to Modules/Platform/MacOS/Input/Keyboard/Sources/Methane/Platform/Input/MacOS/Keyboard.mm index e0a6c56df..069cae86b 100644 --- a/Modules/Platform/Input/Keyboard/Sources/Methane/Platform/Input/MacOS/Keyboard.mm +++ b/Modules/Platform/MacOS/Input/Keyboard/Sources/Methane/Platform/Input/MacOS/Keyboard.mm @@ -21,6 +21,7 @@ ******************************************************************************/ +#include #include #include diff --git a/Modules/Platform/README.md b/Modules/Platform/README.md index 82abcbb1c..724f50754 100644 --- a/Modules/Platform/README.md +++ b/Modules/Platform/README.md @@ -1,25 +1,148 @@ # Methane Platform +Code of these modules is located in `Methane::Platform` namespace. + +Platform modules are grouped by platform support, similar to [Graphics RHI](../Graphics/RHI) modules: + +| Group | Namespace | Content | +|--------------------------|------------------------------|------------------------------------------------------------------| +| [Interfaces](Interfaces) | `Methane::Platform` | Public interfaces and settings structures with no implementation | +| [Base](Base) | `Methane::Platform::Base` | Platform-independent base implementations used by all platforms | +| [Common](Common) | `Methane::Platform` | Fully platform-independent implementations | +| [Windows](Windows) | `Methane::Platform::Windows` | Windows-specific implementations | +| [Linux](Linux) | `Methane::Platform::Linux` | Linux-specific implementations | +| [MacOS](MacOS) | `Methane::Platform::MacOS` | MacOS-specific implementations | +| [iOS](iOS) | `Methane::Platform::iOS` | iOS / tvOS-specific implementations | +| [Apple](Apple) | `Methane::Platform::Apple` | Implementations shared by all Apple platforms | +| [Impl](Impl) | `Methane::Platform` | Final implementation modules binding the groups above together | + +Exactly one platform group is added to the build by [CMakeLists.txt](CMakeLists.txt), chosen by the target platform. +Only the `Impl` group targets are intended to be linked from other domains: `MethanePlatformApp`, +`MethanePlatformAppView`, `MethanePlatformInputKeyboard` and `MethanePlatformUtils`. + ## Modules -Code of these modules is located in `Methane::Platform` namespace: +### App + +Application platform-abstraction class and platform-specific implementations — +see [Platform App description](Impl/App/README.md) for details. + +| Module | CMake Target | +|----------------------------------|-----------------------------| +| [Interfaces/App](Interfaces/App) | MethanePlatformAppInterface | +| [Base/App](Base/App) | MethanePlatformAppBase | +| [Common/App](Common/App) | MethanePlatformAppCommon | +| [Windows/App](Windows/App) | MethanePlatformAppWindows | +| [Linux/App](Linux/App) | MethanePlatformAppLinux | +| [MacOS/App](MacOS/App) | MethanePlatformAppMacOS | +| [iOS/App](iOS/App) | MethanePlatformAppIOS | +| [Impl/App](Impl/App) | MethanePlatformApp | + +### AppView + +Application view and environment platform-abstraction classes. + +| Module | CMake Target | +|------------------------------------|-------------------------------| +| [Windows/AppView](Windows/AppView) | MethanePlatformAppViewWindows | +| [Linux/AppView](Linux/AppView) | MethanePlatformAppViewLinux | +| [MacOS/AppView](MacOS/AppView) | MethanePlatformAppViewMacOS | +| [iOS/AppView](iOS/AppView) | MethanePlatformAppViewIOS | +| [Impl/AppView](Impl/AppView) | MethanePlatformAppView | + +### Input + +Application input with mouse and keyboard and platform-specific handling implementations. + +| Module | CMake Target | +|-----------------------------------------------------------------|---------------------------------------| +| [Base/Input/Keyboard](Base/Input/Keyboard) | MethanePlatformInputKeyboardBase | +| [Windows/Input/Keyboard](Windows/Input/Keyboard) | MethanePlatformInputKeyboardWindows | +| [Linux/Input/Keyboard](Linux/Input/Keyboard) | MethanePlatformInputKeyboardLinux | +| [MacOS/Input/Keyboard](MacOS/Input/Keyboard) | MethanePlatformInputKeyboardMacOS | +| [Impl/Input/Keyboard](Impl/Input/Keyboard) | MethanePlatformInputKeyboard | +| [Common/Input/Mouse](Common/Input/Mouse) | MethanePlatformInputMouse | +| [Common/Input/Controllers](Common/Input/Controllers) | MethanePlatformInputControllers | +| [Common/Input/ActionControllers](Common/Input/ActionControllers) | MethanePlatformInputActionControllers | + +The platform-specific `Keyboard::NativeKey` structure is defined in the +`/Keyboard.h>` header of the platform group, while the +platform-independent `Keyboard::Key`, `Keyboard::KeyConverter` and `Keyboard::State` classes +are defined in `` of the `Base` group. +iOS and tvOS have no native keyboard event translation implementation. + +### Utils + +Platform utilities. -- [AppView](AppView) - application view and environment platform-abstraction classes -- [App](App) - application platform-abstraction class and platform-specific implementations -- [Input](Input) - application input with mouse and keyboard and platform-specific handling implementations. -- [Utils](Utils) - platform utilities +| Module | CMake Target | +|--------------------------------|-----------------------------| +| [Base/Utils](Base/Utils) | MethanePlatformUtilsBase | +| [Windows/Utils](Windows/Utils) | MethanePlatformUtilsWindows | +| [Linux/Utils](Linux/Utils) | MethanePlatformUtilsLinux | +| [Apple/Utils](Apple/Utils) | MethanePlatformUtilsApple | +| [Impl/Utils](Impl/Utils) | MethanePlatformUtils | + +Platform-independent functions are declared in `` of the `Base` group, +while platform-specific ones are declared in `/Utils.h>` of the platform group. ## Intra-Domain Modules Dependencies +`Platform/...` in the graph below stands for the single platform group added to the build. + ```mermaid graph TD; - Utils-->Input/Keyboard; - Input/Keyboard-->Input/Controllers; - Input/Mouse-->Input/Controllers; - Input/Controllers-->Input/ActionControlls; - Input/ActionControlls-->App - AppView-->App - Utils-->App + subgraph Utils + utils_base([Base/Utils]) + utils_os([Platform/Utils]) + utils_impl([Impl/Utils]) + end + + subgraph Input + key_base([Base/Input/Keyboard]) + key_os([Platform/Input/Keyboard]) + key_impl([Impl/Input/Keyboard]) + mouse([Common/Input/Mouse]) + cont([Common/Input/Controllers]) + action([Common/Input/ActionControllers]) + end + + subgraph AppView + view_os([Platform/AppView]) + view_impl([Impl/AppView]) + end + + subgraph App + app_iface([Interfaces/App]) + app_base([Base/App]) + app_os([Platform/App]) + app_common([Common/App]) + app_impl([Impl/App]) + end + + utils_base-->utils_os + utils_base-->utils_impl + utils_os-->utils_impl + + utils_impl-->key_base + key_base-->key_os + key_base-->key_impl + key_os-->key_impl + + key_impl-->cont + mouse-->cont + cont-->action + + view_os-->view_impl + + app_iface-->app_base + action-->app_base + view_impl-->app_base + utils_impl-->app_base + app_base-->app_os + app_base-->app_common + app_os-->app_impl + app_common-->app_impl ``` ## Cross-Domain Modules Dependencies @@ -32,13 +155,13 @@ graph TD; end subgraph Platform - pal_util([Utils]) - pal_key([Input/Keyboard]) - pal_mouse([Input/Mouse]) - pal_cont([Input/Controllers]) - pal_action([Input/ActionControllers]) - pal_view([AppView]) - pal_app([App]) + pal_util([Impl/Utils]) + pal_key([Impl/Input/Keyboard]) + pal_mouse([Common/Input/Mouse]) + pal_cont([Common/Input/Controllers]) + pal_action([Common/Input/ActionControllers]) + pal_view([Impl/AppView]) + pal_app([Impl/App]) end pal_util-->pal_key diff --git a/Modules/Platform/Windows/App/CMakeLists.txt b/Modules/Platform/Windows/App/CMakeLists.txt new file mode 100644 index 000000000..608f0d241 --- /dev/null +++ b/Modules/Platform/Windows/App/CMakeLists.txt @@ -0,0 +1,69 @@ +set(TARGET MethanePlatformAppWindows) + +include(MethaneModules) + +get_module_dirs("Methane/Platform") + +list(APPEND HEADERS + ${INCLUDE_PLATFORM_OS_DIR}/App.h +) + +list(APPEND SOURCES + ${SOURCES_PLATFORM_OS_DIR}/App.cpp + ${SOURCES_PLATFORM_OS_DIR}/ConsoleStreams.h + ${SOURCES_PLATFORM_OS_DIR}/ConsoleStreams.cpp +) + +add_library(${TARGET} STATIC + ${HEADERS} + ${SOURCES} +) + +target_link_libraries(${TARGET} + PUBLIC + MethanePlatformAppBase + MethanePlatformAppViewWindows + MethanePlatformInputKeyboardWindows + PRIVATE + MethaneBuildOptions + MethaneCommonPrecompiledHeaders + MethanePlatformUtilsWindows + MethaneDataProvider + fmt + nowide + Shcore +) + +target_compile_definitions(${TARGET} + PRIVATE + METHANE_RENDER_APP +) + +if(METHANE_PRECOMPILED_HEADERS_ENABLED) + target_precompile_headers(${TARGET} REUSE_FROM MethaneCommonPrecompiledHeaders) +endif() + +target_include_directories(${TARGET} + PRIVATE + Sources + ${SOURCES_PLATFORM_OS_DIR} + PUBLIC + Include +) + +source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) + +set_target_properties(${TARGET} + PROPERTIES + FOLDER Modules/Platform/Windows + PUBLIC_HEADER "${HEADERS}" +) + +install(TARGETS ${TARGET} + PUBLIC_HEADER + DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} + COMPONENT Development + ARCHIVE + DESTINATION lib + COMPONENT Development +) diff --git a/Modules/Platform/App/Include/Methane/Platform/Windows/AppWin.h b/Modules/Platform/Windows/App/Include/Methane/Platform/Windows/App.h similarity index 89% rename from Modules/Platform/App/Include/Methane/Platform/Windows/AppWin.h rename to Modules/Platform/Windows/App/Include/Methane/Platform/Windows/App.h index 84c5979d4..d90e95366 100644 --- a/Modules/Platform/App/Include/Methane/Platform/Windows/AppWin.h +++ b/Modules/Platform/Windows/App/Include/Methane/Platform/Windows/App.h @@ -16,14 +16,14 @@ limitations under the License. ******************************************************************************* -FILE: Methane/Platform/Windows/AppWin.h +FILE: Methane/Platform/Windows/App.h Windows application implementation. ******************************************************************************/ #pragma once -#include +#include #include #include #include @@ -33,18 +33,18 @@ Windows application implementation. #include #include -namespace Methane::Platform +namespace Methane::Platform::Windows { class ConsoleStreams; -class AppWin : public AppBase +class App : public Base::App { public: - explicit AppWin(const Settings& settings); - ~AppWin() override; + explicit App(const Settings& settings); + ~App() override; - // AppBase interface + // Base::App interface int Run(const RunArgs& args) override; void Alert(const Message& msg, bool deferred = false) override; void SetWindowTitle(const std::string& title_text) override; @@ -54,7 +54,7 @@ class AppWin : public AppBase void Close() override; protected: - // AppBase interface + // Base::App interface void ShowAlert(const Message& msg) override; void ScheduleAlert(); @@ -81,4 +81,4 @@ class AppWin : public AppBase UniquePtr m_console_streams_ptr; }; -} // namespace Methane::Platform +} // namespace Methane::Platform::Windows diff --git a/Modules/Platform/App/Sources/Methane/Platform/Windows/AppWin.cpp b/Modules/Platform/Windows/App/Sources/Methane/Platform/Windows/App.cpp similarity index 91% rename from Modules/Platform/App/Sources/Methane/Platform/Windows/AppWin.cpp rename to Modules/Platform/Windows/App/Sources/Methane/Platform/Windows/App.cpp index 7c82cb8bf..511b9b0d7 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/Windows/AppWin.cpp +++ b/Modules/Platform/Windows/App/Sources/Methane/Platform/Windows/App.cpp @@ -16,14 +16,16 @@ limitations under the License. ******************************************************************************* -FILE: Methane/Platform/Windows/AppWin.cpp +FILE: Methane/Platform/Windows/App.cpp Windows application implementation. ******************************************************************************/ #include "ConsoleStreams.h" -#include +#include +#include +#include #include #include #include @@ -32,7 +34,7 @@ Windows application implementation. #include #include -namespace Methane::Platform +namespace Methane::Platform::Windows { constexpr auto WM_ALERT = WM_USER + 1; @@ -40,12 +42,12 @@ constexpr auto WM_ALERT = WM_USER + 1; static const wchar_t* const g_window_class = L"MethaneWindowClass"; static const wchar_t* const g_window_icon = L"IDI_APP_ICON"; -static UINT ConvertMessageTypeToFlags(AppBase::Message::Type msg_type) +static UINT ConvertMessageTypeToFlags(Base::App::Message::Type msg_type) { META_FUNCTION_TASK(); switch (msg_type) { - using enum AppBase::Message::Type; + using enum Base::App::Message::Type; case Information: return MB_ICONINFORMATION | MB_OK; case Warning: return MB_ICONWARNING | MB_OK; case Error: return MB_ICONERROR | MB_OK; @@ -81,20 +83,20 @@ static float GetDeviceScaleRatio(DEVICE_SCALE_FACTOR device_scale_factor) } } -AppWin::AppWin(const AppBase::Settings& settings) - : AppBase(settings) +App::App(const Base::App::Settings& settings) + : Base::App(settings) , m_console_streams_ptr(std::make_unique()) // NOSONAR { META_FUNCTION_TASK(); m_console_streams_ptr->Attach(); } -AppWin::~AppWin() = default; +App::~App() = default; -int AppWin::Run(const RunArgs& args) +int App::Run(const RunArgs& args) { // Skip instrumentation META_FUNCTION_TASK() since this is the only root function running till application close - if (const int base_return_code = AppBase::Run(args); + if (const int base_return_code = Base::App::Run(args); base_return_code) return base_return_code; @@ -112,7 +114,7 @@ int AppWin::Run(const RunArgs& args) uint32_t desktop_width = 0U; uint32_t desktop_height = 0U; - Windows::GetDesktopResolution(desktop_width, desktop_height); + GetDesktopResolution(desktop_width, desktop_height); const Settings& app_settings = GetPlatformAppSettings(); const Data::FrameSize frame_size( @@ -178,10 +180,10 @@ int AppWin::Run(const RunArgs& args) return static_cast(msg.wParam); } -void AppWin::Alert(const Message& msg, bool deferred) +void App::Alert(const Message& msg, bool deferred) { META_FUNCTION_TASK(); - AppBase::Alert(msg, deferred); + Base::App::Alert(msg, deferred); if (deferred) { @@ -193,7 +195,7 @@ void AppWin::Alert(const Message& msg, bool deferred) } } -void AppWin::OnWindowAlert() +void App::OnWindowAlert() { META_FUNCTION_TASK(); if (!HasDeferredMessage()) @@ -203,7 +205,7 @@ void AppWin::OnWindowAlert() ResetDeferredMessage(); } -LRESULT AppWin::OnWindowDestroy() +LRESULT App::OnWindowDestroy() { META_FUNCTION_TASK(); StopMessageProcessing(); @@ -211,7 +213,7 @@ LRESULT AppWin::OnWindowDestroy() return 0; } -void AppWin::OnWindowResized(WPARAM w_param, LPARAM l_param) +void App::OnWindowResized(WPARAM w_param, LPARAM l_param) { META_FUNCTION_TASK(); META_UNUSED(l_param); @@ -242,7 +244,7 @@ void AppWin::OnWindowResized(WPARAM w_param, LPARAM l_param) } } -LRESULT AppWin::OnWindowResizing(WPARAM w_param, LPARAM l_param) +LRESULT App::OnWindowResizing(WPARAM w_param, LPARAM l_param) { META_FUNCTION_TASK(); META_UNUSED(w_param); @@ -283,7 +285,7 @@ LRESULT AppWin::OnWindowResizing(WPARAM w_param, LPARAM l_param) return TRUE; } -void AppWin::OnWindowKeyboardEvent(WPARAM w_param, LPARAM l_param) +void App::OnWindowKeyboardEvent(WPARAM w_param, LPARAM l_param) { META_FUNCTION_TASK(); using enum Input::Keyboard::KeyState; @@ -313,7 +315,7 @@ void AppWin::OnWindowKeyboardEvent(WPARAM w_param, LPARAM l_param) } } -LRESULT AppWin::OnWindowMouseButtonEvent(UINT msg_id, WPARAM w_param, LPARAM l_param) +LRESULT App::OnWindowMouseButtonEvent(UINT msg_id, WPARAM w_param, LPARAM l_param) { META_FUNCTION_TASK(); META_UNUSED(l_param); @@ -353,7 +355,7 @@ LRESULT AppWin::OnWindowMouseButtonEvent(UINT msg_id, WPARAM w_param, LPARAM l_p return FALSE; } -LRESULT AppWin::OnWindowMouseMoveEvent(WPARAM w_param, LPARAM l_param) +LRESULT App::OnWindowMouseMoveEvent(WPARAM w_param, LPARAM l_param) { META_FUNCTION_TASK(); META_UNUSED(w_param); @@ -378,7 +380,7 @@ LRESULT AppWin::OnWindowMouseMoveEvent(WPARAM w_param, LPARAM l_param) return 0; } -LRESULT AppWin::OnWindowMouseWheelEvent(bool is_vertical_scroll, WPARAM w_param, LPARAM l_param) +LRESULT App::OnWindowMouseWheelEvent(bool is_vertical_scroll, WPARAM w_param, LPARAM l_param) { META_FUNCTION_TASK(); META_UNUSED(w_param); @@ -399,14 +401,14 @@ LRESULT AppWin::OnWindowMouseWheelEvent(bool is_vertical_scroll, WPARAM w_param, return 0; } -LRESULT AppWin::OnWindowMouseLeave() +LRESULT App::OnWindowMouseLeave() { META_FUNCTION_TASK(); ProcessInputWithErrorHandling(&Input::IActionController::OnMouseInWindowChanged, false); return 0; } -LRESULT CALLBACK AppWin::WindowProc(HWND h_wnd, UINT msg_id, WPARAM w_param, LPARAM l_param) +LRESULT CALLBACK App::WindowProc(HWND h_wnd, UINT msg_id, WPARAM w_param, LPARAM l_param) { META_FUNCTION_TASK(); @@ -416,7 +418,7 @@ LRESULT CALLBACK AppWin::WindowProc(HWND h_wnd, UINT msg_id, WPARAM w_param, LPA return 0; } - auto app_ptr = reinterpret_cast(GetWindowLongPtr(h_wnd, GWLP_USERDATA)); // NOSONAR + auto app_ptr = reinterpret_cast(GetWindowLongPtr(h_wnd, GWLP_USERDATA)); // NOSONAR if (!app_ptr || !app_ptr->IsMessageProcessing()) { return DefWindowProc(h_wnd, msg_id, w_param, l_param); @@ -477,7 +479,7 @@ LRESULT CALLBACK AppWin::WindowProc(HWND h_wnd, UINT msg_id, WPARAM w_param, LPA return DefWindowProc(h_wnd, msg_id, w_param, l_param); } -void AppWin::ShowAlert(const Message& msg) +void App::ShowAlert(const Message& msg) { META_FUNCTION_TASK(); @@ -488,7 +490,7 @@ void AppWin::ShowAlert(const Message& msg) ConvertMessageTypeToFlags(msg.type) ); - AppBase::ShowAlert(msg); + Base::App::ShowAlert(msg); if (msg.type == Message::Type::Error) { @@ -496,7 +498,7 @@ void AppWin::ShowAlert(const Message& msg) } } -void AppWin::ScheduleAlert() +void App::ScheduleAlert() { META_FUNCTION_TASK(); if (!m_env.window_handle) @@ -506,7 +508,7 @@ void AppWin::ScheduleAlert() META_CHECK_TRUE_DESCR(post_result, "failed to post window message"); } -void AppWin::SetWindowTitle(const std::string& title_text) +void App::SetWindowTitle(const std::string& title_text) { META_FUNCTION_TASK(); if (!m_env.window_handle) @@ -516,10 +518,10 @@ void AppWin::SetWindowTitle(const std::string& title_text) META_CHECK_TRUE_DESCR(set_result, "failed to update window title"); } -bool AppWin::SetFullScreen(bool is_full_screen) +bool App::SetFullScreen(bool is_full_screen) { META_FUNCTION_TASK(); - if (!AppBase::SetFullScreen(is_full_screen)) + if (!Base::App::SetFullScreen(is_full_screen)) return false; META_CHECK_NOT_NULL(m_env.window_handle); @@ -562,7 +564,7 @@ bool AppWin::SetFullScreen(bool is_full_screen) return true; } -float AppWin::GetContentScalingFactor() const +float App::GetContentScalingFactor() const { META_FUNCTION_TASK(); DEVICE_SCALE_FACTOR device_scale_factor = DEVICE_SCALE_FACTOR_INVALID; @@ -571,7 +573,7 @@ float AppWin::GetContentScalingFactor() const return GetDeviceScaleRatio(device_scale_factor); } -uint32_t AppWin::GetFontResolutionDpi() const +uint32_t App::GetFontResolutionDpi() const { META_FUNCTION_TASK(); const HDC window_device_context = GetDC(m_env.window_handle); @@ -582,7 +584,7 @@ uint32_t AppWin::GetFontResolutionDpi() const return dpi_y; } -void AppWin::Close() +void App::Close() { META_FUNCTION_TASK(); if (m_env.window_handle && PostMessage(m_env.window_handle, WM_CLOSE, 0, 0)) @@ -591,4 +593,4 @@ void AppWin::Close() ExitProcess(0); } -} // namespace Methane::Platform \ No newline at end of file +} // namespace Methane::Platform::Windows \ No newline at end of file diff --git a/Modules/Platform/App/Sources/Methane/Platform/Windows/ConsoleStreams.cpp b/Modules/Platform/Windows/App/Sources/Methane/Platform/Windows/ConsoleStreams.cpp similarity index 96% rename from Modules/Platform/App/Sources/Methane/Platform/Windows/ConsoleStreams.cpp rename to Modules/Platform/Windows/App/Sources/Methane/Platform/Windows/ConsoleStreams.cpp index a9554905f..64e039a04 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/Windows/ConsoleStreams.cpp +++ b/Modules/Platform/Windows/App/Sources/Methane/Platform/Windows/ConsoleStreams.cpp @@ -27,7 +27,7 @@ IO Stream class used for standard and error output redirection from GUI app to c #include -namespace Methane::Platform +namespace Methane::Platform::Windows { static bool IsMappedToFile(FILE* std_stream) @@ -78,4 +78,4 @@ bool ConsoleStreams::Attach() m_error_stream.RedirectToFile("CONOUT$", "w"); } -} // namespace Methane::Platform \ No newline at end of file +} // namespace Methane::Platform::Windows \ No newline at end of file diff --git a/Modules/Platform/App/Sources/Methane/Platform/Windows/ConsoleStreams.h b/Modules/Platform/Windows/App/Sources/Methane/Platform/Windows/ConsoleStreams.h similarity index 96% rename from Modules/Platform/App/Sources/Methane/Platform/Windows/ConsoleStreams.h rename to Modules/Platform/Windows/App/Sources/Methane/Platform/Windows/ConsoleStreams.h index b3b1b6369..eb4f48569 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/Windows/ConsoleStreams.h +++ b/Modules/Platform/Windows/App/Sources/Methane/Platform/Windows/ConsoleStreams.h @@ -28,7 +28,7 @@ IOStream class is used for standard and error output redirection #include #include -namespace Methane::Platform +namespace Methane::Platform::Windows { class IOStream // NOSONAR - destructor is required in this class @@ -66,4 +66,4 @@ class ConsoleStreams IOStream m_error_stream = { stderr, STD_ERROR_HANDLE }; }; -} // namespace Methane::Platform \ No newline at end of file +} // namespace Methane::Platform::Windows \ No newline at end of file diff --git a/Modules/Platform/Windows/AppView/CMakeLists.txt b/Modules/Platform/Windows/AppView/CMakeLists.txt new file mode 100644 index 000000000..17a7c7dce --- /dev/null +++ b/Modules/Platform/Windows/AppView/CMakeLists.txt @@ -0,0 +1,35 @@ +set(TARGET MethanePlatformAppViewWindows) + +include(MethaneModules) + +get_module_dirs("Methane/Platform") + +list(APPEND HEADERS + ${CMAKE_CURRENT_SOURCE_DIR}/${INCLUDE_PLATFORM_OS_DIR}/AppEnvironment.h +) + +add_library(${TARGET} INTERFACE) + +target_sources(${TARGET} + INTERFACE + ${HEADERS} +) + +target_include_directories(${TARGET} + INTERFACE + ${CMAKE_CURRENT_SOURCE_DIR}/Include +) + +source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS}) + +set_target_properties(${TARGET} + PROPERTIES + FOLDER Modules/Platform/Windows + PUBLIC_HEADER "${HEADERS}" +) + +install(TARGETS ${TARGET} + PUBLIC_HEADER + DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} + COMPONENT Development +) diff --git a/Modules/Platform/AppView/Include/Methane/Platform/Windows/AppEnvironment.h b/Modules/Platform/Windows/AppView/Include/Methane/Platform/Windows/AppEnvironment.h similarity index 100% rename from Modules/Platform/AppView/Include/Methane/Platform/Windows/AppEnvironment.h rename to Modules/Platform/Windows/AppView/Include/Methane/Platform/Windows/AppEnvironment.h diff --git a/Modules/Platform/Windows/CMakeLists.txt b/Modules/Platform/Windows/CMakeLists.txt new file mode 100644 index 000000000..2b7f51c09 --- /dev/null +++ b/Modules/Platform/Windows/CMakeLists.txt @@ -0,0 +1,4 @@ +add_subdirectory(Utils) +add_subdirectory(Input) +add_subdirectory(AppView) +add_subdirectory(App) diff --git a/Modules/Platform/Windows/Input/CMakeLists.txt b/Modules/Platform/Windows/Input/CMakeLists.txt new file mode 100644 index 000000000..df28aa576 --- /dev/null +++ b/Modules/Platform/Windows/Input/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(Keyboard) diff --git a/Modules/Platform/Windows/Input/Keyboard/CMakeLists.txt b/Modules/Platform/Windows/Input/Keyboard/CMakeLists.txt new file mode 100644 index 000000000..cb71b2a4c --- /dev/null +++ b/Modules/Platform/Windows/Input/Keyboard/CMakeLists.txt @@ -0,0 +1,57 @@ +set(TARGET MethanePlatformInputKeyboardWindows) + +include(MethaneModules) + +get_module_dirs("Methane/Platform/Input") + +list(APPEND HEADERS + ${INCLUDE_PLATFORM_OS_DIR}/Keyboard.h +) + +list(APPEND SOURCES + ${SOURCES_PLATFORM_OS_DIR}/Keyboard.cpp +) + +add_library(${TARGET} STATIC + ${HEADERS} + ${SOURCES} +) + +target_link_libraries(${TARGET} + PUBLIC + MethanePlatformInputKeyboardBase + PRIVATE + MethaneBuildOptions + MethaneCommonPrecompiledHeaders + MethanePrimitives + MethaneInstrumentation + magic_enum +) + +if(METHANE_PRECOMPILED_HEADERS_ENABLED) + target_precompile_headers(${TARGET} REUSE_FROM MethaneCommonPrecompiledHeaders) +endif() + +target_include_directories(${TARGET} + PRIVATE + Sources + PUBLIC + Include +) + +source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) + +set_target_properties(${TARGET} + PROPERTIES + FOLDER Modules/Platform/Windows/Input + PUBLIC_HEADER "${HEADERS}" +) + +install(TARGETS ${TARGET} + PUBLIC_HEADER + DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} + COMPONENT Development + ARCHIVE + DESTINATION lib + COMPONENT Development +) diff --git a/Modules/Platform/Input/Keyboard/Include/Methane/Platform/Input/Windows/Keyboard.h b/Modules/Platform/Windows/Input/Keyboard/Include/Methane/Platform/Input/Windows/Keyboard.h similarity index 100% rename from Modules/Platform/Input/Keyboard/Include/Methane/Platform/Input/Windows/Keyboard.h rename to Modules/Platform/Windows/Input/Keyboard/Include/Methane/Platform/Input/Windows/Keyboard.h diff --git a/Modules/Platform/Input/Keyboard/Sources/Methane/Platform/Input/Windows/Keyboard.cpp b/Modules/Platform/Windows/Input/Keyboard/Sources/Methane/Platform/Input/Windows/Keyboard.cpp similarity index 99% rename from Modules/Platform/Input/Keyboard/Sources/Methane/Platform/Input/Windows/Keyboard.cpp rename to Modules/Platform/Windows/Input/Keyboard/Sources/Methane/Platform/Input/Windows/Keyboard.cpp index 393f7ba99..92a80ea5d 100644 --- a/Modules/Platform/Input/Keyboard/Sources/Methane/Platform/Input/Windows/Keyboard.cpp +++ b/Modules/Platform/Windows/Input/Keyboard/Sources/Methane/Platform/Input/Windows/Keyboard.cpp @@ -21,6 +21,7 @@ Windows platform specific types and implementation of Keyboard abstractions. ******************************************************************************/ +#include #include #include diff --git a/Modules/Platform/Windows/Utils/CMakeLists.txt b/Modules/Platform/Windows/Utils/CMakeLists.txt new file mode 100644 index 000000000..fa8391f75 --- /dev/null +++ b/Modules/Platform/Windows/Utils/CMakeLists.txt @@ -0,0 +1,56 @@ +set(TARGET MethanePlatformUtilsWindows) + +include(MethaneModules) + +get_module_dirs("Methane/Platform") + +list(APPEND HEADERS + ${INCLUDE_PLATFORM_OS_DIR}/Utils.h +) + +list(APPEND SOURCES + ${SOURCES_PLATFORM_OS_DIR}/Utils.cpp +) + +add_library(${TARGET} STATIC + ${HEADERS} + ${SOURCES} +) + +target_link_libraries(${TARGET} + PUBLIC + MethanePlatformUtilsBase + PRIVATE + MethaneBuildOptions + MethaneCommonPrecompiledHeaders + MethaneInstrumentation + nowide +) + +if(METHANE_PRECOMPILED_HEADERS_ENABLED) + target_precompile_headers(${TARGET} REUSE_FROM MethaneCommonPrecompiledHeaders) +endif() + +target_include_directories(${TARGET} + PRIVATE + Sources + PUBLIC + Include +) + +source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) + +set_target_properties(${TARGET} + PROPERTIES + FOLDER Modules/Platform/Windows + PUBLIC_HEADER "${HEADERS}" +) + +install(TARGETS ${TARGET} + PUBLIC_HEADER + DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} + COMPONENT Development + ARCHIVE + DESTINATION lib + COMPONENT Development +) diff --git a/Modules/Platform/Utils/Include/Methane/Platform/Windows/Utils.h b/Modules/Platform/Windows/Utils/Include/Methane/Platform/Windows/Utils.h similarity index 100% rename from Modules/Platform/Utils/Include/Methane/Platform/Windows/Utils.h rename to Modules/Platform/Windows/Utils/Include/Methane/Platform/Windows/Utils.h diff --git a/Modules/Platform/Utils/Sources/Methane/Platform/Windows/Utils.cpp b/Modules/Platform/Windows/Utils/Sources/Methane/Platform/Windows/Utils.cpp similarity index 100% rename from Modules/Platform/Utils/Sources/Methane/Platform/Windows/Utils.cpp rename to Modules/Platform/Windows/Utils/Sources/Methane/Platform/Windows/Utils.cpp diff --git a/Modules/Platform/iOS/App/CMakeLists.txt b/Modules/Platform/iOS/App/CMakeLists.txt new file mode 100644 index 000000000..90a5368fc --- /dev/null +++ b/Modules/Platform/iOS/App/CMakeLists.txt @@ -0,0 +1,78 @@ +set(TARGET MethanePlatformAppIOS) + +include(MethaneModules) + +get_module_dirs("Methane/Platform") + +list(APPEND HEADERS + ${INCLUDE_PLATFORM_OS_DIR}/App.hh + ${SOURCES_PLATFORM_OS_DIR}/AppDelegate.hh + ${SOURCES_PLATFORM_OS_DIR}/AppViewController.hh +) + +list(APPEND SOURCES + ${SOURCES_PLATFORM_OS_DIR}/App.mm + ${SOURCES_PLATFORM_OS_DIR}/AppDelegate.mm + ${SOURCES_PLATFORM_OS_DIR}/AppViewController.mm +) + +add_library(${TARGET} STATIC + ${HEADERS} + ${SOURCES} +) + +target_link_libraries(${TARGET} + PUBLIC + MethanePlatformAppBase + MethanePlatformAppViewIOS + "-framework UIKit" + PRIVATE + MethaneBuildOptions + MethaneCommonPrecompiledHeaders + MethanePlatformUtilsApple + MethaneDataProvider + fmt + nowide +) + +target_compile_definitions(${TARGET} + PRIVATE + METHANE_RENDER_APP +) + +if(METHANE_PRECOMPILED_HEADERS_ENABLED) + target_precompile_headers(${TARGET} REUSE_FROM MethaneCommonPrecompiledHeaders) +endif() + +target_include_directories(${TARGET} + PRIVATE + Sources + ${SOURCES_PLATFORM_OS_DIR} + PUBLIC + Include +) + +# Disable precompiled headers and enable ARC for Objective-C sources: +set_source_files_properties( + ${SOURCES} + PROPERTIES + COMPILE_FLAGS -fobjc-arc + SKIP_PRECOMPILE_HEADERS ON +) + +source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) + +set_target_properties(${TARGET} + PROPERTIES + FOLDER Modules/Platform/iOS + PUBLIC_HEADER "${HEADERS}" +) + +install(TARGETS ${TARGET} + PUBLIC_HEADER + DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} + COMPONENT Development + ARCHIVE + DESTINATION lib + COMPONENT Development +) diff --git a/Modules/Platform/App/Include/Methane/Platform/iOS/AppIOS.hh b/Modules/Platform/iOS/App/Include/Methane/Platform/iOS/App.hh similarity index 78% rename from Modules/Platform/App/Include/Methane/Platform/iOS/AppIOS.hh rename to Modules/Platform/iOS/App/Include/Methane/Platform/iOS/App.hh index bcb966be8..8c1c0607a 100644 --- a/Modules/Platform/App/Include/Methane/Platform/iOS/AppIOS.hh +++ b/Modules/Platform/iOS/App/Include/Methane/Platform/iOS/App.hh @@ -16,14 +16,14 @@ limitations under the License. ******************************************************************************* -FILE: Methane/Platform/iOS/AppIOS.h +FILE: Methane/Platform/iOS/App.hh iOS application implementation. ******************************************************************************/ #pragma once -#include +#include #include #ifndef __OBJC__ @@ -32,17 +32,17 @@ using UIWindow = void; #endif -namespace Methane::Platform +namespace Methane::Platform::iOS { -class AppIOS : public AppBase +class App : public Base::App { public: - static AppIOS* GetInstance(); + static App* GetInstance(); - explicit AppIOS(const AppBase::Settings& settings); + explicit App(const Base::App::Settings& settings); - // AppBase interface + // Base::App interface void InitContext(const Platform::AppEnvironment& env, const Data::FrameSize& frame_size) override; int Run(const RunArgs& args) override; void Alert(const Message& msg, bool deferred = false) override; @@ -53,17 +53,17 @@ public: void Close() override; void SetWindow(UIWindow* ns_window); - bool SetFullScreenInternal(bool is_full_screen) { return AppBase::SetFullScreen(is_full_screen); } + bool SetFullScreenInternal(bool is_full_screen) { return Base::App::SetFullScreen(is_full_screen); } UIWindow* GetWindow() { return m_ns_window; } protected: - // AppBase interface + // Base::App interface void ShowAlert(const Message& msg) override; private: UIWindow* m_ns_window = nullptr; - static AppIOS* s_instance_ptr; + static App* s_instance_ptr; }; -} // namespace Methane::Platform +} // namespace Methane::Platform::iOS diff --git a/Modules/Platform/App/Sources/Methane/Platform/iOS/AppIOS.mm b/Modules/Platform/iOS/App/Sources/Methane/Platform/iOS/App.mm similarity index 67% rename from Modules/Platform/App/Sources/Methane/Platform/iOS/AppIOS.mm rename to Modules/Platform/iOS/App/Sources/Methane/Platform/iOS/App.mm index 2a57e9f69..780a0adf4 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/iOS/AppIOS.mm +++ b/Modules/Platform/iOS/App/Sources/Methane/Platform/iOS/App.mm @@ -16,56 +16,56 @@ ******************************************************************************* -FILE: Methane/Platform/iOS/AppMac.mm +FILE: Methane/Platform/iOS/App.mm iOS application implementation. ******************************************************************************/ -#include +#include #include #include #include #import "AppDelegate.hh" -namespace Methane::Platform +namespace Methane::Platform::iOS { -AppIOS* AppIOS::s_instance_ptr = nullptr; +App* App::s_instance_ptr = nullptr; -static UIAlertActionStyle ConvertMessageTypeToNsAlertStyle(AppBase::Message::Type msg_type) +static UIAlertActionStyle ConvertMessageTypeToNsAlertStyle(Base::App::Message::Type msg_type) { META_FUNCTION_TASK(); switch(msg_type) { - case AppBase::Message::Type::Information: return UIAlertActionStyleDefault; - case AppBase::Message::Type::Warning: return UIAlertActionStyleCancel; - case AppBase::Message::Type::Error: return UIAlertActionStyleDestructive; + case Base::App::Message::Type::Information: return UIAlertActionStyleDefault; + case Base::App::Message::Type::Warning: return UIAlertActionStyleCancel; + case Base::App::Message::Type::Error: return UIAlertActionStyleDestructive; default: META_UNEXPECTED_RETURN(msg_type, UIAlertActionStyleDestructive); } } -AppIOS* AppIOS::GetInstance() +App* App::GetInstance() { META_FUNCTION_TASK(); return s_instance_ptr; } -AppIOS::AppIOS(const AppBase::Settings& settings) - : AppBase(settings) +App::App(const Base::App::Settings& settings) + : Base::App(settings) { META_FUNCTION_TASK(); META_CHECK_EQUAL_DESCR(s_instance_ptr, nullptr, "Application can have only one instance"); s_instance_ptr = this; } -void AppIOS::InitContext(const Platform::AppEnvironment& /*env*/, const Data::FrameSize& /*frame_size*/) +void App::InitContext(const Platform::AppEnvironment& /*env*/, const Data::FrameSize& /*frame_size*/) { } -int AppIOS::Run(const RunArgs& args) +int App::Run(const RunArgs& args) { META_FUNCTION_TASK(); - const int base_return_code = AppBase::Run(args); + const int base_return_code = Base::App::Run(args); if (base_return_code) return base_return_code; @@ -73,7 +73,7 @@ static UIAlertActionStyle ConvertMessageTypeToNsAlertStyle(AppBase::Message::Typ NSStringFromClass([AppDelegate class])); } -void AppIOS::Alert(const Message& msg, bool deferred) +void App::Alert(const Message& msg, bool deferred) { META_FUNCTION_TASK(); if (deferred) @@ -91,22 +91,22 @@ static UIAlertActionStyle ConvertMessageTypeToNsAlertStyle(AppBase::Message::Typ ShowAlert(msg); } - AppBase::Alert(msg, deferred); + Base::App::Alert(msg, deferred); } -void AppIOS::SetWindowTitle(const std::string& title_text) +void App::SetWindowTitle(const std::string& title_text) { META_FUNCTION_TASK(); META_UNUSED(title_text); } -void AppIOS::SetWindow(UIWindow* ns_window) +void App::SetWindow(UIWindow* ns_window) { META_FUNCTION_TASK(); m_ns_window = ns_window; } -void AppIOS::ShowAlert(const Message& msg) +void App::ShowAlert(const Message& msg) { META_FUNCTION_TASK(); @@ -117,31 +117,31 @@ static UIAlertActionStyle ConvertMessageTypeToNsAlertStyle(AppBase::Message::Typ withInformation: MacOS::ConvertToNsString(msg.information) andStyle: ConvertMessageTypeToNsAlertStyle(msg.type)]; - AppBase::ShowAlert(msg); + Base::App::ShowAlert(msg); } -bool AppIOS::SetFullScreen(bool is_full_screen) +bool App::SetFullScreen(bool is_full_screen) { META_FUNCTION_TASK(); - if (!AppBase::SetFullScreen(is_full_screen)) + if (!Base::App::SetFullScreen(is_full_screen)) return false; return true; } -float AppIOS::GetContentScalingFactor() const +float App::GetContentScalingFactor() const { META_FUNCTION_TASK(); return static_cast(m_ns_window.screen.nativeScale); } -uint32_t AppIOS::GetFontResolutionDpi() const +uint32_t App::GetFontResolutionDpi() const { META_FUNCTION_TASK(); return 72U * GetContentScalingFactor(); } -void AppIOS::Close() +void App::Close() { } -} // namespace Methane::Platform +} // namespace Methane::Platform::iOS diff --git a/Modules/Platform/App/Sources/Methane/Platform/iOS/AppDelegate.hh b/Modules/Platform/iOS/App/Sources/Methane/Platform/iOS/AppDelegate.hh similarity index 93% rename from Modules/Platform/App/Sources/Methane/Platform/iOS/AppDelegate.hh rename to Modules/Platform/iOS/App/Sources/Methane/Platform/iOS/AppDelegate.hh index 92b77896d..df352abe1 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/iOS/AppDelegate.hh +++ b/Modules/Platform/iOS/App/Sources/Methane/Platform/iOS/AppDelegate.hh @@ -23,11 +23,11 @@ iOS application delegate implementation. #include "AppViewController.hh" -#include +#include #import -namespace Methane::Platform { class AppIOS; } +namespace Methane::Platform::iOS { class App; } @interface AppDelegate : UIResponder diff --git a/Modules/Platform/App/Sources/Methane/Platform/iOS/AppDelegate.mm b/Modules/Platform/iOS/App/Sources/Methane/Platform/iOS/AppDelegate.mm similarity index 96% rename from Modules/Platform/App/Sources/Methane/Platform/iOS/AppDelegate.mm rename to Modules/Platform/iOS/App/Sources/Methane/Platform/iOS/AppDelegate.mm index 4bd35b074..131fea072 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/iOS/AppDelegate.mm +++ b/Modules/Platform/iOS/App/Sources/Methane/Platform/iOS/AppDelegate.mm @@ -23,7 +23,7 @@ #import "AppDelegate.hh" -#include +#include #include #include #include @@ -45,7 +45,7 @@ - (id) init if (!self) return nil; - AppIOS* app_ptr = AppIOS::GetInstance(); + iOS::App* app_ptr = iOS::App::GetInstance(); UIScreen* ns_main_screen = [UIScreen mainScreen]; const auto& ns_frame_size = ns_main_screen.bounds.size; const CGRect backing_frame = CGRectMake(0.f, 0.f, @@ -108,7 +108,7 @@ - (UIWindow*) window navigation_controller.navigationBarHidden = YES; m_window.rootViewController = navigation_controller; - AppIOS::GetInstance()->SetWindow(m_window); + iOS::App::GetInstance()->SetWindow(m_window); } return m_window; } diff --git a/Modules/Platform/App/Sources/Methane/Platform/iOS/AppViewController.hh b/Modules/Platform/iOS/App/Sources/Methane/Platform/iOS/AppViewController.hh similarity index 84% rename from Modules/Platform/App/Sources/Methane/Platform/iOS/AppViewController.hh rename to Modules/Platform/iOS/App/Sources/Methane/Platform/iOS/AppViewController.hh index 12f3eb14c..96fffaf87 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/iOS/AppViewController.hh +++ b/Modules/Platform/iOS/App/Sources/Methane/Platform/iOS/AppViewController.hh @@ -25,13 +25,13 @@ iOS application view controller implementation. #import -namespace Methane::Platform { class AppIOS; } +namespace Methane::Platform::iOS { class App; } @interface AppViewController : UIViewController @property (nonatomic, readonly, nullable) UIWindow* window; -- (id _Nullable)initWithApp : (Methane::Platform::AppIOS* _Nonnull) app_ptr andFrameRect : (CGRect) frame; -- (Methane::Platform::AppIOS* _Nonnull) getApp; +- (id _Nullable)initWithApp : (Methane::Platform::iOS::App* _Nonnull) app_ptr andFrameRect : (CGRect) frame; +- (Methane::Platform::iOS::App* _Nonnull) getApp; @end diff --git a/Modules/Platform/App/Sources/Methane/Platform/iOS/AppViewController.mm b/Modules/Platform/iOS/App/Sources/Methane/Platform/iOS/AppViewController.mm similarity index 96% rename from Modules/Platform/App/Sources/Methane/Platform/iOS/AppViewController.mm rename to Modules/Platform/iOS/App/Sources/Methane/Platform/iOS/AppViewController.mm index c6ffa03de..17d9ae285 100644 --- a/Modules/Platform/App/Sources/Methane/Platform/iOS/AppViewController.mm +++ b/Modules/Platform/iOS/App/Sources/Methane/Platform/iOS/AppViewController.mm @@ -23,7 +23,7 @@ #import "AppViewController.hh" -#include +#include #include #include #include @@ -45,7 +45,7 @@ } } -} // namespace Methane::Platform +} // namespace Methane::Platform::Input namespace data = Methane::Data; namespace pal = Methane::Platform; @@ -53,13 +53,13 @@ @implementation AppViewController { - pal::AppIOS* m_app_ptr; + pal::iOS::App* m_app_ptr; CGRect m_frame_rect; bool m_is_initialized; std::string m_error; } -- (id)initWithApp : (pal::AppIOS*) app_ptr andFrameRect : (CGRect) frame_rect +- (id)initWithApp : (pal::iOS::App*) app_ptr andFrameRect : (CGRect) frame_rect { META_FUNCTION_TASK(); @@ -80,7 +80,7 @@ -(nullable UIWindow*) window return m_app_ptr ? m_app_ptr->GetWindow() : nil; } -- (pal::AppIOS*) getApp +- (pal::iOS::App*) getApp { return m_app_ptr; } diff --git a/Modules/Platform/iOS/AppView/CMakeLists.txt b/Modules/Platform/iOS/AppView/CMakeLists.txt new file mode 100644 index 000000000..c8fb8c5b6 --- /dev/null +++ b/Modules/Platform/iOS/AppView/CMakeLists.txt @@ -0,0 +1,67 @@ +set(TARGET MethanePlatformAppViewIOS) + +include(MethaneModules) + +get_module_dirs("Methane/Platform") + +list(APPEND HEADERS + ${INCLUDE_PLATFORM_OS_DIR}/AppEnvironment.hh + ${INCLUDE_PLATFORM_OS_DIR}/AppViewMetal.hh +) + +list(APPEND SOURCES + ${SOURCES_PLATFORM_OS_DIR}/AppViewMetal.mm +) + +add_library(${TARGET} STATIC + ${HEADERS} + ${SOURCES} +) + +target_link_libraries(${TARGET} + PUBLIC + "-framework UIKit" + "-framework Metal" + "-framework QuartzCore" + PRIVATE + MethaneBuildOptions + MethaneInstrumentation + MethaneDataTypes +) + +target_compile_definitions(${TARGET} + PRIVATE + $<$:METHANE_GPU_INSTRUMENTATION_ENABLED> +) + +target_include_directories(${TARGET} + PRIVATE + Sources + PUBLIC + Include +) + +# Disable precompiled headers, enable ARC and weak Objective-C references: +set_source_files_properties( + ${SOURCES} + PROPERTIES + COMPILE_FLAGS "-fobjc-arc -fobjc-weak" + SKIP_PRECOMPILE_HEADERS ON +) + +source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) + +set_target_properties(${TARGET} + PROPERTIES + FOLDER Modules/Platform/iOS + PUBLIC_HEADER "${HEADERS}" +) + +install(TARGETS ${TARGET} + PUBLIC_HEADER + DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} + COMPONENT Development + ARCHIVE + DESTINATION lib + COMPONENT Development +) diff --git a/Modules/Platform/AppView/Include/Methane/Platform/iOS/AppEnvironment.hh b/Modules/Platform/iOS/AppView/Include/Methane/Platform/iOS/AppEnvironment.hh similarity index 100% rename from Modules/Platform/AppView/Include/Methane/Platform/iOS/AppEnvironment.hh rename to Modules/Platform/iOS/AppView/Include/Methane/Platform/iOS/AppEnvironment.hh diff --git a/Modules/Platform/AppView/Include/Methane/Platform/iOS/AppViewMetal.hh b/Modules/Platform/iOS/AppView/Include/Methane/Platform/iOS/AppViewMetal.hh similarity index 100% rename from Modules/Platform/AppView/Include/Methane/Platform/iOS/AppViewMetal.hh rename to Modules/Platform/iOS/AppView/Include/Methane/Platform/iOS/AppViewMetal.hh diff --git a/Modules/Platform/AppView/Sources/Methane/Platform/iOS/AppViewMetal.mm b/Modules/Platform/iOS/AppView/Sources/Methane/Platform/iOS/AppViewMetal.mm similarity index 100% rename from Modules/Platform/AppView/Sources/Methane/Platform/iOS/AppViewMetal.mm rename to Modules/Platform/iOS/AppView/Sources/Methane/Platform/iOS/AppViewMetal.mm diff --git a/Modules/Platform/iOS/CMakeLists.txt b/Modules/Platform/iOS/CMakeLists.txt new file mode 100644 index 000000000..70176e31f --- /dev/null +++ b/Modules/Platform/iOS/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(AppView) +add_subdirectory(App) diff --git a/Modules/UserInterface/App/Include/Methane/UserInterface/App.hpp b/Modules/UserInterface/App/Include/Methane/UserInterface/App.hpp index 7156e5e42..9dd6774c1 100644 --- a/Modules/UserInterface/App/Include/Methane/UserInterface/App.hpp +++ b/Modules/UserInterface/App/Include/Methane/UserInterface/App.hpp @@ -134,18 +134,18 @@ class App SetParametersText(GetParametersString()); } - // Platform::AppBase overrides + // Platform::Base::App overrides void ShowControlsHelp() final { META_FUNCTION_TASK(); - if (!SetHelpText(Platform::AppBase::GetControlsHelp())) + if (!SetHelpText(Platform::Base::App::GetControlsHelp())) SetHelpText(""); } void ShowCommandLineHelp() final { META_FUNCTION_TASK(); - if (!SetHelpText(Platform::AppBase::GetCommandLineHelp())) + if (!SetHelpText(Platform::Base::App::GetCommandLineHelp())) SetHelpText(""); } diff --git a/Tests/Platform/Input/README.md b/Tests/Platform/Input/README.md index ec4770593..1e3748607 100644 --- a/Tests/Platform/Input/README.md +++ b/Tests/Platform/Input/README.md @@ -2,10 +2,10 @@ | Type Class | Unit Test | |-----------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------| -| [Platform::Input::Mouse](/Modules/Platform/Input/Mouse/Include/Methane/Platform/Input/Mouse.h) | :white_check_mark: [MouseTest](MouseTest.cpp) | -| [Platform::Input::Mouse::ActionControllerBase](/Modules/Platform/Input/ActionControllers/Include/Methane/Platform/Input/KeyboardActionControllerBase.hpp) | :warning: not covered yet | -| [Platform::Input::Keyboard](/Modules/Platform/Input/Keyboard/Include/Methane/Platform/Input/Keyboard.h) | :white_check_mark: [KeyboardTest](KeyboardTest.cpp) | -| [Platform::Input::Keyboard::ActionControllerBase](/Modules/Platform/Input/ActionControllers/Include/Methane/Platform/Input/MouseActionControllerBase.hpp) | :warning: not covered yet | -| [Platform::Input::Controller](/Modules/Platform/Input/Controllers/Include/Methane/Platform/Input/Controller.h) | :warning: not covered yet | -| [Platform::Input::ControllersPool](/Modules/Platform/Input/Controllers/Include/Methane/Platform/Input/ControllersPool.h) | :warning: not covered yet | -| [Platform::Input::State](/Modules/Platform/Input/Controllers/Include/Methane/Platform/Input/State.h) | :warning: not covered yet | +| [Platform::Input::Mouse](/Modules/Platform/Common/Input/Mouse/Include/Methane/Platform/Input/Mouse.h) | :white_check_mark: [MouseTest](MouseTest.cpp) | +| [Platform::Input::Mouse::ActionControllerBase](/Modules/Platform/Common/Input/ActionControllers/Include/Methane/Platform/Input/KeyboardActionControllerBase.hpp) | :warning: not covered yet | +| [Platform::Input::Keyboard](/Modules/Platform/Base/Input/Keyboard/Include/Methane/Platform/Input/Keyboard.h) | :white_check_mark: [KeyboardTest](KeyboardTest.cpp) | +| [Platform::Input::Keyboard::ActionControllerBase](/Modules/Platform/Common/Input/ActionControllers/Include/Methane/Platform/Input/MouseActionControllerBase.hpp) | :warning: not covered yet | +| [Platform::Input::Controller](/Modules/Platform/Common/Input/Controllers/Include/Methane/Platform/Input/Controller.h) | :warning: not covered yet | +| [Platform::Input::ControllersPool](/Modules/Platform/Common/Input/Controllers/Include/Methane/Platform/Input/ControllersPool.h) | :warning: not covered yet | +| [Platform::Input::State](/Modules/Platform/Common/Input/Controllers/Include/Methane/Platform/Input/State.h) | :warning: not covered yet | diff --git a/Tests/Platform/README.md b/Tests/Platform/README.md index 84d90b197..d11499e10 100644 --- a/Tests/Platform/README.md +++ b/Tests/Platform/README.md @@ -1,8 +1,8 @@ # Methane Platform Modules Unit Tests -| Platform Module Name | Unit Tests Folder | -|-----------------------------------------------|-----------------------------------------| -| [Platform/App](/Modules/Platform/App) | :warning: not covered yet | -| [Platform/AppView](/Modules/Platform/AppView) | :warning: not covered yet | -| [Platform/Input](/Modules/Platform/Input) | :white_check_mark: [Input](Input) tests | -| [Platform/Utils](/Modules/Platform/Utils) | :warning: not covered yet | +| Platform Module Name | Unit Tests Folder | +|----------------------------------------------------|-----------------------------------------| +| [Platform/App](/Modules/Platform/Impl/App) | :warning: not covered yet | +| [Platform/AppView](/Modules/Platform/Impl/AppView) | :warning: not covered yet | +| [Platform/Input](/Modules/Platform/Common/Input) | :white_check_mark: [Input](Input) tests | +| [Platform/Utils](/Modules/Platform/Impl/Utils) | :warning: not covered yet | From 0fd6143b564d0b648f6ef1c021174b25f47c7795 Mon Sep 17 00:00:00 2001 From: Evgeny Gorodetskiy Date: Sun, 29 Nov 2026 19:10:44 +0300 Subject: [PATCH 2/7] Nest MacOS and iOS platform module groups under Platform/Apple Move Modules/Platform/MacOS and Modules/Platform/iOS into Modules/Platform/Apple, next to the Apple/Utils module shared by both, so that all Apple platform modules live under a single directory: Modules/Platform/Apple/Utils - shared by MacOS and iOS Modules/Platform/Apple/MacOS/... - MacOS only Modules/Platform/Apple/iOS/... - iOS / tvOS only Modules/Platform/CMakeLists.txt now adds the Apple group as a whole, and Modules/Platform/Apple/CMakeLists.txt picks MacOS or iOS on top of the shared modules. CMake target names, C++ namespaces and public include paths are unchanged, so nothing outside Modules/Platform is affected. Verified on Windows with the VS2022-Win64-DX and VS2022-Win64-VK presets (Debug build clean, 493/493 unit tests passing on each). Refs #165 Co-Authored-By: Claude Opus 5 --- .codecov.yml | 3 + Modules/Platform/Apple/CMakeLists.txt | 8 +++ .../{ => Apple}/MacOS/App/CMakeLists.txt | 2 +- .../App/Include/Methane/Platform/MacOS/App.hh | 0 .../App/Sources/Methane/Platform/MacOS/App.mm | 0 .../Methane/Platform/MacOS/AppDelegate.hh | 0 .../Methane/Platform/MacOS/AppDelegate.mm | 0 .../Platform/MacOS/AppViewController.hh | 0 .../Platform/MacOS/AppViewController.mm | 0 .../Methane/Platform/MacOS/WindowDelegate.hh | 0 .../Methane/Platform/MacOS/WindowDelegate.mm | 0 .../{ => Apple}/MacOS/AppView/CMakeLists.txt | 2 +- .../Methane/Platform/MacOS/AppEnvironment.hh | 0 .../Methane/Platform/MacOS/AppViewMetal.hh | 0 .../Methane/Platform/MacOS/AppViewMetal.mm | 0 .../Platform/{ => Apple}/MacOS/CMakeLists.txt | 0 .../{ => Apple}/MacOS/Input/CMakeLists.txt | 0 .../MacOS/Input/Keyboard/CMakeLists.txt | 2 +- .../Methane/Platform/Input/MacOS/Keyboard.h | 0 .../Methane/Platform/Input/MacOS/Keyboard.mm | 0 .../{ => Apple}/iOS/App/CMakeLists.txt | 2 +- .../App/Include/Methane/Platform/iOS/App.hh | 0 .../App/Sources/Methane/Platform/iOS/App.mm | 0 .../Methane/Platform/iOS/AppDelegate.hh | 0 .../Methane/Platform/iOS/AppDelegate.mm | 0 .../Methane/Platform/iOS/AppViewController.hh | 0 .../Methane/Platform/iOS/AppViewController.mm | 0 .../{ => Apple}/iOS/AppView/CMakeLists.txt | 2 +- .../Methane/Platform/iOS/AppEnvironment.hh | 0 .../Methane/Platform/iOS/AppViewMetal.hh | 0 .../Methane/Platform/iOS/AppViewMetal.mm | 0 .../Platform/{ => Apple}/iOS/CMakeLists.txt | 0 Modules/Platform/CMakeLists.txt | 5 -- Modules/Platform/Impl/App/README.md | 28 ++++---- Modules/Platform/README.md | 65 ++++++++++--------- 35 files changed, 64 insertions(+), 55 deletions(-) rename Modules/Platform/{ => Apple}/MacOS/App/CMakeLists.txt (97%) rename Modules/Platform/{ => Apple}/MacOS/App/Include/Methane/Platform/MacOS/App.hh (100%) rename Modules/Platform/{ => Apple}/MacOS/App/Sources/Methane/Platform/MacOS/App.mm (100%) rename Modules/Platform/{ => Apple}/MacOS/App/Sources/Methane/Platform/MacOS/AppDelegate.hh (100%) rename Modules/Platform/{ => Apple}/MacOS/App/Sources/Methane/Platform/MacOS/AppDelegate.mm (100%) rename Modules/Platform/{ => Apple}/MacOS/App/Sources/Methane/Platform/MacOS/AppViewController.hh (100%) rename Modules/Platform/{ => Apple}/MacOS/App/Sources/Methane/Platform/MacOS/AppViewController.mm (100%) rename Modules/Platform/{ => Apple}/MacOS/App/Sources/Methane/Platform/MacOS/WindowDelegate.hh (100%) rename Modules/Platform/{ => Apple}/MacOS/App/Sources/Methane/Platform/MacOS/WindowDelegate.mm (100%) rename Modules/Platform/{ => Apple}/MacOS/AppView/CMakeLists.txt (96%) rename Modules/Platform/{ => Apple}/MacOS/AppView/Include/Methane/Platform/MacOS/AppEnvironment.hh (100%) rename Modules/Platform/{ => Apple}/MacOS/AppView/Include/Methane/Platform/MacOS/AppViewMetal.hh (100%) rename Modules/Platform/{ => Apple}/MacOS/AppView/Sources/Methane/Platform/MacOS/AppViewMetal.mm (100%) rename Modules/Platform/{ => Apple}/MacOS/CMakeLists.txt (100%) rename Modules/Platform/{ => Apple}/MacOS/Input/CMakeLists.txt (100%) rename Modules/Platform/{ => Apple}/MacOS/Input/Keyboard/CMakeLists.txt (96%) rename Modules/Platform/{ => Apple}/MacOS/Input/Keyboard/Include/Methane/Platform/Input/MacOS/Keyboard.h (100%) rename Modules/Platform/{ => Apple}/MacOS/Input/Keyboard/Sources/Methane/Platform/Input/MacOS/Keyboard.mm (100%) rename Modules/Platform/{ => Apple}/iOS/App/CMakeLists.txt (97%) rename Modules/Platform/{ => Apple}/iOS/App/Include/Methane/Platform/iOS/App.hh (100%) rename Modules/Platform/{ => Apple}/iOS/App/Sources/Methane/Platform/iOS/App.mm (100%) rename Modules/Platform/{ => Apple}/iOS/App/Sources/Methane/Platform/iOS/AppDelegate.hh (100%) rename Modules/Platform/{ => Apple}/iOS/App/Sources/Methane/Platform/iOS/AppDelegate.mm (100%) rename Modules/Platform/{ => Apple}/iOS/App/Sources/Methane/Platform/iOS/AppViewController.hh (100%) rename Modules/Platform/{ => Apple}/iOS/App/Sources/Methane/Platform/iOS/AppViewController.mm (100%) rename Modules/Platform/{ => Apple}/iOS/AppView/CMakeLists.txt (97%) rename Modules/Platform/{ => Apple}/iOS/AppView/Include/Methane/Platform/iOS/AppEnvironment.hh (100%) rename Modules/Platform/{ => Apple}/iOS/AppView/Include/Methane/Platform/iOS/AppViewMetal.hh (100%) rename Modules/Platform/{ => Apple}/iOS/AppView/Sources/Methane/Platform/iOS/AppViewMetal.mm (100%) rename Modules/Platform/{ => Apple}/iOS/CMakeLists.txt (100%) diff --git a/.codecov.yml b/.codecov.yml index f5c4be36c..321e06ee2 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -60,15 +60,18 @@ component_management: name: Platform Input paths: - Modules/Platform/*/Input/** + - Modules/Platform/Apple/*/Input/** - Tests/Platform/Input/** - component_id: platform-app-view name: Platform App-View paths: - Modules/Platform/*/AppView/** + - Modules/Platform/Apple/*/AppView/** - component_id: platform-app name: Platform App paths: - Modules/Platform/*/App/** + - Modules/Platform/Apple/*/App/** - component_id: graphics-types name: Graphics Types paths: diff --git a/Modules/Platform/Apple/CMakeLists.txt b/Modules/Platform/Apple/CMakeLists.txt index e3ce185e0..d4ab7d4a4 100644 --- a/Modules/Platform/Apple/CMakeLists.txt +++ b/Modules/Platform/Apple/CMakeLists.txt @@ -1 +1,9 @@ +# Modules shared by all Apple platforms: add_subdirectory(Utils) + +# Modules of the particular Apple platform: +if(APPLE_MACOS) + add_subdirectory(MacOS) +else() # iOS / tvOS + add_subdirectory(iOS) +endif() diff --git a/Modules/Platform/MacOS/App/CMakeLists.txt b/Modules/Platform/Apple/MacOS/App/CMakeLists.txt similarity index 97% rename from Modules/Platform/MacOS/App/CMakeLists.txt rename to Modules/Platform/Apple/MacOS/App/CMakeLists.txt index 21d1b4fa0..410d286f6 100644 --- a/Modules/Platform/MacOS/App/CMakeLists.txt +++ b/Modules/Platform/Apple/MacOS/App/CMakeLists.txt @@ -67,7 +67,7 @@ source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) set_target_properties(${TARGET} PROPERTIES - FOLDER Modules/Platform/MacOS + FOLDER Modules/Platform/Apple/MacOS PUBLIC_HEADER "${HEADERS}" ) diff --git a/Modules/Platform/MacOS/App/Include/Methane/Platform/MacOS/App.hh b/Modules/Platform/Apple/MacOS/App/Include/Methane/Platform/MacOS/App.hh similarity index 100% rename from Modules/Platform/MacOS/App/Include/Methane/Platform/MacOS/App.hh rename to Modules/Platform/Apple/MacOS/App/Include/Methane/Platform/MacOS/App.hh diff --git a/Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/App.mm b/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/App.mm similarity index 100% rename from Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/App.mm rename to Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/App.mm diff --git a/Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/AppDelegate.hh b/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/AppDelegate.hh similarity index 100% rename from Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/AppDelegate.hh rename to Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/AppDelegate.hh diff --git a/Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/AppDelegate.mm b/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/AppDelegate.mm similarity index 100% rename from Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/AppDelegate.mm rename to Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/AppDelegate.mm diff --git a/Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/AppViewController.hh b/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/AppViewController.hh similarity index 100% rename from Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/AppViewController.hh rename to Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/AppViewController.hh diff --git a/Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/AppViewController.mm b/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/AppViewController.mm similarity index 100% rename from Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/AppViewController.mm rename to Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/AppViewController.mm diff --git a/Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/WindowDelegate.hh b/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/WindowDelegate.hh similarity index 100% rename from Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/WindowDelegate.hh rename to Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/WindowDelegate.hh diff --git a/Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/WindowDelegate.mm b/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/WindowDelegate.mm similarity index 100% rename from Modules/Platform/MacOS/App/Sources/Methane/Platform/MacOS/WindowDelegate.mm rename to Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/WindowDelegate.mm diff --git a/Modules/Platform/MacOS/AppView/CMakeLists.txt b/Modules/Platform/Apple/MacOS/AppView/CMakeLists.txt similarity index 96% rename from Modules/Platform/MacOS/AppView/CMakeLists.txt rename to Modules/Platform/Apple/MacOS/AppView/CMakeLists.txt index c1c3e97e0..ea0488831 100644 --- a/Modules/Platform/MacOS/AppView/CMakeLists.txt +++ b/Modules/Platform/Apple/MacOS/AppView/CMakeLists.txt @@ -53,7 +53,7 @@ source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) set_target_properties(${TARGET} PROPERTIES - FOLDER Modules/Platform/MacOS + FOLDER Modules/Platform/Apple/MacOS PUBLIC_HEADER "${HEADERS}" ) diff --git a/Modules/Platform/MacOS/AppView/Include/Methane/Platform/MacOS/AppEnvironment.hh b/Modules/Platform/Apple/MacOS/AppView/Include/Methane/Platform/MacOS/AppEnvironment.hh similarity index 100% rename from Modules/Platform/MacOS/AppView/Include/Methane/Platform/MacOS/AppEnvironment.hh rename to Modules/Platform/Apple/MacOS/AppView/Include/Methane/Platform/MacOS/AppEnvironment.hh diff --git a/Modules/Platform/MacOS/AppView/Include/Methane/Platform/MacOS/AppViewMetal.hh b/Modules/Platform/Apple/MacOS/AppView/Include/Methane/Platform/MacOS/AppViewMetal.hh similarity index 100% rename from Modules/Platform/MacOS/AppView/Include/Methane/Platform/MacOS/AppViewMetal.hh rename to Modules/Platform/Apple/MacOS/AppView/Include/Methane/Platform/MacOS/AppViewMetal.hh diff --git a/Modules/Platform/MacOS/AppView/Sources/Methane/Platform/MacOS/AppViewMetal.mm b/Modules/Platform/Apple/MacOS/AppView/Sources/Methane/Platform/MacOS/AppViewMetal.mm similarity index 100% rename from Modules/Platform/MacOS/AppView/Sources/Methane/Platform/MacOS/AppViewMetal.mm rename to Modules/Platform/Apple/MacOS/AppView/Sources/Methane/Platform/MacOS/AppViewMetal.mm diff --git a/Modules/Platform/MacOS/CMakeLists.txt b/Modules/Platform/Apple/MacOS/CMakeLists.txt similarity index 100% rename from Modules/Platform/MacOS/CMakeLists.txt rename to Modules/Platform/Apple/MacOS/CMakeLists.txt diff --git a/Modules/Platform/MacOS/Input/CMakeLists.txt b/Modules/Platform/Apple/MacOS/Input/CMakeLists.txt similarity index 100% rename from Modules/Platform/MacOS/Input/CMakeLists.txt rename to Modules/Platform/Apple/MacOS/Input/CMakeLists.txt diff --git a/Modules/Platform/MacOS/Input/Keyboard/CMakeLists.txt b/Modules/Platform/Apple/MacOS/Input/Keyboard/CMakeLists.txt similarity index 96% rename from Modules/Platform/MacOS/Input/Keyboard/CMakeLists.txt rename to Modules/Platform/Apple/MacOS/Input/Keyboard/CMakeLists.txt index ebb8963d7..778877812 100644 --- a/Modules/Platform/MacOS/Input/Keyboard/CMakeLists.txt +++ b/Modules/Platform/Apple/MacOS/Input/Keyboard/CMakeLists.txt @@ -52,7 +52,7 @@ source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) set_target_properties(${TARGET} PROPERTIES - FOLDER Modules/Platform/MacOS/Input + FOLDER Modules/Platform/Apple/MacOS/Input PUBLIC_HEADER "${HEADERS}" ) diff --git a/Modules/Platform/MacOS/Input/Keyboard/Include/Methane/Platform/Input/MacOS/Keyboard.h b/Modules/Platform/Apple/MacOS/Input/Keyboard/Include/Methane/Platform/Input/MacOS/Keyboard.h similarity index 100% rename from Modules/Platform/MacOS/Input/Keyboard/Include/Methane/Platform/Input/MacOS/Keyboard.h rename to Modules/Platform/Apple/MacOS/Input/Keyboard/Include/Methane/Platform/Input/MacOS/Keyboard.h diff --git a/Modules/Platform/MacOS/Input/Keyboard/Sources/Methane/Platform/Input/MacOS/Keyboard.mm b/Modules/Platform/Apple/MacOS/Input/Keyboard/Sources/Methane/Platform/Input/MacOS/Keyboard.mm similarity index 100% rename from Modules/Platform/MacOS/Input/Keyboard/Sources/Methane/Platform/Input/MacOS/Keyboard.mm rename to Modules/Platform/Apple/MacOS/Input/Keyboard/Sources/Methane/Platform/Input/MacOS/Keyboard.mm diff --git a/Modules/Platform/iOS/App/CMakeLists.txt b/Modules/Platform/Apple/iOS/App/CMakeLists.txt similarity index 97% rename from Modules/Platform/iOS/App/CMakeLists.txt rename to Modules/Platform/Apple/iOS/App/CMakeLists.txt index 90a5368fc..27959501f 100644 --- a/Modules/Platform/iOS/App/CMakeLists.txt +++ b/Modules/Platform/Apple/iOS/App/CMakeLists.txt @@ -64,7 +64,7 @@ source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) set_target_properties(${TARGET} PROPERTIES - FOLDER Modules/Platform/iOS + FOLDER Modules/Platform/Apple/iOS PUBLIC_HEADER "${HEADERS}" ) diff --git a/Modules/Platform/iOS/App/Include/Methane/Platform/iOS/App.hh b/Modules/Platform/Apple/iOS/App/Include/Methane/Platform/iOS/App.hh similarity index 100% rename from Modules/Platform/iOS/App/Include/Methane/Platform/iOS/App.hh rename to Modules/Platform/Apple/iOS/App/Include/Methane/Platform/iOS/App.hh diff --git a/Modules/Platform/iOS/App/Sources/Methane/Platform/iOS/App.mm b/Modules/Platform/Apple/iOS/App/Sources/Methane/Platform/iOS/App.mm similarity index 100% rename from Modules/Platform/iOS/App/Sources/Methane/Platform/iOS/App.mm rename to Modules/Platform/Apple/iOS/App/Sources/Methane/Platform/iOS/App.mm diff --git a/Modules/Platform/iOS/App/Sources/Methane/Platform/iOS/AppDelegate.hh b/Modules/Platform/Apple/iOS/App/Sources/Methane/Platform/iOS/AppDelegate.hh similarity index 100% rename from Modules/Platform/iOS/App/Sources/Methane/Platform/iOS/AppDelegate.hh rename to Modules/Platform/Apple/iOS/App/Sources/Methane/Platform/iOS/AppDelegate.hh diff --git a/Modules/Platform/iOS/App/Sources/Methane/Platform/iOS/AppDelegate.mm b/Modules/Platform/Apple/iOS/App/Sources/Methane/Platform/iOS/AppDelegate.mm similarity index 100% rename from Modules/Platform/iOS/App/Sources/Methane/Platform/iOS/AppDelegate.mm rename to Modules/Platform/Apple/iOS/App/Sources/Methane/Platform/iOS/AppDelegate.mm diff --git a/Modules/Platform/iOS/App/Sources/Methane/Platform/iOS/AppViewController.hh b/Modules/Platform/Apple/iOS/App/Sources/Methane/Platform/iOS/AppViewController.hh similarity index 100% rename from Modules/Platform/iOS/App/Sources/Methane/Platform/iOS/AppViewController.hh rename to Modules/Platform/Apple/iOS/App/Sources/Methane/Platform/iOS/AppViewController.hh diff --git a/Modules/Platform/iOS/App/Sources/Methane/Platform/iOS/AppViewController.mm b/Modules/Platform/Apple/iOS/App/Sources/Methane/Platform/iOS/AppViewController.mm similarity index 100% rename from Modules/Platform/iOS/App/Sources/Methane/Platform/iOS/AppViewController.mm rename to Modules/Platform/Apple/iOS/App/Sources/Methane/Platform/iOS/AppViewController.mm diff --git a/Modules/Platform/iOS/AppView/CMakeLists.txt b/Modules/Platform/Apple/iOS/AppView/CMakeLists.txt similarity index 97% rename from Modules/Platform/iOS/AppView/CMakeLists.txt rename to Modules/Platform/Apple/iOS/AppView/CMakeLists.txt index c8fb8c5b6..b36aa7ed3 100644 --- a/Modules/Platform/iOS/AppView/CMakeLists.txt +++ b/Modules/Platform/Apple/iOS/AppView/CMakeLists.txt @@ -53,7 +53,7 @@ source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) set_target_properties(${TARGET} PROPERTIES - FOLDER Modules/Platform/iOS + FOLDER Modules/Platform/Apple/iOS PUBLIC_HEADER "${HEADERS}" ) diff --git a/Modules/Platform/iOS/AppView/Include/Methane/Platform/iOS/AppEnvironment.hh b/Modules/Platform/Apple/iOS/AppView/Include/Methane/Platform/iOS/AppEnvironment.hh similarity index 100% rename from Modules/Platform/iOS/AppView/Include/Methane/Platform/iOS/AppEnvironment.hh rename to Modules/Platform/Apple/iOS/AppView/Include/Methane/Platform/iOS/AppEnvironment.hh diff --git a/Modules/Platform/iOS/AppView/Include/Methane/Platform/iOS/AppViewMetal.hh b/Modules/Platform/Apple/iOS/AppView/Include/Methane/Platform/iOS/AppViewMetal.hh similarity index 100% rename from Modules/Platform/iOS/AppView/Include/Methane/Platform/iOS/AppViewMetal.hh rename to Modules/Platform/Apple/iOS/AppView/Include/Methane/Platform/iOS/AppViewMetal.hh diff --git a/Modules/Platform/iOS/AppView/Sources/Methane/Platform/iOS/AppViewMetal.mm b/Modules/Platform/Apple/iOS/AppView/Sources/Methane/Platform/iOS/AppViewMetal.mm similarity index 100% rename from Modules/Platform/iOS/AppView/Sources/Methane/Platform/iOS/AppViewMetal.mm rename to Modules/Platform/Apple/iOS/AppView/Sources/Methane/Platform/iOS/AppViewMetal.mm diff --git a/Modules/Platform/iOS/CMakeLists.txt b/Modules/Platform/Apple/iOS/CMakeLists.txt similarity index 100% rename from Modules/Platform/iOS/CMakeLists.txt rename to Modules/Platform/Apple/iOS/CMakeLists.txt diff --git a/Modules/Platform/CMakeLists.txt b/Modules/Platform/CMakeLists.txt index 88cf6ffab..e457ac28c 100644 --- a/Modules/Platform/CMakeLists.txt +++ b/Modules/Platform/CMakeLists.txt @@ -8,11 +8,6 @@ if(WIN32) add_subdirectory(Windows) elseif(APPLE) add_subdirectory(Apple) - if(APPLE_MACOS) - add_subdirectory(MacOS) - else() # iOS / tvOS - add_subdirectory(iOS) - endif() else() # Linux add_subdirectory(Linux) endif() diff --git a/Modules/Platform/Impl/App/README.md b/Modules/Platform/Impl/App/README.md index 3e249b752..4229c489f 100644 --- a/Modules/Platform/Impl/App/README.md +++ b/Modules/Platform/Impl/App/README.md @@ -6,20 +6,20 @@ Graphics rendering infrastructure itself is split into derived class defined in Platform application modules are grouped by platform support, similar to [Graphics RHI](../../../Graphics/RHI): ``` -Interfaces/App ──> Base/App ──> { Windows | Linux | MacOS | iOS }/App ──> Impl/App - Common/App ──┘ +Interfaces/App ──> Base/App ──> { Windows | Linux | Apple/MacOS | Apple/iOS }/App ──> Impl/App + Common/App ──┘ ``` -| Module | CMake Target | Description | -|--------------------------------------------------------|------------------------------|---------------------------------------------| -| [Interfaces/App](../../Interfaces/App) | MethanePlatformAppInterface | `Platform::IApp` interface and app settings | -| [Base/App](../../Base/App) | MethanePlatformAppBase | `Platform::Base::App` implementation | -| [Windows/App](../../Windows/App) | MethanePlatformAppWindows | `Platform::Windows::App` implementation | -| [Linux/App](../../Linux/App) | MethanePlatformAppLinux | `Platform::Linux::App` implementation | -| [MacOS/App](../../MacOS/App) | MethanePlatformAppMacOS | `Platform::MacOS::App` implementation | -| [iOS/App](../../iOS/App) | MethanePlatformAppIOS | `Platform::iOS::App` implementation | -| [Common/App](../../Common/App) | MethanePlatformAppCommon | `Platform::AppController` implementation | -| [Impl/App](.) | MethanePlatformApp | `Platform::App` final implementation alias | +| Module | CMake Target | Description | +|------------------------------------------------|-----------------------------|---------------------------------------------| +| [Interfaces/App](../../Interfaces/App) | MethanePlatformAppInterface | `Platform::IApp` interface and app settings | +| [Base/App](../../Base/App) | MethanePlatformAppBase | `Platform::Base::App` implementation | +| [Windows/App](../../Windows/App) | MethanePlatformAppWindows | `Platform::Windows::App` implementation | +| [Linux/App](../../Linux/App) | MethanePlatformAppLinux | `Platform::Linux::App` implementation | +| [Apple/MacOS/App](../../Apple/MacOS/App) | MethanePlatformAppMacOS | `Platform::MacOS::App` implementation | +| [Apple/iOS/App](../../Apple/iOS/App) | MethanePlatformAppIOS | `Platform::iOS::App` implementation | +| [Common/App](../../Common/App) | MethanePlatformAppCommon | `Platform::AppController` implementation | +| [Impl/App](.) | MethanePlatformApp | `Platform::App` final implementation alias | ## Platform Application @@ -30,8 +30,8 @@ to one of the platform-specific implementations of the [Platform::Base::App](#pl - [Platform::Windows::App](../../Windows/App/Include/Methane/Platform/Windows/App.h) - Windows app implementation - [Platform::Linux::App](../../Linux/App/Include/Methane/Platform/Linux/App.h) - Linux app implementation -- [Platform::MacOS::App](../../MacOS/App/Include/Methane/Platform/MacOS/App.hh) - MacOS app implementation -- [Platform::iOS::App](../../iOS/App/Include/Methane/Platform/iOS/App.hh) - iOS app implementation +- [Platform::MacOS::App](../../Apple/MacOS/App/Include/Methane/Platform/MacOS/App.hh) - MacOS app implementation +- [Platform::iOS::App](../../Apple/iOS/App/Include/Methane/Platform/iOS/App.hh) - iOS app implementation `Platform::App` should be used as a base class for any windowed Methane application. diff --git a/Modules/Platform/README.md b/Modules/Platform/README.md index 724f50754..77d371474 100644 --- a/Modules/Platform/README.md +++ b/Modules/Platform/README.md @@ -4,19 +4,22 @@ Code of these modules is located in `Methane::Platform` namespace. Platform modules are grouped by platform support, similar to [Graphics RHI](../Graphics/RHI) modules: -| Group | Namespace | Content | -|--------------------------|------------------------------|------------------------------------------------------------------| -| [Interfaces](Interfaces) | `Methane::Platform` | Public interfaces and settings structures with no implementation | -| [Base](Base) | `Methane::Platform::Base` | Platform-independent base implementations used by all platforms | -| [Common](Common) | `Methane::Platform` | Fully platform-independent implementations | -| [Windows](Windows) | `Methane::Platform::Windows` | Windows-specific implementations | -| [Linux](Linux) | `Methane::Platform::Linux` | Linux-specific implementations | -| [MacOS](MacOS) | `Methane::Platform::MacOS` | MacOS-specific implementations | -| [iOS](iOS) | `Methane::Platform::iOS` | iOS / tvOS-specific implementations | -| [Apple](Apple) | `Methane::Platform::Apple` | Implementations shared by all Apple platforms | -| [Impl](Impl) | `Methane::Platform` | Final implementation modules binding the groups above together | - -Exactly one platform group is added to the build by [CMakeLists.txt](CMakeLists.txt), chosen by the target platform. +| Group | Namespace | Content | +|------------------------------|------------------------------|-----------------------------------------------------------------| +| [Interfaces](Interfaces) | `Methane::Platform` | Public interfaces and settings structures with no implementation | +| [Base](Base) | `Methane::Platform::Base` | Platform-independent base implementations used by all platforms | +| [Common](Common) | `Methane::Platform` | Fully platform-independent implementations | +| [Windows](Windows) | `Methane::Platform::Windows` | Windows-specific implementations | +| [Linux](Linux) | `Methane::Platform::Linux` | Linux-specific implementations | +| [Apple](Apple) | `Methane::Platform::Apple` | Implementations shared by all Apple platforms | +| [Apple/MacOS](Apple/MacOS) | `Methane::Platform::MacOS` | MacOS-specific implementations | +| [Apple/iOS](Apple/iOS) | `Methane::Platform::iOS` | iOS / tvOS-specific implementations | +| [Impl](Impl) | `Methane::Platform` | Final implementation modules binding the groups above together | + +Exactly one platform group is added to the build by [CMakeLists.txt](CMakeLists.txt), chosen by the target platform; +on Apple platforms [Apple/CMakeLists.txt](Apple/CMakeLists.txt) additionally picks `MacOS` or `iOS` on top of the +shared `Apple` modules. + Only the `Impl` group targets are intended to be linked from other domains: `MethanePlatformApp`, `MethanePlatformAppView`, `MethanePlatformInputKeyboard` and `MethanePlatformUtils`. @@ -27,28 +30,28 @@ Only the `Impl` group targets are intended to be linked from other domains: `Met Application platform-abstraction class and platform-specific implementations — see [Platform App description](Impl/App/README.md) for details. -| Module | CMake Target | -|----------------------------------|-----------------------------| -| [Interfaces/App](Interfaces/App) | MethanePlatformAppInterface | -| [Base/App](Base/App) | MethanePlatformAppBase | -| [Common/App](Common/App) | MethanePlatformAppCommon | -| [Windows/App](Windows/App) | MethanePlatformAppWindows | -| [Linux/App](Linux/App) | MethanePlatformAppLinux | -| [MacOS/App](MacOS/App) | MethanePlatformAppMacOS | -| [iOS/App](iOS/App) | MethanePlatformAppIOS | -| [Impl/App](Impl/App) | MethanePlatformApp | +| Module | CMake Target | +|------------------------------------------|-----------------------------| +| [Interfaces/App](Interfaces/App) | MethanePlatformAppInterface | +| [Base/App](Base/App) | MethanePlatformAppBase | +| [Common/App](Common/App) | MethanePlatformAppCommon | +| [Windows/App](Windows/App) | MethanePlatformAppWindows | +| [Linux/App](Linux/App) | MethanePlatformAppLinux | +| [Apple/MacOS/App](Apple/MacOS/App) | MethanePlatformAppMacOS | +| [Apple/iOS/App](Apple/iOS/App) | MethanePlatformAppIOS | +| [Impl/App](Impl/App) | MethanePlatformApp | ### AppView Application view and environment platform-abstraction classes. -| Module | CMake Target | -|------------------------------------|-------------------------------| -| [Windows/AppView](Windows/AppView) | MethanePlatformAppViewWindows | -| [Linux/AppView](Linux/AppView) | MethanePlatformAppViewLinux | -| [MacOS/AppView](MacOS/AppView) | MethanePlatformAppViewMacOS | -| [iOS/AppView](iOS/AppView) | MethanePlatformAppViewIOS | -| [Impl/AppView](Impl/AppView) | MethanePlatformAppView | +| Module | CMake Target | +|----------------------------------------------|-------------------------------| +| [Windows/AppView](Windows/AppView) | MethanePlatformAppViewWindows | +| [Linux/AppView](Linux/AppView) | MethanePlatformAppViewLinux | +| [Apple/MacOS/AppView](Apple/MacOS/AppView) | MethanePlatformAppViewMacOS | +| [Apple/iOS/AppView](Apple/iOS/AppView) | MethanePlatformAppViewIOS | +| [Impl/AppView](Impl/AppView) | MethanePlatformAppView | ### Input @@ -59,7 +62,7 @@ Application input with mouse and keyboard and platform-specific handling impleme | [Base/Input/Keyboard](Base/Input/Keyboard) | MethanePlatformInputKeyboardBase | | [Windows/Input/Keyboard](Windows/Input/Keyboard) | MethanePlatformInputKeyboardWindows | | [Linux/Input/Keyboard](Linux/Input/Keyboard) | MethanePlatformInputKeyboardLinux | -| [MacOS/Input/Keyboard](MacOS/Input/Keyboard) | MethanePlatformInputKeyboardMacOS | +| [Apple/MacOS/Input/Keyboard](Apple/MacOS/Input/Keyboard) | MethanePlatformInputKeyboardMacOS | | [Impl/Input/Keyboard](Impl/Input/Keyboard) | MethanePlatformInputKeyboard | | [Common/Input/Mouse](Common/Input/Mouse) | MethanePlatformInputMouse | | [Common/Input/Controllers](Common/Input/Controllers) | MethanePlatformInputControllers | From 1c5c0c34e994c6c74938cfd2f5b96381de7a7eaf Mon Sep 17 00:00:00 2001 From: Evgeny Gorodetskiy Date: Sun, 29 Nov 2026 19:14:38 +0300 Subject: [PATCH 3/7] Fix Linux and MacOS builds of the regrouped Platform Input modules Two defects found by CI on the non-Windows platforms: - MethanePlatformInputKeyboardBase referenced KeyConverter::GetKeyByNativeCode and GetModifiersByNativeCode, which are implemented in the platform keyboard module, so Base and the platform module depended on each other. The MSVC linker resolves such a cycle, GNU ld does not, and every Linux application failed to link. The KeyConverter(const NativeKey&) constructor is moved out of the Base implementation into each platform implementation, next to the two statics it calls, which makes the dependency strictly one-directional: platform -> Base. - MacOS AppViewController.mm constructs a KeyConverter from a NativeKey, so it now has to include explicitly, since the platform dispatch include was removed from Input/Keyboard.h. The equivalent includes were already added for Windows and Linux. iOS and tvOS are unaffected: they have no native keyboard event translation and never provided these statics. Verified on Windows with the VS2022-Win64-DX and VS2022-Win64-VK presets (Debug build clean, 493/493 unit tests passing on each); Linux and MacOS are to be confirmed by CI. Refs #165 Co-Authored-By: Claude Opus 5 --- .../App/Sources/Methane/Platform/MacOS/AppViewController.mm | 1 + .../Sources/Methane/Platform/Input/MacOS/Keyboard.mm | 5 +++++ .../Keyboard/Sources/Methane/Platform/Input/Keyboard.cpp | 5 ----- .../Sources/Methane/Platform/Input/Linux/Keyboard.cpp | 5 +++++ .../Sources/Methane/Platform/Input/Windows/Keyboard.cpp | 5 +++++ 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/AppViewController.mm b/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/AppViewController.mm index bb84e86f2..a183ea671 100644 --- a/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/AppViewController.mm +++ b/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/AppViewController.mm @@ -24,6 +24,7 @@ #import "AppViewController.hh" #include +#include #include #include #include diff --git a/Modules/Platform/Apple/MacOS/Input/Keyboard/Sources/Methane/Platform/Input/MacOS/Keyboard.mm b/Modules/Platform/Apple/MacOS/Input/Keyboard/Sources/Methane/Platform/Input/MacOS/Keyboard.mm index 069cae86b..af47d2113 100644 --- a/Modules/Platform/Apple/MacOS/Input/Keyboard/Sources/Methane/Platform/Input/MacOS/Keyboard.mm +++ b/Modules/Platform/Apple/MacOS/Input/Keyboard/Sources/Methane/Platform/Input/MacOS/Keyboard.mm @@ -182,4 +182,9 @@ return modifiers_mask; } +KeyConverter::KeyConverter(const NativeKey& native_key) + : m_key(GetKeyByNativeCode(native_key)) + , m_modifiers(GetModifiersByNativeCode(native_key)) +{ } + } // namespace Methane::Platform::Input::Keyboard \ No newline at end of file diff --git a/Modules/Platform/Base/Input/Keyboard/Sources/Methane/Platform/Input/Keyboard.cpp b/Modules/Platform/Base/Input/Keyboard/Sources/Methane/Platform/Input/Keyboard.cpp index 612eae06d..a6ebb4cf5 100644 --- a/Modules/Platform/Base/Input/Keyboard/Sources/Methane/Platform/Input/Keyboard.cpp +++ b/Modules/Platform/Base/Input/Keyboard/Sources/Methane/Platform/Input/Keyboard.cpp @@ -50,11 +50,6 @@ KeyConverter::KeyConverter(Key key, ModifierMask modifiers) , m_modifiers(modifiers) { } -KeyConverter::KeyConverter(const NativeKey& native_key) - : m_key(GetKeyByNativeCode(native_key)) - , m_modifiers(GetModifiersByNativeCode(native_key)) -{ } - Opt KeyConverter::GetModifierKey() const noexcept { META_FUNCTION_TASK(); diff --git a/Modules/Platform/Linux/Input/Keyboard/Sources/Methane/Platform/Input/Linux/Keyboard.cpp b/Modules/Platform/Linux/Input/Keyboard/Sources/Methane/Platform/Input/Linux/Keyboard.cpp index ac9216d1d..e4b8fe75b 100644 --- a/Modules/Platform/Linux/Input/Keyboard/Sources/Methane/Platform/Input/Linux/Keyboard.cpp +++ b/Modules/Platform/Linux/Input/Keyboard/Sources/Methane/Platform/Input/Linux/Keyboard.cpp @@ -188,4 +188,9 @@ ModifierMask KeyConverter::GetModifiersByNativeCode(const NativeKey& native_key) return modifiers_mask; } +KeyConverter::KeyConverter(const NativeKey& native_key) + : m_key(GetKeyByNativeCode(native_key)) + , m_modifiers(GetModifiersByNativeCode(native_key)) +{ } + } // namespace Methane::Platform::Input::Keyboard \ No newline at end of file diff --git a/Modules/Platform/Windows/Input/Keyboard/Sources/Methane/Platform/Input/Windows/Keyboard.cpp b/Modules/Platform/Windows/Input/Keyboard/Sources/Methane/Platform/Input/Windows/Keyboard.cpp index 92a80ea5d..112df8847 100644 --- a/Modules/Platform/Windows/Input/Keyboard/Sources/Methane/Platform/Input/Windows/Keyboard.cpp +++ b/Modules/Platform/Windows/Input/Keyboard/Sources/Methane/Platform/Input/Windows/Keyboard.cpp @@ -210,4 +210,9 @@ ModifierMask KeyConverter::GetModifiersByNativeCode(const NativeKey& native_key) } } +KeyConverter::KeyConverter(const NativeKey& native_key) + : m_key(GetKeyByNativeCode(native_key)) + , m_modifiers(GetModifiersByNativeCode(native_key)) +{ } + } // namespace Methane::Platform::Input::Keyboard From 668ccb5a6ca08d89d099fa967cf5e19fe63faee0 Mon Sep 17 00:00:00 2001 From: Evgeny Gorodetskiy Date: Sun, 29 Nov 2026 19:26:09 +0300 Subject: [PATCH 4/7] Fix MacOS namespace resolution and correct Platform App docs Address review feedback on PR #166: - Methane::MacOS (Apple/Types.hh) is a different namespace from the new Methane::Platform::MacOS application namespace. Inside the latter an unqualified "MacOS::ConvertToNsString" resolves to the enclosing application namespace, which has no such function, and in AppDelegate.mm and WindowDelegate.mm the "using namespace Methane" plus "using namespace Methane::Platform" pair makes the name "MacOS" ambiguous between the two. All such uses are now fully qualified as Methane::MacOS::ConvertToNsString and Methane::Platform::MacOS::App. The iOS App.mm uses of the same helper are qualified too, for clarity. - The Platform::AppSettings table in Impl/App/README.md documented fields and command-line options which no longer exist: "name" was typed uint32_t instead of std::string, and the separate width/height and min_width/min_height rows with "-w,--width" and "-x,--height" options were replaced long ago by the "size" and "min_size" fields and the single "-w,--wnd-size" option. The table now matches IApp.h and Base/App.cpp, and the icon provider field and the --print_debug_messages_to_console flag are documented as well. - The external linking guidance in Platform/README.md claimed that only Impl group targets may be linked from other domains, which wrongly excluded the platform-independent Common input targets that Graphics, UserInterface and the tests already link directly. Verified on Windows with the VS2022-Win64-DX and VS2022-Win64-VK presets (Debug build clean, 493/493 unit tests passing on each). Refs #165 Co-Authored-By: Claude Opus 5 --- .../App/Sources/Methane/Platform/MacOS/App.mm | 6 +++--- .../Methane/Platform/MacOS/AppDelegate.mm | 8 ++++---- .../Methane/Platform/MacOS/WindowDelegate.mm | 4 ++-- .../App/Sources/Methane/Platform/iOS/App.mm | 4 ++-- Modules/Platform/Impl/App/README.md | 18 ++++++++++-------- Modules/Platform/README.md | 7 +++++-- 6 files changed, 26 insertions(+), 21 deletions(-) diff --git a/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/App.mm b/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/App.mm index b7ab56da3..0440588e1 100644 --- a/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/App.mm +++ b/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/App.mm @@ -106,7 +106,7 @@ static NSAlertStyle ConvertMessageTypeToNsAlertStyle(Base::App::Message::Type ms void App::SetWindowTitle(const std::string& title_text) { META_FUNCTION_TASK(); - NSString* ns_title_text = MacOS::ConvertToNsString(title_text); + NSString* ns_title_text = Methane::MacOS::ConvertToNsString(title_text); dispatch_async(dispatch_get_main_queue(), ^(void){ m_ns_window.title = ns_title_text; }); @@ -123,8 +123,8 @@ static NSAlertStyle ConvertMessageTypeToNsAlertStyle(Base::App::Message::Type ms META_FUNCTION_TASK(); META_CHECK_NOT_NULL(m_ns_app_delegate); - [m_ns_app_delegate alert: MacOS::ConvertToNsString(msg.title) - withInformation: MacOS::ConvertToNsString(msg.information) + [m_ns_app_delegate alert: Methane::MacOS::ConvertToNsString(msg.title) + withInformation: Methane::MacOS::ConvertToNsString(msg.information) andStyle: ConvertMessageTypeToNsAlertStyle(msg.type)]; Base::App::ShowAlert(msg); diff --git a/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/AppDelegate.mm b/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/AppDelegate.mm index 19cf1a84b..e194a9eed 100644 --- a/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/AppDelegate.mm +++ b/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/AppDelegate.mm @@ -40,7 +40,7 @@ @implementation AppDelegate @synthesize window = m_window; -- (id) initWithApp : (MacOS::App*) app_ptr andSettings : (const Base::App::Settings*) settings_ptr +- (id) initWithApp : (Methane::Platform::MacOS::App*) app_ptr andSettings : (const Base::App::Settings*) settings_ptr { META_FUNCTION_TASK(); self = [super init]; @@ -70,7 +70,7 @@ - (id) initWithApp : (MacOS::App*) app_ptr andSettings : (const Base::App::Setti m_window = [[NSWindow alloc] initWithContentRect:frame styleMask:style_mask backing:backing defer:YES]; m_window.contentMinSize = NSMakeSize(static_cast(min_frame_size.GetWidth()), static_cast(min_frame_size.GetHeight())); - m_window.title = MacOS::ConvertToNsString(settings_ptr->name); + m_window.title = Methane::MacOS::ConvertToNsString(settings_ptr->name); // Window state restoration is not implemented and window size and position are set from application settings, // so it is disabled to stop AppKit from persisting the saved state of the window which is never restored @@ -133,7 +133,7 @@ - (void) windowWillEnterFullScreen:(NSNotification *)notification { META_FUNCTION_TASK(); #pragma unused(notification) - MacOS::App* app_ptr = [self.viewController getApp]; + Methane::Platform::MacOS::App* app_ptr = [self.viewController getApp]; META_CHECK_NOT_NULL(app_ptr); app_ptr->SetFullScreenInternal(true); } @@ -142,7 +142,7 @@ - (void) windowWillExitFullScreen:(NSNotification *)notification { META_FUNCTION_TASK(); #pragma unused(notification) - MacOS::App* app_ptr = [self.viewController getApp]; + Methane::Platform::MacOS::App* app_ptr = [self.viewController getApp]; META_CHECK_NOT_NULL(app_ptr); app_ptr->SetFullScreenInternal(false); } diff --git a/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/WindowDelegate.mm b/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/WindowDelegate.mm index 0b1b72865..21a47f7f7 100644 --- a/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/WindowDelegate.mm +++ b/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/WindowDelegate.mm @@ -32,11 +32,11 @@ @implementation WindowDelegate { - MacOS::App* m_app_ptr; + Methane::Platform::MacOS::App* m_app_ptr; Data::FrameSize m_frame_size; } -- (id) initWithApp : (MacOS::App*) app_ptr +- (id) initWithApp : (Methane::Platform::MacOS::App*) app_ptr { META_FUNCTION_TASK(); diff --git a/Modules/Platform/Apple/iOS/App/Sources/Methane/Platform/iOS/App.mm b/Modules/Platform/Apple/iOS/App/Sources/Methane/Platform/iOS/App.mm index 780a0adf4..6fb0116ce 100644 --- a/Modules/Platform/Apple/iOS/App/Sources/Methane/Platform/iOS/App.mm +++ b/Modules/Platform/Apple/iOS/App/Sources/Methane/Platform/iOS/App.mm @@ -113,8 +113,8 @@ static UIAlertActionStyle ConvertMessageTypeToNsAlertStyle(Base::App::Message::T AppDelegate* app_delegate = static_cast([UIApplication sharedApplication].delegate); META_CHECK_NOT_NULL(app_delegate); - [app_delegate alert: MacOS::ConvertToNsString(msg.title) - withInformation: MacOS::ConvertToNsString(msg.information) + [app_delegate alert: Methane::MacOS::ConvertToNsString(msg.title) + withInformation: Methane::MacOS::ConvertToNsString(msg.information) andStyle: ConvertMessageTypeToNsAlertStyle(msg.type)]; Base::App::ShowAlert(msg); diff --git a/Modules/Platform/Impl/App/README.md b/Modules/Platform/Impl/App/README.md index 4229c489f..6340505b9 100644 --- a/Modules/Platform/Impl/App/README.md +++ b/Modules/Platform/Impl/App/README.md @@ -63,14 +63,16 @@ platform-abstraction implementation of the application class with the following The following settings are available in `Platform::AppSettings` structure: -| Setting | Type | Default Value | Cmd-Line Option | Description | -|----------------|----------|---------------|------------------|-----------------------| -| name | uint32_t | "" | | Application name displayed in window header | -| width | double | 0.8 | -w,--width | Main window width (if < 1.0 it is a ratio of desktop size; else size in pixels/dots) | -| height | double | 0.8 | -x,--height | Main window height (if < 1.0 it is a ratio of desktop size; else size in pixels/dots) | -| min_width | uint32_t | 640 | | Minimum window width in pixels/dots limited for resizing | -| min_height | uint32_t | 480 | | Minimum window height in pixels/dots limited for resizing | -| is_full_screen | bool | false | -f,--full-screen | Full-screen state of the main window | +| Setting | Type | Default Value | Cmd-Line Option | Description | +|-------------------|--------------------|---------------|------------------|---------------------------------------------------------------------------------------------------| +| name | `std::string` | "" | | Application name displayed in window header | +| size | `Data::FloatSize` | 0.8 x 0.8 | -w,--wnd-size | Main window size (if a dimension < 1.0 it is a ratio of desktop size; else size in pixels/dots) | +| min_size | `Data::FrameSize` | 640 x 480 | | Minimum main window size in pixels/dots limited for resizing | +| is_full_screen | `bool` | false | -f,--full-screen | Full-screen state of the main window | +| icon_provider_ptr | `Data::IProvider*` | nullptr | | Provider of the window icon resources | + +Additionally the `--print_debug_messages_to_console` flag redirects debug messages, including graphics API +validation errors and warnings, to the console output instead of the platform debug output. ## Platform Application Controller diff --git a/Modules/Platform/README.md b/Modules/Platform/README.md index 77d371474..2125bf54d 100644 --- a/Modules/Platform/README.md +++ b/Modules/Platform/README.md @@ -20,8 +20,11 @@ Exactly one platform group is added to the build by [CMakeLists.txt](CMakeLists. on Apple platforms [Apple/CMakeLists.txt](Apple/CMakeLists.txt) additionally picks `MacOS` or `iOS` on top of the shared `Apple` modules. -Only the `Impl` group targets are intended to be linked from other domains: `MethanePlatformApp`, -`MethanePlatformAppView`, `MethanePlatformInputKeyboard` and `MethanePlatformUtils`. +Where a module has an `Impl` facade target, other domains link that facade rather than the `Base` or +platform targets behind it: `MethanePlatformApp`, `MethanePlatformAppView`, +`MethanePlatformInputKeyboard` and `MethanePlatformUtils`. Modules which are fully platform-independent +have no facade and are linked directly from the `Common` group: `MethanePlatformInputMouse`, +`MethanePlatformInputControllers` and `MethanePlatformInputActionControllers`. ## Modules From cebacf1ce3400d73d388b5b0eb1d1d1de3098ebb Mon Sep 17 00:00:00 2001 From: Evgeny Gorodetskiy Date: Mon, 30 Nov 2026 22:35:09 +0300 Subject: [PATCH 5/7] Fold Platform Common group into Base and document each platform Continue the Platform modules refactoring: - Common/App moves to Base/AppController, and its target is renamed from MethanePlatformAppCommon to MethanePlatformAppController, since the "Common" group it was named after no longer exists. - Common/Input moves to Base/Input, joining the keyboard module already there: Base/Input/{Keyboard,Mouse,Controllers,ActionControllers}. The three moved targets keep their names, which are linked from other domains. - The Common group is gone. Base now holds every platform-independent implementation, whether or not it has platform counterparts: a module which has them carries a Base target suffix and sits behind an Impl facade, a module which does not has neither. - Each platform group gets a README.md covering its implementation details: Windows (Win32 message loop, deferred WM_ALERT alerts, Shcore vs GetDeviceCaps DPI sources, console stream attachment, Windows-only utility functions), Linux (XCB with an Xlib Display kept for Vulkan, _NET_WM_SYNC_REQUEST resize synchronisation, hand-drawn MessageBox, _NET_WM_ICON), Apple (Objective-C++ conventions and the Methane::MacOS vs Methane::Platform::MacOS namespace gotcha), Apple/MacOS (AppKit delegate split, singleton access, AppViewMetal) and Apple/iOS (shared with tvOS, no keyboard module and what that implies, touch-to-mouse mapping, nativeScale). Platform/README.md, Impl/App/README.md, the tests and tutorial README links and the .codecov.yml component paths are updated accordingly. Verified on Windows with the VS2022-Win64-DX and VS2022-Win64-VK presets (Debug build clean, 493/493 unit tests passing on each). Refs #165 Co-Authored-By: Claude Opus 5 --- .codecov.yml | 1 + Apps/05-Typography/README.md | 2 +- Apps/07-ParallelRendering/README.md | 2 +- Modules/Platform/Apple/MacOS/README.md | 57 ++++++++++++ Modules/Platform/Apple/README.md | 50 ++++++++++ Modules/Platform/Apple/iOS/README.md | 66 +++++++++++++ .../App => Base/AppController}/CMakeLists.txt | 4 +- .../Include/Methane/Platform/AppController.h | 0 .../Methane/Platform/AppController.cpp | 0 Modules/Platform/Base/CMakeLists.txt | 1 + .../Input/ActionControllers/CMakeLists.txt | 2 +- .../Input/KeyboardActionControllerBase.hpp | 0 .../Input/MouseActionControllerBase.hpp | 0 Modules/Platform/Base/Input/CMakeLists.txt | 3 + .../Input/Controllers/CMakeLists.txt | 2 +- .../Methane/Platform/Input/Controller.h | 0 .../Methane/Platform/Input/ControllersPool.h | 0 .../Platform/Input/IActionController.h | 0 .../Methane/Platform/Input/IController.h | 0 .../Methane/Platform/Input/IHelpProvider.h | 0 .../Include/Methane/Platform/Input/State.h | 0 .../Platform/Input/ControllersPool.cpp | 0 .../Sources/Methane/Platform/Input/State.cpp | 0 .../Base/Input/Keyboard/CMakeLists.txt | 2 +- .../Input/Mouse/CMakeLists.txt | 2 +- .../Include/Methane/Platform/Input/Mouse.h | 0 .../Sources/Methane/Platform/Input/Mouse.cpp | 0 Modules/Platform/CMakeLists.txt | 1 - Modules/Platform/Common/CMakeLists.txt | 2 - Modules/Platform/Common/Input/CMakeLists.txt | 3 - Modules/Platform/Impl/App/CMakeLists.txt | 2 +- Modules/Platform/Impl/App/README.md | 6 +- Modules/Platform/Linux/README.md | 60 ++++++++++++ Modules/Platform/README.md | 92 +++++++++---------- Modules/Platform/Windows/README.md | 54 +++++++++++ Tests/Platform/Input/README.md | 12 +-- Tests/Platform/README.md | 2 +- 37 files changed, 357 insertions(+), 71 deletions(-) create mode 100644 Modules/Platform/Apple/MacOS/README.md create mode 100644 Modules/Platform/Apple/README.md create mode 100644 Modules/Platform/Apple/iOS/README.md rename Modules/Platform/{Common/App => Base/AppController}/CMakeLists.txt (93%) rename Modules/Platform/{Common/App => Base/AppController}/Include/Methane/Platform/AppController.h (100%) rename Modules/Platform/{Common/App => Base/AppController}/Sources/Methane/Platform/AppController.cpp (100%) rename Modules/Platform/{Common => Base}/Input/ActionControllers/CMakeLists.txt (95%) rename Modules/Platform/{Common => Base}/Input/ActionControllers/Include/Methane/Platform/Input/KeyboardActionControllerBase.hpp (100%) rename Modules/Platform/{Common => Base}/Input/ActionControllers/Include/Methane/Platform/Input/MouseActionControllerBase.hpp (100%) rename Modules/Platform/{Common => Base}/Input/Controllers/CMakeLists.txt (96%) rename Modules/Platform/{Common => Base}/Input/Controllers/Include/Methane/Platform/Input/Controller.h (100%) rename Modules/Platform/{Common => Base}/Input/Controllers/Include/Methane/Platform/Input/ControllersPool.h (100%) rename Modules/Platform/{Common => Base}/Input/Controllers/Include/Methane/Platform/Input/IActionController.h (100%) rename Modules/Platform/{Common => Base}/Input/Controllers/Include/Methane/Platform/Input/IController.h (100%) rename Modules/Platform/{Common => Base}/Input/Controllers/Include/Methane/Platform/Input/IHelpProvider.h (100%) rename Modules/Platform/{Common => Base}/Input/Controllers/Include/Methane/Platform/Input/State.h (100%) rename Modules/Platform/{Common => Base}/Input/Controllers/Sources/Methane/Platform/Input/ControllersPool.cpp (100%) rename Modules/Platform/{Common => Base}/Input/Controllers/Sources/Methane/Platform/Input/State.cpp (100%) rename Modules/Platform/{Common => Base}/Input/Mouse/CMakeLists.txt (95%) rename Modules/Platform/{Common => Base}/Input/Mouse/Include/Methane/Platform/Input/Mouse.h (100%) rename Modules/Platform/{Common => Base}/Input/Mouse/Sources/Methane/Platform/Input/Mouse.cpp (100%) delete mode 100644 Modules/Platform/Common/CMakeLists.txt delete mode 100644 Modules/Platform/Common/Input/CMakeLists.txt create mode 100644 Modules/Platform/Linux/README.md create mode 100644 Modules/Platform/Windows/README.md diff --git a/.codecov.yml b/.codecov.yml index 321e06ee2..c18181072 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -72,6 +72,7 @@ component_management: paths: - Modules/Platform/*/App/** - Modules/Platform/Apple/*/App/** + - Modules/Platform/*/AppController/** - component_id: graphics-types name: Graphics Types paths: diff --git a/Apps/05-Typography/README.md b/Apps/05-Typography/README.md index 916f498de..141944470 100644 --- a/Apps/05-Typography/README.md +++ b/Apps/05-Typography/README.md @@ -16,7 +16,7 @@ characters and words. Right-to-left and Arabic language character layout is not ## Application Controls Keyboard actions are enabled with [TypographyAppController](TypographyAppController.h) class -derived from [Platform::Input::Keyboard::ActionControllerBase](/Modules/Platform/Common/Input/ActionControllers/Include/Methane/Platform/Input/KeyboardActionControllerBase.hpp): +derived from [Platform::Input::Keyboard::ActionControllerBase](/Modules/Platform/Base/Input/ActionControllers/Include/Methane/Platform/Input/KeyboardActionControllerBase.hpp): | Typography App Action | Keyboard Shortcut | |-----------------------------------------------------------------|-------------------| diff --git a/Apps/07-ParallelRendering/README.md b/Apps/07-ParallelRendering/README.md index e9502a6b4..71e2adadb 100644 --- a/Apps/07-ParallelRendering/README.md +++ b/Apps/07-ParallelRendering/README.md @@ -30,7 +30,7 @@ Tutorial demonstrates the following techniques: ## Application Controls Keyboard actions are enabled with [ParallelRenderingAppController](ParallelRenderingAppController.h) class -derived from [Platform::Input::Keyboard::ActionControllerBase](/Modules/Platform/Common/Input/ActionControllers/Include/Methane/Platform/Input/KeyboardActionControllerBase.hpp): +derived from [Platform::Input::Keyboard::ActionControllerBase](/Modules/Platform/Base/Input/ActionControllers/Include/Methane/Platform/Input/KeyboardActionControllerBase.hpp): | Parallel Rendering App Action | Keyboard Shortcut | |-------------------------------|-------------------| diff --git a/Modules/Platform/Apple/MacOS/README.md b/Modules/Platform/Apple/MacOS/README.md new file mode 100644 index 000000000..c61d6cc8c --- /dev/null +++ b/Modules/Platform/Apple/MacOS/README.md @@ -0,0 +1,57 @@ +# Methane Platform MacOS + +MacOS implementation of the [Platform modules](../../README.md), in namespace +`Methane::Platform::MacOS`, built on **AppKit**. Added to the build by +[Apple/CMakeLists.txt](../CMakeLists.txt) when `APPLE_MACOS` is set, alongside the shared +[Apple](../README.md) modules. + +| Module | CMake Target | Content | +|----------------------------------|-----------------------------------|-----------------------------------------------| +| [App](App) | MethanePlatformAppMacOS | `MacOS::App` AppKit windowed application | +| [AppView](AppView) | MethanePlatformAppViewMacOS | `AppViewMetal` view and `AppEnvironment` | +| [Input/Keyboard](Input/Keyboard) | MethanePlatformInputKeyboardMacOS | `Keyboard::NativeKey` and its key translation | + +Linked frameworks: `AppKit`, `Metal`, `QuartzCore`. + +## App + +[`MacOS::App`](App/Include/Methane/Platform/MacOS/App.hh) derives from [`Base::App`](../../Base/App) +and owns the AppKit object graph, which is split across several Objective-C classes in +[App/Sources](App/Sources/Methane/Platform/MacOS): + +| Class | Role | +|----------------------|--------------------------------------------------------------------------| +| `AppDelegate` | `NSApplicationDelegate`: creates the `NSWindow` and the view controller | +| `WindowDelegate` | `NSWindowDelegate`: window resize, move, focus and close events | +| `AppViewController` | `NSViewController`: drives drawing and input events | + +Because AppKit delegates are constructed by the framework and receive no user pointer, `MacOS::App` +exposes a **singleton** `App::GetInstance()` so the delegates can reach the application instance. + +`METHANE_RENDER_APP` is defined privately for this target and gates the `AppDelegate.hh` import in +the otherwise public `App.hh`, which keeps the delegate out of the installed public header set. + +## AppView + +`AppViewMetal` is an `NSView` backed by a `CAMetalLayer`; `Metal::RenderContext` draws into its +drawables, and `AppEnvironment` carries a `NativeViewController` +(`NSViewController`) rather than a raw window handle. The `MetalAppViewDelegate` +protocol is what lets the RHI layer hand frames back to the view and react to drawable size changes. + +`AppViewMetal.mm` is compiled with `-fobjc-weak` in addition to ARC, as it holds weak references to +its delegate. + +## Input/Keyboard + +`Keyboard::NativeKey` holds the `NSEvent` `keyCode` (`uint16_t`) and `modifierFlags` (`uint64_t`). +Note that MacOS is the **only** Apple platform with a keyboard module — see +[iOS/README.md](../iOS/README.md). + +`Input::Keyboard::OS::g_key_left_ctrl` maps to `Key::LeftSuper` on Apple platforms, so the +Command key takes the role Control plays elsewhere (for example in the `LCtrl/LCmd + Q` shortcut of +[`Platform::AppController`](../../Base/AppController)). + +## Scaling + +`GetContentScalingFactor()` returns `NSWindow.backingScaleFactor` and `GetFontResolutionDpi()` +returns `72 * scaling factor`, since macOS expresses type in points at 72 dpi. diff --git a/Modules/Platform/Apple/README.md b/Modules/Platform/Apple/README.md new file mode 100644 index 000000000..6fd9f0b8e --- /dev/null +++ b/Modules/Platform/Apple/README.md @@ -0,0 +1,50 @@ +# Methane Platform Apple + +Modules shared by all Apple platforms, plus the two platform sub-groups. +This group is added to the build by [Platform/CMakeLists.txt](../CMakeLists.txt) when `APPLE` is set; +[Apple/CMakeLists.txt](CMakeLists.txt) then adds `MacOS` or `iOS` on top of the shared modules, +based on `APPLE_MACOS`. + +| Module / Group | CMake Target | Content | +|--------------------|---------------------------|---------------------------------------------------| +| [Utils](Utils) | MethanePlatformUtilsApple | Utilities and type conversions shared by all Apple platforms | +| [MacOS](MacOS) | *see [MacOS/README.md](MacOS/README.md)* | AppKit application, view and keyboard | +| [iOS](iOS) | *see [iOS/README.md](iOS/README.md)* | UIKit application and view (iOS and tvOS) | + +`APPLE_IOS` and `APPLE_TVOS` are set in [MethaneGlobalOptions.cmake](/CMake/MethaneGlobalOptions.cmake) +and exposed as compile definitions by [MethaneBuildOptions.cmake](/CMake/MethaneBuildOptions.cmake); +tvOS reuses the `iOS` group unchanged. + +## Objective-C++ conventions + +Apple platform code is Objective-C++ and follows the repository conventions: + +- Headers that contain Objective-C constructs use the `.hh` extension, sources use `.mm`. + `.hh` is mapped to Objective-C++ for GitHub language detection in [.gitattributes](/.gitattributes). +- Every Objective-C++ source is compiled with `-fobjc-arc`, and `AppViewMetal.mm` additionally with + `-fobjc-weak`. +- Precompiled headers are disabled for these translation units (`SKIP_PRECOMPILE_HEADERS ON`), since + the shared C++ PCH cannot be reused from an Objective-C++ compilation. +- Public headers guard their Objective-C parts with `#ifdef __OBJC__` and fall back to `void` + aliases, so plain C++ translation units can still include them. + +## Utils + +[Utils](Utils) implements the platform-independent functions declared in +[`Methane/Platform/Utils.h`](../Base/Utils/Include/Methane/Platform/Utils.h) and adds the `NSString` +conversions in [`Types.hh`](Utils/Include/Methane/Platform/Apple/Types.hh). +`Methane/Platform/Apple/Utils.hh` itself declares no Apple-only API. + +`PrintToDebugOutput` writes through `NSLog`, which goes to the *system* log rather than to the +terminal — this is why `--print_debug_messages_to_console` exists; with it, the same messages go to +`std::cout` instead. + +> **Namespace gotcha:** these helpers live in namespace **`Methane::MacOS`** — not +> `Methane::Platform::Apple`, and not `Methane::Platform::MacOS`. That name predates the platform +> grouping and is shared by the iOS build too. Because `Methane::Platform::MacOS` now exists as the +> macOS *application* namespace, an unqualified `MacOS::ConvertToNsString(...)` inside +> `Methane::Platform::MacOS` resolves to the wrong namespace, and in a file with both +> `using namespace Methane;` and `using namespace Methane::Platform;` the name `MacOS` is outright +> ambiguous. Always write `Methane::MacOS::ConvertToNsString` in full. + +Links the `Foundation` framework. diff --git a/Modules/Platform/Apple/iOS/README.md b/Modules/Platform/Apple/iOS/README.md new file mode 100644 index 000000000..f09934b63 --- /dev/null +++ b/Modules/Platform/Apple/iOS/README.md @@ -0,0 +1,66 @@ +# Methane Platform iOS + +iOS **and tvOS** implementation of the [Platform modules](../../README.md), in namespace +`Methane::Platform::iOS`, built on **UIKit**. Added to the build by +[Apple/CMakeLists.txt](../CMakeLists.txt) when `APPLE` is set and `APPLE_MACOS` is not, alongside the +shared [Apple](../README.md) modules. tvOS reuses this group unchanged — `APPLE_IOS` and +`APPLE_TVOS` only differ in the SDK and deployment target chosen by +[MethaneGlobalOptions.cmake](/CMake/MethaneGlobalOptions.cmake). + +| Module | CMake Target | Content | +|--------------------|---------------------------|------------------------------------------| +| [App](App) | MethanePlatformAppIOS | `iOS::App` UIKit application | +| [AppView](AppView) | MethanePlatformAppViewIOS | `AppViewMetal` view and `AppEnvironment` | + +Linked frameworks: `UIKit`, `Metal`, `QuartzCore`. + +## App + +[`iOS::App`](App/Include/Methane/Platform/iOS/App.hh) derives from [`Base::App`](../../Base/App) and, +like the macOS implementation, relies on a **singleton** `App::GetInstance()` so that UIKit-constructed +delegates can reach it. Two Objective-C classes in +[App/Sources](App/Sources/Methane/Platform/iOS): + +| Class | Role | +|---------------------|---------------------------------------------------------------------------| +| `AppDelegate` | `UIApplicationDelegate`: creates the `UIWindow` and the view controller | +| `AppViewController` | `UIViewController`: drives drawing and touch input | + +Alerts are shown with `UIAlertController` instead of the `NSAlert` used on macOS. + +## No keyboard module + +There is deliberately **no `Input/Keyboard` module here**: iOS and tvOS have no native key-event +translation in Methane. Consequently: + +- [`Impl/Input/Keyboard`](../../Impl/Input/Keyboard) links only + [`MethanePlatformInputKeyboardBase`](../../Base/Input/Keyboard) on these platforms, with no + platform target behind it. +- `Keyboard::NativeKey` is left undefined, so `Keyboard::KeyConverter`'s native-key constructor and + its `GetKeyByNativeCode` / `GetModifiersByNativeCode` statics are not available. The + platform-independent parts of `Keyboard::Key`, `Keyboard::State` and the action controllers still + build and link, which is what the shared application and UI code needs. + +## Touch input + +`AppViewController` maps touches onto the platform-independent mouse abstraction by touch count: + +| Touches | Mouse button | +|---------|-----------------------| +| 1 | `Mouse::Button::Left` | +| 2 | `Mouse::Button::Right` | +| 3 | `Mouse::Button::Middle` | + +More than three simultaneous touches are not supported and raise an unexpected-value check. + +## AppView and scaling + +`AppViewMetal` is a `UIView` backed by a `CAMetalLayer`, and `AppEnvironment` carries a +`NativeViewController` (`UIViewController`), mirroring the macOS design. + +`GetContentScalingFactor()` returns `UIScreen.nativeScale` — note this is the *native* scale, not +`UIScreen.scale`, so it reflects the physical panel rather than the logical rendering scale. +`GetFontResolutionDpi()` returns `72 * scaling factor`. + +Applications are always full-screen on these platforms, so `SetFullScreen()` only keeps the base +class bookkeeping in step and changes nothing on screen. diff --git a/Modules/Platform/Common/App/CMakeLists.txt b/Modules/Platform/Base/AppController/CMakeLists.txt similarity index 93% rename from Modules/Platform/Common/App/CMakeLists.txt rename to Modules/Platform/Base/AppController/CMakeLists.txt index 78e88c6f1..1da1026b3 100644 --- a/Modules/Platform/Common/App/CMakeLists.txt +++ b/Modules/Platform/Base/AppController/CMakeLists.txt @@ -1,4 +1,4 @@ -set(TARGET MethanePlatformAppCommon) +set(TARGET MethanePlatformAppController) include(MethaneModules) @@ -43,7 +43,7 @@ source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) set_target_properties(${TARGET} PROPERTIES - FOLDER Modules/Platform/Common + FOLDER Modules/Platform/Base PUBLIC_HEADER "${HEADERS}" ) diff --git a/Modules/Platform/Common/App/Include/Methane/Platform/AppController.h b/Modules/Platform/Base/AppController/Include/Methane/Platform/AppController.h similarity index 100% rename from Modules/Platform/Common/App/Include/Methane/Platform/AppController.h rename to Modules/Platform/Base/AppController/Include/Methane/Platform/AppController.h diff --git a/Modules/Platform/Common/App/Sources/Methane/Platform/AppController.cpp b/Modules/Platform/Base/AppController/Sources/Methane/Platform/AppController.cpp similarity index 100% rename from Modules/Platform/Common/App/Sources/Methane/Platform/AppController.cpp rename to Modules/Platform/Base/AppController/Sources/Methane/Platform/AppController.cpp diff --git a/Modules/Platform/Base/CMakeLists.txt b/Modules/Platform/Base/CMakeLists.txt index ac2613cca..a669895d5 100644 --- a/Modules/Platform/Base/CMakeLists.txt +++ b/Modules/Platform/Base/CMakeLists.txt @@ -1,3 +1,4 @@ add_subdirectory(Utils) add_subdirectory(Input) add_subdirectory(App) +add_subdirectory(AppController) diff --git a/Modules/Platform/Common/Input/ActionControllers/CMakeLists.txt b/Modules/Platform/Base/Input/ActionControllers/CMakeLists.txt similarity index 95% rename from Modules/Platform/Common/Input/ActionControllers/CMakeLists.txt rename to Modules/Platform/Base/Input/ActionControllers/CMakeLists.txt index 7c4723bdc..7679dfef9 100644 --- a/Modules/Platform/Common/Input/ActionControllers/CMakeLists.txt +++ b/Modules/Platform/Base/Input/ActionControllers/CMakeLists.txt @@ -33,7 +33,7 @@ source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS}) set_target_properties(${TARGET} PROPERTIES - FOLDER Modules/Platform/Common/Input + FOLDER Modules/Platform/Base/Input PUBLIC_HEADER "${HEADERS}" ) diff --git a/Modules/Platform/Common/Input/ActionControllers/Include/Methane/Platform/Input/KeyboardActionControllerBase.hpp b/Modules/Platform/Base/Input/ActionControllers/Include/Methane/Platform/Input/KeyboardActionControllerBase.hpp similarity index 100% rename from Modules/Platform/Common/Input/ActionControllers/Include/Methane/Platform/Input/KeyboardActionControllerBase.hpp rename to Modules/Platform/Base/Input/ActionControllers/Include/Methane/Platform/Input/KeyboardActionControllerBase.hpp diff --git a/Modules/Platform/Common/Input/ActionControllers/Include/Methane/Platform/Input/MouseActionControllerBase.hpp b/Modules/Platform/Base/Input/ActionControllers/Include/Methane/Platform/Input/MouseActionControllerBase.hpp similarity index 100% rename from Modules/Platform/Common/Input/ActionControllers/Include/Methane/Platform/Input/MouseActionControllerBase.hpp rename to Modules/Platform/Base/Input/ActionControllers/Include/Methane/Platform/Input/MouseActionControllerBase.hpp diff --git a/Modules/Platform/Base/Input/CMakeLists.txt b/Modules/Platform/Base/Input/CMakeLists.txt index df28aa576..36a26e67b 100644 --- a/Modules/Platform/Base/Input/CMakeLists.txt +++ b/Modules/Platform/Base/Input/CMakeLists.txt @@ -1 +1,4 @@ +add_subdirectory(Mouse) add_subdirectory(Keyboard) +add_subdirectory(Controllers) +add_subdirectory(ActionControllers) diff --git a/Modules/Platform/Common/Input/Controllers/CMakeLists.txt b/Modules/Platform/Base/Input/Controllers/CMakeLists.txt similarity index 96% rename from Modules/Platform/Common/Input/Controllers/CMakeLists.txt rename to Modules/Platform/Base/Input/Controllers/CMakeLists.txt index bec3fd1ae..6044c9a45 100644 --- a/Modules/Platform/Common/Input/Controllers/CMakeLists.txt +++ b/Modules/Platform/Base/Input/Controllers/CMakeLists.txt @@ -48,7 +48,7 @@ source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) set_target_properties(${TARGET} PROPERTIES - FOLDER Modules/Platform/Common/Input + FOLDER Modules/Platform/Base/Input PUBLIC_HEADER "${HEADERS}" ) diff --git a/Modules/Platform/Common/Input/Controllers/Include/Methane/Platform/Input/Controller.h b/Modules/Platform/Base/Input/Controllers/Include/Methane/Platform/Input/Controller.h similarity index 100% rename from Modules/Platform/Common/Input/Controllers/Include/Methane/Platform/Input/Controller.h rename to Modules/Platform/Base/Input/Controllers/Include/Methane/Platform/Input/Controller.h diff --git a/Modules/Platform/Common/Input/Controllers/Include/Methane/Platform/Input/ControllersPool.h b/Modules/Platform/Base/Input/Controllers/Include/Methane/Platform/Input/ControllersPool.h similarity index 100% rename from Modules/Platform/Common/Input/Controllers/Include/Methane/Platform/Input/ControllersPool.h rename to Modules/Platform/Base/Input/Controllers/Include/Methane/Platform/Input/ControllersPool.h diff --git a/Modules/Platform/Common/Input/Controllers/Include/Methane/Platform/Input/IActionController.h b/Modules/Platform/Base/Input/Controllers/Include/Methane/Platform/Input/IActionController.h similarity index 100% rename from Modules/Platform/Common/Input/Controllers/Include/Methane/Platform/Input/IActionController.h rename to Modules/Platform/Base/Input/Controllers/Include/Methane/Platform/Input/IActionController.h diff --git a/Modules/Platform/Common/Input/Controllers/Include/Methane/Platform/Input/IController.h b/Modules/Platform/Base/Input/Controllers/Include/Methane/Platform/Input/IController.h similarity index 100% rename from Modules/Platform/Common/Input/Controllers/Include/Methane/Platform/Input/IController.h rename to Modules/Platform/Base/Input/Controllers/Include/Methane/Platform/Input/IController.h diff --git a/Modules/Platform/Common/Input/Controllers/Include/Methane/Platform/Input/IHelpProvider.h b/Modules/Platform/Base/Input/Controllers/Include/Methane/Platform/Input/IHelpProvider.h similarity index 100% rename from Modules/Platform/Common/Input/Controllers/Include/Methane/Platform/Input/IHelpProvider.h rename to Modules/Platform/Base/Input/Controllers/Include/Methane/Platform/Input/IHelpProvider.h diff --git a/Modules/Platform/Common/Input/Controllers/Include/Methane/Platform/Input/State.h b/Modules/Platform/Base/Input/Controllers/Include/Methane/Platform/Input/State.h similarity index 100% rename from Modules/Platform/Common/Input/Controllers/Include/Methane/Platform/Input/State.h rename to Modules/Platform/Base/Input/Controllers/Include/Methane/Platform/Input/State.h diff --git a/Modules/Platform/Common/Input/Controllers/Sources/Methane/Platform/Input/ControllersPool.cpp b/Modules/Platform/Base/Input/Controllers/Sources/Methane/Platform/Input/ControllersPool.cpp similarity index 100% rename from Modules/Platform/Common/Input/Controllers/Sources/Methane/Platform/Input/ControllersPool.cpp rename to Modules/Platform/Base/Input/Controllers/Sources/Methane/Platform/Input/ControllersPool.cpp diff --git a/Modules/Platform/Common/Input/Controllers/Sources/Methane/Platform/Input/State.cpp b/Modules/Platform/Base/Input/Controllers/Sources/Methane/Platform/Input/State.cpp similarity index 100% rename from Modules/Platform/Common/Input/Controllers/Sources/Methane/Platform/Input/State.cpp rename to Modules/Platform/Base/Input/Controllers/Sources/Methane/Platform/Input/State.cpp diff --git a/Modules/Platform/Base/Input/Keyboard/CMakeLists.txt b/Modules/Platform/Base/Input/Keyboard/CMakeLists.txt index a848c15f7..faacc05d9 100644 --- a/Modules/Platform/Base/Input/Keyboard/CMakeLists.txt +++ b/Modules/Platform/Base/Input/Keyboard/CMakeLists.txt @@ -44,7 +44,7 @@ source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) set_target_properties(${TARGET} PROPERTIES - FOLDER Modules/Platform/Base + FOLDER Modules/Platform/Base/Input PUBLIC_HEADER "${HEADERS}" ) diff --git a/Modules/Platform/Common/Input/Mouse/CMakeLists.txt b/Modules/Platform/Base/Input/Mouse/CMakeLists.txt similarity index 95% rename from Modules/Platform/Common/Input/Mouse/CMakeLists.txt rename to Modules/Platform/Base/Input/Mouse/CMakeLists.txt index 98720b9d0..a632735ec 100644 --- a/Modules/Platform/Common/Input/Mouse/CMakeLists.txt +++ b/Modules/Platform/Base/Input/Mouse/CMakeLists.txt @@ -36,7 +36,7 @@ source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) set_target_properties(${TARGET} PROPERTIES - FOLDER Modules/Platform/Common/Input + FOLDER Modules/Platform/Base/Input PUBLIC_HEADER "${HEADERS}" ) diff --git a/Modules/Platform/Common/Input/Mouse/Include/Methane/Platform/Input/Mouse.h b/Modules/Platform/Base/Input/Mouse/Include/Methane/Platform/Input/Mouse.h similarity index 100% rename from Modules/Platform/Common/Input/Mouse/Include/Methane/Platform/Input/Mouse.h rename to Modules/Platform/Base/Input/Mouse/Include/Methane/Platform/Input/Mouse.h diff --git a/Modules/Platform/Common/Input/Mouse/Sources/Methane/Platform/Input/Mouse.cpp b/Modules/Platform/Base/Input/Mouse/Sources/Methane/Platform/Input/Mouse.cpp similarity index 100% rename from Modules/Platform/Common/Input/Mouse/Sources/Methane/Platform/Input/Mouse.cpp rename to Modules/Platform/Base/Input/Mouse/Sources/Methane/Platform/Input/Mouse.cpp diff --git a/Modules/Platform/CMakeLists.txt b/Modules/Platform/CMakeLists.txt index e457ac28c..6b7813dc4 100644 --- a/Modules/Platform/CMakeLists.txt +++ b/Modules/Platform/CMakeLists.txt @@ -1,7 +1,6 @@ # Platform-independent module layers: add_subdirectory(Interfaces) add_subdirectory(Base) -add_subdirectory(Common) # Platform-specific module layer (only one is added depending on the target platform): if(WIN32) diff --git a/Modules/Platform/Common/CMakeLists.txt b/Modules/Platform/Common/CMakeLists.txt deleted file mode 100644 index c4c670218..000000000 --- a/Modules/Platform/Common/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_subdirectory(Input) -add_subdirectory(App) diff --git a/Modules/Platform/Common/Input/CMakeLists.txt b/Modules/Platform/Common/Input/CMakeLists.txt deleted file mode 100644 index 8e76322ee..000000000 --- a/Modules/Platform/Common/Input/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -add_subdirectory(Mouse) -add_subdirectory(Controllers) -add_subdirectory(ActionControllers) diff --git a/Modules/Platform/Impl/App/CMakeLists.txt b/Modules/Platform/Impl/App/CMakeLists.txt index d68e191ed..e95932fd6 100644 --- a/Modules/Platform/Impl/App/CMakeLists.txt +++ b/Modules/Platform/Impl/App/CMakeLists.txt @@ -33,7 +33,7 @@ target_include_directories(${TARGET} target_link_libraries(${TARGET} INTERFACE ${PLATFORM_APP_TARGET} - MethanePlatformAppCommon + MethanePlatformAppController ) source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS}) diff --git a/Modules/Platform/Impl/App/README.md b/Modules/Platform/Impl/App/README.md index 6340505b9..933516f93 100644 --- a/Modules/Platform/Impl/App/README.md +++ b/Modules/Platform/Impl/App/README.md @@ -7,7 +7,7 @@ Platform application modules are grouped by platform support, similar to [Graphi ``` Interfaces/App ──> Base/App ──> { Windows | Linux | Apple/MacOS | Apple/iOS }/App ──> Impl/App - Common/App ──┘ + Base/AppController ──┘ ``` | Module | CMake Target | Description | @@ -18,7 +18,7 @@ Interfaces/App ──> Base/App ──> { Windows | Linux | Apple/MacOS | Apple/ | [Linux/App](../../Linux/App) | MethanePlatformAppLinux | `Platform::Linux::App` implementation | | [Apple/MacOS/App](../../Apple/MacOS/App) | MethanePlatformAppMacOS | `Platform::MacOS::App` implementation | | [Apple/iOS/App](../../Apple/iOS/App) | MethanePlatformAppIOS | `Platform::iOS::App` implementation | -| [Common/App](../../Common/App) | MethanePlatformAppCommon | `Platform::AppController` implementation | +| [Base/AppController](../../Base/AppController) | MethanePlatformAppController | `Platform::AppController` implementation | | [Impl/App](.) | MethanePlatformApp | `Platform::App` final implementation alias | ## Platform Application @@ -78,7 +78,7 @@ validation errors and warnings, to the console output instead of the platform de ### Platform::AppController -[Methane/Platform/AppController.h](../../Common/App/Include/Methane/Platform/AppController.h) implements +[Methane/Platform/AppController.h](../../Base/AppController/Include/Methane/Platform/AppController.h) implements the following platform-independent actions: | Action | Keyboard Shortcut | diff --git a/Modules/Platform/Linux/README.md b/Modules/Platform/Linux/README.md new file mode 100644 index 000000000..301bf6137 --- /dev/null +++ b/Modules/Platform/Linux/README.md @@ -0,0 +1,60 @@ +# Methane Platform Linux + +Linux implementation of the [Platform modules](../README.md), in namespace `Methane::Platform::Linux`. +This group is added to the build by [Platform/CMakeLists.txt](../CMakeLists.txt) when the target is +neither Windows nor Apple. Linux always uses the Vulkan RHI backend. + +| Module | CMake Target | Content | +|----------------------------------|-----------------------------------|-------------------------------------------------| +| [App](App) | MethanePlatformAppLinux | `Linux::App` XCB windowed application | +| [AppView](AppView) | MethanePlatformAppViewLinux | `AppEnvironment` with the XCB/X11 handles | +| [Input/Keyboard](Input/Keyboard) | MethanePlatformInputKeyboardLinux | `Keyboard::NativeKey` and its key translation | +| [Utils](Utils) | MethanePlatformUtilsLinux | Linux implementation of the platform utilities | + +## Windowing with XCB + +The window is created and driven with **XCB** rather than Xlib, because XCB's explicit request/reply +model suits the single-threaded render loop better. An Xlib `Display*` is nevertheless kept in +`AppEnvironment` alongside the XCB handles, since some Vulkan loaders and drivers still expect it. + +`AppEnvironment` holds the `xcb_connection_t*`, the `xcb_window_t`, the `_XDisplay*`, the +`xcb_screen_t*` and the primary screen rectangle. The primary monitor geometry is queried through +`xcb_randr`, so the window can be sized as a ratio of the actual monitor rather than of the whole +X screen, which may span several monitors. + +Linked X libraries: `X11::X11`, `X11::X11_xcb`, `X11::xcb`, `X11::xcb_randr`, `X11::xcb_sync`. + +## App implementation details + +[`Linux::App`](App/Include/Methane/Platform/Linux/App.h) derives from [`Base::App`](../Base/App) and +runs its own XCB event loop. Points worth knowing: + +- **`XcbUtils`** ([header](App/Sources/Methane/Platform/Linux/XcbUtils.h)) collects the low-level + helpers: interning atoms, setting string and atom window properties, filling `WMSizeHints`, and + translating XCB key/button/motion events into Methane input events. +- **Resize synchronisation** uses the `_NET_WM_SYNC_REQUEST` protocol with an `xcb_sync` counter, so + the compositor waits for the application to finish a frame before showing the resized window. This + is what keeps live resizing from tearing or lagging behind the pointer. +- **`MessageBox`** ([header](App/Sources/Methane/Platform/Linux/MessageBox.h)) is drawn by hand with + XCB and runs a nested event loop. X11 has no native message dialog, so alerts cannot be delegated + to the system the way they are on Windows and macOS. +- **Window icon** is published as `_NET_WM_ICON` from images decoded with STB, which is why the + module links `STB`. +- Full-screen switching is a `_NET_WM_STATE` / `_NET_WM_STATE_FULLSCREEN` client message to the + window manager, so the result depends on the WM honouring it. + +## Input/Keyboard + +`Keyboard::NativeKey` holds an X11 `KeySym` plus the event state flags. `Keyboard::KeyConverter` +maps keysyms (`X11/keysym.h`) to platform-independent `Keyboard::Key` values. The module needs the +`xcb` and `X11` include paths for this translation. + +## Utils + +`Methane/Platform/Linux/Utils.h` declares no Linux-only API — unlike Windows, this group only +implements the platform-independent functions declared in +[`Methane/Platform/Utils.h`](../Base/Utils/Include/Methane/Platform/Utils.h): + +- `GetExecutableDir()` / `GetExecutableFileName()` resolve `/proc/self/exe` with `readlink`. +- `PrintToDebugOutput` has no platform debug channel to write to and is effectively a no-op; use + `--print_debug_messages_to_console` to see debug output on Linux. diff --git a/Modules/Platform/README.md b/Modules/Platform/README.md index 2125bf54d..82013ae20 100644 --- a/Modules/Platform/README.md +++ b/Modules/Platform/README.md @@ -4,27 +4,26 @@ Code of these modules is located in `Methane::Platform` namespace. Platform modules are grouped by platform support, similar to [Graphics RHI](../Graphics/RHI) modules: -| Group | Namespace | Content | -|------------------------------|------------------------------|-----------------------------------------------------------------| -| [Interfaces](Interfaces) | `Methane::Platform` | Public interfaces and settings structures with no implementation | -| [Base](Base) | `Methane::Platform::Base` | Platform-independent base implementations used by all platforms | -| [Common](Common) | `Methane::Platform` | Fully platform-independent implementations | -| [Windows](Windows) | `Methane::Platform::Windows` | Windows-specific implementations | -| [Linux](Linux) | `Methane::Platform::Linux` | Linux-specific implementations | -| [Apple](Apple) | `Methane::Platform::Apple` | Implementations shared by all Apple platforms | -| [Apple/MacOS](Apple/MacOS) | `Methane::Platform::MacOS` | MacOS-specific implementations | -| [Apple/iOS](Apple/iOS) | `Methane::Platform::iOS` | iOS / tvOS-specific implementations | -| [Impl](Impl) | `Methane::Platform` | Final implementation modules binding the groups above together | +| Group | Namespace | Content | +|-----------------------------------------|------------------------------|-----------------------------------------------------------------| +| [Interfaces](Interfaces) | `Methane::Platform` | Public interfaces and settings structures with no implementation | +| [Base](Base) | `Methane::Platform[::Base]` | All platform-independent implementations | +| [Windows](Windows/README.md) | `Methane::Platform::Windows` | Windows-specific implementations | +| [Linux](Linux/README.md) | `Methane::Platform::Linux` | Linux-specific implementations | +| [Apple](Apple/README.md) | `Methane::MacOS` | Implementations shared by all Apple platforms | +| [Apple/MacOS](Apple/MacOS/README.md) | `Methane::Platform::MacOS` | MacOS-specific implementations | +| [Apple/iOS](Apple/iOS/README.md) | `Methane::Platform::iOS` | iOS / tvOS-specific implementations | +| [Impl](Impl) | `Methane::Platform` | Final implementation modules binding the groups above together | Exactly one platform group is added to the build by [CMakeLists.txt](CMakeLists.txt), chosen by the target platform; on Apple platforms [Apple/CMakeLists.txt](Apple/CMakeLists.txt) additionally picks `MacOS` or `iOS` on top of the -shared `Apple` modules. +shared `Apple` modules. Each platform group has its own README with the details of that implementation. -Where a module has an `Impl` facade target, other domains link that facade rather than the `Base` or -platform targets behind it: `MethanePlatformApp`, `MethanePlatformAppView`, -`MethanePlatformInputKeyboard` and `MethanePlatformUtils`. Modules which are fully platform-independent -have no facade and are linked directly from the `Common` group: `MethanePlatformInputMouse`, -`MethanePlatformInputControllers` and `MethanePlatformInputActionControllers`. +Within `Base`, a module which has platform counterparts carries a `Base` target suffix and sits behind an +`Impl` facade that other domains link instead of it: `MethanePlatformApp`, `MethanePlatformAppView`, +`MethanePlatformInputKeyboard` and `MethanePlatformUtils`. A module which is fully platform-independent has +no counterpart, no suffix and no facade, and is linked directly: `MethanePlatformAppController`, +`MethanePlatformInputMouse`, `MethanePlatformInputControllers` and `MethanePlatformInputActionControllers`. ## Modules @@ -33,16 +32,16 @@ have no facade and are linked directly from the `Common` group: `MethanePlatform Application platform-abstraction class and platform-specific implementations — see [Platform App description](Impl/App/README.md) for details. -| Module | CMake Target | -|------------------------------------------|-----------------------------| -| [Interfaces/App](Interfaces/App) | MethanePlatformAppInterface | -| [Base/App](Base/App) | MethanePlatformAppBase | -| [Common/App](Common/App) | MethanePlatformAppCommon | -| [Windows/App](Windows/App) | MethanePlatformAppWindows | -| [Linux/App](Linux/App) | MethanePlatformAppLinux | -| [Apple/MacOS/App](Apple/MacOS/App) | MethanePlatformAppMacOS | -| [Apple/iOS/App](Apple/iOS/App) | MethanePlatformAppIOS | -| [Impl/App](Impl/App) | MethanePlatformApp | +| Module | CMake Target | +|------------------------------------------|------------------------------| +| [Interfaces/App](Interfaces/App) | MethanePlatformAppInterface | +| [Base/App](Base/App) | MethanePlatformAppBase | +| [Base/AppController](Base/AppController) | MethanePlatformAppController | +| [Windows/App](Windows/App) | MethanePlatformAppWindows | +| [Linux/App](Linux/App) | MethanePlatformAppLinux | +| [Apple/MacOS/App](Apple/MacOS/App) | MethanePlatformAppMacOS | +| [Apple/iOS/App](Apple/iOS/App) | MethanePlatformAppIOS | +| [Impl/App](Impl/App) | MethanePlatformApp | ### AppView @@ -60,16 +59,16 @@ Application view and environment platform-abstraction classes. Application input with mouse and keyboard and platform-specific handling implementations. -| Module | CMake Target | -|-----------------------------------------------------------------|---------------------------------------| -| [Base/Input/Keyboard](Base/Input/Keyboard) | MethanePlatformInputKeyboardBase | -| [Windows/Input/Keyboard](Windows/Input/Keyboard) | MethanePlatformInputKeyboardWindows | -| [Linux/Input/Keyboard](Linux/Input/Keyboard) | MethanePlatformInputKeyboardLinux | -| [Apple/MacOS/Input/Keyboard](Apple/MacOS/Input/Keyboard) | MethanePlatformInputKeyboardMacOS | -| [Impl/Input/Keyboard](Impl/Input/Keyboard) | MethanePlatformInputKeyboard | -| [Common/Input/Mouse](Common/Input/Mouse) | MethanePlatformInputMouse | -| [Common/Input/Controllers](Common/Input/Controllers) | MethanePlatformInputControllers | -| [Common/Input/ActionControllers](Common/Input/ActionControllers) | MethanePlatformInputActionControllers | +| Module | CMake Target | +|---------------------------------------------------------------------|---------------------------------------| +| [Base/Input/Keyboard](Base/Input/Keyboard) | MethanePlatformInputKeyboardBase | +| [Windows/Input/Keyboard](Windows/Input/Keyboard) | MethanePlatformInputKeyboardWindows | +| [Linux/Input/Keyboard](Linux/Input/Keyboard) | MethanePlatformInputKeyboardLinux | +| [Apple/MacOS/Input/Keyboard](Apple/MacOS/Input/Keyboard) | MethanePlatformInputKeyboardMacOS | +| [Impl/Input/Keyboard](Impl/Input/Keyboard) | MethanePlatformInputKeyboard | +| [Base/Input/Mouse](Base/Input/Mouse) | MethanePlatformInputMouse | +| [Base/Input/Controllers](Base/Input/Controllers) | MethanePlatformInputControllers | +| [Base/Input/ActionControllers](Base/Input/ActionControllers) | MethanePlatformInputActionControllers | The platform-specific `Keyboard::NativeKey` structure is defined in the `/Keyboard.h>` header of the platform group, while the @@ -91,6 +90,7 @@ Platform utilities. Platform-independent functions are declared in `` of the `Base` group, while platform-specific ones are declared in `/Utils.h>` of the platform group. +Only Windows actually adds such functions; see the per-platform READMEs. ## Intra-Domain Modules Dependencies @@ -108,9 +108,9 @@ graph TD; key_base([Base/Input/Keyboard]) key_os([Platform/Input/Keyboard]) key_impl([Impl/Input/Keyboard]) - mouse([Common/Input/Mouse]) - cont([Common/Input/Controllers]) - action([Common/Input/ActionControllers]) + mouse([Base/Input/Mouse]) + cont([Base/Input/Controllers]) + action([Base/Input/ActionControllers]) end subgraph AppView @@ -122,7 +122,7 @@ graph TD; app_iface([Interfaces/App]) app_base([Base/App]) app_os([Platform/App]) - app_common([Common/App]) + app_ctrl([Base/AppController]) app_impl([Impl/App]) end @@ -146,9 +146,9 @@ graph TD; view_impl-->app_base utils_impl-->app_base app_base-->app_os - app_base-->app_common + app_base-->app_ctrl app_os-->app_impl - app_common-->app_impl + app_ctrl-->app_impl ``` ## Cross-Domain Modules Dependencies @@ -163,9 +163,9 @@ graph TD; subgraph Platform pal_util([Impl/Utils]) pal_key([Impl/Input/Keyboard]) - pal_mouse([Common/Input/Mouse]) - pal_cont([Common/Input/Controllers]) - pal_action([Common/Input/ActionControllers]) + pal_mouse([Base/Input/Mouse]) + pal_cont([Base/Input/Controllers]) + pal_action([Base/Input/ActionControllers]) pal_view([Impl/AppView]) pal_app([Impl/App]) end diff --git a/Modules/Platform/Windows/README.md b/Modules/Platform/Windows/README.md new file mode 100644 index 000000000..b17e15029 --- /dev/null +++ b/Modules/Platform/Windows/README.md @@ -0,0 +1,54 @@ +# Methane Platform Windows + +Windows implementation of the [Platform modules](../README.md), in namespace `Methane::Platform::Windows`. +This group is added to the build by [Platform/CMakeLists.txt](../CMakeLists.txt) when `WIN32` is set. + +| Module | CMake Target | Content | +|--------------------------------------------------|-------------------------------------|-----------------------------------------------------| +| [App](App) | MethanePlatformAppWindows | `Windows::App` Win32 windowed application | +| [AppView](AppView) | MethanePlatformAppViewWindows | `AppEnvironment` with the native window handle | +| [Input/Keyboard](Input/Keyboard) | MethanePlatformInputKeyboardWindows | `Keyboard::NativeKey` and its key translation | +| [Utils](Utils) | MethanePlatformUtilsWindows | Windows-specific utility functions | + +## App + +[`Windows::App`](App/Include/Methane/Platform/Windows/App.h) derives from +[`Base::App`](../Base/App) and drives a classic Win32 window: + +- The window is registered under the `MethaneWindowClass` class name and takes its icon from the + `IDI_APP_ICON` resource embedded by [MethaneResources.cmake](/CMake/MethaneResources.cmake). +- `WindowProc` is a static callback, as Win32 requires; it recovers the `App` instance from the + window's `GWLP_USERDATA` slot and forwards each message to the matching `OnWindow*` method. +- Alerts are deferred through a custom `WM_ALERT` (`WM_USER + 1`) message rather than shown from + inside a message handler, which would otherwise re-enter the message loop from an unexpected state. +- Full-screen switching saves the window rectangle and style, then restores them when leaving. +- `ConsoleStreams` attaches `stdout`/`stderr` to the parent console. Methane applications are built + as GUI-subsystem executables, so without this the `--print_debug_messages_to_console` output would + go nowhere when the application is started from a terminal. + +DPI handling uses two different sources: `GetContentScalingFactor()` asks `Shcore` for +`GetScaleFactorForMonitor` of the monitor the window is on, while `GetFontResolutionDpi()` reads +`LOGPIXELSY` through `GetDeviceCaps`. The module therefore links the `Shcore` library. + +## AppView + +`AppEnvironment` carries a single `HWND window_handle`, which the DirectX and Vulkan RHI backends use +to create a swap chain or a `VkSurfaceKHR` respectively. + +## Input/Keyboard + +`Keyboard::NativeKey` holds the raw `WPARAM` and `LPARAM` of a `WM_KEYDOWN` / `WM_KEYUP` / +`WM_SYSKEYDOWN` / `WM_SYSKEYUP` message, which `Keyboard::KeyConverter` turns into a +platform-independent `Keyboard::Key` and modifier mask. Extended-key and left/right modifier +disambiguation is done from the `LPARAM` bits. + +## Utils + +Besides the platform-independent functions declared in +[`Methane/Platform/Utils.h`](../Base/Utils/Include/Methane/Platform/Utils.h) — where +`PrintToDebugOutput` maps to `OutputDebugString` — this module declares two Windows-only functions in +[`Methane/Platform/Windows/Utils.h`](Utils/Include/Methane/Platform/Windows/Utils.h): + +- `GetDesktopResolution(width, height)` — used to size the main window from a ratio of the desktop. +- `IsDeveloperModeEnabled()` — read from the registry; the DirectX backend requires Developer Mode to + call `ID3D12Device::SetStablePowerState`, which it does only in GPU-instrumented builds. diff --git a/Tests/Platform/Input/README.md b/Tests/Platform/Input/README.md index 1e3748607..57f1c5d46 100644 --- a/Tests/Platform/Input/README.md +++ b/Tests/Platform/Input/README.md @@ -2,10 +2,10 @@ | Type Class | Unit Test | |-----------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------| -| [Platform::Input::Mouse](/Modules/Platform/Common/Input/Mouse/Include/Methane/Platform/Input/Mouse.h) | :white_check_mark: [MouseTest](MouseTest.cpp) | -| [Platform::Input::Mouse::ActionControllerBase](/Modules/Platform/Common/Input/ActionControllers/Include/Methane/Platform/Input/KeyboardActionControllerBase.hpp) | :warning: not covered yet | +| [Platform::Input::Mouse](/Modules/Platform/Base/Input/Mouse/Include/Methane/Platform/Input/Mouse.h) | :white_check_mark: [MouseTest](MouseTest.cpp) | +| [Platform::Input::Mouse::ActionControllerBase](/Modules/Platform/Base/Input/ActionControllers/Include/Methane/Platform/Input/KeyboardActionControllerBase.hpp) | :warning: not covered yet | | [Platform::Input::Keyboard](/Modules/Platform/Base/Input/Keyboard/Include/Methane/Platform/Input/Keyboard.h) | :white_check_mark: [KeyboardTest](KeyboardTest.cpp) | -| [Platform::Input::Keyboard::ActionControllerBase](/Modules/Platform/Common/Input/ActionControllers/Include/Methane/Platform/Input/MouseActionControllerBase.hpp) | :warning: not covered yet | -| [Platform::Input::Controller](/Modules/Platform/Common/Input/Controllers/Include/Methane/Platform/Input/Controller.h) | :warning: not covered yet | -| [Platform::Input::ControllersPool](/Modules/Platform/Common/Input/Controllers/Include/Methane/Platform/Input/ControllersPool.h) | :warning: not covered yet | -| [Platform::Input::State](/Modules/Platform/Common/Input/Controllers/Include/Methane/Platform/Input/State.h) | :warning: not covered yet | +| [Platform::Input::Keyboard::ActionControllerBase](/Modules/Platform/Base/Input/ActionControllers/Include/Methane/Platform/Input/MouseActionControllerBase.hpp) | :warning: not covered yet | +| [Platform::Input::Controller](/Modules/Platform/Base/Input/Controllers/Include/Methane/Platform/Input/Controller.h) | :warning: not covered yet | +| [Platform::Input::ControllersPool](/Modules/Platform/Base/Input/Controllers/Include/Methane/Platform/Input/ControllersPool.h) | :warning: not covered yet | +| [Platform::Input::State](/Modules/Platform/Base/Input/Controllers/Include/Methane/Platform/Input/State.h) | :warning: not covered yet | diff --git a/Tests/Platform/README.md b/Tests/Platform/README.md index d11499e10..76bd51bd6 100644 --- a/Tests/Platform/README.md +++ b/Tests/Platform/README.md @@ -4,5 +4,5 @@ |----------------------------------------------------|-----------------------------------------| | [Platform/App](/Modules/Platform/Impl/App) | :warning: not covered yet | | [Platform/AppView](/Modules/Platform/Impl/AppView) | :warning: not covered yet | -| [Platform/Input](/Modules/Platform/Common/Input) | :white_check_mark: [Input](Input) tests | +| [Platform/Input](/Modules/Platform/Base/Input) | :white_check_mark: [Input](Input) tests | | [Platform/Utils](/Modules/Platform/Impl/Utils) | :warning: not covered yet | From cc2f1792a4d5c703ec69a4748aef104e9020e710 Mon Sep 17 00:00:00 2001 From: Evgeny Gorodetskiy Date: Tue, 1 Dec 2026 22:57:36 +0300 Subject: [PATCH 6/7] Address review feedback on Platform modules refactoring - Apple utilities move from namespace Methane::MacOS to Methane::Platform::Apple, matching their directory. The old name clashed with the Methane::Platform::MacOS application namespace introduced by this refactoring, which is what forced the fully qualified call sites earlier in this branch. Updated all 26 call sites in the Metal RHI backend (now Platform::Apple::Convert*) and the Apple platform app sources (now Apple::Convert*). Stale "MacOS platform" FILE comments in Types.hh and Utils.hh corrected to Apple. - With the clash gone, Methane::Platform::MacOS::App shortens back to MacOS::App in AppDelegate.mm and WindowDelegate.mm. - The alert style converters in MacOS and iOS App.mm now use "using enum Base::App::Message::Type" and short case labels, as the Windows implementation already did. - Restored column alignment broken by the class renames, in the iOS AppDelegate.mm declaration block and in the ivar blocks of WindowDelegate.mm and both AppViewController.mm files. - Platform modules no longer derive their paths from the host platform via get_module_dirs: every path is now the explicit value for that module's own platform, which also makes include(MethaneModules) and get_module_dirs unnecessary in all 14 of them. Install destinations likewise spell out include/Methane/Platform[/Input]/. - Added Base/README.md describing the Base layer: the two kinds of module it holds, why only App needs a nested Base namespace, the forward declared NativeKey contract and where the KeyConverter platform statics live, and why Base/Utils deliberately links with unresolved symbols. Platform/README.md and Apple/README.md updated for the new namespace. Verified on Windows with the VS2022-Win64-DX and VS2022-Win64-VK presets (Debug build clean, 493/493 unit tests passing on each). The Metal and Apple changes cannot be compiled on Windows and are left to CI. Refs #165 Co-Authored-By: Claude Opus 5 --- .../Methane/Graphics/Metal/CommandList.hpp | 2 +- .../Methane/Graphics/Metal/Context.hpp | 2 +- .../Graphics/Metal/RenderContextAppView.hh | 2 +- .../Sources/Methane/Graphics/Metal/Buffer.mm | 2 +- .../Graphics/Metal/CommandListDebugGroup.mm | 2 +- .../Methane/Graphics/Metal/CommandQueue.mm | 2 +- .../Methane/Graphics/Metal/ComputeState.mm | 4 +- .../Methane/Graphics/Metal/DebugMessages.mm | 2 +- .../Sources/Methane/Graphics/Metal/Device.mm | 2 +- .../Sources/Methane/Graphics/Metal/Fence.mm | 2 +- .../Sources/Methane/Graphics/Metal/Program.mm | 4 +- .../Methane/Graphics/Metal/ProgramLibrary.mm | 4 +- .../Methane/Graphics/Metal/RenderContext.mm | 6 +- .../Methane/Graphics/Metal/RenderState.mm | 4 +- .../Sources/Methane/Graphics/Metal/Sampler.mm | 2 +- .../Sources/Methane/Graphics/Metal/Shader.mm | 10 +-- .../Sources/Methane/Graphics/Metal/Texture.mm | 2 +- .../Platform/Apple/MacOS/App/CMakeLists.txt | 24 +++--- .../App/Sources/Methane/Platform/MacOS/App.mm | 13 +-- .../Methane/Platform/MacOS/AppDelegate.mm | 8 +- .../Platform/MacOS/AppViewController.mm | 8 +- .../Methane/Platform/MacOS/WindowDelegate.mm | 4 +- .../Apple/MacOS/AppView/CMakeLists.txt | 12 +-- .../Apple/MacOS/Input/Keyboard/CMakeLists.txt | 10 +-- Modules/Platform/Apple/README.md | 14 ++-- Modules/Platform/Apple/Utils/CMakeLists.txt | 12 +-- .../Include/Methane/Platform/Apple/Types.hh | 8 +- .../Include/Methane/Platform/Apple/Utils.hh | 4 +- Modules/Platform/Apple/iOS/App/CMakeLists.txt | 20 ++--- .../App/Sources/Methane/Platform/iOS/App.mm | 11 +-- .../Methane/Platform/iOS/AppDelegate.mm | 2 +- .../Methane/Platform/iOS/AppViewController.mm | 6 +- .../Platform/Apple/iOS/AppView/CMakeLists.txt | 12 +-- Modules/Platform/Base/README.md | 79 +++++++++++++++++++ Modules/Platform/Linux/App/CMakeLists.txt | 20 ++--- Modules/Platform/Linux/AppView/CMakeLists.txt | 8 +- .../Linux/Input/Keyboard/CMakeLists.txt | 10 +-- Modules/Platform/Linux/Utils/CMakeLists.txt | 10 +-- Modules/Platform/README.md | 4 +- Modules/Platform/Windows/App/CMakeLists.txt | 16 ++-- .../Platform/Windows/AppView/CMakeLists.txt | 8 +- .../Windows/Input/Keyboard/CMakeLists.txt | 10 +-- Modules/Platform/Windows/Utils/CMakeLists.txt | 10 +-- 43 files changed, 211 insertions(+), 186 deletions(-) create mode 100644 Modules/Platform/Base/README.md diff --git a/Modules/Graphics/RHI/Metal/Include/Methane/Graphics/Metal/CommandList.hpp b/Modules/Graphics/RHI/Metal/Include/Methane/Graphics/Metal/CommandList.hpp index 4a2c18a9c..3c74c6740 100644 --- a/Modules/Graphics/RHI/Metal/Include/Methane/Graphics/Metal/CommandList.hpp +++ b/Modules/Graphics/RHI/Metal/Include/Methane/Graphics/Metal/CommandList.hpp @@ -151,7 +151,7 @@ class CommandList : public CommandListBaseT if (!CommandListBaseT::SetName(name)) return false; - m_ns_name = MacOS::ConvertToNsString(name); + m_ns_name = Platform::Apple::ConvertToNsString(name); if (m_mtl_cmd_encoder != nil) { diff --git a/Modules/Graphics/RHI/Metal/Include/Methane/Graphics/Metal/Context.hpp b/Modules/Graphics/RHI/Metal/Include/Methane/Graphics/Metal/Context.hpp index 2e28328e9..9c19dff42 100644 --- a/Modules/Graphics/RHI/Metal/Include/Methane/Graphics/Metal/Context.hpp +++ b/Modules/Graphics/RHI/Metal/Include/Methane/Graphics/Metal/Context.hpp @@ -138,7 +138,7 @@ class Context if (!Base::Context::SetName(name)) return false; - m_ns_name = MacOS::ConvertToNsString(name); + m_ns_name = Platform::Apple::ConvertToNsString(name); return true; } diff --git a/Modules/Graphics/RHI/Metal/Include/Methane/Graphics/Metal/RenderContextAppView.hh b/Modules/Graphics/RHI/Metal/Include/Methane/Graphics/Metal/RenderContextAppView.hh index 32a8c2fb9..7f7e25374 100644 --- a/Modules/Graphics/RHI/Metal/Include/Methane/Graphics/Metal/RenderContextAppView.hh +++ b/Modules/Graphics/RHI/Metal/Include/Methane/Graphics/Metal/RenderContextAppView.hh @@ -46,7 +46,7 @@ inline AppViewMetal* CreateRenderContextAppView(const Platform::AppEnvironment& appWindow: env.ns_app_delegate.window pixelFormat: TypeConverter::DataFormatToMetalPixelType(settings.color_format) drawableCount: settings.frame_buffers_count - vsyncEnabled: MacOS::ConvertToNsBool(settings.vsync_enabled) + vsyncEnabled: Platform::Apple::ConvertToNsBool(settings.vsync_enabled) #ifdef APPLE_MACOS unsyncRefreshInterval: 1.0 / settings.unsync_max_fps #endif diff --git a/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/Buffer.mm b/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/Buffer.mm index 1daa6bb5e..eb2bfbc74 100644 --- a/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/Buffer.mm +++ b/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/Buffer.mm @@ -66,7 +66,7 @@ static MTLResourceOptions GetNativeResourceOptions(Rhi::BufferStorageMode storag if (!Resource::SetName(name)) return false; - m_mtl_buffer.label = MacOS::ConvertToNsString(name); + m_mtl_buffer.label = Platform::Apple::ConvertToNsString(name); return true; } diff --git a/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/CommandListDebugGroup.mm b/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/CommandListDebugGroup.mm index 0d97c38bd..68ce31efa 100644 --- a/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/CommandListDebugGroup.mm +++ b/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/CommandListDebugGroup.mm @@ -42,7 +42,7 @@ CommandListDebugGroup::CommandListDebugGroup(std::string_view name) : Base::CommandListDebugGroup(name) - , m_ns_name(MacOS::ConvertToNsString(Base::Object::GetName())) + , m_ns_name(Platform::Apple::ConvertToNsString(Base::Object::GetName())) { } } // namespace Methane::Graphics::Metal diff --git a/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/CommandQueue.mm b/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/CommandQueue.mm index c9cf9daba..824d3753b 100644 --- a/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/CommandQueue.mm +++ b/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/CommandQueue.mm @@ -98,7 +98,7 @@ return false; META_CHECK_NOT_NULL(m_mtl_command_queue); - m_mtl_command_queue.label = MacOS::ConvertToNsString(name); + m_mtl_command_queue.label = Platform::Apple::ConvertToNsString(name); return true; } diff --git a/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/ComputeState.mm b/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/ComputeState.mm index 9f022b467..1907760bf 100644 --- a/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/ComputeState.mm +++ b/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/ComputeState.mm @@ -78,7 +78,7 @@ if (!Base::ComputeState::SetName(name)) return false; - NSString* ns_name = MacOS::ConvertToNsString(name); + NSString* ns_name = Platform::Apple::ConvertToNsString(name); m_mtl_pipeline_state_desc.label = ns_name; ResetNativeState(); @@ -98,7 +98,7 @@ error: &ns_error]; META_CHECK_NOT_NULL_DESCR(m_mtl_pipeline_state, "failed to create Metal compute pipeline state: {}", - MacOS::ConvertFromNsString([ns_error localizedDescription])); + Platform::Apple::ConvertFromNsString([ns_error localizedDescription])); } id ComputeState::GetNativePipelineState() diff --git a/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/DebugMessages.mm b/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/DebugMessages.mm index 4f90c577f..50beee212 100644 --- a/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/DebugMessages.mm +++ b/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/DebugMessages.mm @@ -60,7 +60,7 @@ static bool IsEnvironmentVariableEnabled(const char* variable_name) static std::string GetNsStringOrDefault(NSString* ns_string, std::string_view default_value) { META_FUNCTION_TASK(); - return ns_string ? MacOS::ConvertFromNsString(ns_string) : std::string(default_value); + return ns_string ? Platform::Apple::ConvertFromNsString(ns_string) : std::string(default_value); } static std::string_view GetLogLevelSeverityName(NSInteger log_level) diff --git a/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/Device.mm b/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/Device.mm index d017d5ae2..e9d4f18e7 100644 --- a/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/Device.mm +++ b/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/Device.mm @@ -44,7 +44,7 @@ } Device::Device(const id& mtl_device, const Capabilities& capabilities) - : Base::Device(MacOS::ConvertFromNsString(mtl_device.name), false, capabilities) + : Base::Device(Platform::Apple::ConvertFromNsString(mtl_device.name), false, capabilities) , m_mtl_device(mtl_device) , m_mtl_log_state(CreateDebugLogState(mtl_device)) { } diff --git a/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/Fence.mm b/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/Fence.mm index 6f48c5127..6b886c248 100644 --- a/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/Fence.mm +++ b/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/Fence.mm @@ -105,7 +105,7 @@ if (!Base::Object::SetName(name)) return false; - m_mtl_event.label = MacOS::ConvertToNsString(name); + m_mtl_event.label = Platform::Apple::ConvertToNsString(name); return true; } diff --git a/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/Program.mm b/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/Program.mm index f479d7d98..4b1b1dee5 100644 --- a/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/Program.mm +++ b/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/Program.mm @@ -132,7 +132,7 @@ META_CHECK_NOT_NULL_DESCR(mtl_render_pipeline_state, "Failed to create dummy pipeline state for program reflection: {}", - MacOS::ConvertFromNsString([ns_error localizedDescription])); + Platform::Apple::ConvertFromNsString([ns_error localizedDescription])); if (!mtl_render_pipeline_reflection) return; @@ -162,7 +162,7 @@ META_CHECK_NOT_NULL_DESCR(mtl_compute_pipeline_state, "Failed to create compute pipeline state for program reflection: {}", - MacOS::ConvertFromNsString([ns_error localizedDescription])); + Platform::Apple::ConvertFromNsString([ns_error localizedDescription])); if (!mtl_compute_pipeline_reflection) return; diff --git a/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/ProgramLibrary.mm b/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/ProgramLibrary.mm index a3923b021..b02449b0f 100644 --- a/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/ProgramLibrary.mm +++ b/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/ProgramLibrary.mm @@ -37,7 +37,7 @@ static NSString* GetLibraryFullPath(std::string_view library_name) { const std::string library_path = fmt::format("{}/{}.metallib", Platform::GetResourceDir(), library_name); - return MacOS::ConvertToNsString(library_path); + return Platform::Apple::ConvertToNsString(library_path); } ProgramLibrary::ProgramLibrary(const Device& metal_device, std::string_view library_name) @@ -55,7 +55,7 @@ META_CHECK_NOT_NULL_DESCR(m_mtl_library, "Failed to create {} Metal library: {}", library_name.empty() ? std::string_view("default") : library_name, - MacOS::ConvertFromNsString([ns_error localizedDescription])); + Platform::Apple::ConvertFromNsString([ns_error localizedDescription])); } } diff --git a/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/RenderContext.mm b/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/RenderContext.mm index d01fa7e1e..b7509ef3e 100644 --- a/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/RenderContext.mm +++ b/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/RenderContext.mm @@ -49,7 +49,7 @@ { META_FUNCTION_TASK(); - m_frame_capture_scope.label = MacOS::ConvertToNsString(fmt::format("{} Frame Scope", device.GetName())); + m_frame_capture_scope.label = Platform::Apple::ConvertToNsString(fmt::format("{} Frame Scope", device.GetName())); [MTLCaptureManager sharedCaptureManager].defaultCaptureScope = m_frame_capture_scope; #ifdef CAPTURE_INITIALIZATION_SCOPE @@ -241,8 +241,8 @@ NSError* ns_error = nil; const bool capture_success = [mtl_capture_manager startCaptureWithDescriptor:mtl_capture_desc error:&ns_error]; META_CHECK_TRUE_DESCR(capture_success, "failed to capture Metal scope '{}', error: {}", - MacOS::ConvertFromNsString(mtl_capture_scope.label), - MacOS::ConvertFromNsString([ns_error localizedDescription])); + Platform::Apple::ConvertFromNsString(mtl_capture_scope.label), + Platform::Apple::ConvertFromNsString([ns_error localizedDescription])); } } // namespace Methane::Graphics::Metal diff --git a/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/RenderState.mm b/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/RenderState.mm index f69d5da1a..716602e1e 100644 --- a/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/RenderState.mm +++ b/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/RenderState.mm @@ -275,7 +275,7 @@ static MTLWinding ConvertRasterizerFrontWindingToMetal(bool is_front_counter_clo if (!Base::RenderState::SetName(name)) return false; - NSString* ns_name = MacOS::ConvertToNsString(name); + NSString* ns_name = Platform::Apple::ConvertToNsString(name); m_mtl_pipeline_state_desc.label = ns_name; m_mtl_depth_stencil_state_desc.label = ns_name; @@ -300,7 +300,7 @@ static MTLWinding ConvertRasterizerFrontWindingToMetal(bool is_front_counter_clo m_mtl_pipeline_state = [GetMetalRenderContext().GetMetalDevice().GetNativeDevice() newRenderPipelineStateWithDescriptor:m_mtl_pipeline_state_desc error:&ns_error]; META_CHECK_NOT_NULL_DESCR(m_mtl_pipeline_state, "failed to create Metal render pipeline state: {}", - MacOS::ConvertFromNsString([ns_error localizedDescription])); + Platform::Apple::ConvertFromNsString([ns_error localizedDescription])); } void RenderState::InitializeNativeDepthStencilState() diff --git a/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/Sampler.mm b/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/Sampler.mm index a7aefaa87..e71fed83b 100644 --- a/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/Sampler.mm +++ b/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/Sampler.mm @@ -128,7 +128,7 @@ static MTLSamplerBorderColor ConvertBorderColorToMetal(const Rhi::SamplerBorderC return false; META_CHECK_NOT_NULL(m_mtl_sampler_desc); - m_mtl_sampler_desc.label = MacOS::ConvertToNsString(name); + m_mtl_sampler_desc.label = Platform::Apple::ConvertToNsString(name); ResetSamplerState(); return true; diff --git a/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/Shader.mm b/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/Shader.mm index 230b03328..3573ab382 100644 --- a/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/Shader.mm +++ b/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/Shader.mm @@ -239,7 +239,7 @@ static bool IsArgumentBufferName(std::string_view argument_name, Rhi::ProgramArg for(MTLStructMember* mtl_struct_member in mtl_element_struct_type.members) { member_by_name.try_emplace( - MacOS::ConvertFromNsString(mtl_struct_member.name), + Platform::Apple::ConvertFromNsString(mtl_struct_member.name), ArgumentBufferMember(mtl_struct_member) ); } @@ -264,7 +264,7 @@ static bool IsArgumentBufferName(std::string_view argument_name, Rhi::ProgramArg #ifdef METAL_LIBRARY_SPLIT_BY_SHADER_ENTRY_FUNCTION NSString* ns_shader_function_name = mtl_shader_library.functionNames.firstObject; #else - NSString* ns_shader_function_name = Methane::MacOS::ConvertToNsString(compiled_entry_function_name); + NSString* ns_shader_function_name = Methane::Platform::Apple::ConvertToNsString(compiled_entry_function_name); #endif return [mtl_shader_library newFunctionWithName: ns_shader_function_name]; @@ -281,7 +281,7 @@ static bool IsArgumentBufferName(std::string_view argument_name, Rhi::ProgramArg // Regex matching suffix of the input attributes "...123" static const std::regex s_attr_suffix_regex("\\d+$"); - std::string attrib_name = MacOS::ConvertFromNsString(ns_reflect_attrib_name); + std::string attrib_name = Platform::Apple::ConvertFromNsString(ns_reflect_attrib_name); attrib_name = std::regex_replace(attrib_name, s_attr_prefix_regex, ""); attrib_name = std::regex_replace(attrib_name, s_attr_suffix_regex, ""); @@ -350,7 +350,7 @@ static bool IsArgumentBufferName(std::string_view argument_name, Rhi::ProgramArg if (!mtl_binding.argument || !mtl_binding.used) continue; - const std::string argument_name = MacOS::ConvertFromNsString(mtl_binding.name); + const std::string argument_name = Platform::Apple::ConvertFromNsString(mtl_binding.name); if (argument_name.find("vertexBuffer.") == 0) { // Skip input vertex buffers, since they are set with a separate IRenderCommandList call, not through resource bindings @@ -403,7 +403,7 @@ static bool IsArgumentBufferName(std::string_view argument_name, Rhi::ProgramArg for(id mtl_binding in m_mtl_bindings) { Rhi::ProgramArgumentAccessType arg_access_type = Rhi::ProgramArgumentAccessType::Mutable; - const std::string argument_name = MacOS::ConvertFromNsString(mtl_binding.name); + const std::string argument_name = Platform::Apple::ConvertFromNsString(mtl_binding.name); if (mtl_binding.argument && mtl_binding.used && mtl_binding.type == MTLBindingTypeBuffer && IsArgumentBufferName(argument_name, arg_access_type)) diff --git a/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/Texture.mm b/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/Texture.mm index c9538d6cc..dd363b9d1 100644 --- a/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/Texture.mm +++ b/Modules/Graphics/RHI/Metal/Sources/Methane/Graphics/Metal/Texture.mm @@ -250,7 +250,7 @@ static MTLRegion GetTextureRegion(const Dimensions& dimensions, Rhi::TextureDime const Settings& settings = GetSettings(); const MTLPixelFormat mtl_pixel_format = TypeConverter::DataFormatToMetalPixelType(settings.pixel_format); - const BOOL is_tex_mipmapped = MacOS::ConvertToNsBool(settings.mipmapped); + const BOOL is_tex_mipmapped = Platform::Apple::ConvertToNsBool(settings.mipmapped); MTLTextureDescriptor* mtl_tex_desc = nil; switch(settings.dimension_type) diff --git a/Modules/Platform/Apple/MacOS/App/CMakeLists.txt b/Modules/Platform/Apple/MacOS/App/CMakeLists.txt index 410d286f6..94b77ccbb 100644 --- a/Modules/Platform/Apple/MacOS/App/CMakeLists.txt +++ b/Modules/Platform/Apple/MacOS/App/CMakeLists.txt @@ -1,21 +1,17 @@ set(TARGET MethanePlatformAppMacOS) -include(MethaneModules) - -get_module_dirs("Methane/Platform") - list(APPEND HEADERS - ${INCLUDE_PLATFORM_OS_DIR}/App.hh - ${SOURCES_PLATFORM_OS_DIR}/AppDelegate.hh - ${SOURCES_PLATFORM_OS_DIR}/AppViewController.hh - ${SOURCES_PLATFORM_OS_DIR}/WindowDelegate.hh + Include/Methane/Platform/MacOS/App.hh + Sources/Methane/Platform/MacOS/AppDelegate.hh + Sources/Methane/Platform/MacOS/AppViewController.hh + Sources/Methane/Platform/MacOS/WindowDelegate.hh ) list(APPEND SOURCES - ${SOURCES_PLATFORM_OS_DIR}/App.mm - ${SOURCES_PLATFORM_OS_DIR}/AppDelegate.mm - ${SOURCES_PLATFORM_OS_DIR}/AppViewController.mm - ${SOURCES_PLATFORM_OS_DIR}/WindowDelegate.mm + Sources/Methane/Platform/MacOS/App.mm + Sources/Methane/Platform/MacOS/AppDelegate.mm + Sources/Methane/Platform/MacOS/AppViewController.mm + Sources/Methane/Platform/MacOS/WindowDelegate.mm ) add_library(${TARGET} STATIC @@ -50,7 +46,7 @@ endif() target_include_directories(${TARGET} PRIVATE Sources - ${SOURCES_PLATFORM_OS_DIR} + Sources/Methane/Platform/MacOS PUBLIC Include ) @@ -73,7 +69,7 @@ set_target_properties(${TARGET} install(TARGETS ${TARGET} PUBLIC_HEADER - DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} + DESTINATION include/Methane/Platform/MacOS COMPONENT Development ARCHIVE DESTINATION lib diff --git a/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/App.mm b/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/App.mm index 0440588e1..c03691e3d 100644 --- a/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/App.mm +++ b/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/App.mm @@ -36,9 +36,10 @@ static NSAlertStyle ConvertMessageTypeToNsAlertStyle(Base::App::Message::Type ms META_FUNCTION_TASK(); switch(msg_type) { - case Base::App::Message::Type::Information: return NSAlertStyleInformational; - case Base::App::Message::Type::Warning: return NSAlertStyleWarning; - case Base::App::Message::Type::Error: return NSAlertStyleCritical; + using enum Base::App::Message::Type; + case Information: return NSAlertStyleInformational; + case Warning: return NSAlertStyleWarning; + case Error: return NSAlertStyleCritical; default: META_UNEXPECTED_RETURN(msg_type, NSAlertStyleInformational); } } @@ -106,7 +107,7 @@ static NSAlertStyle ConvertMessageTypeToNsAlertStyle(Base::App::Message::Type ms void App::SetWindowTitle(const std::string& title_text) { META_FUNCTION_TASK(); - NSString* ns_title_text = Methane::MacOS::ConvertToNsString(title_text); + NSString* ns_title_text = Apple::ConvertToNsString(title_text); dispatch_async(dispatch_get_main_queue(), ^(void){ m_ns_window.title = ns_title_text; }); @@ -123,8 +124,8 @@ static NSAlertStyle ConvertMessageTypeToNsAlertStyle(Base::App::Message::Type ms META_FUNCTION_TASK(); META_CHECK_NOT_NULL(m_ns_app_delegate); - [m_ns_app_delegate alert: Methane::MacOS::ConvertToNsString(msg.title) - withInformation: Methane::MacOS::ConvertToNsString(msg.information) + [m_ns_app_delegate alert: Apple::ConvertToNsString(msg.title) + withInformation: Apple::ConvertToNsString(msg.information) andStyle: ConvertMessageTypeToNsAlertStyle(msg.type)]; Base::App::ShowAlert(msg); diff --git a/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/AppDelegate.mm b/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/AppDelegate.mm index e194a9eed..950f8fc10 100644 --- a/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/AppDelegate.mm +++ b/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/AppDelegate.mm @@ -40,7 +40,7 @@ @implementation AppDelegate @synthesize window = m_window; -- (id) initWithApp : (Methane::Platform::MacOS::App*) app_ptr andSettings : (const Base::App::Settings*) settings_ptr +- (id) initWithApp : (MacOS::App*) app_ptr andSettings : (const Base::App::Settings*) settings_ptr { META_FUNCTION_TASK(); self = [super init]; @@ -70,7 +70,7 @@ - (id) initWithApp : (Methane::Platform::MacOS::App*) app_ptr andSettings : (con m_window = [[NSWindow alloc] initWithContentRect:frame styleMask:style_mask backing:backing defer:YES]; m_window.contentMinSize = NSMakeSize(static_cast(min_frame_size.GetWidth()), static_cast(min_frame_size.GetHeight())); - m_window.title = Methane::MacOS::ConvertToNsString(settings_ptr->name); + m_window.title = Apple::ConvertToNsString(settings_ptr->name); // Window state restoration is not implemented and window size and position are set from application settings, // so it is disabled to stop AppKit from persisting the saved state of the window which is never restored @@ -133,7 +133,7 @@ - (void) windowWillEnterFullScreen:(NSNotification *)notification { META_FUNCTION_TASK(); #pragma unused(notification) - Methane::Platform::MacOS::App* app_ptr = [self.viewController getApp]; + MacOS::App* app_ptr = [self.viewController getApp]; META_CHECK_NOT_NULL(app_ptr); app_ptr->SetFullScreenInternal(true); } @@ -142,7 +142,7 @@ - (void) windowWillExitFullScreen:(NSNotification *)notification { META_FUNCTION_TASK(); #pragma unused(notification) - Methane::Platform::MacOS::App* app_ptr = [self.viewController getApp]; + MacOS::App* app_ptr = [self.viewController getApp]; META_CHECK_NOT_NULL(app_ptr); app_ptr->SetFullScreenInternal(false); } diff --git a/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/AppViewController.mm b/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/AppViewController.mm index a183ea671..c225453b7 100644 --- a/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/AppViewController.mm +++ b/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/AppViewController.mm @@ -37,10 +37,10 @@ @implementation AppViewController { - pal::MacOS::App* m_app_ptr; - NSRect m_frame_rect; - bool m_is_initialized; - std::string m_error; + pal::MacOS::App* m_app_ptr; + NSRect m_frame_rect; + bool m_is_initialized; + std::string m_error; } - (id) initWithApp : (pal::MacOS::App*) app_ptr andFrameRect : (NSRect) frame_rect diff --git a/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/WindowDelegate.mm b/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/WindowDelegate.mm index 21a47f7f7..892640179 100644 --- a/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/WindowDelegate.mm +++ b/Modules/Platform/Apple/MacOS/App/Sources/Methane/Platform/MacOS/WindowDelegate.mm @@ -32,11 +32,11 @@ @implementation WindowDelegate { - Methane::Platform::MacOS::App* m_app_ptr; + MacOS::App* m_app_ptr; Data::FrameSize m_frame_size; } -- (id) initWithApp : (Methane::Platform::MacOS::App*) app_ptr +- (id) initWithApp : (MacOS::App*) app_ptr { META_FUNCTION_TASK(); diff --git a/Modules/Platform/Apple/MacOS/AppView/CMakeLists.txt b/Modules/Platform/Apple/MacOS/AppView/CMakeLists.txt index ea0488831..57ad7b4b6 100644 --- a/Modules/Platform/Apple/MacOS/AppView/CMakeLists.txt +++ b/Modules/Platform/Apple/MacOS/AppView/CMakeLists.txt @@ -1,16 +1,12 @@ set(TARGET MethanePlatformAppViewMacOS) -include(MethaneModules) - -get_module_dirs("Methane/Platform") - list(APPEND HEADERS - ${INCLUDE_PLATFORM_OS_DIR}/AppEnvironment.hh - ${INCLUDE_PLATFORM_OS_DIR}/AppViewMetal.hh + Include/Methane/Platform/MacOS/AppEnvironment.hh + Include/Methane/Platform/MacOS/AppViewMetal.hh ) list(APPEND SOURCES - ${SOURCES_PLATFORM_OS_DIR}/AppViewMetal.mm + Sources/Methane/Platform/MacOS/AppViewMetal.mm ) add_library(${TARGET} STATIC @@ -59,7 +55,7 @@ set_target_properties(${TARGET} install(TARGETS ${TARGET} PUBLIC_HEADER - DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} + DESTINATION include/Methane/Platform/MacOS COMPONENT Development ARCHIVE DESTINATION lib diff --git a/Modules/Platform/Apple/MacOS/Input/Keyboard/CMakeLists.txt b/Modules/Platform/Apple/MacOS/Input/Keyboard/CMakeLists.txt index 778877812..3b47d7555 100644 --- a/Modules/Platform/Apple/MacOS/Input/Keyboard/CMakeLists.txt +++ b/Modules/Platform/Apple/MacOS/Input/Keyboard/CMakeLists.txt @@ -1,15 +1,11 @@ set(TARGET MethanePlatformInputKeyboardMacOS) -include(MethaneModules) - -get_module_dirs("Methane/Platform/Input") - list(APPEND HEADERS - ${INCLUDE_PLATFORM_OS_DIR}/Keyboard.h + Include/Methane/Platform/Input/MacOS/Keyboard.h ) list(APPEND SOURCES - ${SOURCES_PLATFORM_OS_DIR}/Keyboard.mm + Sources/Methane/Platform/Input/MacOS/Keyboard.mm ) add_library(${TARGET} STATIC @@ -58,7 +54,7 @@ set_target_properties(${TARGET} install(TARGETS ${TARGET} PUBLIC_HEADER - DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} + DESTINATION include/Methane/Platform/Input/MacOS COMPONENT Development ARCHIVE DESTINATION lib diff --git a/Modules/Platform/Apple/README.md b/Modules/Platform/Apple/README.md index 6fd9f0b8e..4b6d067bb 100644 --- a/Modules/Platform/Apple/README.md +++ b/Modules/Platform/Apple/README.md @@ -39,12 +39,12 @@ conversions in [`Types.hh`](Utils/Include/Methane/Platform/Apple/Types.hh). terminal — this is why `--print_debug_messages_to_console` exists; with it, the same messages go to `std::cout` instead. -> **Namespace gotcha:** these helpers live in namespace **`Methane::MacOS`** — not -> `Methane::Platform::Apple`, and not `Methane::Platform::MacOS`. That name predates the platform -> grouping and is shared by the iOS build too. Because `Methane::Platform::MacOS` now exists as the -> macOS *application* namespace, an unqualified `MacOS::ConvertToNsString(...)` inside -> `Methane::Platform::MacOS` resolves to the wrong namespace, and in a file with both -> `using namespace Methane;` and `using namespace Methane::Platform;` the name `MacOS` is outright -> ambiguous. Always write `Methane::MacOS::ConvertToNsString` in full. +These helpers live in namespace `Methane::Platform::Apple`, matching the directory. They used to +sit in `Methane::MacOS`, which clashed with the `Methane::Platform::MacOS` application namespace +introduced by the platform grouping: an unqualified `MacOS::ConvertToNsString(...)` resolved to the +wrong namespace, and in a file with both `using namespace Methane;` and +`using namespace Methane::Platform;` the name `MacOS` was ambiguous. With the namespace renamed, +`Apple::ConvertToNsString` is unambiguous from any `Methane::Platform::*` scope, and the Metal RHI +backend refers to it as `Platform::Apple::ConvertToNsString`. Links the `Foundation` framework. diff --git a/Modules/Platform/Apple/Utils/CMakeLists.txt b/Modules/Platform/Apple/Utils/CMakeLists.txt index 6c829e754..75feebbfb 100644 --- a/Modules/Platform/Apple/Utils/CMakeLists.txt +++ b/Modules/Platform/Apple/Utils/CMakeLists.txt @@ -1,16 +1,12 @@ set(TARGET MethanePlatformUtilsApple) -include(MethaneModules) - -get_module_dirs("Methane/Platform") - list(APPEND HEADERS - ${INCLUDE_PLATFORM_DIR}/Types.hh - ${INCLUDE_PLATFORM_DIR}/Utils.hh + Include/Methane/Platform/Apple/Types.hh + Include/Methane/Platform/Apple/Utils.hh ) list(APPEND SOURCES - ${SOURCES_PLATFORM_DIR}/Utils.mm + Sources/Methane/Platform/Apple/Utils.mm ) add_library(${TARGET} STATIC @@ -57,7 +53,7 @@ set_target_properties(${TARGET} install(TARGETS ${TARGET} PUBLIC_HEADER - DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_DIR} + DESTINATION include/Methane/Platform/Apple COMPONENT Development ARCHIVE DESTINATION lib diff --git a/Modules/Platform/Apple/Utils/Include/Methane/Platform/Apple/Types.hh b/Modules/Platform/Apple/Utils/Include/Methane/Platform/Apple/Types.hh index fa0c80ac2..81db17752 100644 --- a/Modules/Platform/Apple/Utils/Include/Methane/Platform/Apple/Types.hh +++ b/Modules/Platform/Apple/Utils/Include/Methane/Platform/Apple/Types.hh @@ -16,8 +16,8 @@ limitations under the License. ******************************************************************************* -FILE: Methane/Platform/MacOS/Types.h -MacOS platform type converters. +FILE: Methane/Platform/Apple/Types.hh +Apple platform type converters. ******************************************************************************/ @@ -27,7 +27,7 @@ MacOS platform type converters. #include -namespace Methane::MacOS +namespace Methane::Platform::Apple { // =============================== @@ -58,4 +58,4 @@ inline std::string ConvertFromNsString(const NSString* ns_str_ptr) return ns_str_ptr ? std::string([ns_str_ptr UTF8String]) : std::string(); } -} // namespace Methane::MacOS +} // namespace Methane::Platform::Apple diff --git a/Modules/Platform/Apple/Utils/Include/Methane/Platform/Apple/Utils.hh b/Modules/Platform/Apple/Utils/Include/Methane/Platform/Apple/Utils.hh index 7435cdd4a..4d553ee62 100644 --- a/Modules/Platform/Apple/Utils/Include/Methane/Platform/Apple/Utils.hh +++ b/Modules/Platform/Apple/Utils/Include/Methane/Platform/Apple/Utils.hh @@ -16,8 +16,8 @@ limitations under the License. ******************************************************************************* -FILE: Methane/Platform/MacOS/Utils.h -MacOS platform utility functions. +FILE: Methane/Platform/Apple/Utils.hh +Apple platform utility functions. ******************************************************************************/ diff --git a/Modules/Platform/Apple/iOS/App/CMakeLists.txt b/Modules/Platform/Apple/iOS/App/CMakeLists.txt index 27959501f..2196574ee 100644 --- a/Modules/Platform/Apple/iOS/App/CMakeLists.txt +++ b/Modules/Platform/Apple/iOS/App/CMakeLists.txt @@ -1,19 +1,15 @@ set(TARGET MethanePlatformAppIOS) -include(MethaneModules) - -get_module_dirs("Methane/Platform") - list(APPEND HEADERS - ${INCLUDE_PLATFORM_OS_DIR}/App.hh - ${SOURCES_PLATFORM_OS_DIR}/AppDelegate.hh - ${SOURCES_PLATFORM_OS_DIR}/AppViewController.hh + Include/Methane/Platform/iOS/App.hh + Sources/Methane/Platform/iOS/AppDelegate.hh + Sources/Methane/Platform/iOS/AppViewController.hh ) list(APPEND SOURCES - ${SOURCES_PLATFORM_OS_DIR}/App.mm - ${SOURCES_PLATFORM_OS_DIR}/AppDelegate.mm - ${SOURCES_PLATFORM_OS_DIR}/AppViewController.mm + Sources/Methane/Platform/iOS/App.mm + Sources/Methane/Platform/iOS/AppDelegate.mm + Sources/Methane/Platform/iOS/AppViewController.mm ) add_library(${TARGET} STATIC @@ -47,7 +43,7 @@ endif() target_include_directories(${TARGET} PRIVATE Sources - ${SOURCES_PLATFORM_OS_DIR} + Sources/Methane/Platform/iOS PUBLIC Include ) @@ -70,7 +66,7 @@ set_target_properties(${TARGET} install(TARGETS ${TARGET} PUBLIC_HEADER - DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} + DESTINATION include/Methane/Platform/iOS COMPONENT Development ARCHIVE DESTINATION lib diff --git a/Modules/Platform/Apple/iOS/App/Sources/Methane/Platform/iOS/App.mm b/Modules/Platform/Apple/iOS/App/Sources/Methane/Platform/iOS/App.mm index 6fb0116ce..e4343442b 100644 --- a/Modules/Platform/Apple/iOS/App/Sources/Methane/Platform/iOS/App.mm +++ b/Modules/Platform/Apple/iOS/App/Sources/Methane/Platform/iOS/App.mm @@ -38,9 +38,10 @@ static UIAlertActionStyle ConvertMessageTypeToNsAlertStyle(Base::App::Message::T META_FUNCTION_TASK(); switch(msg_type) { - case Base::App::Message::Type::Information: return UIAlertActionStyleDefault; - case Base::App::Message::Type::Warning: return UIAlertActionStyleCancel; - case Base::App::Message::Type::Error: return UIAlertActionStyleDestructive; + using enum Base::App::Message::Type; + case Information: return UIAlertActionStyleDefault; + case Warning: return UIAlertActionStyleCancel; + case Error: return UIAlertActionStyleDestructive; default: META_UNEXPECTED_RETURN(msg_type, UIAlertActionStyleDestructive); } } @@ -113,8 +114,8 @@ static UIAlertActionStyle ConvertMessageTypeToNsAlertStyle(Base::App::Message::T AppDelegate* app_delegate = static_cast([UIApplication sharedApplication].delegate); META_CHECK_NOT_NULL(app_delegate); - [app_delegate alert: Methane::MacOS::ConvertToNsString(msg.title) - withInformation: Methane::MacOS::ConvertToNsString(msg.information) + [app_delegate alert: Apple::ConvertToNsString(msg.title) + withInformation: Apple::ConvertToNsString(msg.information) andStyle: ConvertMessageTypeToNsAlertStyle(msg.type)]; Base::App::ShowAlert(msg); diff --git a/Modules/Platform/Apple/iOS/App/Sources/Methane/Platform/iOS/AppDelegate.mm b/Modules/Platform/Apple/iOS/App/Sources/Methane/Platform/iOS/AppDelegate.mm index 131fea072..78e51a369 100644 --- a/Modules/Platform/Apple/iOS/App/Sources/Methane/Platform/iOS/AppDelegate.mm +++ b/Modules/Platform/Apple/iOS/App/Sources/Methane/Platform/iOS/AppDelegate.mm @@ -45,7 +45,7 @@ - (id) init if (!self) return nil; - iOS::App* app_ptr = iOS::App::GetInstance(); + iOS::App* app_ptr = iOS::App::GetInstance(); UIScreen* ns_main_screen = [UIScreen mainScreen]; const auto& ns_frame_size = ns_main_screen.bounds.size; const CGRect backing_frame = CGRectMake(0.f, 0.f, diff --git a/Modules/Platform/Apple/iOS/App/Sources/Methane/Platform/iOS/AppViewController.mm b/Modules/Platform/Apple/iOS/App/Sources/Methane/Platform/iOS/AppViewController.mm index 17d9ae285..e9e93b209 100644 --- a/Modules/Platform/Apple/iOS/App/Sources/Methane/Platform/iOS/AppViewController.mm +++ b/Modules/Platform/Apple/iOS/App/Sources/Methane/Platform/iOS/AppViewController.mm @@ -54,9 +54,9 @@ @implementation AppViewController { pal::iOS::App* m_app_ptr; - CGRect m_frame_rect; - bool m_is_initialized; - std::string m_error; + CGRect m_frame_rect; + bool m_is_initialized; + std::string m_error; } - (id)initWithApp : (pal::iOS::App*) app_ptr andFrameRect : (CGRect) frame_rect diff --git a/Modules/Platform/Apple/iOS/AppView/CMakeLists.txt b/Modules/Platform/Apple/iOS/AppView/CMakeLists.txt index b36aa7ed3..f39305875 100644 --- a/Modules/Platform/Apple/iOS/AppView/CMakeLists.txt +++ b/Modules/Platform/Apple/iOS/AppView/CMakeLists.txt @@ -1,16 +1,12 @@ set(TARGET MethanePlatformAppViewIOS) -include(MethaneModules) - -get_module_dirs("Methane/Platform") - list(APPEND HEADERS - ${INCLUDE_PLATFORM_OS_DIR}/AppEnvironment.hh - ${INCLUDE_PLATFORM_OS_DIR}/AppViewMetal.hh + Include/Methane/Platform/iOS/AppEnvironment.hh + Include/Methane/Platform/iOS/AppViewMetal.hh ) list(APPEND SOURCES - ${SOURCES_PLATFORM_OS_DIR}/AppViewMetal.mm + Sources/Methane/Platform/iOS/AppViewMetal.mm ) add_library(${TARGET} STATIC @@ -59,7 +55,7 @@ set_target_properties(${TARGET} install(TARGETS ${TARGET} PUBLIC_HEADER - DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} + DESTINATION include/Methane/Platform/iOS COMPONENT Development ARCHIVE DESTINATION lib diff --git a/Modules/Platform/Base/README.md b/Modules/Platform/Base/README.md new file mode 100644 index 000000000..c6752c909 --- /dev/null +++ b/Modules/Platform/Base/README.md @@ -0,0 +1,79 @@ +# Methane Platform Base + +All **platform-independent** implementations of the [Platform modules](../README.md). +This group is always added to the build, on every platform. + +| Module | CMake Target | Namespace | +|----------------------------------------------|---------------------------------------|--------------------------------------| +| [App](App) | MethanePlatformAppBase | `Methane::Platform::Base` | +| [AppController](AppController) | MethanePlatformAppController | `Methane::Platform` | +| [Input/Keyboard](Input/Keyboard) | MethanePlatformInputKeyboardBase | `Methane::Platform::Input::Keyboard` | +| [Input/Mouse](Input/Mouse) | MethanePlatformInputMouse | `Methane::Platform::Input::Mouse` | +| [Input/Controllers](Input/Controllers) | MethanePlatformInputControllers | `Methane::Platform::Input` | +| [Input/ActionControllers](Input/ActionControllers) | MethanePlatformInputActionControllers | `Methane::Platform::Input` | +| [Utils](Utils) | MethanePlatformUtilsBase | `Methane::Platform` | + +## Two kinds of module in this group + +The `Base` group holds every platform-independent implementation, but not all of them play the same role: + +- **Modules with platform counterparts** — `App`, `Input/Keyboard` and `Utils` — carry a `Base` target + suffix. Each has a matching module in every platform group, and an + [`Impl`](../Impl) facade target that binds the two together. Other domains link the facade + (`MethanePlatformApp`, `MethanePlatformInputKeyboard`, `MethanePlatformUtils`), never these targets + directly. +- **Fully platform-independent modules** — `AppController`, `Input/Mouse`, `Input/Controllers` and + `Input/ActionControllers` — have no platform counterpart, so they carry no suffix and need no facade. + They are linked directly by name from other domains. + +Only `App` puts its code in a nested `Methane::Platform::Base` namespace, because `Base::App` and the +platform `App` classes would otherwise collide. The other modules define types whose names are already +unique (`AppController`, `Keyboard::Key`, `Mouse::Button`, `Input::State`, …) and stay in their natural +namespace, so their public include paths are unchanged by the grouping. + +## Base/App + +[`Base::App`](App/Include/Methane/Platform/Base/App.h) implements everything about a windowed +application that does not need the native API: settings parsing, the update/render loop, resize and +full-screen bookkeeping, input state dispatch, alerts, help text and the shared +[Taskflow](/Externals/TaskFlow.cmake) executor. It derives from both +[`Platform::IApp`](../Interfaces/App) and `CLI::App`, the latter giving every Methane application its +command-line parsing for free. + +Error handling is centralised here: `ExecuteWithErrorHandling` wraps context initialisation, app +initialisation, input processing and rendering, converting exceptions into deferred user alerts. In +`_DEBUG` builds the wrapper deliberately does **not** catch, so a debugger breaks at the throw site. + +Platform implementations derive from `Base::App` and override `GetView()`, `SetWindowTitle()`, +`GetContentScalingFactor()`, `GetFontResolutionDpi()`, `Run()` and `Close()`, plus `ShowAlert()` to +use the native dialog. + +## Base/Input/Keyboard + +This module declares the whole keyboard abstraction — `Keyboard::Key`, `Keyboard::ModifierMask`, +`Keyboard::State`, `Keyboard::StateChange` and `Keyboard::KeyConverter` — while the native key +representation lives in the platform groups. + +`Keyboard.h` only **forward-declares** `struct NativeKey`, which is what lets this module compile +with no knowledge of any platform. Two consequences worth knowing: + +- Code that constructs a `NativeKey` must include + `/Keyboard.h>` itself; the shared header does not pull it in. +- `KeyConverter`'s native-key constructor and its `GetKeyByNativeCode` / `GetModifiersByNativeCode` + statics are implemented **in the platform modules, not here**, so that this target never references + a symbol the platform group owns. Defining that constructor here previously made `Base` and the + platform module mutually dependent, which GNU `ld` rejects even though the MSVC linker tolerates it. + +`Keyboard::OS::g_key_left_ctrl` resolves to `Key::LeftSuper` on Apple platforms and `Key::LeftControl` +elsewhere, which is how one shortcut definition serves both the Control and Command conventions. + +## Base/Utils + +`Methane/Platform/Utils.h` declares the functions every platform implements — +`PrintToDebugOutput`, `GetExecutableDir`, `GetExecutableFileName`, `GetResourceDir` — and this module +implements only the genuinely shared ones (`SplitString` and the print-to-console flag). It therefore +has unresolved symbols on its own; they are satisfied by the platform `Utils` module, which the +[`Impl/Utils`](../Impl/Utils) facade links alongside it. + +Like the keyboard header, `Utils.h` carries no platform dispatch include: platform-specific functions +are declared in `/Utils.h>` and included directly where needed. diff --git a/Modules/Platform/Linux/App/CMakeLists.txt b/Modules/Platform/Linux/App/CMakeLists.txt index ea07fb836..5332568b7 100644 --- a/Modules/Platform/Linux/App/CMakeLists.txt +++ b/Modules/Platform/Linux/App/CMakeLists.txt @@ -1,19 +1,15 @@ set(TARGET MethanePlatformAppLinux) -include(MethaneModules) - -get_module_dirs("Methane/Platform") - list(APPEND HEADERS - ${INCLUDE_PLATFORM_OS_DIR}/App.h + Include/Methane/Platform/Linux/App.h ) list(APPEND SOURCES - ${SOURCES_PLATFORM_OS_DIR}/App.cpp - ${SOURCES_PLATFORM_OS_DIR}/MessageBox.h - ${SOURCES_PLATFORM_OS_DIR}/MessageBox.cpp - ${SOURCES_PLATFORM_OS_DIR}/XcbUtils.h - ${SOURCES_PLATFORM_OS_DIR}/XcbUtils.cpp + Sources/Methane/Platform/Linux/App.cpp + Sources/Methane/Platform/Linux/MessageBox.h + Sources/Methane/Platform/Linux/MessageBox.cpp + Sources/Methane/Platform/Linux/XcbUtils.h + Sources/Methane/Platform/Linux/XcbUtils.cpp ) add_library(${TARGET} STATIC @@ -53,7 +49,7 @@ endif() target_include_directories(${TARGET} PRIVATE Sources - ${SOURCES_PLATFORM_OS_DIR} + Sources/Methane/Platform/Linux PUBLIC Include ) @@ -68,7 +64,7 @@ set_target_properties(${TARGET} install(TARGETS ${TARGET} PUBLIC_HEADER - DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} + DESTINATION include/Methane/Platform/Linux COMPONENT Development ARCHIVE DESTINATION lib diff --git a/Modules/Platform/Linux/AppView/CMakeLists.txt b/Modules/Platform/Linux/AppView/CMakeLists.txt index 144f5835c..ee39b75ed 100644 --- a/Modules/Platform/Linux/AppView/CMakeLists.txt +++ b/Modules/Platform/Linux/AppView/CMakeLists.txt @@ -1,11 +1,7 @@ set(TARGET MethanePlatformAppViewLinux) -include(MethaneModules) - -get_module_dirs("Methane/Platform") - list(APPEND HEADERS - ${CMAKE_CURRENT_SOURCE_DIR}/${INCLUDE_PLATFORM_OS_DIR}/AppEnvironment.h + ${CMAKE_CURRENT_SOURCE_DIR}/Include/Methane/Platform/Linux/AppEnvironment.h ) add_library(${TARGET} INTERFACE) @@ -30,6 +26,6 @@ set_target_properties(${TARGET} install(TARGETS ${TARGET} PUBLIC_HEADER - DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} + DESTINATION include/Methane/Platform/Linux COMPONENT Development ) diff --git a/Modules/Platform/Linux/Input/Keyboard/CMakeLists.txt b/Modules/Platform/Linux/Input/Keyboard/CMakeLists.txt index c6b96913d..4b1f502c2 100644 --- a/Modules/Platform/Linux/Input/Keyboard/CMakeLists.txt +++ b/Modules/Platform/Linux/Input/Keyboard/CMakeLists.txt @@ -1,15 +1,11 @@ set(TARGET MethanePlatformInputKeyboardLinux) -include(MethaneModules) - -get_module_dirs("Methane/Platform/Input") - list(APPEND HEADERS - ${INCLUDE_PLATFORM_OS_DIR}/Keyboard.h + Include/Methane/Platform/Input/Linux/Keyboard.h ) list(APPEND SOURCES - ${SOURCES_PLATFORM_OS_DIR}/Keyboard.cpp + Sources/Methane/Platform/Input/Linux/Keyboard.cpp ) add_library(${TARGET} STATIC @@ -51,7 +47,7 @@ set_target_properties(${TARGET} install(TARGETS ${TARGET} PUBLIC_HEADER - DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} + DESTINATION include/Methane/Platform/Input/Linux COMPONENT Development ARCHIVE DESTINATION lib diff --git a/Modules/Platform/Linux/Utils/CMakeLists.txt b/Modules/Platform/Linux/Utils/CMakeLists.txt index 3264dc860..6feacf2d5 100644 --- a/Modules/Platform/Linux/Utils/CMakeLists.txt +++ b/Modules/Platform/Linux/Utils/CMakeLists.txt @@ -1,15 +1,11 @@ set(TARGET MethanePlatformUtilsLinux) -include(MethaneModules) - -get_module_dirs("Methane/Platform") - list(APPEND HEADERS - ${INCLUDE_PLATFORM_OS_DIR}/Utils.h + Include/Methane/Platform/Linux/Utils.h ) list(APPEND SOURCES - ${SOURCES_PLATFORM_OS_DIR}/Utils.cpp + Sources/Methane/Platform/Linux/Utils.cpp ) add_library(${TARGET} STATIC @@ -48,7 +44,7 @@ set_target_properties(${TARGET} install(TARGETS ${TARGET} PUBLIC_HEADER - DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} + DESTINATION include/Methane/Platform/Linux COMPONENT Development ARCHIVE DESTINATION lib diff --git a/Modules/Platform/README.md b/Modules/Platform/README.md index 82013ae20..593e065c5 100644 --- a/Modules/Platform/README.md +++ b/Modules/Platform/README.md @@ -7,10 +7,10 @@ Platform modules are grouped by platform support, similar to [Graphics RHI](../G | Group | Namespace | Content | |-----------------------------------------|------------------------------|-----------------------------------------------------------------| | [Interfaces](Interfaces) | `Methane::Platform` | Public interfaces and settings structures with no implementation | -| [Base](Base) | `Methane::Platform[::Base]` | All platform-independent implementations | +| [Base](Base/README.md) | `Methane::Platform[::Base]` | All platform-independent implementations | | [Windows](Windows/README.md) | `Methane::Platform::Windows` | Windows-specific implementations | | [Linux](Linux/README.md) | `Methane::Platform::Linux` | Linux-specific implementations | -| [Apple](Apple/README.md) | `Methane::MacOS` | Implementations shared by all Apple platforms | +| [Apple](Apple/README.md) | `Methane::Platform::Apple` | Implementations shared by all Apple platforms | | [Apple/MacOS](Apple/MacOS/README.md) | `Methane::Platform::MacOS` | MacOS-specific implementations | | [Apple/iOS](Apple/iOS/README.md) | `Methane::Platform::iOS` | iOS / tvOS-specific implementations | | [Impl](Impl) | `Methane::Platform` | Final implementation modules binding the groups above together | diff --git a/Modules/Platform/Windows/App/CMakeLists.txt b/Modules/Platform/Windows/App/CMakeLists.txt index 608f0d241..acbf87e2d 100644 --- a/Modules/Platform/Windows/App/CMakeLists.txt +++ b/Modules/Platform/Windows/App/CMakeLists.txt @@ -1,17 +1,13 @@ set(TARGET MethanePlatformAppWindows) -include(MethaneModules) - -get_module_dirs("Methane/Platform") - list(APPEND HEADERS - ${INCLUDE_PLATFORM_OS_DIR}/App.h + Include/Methane/Platform/Windows/App.h ) list(APPEND SOURCES - ${SOURCES_PLATFORM_OS_DIR}/App.cpp - ${SOURCES_PLATFORM_OS_DIR}/ConsoleStreams.h - ${SOURCES_PLATFORM_OS_DIR}/ConsoleStreams.cpp + Sources/Methane/Platform/Windows/App.cpp + Sources/Methane/Platform/Windows/ConsoleStreams.h + Sources/Methane/Platform/Windows/ConsoleStreams.cpp ) add_library(${TARGET} STATIC @@ -46,7 +42,7 @@ endif() target_include_directories(${TARGET} PRIVATE Sources - ${SOURCES_PLATFORM_OS_DIR} + Sources/Methane/Platform/Windows PUBLIC Include ) @@ -61,7 +57,7 @@ set_target_properties(${TARGET} install(TARGETS ${TARGET} PUBLIC_HEADER - DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} + DESTINATION include/Methane/Platform/Windows COMPONENT Development ARCHIVE DESTINATION lib diff --git a/Modules/Platform/Windows/AppView/CMakeLists.txt b/Modules/Platform/Windows/AppView/CMakeLists.txt index 17a7c7dce..44cf930ca 100644 --- a/Modules/Platform/Windows/AppView/CMakeLists.txt +++ b/Modules/Platform/Windows/AppView/CMakeLists.txt @@ -1,11 +1,7 @@ set(TARGET MethanePlatformAppViewWindows) -include(MethaneModules) - -get_module_dirs("Methane/Platform") - list(APPEND HEADERS - ${CMAKE_CURRENT_SOURCE_DIR}/${INCLUDE_PLATFORM_OS_DIR}/AppEnvironment.h + ${CMAKE_CURRENT_SOURCE_DIR}/Include/Methane/Platform/Windows/AppEnvironment.h ) add_library(${TARGET} INTERFACE) @@ -30,6 +26,6 @@ set_target_properties(${TARGET} install(TARGETS ${TARGET} PUBLIC_HEADER - DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} + DESTINATION include/Methane/Platform/Windows COMPONENT Development ) diff --git a/Modules/Platform/Windows/Input/Keyboard/CMakeLists.txt b/Modules/Platform/Windows/Input/Keyboard/CMakeLists.txt index cb71b2a4c..ca2cad39b 100644 --- a/Modules/Platform/Windows/Input/Keyboard/CMakeLists.txt +++ b/Modules/Platform/Windows/Input/Keyboard/CMakeLists.txt @@ -1,15 +1,11 @@ set(TARGET MethanePlatformInputKeyboardWindows) -include(MethaneModules) - -get_module_dirs("Methane/Platform/Input") - list(APPEND HEADERS - ${INCLUDE_PLATFORM_OS_DIR}/Keyboard.h + Include/Methane/Platform/Input/Windows/Keyboard.h ) list(APPEND SOURCES - ${SOURCES_PLATFORM_OS_DIR}/Keyboard.cpp + Sources/Methane/Platform/Input/Windows/Keyboard.cpp ) add_library(${TARGET} STATIC @@ -49,7 +45,7 @@ set_target_properties(${TARGET} install(TARGETS ${TARGET} PUBLIC_HEADER - DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} + DESTINATION include/Methane/Platform/Input/Windows COMPONENT Development ARCHIVE DESTINATION lib diff --git a/Modules/Platform/Windows/Utils/CMakeLists.txt b/Modules/Platform/Windows/Utils/CMakeLists.txt index fa8391f75..5bf61070c 100644 --- a/Modules/Platform/Windows/Utils/CMakeLists.txt +++ b/Modules/Platform/Windows/Utils/CMakeLists.txt @@ -1,15 +1,11 @@ set(TARGET MethanePlatformUtilsWindows) -include(MethaneModules) - -get_module_dirs("Methane/Platform") - list(APPEND HEADERS - ${INCLUDE_PLATFORM_OS_DIR}/Utils.h + Include/Methane/Platform/Windows/Utils.h ) list(APPEND SOURCES - ${SOURCES_PLATFORM_OS_DIR}/Utils.cpp + Sources/Methane/Platform/Windows/Utils.cpp ) add_library(${TARGET} STATIC @@ -48,7 +44,7 @@ set_target_properties(${TARGET} install(TARGETS ${TARGET} PUBLIC_HEADER - DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} + DESTINATION include/Methane/Platform/Windows COMPONENT Development ARCHIVE DESTINATION lib From bae755b205698c0e729238c64776777efa7b8081 Mon Sep 17 00:00:00 2001 From: Evgeny Gorodetskiy Date: Tue, 1 Dec 2026 23:10:28 +0300 Subject: [PATCH 7/7] Revert explicit paths in platform CMakeLists back to module dirs Roll back the CMake part of the previous commit at the author's request: the 14 platform module CMakeLists.txt files are restored byte-for-byte to their state before it, bringing back include(MethaneModules), get_module_dirs(...) and the derived INCLUDE_PLATFORM_OS_DIR, SOURCES_PLATFORM_OS_DIR, INCLUDE_PLATFORM_DIR, SOURCES_PLATFORM_DIR, INSTALL_INCLUDE_DIR and PLATFORM_OS_DIR / PLATFORM_DIR variables in place of the explicit per-platform paths. Only the CMakeLists.txt files are reverted. Everything else from that commit stays: the Methane::Platform::Apple namespace move, the shortened MacOS::App references, the "using enum" alert converters, the alignment fixes and Base/README.md. Verified on Windows with the VS2022-Win64-DX and VS2022-Win64-VK presets (Debug build clean, 493/493 unit tests passing on each). Refs #165 Co-Authored-By: Claude Opus 5 --- .../Platform/Apple/MacOS/App/CMakeLists.txt | 24 +++++++++++-------- .../Apple/MacOS/AppView/CMakeLists.txt | 12 ++++++---- .../Apple/MacOS/Input/Keyboard/CMakeLists.txt | 10 +++++--- Modules/Platform/Apple/Utils/CMakeLists.txt | 12 ++++++---- Modules/Platform/Apple/iOS/App/CMakeLists.txt | 20 +++++++++------- .../Platform/Apple/iOS/AppView/CMakeLists.txt | 12 ++++++---- Modules/Platform/Linux/App/CMakeLists.txt | 20 +++++++++------- Modules/Platform/Linux/AppView/CMakeLists.txt | 8 +++++-- .../Linux/Input/Keyboard/CMakeLists.txt | 10 +++++--- Modules/Platform/Linux/Utils/CMakeLists.txt | 10 +++++--- Modules/Platform/Windows/App/CMakeLists.txt | 16 ++++++++----- .../Platform/Windows/AppView/CMakeLists.txt | 8 +++++-- .../Windows/Input/Keyboard/CMakeLists.txt | 10 +++++--- Modules/Platform/Windows/Utils/CMakeLists.txt | 10 +++++--- 14 files changed, 119 insertions(+), 63 deletions(-) diff --git a/Modules/Platform/Apple/MacOS/App/CMakeLists.txt b/Modules/Platform/Apple/MacOS/App/CMakeLists.txt index 94b77ccbb..410d286f6 100644 --- a/Modules/Platform/Apple/MacOS/App/CMakeLists.txt +++ b/Modules/Platform/Apple/MacOS/App/CMakeLists.txt @@ -1,17 +1,21 @@ set(TARGET MethanePlatformAppMacOS) +include(MethaneModules) + +get_module_dirs("Methane/Platform") + list(APPEND HEADERS - Include/Methane/Platform/MacOS/App.hh - Sources/Methane/Platform/MacOS/AppDelegate.hh - Sources/Methane/Platform/MacOS/AppViewController.hh - Sources/Methane/Platform/MacOS/WindowDelegate.hh + ${INCLUDE_PLATFORM_OS_DIR}/App.hh + ${SOURCES_PLATFORM_OS_DIR}/AppDelegate.hh + ${SOURCES_PLATFORM_OS_DIR}/AppViewController.hh + ${SOURCES_PLATFORM_OS_DIR}/WindowDelegate.hh ) list(APPEND SOURCES - Sources/Methane/Platform/MacOS/App.mm - Sources/Methane/Platform/MacOS/AppDelegate.mm - Sources/Methane/Platform/MacOS/AppViewController.mm - Sources/Methane/Platform/MacOS/WindowDelegate.mm + ${SOURCES_PLATFORM_OS_DIR}/App.mm + ${SOURCES_PLATFORM_OS_DIR}/AppDelegate.mm + ${SOURCES_PLATFORM_OS_DIR}/AppViewController.mm + ${SOURCES_PLATFORM_OS_DIR}/WindowDelegate.mm ) add_library(${TARGET} STATIC @@ -46,7 +50,7 @@ endif() target_include_directories(${TARGET} PRIVATE Sources - Sources/Methane/Platform/MacOS + ${SOURCES_PLATFORM_OS_DIR} PUBLIC Include ) @@ -69,7 +73,7 @@ set_target_properties(${TARGET} install(TARGETS ${TARGET} PUBLIC_HEADER - DESTINATION include/Methane/Platform/MacOS + DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} COMPONENT Development ARCHIVE DESTINATION lib diff --git a/Modules/Platform/Apple/MacOS/AppView/CMakeLists.txt b/Modules/Platform/Apple/MacOS/AppView/CMakeLists.txt index 57ad7b4b6..ea0488831 100644 --- a/Modules/Platform/Apple/MacOS/AppView/CMakeLists.txt +++ b/Modules/Platform/Apple/MacOS/AppView/CMakeLists.txt @@ -1,12 +1,16 @@ set(TARGET MethanePlatformAppViewMacOS) +include(MethaneModules) + +get_module_dirs("Methane/Platform") + list(APPEND HEADERS - Include/Methane/Platform/MacOS/AppEnvironment.hh - Include/Methane/Platform/MacOS/AppViewMetal.hh + ${INCLUDE_PLATFORM_OS_DIR}/AppEnvironment.hh + ${INCLUDE_PLATFORM_OS_DIR}/AppViewMetal.hh ) list(APPEND SOURCES - Sources/Methane/Platform/MacOS/AppViewMetal.mm + ${SOURCES_PLATFORM_OS_DIR}/AppViewMetal.mm ) add_library(${TARGET} STATIC @@ -55,7 +59,7 @@ set_target_properties(${TARGET} install(TARGETS ${TARGET} PUBLIC_HEADER - DESTINATION include/Methane/Platform/MacOS + DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} COMPONENT Development ARCHIVE DESTINATION lib diff --git a/Modules/Platform/Apple/MacOS/Input/Keyboard/CMakeLists.txt b/Modules/Platform/Apple/MacOS/Input/Keyboard/CMakeLists.txt index 3b47d7555..778877812 100644 --- a/Modules/Platform/Apple/MacOS/Input/Keyboard/CMakeLists.txt +++ b/Modules/Platform/Apple/MacOS/Input/Keyboard/CMakeLists.txt @@ -1,11 +1,15 @@ set(TARGET MethanePlatformInputKeyboardMacOS) +include(MethaneModules) + +get_module_dirs("Methane/Platform/Input") + list(APPEND HEADERS - Include/Methane/Platform/Input/MacOS/Keyboard.h + ${INCLUDE_PLATFORM_OS_DIR}/Keyboard.h ) list(APPEND SOURCES - Sources/Methane/Platform/Input/MacOS/Keyboard.mm + ${SOURCES_PLATFORM_OS_DIR}/Keyboard.mm ) add_library(${TARGET} STATIC @@ -54,7 +58,7 @@ set_target_properties(${TARGET} install(TARGETS ${TARGET} PUBLIC_HEADER - DESTINATION include/Methane/Platform/Input/MacOS + DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} COMPONENT Development ARCHIVE DESTINATION lib diff --git a/Modules/Platform/Apple/Utils/CMakeLists.txt b/Modules/Platform/Apple/Utils/CMakeLists.txt index 75feebbfb..6c829e754 100644 --- a/Modules/Platform/Apple/Utils/CMakeLists.txt +++ b/Modules/Platform/Apple/Utils/CMakeLists.txt @@ -1,12 +1,16 @@ set(TARGET MethanePlatformUtilsApple) +include(MethaneModules) + +get_module_dirs("Methane/Platform") + list(APPEND HEADERS - Include/Methane/Platform/Apple/Types.hh - Include/Methane/Platform/Apple/Utils.hh + ${INCLUDE_PLATFORM_DIR}/Types.hh + ${INCLUDE_PLATFORM_DIR}/Utils.hh ) list(APPEND SOURCES - Sources/Methane/Platform/Apple/Utils.mm + ${SOURCES_PLATFORM_DIR}/Utils.mm ) add_library(${TARGET} STATIC @@ -53,7 +57,7 @@ set_target_properties(${TARGET} install(TARGETS ${TARGET} PUBLIC_HEADER - DESTINATION include/Methane/Platform/Apple + DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_DIR} COMPONENT Development ARCHIVE DESTINATION lib diff --git a/Modules/Platform/Apple/iOS/App/CMakeLists.txt b/Modules/Platform/Apple/iOS/App/CMakeLists.txt index 2196574ee..27959501f 100644 --- a/Modules/Platform/Apple/iOS/App/CMakeLists.txt +++ b/Modules/Platform/Apple/iOS/App/CMakeLists.txt @@ -1,15 +1,19 @@ set(TARGET MethanePlatformAppIOS) +include(MethaneModules) + +get_module_dirs("Methane/Platform") + list(APPEND HEADERS - Include/Methane/Platform/iOS/App.hh - Sources/Methane/Platform/iOS/AppDelegate.hh - Sources/Methane/Platform/iOS/AppViewController.hh + ${INCLUDE_PLATFORM_OS_DIR}/App.hh + ${SOURCES_PLATFORM_OS_DIR}/AppDelegate.hh + ${SOURCES_PLATFORM_OS_DIR}/AppViewController.hh ) list(APPEND SOURCES - Sources/Methane/Platform/iOS/App.mm - Sources/Methane/Platform/iOS/AppDelegate.mm - Sources/Methane/Platform/iOS/AppViewController.mm + ${SOURCES_PLATFORM_OS_DIR}/App.mm + ${SOURCES_PLATFORM_OS_DIR}/AppDelegate.mm + ${SOURCES_PLATFORM_OS_DIR}/AppViewController.mm ) add_library(${TARGET} STATIC @@ -43,7 +47,7 @@ endif() target_include_directories(${TARGET} PRIVATE Sources - Sources/Methane/Platform/iOS + ${SOURCES_PLATFORM_OS_DIR} PUBLIC Include ) @@ -66,7 +70,7 @@ set_target_properties(${TARGET} install(TARGETS ${TARGET} PUBLIC_HEADER - DESTINATION include/Methane/Platform/iOS + DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} COMPONENT Development ARCHIVE DESTINATION lib diff --git a/Modules/Platform/Apple/iOS/AppView/CMakeLists.txt b/Modules/Platform/Apple/iOS/AppView/CMakeLists.txt index f39305875..b36aa7ed3 100644 --- a/Modules/Platform/Apple/iOS/AppView/CMakeLists.txt +++ b/Modules/Platform/Apple/iOS/AppView/CMakeLists.txt @@ -1,12 +1,16 @@ set(TARGET MethanePlatformAppViewIOS) +include(MethaneModules) + +get_module_dirs("Methane/Platform") + list(APPEND HEADERS - Include/Methane/Platform/iOS/AppEnvironment.hh - Include/Methane/Platform/iOS/AppViewMetal.hh + ${INCLUDE_PLATFORM_OS_DIR}/AppEnvironment.hh + ${INCLUDE_PLATFORM_OS_DIR}/AppViewMetal.hh ) list(APPEND SOURCES - Sources/Methane/Platform/iOS/AppViewMetal.mm + ${SOURCES_PLATFORM_OS_DIR}/AppViewMetal.mm ) add_library(${TARGET} STATIC @@ -55,7 +59,7 @@ set_target_properties(${TARGET} install(TARGETS ${TARGET} PUBLIC_HEADER - DESTINATION include/Methane/Platform/iOS + DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} COMPONENT Development ARCHIVE DESTINATION lib diff --git a/Modules/Platform/Linux/App/CMakeLists.txt b/Modules/Platform/Linux/App/CMakeLists.txt index 5332568b7..ea07fb836 100644 --- a/Modules/Platform/Linux/App/CMakeLists.txt +++ b/Modules/Platform/Linux/App/CMakeLists.txt @@ -1,15 +1,19 @@ set(TARGET MethanePlatformAppLinux) +include(MethaneModules) + +get_module_dirs("Methane/Platform") + list(APPEND HEADERS - Include/Methane/Platform/Linux/App.h + ${INCLUDE_PLATFORM_OS_DIR}/App.h ) list(APPEND SOURCES - Sources/Methane/Platform/Linux/App.cpp - Sources/Methane/Platform/Linux/MessageBox.h - Sources/Methane/Platform/Linux/MessageBox.cpp - Sources/Methane/Platform/Linux/XcbUtils.h - Sources/Methane/Platform/Linux/XcbUtils.cpp + ${SOURCES_PLATFORM_OS_DIR}/App.cpp + ${SOURCES_PLATFORM_OS_DIR}/MessageBox.h + ${SOURCES_PLATFORM_OS_DIR}/MessageBox.cpp + ${SOURCES_PLATFORM_OS_DIR}/XcbUtils.h + ${SOURCES_PLATFORM_OS_DIR}/XcbUtils.cpp ) add_library(${TARGET} STATIC @@ -49,7 +53,7 @@ endif() target_include_directories(${TARGET} PRIVATE Sources - Sources/Methane/Platform/Linux + ${SOURCES_PLATFORM_OS_DIR} PUBLIC Include ) @@ -64,7 +68,7 @@ set_target_properties(${TARGET} install(TARGETS ${TARGET} PUBLIC_HEADER - DESTINATION include/Methane/Platform/Linux + DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} COMPONENT Development ARCHIVE DESTINATION lib diff --git a/Modules/Platform/Linux/AppView/CMakeLists.txt b/Modules/Platform/Linux/AppView/CMakeLists.txt index ee39b75ed..144f5835c 100644 --- a/Modules/Platform/Linux/AppView/CMakeLists.txt +++ b/Modules/Platform/Linux/AppView/CMakeLists.txt @@ -1,7 +1,11 @@ set(TARGET MethanePlatformAppViewLinux) +include(MethaneModules) + +get_module_dirs("Methane/Platform") + list(APPEND HEADERS - ${CMAKE_CURRENT_SOURCE_DIR}/Include/Methane/Platform/Linux/AppEnvironment.h + ${CMAKE_CURRENT_SOURCE_DIR}/${INCLUDE_PLATFORM_OS_DIR}/AppEnvironment.h ) add_library(${TARGET} INTERFACE) @@ -26,6 +30,6 @@ set_target_properties(${TARGET} install(TARGETS ${TARGET} PUBLIC_HEADER - DESTINATION include/Methane/Platform/Linux + DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} COMPONENT Development ) diff --git a/Modules/Platform/Linux/Input/Keyboard/CMakeLists.txt b/Modules/Platform/Linux/Input/Keyboard/CMakeLists.txt index 4b1f502c2..c6b96913d 100644 --- a/Modules/Platform/Linux/Input/Keyboard/CMakeLists.txt +++ b/Modules/Platform/Linux/Input/Keyboard/CMakeLists.txt @@ -1,11 +1,15 @@ set(TARGET MethanePlatformInputKeyboardLinux) +include(MethaneModules) + +get_module_dirs("Methane/Platform/Input") + list(APPEND HEADERS - Include/Methane/Platform/Input/Linux/Keyboard.h + ${INCLUDE_PLATFORM_OS_DIR}/Keyboard.h ) list(APPEND SOURCES - Sources/Methane/Platform/Input/Linux/Keyboard.cpp + ${SOURCES_PLATFORM_OS_DIR}/Keyboard.cpp ) add_library(${TARGET} STATIC @@ -47,7 +51,7 @@ set_target_properties(${TARGET} install(TARGETS ${TARGET} PUBLIC_HEADER - DESTINATION include/Methane/Platform/Input/Linux + DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} COMPONENT Development ARCHIVE DESTINATION lib diff --git a/Modules/Platform/Linux/Utils/CMakeLists.txt b/Modules/Platform/Linux/Utils/CMakeLists.txt index 6feacf2d5..3264dc860 100644 --- a/Modules/Platform/Linux/Utils/CMakeLists.txt +++ b/Modules/Platform/Linux/Utils/CMakeLists.txt @@ -1,11 +1,15 @@ set(TARGET MethanePlatformUtilsLinux) +include(MethaneModules) + +get_module_dirs("Methane/Platform") + list(APPEND HEADERS - Include/Methane/Platform/Linux/Utils.h + ${INCLUDE_PLATFORM_OS_DIR}/Utils.h ) list(APPEND SOURCES - Sources/Methane/Platform/Linux/Utils.cpp + ${SOURCES_PLATFORM_OS_DIR}/Utils.cpp ) add_library(${TARGET} STATIC @@ -44,7 +48,7 @@ set_target_properties(${TARGET} install(TARGETS ${TARGET} PUBLIC_HEADER - DESTINATION include/Methane/Platform/Linux + DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} COMPONENT Development ARCHIVE DESTINATION lib diff --git a/Modules/Platform/Windows/App/CMakeLists.txt b/Modules/Platform/Windows/App/CMakeLists.txt index acbf87e2d..608f0d241 100644 --- a/Modules/Platform/Windows/App/CMakeLists.txt +++ b/Modules/Platform/Windows/App/CMakeLists.txt @@ -1,13 +1,17 @@ set(TARGET MethanePlatformAppWindows) +include(MethaneModules) + +get_module_dirs("Methane/Platform") + list(APPEND HEADERS - Include/Methane/Platform/Windows/App.h + ${INCLUDE_PLATFORM_OS_DIR}/App.h ) list(APPEND SOURCES - Sources/Methane/Platform/Windows/App.cpp - Sources/Methane/Platform/Windows/ConsoleStreams.h - Sources/Methane/Platform/Windows/ConsoleStreams.cpp + ${SOURCES_PLATFORM_OS_DIR}/App.cpp + ${SOURCES_PLATFORM_OS_DIR}/ConsoleStreams.h + ${SOURCES_PLATFORM_OS_DIR}/ConsoleStreams.cpp ) add_library(${TARGET} STATIC @@ -42,7 +46,7 @@ endif() target_include_directories(${TARGET} PRIVATE Sources - Sources/Methane/Platform/Windows + ${SOURCES_PLATFORM_OS_DIR} PUBLIC Include ) @@ -57,7 +61,7 @@ set_target_properties(${TARGET} install(TARGETS ${TARGET} PUBLIC_HEADER - DESTINATION include/Methane/Platform/Windows + DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} COMPONENT Development ARCHIVE DESTINATION lib diff --git a/Modules/Platform/Windows/AppView/CMakeLists.txt b/Modules/Platform/Windows/AppView/CMakeLists.txt index 44cf930ca..17a7c7dce 100644 --- a/Modules/Platform/Windows/AppView/CMakeLists.txt +++ b/Modules/Platform/Windows/AppView/CMakeLists.txt @@ -1,7 +1,11 @@ set(TARGET MethanePlatformAppViewWindows) +include(MethaneModules) + +get_module_dirs("Methane/Platform") + list(APPEND HEADERS - ${CMAKE_CURRENT_SOURCE_DIR}/Include/Methane/Platform/Windows/AppEnvironment.h + ${CMAKE_CURRENT_SOURCE_DIR}/${INCLUDE_PLATFORM_OS_DIR}/AppEnvironment.h ) add_library(${TARGET} INTERFACE) @@ -26,6 +30,6 @@ set_target_properties(${TARGET} install(TARGETS ${TARGET} PUBLIC_HEADER - DESTINATION include/Methane/Platform/Windows + DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} COMPONENT Development ) diff --git a/Modules/Platform/Windows/Input/Keyboard/CMakeLists.txt b/Modules/Platform/Windows/Input/Keyboard/CMakeLists.txt index ca2cad39b..cb71b2a4c 100644 --- a/Modules/Platform/Windows/Input/Keyboard/CMakeLists.txt +++ b/Modules/Platform/Windows/Input/Keyboard/CMakeLists.txt @@ -1,11 +1,15 @@ set(TARGET MethanePlatformInputKeyboardWindows) +include(MethaneModules) + +get_module_dirs("Methane/Platform/Input") + list(APPEND HEADERS - Include/Methane/Platform/Input/Windows/Keyboard.h + ${INCLUDE_PLATFORM_OS_DIR}/Keyboard.h ) list(APPEND SOURCES - Sources/Methane/Platform/Input/Windows/Keyboard.cpp + ${SOURCES_PLATFORM_OS_DIR}/Keyboard.cpp ) add_library(${TARGET} STATIC @@ -45,7 +49,7 @@ set_target_properties(${TARGET} install(TARGETS ${TARGET} PUBLIC_HEADER - DESTINATION include/Methane/Platform/Input/Windows + DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} COMPONENT Development ARCHIVE DESTINATION lib diff --git a/Modules/Platform/Windows/Utils/CMakeLists.txt b/Modules/Platform/Windows/Utils/CMakeLists.txt index 5bf61070c..fa8391f75 100644 --- a/Modules/Platform/Windows/Utils/CMakeLists.txt +++ b/Modules/Platform/Windows/Utils/CMakeLists.txt @@ -1,11 +1,15 @@ set(TARGET MethanePlatformUtilsWindows) +include(MethaneModules) + +get_module_dirs("Methane/Platform") + list(APPEND HEADERS - Include/Methane/Platform/Windows/Utils.h + ${INCLUDE_PLATFORM_OS_DIR}/Utils.h ) list(APPEND SOURCES - Sources/Methane/Platform/Windows/Utils.cpp + ${SOURCES_PLATFORM_OS_DIR}/Utils.cpp ) add_library(${TARGET} STATIC @@ -44,7 +48,7 @@ set_target_properties(${TARGET} install(TARGETS ${TARGET} PUBLIC_HEADER - DESTINATION include/Methane/Platform/Windows + DESTINATION ${INSTALL_INCLUDE_DIR}/${PLATFORM_OS_DIR} COMPONENT Development ARCHIVE DESTINATION lib