Minor improvements

Display hourglass in left panel to inform source is loading and prevent buttons when loading + Varia.
This commit is contained in:
Bruno Herbelin
2024-10-05 01:07:05 +02:00
parent 10e95f5388
commit 3909aa4ab7
5 changed files with 71 additions and 54 deletions

View File

@@ -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

View File

@@ -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} }),

View File

@@ -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

View File

@@ -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";
}

View File

@@ -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<MediaSource *>(s);
MultiFileSource *sequence = dynamic_cast<MultiFileSource *>(s);
PatternSource *generated = dynamic_cast<PatternSource *>(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<MediaSource *>(s);
MultiFileSource *sequence = dynamic_cast<MultiFileSource *>(s);
PatternSource *generated = dynamic_cast<PatternSource *>(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();
}
}