Fixed Source creation with new Active mechanism.

This commit is contained in:
brunoherbelin
2020-06-22 18:15:25 +02:00
parent 8684d6f2c2
commit 4df2063a47
6 changed files with 14 additions and 17 deletions

View File

@@ -274,6 +274,9 @@ GstClockTime MediaPlayer::position()
void MediaPlayer::enable(bool on)
{
if ( !ready_ )
return;
if ( enabled_ != on ) {
enabled_ = on;

View File

@@ -11,7 +11,7 @@
#include "Visitor.h"
#include "Log.h"
MediaSource::MediaSource() : Source(), path_(""), media_playing_(true)
MediaSource::MediaSource() : Source(), path_("")
{
// create media player
mediaplayer_ = new MediaPlayer;
@@ -35,7 +35,7 @@ void MediaSource::setPath(const std::string &p)
{
path_ = p;
mediaplayer_->open(path_);
mediaplayer_->play(media_playing_);
mediaplayer_->play(true);
Log::Notify("Opening %s", p.c_str());
}

View File

@@ -29,7 +29,6 @@ protected:
Surface *mediasurface_;
std::string path_;
MediaPlayer *mediaplayer_;
bool media_playing_;
};
#endif // MEDIASOURCE_H

View File

@@ -170,6 +170,7 @@ bool Rendering::init()
//
glfwWindowHint(GLFW_SAMPLES, 0); // no need for multisampling in displaying output
output_.init(1, main_.window());
output_.setIcon("images/vimix_256x256.png");
// special callbacks for user input in output window
glfwSetKeyCallback( output_.window(), WindowEscapeFullscreen);
glfwSetMouseButtonCallback( output_.window(), WindowToggleFullscreen);

View File

@@ -176,7 +176,7 @@ void Source::setMode(Source::Mode m)
}
// choose frame if selected
uint index_frame = m == Source::SELECTED ? 1 : 0;
uint index_frame = m == Source::VISIBLE ? 0 : 1;
for (auto f = frames_.begin(); f != frames_.end(); f++)
(*f).second->setActive(index_frame);

View File

@@ -381,7 +381,6 @@ void UserInterface::handleMouse()
if ( !mousedown )
{
Log::Info("LMB down");
mousedown = true;
// ask the view what was picked
@@ -412,16 +411,11 @@ void UserInterface::handleMouse()
s = nullptr;
}
}
// Mixer::selection().toggle( Mixer::manager().currentSource() );
}
{
Mixer::manager().setCurrentSource( s );
if (navigator.pannelVisible())
navigator.showPannelSource( Mixer::manager().indexCurrentSource() );
}
Mixer::manager().setCurrentSource( s );
if (navigator.pannelVisible())
navigator.showPannelSource( Mixer::manager().indexCurrentSource() );
// indicate to view that an action can be initiated (e.g. grab)
Mixer::manager().view()->initiate();
@@ -432,20 +426,17 @@ void UserInterface::handleMouse()
}
else if ( ImGui::IsMouseReleased(ImGuiMouseButton_Left) )
{
Log::Info("LMB release");
mousedown = false;
// picked = { nullptr, glm::vec2(0.f) };
picked = { nullptr, glm::vec2(0.f) };
}
if ( ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left) )
{
Log::Info("LMB double clic");
// display source in left pannel
navigator.showPannelSource( Mixer::manager().indexCurrentSource() );
// discard current to select front most source
// (because single clic maintains same source active)
Mixer::manager().unsetCurrentSource();
}
// if ( mousedown && glm::distance(mouseclic[ImGuiMouseButton_Left], mousepos) > 3.f )
@@ -1252,6 +1243,9 @@ void SourcePreview::draw(float width)
setSource();
else
{
// update source
ImGuiIO& io = ImGui::GetIO();
source_->update( 1.f / io.Framerate);
// render framebuffer
source_->render();
// draw preview