Module: MotionKit
- Defined in:
- lib/motion-kit/motion-kit.rb,
lib/motion-kit/util.rb,
lib/motion-kit/version.rb,
lib/motion-kit-ios/ios_util.rb,
lib/motion-kit-osx/osx_util.rb,
lib/motion-kit-tvos/ios_util.rb,
lib/motion-kit-ios/deprecated.rb,
lib/motion-kit-osx/deprecated.rb,
lib/motion-kit/helpers/parent.rb,
lib/motion-kit-tvos/deprecated.rb,
lib/motion-kit-cocoa/cocoa_util.rb,
lib/motion-kit/helpers/base_layout.rb,
lib/motion-kit/helpers/tree_layout.rb,
lib/motion-kit/calculator/calculate.rb,
lib/motion-kit/calculator/calculator.rb,
lib/motion-kit-ios/helpers/layout_device.rb,
lib/motion-kit-ios/helpers/uiview_helpers.rb,
lib/motion-kit-osx/helpers/nsmenu_helpers.rb,
lib/motion-kit-osx/helpers/nsview_helpers.rb,
lib/motion-kit-tvos/helpers/layout_device.rb,
lib/motion-kit/calculator/size_calculator.rb,
lib/motion-kit-tvos/helpers/uiview_helpers.rb,
lib/motion-kit/calculator/frame_calculator.rb,
lib/motion-kit-cocoa/constraints/constraint.rb,
lib/motion-kit-ios/helpers/uibutton_helpers.rb,
lib/motion-kit-osx/helpers/nswindow_helpers.rb,
lib/motion-kit/calculator/origin_calculator.rb,
lib/motion-kit-cocoa/helpers/calayer_helpers.rb,
lib/motion-kit-osx/helpers/nsmenu_extensions.rb,
lib/motion-kit-tvos/helpers/uibutton_helpers.rb,
lib/motion-kit-cocoa/helpers/sugarcube_compat.rb,
lib/motion-kit-ios/helpers/layout_orientation.rb,
lib/motion-kit-ios/helpers/constraints_helpers.rb,
lib/motion-kit-osx/helpers/constraints_helpers.rb,
lib/motion-kit-osx/helpers/nstableview_helpers.rb,
lib/motion-kit-tvos/helpers/layout_orientation.rb,
lib/motion-kit-cocoa/calculator/view_calculator.rb,
lib/motion-kit-ios/helpers/uiview_frame_helpers.rb,
lib/motion-kit-osx/helpers/nsview_frame_helpers.rb,
lib/motion-kit-tvos/helpers/constraints_helpers.rb,
lib/motion-kit-cocoa/constraints/size_constraint.rb,
lib/motion-kit-osx/helpers/nsmenuitem_extensions.rb,
lib/motion-kit-osx/helpers/nstablecolumn_helpers.rb,
lib/motion-kit-tvos/helpers/uiview_frame_helpers.rb,
lib/motion-kit/helpers/base_layout_class_methods.rb,
lib/motion-kit-cocoa/constraints/point_constraint.rb,
lib/motion-kit-cocoa/helpers/accessibility_compat.rb,
lib/motion-kit-osx/helpers/nswindow_frame_helpers.rb,
lib/motion-kit-cocoa/helpers/calayer_frame_helpers.rb,
lib/motion-kit-ios/helpers/uiview_gradient_helpers.rb,
lib/motion-kit-cocoa/constraints/constraints_target.rb,
lib/motion-kit-tvos/helpers/uiview_gradient_helpers.rb,
lib/motion-kit-cocoa/constraints/constraints_helpers.rb,
lib/motion-kit-cocoa/helpers/cagradientlayer_helpers.rb,
lib/motion-kit-ios/helpers/uiview_constraints_helpers.rb,
lib/motion-kit-osx/helpers/nsview_constraints_helpers.rb,
lib/motion-kit-ios/helpers/uiview_autoresizing_helpers.rb,
lib/motion-kit-osx/helpers/nsview_autoresizing_helpers.rb,
lib/motion-kit-tvos/helpers/uiview_constraints_helpers.rb,
lib/motion-kit-tvos/helpers/uiview_autoresizing_helpers.rb
Defined Under Namespace
Modules: BaseLayoutClassMethods, FrameCalculator, OriginCalculator, SizeCalculator
Classes: ApplyError, BaseLayout, CAGradientLayerHelpers, CAGradientLayerLayout, CALayerHelpers, CALayerLayout, Calculator, CompoundConstraint, Constraint, ConstraintsHelpers, ConstraintsTarget, ContextConflictError, InvalidAttributeError, InvalidDeferredError, InvalidPriorityError, InvalidRelationshipError, InvalidRootError, Layout, MenuLayout, NSMenuHelpers, NSMenuLayout, NSTableColumnHelpers, NSTableColumnLayout, NSTableViewHelpers, NSTableViewLayout, NSViewHelpers, NSViewLayout, NSWindowHelpers, NSWindowLayout, NoCommonAncestorError, NoContextError, NoSuperviewError, Parent, PointConstraint, SizeConstraint, TreeLayout, UIButtonHelpers, UIButtonLayout, UIViewHelpers, UIViewLayout, ViewCalculator, WindowLayout
Constant Summary
collapse
- VERSION =
'1.1.0'
Class Method Summary
collapse
Class Method Details
.appearance_class ⇒ Object
20
21
22
|
# File 'lib/motion-kit/util.rb', line 20
def appearance_class
@appearance_class ||= Class.new
end
|
.base_view_class ⇒ Object
8
9
10
|
# File 'lib/motion-kit-ios/ios_util.rb', line 8
def base_view_class
UIView
end
|
.calculate(view, dimension, amount, full_view = nil) ⇒ Object
5
6
7
|
# File 'lib/motion-kit/calculator/calculate.rb', line 5
def calculate(view, dimension, amount, full_view=nil)
ViewCalculator.calculate(view, dimension, amount, full_view)
end
|
.camel_case(str) ⇒ Object
8
9
10
|
# File 'lib/motion-kit/util.rb', line 8
def camel_case(str)
str.split('_').map(&:capitalize).join
end
|
.children(view) ⇒ Object
13
14
15
16
17
18
19
20
|
# File 'lib/motion-kit-cocoa/cocoa_util.rb', line 13
def children(view)
case view
when CALayer
view.sublayers
else
view.subviews
end
end
|
.color_class ⇒ Object
16
17
18
|
# File 'lib/motion-kit-ios/ios_util.rb', line 16
def color_class
UIColor
end
|
.default_view_class ⇒ Object
12
13
14
|
# File 'lib/motion-kit-ios/ios_util.rb', line 12
def default_view_class
UIView
end
|
.nearest(view, skip = nil, &test) ⇒ Object
-
check view
-
check subviews (unless ‘skip’ is provided)
-
check siblings (skipping ‘view’)
-
go up to parent and repeat, skipping children
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/motion-kit-cocoa/cocoa_util.rb', line 35
def nearest(view, skip=nil, &test)
return nil if view.nil?
if test.call(view)
return view
end
children = MotionKit.children(view)
siblings = MotionKit.siblings(view)
parent = MotionKit.parent(view)
found = nil
if !skip || skip == parent
children.each do |child|
found = nearest(child, &test)
break if found
end
return found if found
end
unless skip == parent
siblings.each do |sibling|
found = (sibling != view && nearest(sibling, parent, &test))
break if found
end
end
if found
found
elsif skip != parent
nearest(parent, true, &test)
end
end
|
.no_intrinsic_metric ⇒ Object
20
21
22
|
# File 'lib/motion-kit-ios/ios_util.rb', line 20
def no_intrinsic_metric
UIViewNoIntrinsicMetric
end
|
.objective_c_method_name(str) ⇒ Object
4
5
6
|
# File 'lib/motion-kit/util.rb', line 4
def objective_c_method_name(str)
str.split('_').inject([]) { |buffer,e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
end
|
.parent(view) ⇒ Object
22
23
24
25
26
27
28
29
|
# File 'lib/motion-kit-cocoa/cocoa_util.rb', line 22
def parent(view)
case view
when CALayer
view.superlayer
else
view.superview
end
end
|
.setter(method_name) ⇒ Object
12
13
14
15
16
17
18
|
# File 'lib/motion-kit/util.rb', line 12
def setter(method_name)
setter = "set#{method_name[0].capitalize}#{method_name[1..-1]}"
unless setter.end_with?(':')
setter << ':'
end
setter
end
|
.siblings(view) ⇒ Object
4
5
6
7
8
9
10
11
|
# File 'lib/motion-kit-cocoa/cocoa_util.rb', line 4
def siblings(view)
case view
when CALayer
view.superlayer ? view.superlayer.sublayers : []
else
view.superview ? view.superview.subviews : []
end
end
|