GodSVG icon indicating copy to clipboard operation
GodSVG copied to clipboard

Zoom (InputEventMagnifyGesture) on Android

Open Alex2782 opened this issue 2 years ago • 19 comments

v4.2.beta2.official [f8818f85e]

Tested on an Android tablet, InputEventMagnifyGesture does not arrive there, is it an engine problem or? If so I could try to debug and fix under Android Studio https://github.com/MewPurPur/GodSVG/blob/5a009656f999506e08077ab4ed2223dc40afe5da/src/ui_parts/viewport.gd#L79

Alex2782 avatar Nov 02 '23 13:11 Alex2782

No idea, I haven't tested this app on phone for a while now. It would be appreciated if you can help!

MewPurPur avatar Nov 02 '23 13:11 MewPurPur

It's an "engine" problem, I'm closing here.

Logcat , "ScaleGestureDetector" but no InputEventMagnifyGesture

2023-11-02 14:46:45.599 31971-31971 ScaleGestureDetector    org.godotengine.bugreport2           I  TwScaleGestureDetector
2023-11-02 14:46:45.611 31971-32109 godot                   org.godotengine.bugreport2           I  _unhandled_input:InputEventMouseMotion: button_mask=1 (Left Mouse Button), position=((224.9121, 210.453)), relative=((2.249121, -4.047473)), velocity=((45.53934, -260.7545)), pressure=0.00, tilt=((0, 0)), pen_inverted=(false)
2023-11-02 14:46:45.611 31971-32109 godot                   org.godotengine.bugreport2           I  _unhandled_input:InputEventScreenDrag: index=0, position=((224.9121, 210.453)), relative=((2.249121, -4.047473)), velocity=((45.53934, -260.7545)), pressure=0.00, tilt=((0, 0)), pen_inverted=(false)
2023-11-02 14:46:45.611 31971-32109 godot                   org.godotengine.bugreport2           I  _unhandled_input:InputEventScreenDrag: index=1, position=((188.4764, 441.1588)), relative=((-1.7993, 2.698297)), velocity=((-211.065, 139.1805)), pressure=0.00, tilt=((0, 0)), pen_inverted=(false)
2023-11-02 14:46:45.611 31971-32109 godot                   org.godotengine.bugreport2           I  4.6330361366272
2023-11-02 14:46:45.616 31971-31971 ScaleGestureDetector    org.godotengine.bugreport2           I  TwScaleGestureDetector
2023-11-02 14:46:45.628 31971-32109 godot                   org.godotengine.bugreport2           I  _unhandled_input:InputEventMouseMotion: button_mask=1 (Left Mouse Button), position=((227.1613, 207.305)), relative=((2.249121, -3.148022)), velocity=((141.9346, -296.3234)), pressure=0.00, tilt=((0, 0)), pen_inverted=(false)
2023-11-02 14:46:45.628 31971-32109 godot                   org.godotengine.bugreport2           I  _unhandled_input:InputEventScreenDrag: index=0, position=((227.1613, 207.305)), relative=((2.249121, -3.148022)), velocity=((141.9346, -296.3234)), pressure=0.00, tilt=((0, 0)), pen_inverted=(false)
2023-11-02 14:46:45.628 31971-32109 godot                   org.godotengine.bugreport2           I  _unhandled_input:InputEventScreenDrag: index=1, position=((187.5767, 443.4074)), relative=((-0.899643, 2.248627)), velocity=((-211.065, 139.1805)), pressure=0.00, tilt=((0, 0)), pen_inverted=(false)

Alex2782 avatar Nov 02 '23 13:11 Alex2782

Re-opened as "Godot is the culprit" issues are still something I want to document, and to maybe try to fix on the engine side in the future.

MewPurPur avatar Nov 02 '23 13:11 MewPurPur

ok, I know the input sources of Android well by now. If I find a solution I link here too.

Alex2782 avatar Nov 02 '23 13:11 Alex2782

https://github.com/godotengine/godot/issues/84387#issuecomment-1792309747

