Open the Design tab quickly on Windows the first time

A page built on first click is now built before it is shown, as the idle
prebuild already does, so its controls are not created inside a visible
window. This takes the Design tab's first open on Windows from ~9 s to ~1 s.
This commit is contained in:
SoftFever
2026-10-03 12:38:47 +08:00
parent 9351bbaa83
commit 38df8022e3
2 changed files with 10 additions and 1 deletions
+5 -1
View File
@@ -38,7 +38,11 @@ no wx dependency and is unit-tested.
The notebook needs a page object for a tab to exist and for tabs to be inserted and
removed by pointer, and the placeholder is that object. It builds the real panel inside
itself the first time it is shown and forwards showing and hiding afterwards, so a panel's
own show handling stays its activation hook. Nothing builds while the main window is
own show handling stays its activation hook. The build runs before the placeholder shows
itself, so a panel built on demand is created in a hidden window as a prebuilt one is: on
Windows every control created or moved inside a shown window re-clips and repaints its
shown siblings, which makes building a large panel into a shown page many times slower.
Nothing builds while the main window is
hidden; the window's first show builds the start page. A page that is out of the book is
not prebuilt. A panel built while its page is hidden stays hidden, and gets the theming
the window applied before the panel existed.
+5
View File
@@ -57,6 +57,11 @@ public:
// virtual from the book's ShowWithEffect() only for wxSHOW_EFFECT_NONE, the default.
bool Show(bool show = true) override
{
// Built before this page is shown, as an idle prebuild builds it. On MSW every control
// created or moved inside a shown window re-clips and repaints its shown siblings, so
// building a large panel into a shown page took seconds.
if (show && wxGetTopLevelParent(this)->IsShown())
this->ensure();
const bool changed = wxPanel::Show(show);
if (show) {
// The book shows its first page as it is inserted, before startup has chosen the