Class: MotionKit::ConstraintsLayout

Inherits:
BaseLayout show all
Defined in:
lib/motion-kit-ios/layouts/constraints_layout.rb,
lib/motion-kit-osx/layouts/constraints_layout.rb,
lib/motion-kit-cocoa/constraints/constraints_layout.rb

Instance Attribute Summary

Attributes inherited from BaseLayout

#parent

Instance Method Summary collapse

Methods inherited from BaseLayout

#add_deferred_block, #apply, #apply_with_context, #apply_with_target, #context, #deferred, #deferred_blocks, delegate_method_fix, #initialize, #ipad?, #iphone35?, #iphone4?, #iphone?, #method_missing, #orientation?, #retina?, #run_deferred, #set_layout, #target, #v

Methods included from BaseLayoutClassMethods

#layout_for, #memoize, #new_child, #target_klasses, #targets

Constructor Details

This class inherits a constructor from MotionKit::BaseLayout

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class MotionKit::BaseLayout

Instance Method Details

#above(view) ⇒ Object



201
202
203
204
205
206
207
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 201

def above(view)
  constraint = Constraint.new(target.view, :bottom, :equal)
  constraint.equals(view, :top)

  target.add_constraints([constraint])
  return constraint
end

#after(view) ⇒ Object Also known as: right_of



226
227
228
229
230
231
232
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 226

def after(view)
  constraint = Constraint.new(target.view, :left, :equal)
  constraint.equals(view, :right)

  target.add_constraints([constraint])
  return constraint
end

#baseline(value = nil) ⇒ Object



122
123
124
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 122

def baseline(value=nil)
  target_constraint(:baseline, :equal, value)
end

#before(view) ⇒ Object Also known as: left_of



217
218
219
220
221
222
223
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 217

def before(view)
  constraint = Constraint.new(target.view, :right, :equal)
  constraint.equals(view, :left)

  target.add_constraints([constraint])
  return constraint
end

#below(view) ⇒ Object



209
210
211
212
213
214
215
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 209

def below(view)
  constraint = Constraint.new(target.view, :top, :equal)
  constraint.equals(view, :bottom)

  target.add_constraints([constraint])
  return constraint
end

#bottom(value = nil) ⇒ Object



110
111
112
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 110

def bottom(value=nil)
  target_constraint(:bottom, :equal, value)
end

#bottom_left(value = nil) ⇒ Object



193
194
195
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 193

def bottom_left(value=nil)
  target_constraint([:left, :bottom], :equal, value, PointConstraint)
end

#bottom_right(value = nil) ⇒ Object



197
198
199
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 197

def bottom_right(value=nil)
  target_constraint([:right, :bottom], :equal, value, PointConstraint)
end

#center(value = nil) ⇒ Object



172
173
174
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 172

def center(value=nil)
  target_constraint([:center_x, :center_y], :equal, value, PointConstraint)
end

#center_x(value = nil) ⇒ Object



47
48
49
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 47

def center_x(value=nil)
  target_constraint(:center_x, :equal, value)
end

#center_y(value = nil) ⇒ Object



98
99
100
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 98

def center_y(value=nil)
  target_constraint(:center_y, :equal, value)
end

#compression_priority(value, for_axis: orientation) ⇒ Object

consistency with iOS methods:



19
20
21
# File 'lib/motion-kit-osx/layouts/constraints_layout.rb', line 19

def compression_priority(value, for_axis: axis)
  content_compression_resistance_priority(value, for_axis: axis)
end

#content_compression_resistance_priority(value, for_axis: orientation) ⇒ Object

consistency with iOS methods:



10
11
12
# File 'lib/motion-kit-osx/layouts/constraints_layout.rb', line 10

def content_compression_resistance_priority(value, for_axis: axis)
  axis = Constraint.axis_lookup(axis)
end

#content_hugging_priority(value, for_axis: orientation) ⇒ Object

consistency with iOS methods:



28
29
30
# File 'lib/motion-kit-osx/layouts/constraints_layout.rb', line 28

def content_hugging_priority(value, for_axis: axis)
  axis = Constraint.axis_lookup(axis)
end

#first(name) ⇒ Object



8
9
10
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 8

def first(name)
  ConstraintPlaceholder.new(:first, name)
end

#height(value = nil) ⇒ Object Also known as: h



147
148
149
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 147

def height(value=nil)
  target_constraint(:height, :equal, value)
end

#hugging_priority(value, for_axis: orientation) ⇒ Object

consistency with iOS methods:



37
38
39
# File 'lib/motion-kit-osx/layouts/constraints_layout.rb', line 37

def hugging_priority(value, for_axis: axis)
  content_hugging_priority(value, for_axis: axis)
end

#last(name) ⇒ Object



12
13
14
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 12

def last(name)
  ConstraintPlaceholder.new(:last, name)
end

#leading(value = nil) ⇒ Object



35
36
37
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 35

def leading(value=nil)
  target_constraint(:leading, :equal, value)
end

#max_baseline(value = nil) ⇒ Object



130
131
132
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 130

def max_baseline(value=nil)
  target_constraint(:baseline, :lte, value)
end

#max_bottom(value = nil) ⇒ Object



118
119
120
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 118

def max_bottom(value=nil)
  target_constraint(:bottom, :lte, value)
