Browse Source

Fully implement carla_set_custom_ui_title

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.2.0-RC1
falkTX 4 years ago
parent
commit
2009afd551
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
12 changed files with 148 additions and 71 deletions
  1. +2
    -3
      source/backend/CarlaHost.h
  2. +2
    -3
      source/backend/CarlaPlugin.hpp
  3. +3
    -3
      source/backend/CarlaStandalone.cpp
  4. +13
    -4
      source/backend/plugin/CarlaPlugin.cpp
  5. +1
    -1
      source/backend/plugin/CarlaPluginInternal.cpp
  6. +1
    -1
      source/backend/plugin/CarlaPluginInternal.hpp
  7. +17
    -8
      source/backend/plugin/CarlaPluginJuce.cpp
  8. +23
    -6
      source/backend/plugin/CarlaPluginLADSPADSSI.cpp
  9. +34
    -12
      source/backend/plugin/CarlaPluginLV2.cpp
  10. +27
    -13
      source/backend/plugin/CarlaPluginNative.cpp
  11. +17
    -8
      source/backend/plugin/CarlaPluginVST2.cpp
  12. +8
    -9
      source/bridges-plugin/CarlaBridgeSingleLV2.cpp

+ 2
- 3
source/backend/CarlaHost.h View File

@@ -1109,10 +1109,9 @@ CARLA_EXPORT void carla_send_midi_note(CarlaHostHandle handle,
#endif

/*!
* Set a custom prefix for plugin UI windows created by Carla.
* Carla will then add "%s (GUI)" after the prefix.
* Set a custom title for the plugin UI window created by Carla.
*/
CARLA_EXPORT void carla_set_custom_ui_prefix(CarlaHostHandle handle, uint pluginId, const char* prefix);
CARLA_EXPORT void carla_set_custom_ui_title(CarlaHostHandle handle, uint pluginId, const char* title);

/*!
* Tell a plugin to show its own custom UI.


+ 2
- 3
source/backend/CarlaPlugin.hpp View File

@@ -790,10 +790,9 @@ public:
// UI Stuff

/*!
* Set a custom prefix for plugin UI windows created by Carla.
* Carla will then add "%s (GUI)" after the prefix.
* Set a custom title for the plugin UI window created by Carla.
*/
void setCustomUIPrefix(const char* format);
void setCustomUITitle(const char* title) noexcept;

/*!
* Show (or hide) the plugin's custom UI according to @a yesNo.


+ 3
- 3
source/backend/CarlaStandalone.cpp View File

@@ -2150,13 +2150,13 @@ void carla_send_midi_note(CarlaHostHandle handle, uint pluginId, uint8_t channel
}
#endif

void carla_set_custom_ui_prefix(CarlaHostHandle handle, uint pluginId, const char* prefix)
void carla_set_custom_ui_title(CarlaHostHandle handle, uint pluginId, const char* title)
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr,);
CARLA_SAFE_ASSERT_RETURN(prefix != nullptr,);
CARLA_SAFE_ASSERT_RETURN(title != nullptr,);

if (const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId))
plugin->setCustomUIPrefix(prefix);
plugin->setCustomUITitle(title);
}

void carla_show_custom_ui(CarlaHostHandle handle, uint pluginId, bool yesNo)


+ 13
- 4
source/backend/plugin/CarlaPlugin.cpp View File

@@ -2355,9 +2355,9 @@ void CarlaPlugin::postponeRtAllNotesOff()
// -------------------------------------------------------------------
// UI Stuff

void CarlaPlugin::setCustomUIPrefix(const char* format)
void CarlaPlugin::setCustomUITitle(const char* const title) noexcept
{
pData->uiPrefix = format;
pData->uiTitle = title;
}

void CarlaPlugin::showCustomUI(const bool yesNo)
@@ -2429,8 +2429,17 @@ void CarlaPlugin::uiIdle()

carla_stdout("Trying to get window...");

CarlaString uiTitle(pData->name);
uiTitle += " (GUI)";
CarlaString uiTitle;

if (pData->uiTitle.isNotEmpty())
{
uiTitle = pData->uiTitle;
}
else
{
uiTitle = pData->name;
uiTitle += " (GUI)";
}

if (CarlaPluginUI::tryTransientWinIdMatch(getUiBridgeProcessId(), uiTitle,
pData->engine->getOptions().frontendWinId, pData->transientFirstTry))


+ 1
- 1
source/backend/plugin/CarlaPluginInternal.cpp View File

@@ -691,7 +691,7 @@ CarlaPlugin::ProtectedData::ProtectedData(CarlaEngine* const eng, const uint idx
masterMutex(),
singleMutex(),
stateSave(),
uiPrefix(),
uiTitle(),
extNotes(),
latency(),
postRtEvents(),


+ 1
- 1
source/backend/plugin/CarlaPluginInternal.hpp View File

@@ -269,7 +269,7 @@ struct CarlaPlugin::ProtectedData {

CarlaStateSave stateSave;

CarlaString uiPrefix;
CarlaString uiTitle;

struct ExternalNotes {
CarlaMutex mutex;


+ 17
- 8
source/backend/plugin/CarlaPluginJuce.cpp View File

@@ -260,12 +260,12 @@ public:
{
CarlaPlugin::setName(newName);

if (fWindow != nullptr)
{
juce::String uiName(pData->name);
uiName += " (GUI)";
fWindow->setName(uiName);
}
if (fWindow == nullptr || pData->uiTitle.isNotEmpty())
return;
juce::String uiName(pData->name);
uiName += " (GUI)";
fWindow->setName(uiName);
}

// -------------------------------------------------------------------
@@ -384,8 +384,17 @@ public:

if (fWindow == nullptr)
{
juce::String uiName(pData->name);
uiName += " (GUI)";
juce::String uiName;

if (pData->uiTitle.isNotEmpty())
{
uiName = pData->uiTitle.buffer();
}
else
{
uiName = pData->name;
uiName += " (GUI)";
}

fWindow = new JucePluginWindow(opts.frontendWinId);
fWindow->setName(uiName);


+ 23
- 6
source/backend/plugin/CarlaPluginLADSPADSSI.cpp View File

@@ -79,17 +79,20 @@ public:
kPlugin(plugin),
fBinary(),
fLabel(),
fUiTitle(),
fOscData(oscData),
fProcess() {}

void setData(const char* const binary, const char* const label) noexcept
void setData(const char* const binary, const char* const label, const char* const uiTitle) noexcept
{
CARLA_SAFE_ASSERT_RETURN(binary != nullptr && binary[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(label != nullptr /*&& label[0] != '\0'*/,);
CARLA_SAFE_ASSERT_RETURN(label != nullptr,);
CARLA_SAFE_ASSERT_RETURN(uiTitle != nullptr && uiTitle[0] != '\0',);
CARLA_SAFE_ASSERT(! isThreadRunning());

