Skip to content

Commit bba386b

Browse files
committed
Make OnSizeChanged trigger immediately rather than on update()
1 parent 4a56f92 commit bba386b

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

include/lxgui/gui_frame.hpp

-2
Original file line numberDiff line numberDiff line change
@@ -1667,8 +1667,6 @@ class frame : public region {
16671667
float min_height_ = 0.0f;
16681668
float max_height_ = std::numeric_limits<float>::infinity();
16691669

1670-
vector2f old_size_;
1671-
16721670
float scale_ = 1.0f;
16731671

16741672
bool is_mouse_in_frame_ = false;

src/gui_frame.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -1509,7 +1509,16 @@ void frame::update_borders_() {
15091509
check_position_();
15101510

15111511
if (border_list_ != old_border_list || is_ready_ != old_ready) {
1512+
if (border_list_.width() != old_border_list.width() ||
1513+
border_list_.height() != old_border_list.height()) {
1514+
alive_checker checker(*this);
1515+
fire_script("OnSizeChanged");
1516+
if (!checker.is_alive())
1517+
return;
1518+
}
1519+
15121520
get_manager().get_root().notify_hovered_frame_dirty();
1521+
15131522
if (backdrop_)
15141523
backdrop_->notify_borders_updated();
15151524
}
@@ -1591,15 +1600,6 @@ void frame::update(float delta) {
15911600
}
15921601
}
15931602
}
1594-
1595-
vector2f new_size = get_apparent_dimensions();
1596-
if (old_size_ != new_size) {
1597-
fire_script("OnSizeChanged");
1598-
if (!checker.is_alive())
1599-
return;
1600-
1601-
old_size_ = new_size;
1602-
}
16031603
}
16041604

16051605
} // namespace lxgui::gui

0 commit comments

Comments
 (0)