mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-03-01 21:07:12 -05:00
libobs: Change groups to actual public types
(This commit also modifies UI) Changes groups to their own independent type, "group". This allows them to be used like other regular types, and allows the ability to reference groups in multiple scenes. Before, a group would always be linked to the scene it was in. This made it cumbersome for users to modify groups if they had a similar group in multiple scenes (they would have to modify each group in each scene). Making groups like other source types makes more sense to solve this issue so they can be referenced in multiple scenes at once. This also removes a significant amount of group-specific handling code required for implementing groups in the front-end. One limitation however: due to the way sub-items of groups are seamlessly modifiable and sortable as part of the whole scene, the user cannot have multiple references to the same group within one scene.
This commit is contained in:
@@ -38,6 +38,25 @@ bool OBSBasicSourceSelect::EnumSources(void *data, obs_source_t *source)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OBSBasicSourceSelect::EnumGroups(void *data, obs_source_t *source)
|
||||
{
|
||||
OBSBasicSourceSelect *window = static_cast<OBSBasicSourceSelect*>(data);
|
||||
const char *name = obs_source_get_name(source);
|
||||
const char *id = obs_source_get_id(source);
|
||||
|
||||
if (strcmp(id, window->id) == 0) {
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic*>(
|
||||
App()->GetMainWindow());
|
||||
OBSScene scene = main->GetCurrentScene();
|
||||
|
||||
obs_sceneitem_t *existing = obs_scene_get_group(scene, name);
|
||||
if (!existing)
|
||||
window->ui->sourceList->addItem(QT_UTF8(name));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OBSBasicSourceSelect::OBSSourceAdded(void *data, calldata_t *calldata)
|
||||
{
|
||||
OBSBasicSourceSelect *window = static_cast<OBSBasicSourceSelect*>(data);
|
||||
@@ -277,6 +296,8 @@ OBSBasicSourceSelect::OBSBasicSourceSelect(OBSBasic *parent, const char *id_)
|
||||
const char *name = obs_source_get_name(sceneSource);
|
||||
ui->sourceList->addItem(QT_UTF8(name));
|
||||
}
|
||||
} else if (strcmp(id_, "group") == 0) {
|
||||
obs_enum_sources(EnumGroups, this);
|
||||
} else {
|
||||
obs_enum_sources(EnumSources, this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user