Skip to content

Commit 44e9e7b

Browse files
committed
stuff
1 parent ea33d55 commit 44e9e7b

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/ruis/widget/base/touch/flickable.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ ruis::event_status flickable::on_mouse_button(const mouse_button_event& event)
8181
utki::assert(event.action == button_action::release, SL);
8282
this->cur_state = state::inertial_scrolling;
8383

84-
this->velocity = this->calculate_touch_velocity();
84+
this->velocity = this->calculate_touch_velocity_px_per_ms();
8585
std::cout << "touch release, vel = " << this->velocity << std::endl;
8686

8787
this->touch_history.clear();
@@ -253,7 +253,7 @@ void flickable::push_touch_move_to_history(touch_move_info tm)
253253
this->touch_history.push_back(std::move(tm));
254254
};
255255

256-
ruis::vec2 flickable::calculate_touch_velocity()
256+
ruis::vec2 flickable::calculate_touch_velocity_px_per_ms()
257257
{
258258
if (this->touch_history.size() < 2) {
259259
// std::cout << "flickable::calculate_touch_velocity(): return 0. this->touch_history.size() = " << this->touch_history.size() << std::endl;
@@ -276,13 +276,13 @@ ruis::vec2 flickable::calculate_touch_velocity()
276276
}
277277

278278
// use Ordinary Least Squares method to fit a quadratic curve to the points of touch history
279-
ruis::vec2 vel = calculate_touch_velocity_for_at_least_3_points_using_ols_method();
279+
ruis::vec2 vel = calculate_touch_velocity_for_at_least_3_points_using_ols_method_px_per_ms();
280280

281281
// std::cout << "flickable::calculate_touch_velocity(): return " << vel << ". this->touch_history.size() = " << this->touch_history.size() << std::endl;
282282
return vel;
283283
}
284284

285-
ruis::vec2 flickable::calculate_touch_velocity_for_at_least_3_points_using_ols_method()
285+
ruis::vec2 flickable::calculate_touch_velocity_for_at_least_3_points_using_ols_method_px_per_ms()
286286
{
287287
// Ordinary Least Squares method fits quadratic curve y(t)=a*t^2+b*t+c to a set of n >= 3 points.
288288
// Coefficients a, b and c can be found by solving the following system of linear equations

src/ruis/widget/base/touch/flickable.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,13 @@ class flickable :
5959
std::deque<touch_move_info> touch_history;
6060

6161
void push_touch_move_to_history(touch_move_info tm);
62-
vec2 calculate_touch_velocity();
6362

64-
ruis::vec2 calculate_touch_velocity_for_at_least_3_points_using_ols_method();
63+
vec2 calculate_touch_velocity_px_per_ms();
64+
65+
/**
66+
* @return Pixels per ms.
67+
*/
68+
ruis::vec2 calculate_touch_velocity_for_at_least_3_points_using_ols_method_px_per_ms();
6569

6670
// inertial scrolling state
6771
ruis::vec2 velocity;

0 commit comments

Comments
 (0)