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



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

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



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

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, rel = nil) ⇒ Object



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

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

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



256
257
258
259
260
261
262
# File 'lib/motion-kit-cocoa/constraints/constraints_helpers.rb', line 256

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



248
249
250
251
252
253
254
# File 'lib/motion-kit-cocoa/constraints/constraints_helpers.rb', line 248

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, rel = nil) ⇒ Object



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

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

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



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

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

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



228
229
230
# File 'lib/motion-kit-cocoa/constraints/constraints_helpers.rb', line 228

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

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



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

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

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



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

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

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



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

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

#first(name) ⇒ Object



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

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

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



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

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

#last(name) ⇒ Object



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

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

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



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

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

#max_baseline(value = nil) ⇒ Object



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

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

#max_bottom(value = nil) ⇒ Object



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

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

#max_bottom_left(value = nil) ⇒ Object



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

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

#max_bottom_right(value = nil) ⇒ Object



236
237
238
# File 'lib/motion-kit-cocoa/constraints/constraints_helpers.rb', line 236

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

#max_center(value = nil) ⇒ Object



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

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

#max_center_x(value = nil) ⇒ Object



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

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

#max_center_y(value = nil) ⇒ Object



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

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

#max_height(value = nil) ⇒ Object



161
162
163
# File 'lib/motion-kit-cocoa/constraints/constraints_helpers.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_helpers.rb', line 48

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

#max_right(value = nil) ⇒ Object



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

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

#max_size(value = nil) ⇒ Object



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

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

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



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

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

#max_top_right(value = nil) ⇒ Object



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

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

#max_trailing(value = nil) ⇒ Object



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

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

#max_width(value = nil) ⇒ Object



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

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

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



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

def max_x(value=nil)
  x(value, :lte)
end

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



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

def max_y(value=nil)
  y(value, :lte)
end

#min_baseline(value = nil) ⇒ Object



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

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

#min_bottom(value = nil) ⇒ Object



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

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

#min_bottom_left(value = nil) ⇒ Object



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

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

#min_bottom_right(value = nil) ⇒ Object



232
233
234
# File 'lib/motion-kit-cocoa/constraints/constraints_helpers.rb', line 232

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

#min_center(value = nil) ⇒ Object



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

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

#min_center_x(value = nil) ⇒ Object



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

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

#min_center_y(value = nil) ⇒ Object



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

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

#min_height(value = nil) ⇒ Object



157
158
159
# File 'lib/motion-kit-cocoa/constraints/constraints_helpers.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_helpers.rb', line 44

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

#min_right(value = nil) ⇒ Object



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

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

#min_size(value = nil) ⇒ Object



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

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

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



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

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

#min_top_right(value = nil) ⇒ Object



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

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

#min_trailing(value = nil) ⇒ Object



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

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

#min_width(value = nil) ⇒ Object



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

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

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



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

def min_x(value=nil)
  x(value, :gte)
end

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



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

def min_y(value=nil)
  y(value, :gte)
end

#nth(name, value) ⇒ Object



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

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

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



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

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

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



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

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

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



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

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

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



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

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

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



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

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

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



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

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

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



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

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

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



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

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