lib/shoes/swt/common/fill.rb in shoes-swt-4.0.0.pre3 vs lib/shoes/swt/common/fill.rb in shoes-swt-4.0.0.pre4

- old
+ new

@@ -7,12 +7,14 @@ module Fill # This object's fill color # # @return [Swt::Graphics::Color] The Swt representation of this object's fill color def fill + return @cached_swt_fill if @cached_swt_fill + @color_factory ||= ::Shoes::Swt::ColorFactory.new - @color_factory.create(dsl.fill) + @cached_swt_fill = @color_factory.create(dsl.fill) end # This object's fill alpha value # # @return [Integer] The alpha value of this object's fill color (0-255) @@ -23,13 +25,17 @@ # @return [Integer] the angle to use when filling with a pattern def angle @angle || 0 end + # Just clear it out and let next paint recreate and save our SWT color + def update_fill + @cached_swt_fill = nil + end + def apply_fill(context) if fill - left, top = self.is_a?(Star) ? [element_left - element_width / 2.0, element_top - element_height / 2.0] : [element_left, element_top] - fill.apply_as_fill(context, left, top, element_width, element_height, angle) + fill.apply_as_fill(context, self) true end end end end