@@ -50,8 +50,8 @@ ruis::event_status flickable::on_mouse_button(const mouse_button_event& event)
5050 utki::assert (event.action == button_action::press, SL);
5151
5252 this ->push_touch_move_to_history ({.position = event.pos , .timestamp_ms = utki::get_ticks_ms ()});
53- auto vel = this -> calculate_touch_velocity ();
54- std::cout << " touch press, vel = " << vel << std::endl;
53+
54+ // std::cout << "touch press, vel = " << this->calculate_touch_velocity() << std::endl;
5555
5656 this ->cur_state = state::within_scroll_threshold;
5757 this ->prev_touch_point = event.pos ;
@@ -69,14 +69,13 @@ ruis::event_status flickable::on_mouse_button(const mouse_button_event& event)
6969 utki::assert (event.action == button_action::release, SL);
7070 this ->cur_state = state::idle;
7171
72- auto vel = this ->calculate_touch_velocity ();
73- std::cout << " touch release, vel = " << vel << std::endl;
72+ // std::cout << "touch release, vel = " << this->calculate_touch_velocity() << std::endl;
7473
7574 this ->touch_history .clear ();
7675
7776 return this ->flickable_on_mouse_button (event);
7877 }
79- case state::scrolling :
78+ case state::dragging :
8079 {
8180 utki::assert (event.action == button_action::release, SL);
8281 this ->cur_state = state::idle;
@@ -107,8 +106,7 @@ ruis::event_status flickable::on_mouse_move(const mouse_move_event& event)
107106
108107 this ->push_touch_move_to_history ({.position = event.pos , .timestamp_ms = utki::get_ticks_ms ()});
109108
110- auto vel = this ->calculate_touch_velocity ();
111- std::cout << " touch move, vel = " << vel << std::endl;
109+ // std::cout << "touch move, vel = " << this->calculate_touch_velocity() << std::endl;
112110
113111 switch (this ->cur_state ) {
114112 default :
@@ -132,29 +130,36 @@ ruis::event_status flickable::on_mouse_move(const mouse_move_event& event)
132130 // std::cout << "mouse move: within scroll threshold, delta: " << delta << ", abs_delta: " << abs_delta << "\n";
133131
134132 if (abs_delta.x () > this ->scroll_threshold_px || abs_delta.y () > this ->scroll_threshold_px ) {
135- this ->cur_state = state::scrolling ;
133+ this ->cur_state = state::dragging ;
136134
137135 // std::cout << "scrolling\n";
138136
139137 this ->prev_touch_point = event.pos ;
140138
141139 // send mouse button up event out of widget area to cancel any ongoing interactions
142140 {
143- ruis::mouse_button_event mbe{
144- button_action::release,
145- []() {
146- using std::numeric_limits;
147-
148- if constexpr (numeric_limits<ruis::real>::has_infinity) {
149- return -numeric_limits<ruis::real>::infinity ();
150- } else {
151- return numeric_limits<ruis::real>::min ();
152- }
153- }(),
154- mouse_button::left,
155- this ->cur_pointer_id
156- };
157- this ->flickable_on_mouse_button (mbe);
141+ auto pos = []() {
142+ using std::numeric_limits;
143+
144+ if constexpr (numeric_limits<ruis::real>::has_infinity) {
145+ return -numeric_limits<ruis::real>::infinity ();
146+ } else {
147+ return numeric_limits<ruis::real>::min ();
148+ }
149+ }();
150+
151+ // move the cursor out of any widget to update hovered states
152+ this ->flickable_on_mouse_move ({
153+ .pos = pos,
154+ .pointer_id = this ->cur_pointer_id
155+ });
156+
157+ this ->flickable_on_mouse_button ({
158+ .action = button_action::release,
159+ .pos = pos,
160+ .button = mouse_button::left,
161+ .pointer_id = this ->cur_pointer_id
162+ });
158163 }
159164
160165 this ->flickable_scroll_by (-delta);
@@ -164,7 +169,7 @@ ruis::event_status flickable::on_mouse_move(const mouse_move_event& event)
164169 case state::not_scrolling:
165170 // std::cout << "mouse move: not scrolling\n";
166171 return this ->flickable_on_mouse_move (event);
167- case state::scrolling :
172+ case state::dragging :
168173 {
169174 vec2 delta = event.pos - this ->prev_touch_point ;
170175 // std::cout << "mouse move: scrolling, delta: " << delta << "\n";
0 commit comments