Fixed insertion of new source (after drop or pannel) to setup depth and

mixing coordinates.
This commit is contained in:
brunoherbelin
2020-06-08 22:15:03 +02:00
parent dffab7d2df
commit 965b1032a5
6 changed files with 49 additions and 11 deletions

View File

@@ -186,6 +186,12 @@ void Mixer::update()
float dt = static_cast<float>( GST_TIME_AS_MSECONDS(current_time - update_time_) ) * 0.001f;
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
session_->update(dt);
@@ -276,6 +282,11 @@ Source * Mixer::createSourceClone(std::string namesource)
return s;
}
void Mixer::addSource(Source *s)
{
candidate_sources_.push_back(s);
}
void Mixer::insertSource(Source *s, bool makecurrent)
{
if ( s != nullptr )
@@ -283,14 +294,16 @@ void Mixer::insertSource(Source *s, bool makecurrent)
// Add source to Session
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
mixing_.scene.ws()->attach(s->group(View::MIXING));
geometry_.scene.ws()->attach(s->group(View::GEOMETRY));
layer_.scene.ws()->attach(s->group(View::LAYER));
// set a default depth to the new source
layer_.setDepth(s);
if (makecurrent) {
// set this new source as current
setCurrentSource( sit );
@@ -298,9 +311,7 @@ void Mixer::insertSource(Source *s, bool makecurrent)
// switch to Mixing view to show source created
setCurrentView(View::MIXING);
current_view_->update(0);
// current_view_->restoreSettings();
current_view_->centerSource(s);
}
}
}

View File

@@ -33,13 +33,13 @@ public:
// draw session and current view
void draw();
// manangement of sources
// creation of sources
Source * createSourceFile(std::string path);
Source * createSourceClone(std::string namesource);
Source * createSourceRender();
// operations on sources
void insertSource(Source *s, bool makecurrent = true);
void addSource(Source *s);
void deleteSource(Source *s);
void renameSource(Source *s, const std::string &newname);
@@ -76,6 +76,9 @@ protected:
Session *back_session_;
void swap();
SourceList candidate_sources_;
void insertSource(Source *s, bool makecurrent = true);
void setCurrentSource(SourceList::iterator it);
SourceList::iterator current_source_;
int current_source_index_;

View File

@@ -323,9 +323,8 @@ void Rendering::FileDropped(GLFWwindow *, int path_count, const char* paths[])
if (filename.empty())
break;
// try to create a source
Mixer::manager().insertSource ( Mixer::manager().createSourceFile( filename ) );
Mixer::manager().addSource ( Mixer::manager().createSourceFile( filename ) );
}
UserInterface::manager().showPannel();
}

View File

@@ -1261,7 +1261,7 @@ void Navigator::RenderNewPannel()
new_source_preview_.draw(ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN);
// or press Validate button
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;
}
}
@@ -1297,7 +1297,7 @@ void Navigator::RenderNewPannel()
new_source_preview_.draw(ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN);
// ask to import the source in the mixer
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;
}
}

View File

@@ -175,6 +175,29 @@ View::Cursor MixingView::grab (glm::vec2 from, glm::vec2 to, Source *s, std::pai
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()
{
static GLuint texid = 0;

2
View.h
View File

@@ -76,6 +76,8 @@ public:
Cursor grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair<Node *, glm::vec2>) override;
void setAlpha (Source *s);
private:
uint textureMixingQuadratic();
};