obs-vst: Make VST editor buttons reflect UI and VST loaded state

This changes the buttons to better reflect the state of the filter:
* When no VST is loaded, hide both buttons
* Check if VST is loaded before changing visibility
* Check if VST is loaded and editor is open before changing visibility
This commit is contained in:
PatTheMav 2022-09-20 14:07:59 +02:00 committed by Ryan Foster
parent 4a73b01581
commit 2dbd6c2a2f

View file

@ -40,12 +40,15 @@ static bool open_editor_button_clicked(obs_properties_t *props,
{
VSTPlugin *vstPlugin = (VSTPlugin *)data;
QMetaObject::invokeMethod(vstPlugin, "openEditor");
if (vstPlugin && vstPlugin->vstLoaded()) {
obs_property_set_visible(obs_properties_get(props, OPEN_VST_SETTINGS),
false);
obs_property_set_visible(obs_properties_get(props, CLOSE_VST_SETTINGS),
true);
QMetaObject::invokeMethod(vstPlugin, "openEditor");
obs_property_set_visible(
obs_properties_get(props, OPEN_VST_SETTINGS), false);
obs_property_set_visible(
obs_properties_get(props, CLOSE_VST_SETTINGS), true);
}
UNUSED_PARAMETER(props);
UNUSED_PARAMETER(property);
@ -59,12 +62,15 @@ static bool close_editor_button_clicked(obs_properties_t *props,
{
VSTPlugin *vstPlugin = (VSTPlugin *)data;
QMetaObject::invokeMethod(vstPlugin, "closeEditor");
if (vstPlugin && vstPlugin->vstLoaded() && vstPlugin->isEditorOpen()) {
obs_property_set_visible(obs_properties_get(props, OPEN_VST_SETTINGS),
true);
obs_property_set_visible(obs_properties_get(props, CLOSE_VST_SETTINGS),
false);
QMetaObject::invokeMethod(vstPlugin, "closeEditor");
obs_property_set_visible(
obs_properties_get(props, OPEN_VST_SETTINGS), true);
obs_property_set_visible(
obs_properties_get(props, CLOSE_VST_SETTINGS), false);
}
UNUSED_PARAMETER(property);
@ -302,9 +308,14 @@ static obs_properties_t *vst_properties(void *data)
bool close_settings_vis = false;
if (data) {
VSTPlugin *vstPlugin = (VSTPlugin *)data;
if (vstPlugin->isEditorOpen()) {
close_settings_vis = true;
if (!vstPlugin->vstLoaded()) {
close_settings_vis = false;
open_settings_vis = false;
} else {
if (vstPlugin->isEditorOpen()) {
close_settings_vis = true;
open_settings_vis = false;
}
}
}