Browse Source

Start experimenting with embed-ui API, for use in external tools

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.2.0-RC1
falkTX 5 years ago
parent
commit
0e8a2f6e9f
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
7 changed files with 84 additions and 3 deletions
  1. +15
    -0
      source/backend/CarlaBackend.h
  2. +7
    -0
      source/backend/CarlaHost.h
  3. +7
    -0
      source/backend/CarlaPlugin.hpp
  4. +10
    -0
      source/backend/CarlaStandalone.cpp
  5. +5
    -0
      source/backend/plugin/CarlaPlugin.cpp
  6. +38
    -3
      source/backend/plugin/CarlaPluginLV2.cpp
  7. +2
    -0
      source/utils/CarlaBackendUtils.hpp

+ 15
- 0
source/backend/CarlaBackend.h View File

@@ -188,6 +188,13 @@ static const uint PLUGIN_USES_MULTI_PROGS = 0x400;
*/
static const uint PLUGIN_HAS_INLINE_DISPLAY = 0x800;

/*!
* Plugin has its own custom UI which can be embed into another Window.
* @see CarlaPlugin::embedCustomUI() and carla_embed_custom_ui()
* @note This is very experimental and subject to change at this point
*/
static const uint PLUGIN_HAS_CUSTOM_EMBED_UI = 0x1000;

/** @} */

/* ------------------------------------------------------------------------------------------------------------
@@ -1153,6 +1160,14 @@ typedef enum {
*/
ENGINE_CALLBACK_PATCHBAY_CLIENT_POSITION_CHANGED = 47,

/*!
* A plugin embed UI has been resized.
* @a pluginId Plugin Id to resize
* @a value1 New width
* @a value2 New height
*/
ENGINE_CALLBACK_EMBED_UI_RESIZED = 48,

} EngineCallbackOpcode;

/* ------------------------------------------------------------------------------------------------------------


+ 7
- 0
source/backend/CarlaHost.h View File

@@ -1121,6 +1121,13 @@ CARLA_EXPORT void carla_set_custom_ui_title(CarlaHostHandle handle, uint pluginI
*/
CARLA_EXPORT void carla_show_custom_ui(CarlaHostHandle handle, uint pluginId, bool yesNo);

/*!
* Embed the plugin's custom UI to the system pointer @a ptr.
* This function is always called from the main thread.
* @note This is very experimental and subject to change at this point
*/
CARLA_EXPORT void* carla_embed_custom_ui(CarlaHostHandle handle, uint pluginId, void* ptr);

/*!
* Get the current engine buffer size.
*/


+ 7
- 0
source/backend/CarlaPlugin.hpp View File

@@ -802,6 +802,13 @@ public:
*/
virtual void showCustomUI(bool yesNo);

/*!
* Embed the plugin's custom UI to the system pointer @a ptr.
* This function is always called from the main thread.
* @note This is very experimental and subject to change at this point
*/
virtual void* embedCustomUI(void* ptr);

