Reduce UI flicker.

This commit is contained in:
bubnikv 2017-10-28 00:18:02 +02:00
parent 857b78ddca
commit 835e5b71a8
2 changed files with 22 additions and 7 deletions

View File

@ -257,7 +257,6 @@ sub select_preset {
# Save the current application settings with the newly selected preset name.
wxTheApp->save_settings;
print "select_preset 5\n";
}
# Initialize the UI from the current preset.
@ -313,17 +312,17 @@ sub add_options_page {
# Reload current $self->{config} (aka $self->{presets}->edited_preset->config) into the UI fields.
sub _reload_config {
my ($self) = @_;
$self->Freeze;
$_->reload_config for @{$self->{pages}};
$self->Thaw;
}
# Regerenerate content of the page tree.
sub rebuild_page_tree {
my ($self) = @_;
print "Tab::rebuild_page_tree " . $self->title . "\n";
$self->Freeze;
# get label of the currently selected item
my $selected = $self->{treectrl}->GetItemText($self->{treectrl}->GetSelection);
my $selected = $self->{treectrl}->GetItemText($self->{treectrl}->GetSelection);
my $rootItem = $self->{treectrl}->GetRootItem;
$self->{treectrl}->DeleteChildren($rootItem);
my $have_selection = 0;
@ -336,11 +335,11 @@ sub rebuild_page_tree {
$have_selection = 1;
}
}
if (!$have_selection) {
# this is triggered on first load, so we don't disable the sel change event
$self->{treectrl}->SelectItem($self->{treectrl}->GetFirstChild($rootItem));
}
$self->Thaw;
}
# Update the combo box label of the selected preset based on its "dirty" state,
@ -674,6 +673,7 @@ sub _reload_config {
# Slic3r::GUI::Tab::Print::_update is called after a configuration preset is loaded or switched, or when a single option is modifed by the user.
sub _update {
my ($self) = @_;
$self->Freeze;
my $config = $self->{presets}->get_edited_preset->config_ref;
@ -867,6 +867,8 @@ sub _update {
my $have_wipe_tower = $config->wipe_tower;
$self->get_field($_)->toggle($have_wipe_tower)
for qw(wipe_tower_x wipe_tower_y wipe_tower_width wipe_tower_per_color_wipe);
$self->Thaw;
}
package Slic3r::GUI::Tab::Filament;
@ -1432,7 +1434,8 @@ sub _build_extruder_pages {
# Slic3r::GUI::Tab::Printer::_update is called after a configuration preset is loaded or switched, or when a single option is modifed by the user.
sub _update {
my ($self) = @_;
$self->Freeze;
my $config = $self->{config};
my $serial_speed = $self->get_field('serial_speed');
@ -1504,6 +1507,8 @@ sub _update {
$self->get_field('retract_restart_extra_toolchange', $i)->toggle
($have_multiple_extruders && $toolchange_retraction);
}
$self->Thaw;
}
# this gets executed after preset is loaded and before GUI fields are updated

View File

@ -14,6 +14,7 @@
#include <wx/image.h>
#include <wx/choice.h>
#include <wx/bmpcbox.h>
#include <wx/wupdlock.h>
#include "../../libslic3r/Utils.hpp"
@ -279,6 +280,7 @@ void PresetCollection::update_platter_ui(wxBitmapComboBox *ui)
if (ui == nullptr)
return;
// Otherwise fill in the list from scratch.
ui->Freeze();
ui->Clear();
for (size_t i = this->m_presets.front().is_visible ? 0 : 1; i < this->m_presets.size(); ++ i) {
const Preset &preset = this->m_presets[i];
@ -287,12 +289,14 @@ void PresetCollection::update_platter_ui(wxBitmapComboBox *ui)
if (i == m_idx_selected)
ui->SetSelection(ui->GetCount() - 1);
}
ui->Thaw();
}
void PresetCollection::update_tab_ui(wxChoice *ui)
{
if (ui == nullptr)
return;
ui->Freeze();
ui->Clear();
for (size_t i = this->m_presets.front().is_visible ? 0 : 1; i < this->m_presets.size(); ++ i) {
const Preset &preset = this->m_presets[i];
@ -301,6 +305,7 @@ void PresetCollection::update_tab_ui(wxChoice *ui)
if (i == m_idx_selected)
ui->SetSelection(ui->GetCount() - 1);
}
ui->Thaw();
}
// Update a dirty floag of the current preset, update the labels of the UI component accordingly.
@ -326,6 +331,7 @@ bool PresetCollection::update_dirty_ui(wxItemContainer *ui)
bool PresetCollection::update_dirty_ui(wxChoice *ui)
{
wxWindowUpdateLocker noUpdates(ui);
return update_dirty_ui(dynamic_cast<wxItemContainer*>(ui));
}
@ -762,6 +768,7 @@ void PresetBundle::update_platter_filament_ui(unsigned int idx_extruder, wxBitma
extruder_color.clear();
// Fill in the list from scratch.
ui->Freeze();
ui->Clear();
for (size_t i = this->filaments().front().is_visible ? 0 : 1; i < this->filaments().size(); ++ i) {
const Preset &preset = this->filaments.preset(i);
@ -803,6 +810,7 @@ void PresetBundle::update_platter_filament_ui(unsigned int idx_extruder, wxBitma
if (selected)
ui->SetSelection(ui->GetCount() - 1);
}
ui->Thaw();
}
// Update the colors preview at the platter extruder combo box.
@ -817,6 +825,7 @@ void PresetBundle::update_platter_filament_ui_colors(unsigned int idx_extruder,
// Extruder color is not defined.
extruder_color.clear();
ui->Freeze();
for (unsigned int ui_id = 0; ui_id < ui->GetCount(); ++ ui_id) {
std::string preset_name = ui->GetString(ui_id).utf8_str().data();
size_t filament_preset_id = size_t(ui->GetClientData(ui_id));
@ -854,6 +863,7 @@ void PresetBundle::update_platter_filament_ui_colors(unsigned int idx_extruder,
}
ui->SetItemBitmap(ui_id, *bitmap);
}
ui->Thaw();
}
const std::vector<std::string>& PresetBundle::print_options()