diff --git a/src/SourceCallback.cpp b/src/SourceCallback.cpp index 1b0e659..a63505c 100644 --- a/src/SourceCallback.cpp +++ b/src/SourceCallback.cpp @@ -227,7 +227,7 @@ SourceCallback *ResetGeometry::clone() const SetAlpha::SetAlpha(float alpha, float ms, bool revert) : SourceCallback(), duration_(ms), alpha_(alpha), bidirectional_(revert) { - alpha_ = glm::clamp(alpha_, 0.f, 1.f); + alpha_ = glm::clamp(alpha_, -1.f, 1.f); start_ = glm::vec2(); target_ = glm::vec2(); } @@ -252,8 +252,13 @@ void SetAlpha::update(Source *s, float dt) // // target mixing view position // + // special case Alpha < 0 : negative means inactive + if (alpha_ < -DELTA_ALPHA) { + // linear interpolation between 1 and the value given (max 2.f) + target_ = step * ( ABS(alpha_) + 1.f); + } // special case Alpha = 0 - if (alpha_ < DELTA_ALPHA) { + else if (alpha_ < DELTA_ALPHA) { target_ = step; } // special case Alpha = 1 @@ -305,7 +310,13 @@ SourceCallback *SetAlpha::clone() const SourceCallback *SetAlpha::reverse(Source *s) const { - return bidirectional_ ? new SetAlpha(s->alpha(), duration_) : nullptr; + float _a = glm::length( glm::vec2(s->group(View::MIXING)->translation_) ); + if (_a > 1.f) + _a *= -1.f; + else + _a = s->alpha(); + + return bidirectional_ ? new SetAlpha(_a, duration_) : nullptr; } void SetAlpha::accept(Visitor& v) diff --git a/src/UserInterfaceManager.cpp b/src/UserInterfaceManager.cpp index f0d6526..347fb19 100644 --- a/src/UserInterfaceManager.cpp +++ b/src/UserInterfaceManager.cpp @@ -4995,11 +4995,11 @@ void InputMappingInterface::SliderParametersCallback(SourceCallback *callback, c float val = edited->value(); ImGui::SameLine(0, IMGUI_SAME_LINE / 2); ImGui::SetNextItemWidth(right_align); - if (ImGui::SliderFloat("##CALLBACK_ALPHA", &val, 0.f, 1.f, "%.2f")) + if (ImGui::SliderFloat("##CALLBACK_ALPHA", &val, -1.f, 1.f, "%.2f")) edited->setValue(val); ImGui::SameLine(0, IMGUI_SAME_LINE / 2); - ImGuiToolkit::Indication("Target alpha makes the source\nvisible (1.0) or transparent (0.0)", 18, 12); + ImGuiToolkit::Indication("Target alpha makes the source\nvisible (1.0), transparent (0.0),\n or innactive (-1.0)", 18, 12); } break;