@@ -26,6 +26,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2626
2727using namespace ruis ::touch;
2828
29+ flickable::flickable (utki::shared_ref<ruis::context> context) :
30+ friction(context.get().units.dots_per_pp() * 0.005)
31+ {}
32+
2933ruis::event_status flickable::on_mouse_button (const mouse_button_event& event)
3034{
3135 if (event.button != mouse_button::left) {
@@ -161,17 +165,14 @@ ruis::event_status flickable::on_mouse_move(const mouse_move_event& event)
161165 }();
162166
163167 // move the cursor out of any widget to update hovered states
164- this ->flickable_on_mouse_move ({
165- .pos = pos,
166- .pointer_id = this ->cur_pointer_id
167- });
168-
169- this ->flickable_on_mouse_button ({
170- .action = button_action::release,
171- .pos = pos,
172- .button = mouse_button::left,
173- .pointer_id = this ->cur_pointer_id
174- });
168+ this ->flickable_on_mouse_move ({.pos = pos, .pointer_id = this ->cur_pointer_id });
169+
170+ this ->flickable_on_mouse_button (
171+ {.action = button_action::release,
172+ .pos = pos,
173+ .button = mouse_button::left,
174+ .pointer_id = this ->cur_pointer_id }
175+ );
175176 }
176177
177178 this ->flickable_scroll_by (-delta);
@@ -199,7 +200,9 @@ void flickable::update(uint32_t dt_ms)
199200 auto scrolled_by = this ->flickable_scroll_by (-this ->velocity_px_per_ms * ruis::real (dt_ms));
200201
201202 using std::copysign;
202- auto velocity_sign = this ->velocity_px_per_ms .comp_op ([](const auto & e){return copysign (real (1 ), e);});
203+ auto velocity_sign = this ->velocity_px_per_ms .comp_op ([](const auto & e) {
204+ return copysign (real (1 ), e);
205+ });
203206
204207 auto prev_velocity_px_per_ms = this ->velocity_px_per_ms ;
205208
@@ -210,14 +213,16 @@ void flickable::update(uint32_t dt_ms)
210213
211214 // std::cout << "this->velocity_px_per_ms = " << this->velocity_px_per_ms << std::endl;
212215
213- for (auto [prev, cur, scrolled_px] : utki::views::zip (prev_velocity_px_per_ms, this ->velocity_px_per_ms , scrolled_by)){
216+ for (auto [prev, cur, scrolled_px] :
217+ utki::views::zip (prev_velocity_px_per_ms, this ->velocity_px_per_ms , scrolled_by))
218+ {
214219 using std::signbit;
215- if (signbit (prev) != signbit (cur) || scrolled_px == 0 ){
220+ if (signbit (prev) != signbit (cur) || scrolled_px == 0 ) {
216221 cur = ruis::real (0 );
217222 }
218223 }
219224
220- if (this ->velocity_px_per_ms .is_zero ()){
225+ if (this ->velocity_px_per_ms .is_zero ()) {
221226 this ->context .get ().updater .get ().stop (*this );
222227 this ->cur_state = state::idle;
223228 }
0 commit comments