Signed-off-by: falkTX <falktx@falktx.com>tags/v2.2.0-RC1
| @@ -188,6 +188,13 @@ static const uint PLUGIN_USES_MULTI_PROGS = 0x400; | |||||
| */ | */ | ||||
| static const uint PLUGIN_HAS_INLINE_DISPLAY = 0x800; | 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, | 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; | } EngineCallbackOpcode; | ||||
| /* ------------------------------------------------------------------------------------------------------------ | /* ------------------------------------------------------------------------------------------------------------ | ||||
| @@ -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); | 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. | * Get the current engine buffer size. | ||||
| */ | */ | ||||
| @@ -802,6 +802,13 @@ public: | |||||
| */ | */ | ||||
| virtual void showCustomUI(bool yesNo); | 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. | * UI idle function, called at regular intervals. | ||||
| * This function is only called from the main thread if PLUGIN_NEEDS_UI_MAIN_THREAD is set. | * This function is only called from the main thread if PLUGIN_NEEDS_UI_MAIN_THREAD is set. | ||||
| @@ -2167,6 +2167,16 @@ void carla_show_custom_ui(CarlaHostHandle handle, uint pluginId, bool yesNo) | |||||
| plugin->showCustomUI(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) | uint32_t carla_get_buffer_size(CarlaHostHandle handle) | ||||
| @@ -2375,6 +2375,11 @@ void CarlaPlugin::showCustomUI(const bool yesNo) | |||||
| } | } | ||||
| } | } | ||||
| void* CarlaPlugin::embedCustomUI(void*) | |||||
| { | |||||
| return nullptr; | |||||
| } | |||||
| void CarlaPlugin::uiIdle() | void CarlaPlugin::uiIdle() | ||||
| { | { | ||||
| if (pData->hints & PLUGIN_NEEDS_UI_MAIN_THREAD) | if (pData->hints & PLUGIN_NEEDS_UI_MAIN_THREAD) | ||||
| @@ -1561,7 +1561,7 @@ public: | |||||
| return; | return; | ||||
| } | } | ||||
| const uintptr_t frontendWinId(pData->engine->getOptions().frontendWinId); | |||||
| const uintptr_t frontendWinId = pData->engine->getOptions().frontendWinId; | |||||
| #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH | #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH | ||||
| if (! yesNo) | 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 | void idle() override | ||||
| { | { | ||||
| if (fAtomBufferWorkerIn.isDataAvailableForReading()) | if (fAtomBufferWorkerIn.isDataAvailableForReading()) | ||||
| @@ -5457,12 +5478,24 @@ public: | |||||
| int handleUIResize(const int width, const int height) | 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(width > 0, 1); | ||||
| CARLA_SAFE_ASSERT_RETURN(height > 0, 1); | CARLA_SAFE_ASSERT_RETURN(height > 0, 1); | ||||
| carla_debug("CarlaPluginLV2::handleUIResize(%i, %i)", width, height); | 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; | return 0; | ||||
| } | } | ||||
| @@ -6712,6 +6745,7 @@ private: | |||||
| const LV2UI_Descriptor* descriptor; | const LV2UI_Descriptor* descriptor; | ||||
| const LV2_RDF_UI* rdfDescriptor; | const LV2_RDF_UI* rdfDescriptor; | ||||
| bool embedded; | |||||
| bool fileBrowserOpen; | bool fileBrowserOpen; | ||||
| const char* fileNeededForURI; | const char* fileNeededForURI; | ||||
| CarlaPluginUI* window; | CarlaPluginUI* window; | ||||
| @@ -6722,6 +6756,7 @@ private: | |||||
| widget(nullptr), | widget(nullptr), | ||||
| descriptor(nullptr), | descriptor(nullptr), | ||||
| rdfDescriptor(nullptr), | rdfDescriptor(nullptr), | ||||
| embedded(false), | |||||
| fileBrowserOpen(false), | fileBrowserOpen(false), | ||||
| fileNeededForURI(nullptr), | fileNeededForURI(nullptr), | ||||
| window(nullptr) {} | window(nullptr) {} | ||||
| @@ -317,6 +317,8 @@ const char* EngineCallbackOpcode2Str(const EngineCallbackOpcode opcode) noexcept | |||||
| return "ENGINE_CALLBACK_PARAMETER_MAPPED_RANGE_CHANGED"; | return "ENGINE_CALLBACK_PARAMETER_MAPPED_RANGE_CHANGED"; | ||||
| case ENGINE_CALLBACK_PATCHBAY_CLIENT_POSITION_CHANGED: | case ENGINE_CALLBACK_PATCHBAY_CLIENT_POSITION_CHANGED: | ||||
| return "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); | carla_stderr("CarlaBackend::EngineCallbackOpcode2Str(%i) - invalid opcode", opcode); | ||||