From 365c6da71716c90730a5ca714edda264d0d6f93c Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 7 Mar 2020 19:06:38 +0100 Subject: Fix inline display flickering while loading. --- plugin/drumgizmo_plugin.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/plugin/drumgizmo_plugin.cc b/plugin/drumgizmo_plugin.cc index e7bc29e..494be4e 100644 --- a/plugin/drumgizmo_plugin.cc +++ b/plugin/drumgizmo_plugin.cc @@ -235,10 +235,15 @@ void DrumGizmoPlugin::onInlineRedraw(std::size_t width, bool nofl_changed = settingsGetter.number_of_files_loaded.hasChanged(); bool dls_changed = settingsGetter.drumkit_load_status.hasChanged(); + bool in_progress = + settingsGetter.number_of_files_loaded.getValue() < + settingsGetter.number_of_files.getValue(); + bool context_needs_update = !context.data || context.width != width || context.height != height; bool bar_needs_update = - nof_changed || nofl_changed || dls_changed || context_needs_update; + nof_changed || nofl_changed || dls_changed || context_needs_update | + in_progress; // Always update while loading to prevent flickering. bool image_needs_update = inline_image_first_draw || context_needs_update; // TODO: settingsGetter.inline_image_filename.hasChanged(); bool something_needs_update = @@ -254,15 +259,15 @@ void DrumGizmoPlugin::onInlineRedraw(std::size_t width, InlineCanvas canvas(context); GUI::Painter painter(canvas); + double progress = + (double)settingsGetter.number_of_files_loaded.getValue() / + (double)settingsGetter.number_of_files.getValue(); + if(show_bar && bar_needs_update) { box.setSize(context.width, bar_height); painter.drawImage(0, height - bar_height, box); - double progress = - (double)settingsGetter.number_of_files_loaded.getValue() / - (double)settingsGetter.number_of_files.getValue(); - int brd = 4; int val = (width - (2 * brd)) * progress; -- cgit v1.2.3