Sha256: 925e403a4896653513b29362a80d383226b53290895f2db8205a228b7ccb19ec

Contents?: true

Size: 766 Bytes

Versions: 4

Compression:

Stored size: 766 Bytes

Contents

require 'glimmer/dsl/expression'
require 'glimmer/swt/color_proxy'
require 'glimmer/swt/display_proxy'

# TODO consider turning static keywords like rgba/rgb into methods
# Support color keyword

module Glimmer
  module DSL
    class ColorExpression < Expression
      include_package 'org.eclipse.swt.widgets'

      def can_interpret?(parent, keyword, *args, &block)
        ['color', 'rgba', 'rgb'].include?(keyword) and
          (1..4).include?(args.count)
      end

      def interpret(parent, keyword, *args, &block)
        if args.first.is_a?(Display) or args.first.nil?
          display = args.delete_at(0)
        else
          display = SWT::DisplayProxy.instance.swt_display
        end
        SWT::ColorProxy.new(*args)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
glimmer-0.5.4 lib/glimmer/dsl/color_expression.rb
glimmer-0.5.3 lib/glimmer/dsl/color_expression.rb
glimmer-0.5.2 lib/glimmer/dsl/color_expression.rb
glimmer-0.5.0 lib/glimmer/dsl/color_expression.rb