ladybird/Libraries/LibGUI/GLazyWidget.h
Andreas Kling 183f7c9830 LibGUI: Add GLazyWidget, a convenience widget for lazily-built UI's
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.
2019-10-02 20:24:29 +02:00

19 lines
367 B
C++

#pragma once
#include <LibGUI/GWidget.h>
class GLazyWidget : public GWidget {
C_OBJECT(GLazyWidget)
public:
virtual ~GLazyWidget() override;
Function<void(GLazyWidget&)> on_first_show;
protected:
explicit GLazyWidget(GWidget* parent = nullptr);
private:
virtual void show_event(GShowEvent&) override;
bool m_has_been_shown { false };
};