mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-17 13:19:59 +01:00
Enable negative Alpha in Source Callback for inactive source
setAlpha() to negative value allows to make the source inactive (outside mixing circle)
This commit is contained in:
@@ -227,7 +227,7 @@ SourceCallback *ResetGeometry::clone() const
|
|||||||
SetAlpha::SetAlpha(float alpha, float ms, bool revert) : SourceCallback(),
|
SetAlpha::SetAlpha(float alpha, float ms, bool revert) : SourceCallback(),
|
||||||
duration_(ms), alpha_(alpha), bidirectional_(revert)
|
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();
|
start_ = glm::vec2();
|
||||||
target_ = glm::vec2();
|
target_ = glm::vec2();
|
||||||
}
|
}
|
||||||
@@ -252,8 +252,13 @@ void SetAlpha::update(Source *s, float dt)
|
|||||||
//
|
//
|
||||||
// target mixing view position
|
// 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
|
// special case Alpha = 0
|
||||||
if (alpha_ < DELTA_ALPHA) {
|
else if (alpha_ < DELTA_ALPHA) {
|
||||||
target_ = step;
|
target_ = step;
|
||||||
}
|
}
|
||||||
// special case Alpha = 1
|
// special case Alpha = 1
|
||||||
@@ -305,7 +310,13 @@ SourceCallback *SetAlpha::clone() const
|
|||||||
|
|
||||||
SourceCallback *SetAlpha::reverse(Source *s) 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)
|
void SetAlpha::accept(Visitor& v)
|
||||||
|
|||||||
@@ -4995,11 +4995,11 @@ void InputMappingInterface::SliderParametersCallback(SourceCallback *callback, c
|
|||||||
float val = edited->value();
|
float val = edited->value();
|
||||||
ImGui::SameLine(0, IMGUI_SAME_LINE / 2);
|
ImGui::SameLine(0, IMGUI_SAME_LINE / 2);
|
||||||
ImGui::SetNextItemWidth(right_align);
|
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);
|
edited->setValue(val);
|
||||||
|
|
||||||
ImGui::SameLine(0, IMGUI_SAME_LINE / 2);
|
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;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user