Neon icon indicating copy to clipboard operation
Neon copied to clipboard

Can I use this framework for Mac OSX application?

Open ttruongatl opened this issue 10 years ago • 15 comments

Dear,

Neon is really excellent framework for UI design. But I do not know it is possible for mac os application or not?

Thanks.

ttruongatl avatar Sep 29 '15 16:09 ttruongatl

I've never messed with OSX applications before, but I do believe that the origin { 0,0 } is different on OSX apps than iOS apps, lower-left vs. upper-left respectively, so I'm guessing it would not work out of the box, although I'm looking into making a simple fix that will make it work properly on both.

mamaral avatar Sep 29 '15 16:09 mamaral

Thanks for your working. Hoping you will completer this framework for both, iOS & OSX.

ttruongatl avatar Sep 30 '15 05:09 ttruongatl

Would love to use this framework on OS X. Please let me know if you make any progress on that front.

RohanNagar avatar Oct 26 '15 21:10 RohanNagar

Neon looks like a great framework ! I installed it into my project via Carthage this morning, and have been trying to figure out why the subview I've been trying to anchor to the top edge kept showing up centered on the left side with half of the view offscreen. I just realized that the coordinate system on OS X must be different from iOS.. Lol.

thomjordan avatar Oct 29 '15 19:10 thomjordan

Yeah @thomjordan I still need to look into making this work out of the box for both systems.

mamaral avatar Oct 29 '15 20:10 mamaral

Great to hear, thanks for the update !

thomjordan avatar Oct 30 '15 06:10 thomjordan

There's a read-only Bool property in NSView called flipped that can change the traditional OS X coordinates to a new basis whose origin is in the upper-left.

It defaults to false but can be overridden in a custom subclass of NSView or within an extension to an existing subclass of NSView:

public class NSFlippedView : NSView {
    override public var flipped: Bool {
        return true
    }
}

extension NSTextField  {
    override public var flipped: Bool {
        return true
    }
}

After setting these, Neon now seems to be working perfectly on OS X as far as I can tell, at least within the scope of my limited use of it yesterday. I should be trying out more of the framework over the next few days.

BTW, a quick way to utilize existing NSView-derived classes whose content might depend on the traditional coordinate system is to set the frame and bounds of an traditional view instance to however you want it to look, then add it as a subview of a fresh NSFlippedView object, setting its frame and bounds to fit the size of the inner object's frame, and their origins to (0,0). Neon then can correctly utilize the outer NSFlippedView while the frame and bounds of the inner object may be adjusted in the old coordinate system if needed. I've done this with a few custom view classes and it's been working outstandingly well ! Thanks for sharing this amazing and long needed framework.

thomjordan avatar Nov 08 '15 10:11 thomjordan

@thomjordan That is awesome! Any chance you'd be able to throw that in a pull request?

mamaral avatar Nov 08 '15 22:11 mamaral

I can sure try.. I'm not that familiar with Git yet but I can look into it more over the next few days..

On Sun, Nov 8, 2015 at 5:19 PM, Mike Amaral [email protected] wrote:

@thomjordan https://github.com/thomjordan That is awesome! Any chance you'd be able to throw that in a pull request?

— Reply to this email directly or view it on GitHub https://github.com/mamaral/Neon/issues/3#issuecomment-154881507.

thomjordan avatar Nov 08 '15 23:11 thomjordan

@thomjordan No problem, let me know if you need any assistance.

mamaral avatar Nov 09 '15 02:11 mamaral

I forked Neon to my GitHub page, then cloned it to my local system. On my local copy, I added some lines to the #ifdef in Neon.swift, a few times, but each time I save, close then open the file again the changes are gone. I think I know now how to do the rest, submitting the pull request, etc. I just seem to be stuck on this one part.. how to be able to make changes in the first place. There's no diffs available to be staged either. I tried working directly from the clone, and I also tried do a separate checkout after the clone. I've got to be missing something very obvious. I'll try again tomorrow.

thomjordan avatar Nov 17 '15 00:11 thomjordan

I've seen very good results using this version of Neon modified for OS X. I still haven't figured out how to initiate pull requests in Git, so instead here's a zip attachment of the Neon source folder circa mid-November 2015, modified for the default OS X coordinate system with a lower-left origin. I basically just switched around some of the enum cases and turned some "+" signs into "-", et al. It took less than an hour which was surprising, becoming largely mechanical once deciding on a short sequence of steps for repeatedly applying the geometrical reflection within the code. Since then any time I've used the module in OS X I've seen no errors or unpredictable behavior. In the zip archive below, the source files show where each modification was made, by commenting out and preserving the original expressions made for the iOS coordinate system. Thanks for creating Neon and sharing it on here !

NeonSource(OSX).zip

thomjordan avatar May 10 '16 23:05 thomjordan

@thomjordan Excellent, I'll see what you did there and see if I can conditionalize it. Honestly, the reason why I haven't done this yet is because I've actually never built an OSX app, and have no idea how to set it up with a simple widow for testing. I spent like 30 minutes one night last year and gave up, then forgot about it since.

mamaral avatar May 11 '16 00:05 mamaral

I used Neon to help achieve a quick, balanced UI look early on within this large-scale application I'm working on, and then moved on to other areas of the app. I'm in the midst of some heavy refactoring this week, and looking back at some previously-written code it's obvious to me now that I've achieved better, more consistent results using Neon than what I could get using Auto Layout, and much more quickly too. I recently got NSStackView working correctly with the right settings of Auto Layout constraints for my project, and I can see using a mixture of stack views and Neon to achieve some truly superb results. Thanks again !

thomjordan avatar May 17 '16 03:05 thomjordan

@thomjordan Thanks for the feedback! :)

mamaral avatar May 17 '16 21:05 mamaral