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,75 @@
|
|
1
|
+
# @requires MotionKit::UIViewLayout
|
2
|
+
module MotionKit
|
3
|
+
class UIViewLayout
|
4
|
+
|
5
|
+
def autoresizing_mask(*values)
|
6
|
+
value = 0
|
7
|
+
values.each do |mask|
|
8
|
+
case mask
|
9
|
+
when :flexible_left
|
10
|
+
value |= UIViewAutoresizingFlexibleLeftMargin
|
11
|
+
when :flexible_width
|
12
|
+
value |= UIViewAutoresizingFlexibleWidth
|
13
|
+
when :flexible_right
|
14
|
+
value |= UIViewAutoresizingFlexibleRightMargin
|
15
|
+
when :flexible_top
|
16
|
+
value |= UIViewAutoresizingFlexibleTopMargin
|
17
|
+
when :flexible_height
|
18
|
+
value |= UIViewAutoresizingFlexibleHeight
|
19
|
+
when :flexible_bottom
|
20
|
+
value |= UIViewAutoresizingFlexibleBottomMargin
|
21
|
+
|
22
|
+
when :rigid_left
|
23
|
+
value ^= UIViewAutoresizingFlexibleLeftMargin
|
24
|
+
when :rigid_width
|
25
|
+
value ^= UIViewAutoresizingFlexibleWidth
|
26
|
+
when :rigid_right
|
27
|
+
value ^= UIViewAutoresizingFlexibleRightMargin
|
28
|
+
when :rigid_top
|
29
|
+
value ^= UIViewAutoresizingFlexibleTopMargin
|
30
|
+
when :rigid_height
|
31
|
+
value ^= UIViewAutoresizingFlexibleHeight
|
32
|
+
when :rigid_bottom
|
33
|
+
value ^= UIViewAutoresizingFlexibleBottomMargin
|
34
|
+
|
35
|
+
when :fill
|
36
|
+
value |= UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight
|
37
|
+
when :fill_top
|
38
|
+
value |= UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin
|
39
|
+
when :fill_bottom
|
40
|
+
value |= UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin
|
41
|
+
when :fill_left
|
42
|
+
value |= UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleRightMargin
|
43
|
+
when :fill_right
|
44
|
+
value |= UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleLeftMargin
|
45
|
+
|
46
|
+
when :pin_to_top_left
|
47
|
+
value |= UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin
|
48
|
+
when :pin_to_top
|
49
|
+
value |= UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin
|
50
|
+
when :pin_to_top_right
|
51
|
+
value |= UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin
|
52
|
+
when :pin_to_left
|
53
|
+
value |= UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin
|
54
|
+
when :pin_to_center, :pin_to_middle
|
55
|
+
value |= UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin
|
56
|
+
when :pin_to_right
|
57
|
+
value |= UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin
|
58
|
+
when :pin_to_bottom_left
|
59
|
+
value |= UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin
|
60
|
+
when :pin_to_bottom
|
61
|
+
value |= UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin
|
62
|
+
when :pin_to_bottom_right
|
63
|
+
value |= UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin
|
64
|
+
else
|
65
|
+
value |= mask
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
target.autoresizingMask = value
|
70
|
+
value
|
71
|
+
end
|
72
|
+
alias autoresizingMask autoresizing_mask
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# @requires MotionKit::UIViewLayout
|
2
|
+
module MotionKit
|
3
|
+
class UIViewLayout
|
4
|
+
|
5
|
+
def constraints(view=nil, &block)
|
6
|
+
view ||= target
|
7
|
+
if view.is_a?(Symbol)
|
8
|
+
view = self.get(view)
|
9
|
+
end
|
10
|
+
view.setTranslatesAutoresizingMaskIntoConstraints(false)
|
11
|
+
|
12
|
+
deferred do
|
13
|
+
constraints_target = ConstraintsTarget.new(view)
|
14
|
+
context(constraints_target, &block)
|
15
|
+
constraints_target.apply_all_constraints(self, view)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
class Layout
|
22
|
+
|
23
|
+
# Ensure we always have a context in this method; makes it easier to define
|
24
|
+
# constraints in an `add_constraints` method.
|
25
|
+
def constraints(view=nil, &block)
|
26
|
+
if @context
|
27
|
+
apply(:constraints, view, &block)
|
28
|
+
else
|
29
|
+
context(self.view) do
|
30
|
+
constraints(view, &block)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,307 @@
|
|
1
|
+
# @requires MotionKit::UIViewLayout
|
2
|
+
module MotionKit
|
3
|
+
class UIViewLayout
|
4
|
+
override_start
|
5
|
+
|
6
|
+
def x(value)
|
7
|
+
f = target.frame
|
8
|
+
f.origin.x = MotionKit.calculate(target, :width, value)
|
9
|
+
target.frame = f
|
10
|
+
return CGRectGetMinX(f)
|
11
|
+
end
|
12
|
+
alias left x
|
13
|
+
|
14
|
+
def right(value)
|
15
|
+
f = target.frame
|
16
|
+
f.origin.x = MotionKit.calculate(target, :width, value) - f.size.width
|
17
|
+
target.frame = f
|
18
|
+
return CGRectGetMaxX(f)
|
19
|
+
end
|
20
|
+
|
21
|
+
def center_x(value)
|
22
|
+
c = target.center
|
23
|
+
c.x = MotionKit.calculate(target, :width, value)
|
24
|
+
target.center = c
|
25
|
+
return CGRectGetMidX(target.frame)
|
26
|
+
end
|
27
|
+
alias middle_x center_x
|
28
|
+
|
29
|
+
def y(value)
|
30
|
+
f = target.frame
|
31
|
+
f.origin.y = MotionKit.calculate(target, :height, value)
|
32
|
+
target.frame = f
|
33
|
+
return CGRectGetMinY(f)
|
34
|
+
end
|
35
|
+
alias top y
|
36
|
+
|
37
|
+
def bottom(value)
|
38
|
+
f = target.frame
|
39
|
+
f.origin.y = MotionKit.calculate(target, :height, value) - f.size.height
|
40
|
+
target.frame = f
|
41
|
+
return CGRectGetMaxY(f)
|
42
|
+
end
|
43
|
+
|
44
|
+
def center_y(value)
|
45
|
+
c = target.center
|
46
|
+
c.y = MotionKit.calculate(target, :height, value)
|
47
|
+
target.center = c
|
48
|
+
return CGRectGetMidY(target.frame)
|
49
|
+
end
|
50
|
+
alias middle_y center_y
|
51
|
+
|
52
|
+
def width(value)
|
53
|
+
f = target.frame
|
54
|
+
f.size.width = MotionKit.calculate(target, :width, value)
|
55
|
+
target.frame = f
|
56
|
+
return CGRectGetWidth(f)
|
57
|
+
end
|
58
|
+
alias w width
|
59
|
+
|
60
|
+
def height(value)
|
61
|
+
f = target.frame
|
62
|
+
f.size.height = MotionKit.calculate(target, :height, value)
|
63
|
+
target.frame = f
|
64
|
+
return CGRectGetHeight(f)
|
65
|
+
end
|
66
|
+
alias h height
|
67
|
+
|
68
|
+
def origin(value)
|
69
|
+
f = target.frame
|
70
|
+
f.origin = MotionKit.calculate(target, :origin, value)
|
71
|
+
target.frame = f
|
72
|
+
return target.frame.origin
|
73
|
+
end
|
74
|
+
|
75
|
+
def center(value)
|
76
|
+
target.center = MotionKit.calculate(target, :center, value)
|
77
|
+
return target.center
|
78
|
+
end
|
79
|
+
alias middle center
|
80
|
+
|
81
|
+
def size(value)
|
82
|
+
f = target.frame
|
83
|
+
f.size = MotionKit.calculate(target, :size, value)
|
84
|
+
target.frame = f
|
85
|
+
return target.frame.size
|
86
|
+
end
|
87
|
+
|
88
|
+
def frame(value)
|
89
|
+
target.frame = MotionKit.calculate(target, :frame, value)
|
90
|
+
return target.frame
|
91
|
+
end
|
92
|
+
|
93
|
+
def _calculate_frame(f, from: from_view, relative_to: point)
|
94
|
+
if from_view.is_a?(Symbol)
|
95
|
+
from_view = self.get(from_view)
|
96
|
+
end
|
97
|
+
|
98
|
+
from_view_size = from_view.frame.size
|
99
|
+
o = from_view.convertPoint([0, 0], toView: target.superview)
|
100
|
+
|
101
|
+
calculate_view = target
|
102
|
+
|
103
|
+
if point[:x] == :reset || point[:y] == :reset
|
104
|
+
calculate_view = UIView.alloc.initWithFrame([[0, 0], target.frame.size])
|
105
|
+
end
|
106
|
+
|
107
|
+
if f.is_a?(Hash)
|
108
|
+
f = f.merge(relative: true)
|
109
|
+
end
|
110
|
+
f = MotionKit.calculate(calculate_view, :frame, f, from_view)
|
111
|
+
f.origin.x += o.x
|
112
|
+
f.origin.y += o.y
|
113
|
+
|
114
|
+
case point[:x]
|
115
|
+
when :min, :reset
|
116
|
+
# pass
|
117
|
+
when :mid
|
118
|
+
f.origin.x += (from_view_size.width - f.size.width) / 2.0
|
119
|
+
when :max
|
120
|
+
f.origin.x += from_view_size.width - f.size.width
|
121
|
+
when :before
|
122
|
+
f.origin.x -= f.size.width
|
123
|
+
when :after
|
124
|
+
f.origin.x += from_view_size.width
|
125
|
+
else
|
126
|
+
f.origin.x += point[:x]
|
127
|
+
end
|
128
|
+
|
129
|
+
case point[:y]
|
130
|
+
when :min, :reset
|
131
|
+
# pass
|
132
|
+
when :mid
|
133
|
+
f.origin.y += (from_view_size.height - f.size.height) / 2.0
|
134
|
+
when :max
|
135
|
+
f.origin.y += from_view_size.height - f.size.height
|
136
|
+
when :above
|
137
|
+
f.origin.y -= f.size.height
|
138
|
+
when :below
|
139
|
+
f.origin.y += from_view_size.height
|
140
|
+
else
|
141
|
+
f.origin.y += point[:y]
|
142
|
+
end
|
143
|
+
|
144
|
+
return f
|
145
|
+
end
|
146
|
+
|
147
|
+
# The first arg can be a view or a frame
|
148
|
+
# @example
|
149
|
+
# frame from_top_left(width: 80, height: 22)
|
150
|
+
# frame from_top_left(another_view, width: 80, height: 22)
|
151
|
+
def from_top_left(from_view=nil, f=nil)
|
152
|
+
if from_view.is_a?(Hash)
|
153
|
+
f = from_view
|
154
|
+
from_view = nil
|
155
|
+
end
|
156
|
+
f ||= {}
|
157
|
+
from_view ||= target.superview
|
158
|
+
_calculate_frame(f, from: from_view, relative_to: { x: :min, y: :min })
|
159
|
+
end
|
160
|
+
|
161
|
+
# The first arg can be a view or a frame
|
162
|
+
# @example
|
163
|
+
# frame from_top(width: 80, height: 22)
|
164
|
+
# frame from_top(another_view, width: 80, height: 22)
|
165
|
+
def from_top(from_view=nil, f=nil)
|
166
|
+
if from_view.is_a?(Hash)
|
167
|
+
f = from_view
|
168
|
+
from_view = nil
|
169
|
+
end
|
170
|
+
f ||= {}
|
171
|
+
from_view ||= target.superview
|
172
|
+
_calculate_frame(f, from: from_view, relative_to: { x: :mid, y: :min })
|
173
|
+
end
|
174
|
+
|
175
|
+
# The first arg can be a view or a frame
|
176
|
+
# @example
|
177
|
+
# frame from_top_right(width: 80, height: 22)
|
178
|
+
# frame from_top_right(another_view, width: 80, height: 22)
|
179
|
+
def from_top_right(from_view=nil, f=nil)
|
180
|
+
if from_view.is_a?(Hash)
|
181
|
+
f = from_view
|
182
|
+
from_view = nil
|
183
|
+
end
|
184
|
+
f ||= {}
|
185
|
+
from_view ||= target.superview
|
186
|
+
_calculate_frame(f, from: from_view, relative_to: { x: :max, y: :min })
|
187
|
+
end
|
188
|
+
|
189
|
+
# The first arg can be a view or a frame
|
190
|
+
# @example
|
191
|
+
# frame from_left(width: 80, height: 22)
|
192
|
+
# frame from_left(another_view, width: 80, height: 22)
|
193
|
+
def from_left(from_view=nil, f=nil)
|
194
|
+
if from_view.is_a?(Hash)
|
195
|
+
f = from_view
|
196
|
+
from_view = nil
|
197
|
+
end
|
198
|
+
f ||= {}
|
199
|
+
from_view ||= target.superview
|
200
|
+
_calculate_frame(f, from: from_view, relative_to: { x: :min, y: :mid })
|
201
|
+
end
|
202
|
+
|
203
|
+
# The first arg can be a view or a frame
|
204
|
+
# @example
|
205
|
+
# frame from_center(width: 80, height: 22)
|
206
|
+
# frame from_center(another_view, width: 80, height: 22)
|
207
|
+
def from_center(from_view=nil, f=nil)
|
208
|
+
if from_view.is_a?(Hash)
|
209
|
+
f = from_view
|
210
|
+
from_view = nil
|
211
|
+
end
|
212
|
+
f ||= {}
|
213
|
+
from_view ||= target.superview
|
214
|
+
_calculate_frame(f, from: from_view, relative_to: { x: :mid, y: :mid })
|
215
|
+
end
|
216
|
+
|
217
|
+
# The first arg can be a view or a frame
|
218
|
+
# @example
|
219
|
+
# frame from_right(width: 80, height: 22)
|
220
|
+
# frame from_right(another_view, width: 80, height: 22)
|
221
|
+
def from_right(from_view=nil, f=nil)
|
222
|
+
if from_view.is_a?(Hash)
|
223
|
+
f = from_view
|
224
|
+
from_view = nil
|
225
|
+
end
|
226
|
+
f ||= {}
|
227
|
+
from_view ||= target.superview
|
228
|
+
_calculate_frame(f, from: from_view, relative_to: { x: :max, y: :mid })
|
229
|
+
end
|
230
|
+
|
231
|
+
# The first arg can be a view or a frame
|
232
|
+
# @example
|
233
|
+
# frame from_bottom_left(width: 80, height: 22)
|
234
|
+
# frame from_bottom_left(another_view, width: 80, height: 22)
|
235
|
+
def from_bottom_left(from_view=nil, f=nil)
|
236
|
+
if from_view.is_a?(Hash)
|
237
|
+
f = from_view
|
238
|
+
from_view = nil
|
239
|
+
end
|
240
|
+
f ||= {}
|
241
|
+
from_view ||= target.superview
|
242
|
+
_calculate_frame(f, from: from_view, relative_to: { x: :min, y: :max })
|
243
|
+
end
|
244
|
+
|
245
|
+
# The first arg can be a view or a frame
|
246
|
+
# @example
|
247
|
+
# frame from_bottom(width: 80, height: 22)
|
248
|
+
# frame from_bottom(another_view, width: 80, height: 22)
|
249
|
+
def from_bottom(from_view=nil, f=nil)
|
250
|
+
if from_view.is_a?(Hash)
|
251
|
+
f = from_view
|
252
|
+
from_view = nil
|
253
|
+
end
|
254
|
+
f ||= {}
|
255
|
+
from_view ||= target.superview
|
256
|
+
_calculate_frame(f, from: from_view, relative_to: { x: :mid, y: :max })
|
257
|
+
end
|
258
|
+
|
259
|
+
# The first arg can be a view or a frame
|
260
|
+
# @example
|
261
|
+
# frame from_bottom_right(width: 80, height: 22)
|
262
|
+
# frame from_bottom_right(another_view, width: 80, height: 22)
|
263
|
+
def from_bottom_right(from_view=nil, f=nil)
|
264
|
+
if from_view.is_a?(Hash)
|
265
|
+
f = from_view
|
266
|
+
from_view = nil
|
267
|
+
end
|
268
|
+
f ||= {}
|
269
|
+
from_view ||= target.superview
|
270
|
+
_calculate_frame(f, from: from_view, relative_to: { x: :max, y: :max })
|
271
|
+
end
|
272
|
+
|
273
|
+
# The first arg can be a view or a frame
|
274
|
+
# @example
|
275
|
+
def above(from_view, f={})
|
276
|
+
_calculate_frame(f, from: from_view, relative_to: { x: :reset, y: :above })
|
277
|
+
end
|
278
|
+
|
279
|
+
# The first arg can be a view or a frame
|
280
|
+
# @example
|
281
|
+
def below(from_view, f={})
|
282
|
+
_calculate_frame(f, from: from_view, relative_to: { x: :reset, y: :below })
|
283
|
+
end
|
284
|
+
|
285
|
+
# The first arg can be a view or a frame
|
286
|
+
# @example
|
287
|
+
def before(from_view, f={})
|
288
|
+
_calculate_frame(f, from: from_view, relative_to: { x: :before, y: :reset })
|
289
|
+
end
|
290
|
+
alias left_of before
|
291
|
+
|
292
|
+
# The first arg can be a view or a frame
|
293
|
+
# @example
|
294
|
+
def after(from_view, f={})
|
295
|
+
_calculate_frame(f, from: from_view, relative_to: { x: :after, y: :reset })
|
296
|
+
end
|
297
|
+
alias right_of after
|
298
|
+
|
299
|
+
# The first arg must be a view
|
300
|
+
# @example
|
301
|
+
def relative_to(from_view, f)
|
302
|
+
_calculate_frame(f, from: from_view, relative_to: { x: :reset, y: :reset })
|
303
|
+
end
|
304
|
+
|
305
|
+
override_stop
|
306
|
+
end
|
307
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# @requires MotionKit::UIViewLayout
|
2
|
+
module MotionKit
|
3
|
+
class UIViewLayout
|
4
|
+
|
5
|
+
# gradient colors:
|
6
|
+
def gradient(&block)
|
7
|
+
gradient_layer = target.motion_kit_meta(:motionkit_gradient_layer) || begin
|
8
|
+
gradient_layer = CAGradientLayer.layer
|
9
|
+
gradient_layer.frame = CGRect.new([0, 0], target.frame.size)
|
10
|
+
target.layer.insertSublayer(gradient_layer, atIndex:0)
|
11
|
+
|
12
|
+
gradient_layer
|
13
|
+
end
|
14
|
+
context(gradient_layer, &block)
|
15
|
+
|
16
|
+
gradient_layer
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
class DummyView < NSView
|
2
|
+
private
|
3
|
+
def dummy
|
4
|
+
setFrame(nil)
|
5
|
+
setOpaque(nil)
|
6
|
+
setClipsToBounds(nil)
|
7
|
+
setUserInteractionEnabled(nil)
|
8
|
+
setAutoresizingMask(nil)
|
9
|
+
NSView.appearanceWhenContainedIn(NSView, nil)
|
10
|
+
NSView.appearance
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class DummyTableView < NSTableView
|
15
|
+
private
|
16
|
+
def dummy
|
17
|
+
setAllowSelection(value)
|
18
|
+
setSelectionHighlightStyle(value)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class DummyTableColumn < NSTableColumn
|
23
|
+
private
|
24
|
+
def dummy
|
25
|
+
setEditable(nil)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class DummyButton < NSButton
|
30
|
+
private
|
31
|
+
def dummy
|
32
|
+
setTitleEdgeInsets(nil)
|
33
|
+
setTarget(nil)
|
34
|
+
setAction(nil)
|
35
|
+
setBezelStyle(nil)
|
36
|
+
setBordered(nil)
|
37
|
+
setImagePosition(nil)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class DummyScrollView < NSScrollView
|
42
|
+
private
|
43
|
+
def dummy
|
44
|
+
setScrollEnabled(nil)
|
45
|
+
setHasVerticalScroller(nil)
|
46
|
+
setHasHorizontalScroller(nil)
|
47
|
+
setDocumentView(nil)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class DummyTextField < NSTextField
|
52
|
+
private
|
53
|
+
def dummy
|
54
|
+
setAdjustsFontSizeToFitWidth(nil)
|
55
|
+
setFormatter(nil)
|
56
|
+
setBezeled(nil)
|
57
|
+
setBezelStyle(nil)
|
58
|
+
setDrawsBackground(nil)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
class DummyTextView < NSTextView
|
63
|
+
private
|
64
|
+
def dummy
|
65
|
+
setSecureTextEntry(nil)
|
66
|
+
setReturnKeyType(nil)
|
67
|
+
setAutocapitalizationType(nil)
|
68
|
+
setAutocorrectionType(nil)
|
69
|
+
setSpellCheckingType(nil)
|
70
|
+
setDrawsBackground(nil)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
class DummyLayer < CALayer
|
75
|
+
private
|
76
|
+
def dummy
|
77
|
+
setCornerRadius(nil)
|
78
|
+
setTransform(nil)
|
79
|
+
setMasksToBounds(nil)
|
80
|
+
setShadowOffset(nil)
|
81
|
+
setShadowOpacity(nil)
|
82
|
+
setShadowRadius(nil)
|
83
|
+
setShadowOffset(nil)
|
84
|
+
setShadowColor(nil)
|
85
|
+
setShadowPath(nil)
|
86
|
+
setOpaque(nil)
|
87
|
+
setTranslucent(nil)
|
88
|
+
end
|
89
|
+
end
|