修复host窗口在关闭后没有办法toggle的问题

This commit is contained in:
2024-06-11 19:30:30 +08:00
parent 47ae2613c8
commit dc4576634d
6 changed files with 16 additions and 9 deletions

View File

@@ -50,7 +50,11 @@ void plugin_host::init_channel_interface() {
void plugin_host::create_and_open_editor() {
void* handle = get_window_manager()->create_plugin_window(this);
open_editor(handle);
if (!handle) {
spdlog::error("Failed to create plugin window");
return;
}
on_open_editor(handle);
}
void plugin_host::destroy_editor() {

View File

@@ -59,12 +59,13 @@ public:
std::string vendor;
channel_interface* channel = nullptr;
std::vector<mixer_track*> owner_tracks;
bool editor_opened = false;
std::shared_ptr<circular_buffer_vector_type> ui_buffers;
multicast_delegate<void(int32_t index, float value)> on_param_changed;
protected:
void create_and_open_editor();
void destroy_editor();
virtual void open_editor(void* window_handle) = 0;
virtual void close_editor() = 0;
virtual void on_open_editor(void* window_handle) = 0;
virtual void on_close_editor() = 0;
private:
bool editor_opened = false;
};

View File

@@ -18,6 +18,7 @@ public:
void remove_instrument_plugin_host(plugin_host* host);
const std::vector<plugin_host*>& get_plugin_hosts() { return plugin_hosts_; }
const std::vector<plugin_host*>& get_instrument_hosts() { return instrument_plugins_; }
void process(uint32_t in_frames);
const char* get_name() override { return "plugin_host_manager"; }

View File

@@ -261,13 +261,13 @@ std::string vst2_plugin_host::load_vendor() const {
return buffer;
}
void vst2_plugin_host::open_editor(void* window_handle) {
void vst2_plugin_host::on_open_editor(void* window_handle) {
if (!has_editor())
return;
dispatch(effEditOpen, 0, 0, window_handle);
}
void vst2_plugin_host::close_editor() {
void vst2_plugin_host::on_close_editor() {
if (!has_editor())
return;
dispatch(effEditClose);

View File

@@ -35,8 +35,8 @@ public:
[[nodiscard]] std::string load_name() const override;
[[nodiscard]] std::string load_vendor() const override;
protected:
void open_editor(void* window_handle) override;
void close_editor() override;
void on_open_editor(void* window_handle) override;
void on_close_editor() override;
private:
VstIntPtr dispatch(VstInt32 opcode, VstInt32 index = 0, VstIntPtr value = 0, void* ptr = nullptr, float opt = 0) const;
AEffect* effect_;

View File

@@ -90,7 +90,8 @@ void window_manager::on_host_window_close(GLFWwindow* window) {
return info.second.window.get() == window;
});
if (f != host_infos_.end()) {
f->first->close_editor();
f->first->editor_opened = false;
f->first->on_close_editor();
int x, y;
glfwGetWindowPos(window, &x, &y);
f->second.x = x;