BugFix Transition Cross Fading temporarily disabled when faded

When session is already fade to black, the cross fading transition cannot be used. Added an icon in left panel to allow user to set the transition mode
This commit is contained in:
Bruno Herbelin
2024-11-16 11:01:51 +01:00
parent 7e2a34a825
commit 5a933beb16
3 changed files with 30 additions and 5 deletions

View File

@@ -40,7 +40,8 @@
#define POS_TARGET 0.4f #define POS_TARGET 0.4f
TransitionView::TransitionView() : View(TRANSITION), transition_source_(nullptr) TransitionView::TransitionView() : View(TRANSITION), transition_source_(nullptr),
transition_cross_fade(true)
{ {
// read default settings // read default settings
if ( Settings::application.views[mode_].name.empty() ) if ( Settings::application.views[mode_].name.empty() )
@@ -126,7 +127,7 @@ void TransitionView::update(float dt)
// Transfer this movement to changes in mixing // Transfer this movement to changes in mixing
// cross fading // cross fading
if ( Settings::application.transition.cross_fade ) if ( transition_cross_fade )
{ {
float f = 0.f; float f = 0.f;
// change alpha of session: // change alpha of session:
@@ -176,7 +177,7 @@ void TransitionView::update(float dt)
void TransitionView::draw() void TransitionView::draw()
{ {
// update the GUI depending on changes in settings // update the GUI depending on changes in settings
gradient_->setActive( 2 * (Settings::application.transition.profile ? 1 : 0) + (Settings::application.transition.cross_fade ? 0 : 1) ); gradient_->setActive( 2 * (Settings::application.transition.profile ? 1 : 0) + (transition_cross_fade ? 0 : 1) );
// draw scene of this view // draw scene of this view
View::draw(); View::draw();
@@ -234,7 +235,10 @@ void TransitionView::draw()
// toggle transition mode // toggle transition mode
ImGui::SetCursorScreenPos(ImVec2(pos_tran.x - 60.f, pos_tran.y +2.f)); ImGui::SetCursorScreenPos(ImVec2(pos_tran.x - 60.f, pos_tran.y +2.f));
const char *tooltip[2] = {"Fade to black", "Cross fading"}; const char *tooltip[2] = {"Fade to black", "Cross fading"};
ImGuiToolkit::IconToggle(9, 8, 0, 8, &Settings::application.transition.cross_fade, tooltip ); if (ImGuiToolkit::IconToggle(9, 8, 0, 8,
&transition_cross_fade,
tooltip))
Settings::application.transition.cross_fade = transition_cross_fade;
ImGui::SetCursorScreenPos(ImVec2(pos_tran.x + 10.f, pos_tran.y + 2.f)); ImGui::SetCursorScreenPos(ImVec2(pos_tran.x + 10.f, pos_tran.y + 2.f));
const char *_tooltip[2] = {"Linear", "Quadratic"}; const char *_tooltip[2] = {"Linear", "Quadratic"};
@@ -272,8 +276,17 @@ void TransitionView::attach(SessionFileSource *ts)
tg->visible_ = true; tg->visible_ = true;
scene.ws()->attach(tg); scene.ws()->attach(tg);
transition_cross_fade = Settings::application.transition.cross_fade;
// automatically change fading mode to 'fade to black' if
// the session is already faded to black
if (Mixer::manager().session()->fading() > 0.01
&& Settings::application.transition.cross_fade) {
transition_cross_fade = false;
}
// in fade to black transition, start transition from current fading value // in fade to black transition, start transition from current fading value
if ( !Settings::application.transition.cross_fade) { if ( !transition_cross_fade) {
// reverse calculate x position to match actual fading of session // reverse calculate x position to match actual fading of session
float d = 0.f; float d = 0.f;

View File

@@ -35,6 +35,7 @@ private:
Mesh *mark_100ms_, *mark_1s_; Mesh *mark_100ms_, *mark_1s_;
Switch *gradient_; Switch *gradient_;
SessionFileSource *transition_source_; SessionFileSource *transition_source_;
bool transition_cross_fade;
}; };

View File

@@ -5560,10 +5560,21 @@ void Navigator::RenderMainPannelPlaylist()
ImGuiToolkit::HelpToolTip("Double-clic on a filename to open the session.\n\n" ImGuiToolkit::HelpToolTip("Double-clic on a filename to open the session.\n\n"
ICON_FA_ARROW_CIRCLE_RIGHT " enable Smooth transition " ICON_FA_ARROW_CIRCLE_RIGHT " enable Smooth transition "
"to perform a cross fading with the current session."); "to perform a cross fading with the current session.");
// toggle button for smooth transition // toggle button for smooth transition
ImGui::SetCursorPos( ImVec2( pannel_width_ IMGUI_RIGHT_ALIGN, pos_top.y - ImGui::GetFrameHeightWithSpacing()) ); ImGui::SetCursorPos( ImVec2( pannel_width_ IMGUI_RIGHT_ALIGN, pos_top.y - ImGui::GetFrameHeightWithSpacing()) );
ImGuiToolkit::ButtonToggle(ICON_FA_ARROW_CIRCLE_RIGHT, &Settings::application.smooth_transition, "Smooth transition"); ImGuiToolkit::ButtonToggle(ICON_FA_ARROW_CIRCLE_RIGHT, &Settings::application.smooth_transition, "Smooth transition");
// transition mode icon if enabled
if (Settings::application.smooth_transition) {
const char *tooltip[2] = {"Fade to black", "Cross fading"};
ImGui::SameLine(0, IMGUI_SAME_LINE);
if (Mixer::manager().session()->fading() > 0.01)
ImGuiToolkit::Icon(9, 8, false);
else
ImGuiToolkit::IconToggle(9, 8, 0, 8, &Settings::application.transition.cross_fade, tooltip );
}
// //
// Popup window to create playlist // Popup window to create playlist
// //