rinigus / mapbox-gl-qml

Unofficial Mapbox GL Native bindings for Qt QML
GNU Lesser General Public License v3.0
38 stars 10 forks source link

Detect panning only once a threshold has been crossed #36

Closed otsaloma closed 6 years ago

otsaloma commented 6 years ago

I looked into into #32 and added a threshold that has to be crossed for a gesture to be detected as panning, thus keeping the map still when merely tapping.

Please test. map.pixelRatio * 20 seemed to work for me on Sailfish X, but it would be good to test on a different screen. Secondly, I didn't really know if using map.pixelRatio is correct here, should it be something from QML Screen?

rinigus commented 6 years ago

On 1+X it seem to work fine (5 inch screen, same resolution as Sony X). I think it should be linked to something from Screen. map.pixelRatio is more related to how map is translating the events and can be set by developers pretty much to anything, but here we just want to keep the accidental screen panning to be prevented. Which is more about screen itself.

rinigus commented 6 years ago

And now thinking about it, it would have to be cross-platform. Probably just the size of the map could be used as well - it should be a decent indicator for this purpose.

otsaloma commented 6 years ago

I don't think the size of the map is good for this, I think it should be basically the thickness of an average finger (or maybe half a finger) converted to pixels. But, what do you mean by cross-platform, are Screen.devicePixelRatio and Screen.pixelDensity no good?

otsaloma commented 6 years ago

Now that I tried, Screen.devicePixelRatio gives 1 on my Sailfish X, Screen.pixelDensity gives about 17.6 (px/mm), which seems to be correct, so the latter seems to be the useful one. It's available since Qt 5.2.

rinigus commented 6 years ago

I agree, Screen pixel density looks to be a great candidate. Let's use it.

With the cross platform I met that it's not just for Sailfish. But since Screen API if of Qt and not Silica, that fits very well .

otsaloma commented 6 years ago

Fixed now to use Screen.pixelDensity. The threshold translated to 3 mm, which sounds sensible to me. With this change I'm confident it should work well across different screens.

M4rtinK commented 6 years ago

With the cross platform I met that it's not just for Sailfish. But since Screen API if of Qt and not Silica, that fits very well .

My only worry would be bogus data being returned by this API on some platforms (eq. broken Qt hardware adaptation) - on the other hand I'm not sure what one could do about it in such a case without some platform specific hacks.

I don't think the size of the map is good for this, I think it should be basically the thickness of an average finger (or maybe half a finger) converted to pixels.

I think this is the correct way of thinking about this - I remember there being some sort of outright "finger size in pixels" constant back in the Neo FreeRunner era used for the same thing.

rinigus commented 6 years ago

@otsaloma: thank you very much, it works well on my device as well.

@M4rtinK: if the adaptation is broken, its a good way of signaling it as well. Sometimes we don't even know whether the returned constants are correct. So, if maps software starts to behave badly, it can be traced back to the source and fixed on Qt adaptation level.

Merging. I'll keep an eye on QMapboxGL releases and hopefully we can get a new one soon. Then I could release it all together. If not, I'll push the release out, probably towards weekend.