OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::LazyPage< Panel > Class Template Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/LazyPage.hpp>

Inheritance diagram for Slic3r::GUI::LazyPage< Panel >:
Collaboration diagram for Slic3r::GUI::LazyPage< Panel >:

Public Types

using Factory = std::function<Panel*(wxWindow* parent)>

Public Member Functions

 LazyPage (wxWindow *parent, std::string name, int order, Factory make=[](wxWindow *parent) { return new Panel(parent);})
bool in_book () const
bool pending () const override
bool Show (bool show=true) override
Panel * get () const
Panel * ensure ()
void when_built (std::function< void(Panel &)> fn)
const std::string & name () const override
bool built () const override
int prebuild_order () const override
bool build_step () override

Static Protected Member Functions

static void log_null_factory (const std::string &name)

Private Member Functions

bool steps_remain () const
void step ()

Static Private Member Functions

static constexpr bool registered ()
static constexpr bool staged ()

Private Attributes

std::string m_name
int m_order
Factory m_make
Panel * m_object
std::atomic< bool > m_complete
bool m_building
bool m_failed
std::vector< std::function< void(Panel &)> > m_deferred

Detailed Description

template<class Panel>
class Slic3r::GUI::LazyPage< Panel >

Member Typedef Documentation

◆ Factory

template<class Panel>
using Slic3r::GUI::LazyPage< Panel >::Factory = std::function<Panel*(wxWindow* parent)>

Constructor & Destructor Documentation

◆ LazyPage()

template<class Panel>
Slic3r::GUI::LazyPage< Panel >::LazyPage ( wxWindow * parent,
std::string name,
int order,
Factory make = [](wxWindow* parent) { return new Panel(parent); } )
inline
28 { return new Panel(parent); })
30 Panel* panel = make(this);
31 GetSizer()->Add(panel, 1, wxEXPAND);
32 // Hidden while its page is, as an inserted page would be.
33 if (!IsShown())
34 panel->Hide();
35 return panel;
36 })
37 {
39 // Shown by the book when its tab is selected.
40 Hide();
41 this->when_built([this](Panel& panel) {
43 Layout();
44 });
45 }
virtual const std::string & name() const =0
Definition LazyPage.hpp:24
Lazy(std::string name, int order, Factory make)
Definition Lazy.hpp:72
void when_built(std::function< void(Panel &)> fn)
Definition Lazy.hpp:103
void apply_dark_ui_to_lazy_panel(wxWindow *panel)
Definition LazyPage.cpp:7

References Slic3r::GUI::Lazy< Panel >::name().

Here is the call graph for this function:

Member Function Documentation

◆ build_step()

bool Slic3r::GUI::Lazy< Panel >::build_step ( )
inlineoverridevirtualinherited

Implements Slic3r::GUI::LazyBase.

120 {
121 if (built() || m_building || m_failed)
122 return false;
123 m_building = true;
124 try {
125 if (m_object == nullptr)
126 m_object = m_make();
127 else
128 step();
129 } catch (...) {
130 m_building = false;
131 throw;
132 }
133 m_building = false;
134 if (m_object == nullptr) {
135 m_failed = true;
137 return false;
138 }
139 if (steps_remain())
140 return true;
142 for (auto& fn : m_deferred)
143 fn(*m_object);
144 m_deferred.clear();
145 return false;
146 }
static void log_null_factory(const std::string &name)
Definition Lazy.cpp:25
Definition Lazy.hpp:68
Factory m_make
Definition Lazy.hpp:167
void step()
Definition Lazy.hpp:159
bool steps_remain() const
Definition Lazy.hpp:152
bool built() const override
Definition Lazy.hpp:113

◆ built()

bool Slic3r::GUI::Lazy< Panel >::built ( ) const
inlineoverridevirtualinherited

Implements Slic3r::GUI::LazyBase.

Referenced by Slic3r::GUI::LazyPage< Panel >::Show().

Here is the caller graph for this function:

◆ ensure()

Panel * Slic3r::GUI::Lazy< Panel >::ensure ( )
inlineinherited
92 {
93 if (!built() && !m_building) {
94 OnDemandBuild build(*this);
95 do
96 build.unit();
97 while (build_step());
98 }
99 return get();
100 }
bool build_step() override
Definition Lazy.hpp:119

Referenced by Slic3r::GUI::LazyPage< Panel >::Show().

Here is the caller graph for this function:

◆ get()

Panel * Slic3r::GUI::Lazy< Panel >::get ( ) const
inlineinherited
87{ return built() ? m_object : nullptr; }

Referenced by Slic3r::GUI::LazyPage< Panel >::Show().

Here is the caller graph for this function:

◆ in_book()

template<class Panel>
bool Slic3r::GUI::LazyPage< Panel >::in_book ( ) const
inline
49 {
50 auto* book = dynamic_cast<wxBookCtrlBase*>(GetParent());
51 return book != nullptr && book->FindPage(this) != wxNOT_FOUND;
52 }