end

#max_center(value = nil) ⇒ Object



180
181
182
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 180

def max_center(value=nil)
  target_constraint([:center_x, :center_y], :lte, value, PointConstraint)
end

#max_center_x(value = nil) ⇒ Object



55
56
57
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 55

def max_center_x(value=nil)
  target_constraint(:center_x, :lte, value)
end

#max_center_y(value = nil) ⇒ Object



106
107
108
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 106

def max_center_y(value=nil)
  target_constraint(:center_y, :lte, value)
end

#max_height(value = nil) ⇒ Object



156
157
158
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 156

def max_height(value=nil)
  target_constraint(:height, :lte, value)
end

#max_leading(value = nil) ⇒ Object



43
44
45
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 43

def max_leading(value=nil)
  target_constraint(:leading, :lte, value)
end

#max_right(value = nil) ⇒ Object



67
68
69
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 67

def max_right(value=nil)
  target_constraint(:right, :lte, value)
end

#max_size(value = nil) ⇒ Object



168
169
170
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 168

def max_size(value=nil)
  target_constraint(:size, :lte, value, SizeConstraint)
end

#max_trailing(value = nil) ⇒ Object



79
80
81
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 79

def max_trailing(value=nil)
  target_constraint(:trailing, :lte, value)
end

#max_width(value = nil) ⇒ Object



143
144
145
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 143

def max_width(value=nil)
  target_constraint(:width, :lte, value)
end

#max_x(value = nil) ⇒ Object Also known as: max_left



30
31
32
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 30

def max_x(value=nil)
  target_constraint(:left, :lte, value)
end

#max_y(value = nil) ⇒ Object Also known as: max_top



93
94
95
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 93

def max_y(value=nil)
  target_constraint(:top, :lte, value)
end

#min_baseline(value = nil) ⇒ Object



126
127
128
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 126

def min_baseline(value=nil)
  target_constraint(:baseline, :gte, value)
end

#min_bottom(value = nil) ⇒ Object



114
115
116
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 114

def min_bottom(value=nil)
  target_constraint(:bottom, :gte, value)
end

#min_center(value = nil) ⇒ Object



176
177
178
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 176

def min_center(value=nil)
  target_constraint([:center_x, :center_y], :gte, value, PointConstraint)
end

#min_center_x(value = nil) ⇒ Object



51
52
53
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 51

def min_center_x(value=nil)
  target_constraint(:center_x, :gte, value)
end

#min_center_y(value = nil) ⇒ Object



102
103
104
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 102

def min_center_y(value=nil)
  target_constraint(:center_y, :gte, value)
end

#min_height(value = nil) ⇒ Object



152
153
154
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 152

def min_height(value=nil)
  target_constraint(:height, :gte, value)
end

#min_leading(value = nil) ⇒ Object



39
40
41
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 39

def min_leading(value=nil)
  target_constraint(:leading, :gte, value)
end

#min_right(value = nil) ⇒ Object



63
64
65
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 63

def min_right(value=nil)
  target_constraint(:right, :gte, value)
end

#min_size(value = nil) ⇒ Object



164
165
166
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 164

def min_size(value=nil)
  target_constraint(:size, :gte, value, SizeConstraint)
end

#min_trailing(value = nil) ⇒ Object



75
76
77
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 75

def min_trailing(value=nil)
  target_constraint(:trailing, :gte, value)
end

#min_width(value = nil) ⇒ Object



139
140
141
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 139

def min_width(value=nil)
  target_constraint(:width, :gte, value)
end

#min_x(value = nil) ⇒ Object Also known as: min_left



25
26
27
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 25

def min_x(value=nil)
  target_constraint(:left, :gte, value)
end

#min_y(value = nil) ⇒ Object Also known as: min_top



88
89
90
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 88

def min_y(value=nil)
  target_constraint(:top, :gte, value)
end

#nth(name, value) ⇒ Object



16
17
18
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 16

def nth(name, value)
  ConstraintPlaceholder.new(:nth, name, value)
end

#right(value = nil) ⇒ Object



59
60
61
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 59

def right(value=nil)
  target_constraint(:right, :equal, value)
end

#size(value = nil) ⇒ Object



160
161
162
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 160

def size(value=nil)
  target_constraint(:size, :equal, value, SizeConstraint)
end

#top_left(value = nil) ⇒ Object Also known as: origin



184
185
186
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 184

def top_left(value=nil)
  target_constraint([:left, :top], :equal, value, PointConstraint)
end

#top_right(value = nil) ⇒ Object



189
190
191
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 189

def top_right(value=nil)
  target_constraint([:right, :top], :equal, value, PointConstraint)
end

#trailing(value = nil) ⇒ Object



71
72
73
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 71

def trailing(value=nil)
  target_constraint(:trailing, :equal, value)
end

#width(value = nil) ⇒ Object Also known as: w



134
135
136
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 134

def width(value=nil)
  target_constraint(:width, :equal, value)
end

#x(value = nil) ⇒ Object Also known as: left



20
21
22
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 20

def x(value=nil)
  target_constraint(:left, :equal, value)
end

#y(value = nil) ⇒ Object Also known as: top



83
84
85
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 83

def y(value=nil)
  target_constraint(:top, :equal, value)
end