设置插件窗口不可调整大小

实现vst2 host的调整窗口大小回调
This commit is contained in:
Nanako 2024-05-26 16:07:30 +08:00
parent 1659c24d4c
commit b2db523872
3 changed files with 16 additions and 1 deletions

View File

@ -2,6 +2,7 @@
#include "audio/device/audio_device_manager.h"
#include "audio/mixer/channel_interface.h"
#include "window/window_manager.h"
std::map<std::string, std::weak_ptr<dynamic_library>> 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:

View File

@ -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);
}

View File

@ -15,6 +15,7 @@ public:
std::shared_ptr<GLFWwindow> 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: