Skip to content

Conversation

@sgrif
Copy link

@sgrif sgrif commented Apr 26, 2013

Assuming that we always want to use NSLayoutFormatAlignAllCenterX/Y causes certain layouts to become impossible to create. This minor change adds the ability to optionally pass the options for each constraint individually, as so:

    layout.vertical '|-padding-[headline]->=0-[byline]-padding-|', NSLayoutFormatAlignAllLeft
    layout.horizontal '|-[headline]-|'

The default behavior is unchanged, and this change should be fully backwards compatible.

@seanlilmateus
Copy link
Contributor

👍
I support this pull request and I suppose to change the default Option to the cocoa default option NSLayoutFormatDirectionLeadingToTrailing.
explanation: if we want to create a pretty simple layout like
[AVIEW]-[BVIEW]
[____CVIEW ___]

it should be possible without unambiguous Constraint:

    Motion::Layout.new do |layout|
      layout.view self.view
      layout.subviews 'A' => aview, 'B' => bview, 'C' => cview 
      layout.vertical    "|[A]-[C(==A)]|"
      layout.vertical    "|[B(==A)]"
      layout.horizontal "|[A]-[B(==A)]|"   ## this causes the error
      layout.horizontal "|[C]|"
    end

with the current option this would cause an error:

<NSLayoutConstraint:0x4012303e0 H:[A]-(NSSpace(8))-[B] (Names: B:0x40122e600, A:0x40122e220 )>

This should be the final result with the default Option:
screen shot 2013-05-09 at 14 18 14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants