From 44a31ede74fe0505b6c4fa9cbcf87d6b6b1479e2 Mon Sep 17 00:00:00 2001 From: Bruno Herbelin Date: Sun, 3 Sep 2023 18:13:43 +0200 Subject: [PATCH] BugFix and various improvements --- src/GeometryView.cpp | 12 +-- src/ImGuiVisitor.cpp | 146 ++++++++++++++++++++--------------- src/InfoVisitor.cpp | 9 ++- src/RenderingManager.cpp | 2 +- src/TransitionView.cpp | 1 + src/UserInterfaceManager.cpp | 9 ++- src/UserInterfaceManager.h | 2 +- 7 files changed, 104 insertions(+), 77 deletions(-) diff --git a/src/GeometryView.cpp b/src/GeometryView.cpp index b380b5b..8ffb01c 100644 --- a/src/GeometryView.cpp +++ b/src/GeometryView.cpp @@ -166,6 +166,12 @@ void GeometryView::update(float dt) (*node)->scale_.x = aspect_ratio; } output_surface_->setTextureIndex( output->texture() ); + + // set grid aspect ratio + if (Settings::application.proportional_grid) + translation_grid_->setAspectRatio( output->aspectRatio() ); + else + translation_grid_->setAspectRatio( 1.f ); } // prevent invalid scaling @@ -177,12 +183,6 @@ void GeometryView::update(float dt) const ImVec4 c = ImGuiToolkit::HighlightColor(); translation_grid_->setColor( glm::vec4(c.x, c.y, c.z, 0.3) ); rotation_grid_->setColor( glm::vec4(c.x, c.y, c.z, 0.3) ); - - // set grid aspect ratio - if (Settings::application.proportional_grid) - translation_grid_->setAspectRatio( Mixer::manager().session()->frame()->aspectRatio() ); - else - translation_grid_->setAspectRatio( 1.f ); } // the current view is the geometry view diff --git a/src/ImGuiVisitor.cpp b/src/ImGuiVisitor.cpp index 47b340c..8b29d1f 100644 --- a/src/ImGuiVisitor.cpp +++ b/src/ImGuiVisitor.cpp @@ -708,11 +708,11 @@ void ImGuiVisitor::visit (MediaSource& s) ImGui::SetCursorPos(botom); - // Selector for Hardware or software decoding, if available - if ( Settings::application.render.gpu_decoding ) { + MediaPlayer *mp = s.mediaplayer(); + if (mp && !mp->isImage()) { + // Selector for Hardware or software decoding, if available + if ( Settings::application.render.gpu_decoding ) { - MediaPlayer *mp = s.mediaplayer(); - if (mp) { // Build string information on decoder name with icon HW/SW bool hwdec = !mp->softwareDecodingForced(); std::string decoder = mp->decoderName(); @@ -737,12 +737,12 @@ void ImGuiVisitor::visit (MediaSource& s) ImGui::EndCombo(); } } - } - else { - // info of software only decoding if disabled - ImGuiToolkit::Icon(14,2,false); - ImGui::SameLine(); - ImGui::TextDisabled("Hardware decoding disabled"); + else { + // info of software only decoding if disabled + ImGuiToolkit::Icon(14,2,false); + ImGui::SameLine(); + ImGui::TextDisabled("Hardware decoding disabled"); + } } } @@ -786,69 +786,89 @@ void ImGuiVisitor::visit (SessionFileSource& s) ImVec2 botom = ImGui::GetCursorPos(); - if ( !s.failed() && s.session() != nullptr && s.session()->ready()) { - // versions - SessionSnapshots *versions = s.session()->snapshots(); - if (versions->keys_.size()>0) { - ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); - if (ImGui::BeginCombo("Version", ICON_FA_CODE_BRANCH " Select" ) ) - { - for (auto v = versions->keys_.crbegin() ; v != versions->keys_.crend(); ++v){ - std::string label = std::to_string(*v); - const tinyxml2::XMLElement *snap = versions->xmlDoc_->FirstChildElement( SNAPSHOT_NODE(*v).c_str() ); - if (snap) - label = snap->Attribute("label"); - if (ImGui::Selectable( label.c_str() )) { - s.session()->applySnapshot(*v); + if ( !s.failed() && s.session() != nullptr ) { + + if ( s.active() && s.session()->ready() ) { + // versions + SessionSnapshots *versions = s.session()->snapshots(); + if (versions->keys_.size()>0) { + ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); + if (ImGui::BeginCombo("Version", ICON_FA_CODE_BRANCH " Select" ) ) + { + for (auto v = versions->keys_.crbegin() ; v != versions->keys_.crend(); ++v){ + std::string label = std::to_string(*v); + const tinyxml2::XMLElement *snap = versions->xmlDoc_->FirstChildElement( SNAPSHOT_NODE(*v).c_str() ); + if (snap) + label = snap->Attribute("label"); + if (ImGui::Selectable( label.c_str() )) { + s.session()->applySnapshot(*v); + } } + ImGui::EndCombo(); } - ImGui::EndCombo(); } + + // fading + std::ostringstream oss; + int f = 100 - int(s.session()->fading() * 100.f); + ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); + if (ImGui::SliderInt("##Fading", &f, 0, 100, f > 99 ? ICON_FA_ADJUST " None" : ICON_FA_ADJUST " %d %%") ) + s.session()->setFadingTarget( float(100 - f) * 0.01f ); + if (ImGui::IsItemDeactivatedAfterEdit()){ + oss << s.name() << ": Fading " << f << " %"; + Action::manager().store(oss.str()); + } + ImGui::SameLine(0, IMGUI_SAME_LINE); + if (ImGuiToolkit::TextButton("Fading")) { + s.session()->setFadingTarget(0.f); + oss << s.name() << ": Fading 0 %"; + Action::manager().store(oss.str()); + } + + // import + if ( ImGui::Button( ICON_FA_FILE_EXPORT " Import all", ImVec2(IMGUI_RIGHT_ALIGN, 0)) ) + Mixer::manager().import( &s ); + ImGui::SameLine(0, IMGUI_SAME_LINE); + ImGui::Text("Sources"); + + // file open + if ( ImGui::Button( ICON_FA_FILE_UPLOAD " Open", ImVec2(IMGUI_RIGHT_ALIGN, 0)) ) + Mixer::manager().set( s.detach() ); + ImGui::SameLine(0, IMGUI_SAME_LINE); + ImGui::Text("Session"); + + botom = ImGui::GetCursorPos(); + + // icon (>) to open player + if ( s.playable() ) { + ImGui::SetCursorPos(top); + std::string msg = s.playing() ? "Open Player\n(source is playing)" : "Open Player\n(source is paused)"; + if (ImGuiToolkit::IconButton( s.playing() ? ICON_FA_PLAY_CIRCLE : ICON_FA_PAUSE_CIRCLE, msg.c_str())) + UserInterface::manager().showSourceEditor(&s); + top.x += ImGui::GetFrameHeight(); + } + } + else + { + // file open + if ( ImGui::Button( ICON_FA_ARROW_CIRCLE_RIGHT " Transition", ImVec2(IMGUI_RIGHT_ALIGN, 0)) ) + { + TransitionView *tv = static_cast(Mixer::manager().view(View::TRANSITION)); + tv->attach(&s); + Mixer::manager().setView(View::TRANSITION); + WorkspaceWindow::clearWorkspace(); + } + ImGui::SameLine(0, IMGUI_SAME_LINE); + ImGui::Text("Session"); - // fading - std::ostringstream oss; - int f = 100 - int(s.session()->fading() * 100.f); - ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); - if (ImGui::SliderInt("##Fading", &f, 0, 100, f > 99 ? ICON_FA_ADJUST " None" : ICON_FA_ADJUST " %d %%") ) - s.session()->setFadingTarget( float(100 - f) * 0.01f ); - if (ImGui::IsItemDeactivatedAfterEdit()){ - oss << s.name() << ": Fading " << f << " %"; - Action::manager().store(oss.str()); - } - ImGui::SameLine(0, IMGUI_SAME_LINE); - if (ImGuiToolkit::TextButton("Fading")) { - s.session()->setFadingTarget(0.f); - oss << s.name() << ": Fading 0 %"; - Action::manager().store(oss.str()); - } - - // import - if ( ImGui::Button( ICON_FA_FILE_EXPORT " Import all", ImVec2(IMGUI_RIGHT_ALIGN, 0)) ) - Mixer::manager().import( &s ); - ImGui::SameLine(0, IMGUI_SAME_LINE); - ImGui::Text("Sources"); - - // file open - if ( ImGui::Button( ICON_FA_FILE_UPLOAD " Open", ImVec2(IMGUI_RIGHT_ALIGN, 0)) ) - Mixer::manager().set( s.detach() ); - ImGui::SameLine(0, IMGUI_SAME_LINE); - ImGui::Text("Session"); - - botom = ImGui::GetCursorPos(); - - // icon (>) to open player - if ( s.playable() ) { - ImGui::SetCursorPos(top); - std::string msg = s.playing() ? "Open Player\n(source is playing)" : "Open Player\n(source is paused)"; - if (ImGuiToolkit::IconButton( s.playing() ? ICON_FA_PLAY_CIRCLE : ICON_FA_PAUSE_CIRCLE, msg.c_str())) - UserInterface::manager().showSourceEditor(&s); - top.x += ImGui::GetFrameHeight(); + botom = ImGui::GetCursorPos(); } ImGui::SetCursorPos(top); if (ImGuiToolkit::IconButton(ICON_FA_FOLDER_OPEN, "Show in finder")) SystemToolkit::open(SystemToolkit::path_filename(s.path())); + } else info.reset(); diff --git a/src/InfoVisitor.cpp b/src/InfoVisitor.cpp index f0ca460..839bea8 100644 --- a/src/InfoVisitor.cpp +++ b/src/InfoVisitor.cpp @@ -165,13 +165,14 @@ void InfoVisitor::visit (SessionFileSource& s) oss << "Child session (" << numsource << "), RGB" << std::endl; oss << s.session()->frame()->width() << " x " << s.session()->frame()->height(); } + + current_id_ = s.id(); } else { oss << s.path() << std::endl << std::endl << "Failed to load."; } information_ = oss.str(); - current_id_ = s.id(); } void InfoVisitor::visit (SessionGroupSource& s) @@ -199,13 +200,13 @@ void InfoVisitor::visit (SessionGroupSource& s) oss << (s.session()->frame()->flags() & FrameBuffer::FrameBuffer_alpha ? "RGBA" : "RGB") << std::endl; oss << s.session()->frame()->width() << " x " << s.session()->frame()->height(); } + current_id_ = s.id(); } else { - oss << "Empty bundle."; + oss << std::endl << "Empty bundle."; } information_ = oss.str(); - current_id_ = s.id(); } void InfoVisitor::visit (RenderSource& s) @@ -253,12 +254,12 @@ void InfoVisitor::visit (CloneSource& s) oss << std::get<2>(FrameBufferFilter::Types[s.filter()->type()]) << " filter" << std::endl; oss << s.frame()->width() << " x " << s.frame()->height(); } + current_id_ = s.id(); } else oss << "Undefined"; information_ = oss.str(); - current_id_ = s.id(); } void InfoVisitor::visit (PatternSource& s) diff --git a/src/RenderingManager.cpp b/src/RenderingManager.cpp index 15512ca..d5d68ab 100644 --- a/src/RenderingManager.cpp +++ b/src/RenderingManager.cpp @@ -587,7 +587,7 @@ void Rendering::FileDropped(GLFWwindow *, int path_count, const char* paths[]) Mixer::manager().addSource ( Mixer::manager().createSourceFile( filename ) ); } if (i>0) { - UserInterface::manager().showPannel(); + UserInterface::manager().showPannel( Mixer::manager().numSource() ); Rendering::manager().mainWindow().show(); } } diff --git a/src/TransitionView.cpp b/src/TransitionView.cpp index ac17bd3..27b7169 100644 --- a/src/TransitionView.cpp +++ b/src/TransitionView.cpp @@ -163,6 +163,7 @@ void TransitionView::update(float dt) if (d > 0.2f) { Mixer::manager().setView(View::MIXING); WorkspaceWindow::restoreWorkspace(); + UserInterface::manager().showPannel(NAV_MENU); } } } diff --git a/src/UserInterfaceManager.cpp b/src/UserInterfaceManager.cpp index 9619054..82a1133 100644 --- a/src/UserInterfaceManager.cpp +++ b/src/UserInterfaceManager.cpp @@ -2757,12 +2757,17 @@ void Navigator::togglePannelNew() selected_button[NAV_NEW] = !selected_button[NAV_NEW]; applyButtonSelection(NAV_NEW); new_media_mode_changed = true; + + if (Settings::application.pannel_always_visible) + showPannelSource( Mixer::manager().numSource() ); + } void Navigator::togglePannelAutoHide() { // toggle variable Settings::application.pannel_always_visible = !Settings::application.pannel_always_visible; + // initiate change if (Settings::application.pannel_always_visible) { int current = Mixer::manager().indexCurrentSource(); @@ -4374,7 +4379,7 @@ void Navigator::RenderMainPannelVimix() // Thumbnail static Thumbnail _file_thumbnail; static FrameBufferImage *thumbnail = nullptr; - if ( ImGui::Button( ICON_FA_TAG " Create thumbnail", ImVec2(IMGUI_RIGHT_ALIGN, 0)) ) { + if ( ImGui::Button( ICON_FA_TAG " Set thumbnail", ImVec2(IMGUI_RIGHT_ALIGN, 0)) ) { Mixer::manager().session()->setThumbnail(); thumbnail = nullptr; } @@ -4397,7 +4402,7 @@ void Navigator::RenderMainPannelVimix() if (Mixer::manager().session()->thumbnail()) { ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.7); ImGui::SameLine(); - if (ImGuiToolkit::IconButton(ICON_FA_BACKSPACE, "Remove thumbnail")) { + if (ImGuiToolkit::IconButton(ICON_FA_BACKSPACE, "Clear thumbnail")) { Mixer::manager().session()->resetThumbnail(); _file_thumbnail.reset(); thumbnail = nullptr; diff --git a/src/UserInterfaceManager.h b/src/UserInterfaceManager.h index 9f18fc9..54541ce 100644 --- a/src/UserInterfaceManager.h +++ b/src/UserInterfaceManager.h @@ -166,7 +166,7 @@ public: inline bool altModifier() const { return alt_modifier_active; } inline bool shiftModifier() const { return shift_modifier_active; } - void showPannel(int id = 0); + void showPannel(int id = -1); void setSourceInPanel(int index); void setSourceInPanel(Source *s); Source *sourceInPanel();