mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
Fixed insertion of new source (after drop or pannel) to setup depth and
mixing coordinates.
This commit is contained in:
21
Mixer.cpp
21
Mixer.cpp
@@ -186,6 +186,12 @@ void Mixer::update()
|
|||||||
float dt = static_cast<float>( GST_TIME_AS_MSECONDS(current_time - update_time_) ) * 0.001f;
|
float dt = static_cast<float>( GST_TIME_AS_MSECONDS(current_time - update_time_) ) * 0.001f;
|
||||||
update_time_ = current_time;
|
update_time_ = current_time;
|
||||||
|
|
||||||
|
// insert source candidate for this session
|
||||||
|
if (candidate_sources_.size()>0) {
|
||||||
|
insertSource(candidate_sources_.front());
|
||||||
|
candidate_sources_.pop_front();
|
||||||
|
}
|
||||||
|
|
||||||
// update session and associated sources
|
// update session and associated sources
|
||||||
session_->update(dt);
|
session_->update(dt);
|
||||||
|
|
||||||
@@ -276,6 +282,11 @@ Source * Mixer::createSourceClone(std::string namesource)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Mixer::addSource(Source *s)
|
||||||
|
{
|
||||||
|
candidate_sources_.push_back(s);
|
||||||
|
}
|
||||||
|
|
||||||
void Mixer::insertSource(Source *s, bool makecurrent)
|
void Mixer::insertSource(Source *s, bool makecurrent)
|
||||||
{
|
{
|
||||||
if ( s != nullptr )
|
if ( s != nullptr )
|
||||||
@@ -283,14 +294,16 @@ void Mixer::insertSource(Source *s, bool makecurrent)
|
|||||||
// Add source to Session
|
// Add source to Session
|
||||||
SourceList::iterator sit = session_->addSource(s);
|
SourceList::iterator sit = session_->addSource(s);
|
||||||
|
|
||||||
|
// set a default depth to the new source
|
||||||
|
layer_.setDepth(s);
|
||||||
|
// set a default alpha to the new source
|
||||||
|
mixing_.setAlpha(s);
|
||||||
|
|
||||||
// add sources Nodes to all views
|
// add sources Nodes to all views
|
||||||
mixing_.scene.ws()->attach(s->group(View::MIXING));
|
mixing_.scene.ws()->attach(s->group(View::MIXING));
|
||||||
geometry_.scene.ws()->attach(s->group(View::GEOMETRY));
|
geometry_.scene.ws()->attach(s->group(View::GEOMETRY));
|
||||||
layer_.scene.ws()->attach(s->group(View::LAYER));
|
layer_.scene.ws()->attach(s->group(View::LAYER));
|
||||||
|
|
||||||
// set a default depth to the new source
|
|
||||||
layer_.setDepth(s);
|
|
||||||
|
|
||||||
if (makecurrent) {
|
if (makecurrent) {
|
||||||
// set this new source as current
|
// set this new source as current
|
||||||
setCurrentSource( sit );
|
setCurrentSource( sit );
|
||||||
@@ -298,9 +311,7 @@ void Mixer::insertSource(Source *s, bool makecurrent)
|
|||||||
// switch to Mixing view to show source created
|
// switch to Mixing view to show source created
|
||||||
setCurrentView(View::MIXING);
|
setCurrentView(View::MIXING);
|
||||||
current_view_->update(0);
|
current_view_->update(0);
|
||||||
// current_view_->restoreSettings();
|
|
||||||
current_view_->centerSource(s);
|
current_view_->centerSource(s);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
7
Mixer.h
7
Mixer.h
@@ -33,13 +33,13 @@ public:
|
|||||||
// draw session and current view
|
// draw session and current view
|
||||||
void draw();
|
void draw();
|
||||||
|
|
||||||
// manangement of sources
|
// creation of sources
|
||||||
Source * createSourceFile(std::string path);
|
Source * createSourceFile(std::string path);
|
||||||
Source * createSourceClone(std::string namesource);
|
Source * createSourceClone(std::string namesource);
|
||||||
Source * createSourceRender();
|
Source * createSourceRender();
|
||||||
|
|
||||||
// operations on sources
|
// operations on sources
|
||||||
void insertSource(Source *s, bool makecurrent = true);
|
void addSource(Source *s);
|
||||||
void deleteSource(Source *s);
|
void deleteSource(Source *s);
|
||||||
void renameSource(Source *s, const std::string &newname);
|
void renameSource(Source *s, const std::string &newname);
|
||||||
|
|
||||||
@@ -76,6 +76,9 @@ protected:
|
|||||||
Session *back_session_;
|
Session *back_session_;
|
||||||
void swap();
|
void swap();
|
||||||
|
|
||||||
|
SourceList candidate_sources_;
|
||||||
|
void insertSource(Source *s, bool makecurrent = true);
|
||||||
|
|
||||||
void setCurrentSource(SourceList::iterator it);
|
void setCurrentSource(SourceList::iterator it);
|
||||||
SourceList::iterator current_source_;
|
SourceList::iterator current_source_;
|
||||||
int current_source_index_;
|
int current_source_index_;
|
||||||
|
|||||||
@@ -323,9 +323,8 @@ void Rendering::FileDropped(GLFWwindow *, int path_count, const char* paths[])
|
|||||||
if (filename.empty())
|
if (filename.empty())
|
||||||
break;
|
break;
|
||||||
// try to create a source
|
// try to create a source
|
||||||
Mixer::manager().insertSource ( Mixer::manager().createSourceFile( filename ) );
|
Mixer::manager().addSource ( Mixer::manager().createSourceFile( filename ) );
|
||||||
}
|
}
|
||||||
UserInterface::manager().showPannel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1261,7 +1261,7 @@ void Navigator::RenderNewPannel()
|
|||||||
new_source_preview_.draw(ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN);
|
new_source_preview_.draw(ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN);
|
||||||
// or press Validate button
|
// or press Validate button
|
||||||
if ( ImGui::Button("Import", ImVec2(pannel_width_ - padding_width_, 0)) ) {
|
if ( ImGui::Button("Import", ImVec2(pannel_width_ - padding_width_, 0)) ) {
|
||||||
Mixer::manager().insertSource(new_source_preview_.getSource());
|
Mixer::manager().addSource(new_source_preview_.getSource());
|
||||||
selected_button[NAV_NEW] = false;
|
selected_button[NAV_NEW] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1297,7 +1297,7 @@ void Navigator::RenderNewPannel()
|
|||||||
new_source_preview_.draw(ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN);
|
new_source_preview_.draw(ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN);
|
||||||
// ask to import the source in the mixer
|
// ask to import the source in the mixer
|
||||||
if ( ImGui::Button("Import", ImVec2(pannel_width_ - padding_width_, 0)) ) {
|
if ( ImGui::Button("Import", ImVec2(pannel_width_ - padding_width_, 0)) ) {
|
||||||
Mixer::manager().insertSource(new_source_preview_.getSource());
|
Mixer::manager().addSource(new_source_preview_.getSource());
|
||||||
selected_button[NAV_NEW] = false;
|
selected_button[NAV_NEW] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
23
View.cpp
23
View.cpp
@@ -175,6 +175,29 @@ View::Cursor MixingView::grab (glm::vec2 from, glm::vec2 to, Source *s, std::pai
|
|||||||
return Cursor(Cursor_ResizeAll, info.str() );
|
return Cursor(Cursor_ResizeAll, info.str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MixingView::setAlpha(Source *s)
|
||||||
|
{
|
||||||
|
if (!s)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// move the layer node of the source
|
||||||
|
Group *sourceNode = s->group(mode_);
|
||||||
|
glm::vec2 mix_pos = glm::vec2(sourceNode->translation_);
|
||||||
|
|
||||||
|
for(NodeSet::iterator it = scene.ws()->begin(); it != scene.ws()->end(); it++) {
|
||||||
|
|
||||||
|
if ( glm::distance(glm::vec2((*it)->translation_), mix_pos) < 0.001) {
|
||||||
|
mix_pos += glm::vec2(-0.03, 0.03);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceNode->translation_.x = mix_pos.x;
|
||||||
|
sourceNode->translation_.y = mix_pos.y;
|
||||||
|
|
||||||
|
// request update
|
||||||
|
s->touch();
|
||||||
|
}
|
||||||
|
|
||||||
uint MixingView::textureMixingQuadratic()
|
uint MixingView::textureMixingQuadratic()
|
||||||
{
|
{
|
||||||
static GLuint texid = 0;
|
static GLuint texid = 0;
|
||||||
|
|||||||
2
View.h
2
View.h
@@ -76,6 +76,8 @@ public:
|
|||||||
|
|
||||||
Cursor grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair<Node *, glm::vec2>) override;
|
Cursor grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair<Node *, glm::vec2>) override;
|
||||||
|
|
||||||
|
void setAlpha (Source *s);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint textureMixingQuadratic();
|
uint textureMixingQuadratic();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user