FLTK logo

Re: [fltk.coredev] Gesture progress for 1.4?

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.coredev  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: Gesture progress for 1.4? Rob McDonald Oct 08, 2021  
  This

https://docs.microsoft.com/en-us/windows/win32/wintouch/windows-touch-gestures-overview

Looks like the documentation to support this kind of thing on Windows.  I don't have any Windows touch hardware to develop this.

Rob


On Friday, October 8, 2021 at 10:22:31 PM UTC-7 Rob McDonald wrote:
Thanks to Albrecht's direction, I parroted this commit by Matthias Melcher to add support for a couple other MacOS gestures, two-finger rotate and two-finger scroll.  I can add three finger swype, but my application does not need it, so I'll hold off to see how this is received first.

Changes pushed up here:


This was done in a monkey-see monkey-do way -- I do not claim to have any understanding of Apple's API's.  I have never used Objective-C and will continue to make that claim after doing this work.  I followed Matthias' example and read this bit of Apple documentation as well as a few other bits of their terrible API docs...

In the end, it works for my application and is pretty cool.  It would be great if other OS support could be similarly added.

The rotate gesture is pretty straightforward.  Apple returns the rotation angle in floating point degrees.  I followed Matthias' example and multiplied by 1000.0 and returned it the dy integer.

I also added handling for two-finger scroll on the trackpad.  Apple actually fires the same event for this as for a mouse scroll wheel -- but with tiny magnitude dx,dy such that it seems like nothing is actually happening.  In my application (involving 3D manipulation), I wanted to have different behavior for the scroll wheel (zoom) as for two-finger scroll (pan).  So, I needed to differentiate between these different kinds of scrolls.

I eventually found NSEventSubtype which is equal to NSEventSubtypeMouseEvent when the event originates from a mouse rather than other hardware.  There seemed to be other similar things to check for slightly different API versions.  I don't know if we want to add a bunch of conditionals to know which variable to test.

With this change, FLTK will issue separate FL_MOUSEWHEEL and FL_SCROLL_GESTURE events depending on this value.  Existing applications should be OK with this because the dx,dy returned by two-finger scroll via FL_MOUSEWHEEL is probably getting ignored (unless you do some really angry scrolling in the y-direction only).

I wasn't sure if the float s = Fl::screen_driver()->scale(0); scale value needs to be applied to the scroll gesture.  I'm not sure where it comes from and how I would get it to have different values for testing on my machine.

I also wasn't sure if and where to add to unit tests, test applications, documentation, etc.

Finally, as this adds some new event types, I am not sure how to add protections to existing applications that still need to be able to compile against older versions of FLTK that do not have these defined.

Rob

On Thursday, October 7, 2021 at 2:31:03 PM UTC-7 Rob McDonald wrote:
I think there's something already available for macOS but I don't know
how complete / working this code is.

  FL_ZOOM_GESTURE       = 26,

Thanks for pointing that out, I was unaware of it.

It works for me.

 I'd encourage whoever implemented this to continue to support other MacOS supported gestures.  Hopefully in time it could also grow to include any Windows and Linux gestures.
 
I'm personally not working on this and I'm too busy with other stuff to
start yet another "project". I don't know of any other dev working on
touch and gesture events.

Understood.  Thanks,

Rob
 

--
You received this message because you are subscribed to the Google Groups "fltk.coredev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkcoredev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkcoredev/f6e35377-ba75-44fa-a7c4-a5f05b004c9cn%40googlegroups.com.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.