Faster switching of parameter pages if the page is switched
by cursor keys in the tree control: The page update is delayed to idle.
This commit is contained in:
parent
5243d3e53c
commit
ec8602f8d9
@ -293,7 +293,20 @@ void Tab::create_preset_tab()
|
|||||||
m_treectrl->AddRoot("root");
|
m_treectrl->AddRoot("root");
|
||||||
m_treectrl->SetIndent(0);
|
m_treectrl->SetIndent(0);
|
||||||
|
|
||||||
m_treectrl->Bind(wxEVT_TREE_SEL_CHANGED, &Tab::OnTreeSelChange, this);
|
// Delay processing of the following handler until the message queue is flushed.
|
||||||
|
// This helps to process all the cursor key events on Windows in the tree control,
|
||||||
|
// so that the cursor jumps to the last item.
|
||||||
|
m_treectrl->Bind(wxEVT_TREE_SEL_CHANGED, [this](wxTreeEvent&) {
|
||||||
|
if (!m_disable_tree_sel_changed_event && !m_pages.empty())
|
||||||
|
m_page_switch_planned = true;
|
||||||
|
});
|
||||||
|
m_treectrl->Bind(wxEVT_IDLE, [this](wxIdleEvent&) {
|
||||||
|
if (m_page_switch_planned) {
|
||||||
|
this->tree_sel_change_delayed();
|
||||||
|
m_page_switch_planned = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
m_treectrl->Bind(wxEVT_KEY_DOWN, &Tab::OnKeyDown, this);
|
m_treectrl->Bind(wxEVT_KEY_DOWN, &Tab::OnKeyDown, this);
|
||||||
|
|
||||||
// Initialize the page.
|
// Initialize the page.
|
||||||
@ -3370,14 +3383,11 @@ void Tab::active_selected_page()
|
|||||||
toggle_options();
|
toggle_options();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tab::OnTreeSelChange(wxTreeEvent& event)
|
void Tab::tree_sel_change_delayed()
|
||||||
{
|
{
|
||||||
if (m_disable_tree_sel_changed_event)
|
// There is a bug related to Ubuntu overlay scrollbars, see https://github.com/prusa3d/PrusaSlicer/issues/898 and https://github.com/prusa3d/PrusaSlicer/issues/952.
|
||||||
return;
|
// The issue apparently manifests when Show()ing a window with overlay scrollbars while the UI is frozen. For this reason,
|
||||||
|
// we will Thaw the UI prematurely on Linux. This means destroing the no_updates object prematurely.
|
||||||
// There is a bug related to Ubuntu overlay scrollbars, see https://github.com/prusa3d/PrusaSlicer/issues/898 and https://github.com/prusa3d/PrusaSlicer/issues/952.
|
|
||||||
// The issue apparently manifests when Show()ing a window with overlay scrollbars while the UI is frozen. For this reason,
|
|
||||||
// we will Thaw the UI prematurely on Linux. This means destroing the no_updates object prematurely.
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
std::unique_ptr<wxWindowUpdateLocker> no_updates(new wxWindowUpdateLocker(this));
|
std::unique_ptr<wxWindowUpdateLocker> no_updates(new wxWindowUpdateLocker(this));
|
||||||
#else
|
#else
|
||||||
@ -3390,9 +3400,6 @@ void Tab::OnTreeSelChange(wxTreeEvent& event)
|
|||||||
//#endif
|
//#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (m_pages.empty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
Page* page = nullptr;
|
Page* page = nullptr;
|
||||||
const auto sel_item = m_treectrl->GetSelection();
|
const auto sel_item = m_treectrl->GetSelection();
|
||||||
const auto selection = sel_item ? m_treectrl->GetItemText(sel_item) : "";
|
const auto selection = sel_item ? m_treectrl->GetItemText(sel_item) : "";
|
||||||
|
@ -238,6 +238,9 @@ protected:
|
|||||||
|
|
||||||
DynamicPrintConfig m_cache_config;
|
DynamicPrintConfig m_cache_config;
|
||||||
|
|
||||||
|
|
||||||
|
bool m_page_switch_planned = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PresetBundle* m_preset_bundle;
|
PresetBundle* m_preset_bundle;
|
||||||
bool m_show_btn_incompatible_presets = false;
|
bool m_show_btn_incompatible_presets = false;
|
||||||
@ -351,6 +354,7 @@ protected:
|
|||||||
void compatible_widget_reload(PresetDependencies &deps);
|
void compatible_widget_reload(PresetDependencies &deps);
|
||||||
void load_key_value(const std::string& opt_key, const boost::any& value, bool saved_value = false);
|
void load_key_value(const std::string& opt_key, const boost::any& value, bool saved_value = false);
|
||||||
|
|
||||||
|
void tree_sel_change_delayed();
|
||||||
void on_presets_changed();
|
void on_presets_changed();
|
||||||
void build_preset_description_line(ConfigOptionsGroup* optgroup);
|
void build_preset_description_line(ConfigOptionsGroup* optgroup);
|
||||||
void update_preset_description_line();
|
void update_preset_description_line();
|
||||||
|
Loading…
Reference in New Issue
Block a user