motion-layout icon indicating copy to clipboard operation
motion-layout copied to clipboard

Add ability to override constraint options

Open sgrif opened this issue 12 years ago • 1 comments

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.

sgrif avatar Apr 26 '13 16:04 sgrif

:+1: 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

seanlilmateus avatar May 09 '13 12:05 seanlilmateus