Class: MotionPrime::DrawElement
Instance Attribute Summary
Attributes inherited from BaseElement
#name, #options, #screen, #section, #styles, #view_class, #view_name
Class Method Summary
collapse
Instance Method Summary
collapse
#cached_content_outer_height, #cached_content_outer_width, #content_outer_height, #content_outer_width, #content_padding_bottom, #content_padding_height, #content_padding_left, #content_padding_right, #content_padding_top, #content_padding_width
#calculate_frome_for
Methods inherited from BaseElement
#add_target, after_render, before_render, #compute_options!, #computed_options, #initialize, #render
#camelize_factory, #class_factory, #low_camelize_factory
#build_styles_chain
#normalize_object, #normalize_options
Class Method Details
.factory(type, options = {}) ⇒ Object
96
97
98
99
|
# File 'motion-prime/elements/draw.rb', line 96
def factory(type, options = {})
return unless %w[view label image].include?(type.to_s.downcase)
class_factory("#{type}_draw_element", true).new(options)
end
|
Instance Method Details
#bind_gesture(action, receiver = nil) ⇒ Object
63
64
65
|
# File 'motion-prime/elements/draw.rb', line 63
def bind_gesture(action, receiver = nil)
section.bind_gesture_on_container_for(self, action, receiver)
end
|
#computed_bottom ⇒ Object
57
|
# File 'motion-prime/elements/draw.rb', line 57
def computed_bottom; computed_top + computed_outer_height end
|
#computed_frame ⇒ Object
29
30
31
|
# File 'motion-prime/elements/draw.rb', line 29
def computed_frame
@computed_frame ||= calculate_frome_for(view.try(:bounds) || section.container_bounds, computed_options)
end
|
#computed_height ⇒ Object
49
|
# File 'motion-prime/elements/draw.rb', line 49
def computed_height; computed_outer_height - content_padding_height end
|
#computed_inner_bottom ⇒ Object
58
|
# File 'motion-prime/elements/draw.rb', line 58
def computed_inner_bottom; computed_bottom - content_padding_bottom end
|
#computed_inner_left ⇒ Object
55
|
# File 'motion-prime/elements/draw.rb', line 55
def computed_inner_left; computed_left + content_padding_left end
|
#computed_inner_right ⇒ Object
61
|
# File 'motion-prime/elements/draw.rb', line 61
def computed_inner_right; computed_right - content_padding_right end
|
#computed_inner_top ⇒ Object
52
|
# File 'motion-prime/elements/draw.rb', line 52
def computed_inner_top; computed_top + content_padding_top end
|
#computed_left ⇒ Object
54
|
# File 'motion-prime/elements/draw.rb', line 54
def computed_left; computed_frame.origin.x end
|
#computed_max_height ⇒ Object
41
42
43
|
# File 'motion-prime/elements/draw.rb', line 41
def computed_max_height
view.bounds.size.height
end
|
#computed_max_width ⇒ Object
37
38
39
|
# File 'motion-prime/elements/draw.rb', line 37
def computed_max_width
view.bounds.size.width
end
|
#computed_outer_height ⇒ Object
48
|
# File 'motion-prime/elements/draw.rb', line 48
def computed_outer_height; computed_frame.size.height end
|
#computed_outer_width ⇒ Object
45
|
# File 'motion-prime/elements/draw.rb', line 45
def computed_outer_width; computed_frame.size.width end
|
#computed_right ⇒ Object
60
|
# File 'motion-prime/elements/draw.rb', line 60
def computed_right; computed_left + computed_width end
|
#computed_top ⇒ Object
51
|
# File 'motion-prime/elements/draw.rb', line 51
def computed_top; computed_frame.origin.y end
|
#computed_width ⇒ Object
46
|
# File 'motion-prime/elements/draw.rb', line 46
def computed_width; computed_outer_width - content_padding_width end
|
#default_padding_for(side) ⇒ Object
33
34
35
|
# File 'motion-prime/elements/draw.rb', line 33
def default_padding_for(side)
0
end
|
#draw_options ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'motion-prime/elements/draw.rb', line 10
def draw_options
options = computed_options
background_color = options[:background_color].try(:uicolor)
{
rect: CGRectMake(computed_left, computed_top, computed_outer_width, computed_outer_height),
background_color: background_color,
masks_to_bounds: options[:layer].try(:[], :masks_to_bounds) || options[:clips_to_bounds],
corner_radius: options[:layer].try(:[], :corner_radius).to_f,
border_width: options[:layer].try(:[], :border_width).to_f,
border_color: options[:layer].try(:[], :border_color).try(:uicolor) || background_color
}
end
|
#hide ⇒ Object
67
68
69
70
71
72
|
# File 'motion-prime/elements/draw.rb', line 67
def hide
return if computed_options[:hidden]
computed_options[:hidden] = true
section.cached_draw_image = nil
view.setNeedsDisplay
end
|
#render! ⇒ Object
23
|
# File 'motion-prime/elements/draw.rb', line 23
def render!; end
|
#show ⇒ Object
74
75
76
77
78
79
|
# File 'motion-prime/elements/draw.rb', line 74
def show
return if !computed_options[:hidden]
computed_options[:hidden] = false
section.cached_draw_image = nil
view.setNeedsDisplay
end
|
#update_with_options(new_options = {}) ⇒ Object
81
82
83
84
85
86
|
# File 'motion-prime/elements/draw.rb', line 81
def update_with_options(new_options = {})
options.merge!(new_options)
compute_options!
section.cached_draw_image = nil
view.setNeedsDisplay
end
|
#view ⇒ Object
25
26
27
|
# File 'motion-prime/elements/draw.rb', line 25
def view
@view ||= section.container_view
end
|