Sha256: 3568cfa585e85e1e38e69c09bbae08156dc58d250dc4d4651d024fceaa924245

Contents?: true

Size: 1.13 KB

Versions: 5

Compression:

Stored size: 1.13 KB

Contents

class Shoes
  module Swt
    module Common
      # Methods for retrieving fill values from a Shoes DSL class
      #
      # @note Including classes must provide `#dsl`
      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
          @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)
        def fill_alpha
          fill.alpha
        end

        # @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
            fill.apply_as_fill(context, self)
            true
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
shoes-swt-4.0.0.pre8 lib/shoes/swt/common/fill.rb
shoes-swt-4.0.0.pre7 lib/shoes/swt/common/fill.rb
shoes-swt-4.0.0.pre6 lib/shoes/swt/common/fill.rb
shoes-swt-4.0.0.pre5 lib/shoes/swt/common/fill.rb
shoes-swt-4.0.0.pre4 lib/shoes/swt/common/fill.rb