fBinary = binary;
fLabel = label;
fBinary = binary;
fLabel = label;
fUiTitle = uiTitle;

if (fLabel.isEmpty())
fLabel = "\"\"";
@@ -148,7 +151,7 @@ public:
arguments.add(fLabel.buffer());

// ui-title
arguments.add(name + String(" (GUI)"));
arguments.add(fUiTitle.buffer());

bool started;

@@ -242,6 +245,7 @@ private:

CarlaString fBinary;
CarlaString fLabel;
CarlaString fUiTitle;

const CarlaOscData& fOscData;
CarlaScopedPointer<ChildProcess> fProcess;
@@ -2957,7 +2961,20 @@ public:
if (const char* const guiFilename = find_dssi_ui(filename, fDescriptor->Label))
{
fUiFilename = guiFilename;
fThreadUI.setData(guiFilename, fDescriptor->Label);

CarlaString uiTitle;

if (pData->uiTitle.isNotEmpty())
{
uiTitle = pData->uiTitle;
}
else
{
uiTitle = pData->name;
uiTitle += " (GUI)";
}

fThreadUI.setData(guiFilename, fDescriptor->Label, uiTitle);
}
}
#endif


+ 34
- 12
source/backend/plugin/CarlaPluginLV2.cpp View File

@@ -452,7 +452,7 @@ struct CarlaPluginLV2Options {

if (windowTitle != nullptr)
{
delete[] windowTitle;
std::free(const_cast<char*>(windowTitle));
windowTitle = nullptr;
}
}
@@ -1303,14 +1303,14 @@ public:
{
CarlaPlugin::setName(newName);

if (fLv2Options.windowTitle == nullptr)
if (fLv2Options.windowTitle == nullptr || pData->uiTitle.isNotEmpty())
return;

CarlaString guiTitle(pData->name);
guiTitle += " (GUI)";
CarlaString uiTitle(pData->name);
uiTitle += " (GUI)";

delete[] fLv2Options.windowTitle;
fLv2Options.windowTitle = guiTitle.dup();
std::free(const_cast<char*>(fLv2Options.windowTitle));
fLv2Options.windowTitle = uiTitle.releaseBufferPointer();

fLv2Options.opts[CarlaPluginLV2Options::WindowTitle].size = (uint32_t)std::strlen(fLv2Options.windowTitle);
fLv2Options.opts[CarlaPluginLV2Options::WindowTitle].value = fLv2Options.windowTitle;
@@ -6271,9 +6271,19 @@ public:
{
carla_stdout("Will use UI-Bridge for '%s', binary: \"%s\"", pData->name, bridgeBinary);

CarlaString guiTitle(pData->name);
guiTitle += " (GUI)";
fLv2Options.windowTitle = guiTitle.dup();
CarlaString uiTitle;

if (pData->uiTitle.isNotEmpty())
{
uiTitle = pData->uiTitle;
}
else
{
uiTitle = pData->name;
uiTitle += " (GUI)";
}

fLv2Options.windowTitle = uiTitle.releaseBufferPointer();

fUI.type = UI::TYPE_BRIDGE;
fPipeServer.setData(bridgeBinary, fRdfDescriptor->URI, fUI.rdfDescriptor->URI);
@@ -6400,9 +6410,21 @@ public:
// ---------------------------------------------------------------
// initialize ui data

CarlaString guiTitle(pData->name);
guiTitle += " (GUI)";
fLv2Options.windowTitle = guiTitle.dup();
{
CarlaString uiTitle;

if (pData->uiTitle.isNotEmpty())
{
uiTitle = pData->uiTitle;
}
else
{
uiTitle = pData->name;
uiTitle += " (GUI)";
}

fLv2Options.windowTitle = uiTitle.releaseBufferPointer();
}

fLv2Options.opts[CarlaPluginLV2Options::WindowTitle].size = (uint32_t)std::strlen(fLv2Options.windowTitle);
fLv2Options.opts[CarlaPluginLV2Options::WindowTitle].value = fLv2Options.windowTitle;


+ 27
- 13
source/backend/plugin/CarlaPluginNative.cpp View File

@@ -347,7 +347,7 @@ public:

if (fHost.uiName != nullptr)
{
delete[] fHost.uiName;
std::free(const_cast<char*>(fHost.uiName));
fHost.uiName = nullptr;
}

@@ -695,18 +695,24 @@ public:
CARLA_SAFE_ASSERT_RETURN(fHandle != nullptr,);
CARLA_SAFE_ASSERT_RETURN(newName != nullptr && newName[0] != '\0',);

char uiName[std::strlen(newName)+6+1];
std::strcpy(uiName, newName);
std::strcat(uiName, " (GUI)");
CarlaPlugin::setName(newName);

if (fHost.uiName != nullptr)
delete[] fHost.uiName;
fHost.uiName = carla_strdup(uiName);
if (pData->uiTitle.isNotEmpty())
return;

CarlaString uiName(pData->name);
uiName += " (GUI)";

std::free(const_cast<char*>(fHost.uiName));
fHost.uiName = uiName.releaseBufferPointer();

if (fDescriptor->dispatcher != nullptr && fIsUiVisible)
fDescriptor->dispatcher(fHandle, NATIVE_PLUGIN_OPCODE_UI_NAME_CHANGED, 0, 0, uiName, 0.0f);
fDescriptor->dispatcher(fHandle,
NATIVE_PLUGIN_OPCODE_UI_NAME_CHANGED,
0, 0,
const_cast<char*>(fHost.uiName),
0.0f);

CarlaPlugin::setName(newName);
}

void setCtrlChannel(const int8_t channel, const bool sendOsc, const bool sendCallback) noexcept override
@@ -2889,11 +2895,19 @@ public:
{
CARLA_ASSERT(fHost.uiName == nullptr);

char uiName[std::strlen(pData->name)+6+1];
std::strcpy(uiName, pData->name);
std::strcat(uiName, " (GUI)");
CarlaString uiName;

if (pData->uiTitle.isNotEmpty())
{
uiName = pData->uiTitle;
}
else
{
uiName = pData->name;
uiName += " (GUI)";
}

fHost.uiName = carla_strdup(uiName);
fHost.uiName = uiName.releaseBufferPointer();
}

// ---------------------------------------------------------------


+ 17
- 8
source/backend/plugin/CarlaPluginVST2.cpp View File

@@ -367,12 +367,12 @@ public:
{
CarlaPlugin::setName(newName);

if (fUI.window != nullptr)
{
CarlaString guiTitle(pData->name);
guiTitle += " (GUI)";
fUI.window->setTitle(guiTitle.buffer());
}
if (fUI.window == nullptr || pData->uiTitle.isNotEmpty())
return;
CarlaString uiTitle(pData->name);
uiTitle += " (GUI)";
fUI.window->setTitle(uiTitle.buffer());
}

// -------------------------------------------------------------------
@@ -490,8 +490,17 @@ public:

if (yesNo)
{
CarlaString uiTitle(pData->name);
uiTitle += " (GUI)";
CarlaString uiTitle;

if (pData->uiTitle.isNotEmpty())
{
uiTitle = pData->uiTitle;
}
else
{
uiTitle = pData->name;
uiTitle += " (GUI)";
}

intptr_t value = 0;



+ 8
- 9
source/bridges-plugin/CarlaBridgeSingleLV2.cpp View File

@@ -66,8 +66,7 @@ public:
const char* const bundlePath,
const LV2_Feature* const* const features)
: Lv2PluginBaseClass<EngineTimeInfo>(sampleRate, features),
fPlugin(nullptr),
fUiName()
fPlugin(nullptr)
#ifdef USING_JUCE
, fJuceInitialiser()
#endif
@@ -311,8 +310,6 @@ public:
fUI.controller = controller;
fUI.host = nullptr;

fUiName.clear();

const LV2_URID_Map* uridMap = nullptr;

// ------------------------------------------------------------------------------------------------------------
@@ -333,7 +330,7 @@ public:

if (fUI.host != nullptr)
{
fUiName = fUI.host->plugin_human_id;
fPlugin->setCustomUITitle(fUI.host->plugin_human_id);
*widget = (LV2_External_UI_Widget_Compat*)this;
return true;
}
@@ -341,6 +338,8 @@ public:
// ------------------------------------------------------------------------------------------------------------
// no external-ui support, use showInterface

const char* uiTitle = nullptr;

for (int i=0; features[i] != nullptr; ++i)
{
if (std::strcmp(features[i]->URI, LV2_OPTIONS__options) == 0)
@@ -351,7 +350,7 @@ public:
{
if (options[j].key == uridMap->map(uridMap->handle, LV2_UI__windowTitle))
{
fUiName = (const char*)options[j].value;
uiTitle = (const char*)options[j].value;
break;
}
}
@@ -359,9 +358,10 @@ public:
}
}

if (fUiName.isEmpty())
fUiName = fPlugin->getName();
if (uiTitle == nullptr)
uiTitle = fPlugin->getName();

fPlugin->setCustomUITitle(uiTitle);
*widget = nullptr;
return true;
}
@@ -498,7 +498,6 @@ protected:

private:
CarlaPluginPtr fPlugin;
CarlaString fUiName;

#ifdef USING_JUCE
juce::SharedResourcePointer<juce::ScopedJuceInitialiser_GUI> fJuceInitialiser;


Loading…
Cancel
Save