Sha256: 5a83b0c16f1ba08882cbd5d2b7449a8a553645e1a1e6977a9857c93f712363dc

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true
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

4 entries across 4 versions & 1 rubygems

Version Path
shoes-swt-4.0.0.pre12 lib/shoes/swt/common/fill.rb
shoes-swt-4.0.0.pre11 lib/shoes/swt/common/fill.rb
shoes-swt-4.0.0.pre10 lib/shoes/swt/common/fill.rb
shoes-swt-4.0.0.pre9 lib/shoes/swt/common/fill.rb