Browse Source

Testing: Send UI scale to lv2 uis

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.1-rc1
falkTX 5 years ago
parent
commit
269356b881
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
10 changed files with 70 additions and 16 deletions
  1. +13
    -8
      source/backend/CarlaBackend.h
  2. +1
    -0
      source/backend/CarlaEngine.hpp
  3. +7
    -0
      source/backend/CarlaStandalone.cpp
  4. +5
    -0
      source/backend/engine/CarlaEngine.cpp
  5. +1
    -0
      source/backend/engine/CarlaEngineData.cpp
  6. +16
    -0
      source/backend/plugin/CarlaPluginLV2.cpp
  7. +12
    -0
      source/bridges-ui/CarlaBridgeFormatLV2.cpp
  8. +11
    -8
      source/frontend/carla_backend.py
  9. +2
    -0
      source/frontend/carla_host.py
  10. +2
    -0
      source/utils/CarlaBackendUtils.hpp

+ 13
- 8
source/backend/CarlaBackend.h View File

@@ -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;



+ 1
- 0
source/backend/CarlaEngine.hpp View File

@@ -228,6 +228,7 @@ struct CARLA_API EngineOptions {
bool preferPluginBridges;
bool preferUiBridges;
bool uisAlwaysOnTop;
float uiScale;

uint maxParameters;
uint uiBridgesTimeout;


+ 7
- 0
source/backend/CarlaStandalone.cpp View File

@@ -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));


+ 5
- 0
source/backend/engine/CarlaEngine.cpp View File

@@ -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));


+ 1
- 0
source/backend/engine/CarlaEngineData.cpp View File

@@ -191,6 +191,7 @@ EngineOptions::EngineOptions() noexcept
preferUiBridges(true),
#endif
uisAlwaysOnTop(true),
uiScale(1.0f),
maxParameters(MAX_DEFAULT_PARAMETERS),
uiBridgesTimeout(4000),
audioBufferSize(512),


+ 16
- 0
source/backend/plugin/CarlaPluginLV2.cpp View File

@@ -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


+ 12
- 0
source/bridges-ui/CarlaBridgeFormatLV2.cpp View File

@@ -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;


+ 11
- 8
source/frontend/carla_backend.py View File

@@ -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


+ 2
- 0
source/frontend/carla_host.py View File

@@ -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:


+ 2
- 0
source/utils/CarlaBackendUtils.hpp View File

@@ -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)


Loading…
Cancel
Save