Class: MotionKit::ConstraintsHelpers

Inherits:
BaseLayout show all
Defined in:
lib/motion-kit-cocoa/constraints/constraints_helpers.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, #has_context?, #initialize, #ipad?, #iphone35?, #iphone4?, #iphone?, #is_parent_layout?, #method_missing, #objc_version, #orientation?, #parent_layout, #retina?, #ruby_version, #run_deferred, #set_parent_layout, #target, #v

Methods included from BaseLayoutClassMethods

#layout_for, #memoize, #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



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

def above(view)
  unless view
    raise ArgumentError.new("`#{view.inspect}` is not a valid target for making a `above` constraint.")
  end
  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



262
263
264
265
266
267
268
269
270
271
# File 'lib/motion-kit-cocoa/constraints/constraints_helpers.rb', line 262

def after(view)
  unless view
    raise ArgumentError.new("`#{view.inspect}` is not a valid target for making a `after` constraint.")
  end
  constraint = Constraint.new(constraint_target.view, :left, :equal)
  constraint.equals(view, :right)

  constraint_target.add_constraints([constraint])
  return constraint
end

#baseline(value = nil, rel = nil) ⇒ Object



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

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

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



250
251
252
253
254
255
256
257
258
259
# File 'lib/motion-kit-cocoa/constraints/constraints_helpers.rb', line 250

def before(view)
  unless view
    raise ArgumentError.new("`#{view.inspect}` is not a valid target for making a `before` constraint.")
  end
  constraint = Constraint.new(constraint_target.view, :right, :equal)
  constraint.equals(view, :left)

  constraint_target.add_constraints([constraint])
  return constraint
end

#below(view) ⇒ Object



239
240
241
242
243
244
245
246
247
248
# File 'lib/motion-kit-cocoa/constraints/constraints_helpers.rb', line 239

def below(view)
  unless view
    raise ArgumentError.new("`#{view.inspect}` is not a valid target for making a `below` constraint.")
  end
  constraint = Constraint.new(constraint_target.view, :top, :equal)
  constraint.equals(view, :bottom)

  constraint_target.add_constraints([constraint])
  return constraint
end

#bottom(value = nil, rel = nil) ⇒ Object



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

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

#bottom_left(value = nil, rel = nil) ⇒ Object



204
205
206
# File 'lib/motion-kit-cocoa/constraints/constraints_helpers.rb', line 204

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

#bottom_right(value = nil, rel = nil) ⇒ Object



216
217
218
# File 'lib/motion-kit-cocoa/constraints/constraints_helpers.rb', line 216

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

#center(value = nil, rel = nil) ⇒ Object



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

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

#center_x(value = nil, rel = nil) ⇒ Object



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

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

#center_y(value = nil, rel = nil) ⇒ Object



91
92
93
# File 'lib/motion-kit-cocoa/constraints/constraints_helpers.rb', line 91

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

#constraint_targetObject

A more sensible name for the constraint that is created.



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

def constraint_target
  target
end

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



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

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

#leading(value = nil, rel = nil) ⇒ Object



28
29
30
# File 'lib/motion-kit-cocoa/constraints/constraints_helpers.rb', line 28

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

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



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

def left(value=nil, rel=nil)
  target_constraint(:left, rel, value)
end

#max_baseline(value = nil) ⇒ Object



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

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

#max_bottom(value = nil) ⇒ Object



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

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

#max_bottom_left(value = nil) ⇒ Object



212
213
214
# File 'lib/motion-kit-cocoa/constraints/constraints_helpers.rb', line 212

def max_bottom_left(value=nil)
  bottom_left(value, :lte)
end

#max_bottom_right(value = nil) ⇒ Object



224
225
226
# File 'lib/motion-kit-cocoa/constraints/constraints_helpers.rb', line 224

def max_bottom_right(value=nil)
  bottom_right(value, :lte)
end

#max_center(value = nil) ⇒ Object



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

def max_center(value=nil)
  center(value, :lte)
end

#max_center_x(value = nil) ⇒ Object



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

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

#max_center_y(value = nil) ⇒ Object



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

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

#max_height(value = nil) ⇒ Object



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

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

#max_leading(value = nil) ⇒ Object



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

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

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



23
24
25
# File 'lib/motion-kit-cocoa/constraints/constraints_helpers.rb', line 23

def max_left(value=nil)
  left(value, :lte)
end

#max_right(value = nil) ⇒ Object



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

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

#max_size(value = nil) ⇒ Object



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

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

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



86
87
88
# File 'lib/motion-kit-cocoa/constraints/constraints_helpers.rb', line 86

def max_top(value=nil)
  top(value, :lte)
end

#max_top_left(value = nil) ⇒ Object Also known as: max_origin



187
188
189
# File 'lib/motion-kit-cocoa/constraints/constraints_helpers.rb', line 187

def max_top_left(value=nil)
  top_left(value, :lte)
end

#max_top_right(value = nil) ⇒ Object



200
201
202
# File 'lib/motion-kit-cocoa/constraints/constraints_helpers.rb', line 200

def max_top_right(value=nil)
  top_right(value, :lte)
end

#max_trailing(value = nil) ⇒ Object



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

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

#max_width(value = nil) ⇒ Object



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

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

#min_baseline(value = nil) ⇒ Object



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

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

#min_bottom(value = nil) ⇒ Object



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

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

#min_bottom_left(value = nil) ⇒ Object



208
209
210
# File 'lib/motion-kit-cocoa/constraints/constraints_helpers.rb', line 208

def min_bottom_left(value=nil)
  bottom_left(value, :gte)
end

#min_bottom_right(value = nil) ⇒ Object



220
221
222
# File 'lib/motion-kit-cocoa/constraints/constraints_helpers.rb', line 220

def min_bottom_right(value=nil)
  bottom_right(value, :gte)
end

#min_center(value = nil) ⇒ Object



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

def min_center(value=nil)
  center(value, :gte)
end

#min_center_x(value = nil) ⇒ Object



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

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

#min_center_y(value = nil) ⇒ Object



95
96
97
# File 'lib/motion-kit-cocoa/constraints/constraints_helpers.rb', line 95

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

#min_height(value = nil) ⇒ Object



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

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

#min_leading(value = nil) ⇒ Object



32
33
34
# File 'lib/motion-kit-cocoa/constraints/constraints_helpers.rb', line 32

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

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



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

def min_left(value=nil)
  left(value, :gte)
end

#min_right(value = nil) ⇒ Object



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

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

#min_size(value = nil) ⇒ Object



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

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

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



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

def min_top(value=nil)
  top(value, :gte)
end

#min_top_left(value = nil) ⇒ Object Also known as: min_origin



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

def min_top_left(value=nil)
  top_left(value, :gte)
end

#min_top_right(value = nil) ⇒ Object



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

def min_top_right(value=nil)
  top_right(value, :gte)
end

#min_trailing(value = nil) ⇒ Object



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

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

#min_width(value = nil) ⇒ Object



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

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

#right(value = nil, rel = nil) ⇒ Object



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

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

#size(value = nil, rel = nil) ⇒ Object



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

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

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



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

def top(value=nil, rel=nil)
  target_constraint(:top, rel, value)
end

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



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

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

#top_right(value = nil, rel = nil) ⇒ Object



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

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

#trailing(value = nil, rel = nil) ⇒ Object



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

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

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



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

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