Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any chance of porting this to OSX? #43

Closed
crewshin opened this issue Apr 22, 2015 · 31 comments
Closed

Any chance of porting this to OSX? #43

crewshin opened this issue Apr 22, 2015 · 31 comments
Assignees
Labels

Comments

@crewshin
Copy link

Any chance of porting this to OSX?

@danielgindi
Copy link
Collaborator

Well I am not planning to use this on OS X anytime soon, but if you are willing to do it - that would be great!
If I'm not missing anything, we just need typealiases for UIKit types. Everything else is same API as iOS.

@danielgindi
Copy link
Collaborator

Of course you would need to write an OS X app and test that it's behaving there :-)

@danielgindi
Copy link
Collaborator

I guess there's no interest there. I will close this in a day of two if nobody wants to help with this. (Help means porting using typealiases, possibly handle mouse event in addition to touches, and testing to that it actually works)

@crewshin
Copy link
Author

crewshin commented May 2, 2015

Oh there is interest, trust me. I mean basically there is one option for OSX right now (core plot) and it's an old crotchety bastard.

Although I'd LOVE to, I personally don't have the time to learn this entire framework's inner workings enough to do this on top of everything else I have going on at the moment. I was hoping someone that knew it's internals would be able to bang it out real fast. I mean it shouldn't be too much work.

@danielgindi
Copy link
Collaborator

Okay then :)
We'll leave it open for a while!

I personally don't have the time right now but it really shouldn't be too much work... May be this will be your contribution to the project, who know ;)

@Fab1n
Copy link

Fab1n commented Sep 8, 2015

I like the project and porting it to OSX will be done... Maybe I will do some work soon

@crewshin
Copy link
Author

crewshin commented Sep 8, 2015

That would be fantastic @Fab1n ! I'm helping start up a company and even though I'd love to help port this, time has not been my friend lately.

@liuxuan30
Copy link
Member

@crewshin same as you. God I wish I have 48 hours a day.

@klaas
Copy link

klaas commented Sep 26, 2015

+1 OS X support would be more than awesome.

@danielgindi
Copy link
Collaborator

@Fab1n any news on this?

@Fab1n
Copy link

Fab1n commented Oct 2, 2015

@danielgindi sorry, not yet. I didn't need it really until now, but when I need it, I will convert it.
Otherwise, what about the others here? It should not be much pain to convert it to OSX... Just work on it, submit a pull request

@pblen
Copy link

pblen commented Nov 18, 2015

danielgindib, would like to understand the effort. Could you point me to where the changes need to be made. thx.

@pmairoldi
Copy link
Collaborator

If it was just making type alias for bridging it would be easy but there is an extensive use of gesture recognizers which don't have an equivalent for OS X. There is also some use of CADisplayLink which doesn't exist either but from what I read can be done.

It's not as simple as everyone here makes it seem. You can try it out and maybe help us since I don't usually make things for OS X.

@liuxuan30
Copy link
Member

And the coordinate system is different on OS X and iOS I remember?

@danielgindi
Copy link
Collaborator

danielgindi commented Nov 19, 2015 via email

@whatsthebeef
Copy link

Can the gesture recognizers not be implemented in stages?

@pmairoldi
Copy link
Collaborator

There is no 1 to 1 mapping of iOS gesture recognizers to OS X gesture recognizers. Some don't exist at all so those would need to be created for OS X or disabled all together. When I tried this out last that is where I stopped.

@whatsthebeef
Copy link

I have limited knowledge of the library but some of my colleagues use it quit extensively on an iOS app and I'm working on the OSX port of this app. I therefore have some time to invest if it is feasible to make it OSX compliant and I'm interested in your thoughts of how we might go about it.

  • For gestures can we not just begin with a simple scroll which I guess can be mapped to an OSX gesture recognizer and switch the other gestures on/off according to the platform?
  • If we followed this approach and given the work you have already done how long do you think it might take?

@pmairoldi
Copy link
Collaborator

Probably a couple days. Don't know if I kept my work on the OS X version. If you could look into the gesture stuff that would be great. The NS* to UI* conversion is really easy with typaliases so dont worry about that.

@whatsthebeef
Copy link

Okay so I did a little research and this is what I came up with.

UI* to NS* conversion

  • For the simpler classes (UIColor, UIFont etc.) we should just be able to use typealiases (as suggested by @petester42)
  • For the more complicated classes (NSImage etc.) it's less clear and probably needs to be approached on a class by class basis using wrappers where necessary.
  • For classes that are missing methods, we could use typealiases and/or wrappers/categories to add the missing methods.
  • The typealiases could either specify a new class name to be used in both platforms or just point from UI* to NS* in OSX.

UIView

  • It's not clear to me what the consequences are of typealiasing UIView and other classes high up the hierarchy. But we can just try it out I guess.

Gestures

  • Gestures that overlap (Tap, DoubleTap) could possibly be typealiased and we can use wrappers/categories to apply the correct action according to the platform if it needs it.
  • Gestures that don't overlap (Pinch, Drag) can be stubbed out in the platform that doesn't used them.

Coordinates

  • Because the NSView and UIView have different origins for the coordinates we will need to use the isFlipped method on NSView.

Any thoughts?

@pixelspark
Copy link
Contributor

After a few hours:

naamloos

Will upload my fork soon after clean-up.

@liuxuan30
Copy link
Member

awesome work :) only a few hours?

@pixelspark
Copy link
Contributor

@liuxuan30 yes, the find/replace bit of UI to NS/UI was actually easy. The difficult bits were the UIImage specific features (this project came in handy to find how they could be implemented) and implementing CADisplayLink for OSX (there is no such thing so I simply made it into a 60fps timer - could perhaps also use CVDisplayLink in the future).

@pixelspark
Copy link
Contributor

I've also implemented gestures by the way, however they need some more work. Tapping (clicking) and dragging works, haven't tried the others. OSX does not provide an NSPinchGestureRecognizer so that one won't work for sure.

@crewshin
Copy link
Author

Thanks for putting time into this guys! I'm sure free time is hard to come by for everyone in here.

@danielgindi
Copy link
Collaborator

@pixelspark thank you so much for you efforts!

@danielgindi
Copy link
Collaborator

I've done some improvements. There are still some limitations to the gesture recognizers:

  1. "magnification" recognizer has no way to tell the angle, as it does not share information about the trackpad touches...
  2. There are issues with velocity, but no way to resolve those in current version of the OSX SDK. The NSGestureRecognizer api is really lacking, and there's no way to handle the trackpad touched here. I would have written my own rotation gesture recognizer - I did so on the Android side, with velocity and eveything. But as it's impossible to effectively subclass the NSGestureRecognizer - it's not use.

@danielgindi
Copy link
Collaborator

I have implemented CVDisplayLink for OSX. The animations look smoother now.

Funny thing - CVDisplayLink is meant specifically for OpenGL, which makes me want to go back and try again to move all the drawing to OpenGL. But that's a project for another time :-)

@pixelspark
Copy link
Contributor

Looks great, Daniel! Thanks so much for fixing up these last things. I have pulled your branch into an OS X application that draws some charts and gestures + animations seem to work smoothly 👍

@danielgindi
Copy link
Collaborator

@petester42 feel free to merge that in when you feel it is ready!

@danielgindi
Copy link
Collaborator

I think we need some comments in the docs about this, explaining current limitations (touch gestures).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants