Signed-off-by: falkTX <falktx@falktx.com>tags/v2.1-rc2
@@ -1357,51 +1357,61 @@ typedef enum { | |||||
ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR = 22, | ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR = 22, | ||||
/*! | /*! | ||||
* Set UI scaling used in frontend, so backend can do the same for plugin UIs. | |||||
* Set background color used in the frontend, so backend can do the same for plugin UIs. | |||||
*/ | */ | ||||
ENGINE_OPTION_FRONTEND_UI_SCALE = 23, | |||||
ENGINE_OPTION_FRONTEND_BACKGROUND_COLOR = 23, | |||||
/*! | |||||
* Set foreground color used in the frontend, so backend can do the same for plugin UIs. | |||||
*/ | |||||
ENGINE_OPTION_FRONTEND_FOREGROUND_COLOR = 24, | |||||
/*! | |||||
* Set UI scaling used in the frontend, so backend can do the same for plugin UIs. | |||||
*/ | |||||
ENGINE_OPTION_FRONTEND_UI_SCALE = 25, | |||||
/*! | /*! | ||||
* Set frontend winId, used to define as parent window for plugin UIs. | * Set frontend winId, used to define as parent window for plugin UIs. | ||||
*/ | */ | ||||
ENGINE_OPTION_FRONTEND_WIN_ID = 24, | |||||
ENGINE_OPTION_FRONTEND_WIN_ID = 26, | |||||
#if !defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) && !defined(CARLA_OS_WIN) | #if !defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) && !defined(CARLA_OS_WIN) | ||||
/*! | /*! | ||||
* Set path to wine executable. | * Set path to wine executable. | ||||
*/ | */ | ||||
ENGINE_OPTION_WINE_EXECUTABLE = 25, | |||||
ENGINE_OPTION_WINE_EXECUTABLE = 27, | |||||
/*! | /*! | ||||
* Enable automatic wineprefix detection. | * Enable automatic wineprefix detection. | ||||
*/ | */ | ||||
ENGINE_OPTION_WINE_AUTO_PREFIX = 26, | |||||
ENGINE_OPTION_WINE_AUTO_PREFIX = 28, | |||||
/*! | /*! | ||||
* Fallback wineprefix to use if automatic detection fails or is disabled, and WINEPREFIX is not set. | * Fallback wineprefix to use if automatic detection fails or is disabled, and WINEPREFIX is not set. | ||||
*/ | */ | ||||
ENGINE_OPTION_WINE_FALLBACK_PREFIX = 27, | |||||
ENGINE_OPTION_WINE_FALLBACK_PREFIX = 29, | |||||
/*! | /*! | ||||
* Enable realtime priority for Wine application and server threads. | * Enable realtime priority for Wine application and server threads. | ||||
*/ | */ | ||||
ENGINE_OPTION_WINE_RT_PRIO_ENABLED = 28, | |||||
ENGINE_OPTION_WINE_RT_PRIO_ENABLED = 30, | |||||
/*! | /*! | ||||
* Base realtime priority for Wine threads. | * Base realtime priority for Wine threads. | ||||
*/ | */ | ||||
ENGINE_OPTION_WINE_BASE_RT_PRIO = 29, | |||||
ENGINE_OPTION_WINE_BASE_RT_PRIO = 31, | |||||
/*! | /*! | ||||
* Wine server realtime priority. | * Wine server realtime priority. | ||||
*/ | */ | ||||
ENGINE_OPTION_WINE_SERVER_RT_PRIO = 30, | |||||
ENGINE_OPTION_WINE_SERVER_RT_PRIO = 32, | |||||
#endif | #endif | ||||
/*! | /*! | ||||
* Capture console output into debug callbacks. | * Capture console output into debug callbacks. | ||||
*/ | */ | ||||
ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT = 31 | |||||
ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT = 33 | |||||
} EngineOption; | } EngineOption; | ||||
@@ -239,6 +239,8 @@ struct CARLA_API EngineOptions { | |||||
bool preferPluginBridges; | bool preferPluginBridges; | ||||
bool preferUiBridges; | bool preferUiBridges; | ||||
bool uisAlwaysOnTop; | bool uisAlwaysOnTop; | ||||
uint bgColor; | |||||
uint fgColor; | |||||
float uiScale; | float uiScale; | ||||
uint maxParameters; | uint maxParameters; | ||||
@@ -312,6 +312,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_PREVENT_BAD_BEHAVIOUR, gStandalone.engineOptions.preventBadBehaviour ? 1 : 0, nullptr); | ||||
engine->setOption(CB::ENGINE_OPTION_FRONTEND_BACKGROUND_COLOR, static_cast<int>(gStandalone.engineOptions.bgColor), nullptr); | |||||
engine->setOption(CB::ENGINE_OPTION_FRONTEND_FOREGROUND_COLOR, static_cast<int>(gStandalone.engineOptions.fgColor), nullptr); | |||||
engine->setOption(CB::ENGINE_OPTION_FRONTEND_UI_SCALE, static_cast<int>(gStandalone.engineOptions.uiScale * 1000.0f), nullptr); | engine->setOption(CB::ENGINE_OPTION_FRONTEND_UI_SCALE, static_cast<int>(gStandalone.engineOptions.uiScale * 1000.0f), nullptr); | ||||
if (gStandalone.engineOptions.frontendWinId != 0) | if (gStandalone.engineOptions.frontendWinId != 0) | ||||
@@ -848,6 +850,14 @@ void carla_set_engine_option(EngineOption option, int value, const char* valueSt | |||||
gStandalone.engineOptions.preventBadBehaviour = (value != 0); | gStandalone.engineOptions.preventBadBehaviour = (value != 0); | ||||
break; | break; | ||||
case CB::ENGINE_OPTION_FRONTEND_BACKGROUND_COLOR: | |||||
gStandalone.engineOptions.bgColor = static_cast<uint>(value); | |||||
break; | |||||
case CB::ENGINE_OPTION_FRONTEND_FOREGROUND_COLOR: | |||||
gStandalone.engineOptions.fgColor = static_cast<uint>(value); | |||||
break; | |||||
case CB::ENGINE_OPTION_FRONTEND_UI_SCALE: | case CB::ENGINE_OPTION_FRONTEND_UI_SCALE: | ||||
CARLA_SAFE_ASSERT_RETURN(value > 0,); | CARLA_SAFE_ASSERT_RETURN(value > 0,); | ||||
gStandalone.engineOptions.uiScale = static_cast<float>(value) / 1000; | gStandalone.engineOptions.uiScale = static_cast<float>(value) / 1000; | ||||
@@ -1901,6 +1901,14 @@ void CarlaEngine::setOption(const EngineOption option, const int value, const ch | |||||
#endif | #endif | ||||
} break; | } break; | ||||
case ENGINE_OPTION_FRONTEND_BACKGROUND_COLOR: | |||||
pData->options.bgColor = static_cast<uint>(value); | |||||
break; | |||||
case ENGINE_OPTION_FRONTEND_FOREGROUND_COLOR: | |||||
pData->options.fgColor = static_cast<uint>(value); | |||||
break; | |||||
case ENGINE_OPTION_FRONTEND_UI_SCALE: | case ENGINE_OPTION_FRONTEND_UI_SCALE: | ||||
CARLA_SAFE_ASSERT_RETURN(value > 0,); | CARLA_SAFE_ASSERT_RETURN(value > 0,); | ||||
pData->options.uiScale = static_cast<float>(value) / 1000; | pData->options.uiScale = static_cast<float>(value) / 1000; | ||||
@@ -192,6 +192,8 @@ EngineOptions::EngineOptions() noexcept | |||||
preferUiBridges(true), | preferUiBridges(true), | ||||
#endif | #endif | ||||
uisAlwaysOnTop(true), | uisAlwaysOnTop(true), | ||||
bgColor(0x000000ff), | |||||
fgColor(0xffffffff), | |||||
uiScale(1.0f), | uiScale(1.0f), | ||||
maxParameters(MAX_DEFAULT_PARAMETERS), | maxParameters(MAX_DEFAULT_PARAMETERS), | ||||
uiBridgesTimeout(4000), | uiBridgesTimeout(4000), | ||||
@@ -132,11 +132,16 @@ enum CarlaLv2URIDs { | |||||
kUridTimeTicksPerBeat, | kUridTimeTicksPerBeat, | ||||
kUridMidiEvent, | kUridMidiEvent, | ||||
kUridParamSampleRate, | kUridParamSampleRate, | ||||
// ui stuff | |||||
kUridBackgroundColor, | |||||
kUridForegroundColor, | |||||
kUridScaleFactor, | kUridScaleFactor, | ||||
kUridWindowTitle, | kUridWindowTitle, | ||||
// custom carla props | |||||
kUridCarlaAtomWorkerIn, | kUridCarlaAtomWorkerIn, | ||||
kUridCarlaAtomWorkerResp, | kUridCarlaAtomWorkerResp, | ||||
kUridCarlaTransientWindowId, | kUridCarlaTransientWindowId, | ||||
// count | |||||
kUridCount | kUridCount | ||||
}; | }; | ||||
@@ -316,6 +321,8 @@ struct CarlaPluginLV2Options { | |||||
SequenceSize, | SequenceSize, | ||||
SampleRate, | SampleRate, | ||||
TransientWinId, | TransientWinId, | ||||
BackgroundColor, | |||||
ForegroundColor, | |||||
ScaleFactor, | ScaleFactor, | ||||
WindowTitle, | WindowTitle, | ||||
Null, | Null, | ||||
@@ -328,6 +335,8 @@ struct CarlaPluginLV2Options { | |||||
int sequenceSize; | int sequenceSize; | ||||
float sampleRate; | float sampleRate; | ||||
int64_t transientWinId; | int64_t transientWinId; | ||||
uint32_t bgColor; | |||||
uint32_t fgColor; | |||||
float uiScale; | float uiScale; | ||||
const char* windowTitle; | const char* windowTitle; | ||||
LV2_Options_Option opts[Count]; | LV2_Options_Option opts[Count]; | ||||
@@ -339,6 +348,8 @@ struct CarlaPluginLV2Options { | |||||
sequenceSize(MAX_DEFAULT_BUFFER_SIZE), | sequenceSize(MAX_DEFAULT_BUFFER_SIZE), | ||||
sampleRate(0.0), | sampleRate(0.0), | ||||
transientWinId(0), | transientWinId(0), | ||||
bgColor(0x000000ff), | |||||
fgColor(0xffffffff), | |||||
uiScale(1.0f), | uiScale(1.0f), | ||||
windowTitle(nullptr) | windowTitle(nullptr) | ||||
{ | { | ||||
@@ -374,6 +385,22 @@ struct CarlaPluginLV2Options { | |||||
optSequenceSize.type = kUridAtomInt; | optSequenceSize.type = kUridAtomInt; | ||||
optSequenceSize.value = &sequenceSize; | optSequenceSize.value = &sequenceSize; | ||||
LV2_Options_Option& optBackgroundColor(opts[BackgroundColor]); | |||||
optBackgroundColor.context = LV2_OPTIONS_INSTANCE; | |||||
optBackgroundColor.subject = 0; | |||||
optBackgroundColor.key = kUridBackgroundColor; | |||||
optBackgroundColor.size = sizeof(int32_t); | |||||
optBackgroundColor.type = kUridAtomInt; | |||||
optBackgroundColor.value = &bgColor; | |||||
LV2_Options_Option& optForegroundColor(opts[ForegroundColor]); | |||||
optForegroundColor.context = LV2_OPTIONS_INSTANCE; | |||||
optForegroundColor.subject = 0; | |||||
optForegroundColor.key = kUridForegroundColor; | |||||
optForegroundColor.size = sizeof(int32_t); | |||||
optForegroundColor.type = kUridAtomInt; | |||||
optForegroundColor.value = &fgColor; | |||||
LV2_Options_Option& optScaleFactor(opts[ScaleFactor]); | LV2_Options_Option& optScaleFactor(opts[ScaleFactor]); | ||||
optScaleFactor.context = LV2_OPTIONS_INSTANCE; | optScaleFactor.context = LV2_OPTIONS_INSTANCE; | ||||
optScaleFactor.subject = 0; | optScaleFactor.subject = 0; | ||||
@@ -1576,11 +1603,21 @@ public: | |||||
if (! fPipeServer.writeMessage("uiOptions\n", 10)) | if (! fPipeServer.writeMessage("uiOptions\n", 10)) | ||||
return; | return; | ||||
const EngineOptions& opts(pData->engine->getOptions()); | |||||
std::snprintf(tmpBuf, 0xff, "%g\n", pData->engine->getSampleRate()); | std::snprintf(tmpBuf, 0xff, "%g\n", pData->engine->getSampleRate()); | ||||
if (! fPipeServer.writeMessage(tmpBuf)) | if (! fPipeServer.writeMessage(tmpBuf)) | ||||
return; | return; | ||||
std::snprintf(tmpBuf, 0xff, "%.12g\n", static_cast<double>(pData->engine->getOptions().uiScale)); | |||||
std::snprintf(tmpBuf, 0xff, "%u\n", opts.bgColor); | |||||
if (! fPipeServer.writeMessage(tmpBuf)) | |||||
return; | |||||
std::snprintf(tmpBuf, 0xff, "%u\n", opts.fgColor); | |||||
if (! fPipeServer.writeMessage(tmpBuf)) | |||||
return; | |||||
std::snprintf(tmpBuf, 0xff, "%.12g\n", static_cast<double>(opts.uiScale)); | |||||
if (! fPipeServer.writeMessage(tmpBuf)) | if (! fPipeServer.writeMessage(tmpBuf)) | ||||
return; | return; | ||||
@@ -5541,13 +5578,15 @@ public: | |||||
return false; | return false; | ||||
} | } | ||||
const EngineOptions& opts(pData->engine->getOptions()); | |||||
// --------------------------------------------------------------- | // --------------------------------------------------------------- | ||||
// Init LV2 World if needed, sets LV2_PATH for lilv | // Init LV2 World if needed, sets LV2_PATH for lilv | ||||
Lv2WorldClass& lv2World(Lv2WorldClass::getInstance()); | Lv2WorldClass& lv2World(Lv2WorldClass::getInstance()); | ||||
if (pData->engine->getOptions().pathLV2 != nullptr && pData->engine->getOptions().pathLV2[0] != '\0') | |||||
lv2World.initIfNeeded(pData->engine->getOptions().pathLV2); | |||||
if (opts.pathLV2 != nullptr && opts.pathLV2[0] != '\0') | |||||
lv2World.initIfNeeded(opts.pathLV2); | |||||
else if (const char* const LV2_PATH = std::getenv("LV2_PATH")) | else if (const char* const LV2_PATH = std::getenv("LV2_PATH")) | ||||
lv2World.initIfNeeded(LV2_PATH); | lv2World.initIfNeeded(LV2_PATH); | ||||
else | else | ||||
@@ -5725,7 +5764,7 @@ public: | |||||
fLv2Options.maxBufferSize = bufferSize; | fLv2Options.maxBufferSize = bufferSize; | ||||
fLv2Options.nominalBufferSize = bufferSize; | fLv2Options.nominalBufferSize = bufferSize; | ||||
fLv2Options.sampleRate = static_cast<float>(pData->engine->getSampleRate()); | fLv2Options.sampleRate = static_cast<float>(pData->engine->getSampleRate()); | ||||
fLv2Options.transientWinId = static_cast<int64_t>(pData->engine->getOptions().frontendWinId); | |||||
fLv2Options.transientWinId = static_cast<int64_t>(opts.frontendWinId); | |||||
uint32_t eventBufferSize = MAX_DEFAULT_BUFFER_SIZE; | uint32_t eventBufferSize = MAX_DEFAULT_BUFFER_SIZE; | ||||
@@ -5742,7 +5781,9 @@ public: | |||||
fLv2Options.sequenceSize = static_cast<int>(eventBufferSize); | fLv2Options.sequenceSize = static_cast<int>(eventBufferSize); | ||||
fLv2Options.uiScale = pData->engine->getOptions().uiScale; | |||||
fLv2Options.bgColor = opts.bgColor; | |||||
fLv2Options.fgColor = opts.fgColor; | |||||
fLv2Options.uiScale = opts.uiScale; | |||||
// --------------------------------------------------------------- | // --------------------------------------------------------------- | ||||
// initialize features (part 1) | // initialize features (part 1) | ||||
@@ -5903,7 +5944,7 @@ public: | |||||
else if (options & PLUGIN_OPTION_FIXED_BUFFERS) | else if (options & PLUGIN_OPTION_FIXED_BUFFERS) | ||||
pData->options |= PLUGIN_OPTION_FIXED_BUFFERS; | pData->options |= PLUGIN_OPTION_FIXED_BUFFERS; | ||||
if (pData->engine->getOptions().forceStereo) | |||||
if (opts.forceStereo) | |||||
pData->options |= PLUGIN_OPTION_FORCE_STEREO; | pData->options |= PLUGIN_OPTION_FORCE_STEREO; | ||||
else if (options & PLUGIN_OPTION_FORCE_STEREO) | else if (options & PLUGIN_OPTION_FORCE_STEREO) | ||||
pData->options |= PLUGIN_OPTION_FORCE_STEREO; | pData->options |= PLUGIN_OPTION_FORCE_STEREO; | ||||
@@ -6816,6 +6857,10 @@ private: | |||||
return kUridMidiEvent; | return kUridMidiEvent; | ||||
if (std::strcmp(uri, LV2_PARAMETERS__sampleRate) == 0) | if (std::strcmp(uri, LV2_PARAMETERS__sampleRate) == 0) | ||||
return kUridParamSampleRate; | return kUridParamSampleRate; | ||||
if (std::strcmp(uri, LV2_UI__backgroundColor) == 0) | |||||
return kUridBackgroundColor; | |||||
if (std::strcmp(uri, LV2_UI__foregroundColor) == 0) | |||||
return kUridForegroundColor; | |||||
if (std::strcmp(uri, LV2_UI__scaleFactor) == 0) | if (std::strcmp(uri, LV2_UI__scaleFactor) == 0) | ||||
return kUridScaleFactor; | return kUridScaleFactor; | ||||
if (std::strcmp(uri, LV2_UI__windowTitle) == 0) | if (std::strcmp(uri, LV2_UI__windowTitle) == 0) | ||||
@@ -6946,6 +6991,10 @@ private: | |||||
return LV2_MIDI__MidiEvent; | return LV2_MIDI__MidiEvent; | ||||
case kUridParamSampleRate: | case kUridParamSampleRate: | ||||
return LV2_PARAMETERS__sampleRate; | return LV2_PARAMETERS__sampleRate; | ||||
case kUridBackgroundColor: | |||||
return LV2_UI__backgroundColor; | |||||
case kUridForegroundColor: | |||||
return LV2_UI__foregroundColor; | |||||
case kUridScaleFactor: | case kUridScaleFactor: | ||||
return LV2_UI__scaleFactor; | return LV2_UI__scaleFactor; | ||||
case kUridWindowTitle: | case kUridWindowTitle: | ||||
@@ -226,25 +226,21 @@ bool CarlaBridgeFormat::msgReceived(const char* const msg) noexcept | |||||
if (std::strcmp(msg, "uiOptions") == 0) | if (std::strcmp(msg, "uiOptions") == 0) | ||||
{ | { | ||||
double sampleRate; | |||||
bool useTheme, useThemeColors; | |||||
float uiScale; | |||||
const char* windowTitle; | |||||
uint64_t transientWindowId; | |||||
CARLA_SAFE_ASSERT_RETURN(readNextLineAsDouble(sampleRate), true); | |||||
CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(uiScale), true); | |||||
CARLA_SAFE_ASSERT_RETURN(readNextLineAsBool(useTheme), true); | |||||
CARLA_SAFE_ASSERT_RETURN(readNextLineAsBool(useThemeColors), true); | |||||
CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(windowTitle), true); | |||||
CARLA_SAFE_ASSERT_RETURN(readNextLineAsULong(transientWindowId), true); | |||||
BridgeFormatOptions opts; | |||||
CARLA_SAFE_ASSERT_RETURN(readNextLineAsDouble(opts.sampleRate), true); | |||||
CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(opts.bgColor), true); | |||||
CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(opts.fgColor), true); | |||||
CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(opts.uiScale), true); | |||||
CARLA_SAFE_ASSERT_RETURN(readNextLineAsBool(opts.useTheme), true); | |||||
CARLA_SAFE_ASSERT_RETURN(readNextLineAsBool(opts.useThemeColors), true); | |||||
CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(opts.windowTitle), true); | |||||
CARLA_SAFE_ASSERT_RETURN(readNextLineAsULong(opts.transientWindowId), true); | |||||
fGotOptions = true; | fGotOptions = true; | ||||
uiOptionsChanged(sampleRate, uiScale, | |||||
useTheme, useThemeColors, | |||||
windowTitle, static_cast<uintptr_t>(transientWindowId)); | |||||
uiOptionsChanged(opts); | |||||
delete[] windowTitle; | |||||
delete[] opts.windowTitle; | |||||
return true; | return true; | ||||
} | } | ||||
@@ -69,9 +69,18 @@ protected: | |||||
virtual void dspAtomReceived(const uint32_t index, const LV2_Atom* const atom) = 0; | virtual void dspAtomReceived(const uint32_t index, const LV2_Atom* const atom) = 0; | ||||
virtual void dspURIDReceived(const LV2_URID urid, const char* const uri) = 0; | virtual void dspURIDReceived(const LV2_URID urid, const char* const uri) = 0; | ||||
virtual void uiOptionsChanged(const double sampleRate, const float uiScale, | |||||
const bool useTheme, const bool useThemeColors, | |||||
const char* const windowTitle, const uintptr_t transientWindowId) = 0; | |||||
struct BridgeFormatOptions { | |||||
double sampleRate; | |||||
uint32_t bgColor; | |||||
uint32_t fgColor; | |||||
float uiScale; | |||||
bool useTheme; | |||||
bool useThemeColors; | |||||
const char* windowTitle; | |||||
uintptr_t transientWindowId; | |||||
}; | |||||
virtual void uiOptionsChanged(const BridgeFormatOptions& opts) = 0; | |||||
public: | public: | ||||
// --------------------------------------------------------------------- | // --------------------------------------------------------------------- | ||||
@@ -93,11 +93,16 @@ enum CarlaLv2URIDs { | |||||
kUridTimeTicksPerBeat, | kUridTimeTicksPerBeat, | ||||
kUridMidiEvent, | kUridMidiEvent, | ||||
kUridParamSampleRate, | kUridParamSampleRate, | ||||
// ui stuff | |||||
kUridBackgroundColor, | |||||
kUridForegroundColor, | |||||
kUridScaleFactor, | kUridScaleFactor, | ||||
kUridWindowTitle, | kUridWindowTitle, | ||||
// custom carla props | |||||
kUridCarlaAtomWorkerIn, | kUridCarlaAtomWorkerIn, | ||||
kUridCarlaAtomWorkerResp, | kUridCarlaAtomWorkerResp, | ||||
kUridCarlaTransientWindowId, | kUridCarlaTransientWindowId, | ||||
// count | |||||
kUridCount | kUridCount | ||||
}; | }; | ||||
@@ -131,6 +136,8 @@ struct Lv2PluginOptions { | |||||
enum OptIndex { | enum OptIndex { | ||||
SampleRate, | SampleRate, | ||||
TransientWinId, | TransientWinId, | ||||
BackgroundColor, | |||||
ForegroundColor, | |||||
ScaleFactor, | ScaleFactor, | ||||
WindowTitle, | WindowTitle, | ||||
Null, | Null, | ||||
@@ -139,12 +146,16 @@ struct Lv2PluginOptions { | |||||
float sampleRate; | float sampleRate; | ||||
int64_t transientWinId; | int64_t transientWinId; | ||||
uint32_t bgColor; | |||||
uint32_t fgColor; | |||||
float uiScale; | float uiScale; | ||||
LV2_Options_Option opts[Count]; | LV2_Options_Option opts[Count]; | ||||
Lv2PluginOptions() noexcept | Lv2PluginOptions() noexcept | ||||
: sampleRate(static_cast<float>(gInitialSampleRate)), | : sampleRate(static_cast<float>(gInitialSampleRate)), | ||||
transientWinId(0), | transientWinId(0), | ||||
bgColor(0x000000ff), | |||||
fgColor(0xffffffff), | |||||
uiScale(1.0f) | uiScale(1.0f) | ||||
{ | { | ||||
LV2_Options_Option& optSampleRate(opts[SampleRate]); | LV2_Options_Option& optSampleRate(opts[SampleRate]); | ||||
@@ -155,6 +166,22 @@ struct Lv2PluginOptions { | |||||
optSampleRate.type = kUridAtomFloat; | optSampleRate.type = kUridAtomFloat; | ||||
optSampleRate.value = &sampleRate; | optSampleRate.value = &sampleRate; | ||||
LV2_Options_Option& optBackgroundColor(opts[BackgroundColor]); | |||||
optBackgroundColor.context = LV2_OPTIONS_INSTANCE; | |||||
optBackgroundColor.subject = 0; | |||||
optBackgroundColor.key = kUridBackgroundColor; | |||||
optBackgroundColor.size = sizeof(int32_t); | |||||
optBackgroundColor.type = kUridAtomInt; | |||||
optBackgroundColor.value = &bgColor; | |||||
LV2_Options_Option& optForegroundColor(opts[ForegroundColor]); | |||||
optForegroundColor.context = LV2_OPTIONS_INSTANCE; | |||||
optForegroundColor.subject = 0; | |||||
optForegroundColor.key = kUridForegroundColor; | |||||
optForegroundColor.size = sizeof(int32_t); | |||||
optForegroundColor.type = kUridAtomInt; | |||||
optForegroundColor.value = &fgColor; | |||||
LV2_Options_Option& optScaleFactor(opts[ScaleFactor]); | LV2_Options_Option& optScaleFactor(opts[ScaleFactor]); | ||||
optScaleFactor.context = LV2_OPTIONS_INSTANCE; | optScaleFactor.context = LV2_OPTIONS_INSTANCE; | ||||
optScaleFactor.subject = 0; | optScaleFactor.subject = 0; | ||||
@@ -598,19 +625,14 @@ public: | |||||
fCustomURIDs.push_back(uri); | fCustomURIDs.push_back(uri); | ||||
} | } | ||||
void uiOptionsChanged(const double sampleRate, const float uiScale, | |||||
const bool useTheme, const bool useThemeColors, | |||||
const char* const windowTitle, const uintptr_t transientWindowId) override | |||||
void uiOptionsChanged(const BridgeFormatOptions& opts) override | |||||
{ | { | ||||
carla_debug("CarlaLv2Client::uiOptionsChanged(%f, %f, %s, %s, \"%s\", " P_UINTPTR ")", | |||||
sampleRate, static_cast<double>(uiScale), | |||||
bool2str(useTheme), bool2str(useThemeColors), | |||||
windowTitle, transientWindowId); | |||||
carla_debug("CarlaLv2Client::uiOptionsChanged()"); | |||||
// ------------------------------------------------------------------------------------------------------------ | // ------------------------------------------------------------------------------------------------------------ | ||||
// sample rate | // sample rate | ||||
const float sampleRatef = static_cast<float>(sampleRate); | |||||
const float sampleRatef = static_cast<float>(opts.sampleRate); | |||||
if (carla_isNotEqual(fLv2Options.sampleRate, sampleRatef)) | if (carla_isNotEqual(fLv2Options.sampleRate, sampleRatef)) | ||||
{ | { | ||||
@@ -634,15 +656,17 @@ public: | |||||
} | } | ||||
// ------------------------------------------------------------------------------------------------------------ | // ------------------------------------------------------------------------------------------------------------ | ||||
// ui scale | |||||
// ui colors and scale | |||||
fLv2Options.uiScale = uiScale; | |||||
fLv2Options.bgColor = opts.bgColor; | |||||
fLv2Options.fgColor = opts.fgColor; | |||||
fLv2Options.uiScale = opts.uiScale; | |||||
// ------------------------------------------------------------------------------------------------------------ | // ------------------------------------------------------------------------------------------------------------ | ||||
// window title | // window title | ||||
if (windowTitle != nullptr) | |||||
fUiOptions.windowTitle = windowTitle; | |||||
if (opts.windowTitle != nullptr) | |||||
fUiOptions.windowTitle = opts.windowTitle; | |||||
else | else | ||||
fUiOptions.windowTitle.clear(); | fUiOptions.windowTitle.clear(); | ||||
@@ -652,14 +676,14 @@ public: | |||||
// ------------------------------------------------------------------------------------------------------------ | // ------------------------------------------------------------------------------------------------------------ | ||||
// transient win id | // transient win id | ||||
fLv2Options.transientWinId = static_cast<int64_t>(transientWindowId); | |||||
fUiOptions.transientWindowId = transientWindowId; | |||||
fLv2Options.transientWinId = static_cast<int64_t>(opts.transientWindowId); | |||||
fUiOptions.transientWindowId = opts.transientWindowId; | |||||
// ------------------------------------------------------------------------------------------------------------ | // ------------------------------------------------------------------------------------------------------------ | ||||
// other | // other | ||||
fUiOptions.useTheme = useTheme; | |||||
fUiOptions.useThemeColors = useThemeColors; | |||||
fUiOptions.useTheme = opts.useTheme; | |||||
fUiOptions.useThemeColors = opts.useThemeColors; | |||||
} | } | ||||
void uiResized(const uint width, const uint height) override | void uiResized(const uint width, const uint height) override | ||||
@@ -1060,6 +1084,10 @@ private: | |||||
return kUridMidiEvent; | return kUridMidiEvent; | ||||
if (std::strcmp(uri, LV2_PARAMETERS__sampleRate) == 0) | if (std::strcmp(uri, LV2_PARAMETERS__sampleRate) == 0) | ||||
return kUridParamSampleRate; | return kUridParamSampleRate; | ||||
if (std::strcmp(uri, LV2_UI__backgroundColor) == 0) | |||||
return kUridBackgroundColor; | |||||
if (std::strcmp(uri, LV2_UI__foregroundColor) == 0) | |||||
return kUridForegroundColor; | |||||
if (std::strcmp(uri, LV2_UI__scaleFactor) == 0) | if (std::strcmp(uri, LV2_UI__scaleFactor) == 0) | ||||
return kUridScaleFactor; | return kUridScaleFactor; | ||||
if (std::strcmp(uri, LV2_UI__windowTitle) == 0) | if (std::strcmp(uri, LV2_UI__windowTitle) == 0) | ||||
@@ -1190,6 +1218,10 @@ private: | |||||
return LV2_MIDI__MidiEvent; | return LV2_MIDI__MidiEvent; | ||||
case kUridParamSampleRate: | case kUridParamSampleRate: | ||||
return LV2_PARAMETERS__sampleRate; | return LV2_PARAMETERS__sampleRate; | ||||
case kUridBackgroundColor: | |||||
return LV2_UI__backgroundColor; | |||||
case kUridForegroundColor: | |||||
return LV2_UI__foregroundColor; | |||||
case kUridScaleFactor: | case kUridScaleFactor: | ||||
return LV2_UI__scaleFactor; | return LV2_UI__scaleFactor; | ||||
case kUridWindowTitle: | case kUridWindowTitle: | ||||
@@ -959,32 +959,38 @@ ENGINE_OPTION_PATH_RESOURCES = 21 | |||||
# @note: Linux only | # @note: Linux only | ||||
ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR = 22 | ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR = 22 | ||||
# Set UI scaling used in frontend, so backend can do the same for plugin UIs. | |||||
ENGINE_OPTION_FRONTEND_UI_SCALE = 23 | |||||
# Set background color used in the frontend, so backend can do the same for plugin UIs. | |||||
ENGINE_OPTION_FRONTEND_BACKGROUND_COLOR = 23 | |||||
# Set foreground color used in the frontend, so backend can do the same for plugin UIs. | |||||
ENGINE_OPTION_FRONTEND_FOREGROUND_COLOR = 24 | |||||
# Set UI scaling used in the frontend, so backend can do the same for plugin UIs. | |||||
ENGINE_OPTION_FRONTEND_UI_SCALE = 25 | |||||
# Set frontend winId, used to define as parent window for plugin UIs. | # Set frontend winId, used to define as parent window for plugin UIs. | ||||
ENGINE_OPTION_FRONTEND_WIN_ID = 24 | |||||
ENGINE_OPTION_FRONTEND_WIN_ID = 26 | |||||
# Set path to wine executable. | # Set path to wine executable. | ||||
ENGINE_OPTION_WINE_EXECUTABLE = 25 | |||||
ENGINE_OPTION_WINE_EXECUTABLE = 27 | |||||
# Enable automatic wineprefix detection. | # Enable automatic wineprefix detection. | ||||
ENGINE_OPTION_WINE_AUTO_PREFIX = 26 | |||||
ENGINE_OPTION_WINE_AUTO_PREFIX = 28 | |||||
# Fallback wineprefix to use if automatic detection fails or is disabled, and WINEPREFIX is not set. | # Fallback wineprefix to use if automatic detection fails or is disabled, and WINEPREFIX is not set. | ||||
ENGINE_OPTION_WINE_FALLBACK_PREFIX = 27 | |||||
ENGINE_OPTION_WINE_FALLBACK_PREFIX = 29 | |||||
# Enable realtime priority for Wine application and server threads. | # Enable realtime priority for Wine application and server threads. | ||||
ENGINE_OPTION_WINE_RT_PRIO_ENABLED = 28 | |||||
ENGINE_OPTION_WINE_RT_PRIO_ENABLED = 30 | |||||
# Base realtime priority for Wine threads. | # Base realtime priority for Wine threads. | ||||
ENGINE_OPTION_WINE_BASE_RT_PRIO = 29 | |||||
ENGINE_OPTION_WINE_BASE_RT_PRIO = 31 | |||||
# Wine server realtime priority. | # Wine server realtime priority. | ||||
ENGINE_OPTION_WINE_SERVER_RT_PRIO = 30 | |||||
ENGINE_OPTION_WINE_SERVER_RT_PRIO = 32 | |||||
# Capture console output into debug callbacks | # Capture console output into debug callbacks | ||||
ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT = 31 | |||||
ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT = 33 | |||||
# ------------------------------------------------------------------------------------------------------------ | # ------------------------------------------------------------------------------------------------------------ | ||||
# Engine Process Mode | # Engine Process Mode | ||||
@@ -2542,7 +2542,9 @@ class HostWindow(QMainWindow): | |||||
else: | else: | ||||
value_fix = 1.5 | value_fix = 1.5 | ||||
bg_color = self.ui.rack.palette().window().color() | |||||
rack_pal = self.ui.rack.palette() | |||||
bg_color = rack_pal.window().color() | |||||
fg_color = rack_pal.text().color() | |||||
bg_value = 1.0 - bg_color.blackF() | bg_value = 1.0 - bg_color.blackF() | ||||
if bg_value != 0.0 and bg_value < min_value: | if bg_value != 0.0 and bg_value < min_value: | ||||
pad_color = bg_color.lighter(100*min_value/bg_value*value_fix) | pad_color = bg_color.lighter(100*min_value/bg_value*value_fix) | ||||
@@ -2574,6 +2576,16 @@ class HostWindow(QMainWindow): | |||||
self.ui.pad_right.setPalette(self.imgR_palette) | self.ui.pad_right.setPalette(self.imgR_palette) | ||||
self.ui.pad_right.setAutoFillBackground(True) | self.ui.pad_right.setAutoFillBackground(True) | ||||
# qt's rgba is actually argb, so convert that | |||||
bg_color_value = bg_color.rgba() | |||||
bg_color_value = ((bg_color_value & 0xffffff) << 8) | (bg_color_value >> 24) | |||||
fg_color_value = fg_color.rgba() | |||||
fg_color_value = ((fg_color_value & 0xffffff) << 8) | (fg_color_value >> 24) | |||||
self.host.set_engine_option(ENGINE_OPTION_FRONTEND_BACKGROUND_COLOR, bg_color_value, "") | |||||
self.host.set_engine_option(ENGINE_OPTION_FRONTEND_FOREGROUND_COLOR, fg_color_value, "") | |||||
# -------------------------------------------------------------------------------------------------------- | # -------------------------------------------------------------------------------------------------------- | ||||
# paint event | # paint event | ||||
@@ -45,8 +45,10 @@ | |||||
#define LV2_UI__UI LV2_UI_PREFIX "UI" ///< http://lv2plug.in/ns/extensions/ui#UI | #define LV2_UI__UI LV2_UI_PREFIX "UI" ///< http://lv2plug.in/ns/extensions/ui#UI | ||||
#define LV2_UI__WindowsUI LV2_UI_PREFIX "WindowsUI" ///< http://lv2plug.in/ns/extensions/ui#WindowsUI | #define LV2_UI__WindowsUI LV2_UI_PREFIX "WindowsUI" ///< http://lv2plug.in/ns/extensions/ui#WindowsUI | ||||
#define LV2_UI__X11UI LV2_UI_PREFIX "X11UI" ///< http://lv2plug.in/ns/extensions/ui#X11UI | #define LV2_UI__X11UI LV2_UI_PREFIX "X11UI" ///< http://lv2plug.in/ns/extensions/ui#X11UI | ||||
#define LV2_UI__backgroundColor LV2_UI_PREFIX "backgroundColor" ///< http://lv2plug.in/ns/extensions/ui#backgroundColor | |||||
#define LV2_UI__binary LV2_UI_PREFIX "binary" ///< http://lv2plug.in/ns/extensions/ui#binary | #define LV2_UI__binary LV2_UI_PREFIX "binary" ///< http://lv2plug.in/ns/extensions/ui#binary | ||||
#define LV2_UI__fixedSize LV2_UI_PREFIX "fixedSize" ///< http://lv2plug.in/ns/extensions/ui#fixedSize | #define LV2_UI__fixedSize LV2_UI_PREFIX "fixedSize" ///< http://lv2plug.in/ns/extensions/ui#fixedSize | ||||
#define LV2_UI__foregroundColor LV2_UI_PREFIX "foregroundColor" ///< http://lv2plug.in/ns/extensions/ui#foregroundColor | |||||
#define LV2_UI__idleInterface LV2_UI_PREFIX "idleInterface" ///< http://lv2plug.in/ns/extensions/ui#idleInterface | #define LV2_UI__idleInterface LV2_UI_PREFIX "idleInterface" ///< http://lv2plug.in/ns/extensions/ui#idleInterface | ||||
#define LV2_UI__noUserResize LV2_UI_PREFIX "noUserResize" ///< http://lv2plug.in/ns/extensions/ui#noUserResize | #define LV2_UI__noUserResize LV2_UI_PREFIX "noUserResize" ///< http://lv2plug.in/ns/extensions/ui#noUserResize | ||||
#define LV2_UI__notifyType LV2_UI_PREFIX "notifyType" ///< http://lv2plug.in/ns/extensions/ui#notifyType | #define LV2_UI__notifyType LV2_UI_PREFIX "notifyType" ///< http://lv2plug.in/ns/extensions/ui#notifyType | ||||
@@ -372,6 +372,10 @@ const char* EngineOption2Str(const EngineOption option) noexcept | |||||
return "ENGINE_OPTION_PATH_RESOURCES"; | return "ENGINE_OPTION_PATH_RESOURCES"; | ||||
case ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR: | case ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR: | ||||
return "ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR"; | return "ENGINE_OPTION_PREVENT_BAD_BEHAVIOUR"; | ||||
case ENGINE_OPTION_FRONTEND_BACKGROUND_COLOR: | |||||
return "ENGINE_OPTION_FRONTEND_BACKGROUND_COLOR"; | |||||
case ENGINE_OPTION_FRONTEND_FOREGROUND_COLOR: | |||||
return "ENGINE_OPTION_FRONTEND_FOREGROUND_COLOR"; | |||||
case ENGINE_OPTION_FRONTEND_UI_SCALE: | case ENGINE_OPTION_FRONTEND_UI_SCALE: | ||||
return "ENGINE_OPTION_FRONTEND_UI_SCALE"; | return "ENGINE_OPTION_FRONTEND_UI_SCALE"; | ||||
case ENGINE_OPTION_FRONTEND_WIN_ID: | case ENGINE_OPTION_FRONTEND_WIN_ID: | ||||