UI: Fix studio mode transition bugs

-If the user were in the middle of a transition and clicked
the cut transition, the transitions would become borked.

-This actually disables the transition widgets, so the
user doesn't click them. Before, the disabling of the
widgets didn't work as expected. The code for enabling/disabling
them was also simplified.

-This loading of studio mode was moved in OBSInit because
the loading of transitions needs to happen first. This fixes
a bug when enabling/disabling the t-bar when the program
is first loaded. The t-bar would be disabled even if a
cut or stinger transition was not used.

-When the user would click the quick transitions, the
t-bar would be enabled even when it was not supposed
to.
This commit is contained in:
Clayton Groeneveld
2020-01-14 01:29:23 -06:00
parent 37a7805ad5
commit f7d39c12c0
3 changed files with 27 additions and 53 deletions
+17 -43
View File
@@ -268,11 +268,7 @@ void OBSBasic::TransitionStopped()
if (scene)
SetCurrentScene(scene);
// Make sure we re-enable the transition button
if (transitionButton)
transitionButton->setEnabled(true);
EnableQuickTransitionWidgets();
EnableTransitionWidgets(true);
}
if (api) {
@@ -343,8 +339,7 @@ void OBSBasic::TransitionToScene(OBSSource source, bool force,
obs_source_release(transition);
float t = obs_transition_get_time(transition);
bool stillTransitioning = (!tBarActive && t < 1.0f) ||
(tBarActive && t > 0.0f) || tBarDown;
bool stillTransitioning = t < 1.0f && t > 0.0f;
// If actively transitioning, block new transitions from starting
if (usingPreviewProgram && stillTransitioning)
@@ -399,6 +394,8 @@ void OBSBasic::TransitionToScene(OBSSource source, bool force,
manual ? OBS_TRANSITION_MODE_MANUAL
: OBS_TRANSITION_MODE_AUTO;
EnableTransitionWidgets(false);
bool success = obs_transition_start(transition, mode, duration,
source);
@@ -406,14 +403,6 @@ void OBSBasic::TransitionToScene(OBSSource source, bool force,
TransitionFullyStopped();
}
// If transition has begun, disable Transition button
if (usingPreviewProgram && stillTransitioning) {
if (transitionButton)
transitionButton->setEnabled(false);
DisableQuickTransitionWidgets();
}
cleanup:
if (usingPreviewProgram && sceneDuplicationMode)
obs_scene_release(scene);
@@ -454,8 +443,6 @@ void OBSBasic::SetTransition(OBSSource transition)
ui->transitionRemove->setEnabled(configurable);
ui->transitionProps->setEnabled(configurable);
EnableTBar();
if (api)
api->on_event(OBS_FRONTEND_EVENT_TRANSITION_CHANGED);
}
@@ -469,6 +456,7 @@ void OBSBasic::on_transitions_currentIndexChanged(int)
{
OBSSource transition = GetCurrentTransition();
SetTransition(transition);
EnableTBar();
}
void OBSBasic::AddTransition()
@@ -907,12 +895,15 @@ void OBSBasic::TBarReleased()
tBar->setValue(0);
tBar->blockSignals(false);
tBarActive = false;
EnableTransitionWidgets(true);
} else if (val <= T_BAR_CLAMP) {
obs_transition_set_manual_time(GetCurrentTransition(), 0.0f);
tBar->blockSignals(true);
tBar->setValue(0);
tBar->blockSignals(false);
tBarActive = false;
EnableTransitionWidgets(true);
}
tBarDown = false;
@@ -1215,8 +1206,6 @@ void OBSBasic::QuickTransitionChange()
qt->source = GetTransitionComboItem(ui->transitions, trIdx);
ResetQuickTransitionText(qt);
}
EnableTBar();
}
void OBSBasic::QuickTransitionChangeDuration(int value)
@@ -1280,8 +1269,10 @@ void OBSBasic::RefreshQuickTransitions()
AddQuickTransitionId(qt.id);
}
void OBSBasic::DisableQuickTransitionWidgets()
void OBSBasic::EnableTransitionWidgets(bool enable)
{
ui->transitions->setEnabled(enable);
if (!IsPreviewProgramMode())
return;
@@ -1293,33 +1284,16 @@ void OBSBasic::DisableQuickTransitionWidgets()
if (!item)
break;
QWidget *widget = item->widget();
if (!widget)
QPushButton *button =
qobject_cast<QPushButton *>(item->widget());
if (!button)
continue;
widget->setEnabled(false);
button->setEnabled(enable);
}
}
void OBSBasic::EnableQuickTransitionWidgets()
{
if (!IsPreviewProgramMode())
return;
QVBoxLayout *programLayout =
reinterpret_cast<QVBoxLayout *>(programOptions->layout());
for (int idx = 0;; idx++) {
QLayoutItem *item = programLayout->itemAt(idx);
if (!item)
break;
QWidget *widget = item->widget();
if (!widget)
continue;
widget->setEnabled(true);
}
if (transitionButton)
transitionButton->setEnabled(enable);
}
void OBSBasic::SetPreviewProgramMode(bool enabled)