Cleanup UI for source info, cleanup code

This commit is contained in:
Bruno Herbelin
2022-01-16 17:47:43 +01:00
parent ddccc5ff6b
commit e52785a8b4
7 changed files with 78 additions and 45 deletions

View File

@@ -141,7 +141,9 @@ void CloneSource::setActive (bool on)
void CloneSource::update(float dt) void CloneSource::update(float dt)
{ {
if (active_ && !paused_ && origin_ && cloningsurface_ != nullptr) { Source::update(dt);
if (!paused_ && origin_ && cloningsurface_ != nullptr) {
double now = g_timer_elapsed (timer_, NULL) ; double now = g_timer_elapsed (timer_, NULL) ;
@@ -179,10 +181,7 @@ void CloneSource::update(float dt)
// update the source surface to be rendered // update the source surface to be rendered
texturesurface_->setTextureIndex( stack_[read_index_]->texture() ); texturesurface_->setTextureIndex( stack_[read_index_]->texture() );
} }
Source::update(dt);
} }

View File

@@ -702,10 +702,23 @@ void ImGuiVisitor::visit (RenderSource& s)
ImGuiToolkit::Icon(s.icon().x, s.icon().y); ImGuiToolkit::Icon(s.icon().x, s.icon().y);
ImGui::SameLine(0, IMGUI_SAME_LINE); ImGui::SameLine(0, IMGUI_SAME_LINE);
ImGui::Text("Rendering Output"); ImGui::Text("Rendering Output");
if ( ImGui::Button(ICON_FA_DESKTOP " Show window", ImVec2(IMGUI_RIGHT_ALIGN, 0)) )
// info
ImGui::PushTextWrapPos(ImGui::GetCursorPos().x + ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN);
s.accept(info);
ImGui::Text("%s", info.str().c_str());
ImGui::PopTextWrapPos();
// icon (>) to open player
ImVec2 pos = ImGui::GetCursorPos();
ImGui::SameLine(0, 0);
ImGui::SameLine(0, 10.f + ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN);
if (ImGuiToolkit::IconButton(ICON_FA_PLAY_CIRCLE, "Open in Player"))
UserInterface::manager().showSourceEditor(&s);
ImGui::SameLine();
if (ImGuiToolkit::IconButton(ICON_FA_DESKTOP, "Show Output"))
Settings::application.widget.preview = true; Settings::application.widget.preview = true;
ImGui::SameLine(0, IMGUI_SAME_LINE); ImGui::SetCursorPos(pos);
ImGui::Text("Output");
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
int m = (int) s.renderingProvenance(); int m = (int) s.renderingProvenance();
@@ -719,10 +732,25 @@ void ImGuiVisitor::visit (CloneSource& s)
ImGuiToolkit::Icon(s.icon().x, s.icon().y); ImGuiToolkit::Icon(s.icon().x, s.icon().y);
ImGui::SameLine(0, IMGUI_SAME_LINE); ImGui::SameLine(0, IMGUI_SAME_LINE);
ImGui::Text("Clone"); ImGui::Text("Clone");
// info
ImGui::PushTextWrapPos(ImGui::GetCursorPos().x + ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN);
s.accept(info);
ImGui::Text("%s", info.str().c_str());
ImGui::PopTextWrapPos();
// icon (>) to open player
ImVec2 pos = ImGui::GetCursorPos();
ImGui::SameLine(0, 0);
ImGui::SameLine(0, 10.f + ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN);
if (ImGuiToolkit::IconButton(ICON_FA_PLAY_CIRCLE, "Open in Player"))
UserInterface::manager().showSourceEditor(&s);
ImGui::SetCursorPos(pos);
if ( ImGui::Button(s.origin()->name().c_str(), ImVec2(IMGUI_RIGHT_ALIGN, 0)) ) if ( ImGui::Button(s.origin()->name().c_str(), ImVec2(IMGUI_RIGHT_ALIGN, 0)) )
Mixer::manager().setCurrentSource(s.origin()); Mixer::manager().setCurrentSource(s.origin());
ImGui::SameLine(0, IMGUI_SAME_LINE); ImGui::SameLine(0, IMGUI_SAME_LINE);
ImGui::Text("Source"); ImGui::Text("Origin");
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
int m = (int) s.cloningProvenance(); int m = (int) s.cloningProvenance();

