diff --git a/src/widget_tree/widget_system.cpp b/src/widget_tree/widget_system.cpp index cf273ff..21e57a2 100644 --- a/src/widget_tree/widget_system.cpp +++ b/src/widget_tree/widget_system.cpp @@ -57,6 +57,7 @@ widget_hit_test_system::~widget_hit_test_system() { window->on_mouse_button_up_delegate.remove_object(this); window->on_mouse_button_down_delegate.remove_object(this); window->on_mouse_button_dbl_delegate.remove_object(this); + window->on_mouse_wheel_delegate.remove_object(this); window->on_mouse_leave_delegate.remove_object(this); } } @@ -192,8 +193,8 @@ void widget_hit_test_system::process_mouse_button_down(const Eigen::Vector2f& in * @param in_window_pos 鼠标在窗口中的位置 * @param in_button 双击的鼠标按钮 */ -void widget_hit_test_system::process_mouse_button_dbl(const Eigen::Vector2f& in_window_pos, mouse_button in_button) { - if (auto last_hover_widget = widget_manager::get().get_component(last_hover_widget_)) { +void widget_hit_test_system::process_mouse_button_dbl(const Eigen::Vector2f& in_window_pos, mouse_button in_button) const { + if (const auto last_hover_widget = widget_manager::get().get_component(last_hover_widget_)) { last_hover_widget->widget->on_double_click(last_hover_local_pos_, in_button); } } @@ -203,8 +204,8 @@ void widget_hit_test_system::process_mouse_button_dbl(const Eigen::Vector2f& in_ * @param in_window_pos 鼠标在窗口中的位置 * @param in_wheel_event 滚轮事件 */ -void widget_hit_test_system::process_mouse_wheel(const Eigen::Vector2f& in_window_pos, wheel_event in_wheel_event) { - if (auto last_hover_widget = widget_manager::get().get_component(last_hover_widget_)) { +void widget_hit_test_system::process_mouse_wheel(const Eigen::Vector2f& in_window_pos, wheel_event in_wheel_event) const { + if (const auto last_hover_widget = widget_manager::get().get_component(last_hover_widget_)) { last_hover_widget->widget->on_mouse_wheel(last_hover_local_pos_, in_wheel_event); } } @@ -290,8 +291,8 @@ hit_test_result widget_hit_test_system::perform_hit_test( * @brief 析构函数,移除窗口大小变化监听 */ widget_render_system::~widget_render_system() { - if (auto window = window_.lock()) { - window->on_resize_delegate.remove_object(this); + if (const auto window = window_.lock()) { + window->on_resize_delegate.remove_object(this); } } diff --git a/src/widget_tree/widget_system.h b/src/widget_tree/widget_system.h index b71afdc..f893714 100644 --- a/src/widget_tree/widget_system.h +++ b/src/widget_tree/widget_system.h @@ -108,14 +108,14 @@ protected: * @param in_window_pos 鼠标在窗口中的位置 * @param in_button 双击的鼠标按钮 */ - void process_mouse_button_dbl(const Eigen::Vector2f& in_window_pos, mouse_button in_button); + void process_mouse_button_dbl(const Eigen::Vector2f& in_window_pos, mouse_button in_button) const; /** * @brief 处理鼠标滚轮事件 * @param in_window_pos 鼠标在窗口中的位置 * @param in_wheel_event 滚轮事件 */ - void process_mouse_wheel(const Eigen::Vector2f& in_window_pos, wheel_event in_wheel_event); + void process_mouse_wheel(const Eigen::Vector2f& in_window_pos, wheel_event in_wheel_event) const; /** * @brief 处理鼠标离开窗口事件