UI: Add checkbox for visibility of new scene items
Note: This functionality should probably be considered as a temporary solution. Ideally, sources should not be visible on creation until the user presses "OK" in the initial properties dialog. Also, the problem of initial visibility can additionally be solved by implementing the preview/program functionality. Once preview/program is implemented the need for this patch will be negated, and the option should probably be removed. Closes jp9000/obs-studio#483
This commit is contained in:
committed by
jp9000
parent
6bc7fc65b3
commit
fc063444ca
@@ -157,6 +157,7 @@ Basic.Main.PreviewDisabled="Preview is currently disabled"
|
||||
Basic.SourceSelect="Create/Select Source"
|
||||
Basic.SourceSelect.CreateNew="Create new"
|
||||
Basic.SourceSelect.AddExisting="Add Existing"
|
||||
Basic.SourceSelect.AddVisible="Make source visible"
|
||||
|
||||
# properties window
|
||||
Basic.PropertiesWindow="Properties for '%1'"
|
||||
|
@@ -49,6 +49,16 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="sourceVisible">
|
||||
<property name="text">
|
||||
<string>Basic.SourceSelect.AddVisible</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
@@ -21,6 +21,11 @@
|
||||
#include "qt-wrappers.hpp"
|
||||
#include "obs-app.hpp"
|
||||
|
||||
struct AddSourceData {
|
||||
obs_source_t *source;
|
||||
bool visible;
|
||||
};
|
||||
|
||||
bool OBSBasicSourceSelect::EnumSources(void *data, obs_source_t *source)
|
||||
{
|
||||
OBSBasicSourceSelect *window = static_cast<OBSBasicSourceSelect*>(data);
|
||||
@@ -79,7 +84,16 @@ void OBSBasicSourceSelect::SourceRemoved(OBSSource source)
|
||||
delete items[0];
|
||||
}
|
||||
|
||||
static void AddExisting(const char *name)
|
||||
static void AddSource(void *_data, obs_scene_t *scene)
|
||||
{
|
||||
AddSourceData *data = (AddSourceData *)_data;
|
||||
obs_sceneitem_t *sceneitem;
|
||||
|
||||
sceneitem = obs_scene_add(scene, data->source);
|
||||
obs_sceneitem_set_visible(sceneitem, data->visible);
|
||||
}
|
||||
|
||||
static void AddExisting(const char *name, const bool visible)
|
||||
{
|
||||
obs_source_t *source = obs_get_output_source(0);
|
||||
obs_scene_t *scene = obs_scene_from_source(source);
|
||||
@@ -88,14 +102,19 @@ static void AddExisting(const char *name)
|
||||
|
||||
source = obs_get_source_by_name(name);
|
||||
if (source) {
|
||||
obs_scene_add(scene, source);
|
||||
AddSourceData data;
|
||||
data.source = source;
|
||||
data.visible = visible;
|
||||
obs_scene_atomic_update(scene, AddSource, &data);
|
||||
|
||||
obs_source_release(source);
|
||||
}
|
||||
|
||||
obs_scene_release(scene);
|
||||
}
|
||||
|
||||
bool AddNew(QWidget *parent, const char *id, const char *name)
|
||||
bool AddNew(QWidget *parent, const char *id, const char *name,
|
||||
const bool visible)
|
||||
{
|
||||
obs_source_t *source = obs_get_output_source(0);
|
||||
obs_scene_t *scene = obs_scene_from_source(source);
|
||||
@@ -115,7 +134,11 @@ bool AddNew(QWidget *parent, const char *id, const char *name)
|
||||
|
||||
if (source) {
|
||||
obs_add_source(source);
|
||||
obs_scene_add(scene, source);
|
||||
|
||||
AddSourceData data;
|
||||
data.source = source;
|
||||
data.visible = visible;
|
||||
obs_scene_atomic_update(scene, AddSource, &data);
|
||||
|
||||
success = true;
|
||||
}
|
||||
@@ -130,13 +153,14 @@ bool AddNew(QWidget *parent, const char *id, const char *name)
|
||||
void OBSBasicSourceSelect::on_buttonBox_accepted()
|
||||
{
|
||||
bool useExisting = ui->selectExisting->isChecked();
|
||||
bool visible = ui->sourceVisible->isChecked();
|
||||
|
||||
if (useExisting) {
|
||||
QListWidgetItem *item = ui->sourceList->currentItem();
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
AddExisting(QT_TO_UTF8(item->text()));
|
||||
AddExisting(QT_TO_UTF8(item->text()), visible);
|
||||
} else {
|
||||
if (ui->sourceName->text().isEmpty()) {
|
||||
QMessageBox::information(this,
|
||||
@@ -145,7 +169,8 @@ void OBSBasicSourceSelect::on_buttonBox_accepted()
|
||||
return;
|
||||
}
|
||||
|
||||
if (!AddNew(this, id, QT_TO_UTF8(ui->sourceName->text())))
|
||||
if (!AddNew(this, id, QT_TO_UTF8(ui->sourceName->text()),
|
||||
visible))
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user