vanilla icon indicating copy to clipboard operation
vanilla copied to clipboard

Look at supporting Cocoa's Auto Layout.

Open typesupply opened this issue 12 years ago • 9 comments

In 10.7, Apple added a really interesting new method for building interfaces. I think this could be a replacement for the posSize argument in the standard vanilla object constructor. It's definitely worth a try.

I have skimmed the conceptual documentation and a couple of blog posts and I think the two bits of data are the layout string and an identifier hat the layout engine uses in conjunction with the layout string. These are my initial thoughts for the layout string:

  1. posSize could be a triple as it has been for years or it could be a string. If it is a string, the string is the auto layout string.
  2. A new autoLayout keyword argument.

For the identifier:

  1. Use the attribute name that is used when adding the object to the super view.
  2. Add a new autoLayoutIdentifier.

I think using the string as posSize and the attribute name as he identifier seem the cleanest. I'll experiment with the timing and structure of all of this.

typesupply avatar Sep 02 '13 00:09 typesupply

a proposal for the auto layout https://gist.github.com/typemytype/b9c85801762c579448d7

typemytype avatar Oct 27 '17 12:10 typemytype

a proposal for the auto layout

From an API perspective, this looks cool. The internal code looks nice and simple, too. The only less-than-vanilla-like-thing is the constraint syntax:

V:|-padding-[info(>=controlHeight)]-padding-[info1(>=controlHeight)]-80-|

However, it's well document and we wouldn't have to reinvent the wheel so it's probably best to use it as specced by Apple.

typesupply avatar Oct 27 '17 13:10 typesupply

I'm still trying to understand that syntax, but overall this looks good!

justvanrossum avatar Oct 28 '17 07:10 justvanrossum

I'm going to create a branch, implement this and see what happens. I'd really like to add NSCollectionView, NSStackView and NSGridView to vanilla and those require auto layout. I'll submit a PR if it works.

typesupply avatar Apr 17 '19 18:04 typesupply

Regarding the PR I just submitted: there are two other views that could be useful for auto layout:

  • NSGridView
  • NSCollectionView

I have NSGridView wrapped and in an experiment, but it's complex and doesn't feel ready yet. I haven't wrapped NSCollectionView yet. That one may be too complex to wrap with vanilla.

I'll keep adjusting auto layout and implement things as they seem necessary. What I have now is a good starting point.

typesupply avatar Apr 19 '19 13:04 typesupply

@typesupply: Did you ever get anywhere with NSGridView? I would be interested in seeing the experiment you did (and maybe finishing it).

simoncozens avatar Aug 03 '20 07:08 simoncozens

Did you ever get anywhere with NSGridView?

No. I focused on NSCollectionView. I'll publish that at some point, but it probably won't be in vanilla. It's a pretty different set of concepts.

typesupply avatar Aug 10 '20 16:08 typesupply

Fair enough; I got most of what I wanted with a list view and horrible hackery.

simoncozens avatar Aug 10 '20 17:08 simoncozens

"horrible hackery" should be the code name for vanilla. 😄

typesupply avatar Aug 10 '20 17:08 typesupply