Referenced by pending().

Here is the caller graph for this function:

◆ log_null_factory()

void Slic3r::GUI::LazyBase::log_null_factory ( const std::string & name)
staticprotectedinherited
26{
27 BOOST_LOG_TRIVIAL(error) << "Lazy::build_step: the factory for " << name << " returned null";
28}

◆ name()

const std::string & Slic3r::GUI::Lazy< Panel >::name ( ) const
inlineoverridevirtualinherited

Implements Slic3r::GUI::LazyBase.

111{ return m_name; }

Referenced by Slic3r::GUI::LazyPage< Panel >::LazyPage().

Here is the caller graph for this function:

◆ pending()

template<class Panel>
bool Slic3r::GUI::LazyPage< Panel >::pending ( ) const
inlineoverridevirtual

Reimplemented from Slic3r::GUI::Lazy< Panel >.

55{ return in_book() && Lazy<Panel>::pending(); }
bool in_book() const
Definition LazyPage.hpp:48
bool pending() const override
Definition Lazy.hpp:114

References in_book(), and Slic3r::GUI::Lazy< T >::pending().

Here is the call graph for this function:

◆ prebuild_order()

int Slic3r::GUI::Lazy< Panel >::prebuild_order ( ) const
inlineoverridevirtualinherited

Implements Slic3r::GUI::LazyBase.

115{ return m_order; }

◆ registered()

constexpr bool Slic3r::GUI::Lazy< Panel >::registered ( )
inlinestaticconstexprprivateinherited

◆ Show()

template<class Panel>
bool Slic3r::GUI::LazyPage< Panel >::Show ( bool show = true)
inlineoverride
60 {
61 // Built before this page is shown, as an idle prebuild builds it. On MSW every control
62 // created or moved inside a shown window re-clips and repaints its shown siblings, so
63 // building a large panel into a shown page took seconds.
64 if (show && wxGetTopLevelParent(this)->IsShown())
65 this->ensure();
66 const bool changed = wxPanel::Show(show);
67 if (show) {
68 // The book shows its first page as it is inserted, before startup has chosen the
69 // start page, so a hidden frame builds nothing; MainFrame::Show() completes it.
70 if (this->built() || wxGetTopLevelParent(this)->IsShown()) {
71 if (Panel* panel = this->ensure())
72 panel->Show(true);
73 // The sizer skipped the panel while the book kept it hidden.
74 Layout();
75 }
76 } else if (Panel* panel = this->get()) {
77 panel->Show(false);
78 }
79 return changed;
80 }
bool Show(bool show=true) override
Definition LazyPage.hpp:59
Panel * ensure()
Definition Lazy.hpp:91
Panel * get() const
Definition Lazy.hpp:87

References Slic3r::GUI::Lazy< Panel >::built(), Slic3r::GUI::Lazy< Panel >::ensure(), and Slic3r::GUI::Lazy< Panel >::get().

Here is the call graph for this function:

◆ staged()

constexpr bool Slic3r::GUI::Lazy< Panel >::staged ( )
inlinestaticconstexprprivateinherited

◆ step()

void Slic3r::GUI::Lazy< Panel >::step ( )
inlineprivateinherited
160 {
161 if constexpr (staged())
163 }
static constexpr bool staged()
Definition Lazy.hpp:150

◆ steps_remain()

bool Slic3r::GUI::Lazy< Panel >::steps_remain ( ) const
inlineprivateinherited
153 {
154 if constexpr (staged())
155 return !m_object->built();
156 else
157 return false;
158 }

◆ when_built()

void Slic3r::GUI::Lazy< Panel >::when_built ( std::function< void(Panel &)> fn)
inlineinherited
104 {
105 if (built())
106 fn(*m_object);
107 else
108 m_deferred.push_back(std::move(fn));
109 }

Member Data Documentation

◆ m_building

bool Slic3r::GUI::Lazy< Panel >::m_building
privateinherited
170{ false };

◆ m_complete

std::atomic<bool> Slic3r::GUI::Lazy< Panel >::m_complete
privateinherited
169{ false };

◆ m_deferred

std::vector<std::function<void(Panel&)> > Slic3r::GUI::Lazy< Panel >::m_deferred
privateinherited

◆ m_failed

bool Slic3r::GUI::Lazy< Panel >::m_failed
privateinherited
171{ false };

◆ m_make

Factory Slic3r::GUI::Lazy< Panel >::m_make
privateinherited

◆ m_name

std::string Slic3r::GUI::Lazy< Panel >::m_name
privateinherited

◆ m_object

Panel* Slic3r::GUI::Lazy< Panel >::m_object
privateinherited
168{ nullptr };

◆ m_order

int Slic3r::GUI::Lazy< Panel >::m_order
privateinherited

The documentation for this class was generated from the following file:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/LazyPage.hpp