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, #reload!, #render, #update, #update_options, #update_with_options
#camelize_factory, #class_factory, #low_camelize_factory
#build_styles_chain
#debug_info, #element?, #normalize_object, #normalize_options, #normalize_value
Class Method Details
.factory(type, options = {}) ⇒ Object
84
85
86
87
|
# File 'motion-prime/elements/draw.rb', line 84
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
37
38
39
40
|
# File 'motion-prime/elements/draw.rb', line 37
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
29
30
31
|
# File 'motion-prime/elements/draw.rb', line 29
def computed_frame
@computed_frame ||= calculate_frame_for(view.try(:bounds) || section.container_bounds, computed_options)
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(frame_left, frame_top, frame_outer_width, frame_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
42
43
44
45
46
|
# File 'motion-prime/elements/draw.rb', line 42
def hide
return if computed_options[:hidden]
computed_options[:hidden] = true
rerender!
end
|
#render! ⇒ Object
23
|
# File 'motion-prime/elements/draw.rb', line 23
def render!; end
|
#rerender! ⇒ Object
54
55
56
57
|
# File 'motion-prime/elements/draw.rb', line 54
def rerender!
section.cached_draw_image = nil
view.try(:setNeedsDisplay)
end
|
#show ⇒ Object
48
49
50
51
52
|
# File 'motion-prime/elements/draw.rb', line 48
def show
return if !computed_options[:hidden]
computed_options[:hidden] = false
rerender!
end
|
#view ⇒ Object
25
26
27
|
# File 'motion-prime/elements/draw.rb', line 25
def view
@view ||= section.container_view
end
|