Browse Source

Pass ui scale to ui bridges

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.1-rc1
falkTX 6 years ago
parent
commit
83deb53177
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
5 changed files with 49 additions and 19 deletions
  1. +4
    -0
      source/backend/plugin/CarlaPluginLV2.cpp
  2. +5
    -1
      source/bridges-ui/CarlaBridgeFormat.cpp
  3. +3
    -1
      source/bridges-ui/CarlaBridgeFormat.hpp
  4. +32
    -16
      source/bridges-ui/CarlaBridgeFormatLV2.cpp
  5. +5
    -1
      source/modules/distrho/src/DistrhoPluginCarla.cpp

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

@@ -1489,6 +1489,10 @@ public:
if (! fPipeServer.writeMessage(tmpBuf))
return;

std::snprintf(tmpBuf, 0xff, "%f\n", static_cast<double>(pData->engine->getOptions().uiScale));
if (! fPipeServer.writeMessage(tmpBuf))
return;

std::snprintf(tmpBuf, 0xff, "%s\n", bool2str(true)); // useTheme
if (! fPipeServer.writeMessage(tmpBuf))
return;


+ 5
- 1
source/bridges-ui/CarlaBridgeFormat.cpp View File

@@ -228,17 +228,21 @@ bool CarlaBridgeFormat::msgReceived(const char* const msg) noexcept
{
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);

fGotOptions = true;
uiOptionsChanged(sampleRate, useTheme, useThemeColors, windowTitle, static_cast<uintptr_t>(transientWindowId));
uiOptionsChanged(sampleRate, uiScale,
useTheme, useThemeColors,
windowTitle, static_cast<uintptr_t>(transientWindowId));

delete[] windowTitle;
return true;


+ 3
- 1
source/bridges-ui/CarlaBridgeFormat.hpp View File

@@ -69,7 +69,9 @@ protected:
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 uiOptionsChanged(const double sampleRate, const bool useTheme, const bool useThemeColors, const char* const windowTitle, uintptr_t transientWindowId) = 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;

public:
// ---------------------------------------------------------------------


+ 32
- 16
source/bridges-ui/CarlaBridgeFormatLV2.cpp View File

@@ -140,14 +140,12 @@ 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)
uiScale(1.0f)
{
LV2_Options_Option& optSampleRate(opts[SampleRate]);
optSampleRate.context = LV2_OPTIONS_INSTANCE;
@@ -600,9 +598,17 @@ public:
fCustomURIDs.push_back(uri);
}

void uiOptionsChanged(const double sampleRate, const bool useTheme, const bool useThemeColors, const char* const windowTitle, uintptr_t transientWindowId) override
void uiOptionsChanged(const double sampleRate, const float uiScale,
const bool useTheme, const bool useThemeColors,
const char* const windowTitle, const uintptr_t transientWindowId) override
{
carla_debug("CarlaLv2Client::uiOptionsChanged(%g, %s, %s, \"%s\", " P_UINTPTR ")", sampleRate, bool2str(useTheme), bool2str(useThemeColors), windowTitle, transientWindowId);
carla_debug("CarlaLv2Client::uiOptionsChanged(%f, %f, %s, %s, \"%s\", " P_UINTPTR ")",
sampleRate, static_cast<double>(uiScale),
bool2str(useTheme), bool2str(useThemeColors),
windowTitle, transientWindowId);

// ------------------------------------------------------------------------------------------------------------
// sample rate

const float sampleRatef = static_cast<float>(sampleRate);

@@ -627,23 +633,33 @@ public:
}
}

if (fLv2Options.windowTitle != nullptr && fLv2Options.windowTitle != kNullWindowTitle)
delete[] fLv2Options.windowTitle;
// ------------------------------------------------------------------------------------------------------------
// ui scale

fLv2Options.uiScale = uiScale;

fLv2Options.transientWinId = static_cast<int64_t>(transientWindowId);
fLv2Options.windowTitle = carla_strdup_safe(windowTitle);
// ------------------------------------------------------------------------------------------------------------
// window title

if (fLv2Options.windowTitle == nullptr)
fLv2Options.windowTitle = kNullWindowTitle;
if (windowTitle != nullptr)
fUiOptions.windowTitle = windowTitle;
else
fUiOptions.windowTitle = fLv2Options.windowTitle;
fUiOptions.windowTitle.clear();

fLv2Options.opts[Lv2PluginOptions::WindowTitle].size = (uint32_t)std::strlen(fLv2Options.windowTitle);
fLv2Options.opts[Lv2PluginOptions::WindowTitle].value = fLv2Options.windowTitle;
fLv2Options.opts[Lv2PluginOptions::WindowTitle].size = static_cast<uint32_t>(fUiOptions.windowTitle.length());
fLv2Options.opts[Lv2PluginOptions::WindowTitle].value = fUiOptions.windowTitle.buffer();

fUiOptions.useTheme = useTheme;
fUiOptions.useThemeColors = useThemeColors;
// ------------------------------------------------------------------------------------------------------------
// transient win id

fLv2Options.transientWinId = static_cast<int64_t>(transientWindowId);
fUiOptions.transientWindowId = transientWindowId;

// ------------------------------------------------------------------------------------------------------------
// other

fUiOptions.useTheme = useTheme;
fUiOptions.useThemeColors = useThemeColors;
}

void uiResized(const uint width, const uint height) override


+ 5
- 1
source/modules/distrho/src/DistrhoPluginCarla.cpp View File

@@ -100,7 +100,11 @@ public:
protected:
void handleEditParameter(const uint32_t rindex, const bool touch)
{
fHost->ui_parameter_touch(fHost->handle, rindex, touch);
pHost->dispatcher(pHost->handle,
NATIVE_HOST_OPCODE_UI_TOUCH_PARAMETER,
static_cast<int32_t>(rindex),
touch ? 1 : 0,
nullptr, 0.0f);
}

void handleSetParameterValue(const uint32_t rindex, const float value)


Loading…
Cancel
Save