lib/glimmer/swt/custom/shape/rectangle.rb in glimmer-dsl-swt-4.18.7.2 vs lib/glimmer/swt/custom/shape/rectangle.rb in glimmer-dsl-swt-4.18.7.3
- old
+ new
@@ -21,31 +21,21 @@
require 'glimmer/swt/custom/shape'
require 'glimmer/swt/swt_proxy'
require 'glimmer/swt/display_proxy'
require 'glimmer/swt/color_proxy'
-require 'glimmer/swt/font_proxy'
require 'glimmer/swt/transform_proxy'
module Glimmer
module SWT
module Custom
# Represents a shape (graphics) to be drawn on a control/widget/canvas/display
# That is because Shape is drawn on a parent as graphics and doesn't have an SWT widget for itself
class Shape
class Rectangle < Shape
def parameter_names
- # TODO consider optimizing just like text where it is set upon updating attribute and here you just return a variable
- if @args.to_a.size >= 6
- rectangle_round_parameter_names
- elsif @args.to_a.size == 5
- rectangle_gradient_parameter_names
- elsif @args.to_a.size == 1
- rectangle_rectangle_parameter_names
- else
- rectangle_parameter_names
- end
+ @parameter_names || rectangle_parameter_names
end
def possible_parameter_names
# TODO refactor and improve this method through meta-programming (and share across other shapes)
(rectangle_round_parameter_names + rectangle_gradient_parameter_names + rectangle_parameter_names + rectangle_rectangle_parameter_names).uniq
@@ -66,20 +56,21 @@
def rectangle_rectangle_parameter_names
# this receives a Rectangle object
[:rectangle]
end
- def parameter_index(attribute_name)
- ####TODO refactor and improve this method through meta-programming (and share across other shapes)
- if rectangle_round_parameter_names.map(&:to_s).include?(attribute_name.to_s)
- rectangle_round_parameter_names.map(&:to_s).index(attribute_name.to_s)
+ def set_parameter_attribute(attribute_name, *args)
+ return super if @parameter_names.to_a.map(&:to_s).include?(attribute_name.to_s)
+ if rectangle_parameter_names.map(&:to_s).include?(attribute_name.to_s)
+ @parameter_names = rectangle_parameter_names
+ elsif rectangle_round_parameter_names.map(&:to_s).include?(attribute_name.to_s)
+ @parameter_names = rectangle_round_parameter_names
elsif rectangle_gradient_parameter_names.map(&:to_s).include?(attribute_name.to_s)
- rectangle_gradient_parameter_names.map(&:to_s).index(attribute_name.to_s)
- elsif rectangle_parameter_names.map(&:to_s).include?(attribute_name.to_s)
- rectangle_parameter_names.map(&:to_s).index(attribute_name.to_s)
+ @parameter_names = rectangle_gradient_parameter_names
elsif rectangle_rectangle_parameter_names.map(&:to_s).include?(attribute_name.to_s)
- rectangle_rectangle_parameter_names.map(&:to_s).index(attribute_name.to_s)
+ @parameter_names = rectangle_rectangle_parameter_names
end
+ super
end
def point_xy_array
[[x, y], [x + calculated_width, y], [x + calculated_width, y + calculated_height], [x, y + calculated_height]]
end