From f3dcc4e3e58fa4bb788d54865f6f17e586875393 Mon Sep 17 00:00:00 2001 From: brunoherbelin Date: Wed, 20 May 2020 23:37:36 +0200 Subject: [PATCH] Loading and saving SessionSource in vmx session file. --- ImGuiVisitor.cpp | 44 ++++++++++++++++++++++++++++++++++------ ImGuiVisitor.h | 3 +++ SessionCreator.cpp | 19 +++++++++++++++++ SessionCreator.h | 1 + SessionVisitor.cpp | 11 ++++++++++ SessionVisitor.h | 1 + UserInterfaceManager.cpp | 11 ++-------- Visitor.h | 2 ++ 8 files changed, 77 insertions(+), 15 deletions(-) diff --git a/ImGuiVisitor.cpp b/ImGuiVisitor.cpp index b7a64c7..9b5dabc 100644 --- a/ImGuiVisitor.cpp +++ b/ImGuiVisitor.cpp @@ -14,6 +14,8 @@ #include "ImageShader.h" #include "ImageProcessingShader.h" #include "MediaPlayer.h" +#include "MediaSource.h" +#include "SessionSource.h" #include "imgui.h" #include "ImGuiToolkit.h" @@ -99,6 +101,15 @@ void ImGuiVisitor::visit(Animation &n) } +void ImGuiVisitor::visit(Scene &n) +{ + ImGui::SetNextItemOpen(true, ImGuiCond_Once); + if (ImGui::CollapsingHeader("Scene Property Tree")) + { + n.root()->accept(*this); + } +} + void ImGuiVisitor::visit(Primitive &n) { ImGui::PushID(n.id()); @@ -234,13 +245,34 @@ void ImGuiVisitor::visit(ImageProcessingShader &n) ImGui::PopID(); } -void ImGuiVisitor::visit(Scene &n) + +void ImGuiVisitor::visit (Source& s) { - ImGui::SetNextItemOpen(true, ImGuiCond_Once); - if (ImGui::CollapsingHeader("Scene Property Tree")) - { - n.root()->accept(*this); - } + // blending + s.blendingShader()->accept(*this); + + // preview + float preview_width = ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN; + ImVec2 imagesize ( preview_width, preview_width / s.frame()->aspectRatio()); + ImGui::Image((void*)(uintptr_t) s.frame()->texture(), imagesize); + + // image processing pannel + s.processingShader()->accept(*this); + + // geometry direct control + s.groupNode(View::GEOMETRY)->accept(*this); + + // Action on source + ImGui::Button("Clone", ImVec2(IMGUI_RIGHT_ALIGN, 0)); } +void ImGuiVisitor::visit (MediaSource& s) +{ + ImGui::Button("Open Media Player", ImVec2(IMGUI_RIGHT_ALIGN, 0)); +} +void ImGuiVisitor::visit (SessionSource& s) +{ + ImGui::Button("Expand", ImVec2(IMGUI_RIGHT_ALIGN, 0)); + ImGui::Button("Make Current", ImVec2(IMGUI_RIGHT_ALIGN, 0)); +} diff --git a/ImGuiVisitor.h b/ImGuiVisitor.h index 2e6823e..c6c44a5 100644 --- a/ImGuiVisitor.h +++ b/ImGuiVisitor.h @@ -23,6 +23,9 @@ public: void visit(Shader& n) override; void visit(ImageShader& n) override; void visit(ImageProcessingShader& n) override; + void visit (Source& s) override; + void visit (MediaSource& s) override; + void visit (SessionSource& s) override; }; #endif // IMGUIVISITOR_H diff --git a/SessionCreator.cpp b/SessionCreator.cpp index 30cb870..c9c15f6 100644 --- a/SessionCreator.cpp +++ b/SessionCreator.cpp @@ -7,6 +7,7 @@ #include "Mesh.h" #include "Source.h" #include "MediaSource.h" +#include "SessionSource.h" #include "Session.h" #include "ImageShader.h" #include "ImageProcessingShader.h" @@ -67,11 +68,18 @@ void SessionCreator::loadSession(XMLElement *sessionNode) counter++; const char *pType = xmlCurrent_->Attribute("type"); + if (!pType) + continue; if ( std::string(pType) == "MediaSource") { MediaSource *new_media_source = new MediaSource(); new_media_source->accept(*this); session_->addSource(new_media_source); } + if ( std::string(pType) == "SessionSource") { + SessionSource *new_session_source = new SessionSource(); + new_session_source->accept(*this); + session_->addSource(new_session_source); + } // TODO : create other types of source } @@ -220,6 +228,17 @@ void SessionCreator::visit (MediaSource& s) s.mediaplayer()->accept(*this); } +void SessionCreator::visit (SessionSource& s) +{ + // set uri + XMLElement* pathNode = xmlCurrent_->FirstChildElement("path"); + if (pathNode) { + std::string path = std::string ( pathNode->GetText() ); + s.setPath(path); + } + +} + diff --git a/SessionCreator.h b/SessionCreator.h index 7fd541e..adbb2ac 100644 --- a/SessionCreator.h +++ b/SessionCreator.h @@ -46,6 +46,7 @@ public: void visit (Source& s) override; void visit (MediaSource& s) override; + void visit (SessionSource& s) override; static void XMLToNode(tinyxml2::XMLElement *xml, Node &n); }; diff --git a/SessionVisitor.cpp b/SessionVisitor.cpp index fe1ff05..5c25baf 100644 --- a/SessionVisitor.cpp +++ b/SessionVisitor.cpp @@ -6,6 +6,7 @@ #include "Mesh.h" #include "Source.h" #include "MediaSource.h" +#include "SessionSource.h" #include "ImageShader.h" #include "ImageProcessingShader.h" #include "MediaPlayer.h" @@ -338,3 +339,13 @@ void SessionVisitor::visit (MediaSource& s) s.mediaplayer()->accept(*this); } + +void SessionVisitor::visit (SessionSource& s) +{ + xmlCurrent_->SetAttribute("type", "SessionSource"); + + XMLElement *path = xmlDoc_->NewElement("path"); + xmlCurrent_->InsertEndChild(path); + XMLText *text = xmlDoc_->NewText( s.path().c_str() ); + path->InsertEndChild( text ); +} diff --git a/SessionVisitor.h b/SessionVisitor.h index c8736e6..52765f6 100644 --- a/SessionVisitor.h +++ b/SessionVisitor.h @@ -42,6 +42,7 @@ public: void visit (Source& s) override; void visit (MediaSource& s) override; + void visit (SessionSource& s) override; static tinyxml2::XMLElement *NodeToXML(Node &n, tinyxml2::XMLDocument *doc); }; diff --git a/UserInterfaceManager.cpp b/UserInterfaceManager.cpp index fe77ed8..265c17e 100644 --- a/UserInterfaceManager.cpp +++ b/UserInterfaceManager.cpp @@ -1028,16 +1028,9 @@ void Navigator::RenderSourcePannel(Source *s) if (ImGui::InputText("Name", buf5, 64, ImGuiInputTextFlags_CharsNoBlank)){ Mixer::manager().renameSource(s, buf5); } - // blending pannel + // Source pannel static ImGuiVisitor v; - s->blendingShader()->accept(v); - // preview - float preview_width = ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN; - ImVec2 imagesize ( preview_width, preview_width / s->frame()->aspectRatio()); - ImGui::Image((void*)(uintptr_t) s->frame()->texture(), imagesize); - // image processing pannel - s->processingShader()->accept(v); - s->groupNode(View::GEOMETRY)->accept(v); + s->accept(v); // ensure change is applied s->touch(); // delete button diff --git a/Visitor.h b/Visitor.h index 2440dab..544ae66 100644 --- a/Visitor.h +++ b/Visitor.h @@ -26,6 +26,7 @@ class ImageShader; class ImageProcessingShader; class Source; class MediaSource; +class SessionSource; // Declares the interface for the visitors class Visitor { @@ -58,6 +59,7 @@ public: // utility virtual void visit (Source&) {} virtual void visit (MediaSource&) {} + virtual void visit (SessionSource&) {} };