diff --git a/UserInterfaceManager.cpp b/UserInterfaceManager.cpp index fa19142..f5d3271 100644 --- a/UserInterfaceManager.cpp +++ b/UserInterfaceManager.cpp @@ -1547,13 +1547,13 @@ void Navigator::RenderTransitionPannel() ImGui::SameLine(0, 10); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::Combo("Curve", &Settings::application.transition.profile, "Linear\0Quadratic\0"); - if ( ImGui::Button( ICON_FA_PLAY " Start", ImVec2(IMGUI_RIGHT_ALIGN, 0)) ) { - TransitionView *tv = static_cast(Mixer::manager().view(View::TRANSITION)); - if (tv) tv->play(); - } ImGui::Text(" "); - if ( ImGui::Button( ICON_FA_DOOR_OPEN " Exit", ImVec2(ImGui::GetContentRegionAvail().x, 0)) ) + if ( ImGui::Button( ICON_FA_PLAY " Play ", ImVec2(ImGui::GetContentRegionAvail().x, 0)) ){ + TransitionView *tv = static_cast(Mixer::manager().view(View::TRANSITION)); + if (tv) tv->play(true); + } + if ( ImGui::Button( ICON_FA_DOOR_OPEN " Cancel", ImVec2(ImGui::GetContentRegionAvail().x, 0)) ) Mixer::manager().setView(View::MIXING); } diff --git a/View.cpp b/View.cpp index 9e943f6..02e038e 100644 --- a/View.cpp +++ b/View.cpp @@ -877,7 +877,7 @@ void TransitionView::draw() 0.1f, TRANSITION_MIN_DURATION, TRANSITION_MAX_DURATION, "%.1f s"); ImGui::SameLine(); if ( ImGui::Button(ICON_FA_PLAY) ) - play(); + play(false); ImGui::PopFont(); ImGui::End(); } @@ -936,7 +936,7 @@ std::pair TransitionView::pick(glm::vec2 P) if (transition_source_ != nullptr) { // start animation when clic on target if (pick.first == output_surface_) - play(); + play(true); // otherwise cancel animation else transition_source_->group(View::TRANSITION)->clearCallbacks(); @@ -946,26 +946,31 @@ std::pair TransitionView::pick(glm::vec2 P) } -void TransitionView::play() +void TransitionView::play(bool open) { if (transition_source_ != nullptr) { + // if want to open session after play, target movement till end position, otherwise stop at 0 + float target_x = open ? 0.4f : 0.f; + + // calculate time remaining to reach target float time = CLAMP(- transition_source_->group(View::TRANSITION)->translation_.x, 0.f, 1.f); - time += 0.2; // extra time to reach transition + time += open ? 0.2f : 0.f;; // extra time to reach transition if want to open time *= Settings::application.transition.duration * 1000.f; + // if remaining time is more than 50ms if (time > 50.f) { // start animation - MoveToCallback *anim = new MoveToCallback(glm::vec3(0.4f, 0.0, 0.0), time); + MoveToCallback *anim = new MoveToCallback(glm::vec3(target_x, 0.0, 0.0), time); transition_source_->group(View::TRANSITION)->update_callbacks_.push_back(anim); } // otherwise finish animation else - transition_source_->group(View::TRANSITION)->translation_.x = 0.4; + transition_source_->group(View::TRANSITION)->translation_.x = target_x; } } -View::Cursor TransitionView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::pair pick) +View::Cursor TransitionView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::pair) { if (!s) return Cursor(); diff --git a/View.h b/View.h index 13b3989..8e05994 100644 --- a/View.h +++ b/View.h @@ -157,7 +157,7 @@ public: void attach(SessionSource *ts); class Session *detach(); - void play(); + void play(bool open); void draw () override; void update (float dt) override;