Sha256: 091ac781abe7770b79f6babab604a9d033fbb39a62595c230e01a1711d50e3ff

Contents?: true

Size: 1.27 KB

Versions: 5

Compression:

Stored size: 1.27 KB

Contents

class Shoes
  module Swt
    module Common
      # Methods for retrieving stroke values from a Shoes DSL class
      #
      # @note Including classes must provide `#dsl`
      module Stroke
        # This object's stroke color
        #
        # @return [Swt::Graphics::Color] The Swt representation of this object's stroke color
        def stroke
          return @cached_swt_stroke if @cached_swt_stroke

          @color_factory ||= ::Shoes::Swt::ColorFactory.new
          @cached_swt_stroke = @color_factory.create(dsl.stroke)
        end

        # This object's stroke alpha value
        #
        # @return [Integer] The alpha value of this object's stroke color (0-255)
        def stroke_alpha
          dsl.stroke.alpha if dsl.stroke
        end

        # This object's strokewidth
        #
        # @return [Integer] This object's strokewidth
        def strokewidth
          dsl.strokewidth
        end

        # Just clear it out and let next paint recreate and save our SWT color
        def update_stroke
          @cached_swt_stroke = nil
        end

        def apply_stroke(context)
          if stroke
            stroke.apply_as_stroke(context, self)
            context.set_line_width strokewidth
            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/stroke.rb
shoes-swt-4.0.0.pre7 lib/shoes/swt/common/stroke.rb
shoes-swt-4.0.0.pre6 lib/shoes/swt/common/stroke.rb
shoes-swt-4.0.0.pre5 lib/shoes/swt/common/stroke.rb
shoes-swt-4.0.0.pre4 lib/shoes/swt/common/stroke.rb