mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-26 10:21:00 +00:00
feat: faster startup by lazy-loading main window panels on idle or first use (#15811)
This commit is contained in:
+56
-17
@@ -804,6 +804,10 @@ void Tab::OnActivate()
|
||||
}
|
||||
#endif
|
||||
|
||||
// The OnActivate() that shows the tab builds the page.
|
||||
if (wxGetApp().mainframe != nullptr && !wxGetApp().mainframe->is_active_and_shown_tab(m_parent))
|
||||
return;
|
||||
|
||||
// BBS: select on first active
|
||||
if (!m_active_page)
|
||||
restore_last_select_item();
|
||||
@@ -7159,6 +7163,16 @@ void Tab::restore_last_select_item()
|
||||
m_tabctrl->SelectItem(item);
|
||||
}
|
||||
|
||||
bool Tab::page_build_pending() const
|
||||
{
|
||||
return m_active_page != nullptr && m_active_page->build_pending();
|
||||
}
|
||||
|
||||
bool Tab::page_build_step()
|
||||
{
|
||||
return m_active_page != nullptr && m_active_page->build_step(m_mode);
|
||||
}
|
||||
|
||||
void Tab::update_description_lines()
|
||||
{
|
||||
if (m_active_page && m_active_page->title() == "Dependencies" && m_parent_preset_description_line)
|
||||
@@ -7375,7 +7389,7 @@ void Tab::OnKeyDown(wxKeyEvent& event)
|
||||
|
||||
void Tab::compare_preset()
|
||||
{
|
||||
wxGetApp().mainframe->diff_dialog.show(m_type);
|
||||
DiffPresetDialog::ensure()->show(m_type);
|
||||
}
|
||||
|
||||
void Tab::transfer_options(const std::string &name_from, const std::string &name_to, std::vector<std::string> options)
|
||||
@@ -7543,8 +7557,10 @@ void Tab::save_preset(std::string name /*= ""*/, bool detach, bool save_to_proje
|
||||
wxGetApp().get_tab(preset_type)->update_tab_ui();
|
||||
}
|
||||
|
||||
// update preset comboboxes in DiffPresetDlg
|
||||
wxGetApp().mainframe->diff_dialog.update_presets(m_type);
|
||||
// show() reloads the presets, so only a visible Compare dialog needs updating.
|
||||
DiffPresetDialog* diff_dialog = DiffPresetDialog::if_built();
|
||||
if (diff_dialog != nullptr && diff_dialog->IsShown())
|
||||
diff_dialog->update_presets(m_type);
|
||||
}
|
||||
|
||||
// Called for a currently selected preset.
|
||||
@@ -8604,20 +8620,8 @@ void Page::activate(ConfigOptionMode mode, std::function<void()> throw_if_cancel
|
||||
#else
|
||||
//m_vsizer->AddSpacer(10);
|
||||
#endif
|
||||
#if HIDE_FIRST_SPLIT_LINE
|
||||
// BBS: no line spliter for first group
|
||||
bool first = true;
|
||||
#endif
|
||||
for (auto group : m_optgroups) {
|
||||
if (!group->activate(throw_if_canceled))
|
||||
continue;
|
||||
m_vsizer->Add(group->sizer, 0, wxEXPAND | (group->is_legend_line() ? (wxLEFT|wxTOP) : wxALL), m_parent->FromDIP(5)); // ORCA use less margin on parameters section
|
||||
group->update_visibility(mode);
|
||||
#if HIDE_FIRST_SPLIT_LINE
|
||||
if (first) group->stb->Hide();
|
||||
first = false;
|
||||
#endif
|
||||
group->reload_config();
|
||||
for (size_t i = 0; i < m_optgroups.size(); ++i) {
|
||||
activate_group(i, mode, throw_if_canceled);
|
||||
throw_if_canceled();
|
||||
}
|
||||
|
||||
@@ -8636,6 +8640,41 @@ void Page::activate(ConfigOptionMode mode, std::function<void()> throw_if_cancel
|
||||
#endif
|
||||
}
|
||||
|
||||
// Builds one option group; false when it already has its controls.
|
||||
bool Page::activate_group(size_t i, ConfigOptionMode mode, std::function<void()> throw_if_canceled)
|
||||
{
|
||||
auto& group = m_optgroups[i];
|
||||
if (!group->activate(throw_if_canceled))
|
||||
return false;
|
||||
m_vsizer->Add(group->sizer, 0, wxEXPAND | (group->is_legend_line() ? (wxLEFT|wxTOP) : wxALL), m_parent->FromDIP(5)); // ORCA use less margin on parameters section
|
||||
group->update_visibility(mode);
|
||||
#if HIDE_FIRST_SPLIT_LINE
|
||||
// BBS: no line spliter for first group
|
||||
if (i == 0) group->stb->Hide();
|
||||
#endif
|
||||
group->reload_config();
|
||||
return true;
|
||||
}
|
||||
|
||||
// The first group without controls.
|
||||
size_t Page::next_group_to_build() const
|
||||
{
|
||||
return std::find_if(m_optgroups.begin(), m_optgroups.end(), [](const auto& group) { return !group->is_activated(); }) - m_optgroups.begin();
|
||||
}
|
||||
|
||||
bool Page::build_pending() const
|
||||
{
|
||||
return next_group_to_build() < m_optgroups.size();
|
||||
}
|
||||
|
||||
bool Page::build_step(ConfigOptionMode mode)
|
||||
{
|
||||
const size_t i = next_group_to_build();
|
||||
if (i < m_optgroups.size())
|
||||
activate_group(i, mode, [] {});
|
||||
return build_pending();
|
||||
}
|
||||
|
||||
void Page::clear()
|
||||
{
|
||||
for (auto group : m_optgroups)
|
||||
|
||||
Reference in New Issue
Block a user