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_frame_for
Methods inherited from BaseElement
#add_target, after_render, before_render, #cell_element?, #cell_section?, #compute_options!, #computed_options, #dealloc, #initialize, #notify_section_after_render, #notify_section_before_render, #reload!, #render, #update, #update_options, #update_with_options
#camelize_factory, #class_factory, #low_camelize_factory, #underscore_factory
#extract_font_from
#build_styles_chain
#debug_info, #element?, #normalize_object, #normalize_options, #normalize_value
Class Method Details
.factory(type, options = {}) ⇒ Object
106
107
108
109
|
# File 'motion-prime/elements/draw.rb', line 106
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, target = nil) ⇒ Object
58
59
60
61
|
# File 'motion-prime/elements/draw.rb', line 58
def bind_gesture(action, receiver = nil, target = nil)
target ||= section
target.bind_gesture_on_container_for(self, action, receiver.weak_ref)
end
|
#computed_frame ⇒ Object
50
51
52
|
# File 'motion-prime/elements/draw.rb', line 50
def computed_frame
@computed_frame ||= calculate_frame_for(view.try(:bounds) || section.container_bounds, computed_options)
end
|
#default_padding_for(side) ⇒ Object
54
55
56
|
# File 'motion-prime/elements/draw.rb', line 54
def default_padding_for(side)
0
end
|
#draw_in(rect) ⇒ Object
32
33
34
35
36
37
|
# File 'motion-prime/elements/draw.rb', line 32
def draw_in(rect)
if @_prev_rect_size && @_prev_rect_size != rect.size
reset_computed_values
end
@_prev_rect_size = rect.size
end
|
#draw_options ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'motion-prime/elements/draw.rb', line 10
def draw_options
options = computed_options
background_color = options[:background_color].try(:uicolor)
layer_options = options[:layer] || {}
corner_radius = layer_options[:corner_radius].to_f
layer_options.delete(:masks_to_bounds) if layer_options[:masks_to_bounds].nil?
options.delete(:clips_to_bounds) if options[:clips_to_bounds].nil?
masks_to_bounds = layer_options.fetch(:masks_to_bounds, options.fetch(:clips_to_bounds, corner_radius > 0))
{
rect: CGRectMake(frame_left, frame_top, frame_outer_width, frame_outer_height),
background_color: background_color,
masks_to_bounds: masks_to_bounds,
corner_radius: corner_radius,
rounded_corners: layer_options[:rounded_corners],
border_width: layer_options[:border_width].to_f,
border_color: layer_options[:border_color].try(:uicolor) || background_color,
border_sides: layer_options[:border_sides],
dashes: layer_options[:dashes]
}
end
|
#hide ⇒ Object
63
64
65
66
67
|
# File 'motion-prime/elements/draw.rb', line 63
def hide
return if computed_options[:hidden]
computed_options[:hidden] = true
rerender!
end
|
#on_container_render ⇒ Object
41
42
43
44
|
# File 'motion-prime/elements/draw.rb', line 41
def on_container_render
@view = nil
@computed_frame = nil
end
|
#render! ⇒ Object
39
|
# File 'motion-prime/elements/draw.rb', line 39
def render!; end
|
#rerender!(changed_options = []) ⇒ Object
75
76
77
78
79
|
# File 'motion-prime/elements/draw.rb', line 75
def rerender!(changed_options = [])
@_original_options = nil
section.cached_draw_image = nil
view.try(:setNeedsDisplay)
end
|
#show ⇒ Object
69
70
71
72
73
|
# File 'motion-prime/elements/draw.rb', line 69
def show
return if !computed_options[:hidden]
computed_options[:hidden] = false
rerender!
end
|
#view ⇒ Object
46
47
48
|
# File 'motion-prime/elements/draw.rb', line 46
def view
@view ||= section.container_view
end
|