v4.2.beta4.official [93cdacbb0] I have tried the new setting, zooming is strange. (video below)

image

https://github.com/MewPurPur/GodSVG/assets/41921395/af35254f-6cdb-4382-9153-c97bd0f071f1

Alex2782 avatar Nov 03 '23 17:11 Alex2782

Looks nice! To me it looks like the inputs just need to be toned down a notch or something.

MewPurPur avatar Nov 03 '23 17:11 MewPurPur

or that: https://github.com/MewPurPur/GodSVG/issues/57

Zooming forces the SVG to the center

Alex2782 avatar Nov 03 '23 18:11 Alex2782

Oh yeah, it's probably that.

MewPurPur avatar Nov 03 '23 18:11 MewPurPur

I'm working on solving the underlying bug. Could you test after that?

MewPurPur avatar Nov 04 '23 11:11 MewPurPur

On weekends I usually have less time, next week I'll try to release it in the PlayStore as an internal test.

Alex2782 avatar Nov 04 '23 13:11 Alex2782

I couldn't find any improvements, it's still like in the video or something like that

InputEventMagnifyGesture and not InputEventPanGesture would have to be used for Zoom, I think. I will test it in the next few days and create PR

	if event is InputEventPanGesture:
		if event.ctrl_pressed:
			zoom_menu.zoom_level *= 1 + event.delta.y / 2
		else:
			set_view(view.position + event.delta * 32)

Alex2782 avatar Nov 06 '23 01:11 Alex2782

Unfortunately, remote debugging no longer works. I would have to check it via Android Studio, could take longer because I am still checking another problem via Android Studio.

PR #176 has improved it slightly, the graphic remains in the camera's field of view.

https://github.com/MewPurPur/GodSVG/assets/41921395/13e62444-2226-454e-8a3e-7d630b67debb

Alex2782 avatar Nov 06 '23 21:11 Alex2782

Ow. My hunch is that the delta from the set_view(view.position + event.delta * 32) line in viewport.gd shouldn't be multiplied by anything

MewPurPur avatar Nov 06 '23 21:11 MewPurPur

yes without InputEventPanGesture it is better, but still not perfect. You can compare it with the mouse wheel, it does not zoom exactly where the mouse cursor or the fingers are.

	#if event is InputEventPanGesture:
	#	if event.ctrl_pressed:
	#		zoom_menu.zoom_level *= 1 + event.delta.y / 2
	#	else:
	#		set_view(view.position + event.delta * 32)

Alex2782 avatar Nov 06 '23 22:11 Alex2782

Ah yeah, I haven't implemented logic for that as it's harder. I'll get to it, but there are bigger priorities at the moment. If the zooming is not sporadically moving the screen around like in the videos, I'd say it's good enough for the time being.

MewPurPur avatar Nov 06 '23 22:11 MewPurPur

Ow. My hunch is that the delta from the set_view(view.position + event.delta * 32) line in viewport.gd shouldn't be multiplied by anything

/ 12 it is good, on the Samsung tablet 2k resolution

	if event is InputEventPanGesture:
		if event.ctrl_pressed:
			zoom_menu.zoom_level *= 1 + event.delta.y / 2
		else:
			set_view(view.position + event.delta / 12)
			pass

Alex2782 avatar Nov 06 '23 22:11 Alex2782

Huh, so it seems like the pan strength might need to be made configurable then.

MewPurPur avatar Nov 06 '23 22:11 MewPurPur

I'd really appreciate if someone who can test it takes a look at this code in viewport.gd:

image

InputEventGesture has a position argument, and zooming can now take an offset for which part of the screen it should focus on.

MewPurPur avatar Dec 28 '23 09:12 MewPurPur

it's not perfect yet (user friendly), I don't know if it's the code, I would have to debug the values more precisely first.

https://github.com/MewPurPur/GodSVG/assets/41921395/806a1a40-1a9c-4165-8cc7-559e701f9c26

Alex2782 avatar Jan 05 '24 20:01 Alex2782