mirror of
https://github.com/RGBCube/serenity
synced 2025-10-22 17:42:33 +00:00
Here's how you can use this to speed up startup time:
auto widget = GLazyWidget::construct();
widget->on_first_show = [](auto& self) {
self.set_layout(...);
...
};
Basically, it allows you to delay building the widget subtree until
it's shown for the first time.
20 lines
306 B
C++
20 lines
306 B
C++
#include <LibGUI/GLazyWidget.h>
|
|
|
|
GLazyWidget::GLazyWidget(GWidget* parent)
|
|
: GWidget(parent)
|
|
{
|
|
}
|
|
|
|
GLazyWidget::~GLazyWidget()
|
|
{
|
|
}
|
|
|
|
void GLazyWidget::show_event(GShowEvent&)
|
|
{
|
|
if (m_has_been_shown)
|
|
return;
|
|
m_has_been_shown = true;
|
|
|
|
ASSERT(on_first_show);
|
|
on_first_show(*this);
|
|
}
|