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;
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
7
Mixer.h
7
Mixer.h
@@ -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_;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
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() );
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user