Class: Glimmer::DSL::SWT::ImageExpression
- Inherits:
-
Expression
- Object
- Expression
- Glimmer::DSL::SWT::ImageExpression
- Includes:
- ParentExpression, TopLevelExpression
- Defined in:
- lib/glimmer/dsl/swt/image_expression.rb
Overview
image expression Note: Cannot be a static expression because it clashes with image property expression
Instance Method Summary collapse
- #add_content(parent, keyword, *args, &block) ⇒ Object
- #can_interpret?(parent, keyword, *args, &block) ⇒ Boolean
- #interpret(parent, keyword, *args, &block) ⇒ Object
Instance Method Details
#add_content(parent, keyword, *args, &block) ⇒ Object
60 61 62 63 64 |
# File 'lib/glimmer/dsl/swt/image_expression.rb', line 60 def add_content(parent, keyword, *args, &block) return if @create_pixel_by_pixel || block&.parameters&.count == 2 super parent.post_add_content end |
#can_interpret?(parent, keyword, *args, &block) ⇒ Boolean
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/glimmer/dsl/swt/image_expression.rb', line 36 def can_interpret?(parent, keyword, *args, &block) = args.last.is_a?(Hash) ? args.last : {} (keyword == 'image') and ( .keys.include?(:top_level) or ( !parent.is_a?(Glimmer::SWT::Custom::Shape) and (parent.nil? or parent.respond_to?('image=') or args.first.is_a?(Numeric)) ) ) end |
#interpret(parent, keyword, *args, &block) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/glimmer/dsl/swt/image_expression.rb', line 48 def interpret(parent, keyword, *args, &block) = args.last.is_a?(Hash) ? args.last : {} coordinate_args = args.size == (.empty? ? 2 : 3) args.unshift(parent) unless parent.nil? || [:top_level] @create_pixel_by_pixel = coordinate_args && block&.parameters&.count == 2 if @create_pixel_by_pixel Glimmer::SWT::ImageProxy.create_pixel_by_pixel(*args, &block) else Glimmer::SWT::ImageProxy.create(*args, &block) end end |