View File

@@ -174,16 +174,15 @@ void InfoVisitor::visit (RenderSource& s)
return; return;
std::ostringstream oss; std::ostringstream oss;
if (!brief_) {
oss << "Rendering Output ("; oss << "Rendering Output (";
oss << RenderSource::rendering_provenance_label[s.renderingProvenance()]; oss << RenderSource::rendering_provenance_label[s.renderingProvenance()];
oss << ") " << std::endl; oss << ") " << std::endl;
}
if (s.frame()){ if (s.frame()){
oss << s.frame()->width() << " x " << s.frame()->height() << ", "; oss << s.frame()->width() << " x " << s.frame()->height() << ", ";
if (s.frame()->use_alpha()) oss << (s.frame()->use_alpha() ? "RGBA" : "RGB");
oss << "RGBA";
else
oss << "RGB";
} }
information_ = oss.str(); information_ = oss.str();
@@ -196,16 +195,15 @@ void InfoVisitor::visit (CloneSource& s)
return; return;
std::ostringstream oss; std::ostringstream oss;
if (!brief_) {
oss << "Clone of '" << s.origin()->name() << "' ("; oss << "Clone of '" << s.origin()->name() << "' (";
oss << CloneSource::cloning_provenance_label[s.cloningProvenance()]; oss << CloneSource::cloning_provenance_label[s.cloningProvenance()];
oss << ") " << std::endl; oss << ") " << std::endl;
}
if (s.frame()){ if (s.frame()){
oss << s.frame()->width() << " x " << s.frame()->height() << ", "; oss << s.frame()->width() << " x " << s.frame()->height() << ", ";
if (s.frame()->use_alpha()) oss << (s.frame()->use_alpha() ? "RGBA" : "RGB");
oss << "RGBA";
else
oss << "RGB";
} }
information_ = oss.str(); information_ = oss.str();
@@ -218,10 +216,12 @@ void InfoVisitor::visit (PatternSource& s)
return; return;
std::ostringstream oss; std::ostringstream oss;
oss << Pattern::get(s.pattern()->type()).label << std::endl; if (!brief_)
oss << Pattern::get(s.pattern()->type()).label << " pattern" << std::endl;
if (s.pattern()) { if (s.pattern()) {
oss << s.pattern()->width() << " x " << s.pattern()->height(); oss << s.pattern()->width() << " x " << s.pattern()->height();
oss << ", RGB"; oss << ", RGBA";
} }
information_ = oss.str(); information_ = oss.str();
@@ -313,10 +313,13 @@ void InfoVisitor::visit (GenericStreamSource& s)
std::ostringstream oss; std::ostringstream oss;
if (s.stream()) { if (s.stream()) {
std::string src_element = s.gstElements().front(); std::string src_element = s.gstElements().front();
if (brief_)
src_element = src_element.substr(0, src_element.find(" ")); src_element = src_element.substr(0, src_element.find(" "));
oss << "gstreamer '" << src_element << "'" << std::endl; oss << "gstreamer '" << src_element << "'" << std::endl;
oss << s.stream()->width() << " x " << s.stream()->height(); oss << s.stream()->width() << " x " << s.stream()->height();
oss << ", RGB"; oss << ", RGBA";
} }
else else
oss << "Undefined"; oss << "Undefined";

View File

