mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
Automatic depth increment when placing a source.
This commit is contained in:
@@ -201,6 +201,7 @@ void Mixer::insertSource(Source *s)
|
|||||||
geometry_.scene.fg()->attach(s->group(View::GEOMETRY));
|
geometry_.scene.fg()->attach(s->group(View::GEOMETRY));
|
||||||
layer_.scene.fg()->attach(s->group(View::LAYER));
|
layer_.scene.fg()->attach(s->group(View::LAYER));
|
||||||
|
|
||||||
|
layer_.setDepth(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mixer::deleteCurrentSource()
|
void Mixer::deleteCurrentSource()
|
||||||
|
|||||||
15
Scene.cpp
15
Scene.cpp
@@ -272,6 +272,21 @@ NodeSet::iterator Group::end()
|
|||||||
return children_.end();
|
return children_.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Node *Group::front()
|
||||||
|
{
|
||||||
|
if (!children_.empty())
|
||||||
|
return *children_.rbegin();
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
Node *Group::back()
|
||||||
|
{
|
||||||
|
if (!children_.empty())
|
||||||
|
return *children_.begin();
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
uint Group::numChildren() const
|
uint Group::numChildren() const
|
||||||
{
|
{
|
||||||
return children_.size();
|
return children_.size();
|
||||||
|
|||||||
2
Scene.h
2
Scene.h
@@ -171,6 +171,8 @@ public:
|
|||||||
|
|
||||||
NodeSet::iterator begin();
|
NodeSet::iterator begin();
|
||||||
NodeSet::iterator end();
|
NodeSet::iterator end();
|
||||||
|
Node *front();
|
||||||
|
Node *back();
|
||||||
uint numChildren() const;
|
uint numChildren() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
14
View.cpp
14
View.cpp
@@ -400,10 +400,22 @@ void LayerView::setDepth (Source *s, float d)
|
|||||||
if (!s)
|
if (!s)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
float depth = d;
|
||||||
|
|
||||||
|
// negative depth given; find the front most depth
|
||||||
|
if ( depth < 0.f ) {
|
||||||
|
Node *front = scene.fg()->front();
|
||||||
|
if (front)
|
||||||
|
depth = front->translation_.z + 0.5f;
|
||||||
|
else
|
||||||
|
depth = 0.5f;
|
||||||
|
}
|
||||||
|
|
||||||
|
// move the layer node of the source
|
||||||
Group *sourceNode = s->group(mode_);
|
Group *sourceNode = s->group(mode_);
|
||||||
|
|
||||||
// diagonal movement only
|
// diagonal movement only
|
||||||
sourceNode->translation_.x = CLAMP( -d, SCENE_DEPTH + 2.f, 0.f);
|
sourceNode->translation_.x = CLAMP( -depth, SCENE_DEPTH + 2.f, 0.f);
|
||||||
sourceNode->translation_.y = sourceNode->translation_.x / aspect_ratio;
|
sourceNode->translation_.y = sourceNode->translation_.x / aspect_ratio;
|
||||||
|
|
||||||
// change depth
|
// change depth
|
||||||
|
|||||||
2
View.h
2
View.h
@@ -89,7 +89,7 @@ public:
|
|||||||
void zoom (float factor) override;
|
void zoom (float factor) override;
|
||||||
void grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair<Node *, glm::vec2> pick) override;
|
void grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair<Node *, glm::vec2> pick) override;
|
||||||
|
|
||||||
void setDepth (Source *, float d);
|
void setDepth (Source *, float d = -1.f);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float aspect_ratio;
|
float aspect_ratio;
|
||||||
|
|||||||
Reference in New Issue
Block a user