diff --git a/ImGuiVisitor.cpp b/ImGuiVisitor.cpp index b02cd6d..b7a64c7 100644 --- a/ImGuiVisitor.cpp +++ b/ImGuiVisitor.cpp @@ -53,7 +53,7 @@ void ImGuiVisitor::visit(Group &n) ImGui::SameLine(0, 10); float translation[2] = { n.translation_.x, n.translation_.y}; ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); - if ( ImGui::SliderFloat2("position", translation, -5.0, 5.0) ) + if ( ImGui::SliderFloat2("Position", translation, -5.0, 5.0) ) { n.translation_.x = translation[0]; n.translation_.y = translation[1]; @@ -63,7 +63,7 @@ void ImGuiVisitor::visit(Group &n) n.rotation_.z = 0.f; ImGui::SameLine(0, 10); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); - ImGui::SliderAngle("angle", &(n.rotation_.z), -180.f, 180.f) ; + ImGui::SliderAngle("Angle", &(n.rotation_.z), -180.f, 180.f) ; if (ImGuiToolkit::ButtonIcon(3, 15)) { n.scale_.x = 1.f; @@ -72,7 +72,7 @@ void ImGuiVisitor::visit(Group &n) ImGui::SameLine(0, 10); float scale[2] = { n.scale_.x, n.scale_.y} ; ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); - if ( ImGui::SliderFloat2("scale", scale, -5.0, 5.0, "%.2f") ) + if ( ImGui::SliderFloat2("Scale", scale, -5.0, 5.0, "%.2f") ) { n.scale_.x = scale[0]; n.scale_.y = scale[1]; @@ -196,20 +196,20 @@ void ImGuiVisitor::visit(ImageProcessingShader &n) ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SliderFloat("Hue shift", &n.hueshift, 0.0, 1.0); - if (ImGuiToolkit::ButtonIcon(8, 1)) n.threshold = 0.f; - ImGui::SameLine(0, 10); - ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); - ImGui::SliderFloat("Threshold", &n.threshold, 0.0, 1.0); - if (ImGuiToolkit::ButtonIcon(3, 1)) n.lumakey = 0.f; ImGui::SameLine(0, 10); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::SliderFloat("Lumakey", &n.lumakey, 0.0, 1.0); + if (ImGuiToolkit::ButtonIcon(8, 1)) n.threshold = 0.f; + ImGui::SameLine(0, 10); + ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); + ImGui::SliderFloat("Threshold", &n.threshold, 0.0, 1.0, n.threshold < 0.001 ? "None" : "%.2f"); + if (ImGuiToolkit::ButtonIcon(18, 1)) n.nbColors = 0; ImGui::SameLine(0, 10); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); - ImGui::SliderInt("Posterize", &n.nbColors, 0, 16, "%d colors"); + ImGui::SliderInt("Posterize", &n.nbColors, 0, 16, n.nbColors == 0 ? "None" : "%d colors"); if (ImGuiToolkit::ButtonIcon(1, 7)) n.filterid = 0; ImGui::SameLine(0, 10); @@ -229,7 +229,7 @@ void ImGuiVisitor::visit(ImageProcessingShader &n) ImGui::ColorEdit3("Chroma color", glm::value_ptr(n.chromakey), ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel ) ; ImGui::SameLine(0, 5); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); - ImGui::SliderFloat("Chromakey", &n.chromadelta, 0.0, 1.0, "%.2f tolerance"); + ImGui::SliderFloat("Chromakey", &n.chromadelta, 0.0, 1.0, n.chromadelta < 0.001 ? "None" : "Tolerance %.2f"); ImGui::PopID(); } diff --git a/Source.cpp b/Source.cpp index 1bed584..0e5facc 100644 --- a/Source.cpp +++ b/Source.cpp @@ -16,11 +16,13 @@ #include "Log.h" -Source::Source(const std::string &name) : name_(name), initialized_(false), need_update_(true) +Source::Source() : initialized_(false), need_update_(true) { sprintf(initials_, "__"); + name_ = "Source"; + + // create groups and overlays for each view - // create groups for each view // default rendering node groups_[View::RENDERING] = new Group; groups_[View::RENDERING]->visible_ = false; @@ -53,7 +55,7 @@ Source::Source(const std::string &name) : name_(name), initialized_(false), need groups_[View::GEOMETRY]->attach(overlays_[View::GEOMETRY]); // default mixing nodes - groups_[View::LAYER] = new Group; + groups_[View::LAYER] = new Group; groups_[View::LAYER]->visible_ = false; frame = new Frame(Frame::ROUND_SHADOW); frame->translation_.z = 0.1; @@ -83,13 +85,14 @@ Source::~Source() delete renderbuffer_; // all groups and their children are deleted in the scene - // this includes rendersurface_ , overlay_, blendingshader_ and rendershader_ + // this includes rendersurface_, overlays, blendingshader_ and rendershader_ delete groups_[View::RENDERING]; delete groups_[View::MIXING]; delete groups_[View::GEOMETRY]; delete groups_[View::LAYER]; groups_.clear(); + overlays_.clear(); } @@ -127,7 +130,7 @@ void Source::update(float dt) groups_[View::RENDERING]->scale_ = groups_[View::GEOMETRY]->scale_; groups_[View::RENDERING]->rotation_ = groups_[View::GEOMETRY]->rotation_; - // MODIFY DEPTH + // MODIFY depth based on LAYER node groups_[View::MIXING]->translation_.z = groups_[View::LAYER]->translation_.z; groups_[View::GEOMETRY]->translation_.z = groups_[View::LAYER]->translation_.z; groups_[View::RENDERING]->translation_.z = groups_[View::LAYER]->translation_.z; @@ -170,7 +173,7 @@ bool hasNode::operator()(const Source* elem) const return false; } -MediaSource::MediaSource(const std::string &name) : Source(name), path_("") +MediaSource::MediaSource() : Source(), path_("") { // create media player mediaplayer_ = new MediaPlayer; diff --git a/Source.h b/Source.h index 02f52f5..d4beedb 100644 --- a/Source.h +++ b/Source.h @@ -21,7 +21,7 @@ class Source public: // create a source and add it to the list // only subclasses of sources can actually be instanciated - Source(const std::string &name = ""); + Source(); virtual ~Source(); // manipulate name of source @@ -125,7 +125,7 @@ private: class MediaSource : public Source { public: - MediaSource(const std::string &name = ""); + MediaSource(); ~MediaSource(); // implementation of source API diff --git a/UserInterfaceManager.cpp b/UserInterfaceManager.cpp index 8973b3e..1ea7ae1 100644 --- a/UserInterfaceManager.cpp +++ b/UserInterfaceManager.cpp @@ -580,8 +580,6 @@ void ToolBox::Render() case 3: { if ( Rendering::manager().CurrentScreenshot()->IsFull() ){ - std::time_t t = std::time(0); // get time now - std::tm* now = std::localtime(&t); std::string filename = SystemToolkit::date_time_string() + "_vmixcapture.png"; Rendering::manager().CurrentScreenshot()->SaveFile( filename.c_str() ); Rendering::manager().CurrentScreenshot()->Clear(); @@ -1052,6 +1050,8 @@ void Navigator::RenderSourcePannel(Source *s) // image processing pannel s->processingShader()->accept(v); s->groupNode(View::GEOMETRY)->accept(v); + // ensure change is applied + s->touch(); // delete button ImGui::Text(" "); if ( ImGui::Button("Delete", ImVec2(ImGui::GetContentRegionAvail().x, 0)) ) { diff --git a/View.cpp b/View.cpp index b783c97..8a52c7b 100644 --- a/View.cpp +++ b/View.cpp @@ -395,30 +395,15 @@ void LayerView::zoom (float factor) } -void LayerView::grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair pick) +void LayerView::setDepth (Source *s, float d) { if (!s) return; Group *sourceNode = s->group(mode_); - static glm::vec3 start_translation = glm::vec3(0.f); - static glm::vec2 start_position = glm::vec2(0.f); - - if ( start_position != from ) { - start_position = from; - start_translation = sourceNode->translation_; - } - - // unproject - glm::vec3 gl_Position_from = Rendering::manager().unProject(from, scene.root()->transform_); - glm::vec3 gl_Position_to = Rendering::manager().unProject(to, scene.root()->transform_); - - // compute delta translation - sourceNode->translation_ = start_translation + gl_Position_to - gl_Position_from; - // diagonal movement only - sourceNode->translation_.x = CLAMP( sourceNode->translation_.x, SCENE_DEPTH + 2.f, 0.f); + sourceNode->translation_.x = CLAMP( -d, SCENE_DEPTH + 2.f, 0.f); sourceNode->translation_.y = sourceNode->translation_.x / aspect_ratio; // change depth @@ -431,3 +416,27 @@ void LayerView::grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair pick) +{ + if (!s) + return; + + static glm::vec3 start_translation = glm::vec3(0.f); + static glm::vec2 start_position = glm::vec2(0.f); + + if ( start_position != from ) { + start_position = from; + start_translation = s->group(mode_)->translation_; + } + + // unproject + glm::vec3 gl_Position_from = Rendering::manager().unProject(from, scene.root()->transform_); + glm::vec3 gl_Position_to = Rendering::manager().unProject(to, scene.root()->transform_); + + // compute delta translation + glm::vec3 dest_translation = start_translation + gl_Position_to - gl_Position_from; + + // apply change + setDepth( s, -dest_translation.x ); +} + diff --git a/View.h b/View.h index 042988a..e86d6fc 100644 --- a/View.h +++ b/View.h @@ -89,6 +89,8 @@ public: void zoom (float factor) override; void grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair pick) override; + void setDepth (Source *, float d); + private: float aspect_ratio; };