UI: Do not disable t-bar

This commit is contained in:
Clayton Groeneveld 2020-03-05 08:58:21 -06:00
parent 46dcc9c2fb
commit b240a5671b
2 changed files with 70 additions and 45 deletions

View File

@ -345,35 +345,21 @@ void OBSBasic::TransitionToScene(OBSSource source, bool force,
if (usingPreviewProgram && stillTransitioning) if (usingPreviewProgram && stillTransitioning)
goto cleanup; goto cleanup;
tBarActive = false;
if (force) { if (force) {
obs_transition_set(transition, source); obs_transition_set(transition, source);
if (api) if (api)
api->on_event(OBS_FRONTEND_EVENT_SCENE_CHANGED); api->on_event(OBS_FRONTEND_EVENT_SCENE_CHANGED);
} else { } else {
/* check for scene override */
OBSData data = obs_source_get_private_settings(source);
obs_data_release(data);
const char *trOverrideName =
obs_data_get_string(data, "transition");
int duration = ui->transitionDuration->value(); int duration = ui->transitionDuration->value();
if (trOverrideName && *trOverrideName && !quickTransition) { /* check for scene override */
OBSSource trOverride = FindTransition(trOverrideName); OBSSource trOverride = GetOverrideTransition(source);
if (trOverride) {
transition = trOverride;
obs_data_set_default_int( if (trOverride && !overridingTransition && !quickTransition) {
data, "transition_duration", 300); duration = GetOverrideTransitionDuration(source);
duration = (int)obs_data_get_int(
data, "transition_duration");
OverrideTransition(trOverride); OverrideTransition(trOverride);
overridingTransition = true; overridingTransition = true;
} }
}
if (black && !prevFTBSource) { if (black && !prevFTBSource) {
source = nullptr; source = nullptr;
@ -456,7 +442,6 @@ void OBSBasic::on_transitions_currentIndexChanged(int)
{ {
OBSSource transition = GetCurrentTransition(); OBSSource transition = GetCurrentTransition();
SetTransition(transition); SetTransition(transition);
EnableTBar();
} }
void OBSBasic::AddTransition() void OBSBasic::AddTransition()
@ -909,8 +894,19 @@ void OBSBasic::TBarReleased()
tBarActive = false; tBarActive = false;
EnableTransitionWidgets(true); EnableTransitionWidgets(true);
} }
}
tBarDown = false; static bool ValidTBarTransition(OBSSource transition)
{
if (!transition)
return false;
QString id = QT_UTF8(obs_source_get_id(transition));
if (id == "cut_transition" || id == "obs_stinger_transition")
return false;
return true;
} }
void OBSBasic::TBarChanged(int value) void OBSBasic::TBarChanged(int value)
@ -918,34 +914,33 @@ void OBSBasic::TBarChanged(int value)
OBSSource transition = obs_get_output_source(0); OBSSource transition = obs_get_output_source(0);
obs_source_release(transition); obs_source_release(transition);
if (!tBarDown) { if (!tBarActive) {
OBSSource sceneSource = GetCurrentSceneSource();
OBSSource tBarTr = GetOverrideTransition(sceneSource);
if (!ValidTBarTransition(tBarTr)) {
tBarTr = GetCurrentTransition();
if (!ValidTBarTransition(tBarTr))
tBarTr = FindTransition(
obs_source_get_display_name(
"fade_transition"));
OverrideTransition(tBarTr);
overridingTransition = true;
transition = tBarTr;
}
obs_transition_set_manual_torque(transition, 8.0f, 0.05f); obs_transition_set_manual_torque(transition, 8.0f, 0.05f);
TransitionToScene(GetCurrentSceneSource(), false, false, false, TransitionToScene(sceneSource, false, false, false, 0, true);
0, true);
tBarActive = true; tBarActive = true;
tBarDown = true;
} }
obs_transition_set_manual_time(transition, obs_transition_set_manual_time(transition,
(float)value / T_BAR_PRECISION_F); (float)value / T_BAR_PRECISION_F);
} }
void OBSBasic::EnableTBar()
{
if (!previewProgramMode)
return;
const char *id = obs_source_get_id(GetCurrentTransition());
if (!id || strcmp(id, "cut_transition") == 0 ||
strcmp(id, "obs_stinger_transition") == 0) {
tBar->setValue(0);
tBar->setEnabled(false);
} else {
tBar->setEnabled(true);
}
}
void OBSBasic::on_modeSwitch_clicked() void OBSBasic::on_modeSwitch_clicked()
{ {
SetPreviewProgramMode(!IsPreviewProgramMode()); SetPreviewProgramMode(!IsPreviewProgramMode());
@ -1318,7 +1313,6 @@ void OBSBasic::SetPreviewProgramMode(bool enabled)
CreateProgramDisplay(); CreateProgramDisplay();
CreateProgramOptions(); CreateProgramOptions();
EnableTBar();
OBSScene curScene = GetCurrentScene(); OBSScene curScene = GetCurrentScene();
@ -1530,3 +1524,33 @@ void OBSBasic::LoadTransitions(obs_data_array_t *transitions)
obs_source_release(source); obs_source_release(source);
} }
} }
OBSSource OBSBasic::GetOverrideTransition(OBSSource source)
{
if (!source)
return nullptr;
OBSData data = obs_source_get_private_settings(source);
obs_data_release(data);
const char *trOverrideName = obs_data_get_string(data, "transition");
OBSSource trOverride = nullptr;
if (trOverrideName && *trOverrideName)
trOverride = FindTransition(trOverrideName);
return trOverride;
}
int OBSBasic::GetOverrideTransitionDuration(OBSSource source)
{
if (!source)
return 300;
OBSData data = obs_source_get_private_settings(source);
obs_data_release(data);
obs_data_set_default_int(data, "transition_duration", 300);
return (int)obs_data_get_int(data, "transition_duration");
}

View File

@ -509,8 +509,9 @@ private:
QSlider *tBar; QSlider *tBar;
bool tBarActive = false; bool tBarActive = false;
bool tBarDown = false;
void EnableTBar(); OBSSource GetOverrideTransition(OBSSource source);
int GetOverrideTransitionDuration(OBSSource source);
public slots: public slots:
void DeferSaveBegin(); void DeferSaveBegin();