@@ -102,14 +102,15 @@ void RenderSource::init()
void RenderSource::update(float dt) void RenderSource::update(float dt)
{ {
static glm::mat4 projection = glm::ortho(-1.f, 1.f, 1.f, -1.f, -SCENE_DEPTH, 1.f); Source::update(dt);
if (active_ && !paused_ && session_ && rendered_output_) { if (!paused_ && session_ && rendered_output_) {
if (provenance_ == RENDER_EXCLUSIVE) { if (provenance_ == RENDER_EXCLUSIVE) {
// temporarily exclude this RenderSource from the rendering // temporarily exclude this RenderSource from the rendering
groups_[View::RENDERING]->visible_ = false; groups_[View::RENDERING]->visible_ = false;
// simulate a rendering of the session in a framebuffer // simulate a rendering of the session in a framebuffer
static glm::mat4 projection = glm::ortho(-1.f, 1.f, 1.f, -1.f, -SCENE_DEPTH, 1.f);
glm::mat4 P = glm::scale( projection, glm::vec3(1.f / rendered_output_->aspectRatio(), 1.f, 1.f)); glm::mat4 P = glm::scale( projection, glm::vec3(1.f / rendered_output_->aspectRatio(), 1.f, 1.f));
rendered_output_->begin(); rendered_output_->begin();
// access to private RenderView in the session to call draw on the root of the scene // access to private RenderView in the session to call draw on the root of the scene
@@ -128,7 +129,6 @@ void RenderSource::update(float dt)
// rendered_output_->end(); // rendered_output_->end();
} }
Source::update(dt);
} }
void RenderSource::play (bool on) void RenderSource::play (bool on)

View File

@@ -133,7 +133,7 @@ void Session::update(float dt)
// update the source // update the source
(*it)->setActive(activation_threshold_); (*it)->setActive(activation_threshold_);
(*it)->update(dt); (*it)->update(dt);
// render the source // TODO: verify ok to render after update // render the source
(*it)->render(); (*it)->render();
} }
} }

View File

@@ -98,6 +98,8 @@ void SessionSource::setActive (bool on)
void SessionSource::update(float dt) void SessionSource::update(float dt)
{ {
Source::update(dt);
if (session_ == nullptr) if (session_ == nullptr)
return; return;
@@ -115,7 +117,6 @@ void SessionSource::update(float dt)
failed_ = true; failed_ = true;
} }
Source::update(dt);
} }
void SessionSource::replay () void SessionSource::replay ()

View File

@@ -616,7 +616,7 @@ void SessionVisitor::visit (SessionGroupSource& s)
xmlCurrent_->SetAttribute("type", "GroupSource"); xmlCurrent_->SetAttribute("type", "GroupSource");
Session *se = s.session(); Session *se = s.session();
if (se) {
XMLElement *sessionNode = xmlDoc_->NewElement("Session"); XMLElement *sessionNode = xmlDoc_->NewElement("Session");
xmlCurrent_->InsertEndChild(sessionNode); xmlCurrent_->InsertEndChild(sessionNode);
@@ -624,7 +624,7 @@ void SessionVisitor::visit (SessionGroupSource& s)
setRoot(sessionNode); setRoot(sessionNode);
(*iter)->accept(*this); (*iter)->accept(*this);
} }
}
} }
void SessionVisitor::visit (RenderSource& s) void SessionVisitor::visit (RenderSource& s)
@@ -636,6 +636,8 @@ void SessionVisitor::visit (RenderSource& s)
void SessionVisitor::visit (CloneSource& s) void SessionVisitor::visit (CloneSource& s)
{ {
xmlCurrent_->SetAttribute("type", "CloneSource"); xmlCurrent_->SetAttribute("type", "CloneSource");
if (s.origin()) {
xmlCurrent_->SetAttribute("provenance", (int) s.cloningProvenance()); xmlCurrent_->SetAttribute("provenance", (int) s.cloningProvenance());
xmlCurrent_->SetAttribute("delay", (double) s.delay()); xmlCurrent_->SetAttribute("delay", (double) s.delay());
@@ -645,7 +647,7 @@ void SessionVisitor::visit (CloneSource& s)
xmlCurrent_->InsertEndChild(origin); xmlCurrent_->InsertEndChild(origin);
XMLText *text = xmlDoc_->NewText( s.origin()->name().c_str() ); XMLText *text = xmlDoc_->NewText( s.origin()->name().c_str() );
origin->InsertEndChild( text ); origin->InsertEndChild( text );
}
} }
void SessionVisitor::visit (PatternSource& s) void SessionVisitor::visit (PatternSource& s)