Signed-off-by: falkTX <falktx@falktx.com>tags/v2.1-rc1
| @@ -1192,47 +1192,52 @@ typedef enum { | |||
| */ | |||
| ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR = 19, | |||
| /*! | |||
| * Set UI scaling used in frontend, so backend can do the same for plugin UIs. | |||
| */ | |||
| ENGINE_OPTION_FRONTEND_UI_SCALE = 20, | |||
| /*! | |||
| * Set frontend winId, used to define as parent window for plugin UIs. | |||
| */ | |||
| ENGINE_OPTION_FRONTEND_WIN_ID = 20, | |||
| ENGINE_OPTION_FRONTEND_WIN_ID = 21, | |||
| #if !defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) && !defined(CARLA_OS_WIN) | |||
| /*! | |||
| * Set path to wine executable. | |||
| */ | |||
| ENGINE_OPTION_WINE_EXECUTABLE = 21, | |||
| ENGINE_OPTION_WINE_EXECUTABLE = 22, | |||
| /*! | |||
| * Enable automatic wineprefix detection. | |||
| */ | |||
| ENGINE_OPTION_WINE_AUTO_PREFIX = 22, | |||
| ENGINE_OPTION_WINE_AUTO_PREFIX = 23, | |||
| /*! | |||
| * Fallback wineprefix to use if automatic detection fails or is disabled, and WINEPREFIX is not set. | |||
| */ | |||
| ENGINE_OPTION_WINE_FALLBACK_PREFIX = 23, | |||
| ENGINE_OPTION_WINE_FALLBACK_PREFIX = 24, | |||
| /*! | |||
| * Enable realtime priority for Wine application and server threads. | |||
| */ | |||
| ENGINE_OPTION_WINE_RT_PRIO_ENABLED = 24, | |||
| ENGINE_OPTION_WINE_RT_PRIO_ENABLED = 25, | |||
| /*! | |||
| * Base realtime priority for Wine threads. | |||
| */ | |||
| ENGINE_OPTION_WINE_BASE_RT_PRIO = 25, | |||
| ENGINE_OPTION_WINE_BASE_RT_PRIO = 26, | |||
| /*! | |||
| * Wine server realtime priority. | |||
| */ | |||
| ENGINE_OPTION_WINE_SERVER_RT_PRIO = 26, | |||
| ENGINE_OPTION_WINE_SERVER_RT_PRIO = 27, | |||
| #endif | |||
| /*! | |||
| * Capture console output into debug callbacks. | |||
| */ | |||
| ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT = 27 | |||
| ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT = 28 | |||
| } EngineOption; | |||
| @@ -228,6 +228,7 @@ struct CARLA_API EngineOptions { | |||
| bool preferPluginBridges; | |||
| bool preferUiBridges; | |||
| bool uisAlwaysOnTop; | |||
| float uiScale; | |||
| uint maxParameters; | |||
| uint uiBridgesTimeout; | |||
| @@ -286,6 +286,8 @@ static void carla_engine_init_common(CarlaEngine* const engine) | |||
| engine->setOption(CB::ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR, gStandalone.engineOptions.preventBadBehaviour ? 1 : 0, nullptr); | |||
| engine->setOption(CB::ENGINE_OPTION_FRONTEND_UI_SCALE, static_cast<int>(gStandalone.engineOptions.uiScale * 1000.0f), nullptr); | |||
| if (gStandalone.engineOptions.frontendWinId != 0) | |||
| { | |||
| char strBuf[STR_MAX+1]; | |||
| @@ -690,6 +692,11 @@ void carla_set_engine_option(EngineOption option, int value, const char* valueSt | |||
| gStandalone.engineOptions.preventBadBehaviour = (value != 0); | |||
| break; | |||
| case CB::ENGINE_OPTION_FRONTEND_UI_SCALE: | |||
| CARLA_SAFE_ASSERT_RETURN(value > 0,); | |||
| gStandalone.engineOptions.uiScale = static_cast<float>(value) / 1000; | |||
| break; | |||
| case CB::ENGINE_OPTION_FRONTEND_WIN_ID: { | |||
| CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',); | |||
| const long long winId(std::strtoll(valueStr, nullptr, 16)); | |||
| @@ -1790,6 +1790,11 @@ void CarlaEngine::setOption(const EngineOption option, const int value, const ch | |||
| #endif | |||
| } break; | |||
| case ENGINE_OPTION_FRONTEND_UI_SCALE: | |||
| CARLA_SAFE_ASSERT_RETURN(value > 0,); | |||
| pData->options.uiScale = static_cast<float>(value) / 1000; | |||
| break; | |||
| case ENGINE_OPTION_FRONTEND_WIN_ID: { | |||
| CARLA_SAFE_ASSERT_RETURN(valueStr != nullptr && valueStr[0] != '\0',); | |||
| const long long winId(std::strtoll(valueStr, nullptr, 16)); | |||
| @@ -191,6 +191,7 @@ EngineOptions::EngineOptions() noexcept | |||
| preferUiBridges(true), | |||
| #endif | |||
| uisAlwaysOnTop(true), | |||
| uiScale(1.0f), | |||
| maxParameters(MAX_DEFAULT_PARAMETERS), | |||
| uiBridgesTimeout(4000), | |||
| audioBufferSize(512), | |||
| @@ -137,6 +137,7 @@ enum CarlaLv2URIDs { | |||
| kUridCarlaAtomWorkerIn, | |||
| kUridCarlaAtomWorkerResp, | |||
| kUridCarlaTransientWindowId, | |||
| kUridCarlaUiScale, | |||
| kUridCount | |||
| }; | |||
| @@ -315,6 +316,7 @@ struct CarlaPluginLV2Options { | |||
| SequenceSize, | |||
| SampleRate, | |||
| TransientWinId, | |||
| UiScale, | |||
| WindowTitle, | |||
| Null, | |||
| Count | |||
| @@ -326,6 +328,7 @@ struct CarlaPluginLV2Options { | |||
| int sequenceSize; | |||
| float sampleRate; | |||
| int64_t transientWinId; | |||
| float uiScale; | |||
| const char* windowTitle; | |||
| LV2_Options_Option opts[Count]; | |||
| @@ -336,6 +339,7 @@ struct CarlaPluginLV2Options { | |||
| sequenceSize(MAX_DEFAULT_BUFFER_SIZE), | |||
| sampleRate(0.0), | |||
| transientWinId(0), | |||
| uiScale(1.0f), | |||
| windowTitle(nullptr) | |||
| { | |||
| LV2_Options_Option& optMaxBlockLenth(opts[MaxBlockLenth]); | |||
| @@ -370,6 +374,14 @@ struct CarlaPluginLV2Options { | |||
| optSequenceSize.type = kUridAtomInt; | |||
| optSequenceSize.value = &sequenceSize; | |||
| LV2_Options_Option& optUiScale(opts[UiScale]); | |||
| optUiScale.context = LV2_OPTIONS_INSTANCE; | |||
| optUiScale.subject = 0; | |||
| optUiScale.key = kUridParamSampleRate; | |||
| optUiScale.size = sizeof(float); | |||
| optUiScale.type = kUridAtomFloat; | |||
| optUiScale.value = &uiScale; | |||
| LV2_Options_Option& optSampleRate(opts[SampleRate]); | |||
| optSampleRate.context = LV2_OPTIONS_INSTANCE; | |||
| optSampleRate.subject = 0; | |||
| @@ -6604,6 +6616,8 @@ private: | |||
| return kUridCarlaAtomWorkerResp; | |||
| if (std::strcmp(uri, LV2_KXSTUDIO_PROPERTIES__TransientWindowId) == 0) | |||
| return kUridCarlaTransientWindowId; | |||
| if (std::strcmp(uri, "urn:carla:scale") == 0) | |||
| return kUridCarlaUiScale; | |||
| // Custom plugin types | |||
| return ((CarlaPluginLV2*)handle)->getCustomURID(uri); | |||
| @@ -6732,6 +6746,8 @@ private: | |||
| return URI_CARLA_ATOM_WORKER_RESP; | |||
| case kUridCarlaTransientWindowId: | |||
| return LV2_KXSTUDIO_PROPERTIES__TransientWindowId; | |||
| case kUridCarlaUiScale: | |||
| return "urn:carla:scale"; | |||
| } | |||
| // Custom plugin types | |||
| @@ -97,6 +97,7 @@ enum CarlaLv2URIDs { | |||
| kUridCarlaAtomWorkerIn, | |||
| kUridCarlaAtomWorkerResp, | |||
| kUridCarlaTransientWindowId, | |||
| kUridCarlaUiScale, | |||
| kUridCount | |||
| }; | |||
| @@ -130,6 +131,7 @@ struct Lv2PluginOptions { | |||
| enum OptIndex { | |||
| SampleRate, | |||
| TransientWinId, | |||
| UiScale, | |||
| WindowTitle, | |||
| Null, | |||
| Count | |||
| @@ -137,12 +139,14 @@ struct Lv2PluginOptions { | |||
| float sampleRate; | |||
| int64_t transientWinId; | |||
| float uiScale; | |||
| const char* windowTitle; | |||
| LV2_Options_Option opts[Count]; | |||
| Lv2PluginOptions() noexcept | |||
| : sampleRate(static_cast<float>(gInitialSampleRate)), | |||
| transientWinId(0), | |||
| uiScale(1.0f), | |||
| windowTitle(kNullWindowTitle) | |||
| { | |||
| LV2_Options_Option& optSampleRate(opts[SampleRate]); | |||
| @@ -153,6 +157,14 @@ struct Lv2PluginOptions { | |||
| optSampleRate.type = kUridAtomFloat; | |||
| optSampleRate.value = &sampleRate; | |||
| LV2_Options_Option& optUiScale(opts[UiScale]); | |||
| optUiScale.context = LV2_OPTIONS_INSTANCE; | |||
| optUiScale.subject = 0; | |||
| optUiScale.key = kUridParamSampleRate; | |||
| optUiScale.size = sizeof(float); | |||
| optUiScale.type = kUridCarlaUiScale; | |||
| optUiScale.value = &uiScale; | |||
| LV2_Options_Option& optTransientWinId(opts[TransientWinId]); | |||
| optTransientWinId.context = LV2_OPTIONS_INSTANCE; | |||
| optTransientWinId.subject = 0; | |||
| @@ -862,29 +862,32 @@ ENGINE_OPTION_PATH_RESOURCES = 18 | |||
| # @note: Linux only | |||
| ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR = 19 | |||
| # Set UI scaling used in frontend, so backend can do the same for plugin UIs. | |||
| ENGINE_OPTION_FRONTEND_UI_SCALE = 20 | |||
| # Set frontend winId, used to define as parent window for plugin UIs. | |||
| ENGINE_OPTION_FRONTEND_WIN_ID = 20 | |||
| ENGINE_OPTION_FRONTEND_WIN_ID = 21 | |||
| # Set path to wine executable. | |||
| ENGINE_OPTION_WINE_EXECUTABLE = 21 | |||
| ENGINE_OPTION_WINE_EXECUTABLE = 22 | |||
| # Enable automatic wineprefix detection. | |||
| ENGINE_OPTION_WINE_AUTO_PREFIX = 22 | |||
| ENGINE_OPTION_WINE_AUTO_PREFIX = 23 | |||
| # Fallback wineprefix to use if automatic detection fails or is disabled, and WINEPREFIX is not set. | |||
| ENGINE_OPTION_WINE_FALLBACK_PREFIX = 23 | |||
| ENGINE_OPTION_WINE_FALLBACK_PREFIX = 24 | |||
| # Enable realtime priority for Wine application and server threads. | |||
| ENGINE_OPTION_WINE_RT_PRIO_ENABLED = 24 | |||
| ENGINE_OPTION_WINE_RT_PRIO_ENABLED = 25 | |||
| # Base realtime priority for Wine threads. | |||
| ENGINE_OPTION_WINE_BASE_RT_PRIO = 25 | |||
| ENGINE_OPTION_WINE_BASE_RT_PRIO = 26 | |||
| # Wine server realtime priority. | |||
| ENGINE_OPTION_WINE_SERVER_RT_PRIO = 26 | |||
| ENGINE_OPTION_WINE_SERVER_RT_PRIO = 27 | |||
| # Capture console output into debug callbacks | |||
| ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT = 27 | |||
| ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT = 28 | |||
| # ------------------------------------------------------------------------------------------------------------ | |||
| # Engine Process Mode | |||
| @@ -2329,6 +2329,8 @@ class HostWindow(QMainWindow): | |||
| self.refreshTransport(True) | |||
| QMainWindow.showEvent(self, event) | |||
| self.host.set_engine_option(ENGINE_OPTION_FRONTEND_UI_SCALE, int(self.devicePixelRatioF() * 1000), "") | |||
| # set our gui as parent for all plugins UIs | |||
| if self.host.manageUIs and not (self.host.isControl or self.host.isPlugin): | |||
| if MACOS: | |||
| @@ -337,6 +337,8 @@ const char* EngineOption2Str(const EngineOption option) noexcept | |||
| return "ENGINE_OPTION_PATH_RESOURCES"; | |||
| case ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR: | |||
| return "ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR"; | |||
| case ENGINE_OPTION_FRONTEND_UI_SCALE: | |||
| return "ENGINE_OPTION_FRONTEND_UI_SCALE"; | |||
| case ENGINE_OPTION_FRONTEND_WIN_ID: | |||
| return "ENGINE_OPTION_FRONTEND_WIN_ID"; | |||
| #if !defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) && !defined(CARLA_OS_WIN) | |||