Sha256: 0f27933d4e7ee4fa695da1b7b7c2cba8cda619c020bdd9ed0c100fa2ddeb0be8

Contents?: true

Size: 734 Bytes

Versions: 5

Compression:

Stored size: 734 Bytes

Contents

class Shoes
  module Swt
    class ImagePattern
      include Common::Remove

      def initialize(dsl)
        @dsl = dsl
      end

      def dispose
        @image.dispose if @image
        @pattern.dispose if @pattern
      end

      # Since colors are bound up (at least in specs) with image patterns,
      # we can't safely touch images during initialize, so lazily load them.
      def pattern
        @image   ||= ::Swt::Image.new(Shoes.display, @dsl.path)
        @pattern ||= ::Swt::Pattern.new(Shoes.display, @image)
      end

      def apply_as_fill(gc, _dsl)
        gc.set_background_pattern pattern
      end

      def apply_as_stroke(gc, _dsl)
        gc.set_foreground_pattern pattern
      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/image_pattern.rb
shoes-swt-4.0.0.pre7 lib/shoes/swt/image_pattern.rb
shoes-swt-4.0.0.pre6 lib/shoes/swt/image_pattern.rb
shoes-swt-4.0.0.pre5 lib/shoes/swt/image_pattern.rb
shoes-swt-4.0.0.pre4 lib/shoes/swt/image_pattern.rb