/*!
* UI idle function, called at regular intervals.
* This function is only called from the main thread if PLUGIN_NEEDS_UI_MAIN_THREAD is set.


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

@@ -2167,6 +2167,16 @@ void carla_show_custom_ui(CarlaHostHandle handle, uint pluginId, bool yesNo)
plugin->showCustomUI(yesNo);
}

void* carla_embed_custom_ui(CarlaHostHandle handle, uint pluginId, void* ptr)
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr, nullptr);

if (const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId))
return plugin->embedCustomUI(ptr);

return nullptr;
}

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

uint32_t carla_get_buffer_size(CarlaHostHandle handle)


+ 5
- 0
source/backend/plugin/CarlaPlugin.cpp View File

@@ -2375,6 +2375,11 @@ void CarlaPlugin::showCustomUI(const bool yesNo)
}
}

void* CarlaPlugin::embedCustomUI(void*)
{
return nullptr;
}

void CarlaPlugin::uiIdle()
{
if (pData->hints & PLUGIN_NEEDS_UI_MAIN_THREAD)


+ 38
- 3
source/backend/plugin/CarlaPluginLV2.cpp View File

@@ -1561,7 +1561,7 @@ public:
return;
}

const uintptr_t frontendWinId(pData->engine->getOptions().frontendWinId);
const uintptr_t frontendWinId = pData->engine->getOptions().frontendWinId;

#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
if (! yesNo)
@@ -1845,6 +1845,27 @@ public:
}
}

#ifndef LV2_UIS_ONLY_BRIDGES
void* embedCustomUI(void* const ptr) override
{
CARLA_SAFE_ASSERT_RETURN(fUI.type == UI::TYPE_EMBED, nullptr);
CARLA_SAFE_ASSERT_RETURN(fUI.descriptor != nullptr, nullptr);
CARLA_SAFE_ASSERT_RETURN(fUI.descriptor->instantiate != nullptr, nullptr);
CARLA_SAFE_ASSERT_RETURN(fUI.descriptor->cleanup != nullptr, nullptr);
CARLA_SAFE_ASSERT_RETURN(fUI.rdfDescriptor->Type != LV2_UI_NONE, nullptr);
CARLA_SAFE_ASSERT_RETURN(fUI.window == nullptr, nullptr);

fFeatures[kFeatureIdUiParent]->data = ptr;

fUI.embedded = true;
fUI.widget = nullptr;
fUI.handle = fUI.descriptor->instantiate(fUI.descriptor, fRdfDescriptor->URI, fUI.rdfDescriptor->Bundle,
carla_lv2_ui_write_function, this, &fUI.widget, fFeatures);

return fUI.widget;
}
#endif

void idle() override
{
if (fAtomBufferWorkerIn.isDataAvailableForReading())
@@ -5457,12 +5478,24 @@ public:

int handleUIResize(const int width, const int height)
{
CARLA_SAFE_ASSERT_RETURN(fUI.window != nullptr, 1);
CARLA_SAFE_ASSERT_RETURN(width > 0, 1);
CARLA_SAFE_ASSERT_RETURN(height > 0, 1);
carla_debug("CarlaPluginLV2::handleUIResize(%i, %i)", width, height);

fUI.window->setSize(static_cast<uint>(width), static_cast<uint>(height), true);

if (fUI.embedded)
{
pData->engine->callback(true, true,
ENGINE_CALLBACK_EMBED_UI_RESIZED,
pData->id, width, height,
0, 0.0f, nullptr);
}
else
{
CARLA_SAFE_ASSERT_RETURN(fUI.window != nullptr, 1);
fUI.window->setSize(static_cast<uint>(width), static_cast<uint>(height), true);
}

return 0;
}

@@ -6712,6 +6745,7 @@ private:
const LV2UI_Descriptor* descriptor;
const LV2_RDF_UI* rdfDescriptor;

bool embedded;
bool fileBrowserOpen;
const char* fileNeededForURI;
CarlaPluginUI* window;
@@ -6722,6 +6756,7 @@ private:
widget(nullptr),
descriptor(nullptr),
rdfDescriptor(nullptr),
embedded(false),
fileBrowserOpen(false),
fileNeededForURI(nullptr),
window(nullptr) {}


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

@@ -317,6 +317,8 @@ const char* EngineCallbackOpcode2Str(const EngineCallbackOpcode opcode) noexcept
return "ENGINE_CALLBACK_PARAMETER_MAPPED_RANGE_CHANGED";
case ENGINE_CALLBACK_PATCHBAY_CLIENT_POSITION_CHANGED:
return "ENGINE_CALLBACK_PATCHBAY_CLIENT_POSITION_CHANGED";
case ENGINE_CALLBACK_EMBED_UI_RESIZED:
return "ENGINE_CALLBACK_EMBED_UI_RESIZED";
}

carla_stderr("CarlaBackend::EngineCallbackOpcode2Str(%i) - invalid opcode", opcode);


Loading…
Cancel
Save