Hiding/Showing source properties on the fly

univrsal

Member
Hey,
I have a source type which has a couple of properties (Sliders, checkboxes etc.), which should only be visible
if another property is set to a specific value.
So I have a path property, which points to a config file, and after reading in that config file I want to either hide or show
certain properties, depending on the contents of the config file.

I tried doing this over the update() method like this:
C++:
inline void input_source::update(obs_data_t* settings)
{
    /* Load config file before this and saved results in settings */
    const auto props = obs_source_properties(m_source); // m_source being obs_source_t*
    const auto slider_visible = obs_data_get_bool(settings, "slider_state");
    obs_property_set_visible(obs_properties_get("slider", props), slider_visible);
    obs_properties_destroy(props);
}
but that didn't seem to work, so I tried setting the obs_property_set_modified_callback() of the text field to this method:
C++:
bool path_changed(obs_properties_t* props, obs_property_t* p, obs_data_t* s)
{
    const auto slider_visible = obs_data_get_bool(settings, "slider_state");
    obs_property_set_visible(obs_properties_get("slider", props), slider_visible);
}
but that didn't work either, although the properties do update, but only after pressing "Ok" and reopening the properties for that source.
So I wanted to know if there's a way to hide/show properties during the update method.

Also I'm currently storing the values I load from the config file in the obs_data_t* of the source, because I can access those in the path_changed method, I don't know if storing data other than that of properties is correct usage.
 
Top