Class: Glimmer::LibUI::Shape::CompositeShape
Constant Summary
KEYWORD_ALIASES
Instance Attribute Summary
#args, #block, #content_added, #keyword, #parent
Instance Method Summary
collapse
#absolute_c1_x, #absolute_c1_y, #absolute_c2_x, #absolute_c2_y, #absolute_end_x, #absolute_end_y, #absolute_point_array, #absolute_x, #absolute_x_center, #absolute_y, #absolute_y_center, #area_proxy, #can_handle_listener?, #composite_shape, constant_symbol, #content, create, #destroy, exists?, #fill, #handle_listener, #implicit_path?, #initialize, #method_missing, parameter_defaults, parameters, #path_proxy, #post_add_content, #post_initialize_child, #redraw, #request_auto_redraw, #respond_to?, shape_class, #stroke
#data_bind, #data_bind_read, #data_bind_write, #data_binding_model_attribute_observer_registrations
#bounding_box, #move, #perfect_shape_dependencies
Methods included from Parent
#children, #post_initialize_child
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Glimmer::LibUI::Shape
Instance Method Details
#contain?(*point, outline: false, distance_tolerance: 0) ⇒ Boolean
69
70
71
|
# File 'lib/glimmer/libui/shape/composite_shape.rb', line 69
def contain?(*point, outline: false, distance_tolerance: 0)
children.any? { |child| child.contain?(*point, outline: outline, distance_tolerance: distance_tolerance) }
end
|
#draw(area_draw_params) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/glimmer/libui/shape/composite_shape.rb', line 32
def draw(area_draw_params)
children.each do |child|
child_fill = child.fill
child_stroke = child.stroke
child_transform = child.transform
child.fill = fill if Glimmer::LibUI.blank_color?(child.fill)
child.stroke = stroke if Glimmer::LibUI.blank_color?(child.stroke)
child.transform = transform if child.transform.nil?
child.move_by(x, y)
begin
child.draw(area_draw_params)
rescue Exception => e
raise e
ensure
child.move_by(-x, -y)
child.transform = child_transform
child.stroke = Glimmer::LibUI.blank_color?(child_stroke) ? Glimmer::LibUI.blank_color : child_stroke
child.fill = Glimmer::LibUI.blank_color?(child_fill) ? Glimmer::LibUI.blank_color : child_fill
end
end
super
end
|
#include?(*point) ⇒ Boolean
73
74
75
|
# File 'lib/glimmer/libui/shape/composite_shape.rb', line 73
def include?(*point)
children.any? { |child| child.include?(*point) }
end
|
#move_by(x_delta, y_delta) ⇒ Object
64
65
66
67
|
# File 'lib/glimmer/libui/shape/composite_shape.rb', line 64
def move_by(x_delta, y_delta)
self.x += x_delta
self.y += y_delta
end
|
#perfect_shape ⇒ Object
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/glimmer/libui/shape/composite_shape.rb', line 89
def perfect_shape
require 'perfect-shape'
perfect_shape_dependencies = [x, y, children.map(&:perfect_shape_dependencies)]
if perfect_shape_dependencies != @perfect_shape_dependencies
x, y, _ = @perfect_shape_dependencies = perfect_shape_dependencies
shapes = children.map(&:perfect_shape)
@perfect_shape = PerfectShape::CompositeShape.new(shapes: shapes)
end
@perfect_shape
end
|
#relative_point(*point) ⇒ Object
85
86
87
|
# File 'lib/glimmer/libui/shape/composite_shape.rb', line 85
def relative_point(*point)
[relative_x(point.first), relative_y(point.last)]
end
|
#relative_x(x) ⇒ Object
77
78
79
|
# File 'lib/glimmer/libui/shape/composite_shape.rb', line 77
def relative_x(x)
self.x + x
end
|
#relative_y(y) ⇒ Object
81
82
83
|
# File 'lib/glimmer/libui/shape/composite_shape.rb', line 81
def relative_y(y)
self.y + y
end
|
56
57
58
59
60
61
62
|
# File 'lib/glimmer/libui/shape/composite_shape.rb', line 56
def transform(matrix = nil)
if matrix.nil?
@matrix
else
@matrix = matrix
end
end
|