motion-kit 0.0.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +839 -0
- data/lib/motion-kit-cocoa/cocoa_util.rb +59 -0
- data/lib/motion-kit-cocoa/constraints/constraint.rb +765 -0
- data/lib/motion-kit-cocoa/constraints/constraint_placeholder.rb +22 -0
- data/lib/motion-kit-cocoa/constraints/constraints_layout.rb +536 -0
- data/lib/motion-kit-cocoa/constraints/constraints_target.rb +52 -0
- data/lib/motion-kit-cocoa/layouts/cagradientlayer_layout.rb +13 -0
- data/lib/motion-kit-cocoa/layouts/calayer_layout.rb +27 -0
- data/lib/motion-kit-cocoa/layouts/sugarcube_compat.rb +38 -0
- data/lib/motion-kit-ios/dummy.rb +93 -0
- data/lib/motion-kit-ios/ios_util.rb +20 -0
- data/lib/motion-kit-ios/layouts/constraints_layout.rb +22 -0
- data/lib/motion-kit-ios/layouts/layout_device.rb +32 -0
- data/lib/motion-kit-ios/layouts/layout_orientation.rb +47 -0
- data/lib/motion-kit-ios/layouts/uibutton_layout.rb +52 -0
- data/lib/motion-kit-ios/layouts/uiview_layout.rb +45 -0
- data/lib/motion-kit-ios/layouts/uiview_layout_autoresizing.rb +75 -0
- data/lib/motion-kit-ios/layouts/uiview_layout_constraints.rb +36 -0
- data/lib/motion-kit-ios/layouts/uiview_layout_frame.rb +307 -0
- data/lib/motion-kit-ios/layouts/uiview_layout_gradient.rb +20 -0
- data/lib/motion-kit-osx/dummy.rb +89 -0
- data/lib/motion-kit-osx/layouts/constraints_layout.rb +42 -0
- data/lib/motion-kit-osx/layouts/nsmenu_extensions.rb +186 -0
- data/lib/motion-kit-osx/layouts/nsmenu_layout.rb +109 -0
- data/lib/motion-kit-osx/layouts/nsmenuitem_extensions.rb +45 -0
- data/lib/motion-kit-osx/layouts/nstablecolumn_layout.rb +12 -0
- data/lib/motion-kit-osx/layouts/nstableview_layout.rb +20 -0
- data/lib/motion-kit-osx/layouts/nsview_layout.rb +47 -0
- data/lib/motion-kit-osx/layouts/nsview_layout_autoresizing.rb +75 -0
- data/lib/motion-kit-osx/layouts/nsview_layout_constraints.rb +34 -0
- data/lib/motion-kit-osx/layouts/nsview_layout_frame.rb +375 -0
- data/lib/motion-kit-osx/layouts/nswindow_frame.rb +14 -0
- data/lib/motion-kit-osx/layouts/nswindow_layout.rb +77 -0
- data/lib/motion-kit-osx/osx_util.rb +16 -0
- data/lib/motion-kit.rb +33 -0
- data/lib/motion-kit/calculate.rb +263 -0
- data/lib/motion-kit/layouts/base_layout.rb +299 -0
- data/lib/motion-kit/layouts/base_layout_class_methods.rb +43 -0
- data/lib/motion-kit/layouts/parent.rb +68 -0
- data/lib/motion-kit/layouts/view_layout.rb +327 -0
- data/lib/motion-kit/motion-kit.rb +18 -0
- data/lib/motion-kit/object.rb +16 -0
- data/lib/motion-kit/util.rb +20 -0
- data/lib/motion-kit/version.rb +1 -1
- data/spec/ios/apply_styles_spec.rb +21 -0
- data/spec/ios/autoresizing_helper_spec.rb +224 -0
- data/spec/ios/calculate_spec.rb +322 -0
- data/spec/ios/calculator_spec.rb +31 -0
- data/spec/ios/constraints_helpers/attribute_lookup_spec.rb +27 -0
- data/spec/ios/constraints_helpers/axis_lookup_spec.rb +13 -0
- data/spec/ios/constraints_helpers/center_constraints_spec.rb +419 -0
- data/spec/ios/constraints_helpers/constraint_placeholder_spec.rb +72 -0
- data/spec/ios/constraints_helpers/priority_lookup_spec.rb +19 -0
- data/spec/ios/constraints_helpers/relationship_lookup_spec.rb +27 -0
- data/spec/ios/constraints_helpers/relative_corners_spec.rb +274 -0
- data/spec/ios/constraints_helpers/relative_location_spec.rb +111 -0
- data/spec/ios/constraints_helpers/simple_constraints_spec.rb +2763 -0
- data/spec/ios/constraints_helpers/size_constraints_spec.rb +422 -0
- data/spec/ios/constraints_helpers/view_lookup_constraints_spec.rb +93 -0
- data/spec/ios/create_layout_spec.rb +40 -0
- data/spec/ios/custom_layout_spec.rb +13 -0
- data/spec/ios/deferred_spec.rb +89 -0
- data/spec/ios/device_helpers_spec.rb +51 -0
- data/spec/ios/frame_helper_spec.rb +1150 -0
- data/spec/ios/layer_layout_spec.rb +36 -0
- data/spec/ios/layout_extensions_spec.rb +70 -0
- data/spec/ios/layout_spec.rb +74 -0
- data/spec/ios/layout_state_spec.rb +27 -0
- data/spec/ios/motionkit_util_spec.rb +102 -0
- data/spec/ios/objc_selectors_spec.rb +10 -0
- data/spec/ios/orientation_helper_specs.rb +67 -0
- data/spec/ios/parent_layout_spec.rb +19 -0
- data/spec/ios/parent_spec.rb +45 -0
- data/spec/ios/remove_layout_spec.rb +25 -0
- data/spec/ios/root_layout_spec.rb +53 -0
- data/spec/ios/setters_spec.rb +63 -0
- data/spec/ios/uibutton_layout_spec.rb +24 -0
- data/spec/ios/uitextfield_spec.rb +14 -0
- data/spec/ios/view_attr_spec.rb +25 -0
- data/spec/osx/autoresizing_helper_spec.rb +224 -0
- data/spec/osx/constraints_helper_spec.rb +0 -0
- data/spec/osx/constraints_helpers/orientation_lookup_spec.rb +13 -0
- data/spec/osx/constraints_helpers/simple_constraints_spec.rb +2095 -0
- data/spec/osx/constraints_helpers/size_constraints_spec.rb +362 -0
- data/spec/osx/create_menu_spec.rb +14 -0
- data/spec/osx/create_via_extensions_spec.rb +63 -0
- data/spec/osx/deferred_spec.rb +85 -0
- data/spec/osx/frame_helper_spec.rb +1881 -0
- data/spec/osx/menu_extensions_spec.rb +376 -0
- data/spec/osx/menu_layout_spec.rb +157 -0
- data/spec/osx/menu_spec.rb +70 -0
- data/spec/osx/root_menu_spec.rb +15 -0
- metadata +166 -14
@@ -0,0 +1,1881 @@
|
|
1
|
+
class UpsideDownView < NSView
|
2
|
+
|
3
|
+
def isFlipped
|
4
|
+
true
|
5
|
+
end
|
6
|
+
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
describe 'Frame helpers' do
|
11
|
+
|
12
|
+
before do
|
13
|
+
@layout = TestEmptyLayout.new
|
14
|
+
top_view = NSView.alloc.initWithFrame([[0, 0], [500, 500]])
|
15
|
+
@layout.root = top_view
|
16
|
+
|
17
|
+
@view_size = CGSize.new(8, 10)
|
18
|
+
@view = NSView.alloc.initWithFrame([[0, 0], @view_size])
|
19
|
+
@view.backgroundColor = NSColor.whiteColor
|
20
|
+
@view.motion_kit_id = :view
|
21
|
+
|
22
|
+
@superview_size = CGSize.new(60, 40)
|
23
|
+
@superview = NSView.alloc.initWithFrame([[0, 0], @superview_size])
|
24
|
+
@superview.addSubview(@view)
|
25
|
+
@superview.backgroundColor = NSColor.blueColor
|
26
|
+
|
27
|
+
@flipped_superview = UpsideDownView.alloc.initWithFrame([[0, @superview_size.height], @superview_size])
|
28
|
+
@flipped_superview.backgroundColor = NSColor.whiteColor
|
29
|
+
|
30
|
+
@flipped_view = NSView.alloc.initWithFrame([[0, 0], @view_size])
|
31
|
+
@flipped_superview.addSubview(@flipped_view)
|
32
|
+
|
33
|
+
@another_view = NSView.alloc.initWithFrame([[10, 100], [120, 48]])
|
34
|
+
@another_view.backgroundColor = NSColor.redColor
|
35
|
+
@another_view.motion_kit_id = :another_view
|
36
|
+
|
37
|
+
top_view.addSubview(@another_view)
|
38
|
+
top_view.addSubview(@superview)
|
39
|
+
top_view.addSubview(@flipped_superview)
|
40
|
+
|
41
|
+
@label = NSTextField.alloc.init
|
42
|
+
@label.stringValue = 'M'
|
43
|
+
|
44
|
+
@label.editable = false
|
45
|
+
@label.selectable = false
|
46
|
+
@label.bordered = false
|
47
|
+
@label.font = NSFont.fontWithName('Monaco', size: 12)
|
48
|
+
|
49
|
+
cell = @label.cell
|
50
|
+
cell.alignment = NSCenterTextAlignment
|
51
|
+
cell.scrollable = false
|
52
|
+
cell.drawsBackground = false
|
53
|
+
|
54
|
+
@label_auto_size = @label.intrinsicContentSize
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should support `x` method' do
|
58
|
+
@layout.context(@view) do
|
59
|
+
retval = @layout.x 1
|
60
|
+
retval.should == CGRectGetMinX(@view.frame)
|
61
|
+
@view.frame.origin.x.should == 1
|
62
|
+
|
63
|
+
retval = @layout.x '100% - 1'
|
64
|
+
retval.should == CGRectGetMinX(@view.frame)
|
65
|
+
@view.frame.origin.x.should == @superview_size.width - 1
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should support `left` method' do
|
70
|
+
@layout.context(@view) do
|
71
|
+
retval = @layout.left 1
|
72
|
+
retval.should == CGRectGetMinX(@view.frame)
|
73
|
+
@view.frame.origin.x.should == 1
|
74
|
+
|
75
|
+
retval = @layout.left '100% - 1'
|
76
|
+
retval.should == CGRectGetMinX(@view.frame)
|
77
|
+
@view.frame.origin.x.should == @superview_size.width - 1
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should support `right` method' do
|
82
|
+
@layout.context(@view) do
|
83
|
+
retval = @layout.right 1
|
84
|
+
retval.should == CGRectGetMaxX(@view.frame)
|
85
|
+
@view.frame.origin.x.should == 1 - @view_size.width
|
86
|
+
|
87
|
+
retval = @layout.right '100% - 1'
|
88
|
+
retval.should == CGRectGetMaxX(@view.frame)
|
89
|
+
@view.frame.origin.x.should == @superview_size.width - 1 - @view_size.width
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'should support `center_x` method' do
|
94
|
+
@view.frame = [[0, 0], [2, 2]]
|
95
|
+
@layout.context(@view) do
|
96
|
+
retval = @layout.center_x 1
|
97
|
+
retval.should == CGRectGetMidX(@view.frame)
|
98
|
+
@view.frame.origin.x.should == 0
|
99
|
+
|
100
|
+
retval = @layout.center_x '100% - 1'
|
101
|
+
retval.should == CGRectGetMidX(@view.frame)
|
102
|
+
@view.frame.origin.x.should == @superview_size.width - 2
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'should support `middle_x` method' do
|
107
|
+
@view.frame = [[0, 0], [2, 2]]
|
108
|
+
@layout.context(@view) do
|
109
|
+
retval = @layout.middle_x 1
|
110
|
+
retval.should == CGRectGetMidX(@view.frame)
|
111
|
+
@view.frame.origin.x.should == 0
|
112
|
+
|
113
|
+
retval = @layout.middle_x '100% - 1'
|
114
|
+
retval.should == CGRectGetMidX(@view.frame)
|
115
|
+
@view.frame.origin.x.should == @superview_size.width - 2
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'should support `y` method' do
|
120
|
+
@layout.context(@view) do
|
121
|
+
retval = @layout.y 1
|
122
|
+
retval.should == CGRectGetMinY(@view.frame)
|
123
|
+
@view.frame.origin.y.should == 1
|
124
|
+
|
125
|
+
retval = @layout.y '100% - 1'
|
126
|
+
retval.should == CGRectGetMinY(@view.frame)
|
127
|
+
@view.frame.origin.y.should == @superview_size.height - 1
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'should support `y` method in a flipped view' do
|
132
|
+
@layout.context(@flipped_view) do
|
133
|
+
retval = @layout.y 1
|
134
|
+
retval.should == CGRectGetMinY(@flipped_view.frame)
|
135
|
+
@flipped_view.frame.origin.y.should == 1
|
136
|
+
|
137
|
+
retval = @layout.y '100% - 1'
|
138
|
+
retval.should == CGRectGetMinY(@flipped_view.frame)
|
139
|
+
@flipped_view.frame.origin.y.should == @superview_size.height - 1
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'should support `bottom` method' do
|
144
|
+
@layout.context(@view) do
|
145
|
+
retval = @layout.bottom 1
|
146
|
+
retval.should == CGRectGetMinY(@view.frame)
|
147
|
+
@view.frame.origin.y.should == 1
|
148
|
+
|
149
|
+
retval = @layout.bottom '100% - 1'
|
150
|
+
retval.should == CGRectGetMinY(@view.frame)
|
151
|
+
@view.frame.origin.y.should == @superview_size.height - 1
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'should support `bottom` method in a flipped view' do
|
156
|
+
@layout.context(@flipped_view) do
|
157
|
+
retval = @layout.bottom 1
|
158
|
+
retval.should == CGRectGetMaxY(@flipped_view.frame)
|
159
|
+
@flipped_view.frame.origin.y.should == 1 - @view_size.height
|
160
|
+
|
161
|
+
retval = @layout.bottom '100% - 1'
|
162
|
+
retval.should == CGRectGetMaxY(@flipped_view.frame)
|
163
|
+
@flipped_view.frame.origin.y.should == @superview_size.height - 1 - @view_size.height
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'should support `top` method' do
|
168
|
+
@layout.context(@view) do
|
169
|
+
retval = @layout.top 1
|
170
|
+
retval.should == CGRectGetMaxY(@view.frame)
|
171
|
+
@view.frame.origin.y.should == 1 - @view_size.height
|
172
|
+
|
173
|
+
retval = @layout.top '100% - 1'
|
174
|
+
retval.should == CGRectGetMaxY(@view.frame)
|
175
|
+
@view.frame.origin.y.should == @superview_size.height - 1 - @view_size.height
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
it 'should support `top` method in a flipped view' do
|
180
|
+
@layout.context(@flipped_view) do
|
181
|
+
retval = @layout.top 1
|
182
|
+
retval.should == CGRectGetMinY(@flipped_view.frame)
|
183
|
+
@flipped_view.frame.origin.y.should == 1
|
184
|
+
|
185
|
+
retval = @layout.top '100% - 1'
|
186
|
+
retval.should == CGRectGetMinY(@flipped_view.frame)
|
187
|
+
@flipped_view.frame.origin.y.should == @superview_size.height - 1
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
it 'should support `center_y` method' do
|
192
|
+
@view.frame = [[0, 0], [2, 2]]
|
193
|
+
@layout.context(@view) do
|
194
|
+
retval = @layout.center_y 1
|
195
|
+
retval.should == CGRectGetMidY(@view.frame)
|
196
|
+
@view.frame.origin.y.should == 0
|
197
|
+
|
198
|
+
retval = @layout.center_y '100% - 1'
|
199
|
+
retval.should == CGRectGetMidY(@view.frame)
|
200
|
+
@view.frame.origin.y.should == @superview_size.height - 2
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
it 'should support `center_y` method in a flipped view' do
|
205
|
+
@flipped_view.frame = [[0, 0], [2, 2]]
|
206
|
+
@layout.context(@flipped_view) do
|
207
|
+
retval = @layout.center_y 1
|
208
|
+
retval.should == CGRectGetMidY(@flipped_view.frame)
|
209
|
+
@flipped_view.frame.origin.y.should == 0
|
210
|
+
|
211
|
+
retval = @layout.center_y '100% - 1'
|
212
|
+
retval.should == CGRectGetMidY(@flipped_view.frame)
|
213
|
+
@flipped_view.frame.origin.y.should == @superview_size.height - 2
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
it 'should support `middle_y` method' do
|
218
|
+
@view.frame = [[0, 0], [2, 2]]
|
219
|
+
@layout.context(@view) do
|
220
|
+
retval = @layout.middle_y 1
|
221
|
+
retval.should == CGRectGetMidY(@view.frame)
|
222
|
+
@view.frame.origin.y.should == 0
|
223
|
+
|
224
|
+
retval = @layout.middle_y '100% - 1'
|
225
|
+
retval.should == CGRectGetMidY(@view.frame)
|
226
|
+
@view.frame.origin.y.should == @superview_size.height - 2
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
it 'should support `width` method' do
|
231
|
+
@layout.context(@view) do
|
232
|
+
retval = @layout.width 1
|
233
|
+
retval.should == CGRectGetWidth(@view.frame)
|
234
|
+
@view.frame.size.width.should == 1
|
235
|
+
|
236
|
+
retval = @layout.width '100% - 1'
|
237
|
+
retval.should == CGRectGetWidth(@view.frame)
|
238
|
+
@view.frame.size.width.should == @superview_size.width - 1
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
it 'should support `w` method' do
|
243
|
+
@layout.context(@view) do
|
244
|
+
retval = @layout.w 1
|
245
|
+
retval.should == CGRectGetWidth(@view.frame)
|
246
|
+
@view.frame.size.width.should == 1
|
247
|
+
|
248
|
+
retval = @layout.w '100% - 1'
|
249
|
+
retval.should == CGRectGetWidth(@view.frame)
|
250
|
+
@view.frame.size.width.should == @superview_size.width - 1
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
it 'should support `height` method' do
|
255
|
+
@layout.context(@view) do
|
256
|
+
retval = @layout.height 1
|
257
|
+
retval.should == CGRectGetHeight(@view.frame)
|
258
|
+
@view.frame.size.height.should == 1
|
259
|
+
|
260
|
+
retval = @layout.height '100% - 1'
|
261
|
+
retval.should == CGRectGetHeight(@view.frame)
|
262
|
+
@view.frame.size.height.should == @superview_size.height - 1
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
it 'should support `h` method' do
|
267
|
+
@layout.context(@view) do
|
268
|
+
retval = @layout.h 1
|
269
|
+
retval.should == CGRectGetHeight(@view.frame)
|
270
|
+
@view.frame.size.height.should == 1
|
271
|
+
|
272
|
+
retval = @layout.h '100% - 1'
|
273
|
+
retval.should == CGRectGetHeight(@view.frame)
|
274
|
+
@view.frame.size.height.should == @superview_size.height - 1
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
it 'should support `origin([])` method' do
|
279
|
+
@layout.context(@view) do
|
280
|
+
retval = @layout.origin [1, 2]
|
281
|
+
retval.should == @view.frame.origin
|
282
|
+
@view.frame.origin.x.should == 1
|
283
|
+
@view.frame.origin.y.should == 2
|
284
|
+
|
285
|
+
retval = @layout.origin ['100% - 1', '100% - 2']
|
286
|
+
retval.should == @view.frame.origin
|
287
|
+
@view.frame.origin.x.should == @superview_size.width - 1
|
288
|
+
@view.frame.origin.y.should == @superview_size.height - 2
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
it 'should support `origin([])` method in a flipped view' do
|
293
|
+
@layout.context(@flipped_view) do
|
294
|
+
retval = @layout.origin [1, 2]
|
295
|
+
retval.should == @flipped_view.frame.origin
|
296
|
+
@flipped_view.frame.origin.x.should == 1
|
297
|
+
@flipped_view.frame.origin.y.should == 2
|
298
|
+
|
299
|
+
retval = @layout.origin ['100% - 1', '100% - 2']
|
300
|
+
retval.should == @flipped_view.frame.origin
|
301
|
+
@flipped_view.frame.origin.x.should == @superview_size.width - 1
|
302
|
+
@flipped_view.frame.origin.y.should == @superview_size.height - 2
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
it 'should support `origin({})` method' do
|
307
|
+
@layout.context(@view) do
|
308
|
+
retval = @layout.origin x: 1, y: 2
|
309
|
+
retval.should == @view.frame.origin
|
310
|
+
@view.frame.origin.x.should == 1
|
311
|
+
@view.frame.origin.y.should == 2
|
312
|
+
|
313
|
+
retval = @layout.origin x: '100% - 1', y: '100% - 2'
|
314
|
+
retval.should == @view.frame.origin
|
315
|
+
@view.frame.origin.x.should == @superview_size.width - 1
|
316
|
+
@view.frame.origin.y.should == @superview_size.height - 2
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
320
|
+
it 'should support `origin({relative: true})` method' do
|
321
|
+
@layout.context(@view) do
|
322
|
+
retval = @layout.origin x: 0, y: 0, right: 1, up: 2, relative: true
|
323
|
+
retval.should == @view.frame.origin
|
324
|
+
@view.frame.origin.x.should == 1
|
325
|
+
@view.frame.origin.y.should == 2
|
326
|
+
|
327
|
+
retval = @layout.origin x: '100%', y: '100%', left: 1, down: 2, relative: true
|
328
|
+
retval.should == @view.frame.origin
|
329
|
+
@view.frame.origin.x.should == @superview_size.width - 1
|
330
|
+
@view.frame.origin.y.should == @superview_size.height - 2
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
it 'should support `origin({relative: true})` method in a flipped view' do
|
335
|
+
@layout.context(@flipped_view) do
|
336
|
+
retval = @layout.origin x: 0, y: 0, right: 1, down: 2, relative: true
|
337
|
+
retval.should == @flipped_view.frame.origin
|
338
|
+
@flipped_view.frame.origin.x.should == 1
|
339
|
+
@flipped_view.frame.origin.y.should == 2
|
340
|
+
|
341
|
+
retval = @layout.origin x: '100%', y: '100%', left: 1, up: 2, relative: true
|
342
|
+
retval.should == @flipped_view.frame.origin
|
343
|
+
@flipped_view.frame.origin.x.should == @superview_size.width - 1
|
344
|
+
@flipped_view.frame.origin.y.should == @superview_size.height - 2
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
348
|
+
it 'should support `center([])` method' do
|
349
|
+
@view.frame = [[0, 0], [2, 2]]
|
350
|
+
@layout.context(@view) do
|
351
|
+
retval = @layout.center [1, 2]
|
352
|
+
retval.x.should == @view.frame.origin.x + @view.frame.size.width / 2
|
353
|
+
retval.y.should == @view.frame.origin.y + @view.frame.size.height / 2
|
354
|
+
@view.frame.origin.x.should == 0
|
355
|
+
@view.frame.origin.y.should == 1
|
356
|
+
|
357
|
+
retval = @layout.center ['100% - 1', '100% - 2']
|
358
|
+
retval.x.should == @view.frame.origin.x + @view.frame.size.width / 2
|
359
|
+
retval.y.should == @view.frame.origin.y + @view.frame.size.height / 2
|
360
|
+
@view.frame.origin.x.should == @superview_size.width - 2
|
361
|
+
@view.frame.origin.y.should == @superview_size.height - 3
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
365
|
+
it 'should support `center({})` method' do
|
366
|
+
@view.frame = [[0, 0], [2, 2]]
|
367
|
+
@layout.context(@view) do
|
368
|
+
retval = @layout.center x: 1, y: 2
|
369
|
+
retval.x.should == @view.frame.origin.x + @view.frame.size.width / 2
|
370
|
+
retval.y.should == @view.frame.origin.y + @view.frame.size.height / 2
|
371
|
+
@view.frame.origin.x.should == 0
|
372
|
+
@view.frame.origin.y.should == 1
|
373
|
+
|
374
|
+
retval = @layout.center x: '100% - 1', y: '100% - 2'
|
375
|
+
retval.x.should == @view.frame.origin.x + @view.frame.size.width / 2
|
376
|
+
retval.y.should == @view.frame.origin.y + @view.frame.size.height / 2
|
377
|
+
@view.frame.origin.x.should == @superview_size.width - 2
|
378
|
+
@view.frame.origin.y.should == @superview_size.height - 3
|
379
|
+
end
|
380
|
+
end
|
381
|
+
|
382
|
+
it 'should support `center({relative: true})` method' do
|
383
|
+
@view.frame = [[0, 0], [2, 2]]
|
384
|
+
@layout.context(@view) do
|
385
|
+
retval = @layout.center x: 1, y: 1, right: 1, up: 2, relative: true
|
386
|
+
retval.x.should == @view.frame.origin.x + @view.frame.size.width / 2
|
387
|
+
retval.y.should == @view.frame.origin.y + @view.frame.size.height / 2
|
388
|
+
@view.frame.origin.x.should == 1
|
389
|
+
@view.frame.origin.y.should == 2
|
390
|
+
|
391
|
+
retval = @layout.center x: '100%', y: '100%', left: 1, down: 2, relative: true
|
392
|
+
retval.x.should == @view.frame.origin.x + @view.frame.size.width / 2
|
393
|
+
retval.y.should == @view.frame.origin.y + @view.frame.size.height / 2
|
394
|
+
@view.frame.origin.x.should == @superview_size.width - 2
|
395
|
+
@view.frame.origin.y.should == @superview_size.height - 3
|
396
|
+
end
|
397
|
+
end
|
398
|
+
|
399
|
+
it 'should support `center({relative: true})` method in a flipped view' do
|
400
|
+
@flipped_view.frame = [[0, 0], [2, 2]]
|
401
|
+
@layout.context(@flipped_view) do
|
402
|
+
retval = @layout.center x: 1, y: 1, right: 1, down: 2, relative: true
|
403
|
+
retval.x.should == @flipped_view.frame.origin.x + @flipped_view.frame.size.width / 2
|
404
|
+
retval.y.should == @flipped_view.frame.origin.y + @flipped_view.frame.size.height / 2
|
405
|
+
@flipped_view.frame.origin.x.should == 1
|
406
|
+
@flipped_view.frame.origin.y.should == 2
|
407
|
+
|
408
|
+
retval = @layout.center x: '100%', y: '100%', left: 1, up: 2, relative: true
|
409
|
+
retval.x.should == @flipped_view.frame.origin.x + @flipped_view.frame.size.width / 2
|
410
|
+
retval.y.should == @flipped_view.frame.origin.y + @flipped_view.frame.size.height / 2
|
411
|
+
@flipped_view.frame.origin.x.should == @superview_size.width - 2
|
412
|
+
@flipped_view.frame.origin.y.should == @superview_size.height - 3
|
413
|
+
end
|
414
|
+
end
|
415
|
+
|
416
|
+
it 'should support `size` method' do
|
417
|
+
@layout.context(@view) do
|
418
|
+
retval = @layout.size [1, 2]
|
419
|
+
retval.should == @view.frame.size
|
420
|
+
@view.frame.size.width.should == 1
|
421
|
+
@view.frame.size.height.should == 2
|
422
|
+
|
423
|
+
retval = @layout.size ['100% - 1', '100% - 2']
|
424
|
+
retval.should == @view.frame.size
|
425
|
+
@view.frame.size.width.should == @superview_size.width - 1
|
426
|
+
@view.frame.size.height.should == @superview_size.height - 2
|
427
|
+
end
|
428
|
+
end
|
429
|
+
|
430
|
+
it 'should support `size :full`' do
|
431
|
+
@layout.context(@view) do
|
432
|
+
retval = @layout.size :full
|
433
|
+
retval.should == @view.frame.size
|
434
|
+
end
|
435
|
+
@view.frame.size.width.should == @superview_size.width
|
436
|
+
@view.frame.size.height.should == @superview_size.height
|
437
|
+
end
|
438
|
+
|
439
|
+
it 'should support `size :auto`' do
|
440
|
+
@layout.context(@label) do
|
441
|
+
retval = @layout.size :auto
|
442
|
+
retval.should == @label.frame.size
|
443
|
+
end
|
444
|
+
@label.frame.size.width.should == @label_auto_size.width
|
445
|
+
@label.frame.size.height.should == @label_auto_size.height
|
446
|
+
end
|
447
|
+
|
448
|
+
it 'should support `size :auto, height`' do
|
449
|
+
@layout.context(@label) do
|
450
|
+
retval = @layout.size [:auto, @label_auto_size.height]
|
451
|
+
retval.should == @label.frame.size
|
452
|
+
end
|
453
|
+
@label.frame.size.width.should == @label_auto_size.width
|
454
|
+
@label.frame.size.height.should == @label_auto_size.height
|
455
|
+
end
|
456
|
+
|
457
|
+
it 'should support `size width, :auto`' do
|
458
|
+
@layout.context(@label) do
|
459
|
+
retval = @layout.size [@label_auto_size.width, :auto]
|
460
|
+
retval.should == @label.frame.size
|
461
|
+
end
|
462
|
+
@label.frame.size.width.should == @label_auto_size.width
|
463
|
+
@label.frame.size.height.should == @label_auto_size.height
|
464
|
+
end
|
465
|
+
|
466
|
+
it 'should support `size :scale, height`' do
|
467
|
+
@layout.context(@label) do
|
468
|
+
retval = @layout.size [100 * @label_auto_size.width, :scale]
|
469
|
+
retval.should == @label.frame.size
|
470
|
+
end
|
471
|
+
@label.frame.size.width.should == 100 * @label_auto_size.width
|
472
|
+
@label.frame.size.height.should == 100 * @label_auto_size.height
|
473
|
+
end
|
474
|
+
|
475
|
+
it 'should support `size width, :scale`' do
|
476
|
+
@layout.context(@label) do
|
477
|
+
retval = @layout.size [:scale, 100 * @label_auto_size.height]
|
478
|
+
retval.should == @label.frame.size
|
479
|
+
end
|
480
|
+
@label.frame.size.width.should == 100 * @label_auto_size.width
|
481
|
+
@label.frame.size.height.should == 100 * @label_auto_size.height
|
482
|
+
end
|
483
|
+
|
484
|
+
it 'should support `frame` arrays [[x, y], [w, h]]' do
|
485
|
+
@layout.context(@view) do
|
486
|
+
retval = @layout.frame [[1, 2], [3, 4]]
|
487
|
+
retval.should == @view.frame
|
488
|
+
end
|
489
|
+
@view.frame.origin.x.should == 1
|
490
|
+
@view.frame.origin.y.should == 2
|
491
|
+
@view.frame.size.width.should == 3
|
492
|
+
@view.frame.size.height.should == 4
|
493
|
+
end
|
494
|
+
|
495
|
+
it 'should support `frame` arrays [x, y, w, h]' do
|
496
|
+
@layout.context(@view) do
|
497
|
+
retval = @layout.frame [1, 2, 3, 4]
|
498
|
+
retval.should == @view.frame
|
499
|
+
end
|
500
|
+
@view.frame.origin.x.should == 1
|
501
|
+
@view.frame.origin.y.should == 2
|
502
|
+
@view.frame.size.width.should == 3
|
503
|
+
@view.frame.size.height.should == 4
|
504
|
+
end
|
505
|
+
|
506
|
+
it 'should support `frame :full`' do
|
507
|
+
@layout.context(@view) do
|
508
|
+
retval = @layout.frame :full
|
509
|
+
retval.should == @view.frame
|
510
|
+
end
|
511
|
+
@view.frame.origin.x.should == 0
|
512
|
+
@view.frame.origin.y.should == 0
|
513
|
+
@view.frame.size.width.should == @superview_size.width
|
514
|
+
@view.frame.size.height.should == @superview_size.height
|
515
|
+
end
|
516
|
+
|
517
|
+
it 'should support `frame :auto`' do
|
518
|
+
def @view.intrinsicContentSize
|
519
|
+
CGSize.new(1, 2)
|
520
|
+
end
|
521
|
+
|
522
|
+
@layout.context(@view) do
|
523
|
+
retval = @layout.frame :auto
|
524
|
+
retval.should == @view.frame
|
525
|
+
end
|
526
|
+
@view.frame.origin.x.should == 0
|
527
|
+
@view.frame.origin.y.should == 0
|
528
|
+
@view.frame.size.width.should == 1
|
529
|
+
@view.frame.size.height.should == 2
|
530
|
+
end
|
531
|
+
|
532
|
+
it 'should support `frame :center`' do
|
533
|
+
@layout.context(@view) do
|
534
|
+
retval = @layout.frame :center
|
535
|
+
retval.should == @view.frame
|
536
|
+
end
|
537
|
+
@view.frame.origin.x.should == 26
|
538
|
+
@view.frame.origin.y.should == 15
|
539
|
+
@view.frame.size.width.should == @view_size.width
|
540
|
+
@view.frame.size.height.should == @view_size.height
|
541
|
+
end
|
542
|
+
|
543
|
+
it 'should support setting the frame via `from_bottom_left`' do
|
544
|
+
@layout.context(@view) do
|
545
|
+
retval = @layout.frame @layout.from_bottom_left()
|
546
|
+
retval.should == @view.frame
|
547
|
+
end
|
548
|
+
@view.frame.origin.x.should == 0
|
549
|
+
@view.frame.origin.y.should == 0
|
550
|
+
@view.frame.size.width.should == @view_size.width
|
551
|
+
@view.frame.size.height.should == @view_size.height
|
552
|
+
end
|
553
|
+
|
554
|
+
it 'should support setting the frame via `from_bottom_left` in a flipped view' do
|
555
|
+
@layout.context(@flipped_view) do
|
556
|
+
retval = @layout.frame @layout.from_bottom_left()
|
557
|
+
retval.should == @flipped_view.frame
|
558
|
+
end
|
559
|
+
@flipped_view.frame.origin.x.should == 0
|
560
|
+
@flipped_view.frame.origin.y.should == @superview_size.height - @view_size.height
|
561
|
+
@flipped_view.frame.size.width.should == @view_size.width
|
562
|
+
@flipped_view.frame.size.height.should == @view_size.height
|
563
|
+
end
|
564
|
+
|
565
|
+
it 'should support setting the frame via `from_bottom_left(width:height:)`' do
|
566
|
+
@layout.context(@view) do
|
567
|
+
retval = @layout.frame @layout.from_bottom_left(width: 10, height: 20)
|
568
|
+
retval.should == @view.frame
|
569
|
+
end
|
570
|
+
@view.frame.origin.x.should == 0
|
571
|
+
@view.frame.origin.y.should == 0
|
572
|
+
@view.frame.size.width.should == 10
|
573
|
+
@view.frame.size.height.should == 20
|
574
|
+
end
|
575
|
+
|
576
|
+
it 'should support setting the frame via `from_bottom_left(x:y:width:height:)`' do
|
577
|
+
@layout.context(@view) do
|
578
|
+
retval = @layout.frame @layout.from_bottom_left(x: 10, y: 20, width: 22, height: 12)
|
579
|
+
retval.should == @view.frame
|
580
|
+
end
|
581
|
+
@view.frame.origin.x.should == 10
|
582
|
+
@view.frame.origin.y.should == 20
|
583
|
+
@view.frame.size.width.should == 22
|
584
|
+
@view.frame.size.height.should == 12
|
585
|
+
end
|
586
|
+
|
587
|
+
it 'should support setting the frame via `from_bottom_left(right:up:width:height:)`' do
|
588
|
+
@layout.context(@view) do
|
589
|
+
retval = @layout.frame @layout.from_bottom_left(right: 10, up: 20, width: 22, height: 12)
|
590
|
+
retval.should == @view.frame
|
591
|
+
end
|
592
|
+
@view.frame.origin.x.should == 10
|
593
|
+
@view.frame.origin.y.should == 20
|
594
|
+
@view.frame.size.width.should == 22
|
595
|
+
@view.frame.size.height.should == 12
|
596
|
+
end
|
597
|
+
|
598
|
+
it 'should support setting the frame via `from_bottom_left(left:down:width:height:)`' do
|
599
|
+
@layout.context(@view) do
|
600
|
+
retval = @layout.frame @layout.from_bottom_left(left: 10, down: 20, width: 22, height: 12)
|
601
|
+
retval.should == @view.frame
|
602
|
+
end
|
603
|
+
@view.frame.origin.x.should == -10
|
604
|
+
@view.frame.origin.y.should == -20
|
605
|
+
@view.frame.size.width.should == 22
|
606
|
+
@view.frame.size.height.should == 12
|
607
|
+
end
|
608
|
+
|
609
|
+
it 'should support setting the frame via `from_bottom_left(right:up:width:height:)` in a flipped view' do
|
610
|
+
@layout.context(@flipped_view) do
|
611
|
+
retval = @layout.frame @layout.from_bottom_left(right: 10, down: 20, width: 22, height: 12)
|
612
|
+
retval.should == @flipped_view.frame
|
613
|
+
end
|
614
|
+
@flipped_view.frame.origin.x.should == 10
|
615
|
+
@flipped_view.frame.origin.y.should == @superview_size.height - 12 + 20
|
616
|
+
@flipped_view.frame.size.width.should == 22
|
617
|
+
@flipped_view.frame.size.height.should == 12
|
618
|
+
end
|
619
|
+
|
620
|
+
it 'should support setting the frame via `from_bottom_left(left:down:width:height:)` in a flipped view' do
|
621
|
+
@layout.context(@flipped_view) do
|
622
|
+
retval = @layout.frame @layout.from_bottom_left(left: 10, up: 20, width: 22, height: 12)
|
623
|
+
retval.should == @flipped_view.frame
|
624
|
+
end
|
625
|
+
@flipped_view.frame.origin.x.should == -10
|
626
|
+
@flipped_view.frame.origin.y.should == @superview_size.height - 12 - 20
|
627
|
+
@flipped_view.frame.size.width.should == 22
|
628
|
+
@flipped_view.frame.size.height.should == 12
|
629
|
+
end
|
630
|
+
|
631
|
+
it 'should support setting the frame via `from_bottom_left(view)`' do
|
632
|
+
@layout.context(@view) do
|
633
|
+
retval = @layout.frame @layout.from_bottom_left(@another_view, x: 1, y: 1)
|
634
|
+
retval.should == @view.frame
|
635
|
+
end
|
636
|
+
@view.frame.origin.x.should == @another_view.frame.origin.x + 1
|
637
|
+
@view.frame.origin.y.should == @another_view.frame.origin.y + 1
|
638
|
+
@view.frame.size.width.should == @view_size.width
|
639
|
+
@view.frame.size.height.should == @view_size.height
|
640
|
+
end
|
641
|
+
|
642
|
+
it 'should support setting the frame via `from_bottom_left(:view)`' do
|
643
|
+
@layout.context(@view) do
|
644
|
+
retval = @layout.frame @layout.from_bottom_left(:another_view, x: 1, y: 1)
|
645
|
+
retval.should == @view.frame
|
646
|
+
end
|
647
|
+
@view.frame.origin.x.should == @another_view.frame.origin.x + 1
|
648
|
+
@view.frame.origin.y.should == @another_view.frame.origin.y + 1
|
649
|
+
@view.frame.size.width.should == @view_size.width
|
650
|
+
@view.frame.size.height.should == @view_size.height
|
651
|
+
end
|
652
|
+
|
653
|
+
it 'should support setting the frame via `from_bottom`' do
|
654
|
+
@layout.context(@view) do
|
655
|
+
retval = @layout.frame @layout.from_bottom()
|
656
|
+
retval.should == @view.frame
|
657
|
+
end
|
658
|
+
@view.frame.origin.x.should == (@superview_size.width - @view_size.width) / 2
|
659
|
+
@view.frame.origin.y.should == 0
|
660
|
+
@view.frame.size.width.should == @view_size.width
|
661
|
+
@view.frame.size.height.should == @view_size.height
|
662
|
+
end
|
663
|
+
|
664
|
+
it 'should support setting the frame via `from_bottom` in a flipped view' do
|
665
|
+
@layout.context(@flipped_view) do
|
666
|
+
retval = @layout.frame @layout.from_bottom()
|
667
|
+
retval.should == @flipped_view.frame
|
668
|
+
end
|
669
|
+
@flipped_view.frame.origin.x.should == (@superview_size.width - @view_size.width) / 2
|
670
|
+
@flipped_view.frame.origin.y.should == @superview_size.height - @view_size.height
|
671
|
+
@flipped_view.frame.size.width.should == @view_size.width
|
672
|
+
@flipped_view.frame.size.height.should == @view_size.height
|
673
|
+
end
|
674
|
+
|
675
|
+
it 'should support setting the frame via `from_bottom(width:height:)`' do
|
676
|
+
@layout.context(@view) do
|
677
|
+
retval = @layout.frame @layout.from_bottom(width: 10, height: 20)
|
678
|
+
retval.should == @view.frame
|
679
|
+
end
|
680
|
+
@view.frame.origin.x.should == (@superview_size.width - 10) / 2
|
681
|
+
@view.frame.origin.y.should == 0
|
682
|
+
@view.frame.size.width.should == 10
|
683
|
+
@view.frame.size.height.should == 20
|
684
|
+
end
|
685
|
+
|
686
|
+
it 'should support setting the frame via `from_bottom(x:y:width:height:)`' do
|
687
|
+
@layout.context(@view) do
|
688
|
+
retval = @layout.frame @layout.from_bottom(x: 10, y: 20, width: 22, height: 12)
|
689
|
+
retval.should == @view.frame
|
690
|
+
end
|
691
|
+
@view.frame.origin.x.should == (@superview_size.width - 22) / 2 + 10
|
692
|
+
@view.frame.origin.y.should == 20
|
693
|
+
@view.frame.size.width.should == 22
|
694
|
+
@view.frame.size.height.should == 12
|
695
|
+
end
|
696
|
+
|
697
|
+
it 'should support setting the frame via `from_bottom(right:up:width:height:)`' do
|
698
|
+
@layout.context(@view) do
|
699
|
+
retval = @layout.frame @layout.from_bottom(right: 10, up: 20, width: 22, height: 12)
|
700
|
+
retval.should == @view.frame
|
701
|
+
end
|
702
|
+
@view.frame.origin.x.should == (@superview_size.width - 22) / 2 + 10
|
703
|
+
@view.frame.origin.y.should == 20
|
704
|
+
@view.frame.size.width.should == 22
|
705
|
+
@view.frame.size.height.should == 12
|
706
|
+
end
|
707
|
+
|
708
|
+
it 'should support setting the frame via `from_bottom(left:down:width:height:)`' do
|
709
|
+
@layout.context(@view) do
|
710
|
+
retval = @layout.frame @layout.from_bottom(left: 10, down: 20, width: 22, height: 12)
|
711
|
+
retval.should == @view.frame
|
712
|
+
end
|
713
|
+
@view.frame.origin.x.should == (@superview_size.width - 22) / 2 - 10
|
714
|
+
@view.frame.origin.y.should == -20
|
715
|
+
@view.frame.size.width.should == 22
|
716
|
+
@view.frame.size.height.should == 12
|
717
|
+
end
|
718
|
+
|
719
|
+
it 'should support setting the frame via `from_bottom(right:up:width:height:)` in a flipped view' do
|
720
|
+
@layout.context(@flipped_view) do
|
721
|
+
retval = @layout.frame @layout.from_bottom(right: 10, down: 20, width: 22, height: 12)
|
722
|
+
retval.should == @flipped_view.frame
|
723
|
+
end
|
724
|
+
@flipped_view.frame.origin.x.should == (@superview_size.width - 22) / 2 + 10
|
725
|
+
@flipped_view.frame.origin.y.should == @superview_size.height - 12 + 20
|
726
|
+
@flipped_view.frame.size.width.should == 22
|
727
|
+
@flipped_view.frame.size.height.should == 12
|
728
|
+
end
|
729
|
+
|
730
|
+
it 'should support setting the frame via `from_bottom(left:down:width:height:)` in a flipped view' do
|
731
|
+
@layout.context(@flipped_view) do
|
732
|
+
retval = @layout.frame @layout.from_bottom(left: 10, up: 20, width: 22, height: 12)
|
733
|
+
retval.should == @flipped_view.frame
|
734
|
+
end
|
735
|
+
@flipped_view.frame.origin.x.should == (@superview_size.width - 22) / 2 - 10
|
736
|
+
@flipped_view.frame.origin.y.should == @superview_size.height - 12 - 20
|
737
|
+
@flipped_view.frame.size.width.should == 22
|
738
|
+
@flipped_view.frame.size.height.should == 12
|
739
|
+
end
|
740
|
+
|
741
|
+
it 'should support setting the frame via `from_bottom(view)`' do
|
742
|
+
@layout.context(@view) do
|
743
|
+
retval = @layout.frame @layout.from_bottom(@another_view, x: 1, y: 1)
|
744
|
+
retval.should == @view.frame
|
745
|
+
end
|
746
|
+
@view.frame.origin.x.should == @another_view.frame.origin.x + (@another_view.frame.size.width - @view_size.width) / 2 + 1
|
747
|
+
@view.frame.origin.y.should == @another_view.frame.origin.y + 1
|
748
|
+
@view.frame.size.width.should == @view_size.width
|
749
|
+
@view.frame.size.height.should == @view_size.height
|
750
|
+
end
|
751
|
+
|
752
|
+
it 'should support setting the frame via `from_bottom_right`' do
|
753
|
+
@layout.context(@view) do
|
754
|
+
retval = @layout.frame @layout.from_bottom_right()
|
755
|
+
retval.should == @view.frame
|
756
|
+
end
|
757
|
+
@view.frame.origin.x.should == @superview_size.width - @view_size.width
|
758
|
+
@view.frame.origin.y.should == 0
|
759
|
+
@view.frame.size.width.should == @view_size.width
|
760
|
+
@view.frame.size.height.should == @view_size.height
|
761
|
+
end
|
762
|
+
|
763
|
+
it 'should support setting the frame via `from_bottom_right` in a flipped view' do
|
764
|
+
@layout.context(@flipped_view) do
|
765
|
+
retval = @layout.frame @layout.from_bottom_right()
|
766
|
+
retval.should == @flipped_view.frame
|
767
|
+
end
|
768
|
+
@flipped_view.frame.origin.x.should == @superview_size.width - @view_size.width
|
769
|
+
@flipped_view.frame.origin.y.should == @superview_size.height - @view_size.height
|
770
|
+
@flipped_view.frame.size.width.should == @view_size.width
|
771
|
+
@flipped_view.frame.size.height.should == @view_size.height
|
772
|
+
end
|
773
|
+
|
774
|
+
it 'should support setting the frame via `from_bottom_right(width:height:)`' do
|
775
|
+
@layout.context(@view) do
|
776
|
+
retval = @layout.frame @layout.from_bottom_right(width: 10, height: 20)
|
777
|
+
retval.should == @view.frame
|
778
|
+
end
|
779
|
+
@view.frame.origin.x.should == @superview_size.width - 10
|
780
|
+
@view.frame.origin.y.should == 0
|
781
|
+
@view.frame.size.width.should == 10
|
782
|
+
@view.frame.size.height.should == 20
|
783
|
+
end
|
784
|
+
|
785
|
+
it 'should support setting the frame via `from_bottom_right(x:y:width:height:)`' do
|
786
|
+
@layout.context(@view) do
|
787
|
+
retval = @layout.frame @layout.from_bottom_right(x: 10, y: 20, width: 22, height: 12)
|
788
|
+
retval.should == @view.frame
|
789
|
+
end
|
790
|
+
@view.frame.origin.x.should == @superview_size.width - 22 + 10
|
791
|
+
@view.frame.origin.y.should == 20
|
792
|
+
@view.frame.size.width.should == 22
|
793
|
+
@view.frame.size.height.should == 12
|
794
|
+
end
|
795
|
+
|
796
|
+
it 'should support setting the frame via `from_bottom_right(right:up:width:height:)`' do
|
797
|
+
@layout.context(@view) do
|
798
|
+
retval = @layout.frame @layout.from_bottom_right(right: 10, up: 20, width: 22, height: 12)
|
799
|
+
retval.should == @view.frame
|
800
|
+
end
|
801
|
+
@view.frame.origin.x.should == @superview_size.width - 22 + 10
|
802
|
+
@view.frame.origin.y.should == 20
|
803
|
+
@view.frame.size.width.should == 22
|
804
|
+
@view.frame.size.height.should == 12
|
805
|
+
end
|
806
|
+
|
807
|
+
it 'should support setting the frame via `from_bottom_right(left:down:width:height:)`' do
|
808
|
+
@layout.context(@view) do
|
809
|
+
retval = @layout.frame @layout.from_bottom_right(left: 10, down: 20, width: 22, height: 12)
|
810
|
+
retval.should == @view.frame
|
811
|
+
end
|
812
|
+
@view.frame.origin.x.should == @superview_size.width - 22 - 10
|
813
|
+
@view.frame.origin.y.should == -20
|
814
|
+
@view.frame.size.width.should == 22
|
815
|
+
@view.frame.size.height.should == 12
|
816
|
+
end
|
817
|
+
|
818
|
+
it 'should support setting the frame via `from_bottom_right(right:up:width:height:)` in a flipped view' do
|
819
|
+
@layout.context(@flipped_view) do
|
820
|
+
retval = @layout.frame @layout.from_bottom_right(right: 10, up: 20, width: 22, height: 12)
|
821
|
+
retval.should == @flipped_view.frame
|
822
|
+
end
|
823
|
+
@flipped_view.frame.origin.x.should == @superview_size.width - 22 + 10
|
824
|
+
@flipped_view.frame.origin.y.should == @superview_size.height - 12 - 20
|
825
|
+
@flipped_view.frame.size.width.should == 22
|
826
|
+
@flipped_view.frame.size.height.should == 12
|
827
|
+
end
|
828
|
+
|
829
|
+
it 'should support setting the frame via `from_bottom_right(left:down:width:height:)` in a flipped view' do
|
830
|
+
@layout.context(@flipped_view) do
|
831
|
+
retval = @layout.frame @layout.from_bottom_right(left: 10, down: 20, width: 22, height: 12)
|
832
|
+
retval.should == @flipped_view.frame
|
833
|
+
end
|
834
|
+
@flipped_view.frame.origin.x.should == @superview_size.width - 22 - 10
|
835
|
+
@flipped_view.frame.origin.y.should == @superview_size.height - 12 + 20
|
836
|
+
@flipped_view.frame.size.width.should == 22
|
837
|
+
@flipped_view.frame.size.height.should == 12
|
838
|
+
end
|
839
|
+
|
840
|
+
it 'should support setting the frame via `from_bottom_right(view)`' do
|
841
|
+
@layout.context(@view) do
|
842
|
+
retval = @layout.frame @layout.from_bottom_right(@another_view, x: 1, y: 1)
|
843
|
+
retval.should == @view.frame
|
844
|
+
end
|
845
|
+
@view.frame.origin.x.should == @another_view.frame.origin.x + @another_view.frame.size.width - @view_size.width + 1
|
846
|
+
@view.frame.origin.y.should == @another_view.frame.origin.y + 1
|
847
|
+
@view.frame.size.width.should == @view_size.width
|
848
|
+
@view.frame.size.height.should == @view_size.height
|
849
|
+
end
|
850
|
+
|
851
|
+
it 'should support setting the frame via `from_left`' do
|
852
|
+
@layout.context(@view) do
|
853
|
+
retval = @layout.frame @layout.from_left()
|
854
|
+
retval.should == @view.frame
|
855
|
+
end
|
856
|
+
@view.frame.origin.x.should == 0
|
857
|
+
@view.frame.origin.y.should == (@superview_size.height - @view_size.height) / 2
|
858
|
+
@view.frame.size.width.should == @view_size.width
|
859
|
+
@view.frame.size.height.should == @view_size.height
|
860
|
+
end
|
861
|
+
|
862
|
+
it 'should support setting the frame via `from_left` in a flipped view' do
|
863
|
+
@layout.context(@flipped_view) do
|
864
|
+
retval = @layout.frame @layout.from_left()
|
865
|
+
retval.should == @flipped_view.frame
|
866
|
+
end
|
867
|
+
@flipped_view.frame.origin.x.should == 0
|
868
|
+
@flipped_view.frame.origin.y.should == (@superview_size.height - @view_size.height) / 2
|
869
|
+
@flipped_view.frame.size.width.should == @view_size.width
|
870
|
+
@flipped_view.frame.size.height.should == @view_size.height
|
871
|
+
end
|
872
|
+
|
873
|
+
it 'should support setting the frame via `from_left(width:height:)`' do
|
874
|
+
@layout.context(@view) do
|
875
|
+
retval = @layout.frame @layout.from_left(width: 10, height: 20)
|
876
|
+
retval.should == @view.frame
|
877
|
+
end
|
878
|
+
@view.frame.origin.x.should == 0
|
879
|
+
@view.frame.origin.y.should == (@superview_size.height - 20) / 2
|
880
|
+
@view.frame.size.width.should == 10
|
881
|
+
@view.frame.size.height.should == 20
|
882
|
+
end
|
883
|
+
|
884
|
+
it 'should support setting the frame via `from_left(x:y:width:height:)`' do
|
885
|
+
@layout.context(@view) do
|
886
|
+
retval = @layout.frame @layout.from_left(x: 10, y: 20, width: 22, height: 12)
|
887
|
+
retval.should == @view.frame
|
888
|
+
end
|
889
|
+
@view.frame.origin.x.should == 10
|
890
|
+
@view.frame.origin.y.should == (@superview_size.height - 12) / 2 + 20
|
891
|
+
@view.frame.size.width.should == 22
|
892
|
+
@view.frame.size.height.should == 12
|
893
|
+
end
|
894
|
+
|
895
|
+
it 'should support setting the frame via `from_left(right:up:width:height:)`' do
|
896
|
+
@layout.context(@view) do
|
897
|
+
retval = @layout.frame @layout.from_left(right: 10, up: 20, width: 22, height: 12)
|
898
|
+
retval.should == @view.frame
|
899
|
+
end
|
900
|
+
@view.frame.origin.x.should == 10
|
901
|
+
@view.frame.origin.y.should == (@superview_size.height - 12) / 2 + 20
|
902
|
+
@view.frame.size.width.should == 22
|
903
|
+
@view.frame.size.height.should == 12
|
904
|
+
end
|
905
|
+
|
906
|
+
it 'should support setting the frame via `from_left(left:down:width:height:)`' do
|
907
|
+
@layout.context(@view) do
|
908
|
+
retval = @layout.frame @layout.from_left(left: 10, down: 20, width: 22, height: 12)
|
909
|
+
retval.should == @view.frame
|
910
|
+
end
|
911
|
+
@view.frame.origin.x.should == -10
|
912
|
+
@view.frame.origin.y.should == (@superview_size.height - 12) / 2 - 20
|
913
|
+
@view.frame.size.width.should == 22
|
914
|
+
@view.frame.size.height.should == 12
|
915
|
+
end
|
916
|
+
|
917
|
+
it 'should support setting the frame via `from_left(right:up:width:height:)` in a flipped view' do
|
918
|
+
@layout.context(@flipped_view) do
|
919
|
+
retval = @layout.frame @layout.from_left(right: 10, up: 20, width: 22, height: 12)
|
920
|
+
retval.should == @flipped_view.frame
|
921
|
+
end
|
922
|
+
@flipped_view.frame.origin.x.should == 10
|
923
|
+
@flipped_view.frame.origin.y.should == (@superview_size.height - 12) / 2 - 20
|
924
|
+
@flipped_view.frame.size.width.should == 22
|
925
|
+
@flipped_view.frame.size.height.should == 12
|
926
|
+
end
|
927
|
+
|
928
|
+
it 'should support setting the frame via `from_left(left:down:width:height:)` in a flipped view' do
|
929
|
+
@layout.context(@flipped_view) do
|
930
|
+
retval = @layout.frame @layout.from_left(left: 10, down: 20, width: 22, height: 12)
|
931
|
+
retval.should == @flipped_view.frame
|
932
|
+
end
|
933
|
+
@flipped_view.frame.origin.x.should == -10
|
934
|
+
@flipped_view.frame.origin.y.should == (@superview_size.height - 12) / 2 + 20
|
935
|
+
@flipped_view.frame.size.width.should == 22
|
936
|
+
@flipped_view.frame.size.height.should == 12
|
937
|
+
end
|
938
|
+
|
939
|
+
it 'should support setting the frame via `from_left(view)`' do
|
940
|
+
@layout.context(@view) do
|
941
|
+
retval = @layout.frame @layout.from_left(@another_view, x: 1, y: 1)
|
942
|
+
retval.should == @view.frame
|
943
|
+
end
|
944
|
+
@view.frame.origin.x.should == @another_view.frame.origin.x + 1
|
945
|
+
@view.frame.origin.y.should == @another_view.frame.origin.y + (@another_view.frame.size.height - @view_size.height) / 2 + 1
|
946
|
+
@view.frame.size.width.should == @view_size.width
|
947
|
+
@view.frame.size.height.should == @view_size.height
|
948
|
+
end
|
949
|
+
|
950
|
+
it 'should support setting the frame via `from_center`' do
|
951
|
+
@layout.context(@view) do
|
952
|
+
retval = @layout.frame @layout.from_center()
|
953
|
+
retval.should == @view.frame
|
954
|
+
end
|
955
|
+
@view.frame.origin.x.should == (@superview_size.width - @view_size.width) / 2
|
956
|
+
@view.frame.origin.y.should == (@superview_size.height - @view_size.height) / 2
|
957
|
+
@view.frame.size.width.should == @view_size.width
|
958
|
+
@view.frame.size.height.should == @view_size.height
|
959
|
+
end
|
960
|
+
|
961
|
+
it 'should support setting the frame via `from_center` in a flipped view' do
|
962
|
+
@layout.context(@flipped_view) do
|
963
|
+
retval = @layout.frame @layout.from_center()
|
964
|
+
retval.should == @flipped_view.frame
|
965
|
+
end
|
966
|
+
@flipped_view.frame.origin.x.should == (@superview_size.width - @view_size.width) / 2
|
967
|
+
@flipped_view.frame.origin.y.should == (@superview_size.height - @view_size.height) / 2
|
968
|
+
@flipped_view.frame.size.width.should == @view_size.width
|
969
|
+
@flipped_view.frame.size.height.should == @view_size.height
|
970
|
+
end
|
971
|
+
|
972
|
+
it 'should support setting the frame via `from_center(width:height:)`' do
|
973
|
+
@layout.context(@view) do
|
974
|
+
retval = @layout.frame @layout.from_center(width: 10, height: 20)
|
975
|
+
retval.should == @view.frame
|
976
|
+
end
|
977
|
+
@view.frame.origin.x.should == (@superview_size.width - 10) / 2
|
978
|
+
@view.frame.origin.y.should == (@superview_size.height - 20) / 2
|
979
|
+
@view.frame.size.width.should == 10
|
980
|
+
@view.frame.size.height.should == 20
|
981
|
+
end
|
982
|
+
|
983
|
+
it 'should support setting the frame via `from_center(x:y:width:height:)`' do
|
984
|
+
@layout.context(@view) do
|
985
|
+
retval = @layout.frame @layout.from_center(x: 10, y: 20, width: 22, height: 12)
|
986
|
+
retval.should == @view.frame
|
987
|
+
end
|
988
|
+
@view.frame.origin.x.should == (@superview_size.width - 22) / 2 + 10
|
989
|
+
@view.frame.origin.y.should == (@superview_size.height - 12) / 2 + 20
|
990
|
+
@view.frame.size.width.should == 22
|
991
|
+
@view.frame.size.height.should == 12
|
992
|
+
end
|
993
|
+
|
994
|
+
it 'should support setting the frame via `from_center(right:up:width:height:)`' do
|
995
|
+
@layout.context(@view) do
|
996
|
+
retval = @layout.frame @layout.from_center(right: 10, up: 20, width: 22, height: 12)
|
997
|
+
retval.should == @view.frame
|
998
|
+
end
|
999
|
+
@view.frame.origin.x.should == (@superview_size.width - 22) / 2 + 10
|
1000
|
+
@view.frame.origin.y.should == (@superview_size.height - 12) / 2 + 20
|
1001
|
+
@view.frame.size.width.should == 22
|
1002
|
+
@view.frame.size.height.should == 12
|
1003
|
+
end
|
1004
|
+
|
1005
|
+
it 'should support setting the frame via `from_center(left:down:width:height:)`' do
|
1006
|
+
@layout.context(@view) do
|
1007
|
+
retval = @layout.frame @layout.from_center(left: 10, down: 20, width: 22, height: 12)
|
1008
|
+
retval.should == @view.frame
|
1009
|
+
end
|
1010
|
+
@view.frame.origin.x.should == (@superview_size.width - 22) / 2 - 10
|
1011
|
+
@view.frame.origin.y.should == (@superview_size.height - 12) / 2 - 20
|
1012
|
+
@view.frame.size.width.should == 22
|
1013
|
+
@view.frame.size.height.should == 12
|
1014
|
+
end
|
1015
|
+
|
1016
|
+
it 'should support setting the frame via `from_center(right:up:width:height:)` in a flipped view' do
|
1017
|
+
@layout.context(@flipped_view) do
|
1018
|
+
retval = @layout.frame @layout.from_center(right: 10, up: 20, width: 22, height: 12)
|
1019
|
+
retval.should == @flipped_view.frame
|
1020
|
+
end
|
1021
|
+
@flipped_view.frame.origin.x.should == (@superview_size.width - 22) / 2 + 10
|
1022
|
+
@flipped_view.frame.origin.y.should == (@superview_size.height - 12) / 2 - 20
|
1023
|
+
@flipped_view.frame.size.width.should == 22
|
1024
|
+
@flipped_view.frame.size.height.should == 12
|
1025
|
+
end
|
1026
|
+
|
1027
|
+
it 'should support setting the frame via `from_center(left:down:width:height:)` in a flipped view' do
|
1028
|
+
@layout.context(@flipped_view) do
|
1029
|
+
retval = @layout.frame @layout.from_center(left: 10, down: 20, width: 22, height: 12)
|
1030
|
+
retval.should == @flipped_view.frame
|
1031
|
+
end
|
1032
|
+
@flipped_view.frame.origin.x.should == (@superview_size.width - 22) / 2 - 10
|
1033
|
+
@flipped_view.frame.origin.y.should == (@superview_size.height - 12) / 2 + 20
|
1034
|
+
@flipped_view.frame.size.width.should == 22
|
1035
|
+
@flipped_view.frame.size.height.should == 12
|
1036
|
+
end
|
1037
|
+
|
1038
|
+
it 'should support setting the frame via `from_center(view)`' do
|
1039
|
+
@layout.context(@view) do
|
1040
|
+
retval = @layout.frame @layout.from_center(@another_view, x: 1, y: 1)
|
1041
|
+
retval.should == @view.frame
|
1042
|
+
end
|
1043
|
+
@view.frame.origin.x.should == @another_view.frame.origin.x + (@another_view.frame.size.width - @view_size.width) / 2 + 1
|
1044
|
+
@view.frame.origin.y.should == @another_view.frame.origin.y + (@another_view.frame.size.height - @view_size.height) / 2 + 1
|
1045
|
+
@view.frame.size.width.should == @view_size.width
|
1046
|
+
@view.frame.size.height.should == @view_size.height
|
1047
|
+
end
|
1048
|
+
|
1049
|
+
it 'should support setting the frame via `from_right`' do
|
1050
|
+
@layout.context(@view) do
|
1051
|
+
retval = @layout.frame @layout.from_right()
|
1052
|
+
retval.should == @view.frame
|
1053
|
+
end
|
1054
|
+
@view.frame.origin.x.should == @superview_size.width - @view_size.width
|
1055
|
+
@view.frame.origin.y.should == (@superview_size.height - @view_size.height) / 2
|
1056
|
+
@view.frame.size.width.should == @view_size.width
|
1057
|
+
@view.frame.size.height.should == @view_size.height
|
1058
|
+
end
|
1059
|
+
|
1060
|
+
it 'should support setting the frame via `from_right` in a flipped view' do
|
1061
|
+
@layout.context(@flipped_view) do
|
1062
|
+
retval = @layout.frame @layout.from_right()
|
1063
|
+
retval.should == @flipped_view.frame
|
1064
|
+
end
|
1065
|
+
@flipped_view.frame.origin.x.should == @superview_size.width - @view_size.width
|
1066
|
+
@flipped_view.frame.origin.y.should == (@superview_size.height - @view_size.height) / 2
|
1067
|
+
@flipped_view.frame.size.width.should == @view_size.width
|
1068
|
+
@flipped_view.frame.size.height.should == @view_size.height
|
1069
|
+
end
|
1070
|
+
|
1071
|
+
it 'should support setting the frame via `from_right(width:height:)`' do
|
1072
|
+
@layout.context(@view) do
|
1073
|
+
retval = @layout.frame @layout.from_right(width: 10, height: 20)
|
1074
|
+
retval.should == @view.frame
|
1075
|
+
end
|
1076
|
+
@view.frame.origin.x.should == @superview_size.width - 10
|
1077
|
+
@view.frame.origin.y.should == (@superview_size.height - 20) / 2
|
1078
|
+
@view.frame.size.width.should == 10
|
1079
|
+
@view.frame.size.height.should == 20
|
1080
|
+
end
|
1081
|
+
|
1082
|
+
it 'should support setting the frame via `from_right(x:y:width:height:)`' do
|
1083
|
+
@layout.context(@view) do
|
1084
|
+
retval = @layout.frame @layout.from_right(x: 10, y: 20, width: 22, height: 12)
|
1085
|
+
retval.should == @view.frame
|
1086
|
+
end
|
1087
|
+
@view.frame.origin.x.should == @superview_size.width - 22 + 10
|
1088
|
+
@view.frame.origin.y.should == (@superview_size.height - 12) / 2 + 20
|
1089
|
+
@view.frame.size.width.should == 22
|
1090
|
+
@view.frame.size.height.should == 12
|
1091
|
+
end
|
1092
|
+
|
1093
|
+
it 'should support setting the frame via `from_right(right:up:width:height:)`' do
|
1094
|
+
@layout.context(@view) do
|
1095
|
+
retval = @layout.frame @layout.from_right(right: 10, up: 20, width: 22, height: 12)
|
1096
|
+
retval.should == @view.frame
|
1097
|
+
end
|
1098
|
+
@view.frame.origin.x.should == @superview_size.width - 22 + 10
|
1099
|
+
@view.frame.origin.y.should == (@superview_size.height - 12) / 2 + 20
|
1100
|
+
@view.frame.size.width.should == 22
|
1101
|
+
@view.frame.size.height.should == 12
|
1102
|
+
end
|
1103
|
+
|
1104
|
+
it 'should support setting the frame via `from_right(left:down:width:height:)`' do
|
1105
|
+
@layout.context(@view) do
|
1106
|
+
retval = @layout.frame @layout.from_right(left: 10, down: 20, width: 22, height: 12)
|
1107
|
+
retval.should == @view.frame
|
1108
|
+
end
|
1109
|
+
@view.frame.origin.x.should == @superview_size.width - 22 - 10
|
1110
|
+
@view.frame.origin.y.should == (@superview_size.height - 12) / 2 - 20
|
1111
|
+
@view.frame.size.width.should == 22
|
1112
|
+
@view.frame.size.height.should == 12
|
1113
|
+
end
|
1114
|
+
|
1115
|
+
it 'should support setting the frame via `from_right(right:up:width:height:)` in a flipped view' do
|
1116
|
+
@layout.context(@flipped_view) do
|
1117
|
+
retval = @layout.frame @layout.from_right(right: 10, up: 20, width: 22, height: 12)
|
1118
|
+
retval.should == @flipped_view.frame
|
1119
|
+
end
|
1120
|
+
@flipped_view.frame.origin.x.should == @superview_size.width - 22 + 10
|
1121
|
+
@flipped_view.frame.origin.y.should == (@superview_size.height - 12) / 2 - 20
|
1122
|
+
@flipped_view.frame.size.width.should == 22
|
1123
|
+
@flipped_view.frame.size.height.should == 12
|
1124
|
+
end
|
1125
|
+
|
1126
|
+
it 'should support setting the frame via `from_right(left:down:width:height:)` in a flipped view' do
|
1127
|
+
@layout.context(@flipped_view) do
|
1128
|
+
retval = @layout.frame @layout.from_right(left: 10, down: 20, width: 22, height: 12)
|
1129
|
+
retval.should == @flipped_view.frame
|
1130
|
+
end
|
1131
|
+
@flipped_view.frame.origin.x.should == @superview_size.width - 22 - 10
|
1132
|
+
@flipped_view.frame.origin.y.should == (@superview_size.height - 12) / 2 + 20
|
1133
|
+
@flipped_view.frame.size.width.should == 22
|
1134
|
+
@flipped_view.frame.size.height.should == 12
|
1135
|
+
end
|
1136
|
+
|
1137
|
+
it 'should support setting the frame via `from_right(view)`' do
|
1138
|
+
@layout.context(@view) do
|
1139
|
+
retval = @layout.frame @layout.from_right(@another_view, x: 1, y: 1)
|
1140
|
+
retval.should == @view.frame
|
1141
|
+
end
|
1142
|
+
@view.frame.origin.x.should == @another_view.frame.origin.x + @another_view.frame.size.width - @view_size.width + 1
|
1143
|
+
@view.frame.origin.y.should == @another_view.frame.origin.y + (@another_view.frame.size.height - @view_size.height) / 2 + 1
|
1144
|
+
@view.frame.size.width.should == @view_size.width
|
1145
|
+
@view.frame.size.height.should == @view_size.height
|
1146
|
+
end
|
1147
|
+
|
1148
|
+
it 'should support setting the frame via `from_top_left`' do
|
1149
|
+
@layout.context(@view) do
|
1150
|
+
retval = @layout.frame @layout.from_top_left()
|
1151
|
+
retval.should == @view.frame
|
1152
|
+
end
|
1153
|
+
@view.frame.origin.x.should == 0
|
1154
|
+
@view.frame.origin.y.should == @superview_size.height - @view_size.height
|
1155
|
+
@view.frame.size.width.should == @view_size.width
|
1156
|
+
@view.frame.size.height.should == @view_size.height
|
1157
|
+
end
|
1158
|
+
|
1159
|
+
it 'should support setting the frame via `from_top_left` in a flipped view' do
|
1160
|
+
@layout.context(@flipped_view) do
|
1161
|
+
retval = @layout.frame @layout.from_top_left()
|
1162
|
+
retval.should == @flipped_view.frame
|
1163
|
+
end
|
1164
|
+
@flipped_view.frame.origin.x.should == 0
|
1165
|
+
@flipped_view.frame.origin.y.should == 0
|
1166
|
+
@flipped_view.frame.size.width.should == @view_size.width
|
1167
|
+
@flipped_view.frame.size.height.should == @view_size.height
|
1168
|
+
end
|
1169
|
+
|
1170
|
+
it 'should support setting the frame via `from_top_left(width:height:)`' do
|
1171
|
+
@layout.context(@view) do
|
1172
|
+
retval = @layout.frame @layout.from_top_left(width: 10, height: 20)
|
1173
|
+
retval.should == @view.frame
|
1174
|
+
end
|
1175
|
+
@view.frame.origin.x.should == 0
|
1176
|
+
@view.frame.origin.y.should == @superview_size.height - 20
|
1177
|
+
@view.frame.size.width.should == 10
|
1178
|
+
@view.frame.size.height.should == 20
|
1179
|
+
end
|
1180
|
+
|
1181
|
+
it 'should support setting the frame via `from_top_left(x:y:width:height:)`' do
|
1182
|
+
@layout.context(@view) do
|
1183
|
+
retval = @layout.frame @layout.from_top_left(x: 10, y: 20, width: 22, height: 12)
|
1184
|
+
retval.should == @view.frame
|
1185
|
+
end
|
1186
|
+
@view.frame.origin.x.should == 10
|
1187
|
+
@view.frame.origin.y.should == @superview_size.height - 12 + 20
|
1188
|
+
@view.frame.size.width.should == 22
|
1189
|
+
@view.frame.size.height.should == 12
|
1190
|
+
end
|
1191
|
+
|
1192
|
+
it 'should support setting the frame via `from_top_left(right:up:width:height:)`' do
|
1193
|
+
@layout.context(@view) do
|
1194
|
+
retval = @layout.frame @layout.from_top_left(right: 10, up: 20, width: 22, height: 12)
|
1195
|
+
retval.should == @view.frame
|
1196
|
+
end
|
1197
|
+
@view.frame.origin.x.should == 10
|
1198
|
+
@view.frame.origin.y.should == @superview_size.height - 12 + 20
|
1199
|
+
@view.frame.size.width.should == 22
|
1200
|
+
@view.frame.size.height.should == 12
|
1201
|
+
end
|
1202
|
+
|
1203
|
+
it 'should support setting the frame via `from_top_left(left:down:width:height:)`' do
|
1204
|
+
@layout.context(@view) do
|
1205
|
+
retval = @layout.frame @layout.from_top_left(left: 10, down: 20, width: 22, height: 12)
|
1206
|
+
retval.should == @view.frame
|
1207
|
+
end
|
1208
|
+
@view.frame.origin.x.should == -10
|
1209
|
+
@view.frame.origin.y.should == @superview_size.height - 12 - 20
|
1210
|
+
@view.frame.size.width.should == 22
|
1211
|
+
@view.frame.size.height.should == 12
|
1212
|
+
end
|
1213
|
+
|
1214
|
+
it 'should support setting the frame via `from_top_left(right:up:width:height:)` in a flipped view' do
|
1215
|
+
@layout.context(@flipped_view) do
|
1216
|
+
retval = @layout.frame @layout.from_top_left(right: 10, up: 20, width: 22, height: 12)
|
1217
|
+
retval.should == @flipped_view.frame
|
1218
|
+
end
|
1219
|
+
@flipped_view.frame.origin.x.should == 10
|
1220
|
+
@flipped_view.frame.origin.y.should == -20
|
1221
|
+
@flipped_view.frame.size.width.should == 22
|
1222
|
+
@flipped_view.frame.size.height.should == 12
|
1223
|
+
end
|
1224
|
+
|
1225
|
+
it 'should support setting the frame via `from_top_left(left:down:width:height:)` in a flipped view' do
|
1226
|
+
@layout.context(@flipped_view) do
|
1227
|
+
retval = @layout.frame @layout.from_top_left(left: 10, down: 20, width: 22, height: 12)
|
1228
|
+
retval.should == @flipped_view.frame
|
1229
|
+
end
|
1230
|
+
@flipped_view.frame.origin.x.should == -10
|
1231
|
+
@flipped_view.frame.origin.y.should == 20
|
1232
|
+
@flipped_view.frame.size.width.should == 22
|
1233
|
+
@flipped_view.frame.size.height.should == 12
|
1234
|
+
end
|
1235
|
+
|
1236
|
+
it 'should support setting the frame via `from_top_left(view)`' do
|
1237
|
+
@layout.context(@view) do
|
1238
|
+
retval = @layout.frame @layout.from_top_left(@another_view, x: 1, y: 1)
|
1239
|
+
retval.should == @view.frame
|
1240
|
+
end
|
1241
|
+
@view.frame.origin.x.should == @another_view.frame.origin.x + 1
|
1242
|
+
@view.frame.origin.y.should == @another_view.frame.origin.y + @another_view.frame.size.height - @view_size.height + 1
|
1243
|
+
@view.frame.size.width.should == @view_size.width
|
1244
|
+
@view.frame.size.height.should == @view_size.height
|
1245
|
+
end
|
1246
|
+
|
1247
|
+
it 'should support setting the frame via `from_top`' do
|
1248
|
+
@layout.context(@view) do
|
1249
|
+
retval = @layout.frame @layout.from_top()
|
1250
|
+
retval.should == @view.frame
|
1251
|
+
end
|
1252
|
+
@view.frame.origin.x.should == (@superview_size.width - @view_size.width) / 2
|
1253
|
+
@view.frame.origin.y.should == @superview_size.height - @view_size.height
|
1254
|
+
@view.frame.size.width.should == @view_size.width
|
1255
|
+
@view.frame.size.height.should == @view_size.height
|
1256
|
+
end
|
1257
|
+
|
1258
|
+
it 'should support setting the frame via `from_top` in a flipped view' do
|
1259
|
+
@layout.context(@flipped_view) do
|
1260
|
+
retval = @layout.frame @layout.from_top()
|
1261
|
+
retval.should == @flipped_view.frame
|
1262
|
+
end
|
1263
|
+
@flipped_view.frame.origin.x.should == (@superview_size.width - @view_size.width) / 2
|
1264
|
+
@flipped_view.frame.origin.y.should == 0
|
1265
|
+
@flipped_view.frame.size.width.should == @view_size.width
|
1266
|
+
@flipped_view.frame.size.height.should == @view_size.height
|
1267
|
+
end
|
1268
|
+
|
1269
|
+
it 'should support setting the frame via `from_top(width:height:)`' do
|
1270
|
+
@layout.context(@view) do
|
1271
|
+
retval = @layout.frame @layout.from_top(width: 10, height: 20)
|
1272
|
+
retval.should == @view.frame
|
1273
|
+
end
|
1274
|
+
@view.frame.origin.x.should == (@superview_size.width - 10) / 2
|
1275
|
+
@view.frame.origin.y.should == @superview_size.height - 20
|
1276
|
+
@view.frame.size.width.should == 10
|
1277
|
+
@view.frame.size.height.should == 20
|
1278
|
+
end
|
1279
|
+
|
1280
|
+
it 'should support setting the frame via `from_top(x:y:width:height:)`' do
|
1281
|
+
@layout.context(@view) do
|
1282
|
+
retval = @layout.frame @layout.from_top(x: 10, y: 20, width: 22, height: 12)
|
1283
|
+
retval.should == @view.frame
|
1284
|
+
end
|
1285
|
+
@view.frame.origin.x.should == (@superview_size.width - 22) / 2 + 10
|
1286
|
+
@view.frame.origin.y.should == @superview_size.height - 12 + 20
|
1287
|
+
@view.frame.size.width.should == 22
|
1288
|
+
@view.frame.size.height.should == 12
|
1289
|
+
end
|
1290
|
+
|
1291
|
+
it 'should support setting the frame via `from_top(right:up:width:height:)`' do
|
1292
|
+
@layout.context(@view) do
|
1293
|
+
retval = @layout.frame @layout.from_top(right: 10, up: 20, width: 22, height: 12)
|
1294
|
+
retval.should == @view.frame
|
1295
|
+
end
|
1296
|
+
@view.frame.origin.x.should == (@superview_size.width - 22) / 2 + 10
|
1297
|
+
@view.frame.origin.y.should == @superview_size.height - 12 + 20
|
1298
|
+
@view.frame.size.width.should == 22
|
1299
|
+
@view.frame.size.height.should == 12
|
1300
|
+
end
|
1301
|
+
|
1302
|
+
it 'should support setting the frame via `from_top(left:down:width:height:)`' do
|
1303
|
+
@layout.context(@view) do
|
1304
|
+
retval = @layout.frame @layout.from_top(left: 10, down: 20, width: 22, height: 12)
|
1305
|
+
retval.should == @view.frame
|
1306
|
+
end
|
1307
|
+
@view.frame.origin.x.should == (@superview_size.width - 22) / 2 - 10
|
1308
|
+
@view.frame.origin.y.should == @superview_size.height - 12 - 20
|
1309
|
+
@view.frame.size.width.should == 22
|
1310
|
+
@view.frame.size.height.should == 12
|
1311
|
+
end
|
1312
|
+
|
1313
|
+
it 'should support setting the frame via `from_top(right:up:width:height:)` in a flipped view' do
|
1314
|
+
@layout.context(@flipped_view) do
|
1315
|
+
retval = @layout.frame @layout.from_top(right: 10, up: 20, width: 22, height: 12)
|
1316
|
+
retval.should == @flipped_view.frame
|
1317
|
+
end
|
1318
|
+
@flipped_view.frame.origin.x.should == (@superview_size.width - 22) / 2 + 10
|
1319
|
+
@flipped_view.frame.origin.y.should == -20
|
1320
|
+
@flipped_view.frame.size.width.should == 22
|
1321
|
+
@flipped_view.frame.size.height.should == 12
|
1322
|
+
end
|
1323
|
+
|
1324
|
+
it 'should support setting the frame via `from_top(left:down:width:height:)` in a flipped view' do
|
1325
|
+
@layout.context(@flipped_view) do
|
1326
|
+
retval = @layout.frame @layout.from_top(left: 10, down: 20, width: 22, height: 12)
|
1327
|
+
retval.should == @flipped_view.frame
|
1328
|
+
end
|
1329
|
+
@flipped_view.frame.origin.x.should == (@superview_size.width - 22) / 2 - 10
|
1330
|
+
@flipped_view.frame.origin.y.should == 20
|
1331
|
+
@flipped_view.frame.size.width.should == 22
|
1332
|
+
@flipped_view.frame.size.height.should == 12
|
1333
|
+
end
|
1334
|
+
|
1335
|
+
it 'should support setting the frame via `from_top(view)`' do
|
1336
|
+
@layout.context(@view) do
|
1337
|
+
retval = @layout.frame @layout.from_top(@another_view, x: 1, y: 1)
|
1338
|
+
retval.should == @view.frame
|
1339
|
+
end
|
1340
|
+
@view.frame.origin.x.should == @another_view.frame.origin.x + (@another_view.frame.size.width - @view_size.width) / 2 + 1
|
1341
|
+
@view.frame.origin.y.should == @another_view.frame.origin.y + @another_view.frame.size.height - @view_size.height + 1
|
1342
|
+
@view.frame.size.width.should == @view_size.width
|
1343
|
+
@view.frame.size.height.should == @view_size.height
|
1344
|
+
end
|
1345
|
+
|
1346
|
+
it 'should support setting the frame via `from_top_right`' do
|
1347
|
+
@layout.context(@view) do
|
1348
|
+
retval = @layout.frame @layout.from_top_right()
|
1349
|
+
retval.should == @view.frame
|
1350
|
+
end
|
1351
|
+
@view.frame.origin.x.should == @superview_size.width - @view_size.width
|
1352
|
+
@view.frame.origin.y.should == @superview_size.height - @view_size.height
|
1353
|
+
@view.frame.size.width.should == @view_size.width
|
1354
|
+
@view.frame.size.height.should == @view_size.height
|
1355
|
+
end
|
1356
|
+
|
1357
|
+
it 'should support setting the frame via `from_top_right` in a flipped view' do
|
1358
|
+
@layout.context(@flipped_view) do
|
1359
|
+
retval = @layout.frame @layout.from_top_right()
|
1360
|
+
retval.should == @flipped_view.frame
|
1361
|
+
end
|
1362
|
+
@flipped_view.frame.origin.x.should == @superview_size.width - @view_size.width
|
1363
|
+
@flipped_view.frame.origin.y.should == 0
|
1364
|
+
@flipped_view.frame.size.width.should == @view_size.width
|
1365
|
+
@flipped_view.frame.size.height.should == @view_size.height
|
1366
|
+
end
|
1367
|
+
|
1368
|
+
it 'should support setting the frame via `from_top_right(width:height:)`' do
|
1369
|
+
@layout.context(@view) do
|
1370
|
+
retval = @layout.frame @layout.from_top_right(width: 10, height: 20)
|
1371
|
+
retval.should == @view.frame
|
1372
|
+
end
|
1373
|
+
@view.frame.origin.x.should == @superview_size.width - 10
|
1374
|
+
@view.frame.origin.y.should == @superview_size.height - 20
|
1375
|
+
@view.frame.size.width.should == 10
|
1376
|
+
@view.frame.size.height.should == 20
|
1377
|
+
end
|
1378
|
+
|
1379
|
+
it 'should support setting the frame via `from_top_right(x:y:width:height:)`' do
|
1380
|
+
@layout.context(@view) do
|
1381
|
+
retval = @layout.frame @layout.from_top_right(x: 10, y: 20, width: 22, height: 12)
|
1382
|
+
retval.should == @view.frame
|
1383
|
+
end
|
1384
|
+
@view.frame.origin.x.should == @superview_size.width - 22 + 10
|
1385
|
+
@view.frame.origin.y.should == @superview_size.height - 12 + 20
|
1386
|
+
@view.frame.size.width.should == 22
|
1387
|
+
@view.frame.size.height.should == 12
|
1388
|
+
end
|
1389
|
+
|
1390
|
+
it 'should support setting the frame via `from_top_right(right:up:width:height:)`' do
|
1391
|
+
@layout.context(@view) do
|
1392
|
+
retval = @layout.frame @layout.from_top_right(right: 10, up: 20, width: 22, height: 12)
|
1393
|
+
retval.should == @view.frame
|
1394
|
+
end
|
1395
|
+
@view.frame.origin.x.should == @superview_size.width - 22 + 10
|
1396
|
+
@view.frame.origin.y.should == @superview_size.height - 12 + 20
|
1397
|
+
@view.frame.size.width.should == 22
|
1398
|
+
@view.frame.size.height.should == 12
|
1399
|
+
end
|
1400
|
+
|
1401
|
+
it 'should support setting the frame via `from_top_right(left:down:width:height:)`' do
|
1402
|
+
@layout.context(@view) do
|
1403
|
+
retval = @layout.frame @layout.from_top_right(left: 10, down: 20, width: 22, height: 12)
|
1404
|
+
retval.should == @view.frame
|
1405
|
+
end
|
1406
|
+
@view.frame.origin.x.should == @superview_size.width - 22 - 10
|
1407
|
+
@view.frame.origin.y.should == @superview_size.height - 12 - 20
|
1408
|
+
@view.frame.size.width.should == 22
|
1409
|
+
@view.frame.size.height.should == 12
|
1410
|
+
end
|
1411
|
+
|
1412
|
+
it 'should support setting the frame via `from_top_right(right:up:width:height:)` in a flipped view' do
|
1413
|
+
@layout.context(@flipped_view) do
|
1414
|
+
retval = @layout.frame @layout.from_top_right(right: 10, up: 20, width: 22, height: 12)
|
1415
|
+
retval.should == @flipped_view.frame
|
1416
|
+
end
|
1417
|
+
@flipped_view.frame.origin.x.should == @superview_size.width - 22 + 10
|
1418
|
+
@flipped_view.frame.origin.y.should == -20
|
1419
|
+
@flipped_view.frame.size.width.should == 22
|
1420
|
+
@flipped_view.frame.size.height.should == 12
|
1421
|
+
end
|
1422
|
+
|
1423
|
+
it 'should support setting the frame via `from_top_right(left:down:width:height:)` in a flipped view' do
|
1424
|
+
@layout.context(@flipped_view) do
|
1425
|
+
retval = @layout.frame @layout.from_top_right(left: 10, down: 20, width: 22, height: 12)
|
1426
|
+
retval.should == @flipped_view.frame
|
1427
|
+
end
|
1428
|
+
@flipped_view.frame.origin.x.should == @superview_size.width - 22 - 10
|
1429
|
+
@flipped_view.frame.origin.y.should == 20
|
1430
|
+
@flipped_view.frame.size.width.should == 22
|
1431
|
+
@flipped_view.frame.size.height.should == 12
|
1432
|
+
end
|
1433
|
+
|
1434
|
+
it 'should support setting the frame via `from_top_right(view)`' do
|
1435
|
+
@layout.context(@view) do
|
1436
|
+
retval = @layout.frame @layout.from_top_right(@another_view, x: 1, y: 1)
|
1437
|
+
retval.should == @view.frame
|
1438
|
+
end
|
1439
|
+
@view.frame.origin.x.should == @another_view.frame.origin.x + @another_view.frame.size.width - @view_size.width + 1
|
1440
|
+
@view.frame.origin.y.should == @another_view.frame.origin.y + @another_view.frame.size.height - @view_size.height + 1
|
1441
|
+
@view.frame.size.width.should == @view_size.width
|
1442
|
+
@view.frame.size.height.should == @view_size.height
|
1443
|
+
end
|
1444
|
+
|
1445
|
+
it 'should support setting the frame via `above(view)`' do
|
1446
|
+
@layout.context(@view) do
|
1447
|
+
retval = @layout.frame @layout.above(@another_view)
|
1448
|
+
retval.should == @view.frame
|
1449
|
+
end
|
1450
|
+
@view.frame.origin.x.should == 10
|
1451
|
+
@view.frame.origin.y.should == 148
|
1452
|
+
@view.frame.size.width.should == @view_size.width
|
1453
|
+
@view.frame.size.height.should == @view_size.height
|
1454
|
+
end
|
1455
|
+
|
1456
|
+
it 'should support setting the frame via `above(view)` in a flipped view' do
|
1457
|
+
@layout.context(@flipped_view) do
|
1458
|
+
retval = @layout.frame @layout.above(@another_view)
|
1459
|
+
retval.should == @flipped_view.frame
|
1460
|
+
end
|
1461
|
+
@flipped_view.frame.origin.x.should == 10
|
1462
|
+
@flipped_view.frame.origin.y.should == -78
|
1463
|
+
@flipped_view.frame.size.width.should == @view_size.width
|
1464
|
+
@flipped_view.frame.size.height.should == @view_size.height
|
1465
|
+
end
|
1466
|
+
|
1467
|
+
it 'should support setting the frame via `above(view)` and ignore view origin' do
|
1468
|
+
f = @view.frame
|
1469
|
+
f.origin.x = 10
|
1470
|
+
f.origin.y = 10
|
1471
|
+
@view.frame = f
|
1472
|
+
|
1473
|
+
@layout.context(@view) do
|
1474
|
+
retval = @layout.frame @layout.above(@another_view)
|
1475
|
+
retval.should == @view.frame
|
1476
|
+
end
|
1477
|
+
@view.frame.origin.x.should == 10
|
1478
|
+
@view.frame.origin.y.should == 148
|
1479
|
+
@view.frame.size.width.should == @view_size.width
|
1480
|
+
@view.frame.size.height.should == @view_size.height
|
1481
|
+
end
|
1482
|
+
|
1483
|
+
it 'should support setting the frame via `above(view, down:)`' do
|
1484
|
+
@layout.context(@view) do
|
1485
|
+
retval = @layout.frame @layout.above(@another_view, down: 8)
|
1486
|
+
retval.should == @view.frame
|
1487
|
+
end
|
1488
|
+
@view.frame.origin.x.should == 10
|
1489
|
+
@view.frame.origin.y.should == 140
|
1490
|
+
@view.frame.size.width.should == @view_size.width
|
1491
|
+
@view.frame.size.height.should == @view_size.height
|
1492
|
+
end
|
1493
|
+
|
1494
|
+
it 'should support setting the frame via `above(view, width:height:)`' do
|
1495
|
+
@layout.context(@view) do
|
1496
|
+
retval = @layout.frame @layout.above(@another_view, width: 10, height: 20)
|
1497
|
+
retval.should == @view.frame
|
1498
|
+
end
|
1499
|
+
@view.frame.origin.x.should == 10
|
1500
|
+
@view.frame.origin.y.should == 148
|
1501
|
+
@view.frame.size.width.should == 10
|
1502
|
+
@view.frame.size.height.should == 20
|
1503
|
+
end
|
1504
|
+
|
1505
|
+
it 'should support setting the frame via `above(view, x:y:width:height:)`' do
|
1506
|
+
@layout.context(@view) do
|
1507
|
+
retval = @layout.frame @layout.above(@another_view, x: 10, y: 20, width: 22, height: 12)
|
1508
|
+
retval.should == @view.frame
|
1509
|
+
end
|
1510
|
+
@view.frame.origin.x.should == 20
|
1511
|
+
@view.frame.origin.y.should == 168
|
1512
|
+
@view.frame.size.width.should == 22
|
1513
|
+
@view.frame.size.height.should == 12
|
1514
|
+
end
|
1515
|
+
|
1516
|
+
it 'should support setting the frame via `above(view, right:up:width:height:)`' do
|
1517
|
+
@layout.context(@view) do
|
1518
|
+
retval = @layout.frame @layout.above(@another_view, right: 10, up: 20, width: 22, height: 12)
|
1519
|
+
retval.should == @view.frame
|
1520
|
+
end
|
1521
|
+
@view.frame.origin.x.should == 20
|
1522
|
+
@view.frame.origin.y.should == 168
|
1523
|
+
@view.frame.size.width.should == 22
|
1524
|
+
@view.frame.size.height.should == 12
|
1525
|
+
end
|
1526
|
+
|
1527
|
+
it 'should support setting the frame via `above(view, left:down:width:height:)`' do
|
1528
|
+
@layout.context(@view) do
|
1529
|
+
retval = @layout.frame @layout.above(@another_view, left: 10, down: 20, width: 22, height: 12)
|
1530
|
+
retval.should == @view.frame
|
1531
|
+
end
|
1532
|
+
@view.frame.origin.x.should == 0
|
1533
|
+
@view.frame.origin.y.should == 128
|
1534
|
+
@view.frame.size.width.should == 22
|
1535
|
+
@view.frame.size.height.should == 12
|
1536
|
+
end
|
1537
|
+
|
1538
|
+
it 'should support setting the frame via `above(view, right:up:width:height:)`' do
|
1539
|
+
@layout.context(@flipped_view) do
|
1540
|
+
retval = @layout.frame @layout.above(@another_view, right: 10, up: 20, width: 22, height: 12)
|
1541
|
+
retval.should == @flipped_view.frame
|
1542
|
+
end
|
1543
|
+
@flipped_view.frame.origin.x.should == 20
|
1544
|
+
@flipped_view.frame.origin.y.should == -100
|
1545
|
+
@flipped_view.frame.size.width.should == 22
|
1546
|
+
@flipped_view.frame.size.height.should == 12
|
1547
|
+
end
|
1548
|
+
|
1549
|
+
it 'should support setting the frame via `above(view, left:down:width:height:)`' do
|
1550
|
+
@layout.context(@flipped_view) do
|
1551
|
+
retval = @layout.frame @layout.above(@another_view, left: 10, down: 20, width: 22, height: 12)
|
1552
|
+
retval.should == @flipped_view.frame
|
1553
|
+
end
|
1554
|
+
@flipped_view.frame.origin.x.should == 0
|
1555
|
+
@flipped_view.frame.origin.y.should == -60
|
1556
|
+
@flipped_view.frame.size.width.should == 22
|
1557
|
+
@flipped_view.frame.size.height.should == 12
|
1558
|
+
end
|
1559
|
+
|
1560
|
+
it 'should support setting the frame via `below(view)`' do
|
1561
|
+
@layout.context(@view) do
|
1562
|
+
retval = @layout.frame @layout.below(@another_view)
|
1563
|
+
retval.should == @view.frame
|
1564
|
+
end
|
1565
|
+
@view.frame.origin.x.should == 10
|
1566
|
+
@view.frame.origin.y.should == 90
|
1567
|
+
@view.frame.size.width.should == @view_size.width
|
1568
|
+
@view.frame.size.height.should == @view_size.height
|
1569
|
+
end
|
1570
|
+
|
1571
|
+
it 'should support setting the frame via `below(view)` in a flipped view' do
|
1572
|
+
@layout.context(@flipped_view) do
|
1573
|
+
retval = @layout.frame @layout.below(@another_view)
|
1574
|
+
retval.should == @flipped_view.frame
|
1575
|
+
end
|
1576
|
+
@flipped_view.frame.origin.x.should == 10
|
1577
|
+
@flipped_view.frame.origin.y.should == -20
|
1578
|
+
@flipped_view.frame.size.width.should == @view_size.width
|
1579
|
+
@flipped_view.frame.size.height.should == @view_size.height
|
1580
|
+
end
|
1581
|
+
|
1582
|
+
it 'should support setting the frame via `below(view)` and ignore view origin' do
|
1583
|
+
f = @view.frame
|
1584
|
+
f.origin.x = 10
|
1585
|
+
f.origin.y = 10
|
1586
|
+
@view.frame = f
|
1587
|
+
|
1588
|
+
@layout.context(@view) do
|
1589
|
+
retval = @layout.frame @layout.below(@another_view)
|
1590
|
+
retval.should == @view.frame
|
1591
|
+
end
|
1592
|
+
@view.frame.origin.x.should == 10
|
1593
|
+
@view.frame.origin.y.should == 90
|
1594
|
+
@view.frame.size.width.should == @view_size.width
|
1595
|
+
@view.frame.size.height.should == @view_size.height
|
1596
|
+
end
|
1597
|
+
|
1598
|
+
it 'should support setting the frame via `below(view, up:)`' do
|
1599
|
+
@layout.context(@view) do
|
1600
|
+
retval = @layout.frame @layout.below(@another_view, up: 8)
|
1601
|
+
retval.should == @view.frame
|
1602
|
+
end
|
1603
|
+
@view.frame.origin.x.should == 10
|
1604
|
+
@view.frame.origin.y.should == 98
|
1605
|
+
@view.frame.size.width.should == @view_size.width
|
1606
|
+
@view.frame.size.height.should == @view_size.height
|
1607
|
+
end
|
1608
|
+
|
1609
|
+
it 'should support setting the frame via `below(view, width:height:)`' do
|
1610
|
+
@layout.context(@view) do
|
1611
|
+
retval = @layout.frame @layout.below(@another_view, width: 10, height: 20)
|
1612
|
+
retval.should == @view.frame
|
1613
|
+
end
|
1614
|
+
@view.frame.origin.x.should == 10
|
1615
|
+
@view.frame.origin.y.should == 80
|
1616
|
+
@view.frame.size.width.should == 10
|
1617
|
+
@view.frame.size.height.should == 20
|
1618
|
+
end
|
1619
|
+
|
1620
|
+
it 'should support setting the frame via `below(view, x:y:width:height:)`' do
|
1621
|
+
@layout.context(@view) do
|
1622
|
+
retval = @layout.frame @layout.below(@another_view, x: 10, y: 20, width: 22, height: 12)
|
1623
|
+
retval.should == @view.frame
|
1624
|
+
end
|
1625
|
+
@view.frame.origin.x.should == 20
|
1626
|
+
@view.frame.origin.y.should == 108
|
1627
|
+
@view.frame.size.width.should == 22
|
1628
|
+
@view.frame.size.height.should == 12
|
1629
|
+
end
|
1630
|
+
|
1631
|
+
it 'should support setting the frame via `below(view, right:up:width:height:)`' do
|
1632
|
+
@layout.context(@view) do
|
1633
|
+
retval = @layout.frame @layout.below(@another_view, right: 10, up: 20, width: 22, height: 12)
|
1634
|
+
retval.should == @view.frame
|
1635
|
+
end
|
1636
|
+
@view.frame.origin.x.should == 20
|
1637
|
+
@view.frame.origin.y.should == 108
|
1638
|
+
@view.frame.size.width.should == 22
|
1639
|
+
@view.frame.size.height.should == 12
|
1640
|
+
end
|
1641
|
+
|
1642
|
+
it 'should support setting the frame via `below(view, left:down:width:height:)`' do
|
1643
|
+
@layout.context(@view) do
|
1644
|
+
retval = @layout.frame @layout.below(@another_view, left: 10, down: 20, width: 22, height: 12)
|
1645
|
+
retval.should == @view.frame
|
1646
|
+
end
|
1647
|
+
@view.frame.origin.x.should == 0
|
1648
|
+
@view.frame.origin.y.should == 68
|
1649
|
+
@view.frame.size.width.should == 22
|
1650
|
+
@view.frame.size.height.should == 12
|
1651
|
+
end
|
1652
|
+
|
1653
|
+
it 'should support setting the frame via `below(view, right:up:width:height:)` in a flipped view' do
|
1654
|
+
@layout.context(@flipped_view) do
|
1655
|
+
retval = @layout.frame @layout.below(@another_view, right: 10, up: 20, width: 22, height: 12)
|
1656
|
+
retval.should == @flipped_view.frame
|
1657
|
+
end
|
1658
|
+
@flipped_view.frame.origin.x.should == 20
|
1659
|
+
@flipped_view.frame.origin.y.should == -40
|
1660
|
+
@flipped_view.frame.size.width.should == 22
|
1661
|
+
@flipped_view.frame.size.height.should == 12
|
1662
|
+
end
|
1663
|
+
|
1664
|
+
it 'should support setting the frame via `below(view, left:down:width:height:)` in a flipped view' do
|
1665
|
+
@layout.context(@flipped_view) do
|
1666
|
+
retval = @layout.frame @layout.below(@another_view, left: 10, down: 20, width: 22, height: 12)
|
1667
|
+
retval.should == @flipped_view.frame
|
1668
|
+
end
|
1669
|
+
@flipped_view.frame.origin.x.should == 0
|
1670
|
+
@flipped_view.frame.origin.y.should == 0
|
1671
|
+
@flipped_view.frame.size.width.should == 22
|
1672
|
+
@flipped_view.frame.size.height.should == 12
|
1673
|
+
end
|
1674
|
+
|
1675
|
+
it 'should support setting the frame via `before(view)`' do
|
1676
|
+
@layout.context(@view) do
|
1677
|
+
retval = @layout.frame @layout.before(@another_view)
|
1678
|
+
retval.should == @view.frame
|
1679
|
+
end
|
1680
|
+
@view.frame.origin.x.should == 2
|
1681
|
+
@view.frame.origin.y.should == 100
|
1682
|
+
@view.frame.size.width.should == @view_size.width
|
1683
|
+
@view.frame.size.height.should == @view_size.height
|
1684
|
+
end
|
1685
|
+
|
1686
|
+
it 'should support setting the frame via `before(view)` and ignore view origin' do
|
1687
|
+
f = @view.frame
|
1688
|
+
f.origin.x = 10
|
1689
|
+
f.origin.y = 10
|
1690
|
+
@view.frame = f
|
1691
|
+
|
1692
|
+
@layout.context(@view) do
|
1693
|
+
retval = @layout.frame @layout.before(@another_view)
|
1694
|
+
retval.should == @view.frame
|
1695
|
+
end
|
1696
|
+
@view.frame.origin.x.should == 2
|
1697
|
+
@view.frame.origin.y.should == 100
|
1698
|
+
@view.frame.size.width.should == @view_size.width
|
1699
|
+
@view.frame.size.height.should == @view_size.height
|
1700
|
+
end
|
1701
|
+
|
1702
|
+
it 'should support setting the frame via `before(view, left:)`' do
|
1703
|
+
@layout.context(@view) do
|
1704
|
+
retval = @layout.frame @layout.before(@another_view, left: 8)
|
1705
|
+
retval.should == @view.frame
|
1706
|
+
end
|
1707
|
+
@view.frame.origin.x.should == -6
|
1708
|
+
@view.frame.origin.y.should == 100
|
1709
|
+
@view.frame.size.width.should == @view_size.width
|
1710
|
+
@view.frame.size.height.should == @view_size.height
|
1711
|
+
end
|
1712
|
+
|
1713
|
+
it 'should support setting the frame via `before(view, width:height:)`' do
|
1714
|
+
@layout.context(@view) do
|
1715
|
+
retval = @layout.frame @layout.before(@another_view, width: 10, height: 20)
|
1716
|
+
retval.should == @view.frame
|
1717
|
+
end
|
1718
|
+
@view.frame.origin.x.should == 0
|
1719
|
+
@view.frame.origin.y.should == 100
|
1720
|
+
@view.frame.size.width.should == 10
|
1721
|
+
@view.frame.size.height.should == 20
|
1722
|
+
end
|
1723
|
+
|
1724
|
+
it 'should support setting the frame via `before(view, x:y:width:height:)`' do
|
1725
|
+
@layout.context(@view) do
|
1726
|
+
retval = @layout.frame @layout.before(@another_view, x: 10, y: 20, width: 22, height: 12)
|
1727
|
+
retval.should == @view.frame
|
1728
|
+
end
|
1729
|
+
@view.frame.origin.x.should == -2
|
1730
|
+
@view.frame.origin.y.should == 120
|
1731
|
+
@view.frame.size.width.should == 22
|
1732
|
+
@view.frame.size.height.should == 12
|
1733
|
+
end
|
1734
|
+
|
1735
|
+
it 'should support setting the frame via `left_of(view)`' do
|
1736
|
+
before = nil
|
1737
|
+
left_of = nil
|
1738
|
+
@layout.context(@view) do
|
1739
|
+
before = @layout.before(@another_view)
|
1740
|
+
left_of = @layout.left_of(@another_view)
|
1741
|
+
end
|
1742
|
+
left_of.origin.x.should == before.origin.x
|
1743
|
+
left_of.origin.y.should == before.origin.y
|
1744
|
+
left_of.size.width.should == before.size.width
|
1745
|
+
left_of.size.height.should == before.size.height
|
1746
|
+
end
|
1747
|
+
|
1748
|
+
it 'should support setting the frame via `after(view)`' do
|
1749
|
+
@layout.context(@view) do
|
1750
|
+
retval = @layout.frame @layout.after(@another_view)
|
1751
|
+
retval.should == @view.frame
|
1752
|
+
end
|
1753
|
+
@view.frame.origin.x.should == 130
|
1754
|
+
@view.frame.origin.y.should == 100
|
1755
|
+
@view.frame.size.width.should == @view_size.width
|
1756
|
+
@view.frame.size.height.should == @view_size.height
|
1757
|
+
end
|
1758
|
+
|
1759
|
+
it 'should support setting the frame via `after(view)` and ignore view origin' do
|
1760
|
+
f = @view.frame
|
1761
|
+
f.origin.x = 10
|
1762
|
+
f.origin.y = 10
|
1763
|
+
@view.frame = f
|
1764
|
+
|
1765
|
+
@layout.context(@view) do
|
1766
|
+
retval = @layout.frame @layout.after(@another_view)
|
1767
|
+
retval.should == @view.frame
|
1768
|
+
end
|
1769
|
+
@view.frame.origin.x.should == 130
|
1770
|
+
@view.frame.origin.y.should == 100
|
1771
|
+
@view.frame.size.width.should == @view_size.width
|
1772
|
+
@view.frame.size.height.should == @view_size.height
|
1773
|
+
end
|
1774
|
+
|
1775
|
+
it 'should support setting the frame via `after(view, right:)`' do
|
1776
|
+
@layout.context(@view) do
|
1777
|
+
retval = @layout.frame @layout.after(@another_view, right: 8)
|
1778
|
+
retval.should == @view.frame
|
1779
|
+
end
|
1780
|
+
@view.frame.origin.x.should == 138
|
1781
|
+
@view.frame.origin.y.should == 100
|
1782
|
+
@view.frame.size.width.should == @view_size.width
|
1783
|
+
@view.frame.size.height.should == @view_size.height
|
1784
|
+
end
|
1785
|
+
|
1786
|
+
it 'should support setting the frame via `after(view, width:height:)`' do
|
1787
|
+
@layout.context(@view) do
|
1788
|
+
retval = @layout.frame @layout.after(@another_view, width: 10, height: 20)
|
1789
|
+
retval.should == @view.frame
|
1790
|
+
end
|
1791
|
+
@view.frame.origin.x.should == 130
|
1792
|
+
@view.frame.origin.y.should == 100
|
1793
|
+
@view.frame.size.width.should == 10
|
1794
|
+
@view.frame.size.height.should == 20
|
1795
|
+
end
|
1796
|
+
|
1797
|
+
it 'should support setting the frame via `after(view, x:y:width:height:)`' do
|
1798
|
+
@layout.context(@view) do
|
1799
|
+
retval = @layout.frame @layout.after(@another_view, x: 10, y: 20, width: 22, height: 12)
|
1800
|
+
retval.should == @view.frame
|
1801
|
+
end
|
1802
|
+
@view.frame.origin.x.should == 140
|
1803
|
+
@view.frame.origin.y.should == 120
|
1804
|
+
@view.frame.size.width.should == 22
|
1805
|
+
@view.frame.size.height.should == 12
|
1806
|
+
end
|
1807
|
+
|
1808
|
+
it 'should support setting the frame via `right_of(view)`' do
|
1809
|
+
after = nil
|
1810
|
+
right_of = nil
|
1811
|
+
@layout.context(@view) do
|
1812
|
+
after = @layout.after(@another_view)
|
1813
|
+
right_of = @layout.right_of(@another_view)
|
1814
|
+
end
|
1815
|
+
right_of.origin.x.should == after.origin.x
|
1816
|
+
right_of.origin.y.should == after.origin.y
|
1817
|
+
right_of.size.width.should == after.size.width
|
1818
|
+
right_of.size.height.should == after.size.height
|
1819
|
+
end
|
1820
|
+
|
1821
|
+
it 'should support setting the frame via `relative_to(view)`' do
|
1822
|
+
@layout.context(@view) do
|
1823
|
+
retval = @layout.frame @layout.relative_to(@another_view, {})
|
1824
|
+
retval.should == @view.frame
|
1825
|
+
end
|
1826
|
+
@view.frame.origin.x.should == 10
|
1827
|
+
@view.frame.origin.y.should == 100
|
1828
|
+
@view.frame.size.width.should == @view_size.width
|
1829
|
+
@view.frame.size.height.should == @view_size.height
|
1830
|
+
end
|
1831
|
+
|
1832
|
+
it 'should support setting the frame via `relative_to(view)` in a flipped view' do
|
1833
|
+
@layout.context(@flipped_view) do
|
1834
|
+
retval = @layout.frame @layout.relative_to(@another_view, {})
|
1835
|
+
retval.should == @flipped_view.frame
|
1836
|
+
end
|
1837
|
+
@flipped_view.frame.origin.x.should == 10
|
1838
|
+
@flipped_view.frame.origin.y.should == -20
|
1839
|
+
@flipped_view.frame.size.width.should == @view_size.width
|
1840
|
+
@flipped_view.frame.size.height.should == @view_size.height
|
1841
|
+
end
|
1842
|
+
|
1843
|
+
it 'should support setting the frame via `relative_to(view)` and ignore view origin' do
|
1844
|
+
f = @view.frame
|
1845
|
+
f.origin.x = 10
|
1846
|
+
f.origin.y = 10
|
1847
|
+
@view.frame = f
|
1848
|
+
|
1849
|
+
@layout.context(@view) do
|
1850
|
+
retval = @layout.frame @layout.relative_to(@another_view, {})
|
1851
|
+
retval.should == @view.frame
|
1852
|
+
end
|
1853
|
+
@view.frame.origin.x.should == 10
|
1854
|
+
@view.frame.origin.y.should == 100
|
1855
|
+
@view.frame.size.width.should == @view_size.width
|
1856
|
+
@view.frame.size.height.should == @view_size.height
|
1857
|
+
end
|
1858
|
+
|
1859
|
+
it 'should support setting the frame via `relative_to(view, width:height:)`' do
|
1860
|
+
@layout.context(@view) do
|
1861
|
+
retval = @layout.frame @layout.relative_to(@another_view, width: 10, height: 20)
|
1862
|
+
retval.should == @view.frame
|
1863
|
+
end
|
1864
|
+
@view.frame.origin.x.should == 10
|
1865
|
+
@view.frame.origin.y.should == 100
|
1866
|
+
@view.frame.size.width.should == 10
|
1867
|
+
@view.frame.size.height.should == 20
|
1868
|
+
end
|
1869
|
+
|
1870
|
+
it 'should support setting the frame via `relative_to(view, x:y:width:height:)`' do
|
1871
|
+
@layout.context(@view) do
|
1872
|
+
retval = @layout.frame @layout.relative_to(@another_view, x: 10, y: 20, width: 22, height: 12)
|
1873
|
+
retval.should == @view.frame
|
1874
|
+
end
|
1875
|
+
@view.frame.origin.x.should == 20
|
1876
|
+
@view.frame.origin.y.should == 120
|
1877
|
+
@view.frame.size.width.should == 22
|
1878
|
+
@view.frame.size.height.should == 12
|
1879
|
+
end
|
1880
|
+
|
1881
|
+
end
|