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, #objc_version, #retina?, #ruby_version, #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



206
207
208
209
210
211
212
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 206

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

  constraint_target.add_constraints([constraint])
  return constraint
end

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



231
232
233
234
235
236
237
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 231

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

  constraint_target.add_constraints([constraint])
  return constraint
end

#baseline(value = nil) ⇒ Object



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

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

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



222
223
224
225
226
227
228
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 222

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

  constraint_target.add_constraints([constraint])
  return constraint
end

#below(view) ⇒ Object



214
215
216
217
218
219
220
# File 'lib/motion-kit-cocoa/constraints/constraints_layout.rb', line 214

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

  constraint_target.add_constraints([constraint])
  return constraint
end

#bottom(value = nil) ⇒ Object



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

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

#bottom_left(value = nil) ⇒ Object



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

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

#bottom_right(value = nil) ⇒ Object



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

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

#center(value = nil) ⇒ Object



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

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

#center_x(value = nil) ⇒ Object



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

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

#center_y(value = nil) ⇒ Object



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

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

#constraint_target ⇒ Object

A more sensible name for the constraint that is created.



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

def constraint_target
  target
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



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

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

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



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

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



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

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

#leading(value = nil) ⇒ Object



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

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

#max_baseline(value = nil) ⇒ Object



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

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

#max_bottom(value = nil) ⇒ Object



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

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

#max_center(value = nil) ⇒ Object



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

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

#max_center_x(value = nil) ⇒ Object



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

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

#max_center_y(value = nil) ⇒ Object



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

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

#max_height(value = nil) ⇒ Object



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

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

#max_leading(value = nil) ⇒ Object



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

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

#max_right(value = nil) ⇒ Object



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

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

#max_size(value = nil) ⇒ Object



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

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

#max_trailing(value = nil) ⇒ Object



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

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

#max_width(value = nil) ⇒ Object



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

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

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



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

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

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



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

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

#min_baseline(value = nil) ⇒ Object



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

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

#min_bottom(value = nil) ⇒ Object



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

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

#min_center(value = nil) ⇒ Object



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

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

#min_center_x(value = nil) ⇒ Object



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

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

#min_center_y(value = nil) ⇒ Object



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

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

#min_height(value = nil) ⇒ Object



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

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

#min_leading(value = nil) ⇒ Object



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

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

#min_right(value = nil) ⇒ Object



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

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

#min_size(value = nil) ⇒ Object



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

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

#min_trailing(value = nil) ⇒ Object



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

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

#min_width(value = nil) ⇒ Object



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

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

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



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

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

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



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

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

#nth(name, value) ⇒ Object



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

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

#right(value = nil) ⇒ Object



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

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

#size(value = nil) ⇒ Object



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

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

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



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

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

#top_right(value = nil) ⇒ Object



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

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

#trailing(value = nil) ⇒ Object



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

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

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



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

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

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



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

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

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



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

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