colinta / teacup

This project has been sunset in favor of MotionKit
github.com/motion-kit/motion-kit
Other
602 stars 85 forks source link

Frame calculations and auto-layout with OSX #114

Closed JonasNielsen closed 10 years ago

JonasNielsen commented 11 years ago

Hi guys

I'm struggling to position my views correctly with teacup 2.1.2 (OSX app). I understand that the coordinate system is inverted compared to iOS. Still I have a suspicion that some of the helper and layout methods are not working as expected.

My strategy so forth has been to place views with frame: and beg that OSX would arrange them nicely using springs and struts - autoresizingMask:. If I only use frame:, views are placed in correct coordinates. Using autoresizingMask appears to have no or random results.

This is frustrating, because it's often basic problems: How do you pin a bar to the top of a window? I would expect the following to work:

style :header,
    top: 0, 
    width: '100%',
    height: 50,
    autoresizingMask: autoresize.fill_top
end

But it doesn't, the view is at the bottom. Increasing the top: value moves the view upwards in the coordinate system.

For some views, I've had moderate success with constraints, however at some point the layout breaks and it's difficult to debug why.

What is the best layout technique for OSX? And how much of Frame calculations, Auto layout and Autoresizing mask is supported?

Excuse me for the broad question, it's hard to be more concrete without loads of examples.

My conclusion has been that it is possible to position views only using frame:, but it's extremely cumbersome to calculate everything from the bottom of a window and the result is not very dynamic.

JonasNielsen commented 11 years ago

A quick update:

In particular I was having problems with views inside NSTabView. I wasn't aware that views inside NSTabView uses a flipped coordinate system (logical, right..).

The documentation says that it's possible to override isFlipped for any view to flip the coordinate system. This could probably be useful for many views. I'll give it a try.

colinta commented 10 years ago

Any update on this one? Is this an issue with Teacup, or can this issue be closed?

JonasNielsen commented 10 years ago

Honestly, I don't know. I ended up hard-coding the dimensions and positions of most of my views. Thankfully this wasn't an issue for the kind of interface I needed. Feel free to close the issue.

colinta commented 10 years ago

K, if it comes up again, please submit a project that reproduces the issue and file another report. Thanks!