From b2db5238724cda36500389a39dd0704a06d4237f Mon Sep 17 00:00:00 2001 From: Nanako <469449812@qq.com> Date: Sun, 26 May 2024 16:07:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=8F=92=E4=BB=B6=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E4=B8=8D=E5=8F=AF=E8=B0=83=E6=95=B4=E5=A4=A7=E5=B0=8F?= =?UTF-8?q?=20=E5=AE=9E=E7=8E=B0vst2=20host=E7=9A=84=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E5=A4=A7=E5=B0=8F=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/audio/plugin_host/vst2/vst2_plugin_host.cpp | 3 ++- core/window/window_manager.cpp | 13 +++++++++++++ core/window/window_manager.h | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/core/audio/plugin_host/vst2/vst2_plugin_host.cpp b/core/audio/plugin_host/vst2/vst2_plugin_host.cpp index 3ac94ca..836dfa3 100644 --- a/core/audio/plugin_host/vst2/vst2_plugin_host.cpp +++ b/core/audio/plugin_host/vst2/vst2_plugin_host.cpp @@ -2,6 +2,7 @@ #include "audio/device/audio_device_manager.h" #include "audio/mixer/channel_interface.h" +#include "window/window_manager.h" std::map> vst2_library_map; VstTimeInfo vst2_plugin_host::vst_time_info{}; @@ -63,7 +64,7 @@ VstIntPtr vst_master_callback(AEffect* effect, VstInt32 opcode, VstInt32 index, case audioMasterSizeWindow: { // 设置插件窗口大小 - // g_window_manager.resize_plugin_host_window((plugin_host*)effect->user, index, value); + g_window_manager.resize_plugin_window((plugin_host*)effect->user, index, value); return 1; } case audioMasterGetTime: diff --git a/core/window/window_manager.cpp b/core/window/window_manager.cpp index c2d203a..bb86579 100644 --- a/core/window/window_manager.cpp +++ b/core/window/window_manager.cpp @@ -40,6 +40,8 @@ void* window_manager::create_plugin_window(plugin_host* host) { if (width == 0 || height == 0) return nullptr; auto w = create_window(width, height, host->name.c_str()); + // 设置窗口不可调整大小 + glfwSetWindowAttrib(w.get(), GLFW_RESIZABLE, GLFW_FALSE); host_info info; host_info& window_info = host_infos_[host]; window_info.window = w; @@ -96,3 +98,14 @@ void window_manager::on_host_window_close(GLFWwindow* window) { f->second.window.reset(); } } + +void window_manager::resize_plugin_window(plugin_host *host, int width, int height) { + const auto& find = host_infos_.find(host); + if (find == host_infos_.end()) { + return; + } + auto window = find->second.window; + if (!window) + return; + glfwSetWindowSize(window.get(), width, height); +} diff --git a/core/window/window_manager.h b/core/window/window_manager.h index 07b1d73..a470152 100644 --- a/core/window/window_manager.h +++ b/core/window/window_manager.h @@ -15,6 +15,7 @@ public: std::shared_ptr create_window(int width, int height, const char* title); void* create_plugin_window(plugin_host* host); void destroy_plugin_window(plugin_host* host); + void resize_plugin_window(plugin_host* host, int width, int height); const char* get_name() override { return "window_manager"; } void update(); private: