修改事件layout_changed发送次数为单次,删除无用函数

This commit is contained in:
daiqingshuang 2025-03-25 14:22:52 +08:00
parent 088d301b6c
commit ab9c7028ef
3 changed files with 4 additions and 18 deletions

View File

@ -44,8 +44,6 @@ void mirage_app::init() {
void mirage_app::run() {
// std::thread render_thread(&mirage_app::render_thread, this);
while (!mwindow::get_windows().empty()) {
delta_time = get_current_time() - last_time;
mwindow::poll_events();
@ -60,9 +58,3 @@ void mirage_app::run() {
render_context->cleanup();
delete render_context;
}
void mirage_app::render_thread() {
// while (running) {
// std::scoped_lock lock(render_mutex);
// }
}

View File

@ -14,8 +14,6 @@ public:
return render_context;
}
private:
void render_thread();
inline static mirage_render_context* render_context{};
time_type last_time = {};
duration_type delta_time = {};

View File

@ -24,13 +24,7 @@ auto widget_layout_system::get_dpi_scale() const -> float {
* @param in_world ECS世界引用
*/
void widget_layout_system::onUpdate(mustache::World& in_world) {
// 注: 以下注释代码原本用于更新控件所需大小,现已由其他机制替代
// in_world.entities().forEach([&](const widget_invalidate& in_invalidate, const widget_ptr& in_ptr) {
// if (!in_invalidate.has(invalidate_reason::layout))
// return;
// in_ptr->cache_desired_size(get_dpi_scale());
// });
bool is_layout_changed = false;
// 为所有需要更新布局的控件重新排列子控件
in_world.entities().forEach([&](const widget_layout& in_layout, widget_invalidate& in_invalidate, const widget_ptr& in_ptr) {
// 如果布局有效则跳过
@ -42,8 +36,10 @@ void widget_layout_system::onUpdate(mustache::World& in_world) {
// 清除布局无效标记并发布布局变更事件
in_invalidate.unset(invalidate_reason::layout);
in_world.events().post(layout_changed{});
is_layout_changed = true;
});
if (is_layout_changed)
in_world.events().post(layout_changed{});
}
// ===== widget_hit_test_system 实现 =====