0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-19 20:32:15 +02:00

Allow property list entries to be disabled

This allows, for example, disconnected devices for dshow/avcapture to
be listed (and to stay selected in the user config) while making them
unavailable for selection in new sources
This commit is contained in:
Palana 2014-06-12 02:01:07 +02:00
parent ed7b37b522
commit e007d02c21
2 changed files with 21 additions and 1 deletions

View File

@ -34,6 +34,7 @@ struct int_data {
struct list_item {
char *name;
bool disabled;
union {
char *str;
@ -525,7 +526,7 @@ void obs_property_list_clear(obs_property_t p)
static size_t add_item(struct list_data *data, const char *name,
const void *val)
{
struct list_item item;
struct list_item item = { NULL };
item.name = bstrdup(name);
if (data->format == OBS_COMBO_FORMAT_INT)
@ -580,6 +581,21 @@ size_t obs_property_list_item_count(obs_property_t p)
return data ? data->items.num : 0;
}
bool obs_property_list_item_disabled(obs_property_t p, size_t idx)
{
struct list_data *data = get_list_data(p);
return (data && idx < data->items.num) ?
data->items.array[idx].disabled : false;
}
void obs_property_list_item_disable(obs_property_t p, size_t idx, bool disabled)
{
struct list_data *data = get_list_data(p);
if (!data || idx >= data->items.num)
return;
data->items.array[idx].disabled = disabled;
}
const char *obs_property_list_item_name(obs_property_t p, size_t idx)
{
struct list_data *data = get_list_data(p);

View File

@ -166,6 +166,10 @@ EXPORT size_t obs_property_list_add_int(obs_property_t p,
EXPORT size_t obs_property_list_add_float(obs_property_t p,
const char *name, double val);
EXPORT void obs_property_list_item_disable(obs_property_t p, size_t idx,
bool disabled);
EXPORT bool obs_property_list_item_disabled(obs_property_t p, size_t idx);
EXPORT void obs_property_list_remove(obs_property_t p, size_t idx);
EXPORT size_t obs_property_list_item_count(obs_property_t p);