Merge pull request #3313 from cg2121/transition-fix
UI: Fix transition enumeration
This commit is contained in:
commit
52a0a199d6
@ -119,6 +119,9 @@ struct OBSStudioAPI : obs_frontend_callbacks {
|
|||||||
OBSSource tr = main->ui->transitions->itemData(i)
|
OBSSource tr = main->ui->transitions->itemData(i)
|
||||||
.value<OBSSource>();
|
.value<OBSSource>();
|
||||||
|
|
||||||
|
if (!tr)
|
||||||
|
continue;
|
||||||
|
|
||||||
obs_source_addref(tr);
|
obs_source_addref(tr);
|
||||||
da_push_back(sources->sources, &tr);
|
da_push_back(sources->sources, &tr);
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,8 @@ void OBSBasic::InitDefaultTransitions()
|
|||||||
|
|
||||||
if (strcmp(id, "fade_transition") == 0)
|
if (strcmp(id, "fade_transition") == 0)
|
||||||
fadeTransition = tr;
|
fadeTransition = tr;
|
||||||
|
else if (strcmp(id, "cut_transition") == 0)
|
||||||
|
cutTransition = tr;
|
||||||
|
|
||||||
obs_source_release(tr);
|
obs_source_release(tr);
|
||||||
} else {
|
} else {
|
||||||
@ -180,15 +182,12 @@ void OBSBasic::CreateDefaultQuickTransitions()
|
|||||||
{
|
{
|
||||||
/* non-configurable transitions are always available, so add them
|
/* non-configurable transitions are always available, so add them
|
||||||
* to the "default quick transitions" list */
|
* to the "default quick transitions" list */
|
||||||
quickTransitions.emplace_back(GetTransitionComboItem(ui->transitions,
|
quickTransitions.emplace_back(cutTransition, 300,
|
||||||
0),
|
quickTransitionIdCounter++);
|
||||||
300, quickTransitionIdCounter++);
|
quickTransitions.emplace_back(fadeTransition, 300,
|
||||||
quickTransitions.emplace_back(GetTransitionComboItem(ui->transitions,
|
quickTransitionIdCounter++);
|
||||||
1),
|
quickTransitions.emplace_back(fadeTransition, 300,
|
||||||
300, quickTransitionIdCounter++);
|
quickTransitionIdCounter++, true);
|
||||||
quickTransitions.emplace_back(GetTransitionComboItem(ui->transitions,
|
|
||||||
1),
|
|
||||||
300, quickTransitionIdCounter++, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OBSBasic::LoadQuickTransitions(obs_data_array_t *array)
|
void OBSBasic::LoadQuickTransitions(obs_data_array_t *array)
|
||||||
@ -986,9 +985,11 @@ QMenu *OBSBasic::CreatePerSceneTransitionMenu()
|
|||||||
}
|
}
|
||||||
|
|
||||||
OBSSource tr = GetTransitionComboItem(ui->transitions, idx);
|
OBSSource tr = GetTransitionComboItem(ui->transitions, idx);
|
||||||
const char *name = obs_source_get_name(tr);
|
|
||||||
|
|
||||||
obs_data_set_string(data, "transition", name);
|
if (tr) {
|
||||||
|
const char *name = obs_source_get_name(tr);
|
||||||
|
obs_data_set_string(data, "transition", name);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
auto setDuration = [this](int duration) {
|
auto setDuration = [this](int duration) {
|
||||||
@ -1008,6 +1009,8 @@ QMenu *OBSBasic::CreatePerSceneTransitionMenu()
|
|||||||
if (i >= 0) {
|
if (i >= 0) {
|
||||||
OBSSource tr;
|
OBSSource tr;
|
||||||
tr = GetTransitionComboItem(ui->transitions, i);
|
tr = GetTransitionComboItem(ui->transitions, i);
|
||||||
|
if (!tr)
|
||||||
|
continue;
|
||||||
name = obs_source_get_name(tr);
|
name = obs_source_get_name(tr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1063,10 +1066,9 @@ QMenu *OBSBasic::CreateTransitionMenu(QWidget *parent, QuickTransition *qt)
|
|||||||
this, &OBSBasic::QuickTransitionChangeDuration);
|
this, &OBSBasic::QuickTransitionChangeDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
tr = GetTransitionComboItem(ui->transitions, 1);
|
tr = fadeTransition;
|
||||||
|
|
||||||
action = menu->addAction(QTStr("FadeToBlack"));
|
action = menu->addAction(QTStr("FadeToBlack"));
|
||||||
action->setProperty("transition_index", 1);
|
|
||||||
action->setProperty("fadeToBlack", true);
|
action->setProperty("fadeToBlack", true);
|
||||||
|
|
||||||
if (qt) {
|
if (qt) {
|
||||||
@ -1083,6 +1085,9 @@ QMenu *OBSBasic::CreateTransitionMenu(QWidget *parent, QuickTransition *qt)
|
|||||||
for (int i = 0; i < ui->transitions->count(); i++) {
|
for (int i = 0; i < ui->transitions->count(); i++) {
|
||||||
tr = GetTransitionComboItem(ui->transitions, i);
|
tr = GetTransitionComboItem(ui->transitions, i);
|
||||||
|
|
||||||
|
if (!tr)
|
||||||
|
continue;
|
||||||
|
|
||||||
action = menu->addAction(obs_source_get_name(tr));
|
action = menu->addAction(obs_source_get_name(tr));
|
||||||
action->setProperty("transition_index", i);
|
action->setProperty("transition_index", i);
|
||||||
|
|
||||||
@ -1152,12 +1157,18 @@ void OBSBasic::AddQuickTransition()
|
|||||||
{
|
{
|
||||||
int trIdx = sender()->property("transition_index").toInt();
|
int trIdx = sender()->property("transition_index").toInt();
|
||||||
QSpinBox *duration = sender()->property("duration").value<QSpinBox *>();
|
QSpinBox *duration = sender()->property("duration").value<QSpinBox *>();
|
||||||
bool toBlack = sender()->property("fadeToBlack").value<bool>();
|
bool fadeToBlack = sender()->property("fadeToBlack").value<bool>();
|
||||||
OBSSource transition = GetTransitionComboItem(ui->transitions, trIdx);
|
OBSSource transition =
|
||||||
|
fadeToBlack ? OBSSource(fadeTransition)
|
||||||
|
: GetTransitionComboItem(ui->transitions, trIdx);
|
||||||
|
|
||||||
|
if (!transition)
|
||||||
|
return;
|
||||||
|
|
||||||
int id = quickTransitionIdCounter++;
|
int id = quickTransitionIdCounter++;
|
||||||
|
|
||||||
quickTransitions.emplace_back(transition, duration->value(), id,
|
quickTransitions.emplace_back(transition, duration->value(), id,
|
||||||
toBlack);
|
fadeToBlack);
|
||||||
AddQuickTransitionId(id);
|
AddQuickTransitionId(id);
|
||||||
|
|
||||||
int idx = (int)quickTransitions.size() - 1;
|
int idx = (int)quickTransitions.size() - 1;
|
||||||
@ -1203,11 +1214,18 @@ void OBSBasic::QuickTransitionChange()
|
|||||||
{
|
{
|
||||||
int id = sender()->property("id").toInt();
|
int id = sender()->property("id").toInt();
|
||||||
int trIdx = sender()->property("transition_index").toInt();
|
int trIdx = sender()->property("transition_index").toInt();
|
||||||
|
bool fadeToBlack = sender()->property("fadeToBlack").value<bool>();
|
||||||
QuickTransition *qt = GetQuickTransition(id);
|
QuickTransition *qt = GetQuickTransition(id);
|
||||||
|
|
||||||
if (qt) {
|
if (qt) {
|
||||||
qt->source = GetTransitionComboItem(ui->transitions, trIdx);
|
OBSSource tr = fadeToBlack
|
||||||
ResetQuickTransitionText(qt);
|
? OBSSource(fadeTransition)
|
||||||
|
: GetTransitionComboItem(ui->transitions,
|
||||||
|
trIdx);
|
||||||
|
if (tr) {
|
||||||
|
qt->source = tr;
|
||||||
|
ResetQuickTransitionText(qt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,6 +391,7 @@ private:
|
|||||||
void LoadTransitions(obs_data_array_t *transitions);
|
void LoadTransitions(obs_data_array_t *transitions);
|
||||||
|
|
||||||
obs_source_t *fadeTransition;
|
obs_source_t *fadeTransition;
|
||||||
|
obs_source_t *cutTransition;
|
||||||
|
|
||||||
void CreateProgramDisplay();
|
void CreateProgramDisplay();
|
||||||
void CreateProgramOptions();
|
void CreateProgramOptions();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user