From 3909aa4ab7e95cc5921599373d6620a5ea66e117 Mon Sep 17 00:00:00 2001 From: Bruno Herbelin Date: Sat, 5 Oct 2024 01:07:05 +0200 Subject: [PATCH] Minor improvements Display hourglass in left panel to inform source is loading and prevent buttons when loading + Varia. --- src/ImGuiVisitor.cpp | 26 ++++++++--- src/ImageFilter.cpp | 4 +- src/MediaPlayer.cpp | 2 +- src/TextSource.cpp | 4 +- src/UserInterfaceManager.cpp | 89 +++++++++++++++++++----------------- 5 files changed, 71 insertions(+), 54 deletions(-) diff --git a/src/ImGuiVisitor.cpp b/src/ImGuiVisitor.cpp index 0fc108c..3e9b40b 100644 --- a/src/ImGuiVisitor.cpp +++ b/src/ImGuiVisitor.cpp @@ -463,7 +463,15 @@ void ImGuiVisitor::visit (Source& s) if (s.ready()) { ImGui::SetCursorPos( ImVec2(pos.x + 0.5f * (preview_width-width), pos.y + 0.5f * (preview_height-height-space)) ); ImGui::Image((void*)(uintptr_t) s.frame()->texture(), ImVec2(width, height)); + } else { + ImGuiToolkit::PushFont(ImGuiToolkit::FONT_LARGE); + ImGui::SetCursorPos( + ImVec2(pos.x + (preview_width - ImGui::GetFrameHeight()) * 0.5f, + pos.y + (preview_height - ImGui::GetFrameHeight()) * 0.5f)); + ImGui::Text(ICON_FA_HOURGLASS_HALF); + ImGui::PopFont(); } + // inform on visibility status ImGui::SetCursorPos( ImVec2(preview_width + 20, pos.y ) ); if (s.active()) { @@ -637,9 +645,9 @@ void ImGuiVisitor::visit (Source& s) ImGui::Image((void*)(uintptr_t) s.frame()->texture(), ImVec2(width, height)); // centered icon of failed (skull) - ImGui::SetCursorPos( ImVec2(pos.x + (width -ImGui::GetFrameHeightWithSpacing())* 0.5f , - pos.y + (height -ImGui::GetFrameHeightWithSpacing()) * 0.5f) ); ImGuiToolkit::PushFont(ImGuiToolkit::FONT_LARGE); + ImGui::SetCursorPos( ImVec2(pos.x + (preview_width -ImGui::GetFrameHeight())* 0.5f , + pos.y + (preview_height -ImGui::GetFrameHeight()) * 0.5f) ); ImGui::Text(ICON_FA_SKULL); ImGui::PopFont(); @@ -753,10 +761,12 @@ void ImGuiVisitor::visit (MediaSource& s) ImGui::SetCursorPos(botom); // because sometimes the error comes from gpu decoding - if ( Settings::application.render.gpu_decoding && SystemToolkit::file_exists(s.path()) ) + if ( Settings::application.render.gpu_decoding && + SystemToolkit::file_exists(s.path()) && + !s.mediaplayer()->softwareDecodingForced() ) { // offer to reload the source without hardware decoding - if ( ImGui::Button( ICON_FA_REDO_ALT " Try again without\nhardware decoding", ImVec2(IMGUI_RIGHT_ALIGN, 0)) ) { + if ( ImGui::Button( ICON_FA_REDO_ALT " Try again ", ImVec2(IMGUI_RIGHT_ALIGN, 0)) ) { // replace current source with one created with a flag forcing software decoding Mixer::manager().replaceSource(Mixer::manager().currentSource(), Mixer::manager().createSourceFile(s.path(), true)); @@ -1420,8 +1430,10 @@ void ImGuiVisitor::visit (PatternSource& s) { for (uint p = 0; p < Pattern::count(); ++p){ pattern_descriptor pattern = Pattern::get(p); - std::string label = pattern.label + (pattern.animated ? " " ICON_FA_PLAY_CIRCLE : " "); - if (pattern.available && ImGui::Selectable( label.c_str(), p == s.pattern()->type() )) { + std::string label = pattern.label; + if (pattern.available && + pattern.animated == s.playable() && + ImGui::Selectable( label.c_str(), p == s.pattern()->type() )) { s.setPattern(p, s.pattern()->resolution()); info.reset(); std::ostringstream oss; @@ -1448,7 +1460,7 @@ void ImGuiVisitor::visit (PatternSource& s) top.x += ImGui::GetFrameHeight(); } ImGui::SetCursorPos(top); - if (ImGuiToolkit::IconButton(ICON_FA_COPY, "Copy")) + if (ImGuiToolkit::IconButton(ICON_FA_COPY, "Copy gstreamer code")) ImGui::SetClipboardText(Pattern::get( s.pattern()->type() ).pipeline.c_str()); } else diff --git a/src/ImageFilter.cpp b/src/ImageFilter.cpp index 21a758c..d3fe349 100644 --- a/src/ImageFilter.cpp +++ b/src/ImageFilter.cpp @@ -657,7 +657,7 @@ const char* BlurFilter::method_label[BlurFilter::BLUR_INVALID] = { }; std::vector< FilteringProgram > BlurFilter::programs_ = { - FilteringProgram("Gaussian", "shaders/filters/blur_1.glsl", "shaders/filters/blur_2.glsl", { { "Radius", 0.5} }), + FilteringProgram("Gaussian", "shaders/filters/blur_1.glsl", "shaders/filters/blur_2.glsl", { { "Radius", 0.55} }), FilteringProgram("Scattered","shaders/filters/hashedblur.glsl", "", { { "Radius", 0.5}, { "Iterations", 0.25 } }), FilteringProgram("Opening", "shaders/filters/hashederosion.glsl", "shaders/filters/hasheddilation.glsl", { { "Radius", 0.5} }), FilteringProgram("Closing", "shaders/filters/hasheddilation.glsl","shaders/filters/hashederosion.glsl", { { "Radius", 0.5} }), @@ -800,7 +800,7 @@ const char* SharpenFilter::method_label[SharpenFilter::SHARPEN_INVALID] = { }; std::vector< FilteringProgram > SharpenFilter::programs_ = { - FilteringProgram("UnsharpMask", "shaders/filters/sharpen_1.glsl", "shaders/filters/sharpen_2.glsl", { { "Amount", 0.5} }), + FilteringProgram("UnsharpMask", "shaders/filters/sharpen_1.glsl", "shaders/filters/sharpen_2.glsl", { { "Amount", 0.25} }), FilteringProgram("Sharpen", "shaders/filters/sharpen.glsl", "", { { "Amount", 0.5} }), FilteringProgram("Sharp Edge", "shaders/filters/sharpenedge.glsl","", { { "Amount", 0.25} }), FilteringProgram("TopHat", "shaders/filters/erosion.glsl", "shaders/filters/tophat.glsl", { { "Radius", 0.5} }), diff --git a/src/MediaPlayer.cpp b/src/MediaPlayer.cpp index f889c1b..ff2e3c8 100644 --- a/src/MediaPlayer.cpp +++ b/src/MediaPlayer.cpp @@ -1446,7 +1446,7 @@ void MediaPlayer::execute_seek_command(GstClockTime target, bool force) if (seek_event && gst_element_send_event(pipeline_, seek_event) ) { seeking_ = true; #ifdef MEDIA_PLAYER_DEBUG - g_printerr("MediaPlayer %s Seek %ld %.1f", std::to_string(id_).c_str(), seek_pos, rate_); + g_printerr("MediaPlayer %s Seek %ld %.1f\n", std::to_string(id_).c_str(), seek_pos, rate_); #endif } else diff --git a/src/TextSource.cpp b/src/TextSource.cpp index 432d5bb..4ea2d7f 100644 --- a/src/TextSource.cpp +++ b/src/TextSource.cpp @@ -405,7 +405,7 @@ glm::ivec2 TextSource::icon() const std::string TextSource::info() const { if ( contents()->isSubtitle() ) - return "Subtitle text"; + return "Subtitle file"; else - return "Free text"; + return "Text"; } diff --git a/src/UserInterfaceManager.cpp b/src/UserInterfaceManager.cpp index 1d4b433..7fdccc2 100644 --- a/src/UserInterfaceManager.cpp +++ b/src/UserInterfaceManager.cpp @@ -3558,52 +3558,57 @@ void Navigator::RenderSourcePannel(Source *s, const ImVec2 &iconsize) } } - // clone button + /// + /// ACTION BUTTONS PANEL if not loading + /// ImGui::Text(" "); - if ( s->failed() ) { - ImGuiToolkit::ButtonDisabled( ICON_FA_SHARE_SQUARE " Clone & Filter", ImVec2(ImGui::GetContentRegionAvail().x, 0)); - } - else if ( ImGui::Button( ICON_FA_SHARE_SQUARE " Clone & Filter", ImVec2(ImGui::GetContentRegionAvail().x, 0)) ) { - Mixer::manager().addSource ( (Source *) Mixer::manager().createSourceClone() ); - UserInterface::manager().showPannel( Mixer::manager().numSource() ); - } + if (s->ready() || s->failed()) { - // replace button - if ( ImGui::Button( ICON_FA_PLUS_SQUARE " Replace", ImVec2(ImGui::GetContentRegionAvail().x, 0)) ) { - // prepare panel for new source of same type - MediaSource *file = dynamic_cast(s); - MultiFileSource *sequence = dynamic_cast(s); - PatternSource *generated = dynamic_cast(s); - if (file != nullptr) - Settings::application.source.new_type = SOURCE_FILE; - else if (sequence != nullptr) - Settings::application.source.new_type = SOURCE_SEQUENCE; - else if (generated != nullptr) - Settings::application.source.new_type = SOURCE_GENERATED; - else - Settings::application.source.new_type = SOURCE_CONNECTED; - - // switch to panel new source - showPannelSource(NAV_NEW); - // set source to be replaced - source_to_replace = s; - } - // delete button - if ( ImGui::Button( ACTION_DELETE, ImVec2(ImGui::GetContentRegionAvail().x, 0)) ) { - Mixer::manager().deleteSource(s); - Action::manager().store(sname + std::string(": deleted")); - } - if ( Mixer::manager().session()->failedSources().size() > 1 ) { - ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(IMGUI_COLOR_FAILED, 1.)); - if ( ImGui::Button( ICON_FA_BACKSPACE " Delete all failed", ImVec2(ImGui::GetContentRegionAvail().x, 0)) ) { - auto failedsources = Mixer::manager().session()->failedSources(); - for (auto sit = failedsources.cbegin(); sit != failedsources.cend(); ++sit) { - Mixer::manager().deleteSource( Mixer::manager().findSource( (*sit)->id() ) ); - } + // clone button + if ( s->failed() ) { + ImGuiToolkit::ButtonDisabled( ICON_FA_SHARE_SQUARE " Clone & Filter", ImVec2(ImGui::GetContentRegionAvail().x, 0)); + } + else if ( ImGui::Button( ICON_FA_SHARE_SQUARE " Clone & Filter", ImVec2(ImGui::GetContentRegionAvail().x, 0)) ) { + Mixer::manager().addSource ( (Source *) Mixer::manager().createSourceClone() ); + UserInterface::manager().showPannel( Mixer::manager().numSource() ); } - ImGui::PopStyleColor(1); - } + // replace button + if ( ImGui::Button( ICON_FA_PLUS_SQUARE " Replace", ImVec2(ImGui::GetContentRegionAvail().x, 0)) ) { + // prepare panel for new source of same type + MediaSource *file = dynamic_cast(s); + MultiFileSource *sequence = dynamic_cast(s); + PatternSource *generated = dynamic_cast(s); + if (file != nullptr) + Settings::application.source.new_type = SOURCE_FILE; + else if (sequence != nullptr) + Settings::application.source.new_type = SOURCE_SEQUENCE; + else if (generated != nullptr) + Settings::application.source.new_type = SOURCE_GENERATED; + else + Settings::application.source.new_type = SOURCE_CONNECTED; + + // switch to panel new source + showPannelSource(NAV_NEW); + // set source to be replaced + source_to_replace = s; + } + // delete button + if ( ImGui::Button( ACTION_DELETE, ImVec2(ImGui::GetContentRegionAvail().x, 0)) ) { + Mixer::manager().deleteSource(s); + Action::manager().store(sname + std::string(": deleted")); + } + if ( Mixer::manager().session()->failedSources().size() > 1 ) { + ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(IMGUI_COLOR_FAILED, 1.)); + if ( ImGui::Button( ICON_FA_BACKSPACE " Delete all failed", ImVec2(ImGui::GetContentRegionAvail().x, 0)) ) { + auto failedsources = Mixer::manager().session()->failedSources(); + for (auto sit = failedsources.cbegin(); sit != failedsources.cend(); ++sit) { + Mixer::manager().deleteSource( Mixer::manager().findSource( (*sit)->id() ) ); + } + } + ImGui::PopStyleColor(1); + } + } ImGui::End(); } }