aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordam <dam@gudinoff>2022-02-22 02:17:00 +0000
committerdam <dam@gudinoff>2022-02-22 02:17:00 +0000
commit9296ffd6ef1f8fcc1bbb12332fdc9480ff18c68b (patch)
tree47f13d200bada167aa66db44f243dfb84dc52309
parentfd49e7c53a20728b3c6328141fdb8d63da1dff65 (diff)
downloadsurgery-log-9296ffd6ef1f8fcc1bbb12332fdc9480ff18c68b.tar.zst
surgery-log-9296ffd6ef1f8fcc1bbb12332fdc9480ff18c68b.zip
Improve touch scroll for quick-small-touches.
-rw-r--r--readme.md1
-rw-r--r--touch_item_list/touch_item_list.gd6
-rw-r--r--touch_vertical_container/touch_vertical_container.gd6
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