Skip to content

Commit 81efcbd

Browse files
committed
Made notify_layers_need_update() immediate
1 parent dfe0973 commit 81efcbd

File tree

2 files changed

+17
-27
lines changed

2 files changed

+17
-27
lines changed

include/lxgui/gui_frame.hpp

-2
Original file line numberDiff line numberDiff line change
@@ -1822,8 +1822,6 @@ class frame : public region {
18221822
bool is_resizable_ = false;
18231823
bool is_user_placed_ = false;
18241824

1825-
bool build_layer_list_flag_ = false;
1826-
18271825
bounds2f abs_hit_rect_inset_list_ = bounds2f::zero;
18281826
bounds2f rel_hit_rect_inset_list_ = bounds2f::zero;
18291827

src/gui_frame.cpp

+17-25
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,23 @@ void frame::notify_loaded() {
488488
}
489489

490490
void frame::notify_layers_need_update() {
491-
build_layer_list_flag_ = true;
491+
// Clear layers' content
492+
for (auto& layer : layer_list_)
493+
layer.region_list.clear();
494+
495+
// Fill layers with regions (with font_string rendered last within the same layer)
496+
// TODO: This is bad; the frame class should not know about font_string, see #112.
497+
for (const auto& reg : region_list_) {
498+
if (reg && !reg->is_region_type<font_string>()) {
499+
layer_list_[static_cast<std::size_t>(reg->get_draw_layer())].region_list.push_back(reg);
500+
}
501+
}
502+
503+
for (const auto& reg : region_list_) {
504+
if (reg && reg->is_region_type<font_string>()) {
505+
layer_list_[static_cast<std::size_t>(reg->get_draw_layer())].region_list.push_back(reg);
506+
}
507+
}
492508
}
493509

494510
void frame::set_parent_(utils::observer_ptr<frame> parent) {
@@ -1544,30 +1560,6 @@ void frame::update(float delta) {
15441560
void frame::update_(float delta) {
15451561
alive_checker checker(*this);
15461562

1547-
if (build_layer_list_flag_) {
1548-
// Clear layers' content
1549-
for (auto& layer : layer_list_)
1550-
layer.region_list.clear();
1551-
1552-
// Fill layers with regions (with font_string rendered last within the same layer)
1553-
// TODO: This is bad; the frame class should not know about font_string, see #112.
1554-
for (const auto& reg : region_list_) {
1555-
if (reg && !reg->is_region_type<font_string>()) {
1556-
layer_list_[static_cast<std::size_t>(reg->get_draw_layer())].region_list.push_back(
1557-
reg);
1558-
}
1559-
}
1560-
1561-
for (const auto& reg : region_list_) {
1562-
if (reg && reg->is_region_type<font_string>()) {
1563-
layer_list_[static_cast<std::size_t>(reg->get_draw_layer())].region_list.push_back(
1564-
reg);
1565-
}
1566-
}
1567-
1568-
build_layer_list_flag_ = false;
1569-
}
1570-
15711563
if (is_visible()) {
15721564
fire_script("OnUpdate", {delta});
15731565
if (!checker.is_alive())

0 commit comments

Comments
 (0)