Sha256: f43699db6506d487d739ea9376620d82e778e29b95371f72c236cc67206df465

Contents?: true

Size: 764 Bytes

Versions: 1

Compression:

Stored size: 764 Bytes

Contents

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

1 entries across 1 versions & 1 rubygems

Version Path
shoes-swt-4.0.0.pre9 lib/shoes/swt/image_pattern.rb