From 9296ffd6ef1f8fcc1bbb12332fdc9480ff18c68b Mon Sep 17 00:00:00 2001 From: dam Date: Tue, 22 Feb 2022 02:17:00 +0000 Subject: Improve touch scroll for quick-small-touches. --- readme.md | 1 + touch_item_list/touch_item_list.gd | 6 +++++- touch_vertical_container/touch_vertical_container.gd | 6 +++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 86cfa1c..fe85a0c 100644 --- a/readme.md +++ b/readme.md @@ -56,6 +56,7 @@ Surgery Log - [ ] Database menu and action buttons are not nice; Improve appearance; - [ ] Check if import_option_sets, store_option_sets, store_database require the parameter save_changes; this requires changes on databse, stage and menu scripts; - [ ] Improve menu appearance; +- [ ] Tweak 'POINTER_VELOCITY_DECAYING_FACTOR' and 'POINTER_VELOCITY_BOOST_FACTOR' on database and stage screens; - [ ] Setup two themes: - [ ] theme_light - [ ] theme_dark diff --git a/touch_item_list/touch_item_list.gd b/touch_item_list/touch_item_list.gd index 5a1279c..8b79431 100644 --- a/touch_item_list/touch_item_list.gd +++ b/touch_item_list/touch_item_list.gd @@ -34,7 +34,11 @@ func pointer_input_on_press_handler(pointer: PointerInputSensor.PointerInputData func pointer_input_on_drag_handler(pointer: PointerInputSensor.PointerInputData): is_pointer_dragging = true - pointer_drag_velocity = pointer.velocity.y * POINTER_VELOCITY_BOOST_FACTOR + var reported_velocity_abs := abs(pointer.velocity.y) + var relative_velocity := pointer.relative_position.y * Engine.get_frames_per_second() + var relative_velocity_abs := abs(relative_velocity) + var max_velocity := pointer.velocity.y if reported_velocity_abs > relative_velocity_abs else relative_velocity + pointer_drag_velocity = max_velocity * POINTER_VELOCITY_BOOST_FACTOR v_scroll_bar.value -= pointer.relative_position.y diff --git a/touch_vertical_container/touch_vertical_container.gd b/touch_vertical_container/touch_vertical_container.gd index 2a1a92a..07b8714 100644 --- a/touch_vertical_container/touch_vertical_container.gd +++ b/touch_vertical_container/touch_vertical_container.gd @@ -50,7 +50,11 @@ func pointer_input_on_press_handler(pointer: PointerInputSensor.PointerInputData func pointer_input_on_drag_handler(pointer: PointerInputSensor.PointerInputData): is_pointer_dragging = true - pointer_drag_velocity = pointer.velocity.y * POINTER_VELOCITY_BOOST_FACTOR + var reported_velocity_abs := abs(pointer.velocity.y) + var relative_velocity := pointer.relative_position.y * Engine.get_frames_per_second() + var relative_velocity_abs := abs(relative_velocity) + var max_velocity := pointer.velocity.y if reported_velocity_abs > relative_velocity_abs else relative_velocity + pointer_drag_velocity = max_velocity * POINTER_VELOCITY_BOOST_FACTOR self.scroll_vertical -= pointer.relative_position.y -- cgit v1.2.3