glimmer-dsl-opal 0.28.2 → 0.28.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87981d1ce51eda46029d81945b4a0135e0b08a54d9b935504ab015d789d0b417
4
- data.tar.gz: 0db15d4faaff573e66074299725c052814f3d291cff145f8c871ee95f1b5bfc2
3
+ metadata.gz: 07466f2f1bdce190b47b5150a6eb6dec007cc3053ff33fdcc8e0241ed859a42f
4
+ data.tar.gz: 84f91160a5c1147119f9f48a1189b9d78d20791450b48a6589dcacd6adf4e4cf
5
5
  SHA512:
6
- metadata.gz: 441432dc7b68d4163d9a08b0e8df43580692fa84ff1091ee6f6f6e71abf9199a96038a2df17d017d9fed4016457d5254b7667f71d7f4880fc63dd12f23f4918c
7
- data.tar.gz: edee0a32bfcc5f41a756a837fe904d63039160c446578c4a843190285bd7edb9d99aec946e69c2b956d8ef3cdfd2ee06221061d217aac789c502a7f37c87fd8f
6
+ metadata.gz: ba7a681470d023e717b3d545df05a49950d0c4b7139350c4bbe4631a885152be4e9eefbe13496493563fe6272ca95056d5b6dcd154fb98aa052ea37cc4928f23
7
+ data.tar.gz: e816232d3661aa2dac6e2d9da8e54ac0cc857018ef7a25bb236c3f8802ddd4b82c8cd802f7bb89ddacf3204b25a8fc72f226b694f10d1f8dda56f187191650c4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.28.3
4
+
5
+ - Support Canvas Shape DSL data-binding
6
+ - Use Canvas Shape DSL data-binding with Hello, Canvas! text string attribute
7
+ - Add bevel 3D look to Tetris elaborate sample via Canvas Shape DSL
8
+ - Ensure shell height compensates for providing extra top space to menu_bar when rendered
9
+
3
10
  ## 0.28.2
4
11
 
5
12
  - Support `image` Canvas Shape DSL keyword
data/README.md CHANGED
@@ -145,7 +145,7 @@ Hello, Table! Game Booked
145
145
 
146
146
  NOTE: Glimmer DSL for Opal is an alpha project. Please help make better by contributing, adopting for small or low risk projects, and providing feedback. It is still an early alpha, so the more feedback and issues you report the better.
147
147
 
148
- **Alpha Version** 0.28.2 only supports bare-minimum capabilities for the included [samples](https://github.com/AndyObtiva/glimmer-dsl-opal#samples) (originally written for [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt))
148
+ **Alpha Version** 0.28.3 only supports bare-minimum capabilities for the included [samples](https://github.com/AndyObtiva/glimmer-dsl-opal#samples) (originally written for [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt))
149
149
 
150
150
  Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
151
151
  - [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)
@@ -271,7 +271,7 @@ gem 'opal', '1.0.5'
271
271
  gem 'opal-rails', '1.1.2'
272
272
  gem 'opal-async', '~> 1.4.0'
273
273
  gem 'opal-jquery', '~> 0.4.4'
274
- gem 'glimmer-dsl-opal', '~> 0.28.2'
274
+ gem 'glimmer-dsl-opal', '~> 0.28.3'
275
275
  gem 'glimmer-dsl-xml', '~> 1.2.0', require: false
276
276
  gem 'glimmer-dsl-css', '~> 1.2.0', require: false
277
277
 
@@ -2653,7 +2653,7 @@ Glimmer DSL for Opal Contact Manager Edit Done
2653
2653
 
2654
2654
  #### Tetris
2655
2655
 
2656
- This is a minimal initial version of the [Tetris seen in Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/docs/reference/GLIMMER_SAMPLES.md#glimmer-tetris).
2656
+ This is a slightly minimal version of the [Tetris seen in Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/docs/reference/GLIMMER_SAMPLES.md#glimmer-tetris).
2657
2657
 
2658
2658
  Note that while the Glimmer GUI DSL code is mostly the same, some of the behavioral code around threads is changed
2659
2659
  into async Opal code via the [opal-async](https://github.com/AndyObtiva/opal-async) gem due to the async nature of transpiled JavaScript.
@@ -2743,6 +2743,8 @@ You should see "User Profile"
2743
2743
 
2744
2744
  #### Weather
2745
2745
 
2746
+ This sample does everything the desktop sample does except for the Canvas Shape DSL rectangle decoration (until supported).
2747
+
2746
2748
  Code: [lib/glimmer-dsl-opal/samples/elaborate/weather](lib/glimmer-dsl-opal/samples/elaborate/weather.rb)
2747
2749
 
2748
2750
  Add the following require statement to `app/assets/javascripts/application.rb`
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.28.2
1
+ 0.28.3
@@ -42,9 +42,6 @@ module Glimmer
42
42
  (
43
43
  !parent.is_a?(Glimmer::SWT::Custom::Shape) &&
44
44
  !parent.is_a?(Glimmer::SWT::CanvasProxy)
45
- ) or
46
- (
47
- args.size < 3
48
45
  )
49
46
  )
50
47
  )
@@ -1,11 +1,10 @@
1
1
  require 'glimmer/dsl/expression'
2
+ require 'glimmer/swt/custom/shape'
2
3
 
3
4
  module Glimmer
4
5
  module DSL
5
6
  module Opal
6
7
  class PropertyExpression < StaticExpression
7
- include TopLevelExpression
8
-
9
8
  def can_interpret?(parent, keyword, *args, &block)
10
9
  parent and
11
10
  (!args.empty?) and
@@ -22,6 +22,7 @@
22
22
  require 'glimmer/dsl/expression'
23
23
  require 'glimmer/dsl/parent_expression'
24
24
  require 'glimmer/swt/swt_proxy'
25
+ require 'glimmer/swt/canvas_proxy'
25
26
  require 'glimmer/swt/custom/shape'
26
27
 
27
28
  module Glimmer
@@ -31,9 +32,9 @@ module Glimmer
31
32
  include ParentExpression
32
33
 
33
34
  def can_interpret?(parent, keyword, *args, &block)
34
- (parent.is_a?(Glimmer::SWT::WidgetProxy) or parent.is_a?(Glimmer::SWT::Custom::Shape)) and
35
+ (parent.is_a?(Glimmer::SWT::CanvasProxy) or parent.is_a?(Glimmer::SWT::Custom::Shape)) and
35
36
  Glimmer::SWT::Custom::Shape.valid?(parent, keyword, args, &block) and
36
- (keyword != 'text' || args.size >= 3)
37
+ ((keyword != 'text' && keyword != 'image') || args.size >= 3 || (args.empty? && block_given?))
37
38
  end
38
39
 
39
40
  def interpret(parent, keyword, *args, &block)
@@ -30,6 +30,9 @@ module Glimmer
30
30
  module Custom
31
31
  class Shape
32
32
  class Arc < Shape
33
+ def parameter_names
34
+ [:x, :y, :width, :height, :start_angle, :arc_angle]
35
+ end
33
36
 
34
37
  def post_add_content
35
38
  @performing_post_add_content = true
@@ -31,6 +31,50 @@ module Glimmer
31
31
  module Custom
32
32
  class Shape
33
33
  class Image < Shape
34
+ def parameter_names
35
+ if image_whole_parameter_names.size == @args.size
36
+ @parameter_names = image_whole_parameter_names
37
+ elsif image_part_parameter_names.size == @args.size
38
+ @parameter_names = image_part_parameter_names
39
+ end
40
+ @parameter_names || image_whole_parameter_names
41
+ end
42
+
43
+ def possible_parameter_names
44
+ (image_whole_parameter_names + image_part_parameter_names).uniq
45
+ end
46
+
47
+ def image_part_parameter_names
48
+ [:image, :src_x, :src_y, :src_width, :src_height, :dest_x, :dest_y, :dest_width, :dest_height]
49
+ end
50
+
51
+ def image_whole_parameter_names
52
+ [:image, :x, :y]
53
+ end
54
+
55
+ def set_parameter_attribute(attribute_name, *args)
56
+ if @parameter_names.to_a.map(&:to_s).include?(attribute_name.to_s)
57
+ super(attribute_name, *args)
58
+ build_dom
59
+ reattach(dom_element)
60
+ return
61
+ end
62
+ ####TODO refactor and improve this method through meta-programming (and share across other shapes)
63
+ if image_whole_parameter_names.map(&:to_s).include?(attribute_name.to_s)
64
+ @parameter_names = image_whole_parameter_names
65
+ elsif image_part_parameter_names.map(&:to_s).include?(attribute_name.to_s)
66
+ @parameter_names = image_part_parameter_names
67
+ end
68
+ super(attribute_name, *args)
69
+ end
70
+
71
+ def reattach(old_element)
72
+ old_element.attr('href', Element[@dom].attr('href'))
73
+ old_element.attr('x', Element[@dom].attr('x'))
74
+ old_element.attr('y', Element[@dom].attr('y'))
75
+ old_element.attr('width', Element[@dom].attr('width'))
76
+ old_element.attr('height', Element[@dom].attr('height'))
77
+ end
34
78
 
35
79
  def element
36
80
  'image'
@@ -30,6 +30,9 @@ module Glimmer
30
30
  module Custom
31
31
  class Shape
32
32
  class Line < Shape
33
+ def parameter_names
34
+ [:x1, :y1, :x2, :y2]
35
+ end
33
36
 
34
37
  def element
35
38
  'line'
@@ -30,6 +30,9 @@ module Glimmer
30
30
  module Custom
31
31
  class Shape
32
32
  class Point < Shape
33
+ def parameter_names
34
+ [:x, :y]
35
+ end
33
36
 
34
37
  def element
35
38
  'rect'
@@ -30,6 +30,9 @@ module Glimmer
30
30
  module Custom
31
31
  class Shape
32
32
  class Polygon < Shape
33
+ def parameter_names
34
+ [:point_array]
35
+ end
33
36
 
34
37
  def element
35
38
  'polygon'
@@ -30,6 +30,9 @@ module Glimmer
30
30
  module Custom
31
31
  class Shape
32
32
  class Polyline < Shape
33
+ def parameter_names
34
+ [:point_array]
35
+ end
33
36
 
34
37
  def element
35
38
  'polyline'
@@ -30,6 +30,57 @@ module Glimmer
30
30
  module Custom
31
31
  class Shape
32
32
  class Rectangle < Shape
33
+
34
+ def parameter_names
35
+ if @parameter_names.nil?
36
+ if rectangle_parameter_names.size == @args.size
37
+ @parameter_names = rectangle_parameter_names
38
+ elsif rectangle_round_parameter_names.size == @args.size
39
+ @parameter_names = rectangle_round_parameter_names
40
+ elsif rectangle_gradient_parameter_names.size == @args.size
41
+ @parameter_names = rectangle_gradient_parameter_names
42
+ elsif rectangle_rectangle_parameter_names.size == @args.size
43
+ @parameter_names = rectangle_rectangle_parameter_names
44
+ end
45
+ end
46
+ @parameter_names || rectangle_parameter_names
47
+ end
48
+
49
+ def possible_parameter_names
50
+ # TODO refactor and improve this method through meta-programming (and share across other shapes)
51
+ (rectangle_round_parameter_names + rectangle_parameter_names + rectangle_gradient_parameter_names + rectangle_rectangle_parameter_names).uniq
52
+ end
53
+
54
+ def rectangle_round_parameter_names
55
+ [:x, :y, :width, :height, :arc_width, :arc_height]
56
+ end
57
+
58
+ def rectangle_gradient_parameter_names
59
+ [:x, :y, :width, :height, :vertical]
60
+ end
61
+
62
+ def rectangle_parameter_names
63
+ [:x, :y, :width, :height]
64
+ end
65
+
66
+ def rectangle_rectangle_parameter_names
67
+ # this receives a Rectangle object
68
+ [:rectangle]
69
+ end
70
+
71
+ def set_parameter_attribute(attribute_name, *args)
72
+ return super(attribute_name, *args) if @parameter_names.to_a.map(&:to_s).include?(attribute_name.to_s)
73
+ if rectangle_parameter_names.map(&:to_s).include?(attribute_name.to_s)
74
+ @parameter_names = rectangle_parameter_names
75
+ elsif rectangle_round_parameter_names.map(&:to_s).include?(attribute_name.to_s)
76
+ @parameter_names = rectangle_round_parameter_names
77
+ elsif rectangle_gradient_parameter_names.map(&:to_s).include?(attribute_name.to_s)
78
+ @parameter_names = rectangle_gradient_parameter_names
79
+ elsif rectangle_rectangle_parameter_names.map(&:to_s).include?(attribute_name.to_s)
80
+ @parameter_names = rectangle_rectangle_parameter_names
81
+ end
82
+ super(attribute_name, *args)
83
+ end
33
84
 
34
85
  def element
35
86
  'rect'
@@ -30,7 +30,57 @@ module Glimmer
30
30
  module Custom
31
31
  class Shape
32
32
  class Text < Shape
33
-
33
+ def parameter_names
34
+ if text_parameter_names.size == @args.size
35
+ @parameter_names = text_parameter_names
36
+ elsif text_transparent_parameter_names.size == @args.size
37
+ @parameter_names = text_transparent_parameter_names
38
+ elsif text_flags_parameter_names.size == @args.size
39
+ @parameter_names = text_flags_parameter_names
40
+ end
41
+ @parameter_names || text_parameter_names
42
+ end
43
+
44
+ def possible_parameter_names
45
+ # TODO refactor and improve this method through meta-programming (and share across other shapes)
46
+ (text_parameter_names + text_transparent_parameter_names + text_flags_parameter_names).uniq
47
+ end
48
+
49
+ def text_parameter_names
50
+ [:string, :x, :y]
51
+ end
52
+
53
+ def text_transparent_parameter_names
54
+ [:string, :x, :y, :is_transparent]
55
+ end
56
+
57
+ def text_flags_parameter_names
58
+ [:string, :x, :y, :flags]
59
+ end
60
+
61
+ def set_parameter_attribute(attribute_name, *args)
62
+ if @parameter_names.to_a.map(&:to_s).include?(attribute_name.to_s)
63
+ super(attribute_name, *args)
64
+ build_dom
65
+ reattach(dom_element)
66
+ return
67
+ end
68
+ if text_parameter_names.map(&:to_s).include?(attribute_name.to_s)
69
+ @parameter_names = text_parameter_names
70
+ elsif text_transparent_parameter_names.map(&:to_s).include?(attribute_name.to_s)
71
+ @parameter_names = text_transparent_parameter_names
72
+ elsif text_flags_parameter_names.map(&:to_s).include?(attribute_name.to_s)
73
+ @parameter_names = text_flags_parameter_names
74
+ end
75
+ super(attribute_name, *args)
76
+ end
77
+
78
+ def reattach(old_element)
79
+ old_element.attr('x', Element[@dom].attr('x'))
80
+ old_element.attr('y', Element[@dom].attr('y'))
81
+ old_element.text(Element[@dom].html)
82
+ end
83
+
34
84
  def background=(value)
35
85
  # TODO override background= to fill a rectangle containing text, matching its size
36
86
  # For now, disable background when foreground is not set
@@ -61,18 +61,112 @@ module Glimmer
61
61
  end
62
62
 
63
63
  def background=(value)
64
- value = ColorProxy.new(value) if value.is_a?(String)
64
+ value = ColorProxy.new(value) if value.is_a?(String) || value.is_a?(Symbol)
65
65
  @background = value
66
66
  dom_element.css('fill', background.to_css) unless background.nil?
67
67
  end
68
68
 
69
69
  def foreground=(value)
70
- value = ColorProxy.new(value) if value.is_a?(String)
70
+ value = ColorProxy.new(value) if value.is_a?(String) || value.is_a?(Symbol)
71
71
  @foreground = value
72
72
  dom_element.css('stroke', foreground.to_css) unless foreground.nil?
73
73
  dom_element.css('fill', 'transparent') if background.nil?
74
74
  end
75
75
 
76
+ def post_add_content
77
+ # TODO avoid rendering unless args changed from initialize args (due to setting of piecemeal attributes)
78
+ render
79
+ end
80
+
81
+ def render(custom_parent_dom_element: nil, brand_new: false)
82
+ super(custom_parent_dom_element: nil, brand_new: false)
83
+ self.background = background
84
+ self.foreground = foreground
85
+ self.font = font
86
+ end
87
+
88
+ # parameter names for arguments to pass to SWT GC.xyz method for rendering shape (e.g. draw_image(image, x, y) yields :image, :x, :y parameter names)
89
+ def parameter_names
90
+ [:x, :y, :width, :height]
91
+ end
92
+
93
+ # subclasses may override to specify location parameter names if different from x and y (e.g. all polygon points are location parameters)
94
+ # used in calculating movement changes
95
+ def location_parameter_names
96
+ [:x, :y]
97
+ end
98
+
99
+ def possible_parameter_names
100
+ parameter_names
101
+ end
102
+
103
+ def parameter_name?(attribute_name)
104
+ possible_parameter_names.map(&:to_s).include?(attribute_getter(attribute_name))
105
+ end
106
+
107
+ def current_parameter_name?(attribute_name)
108
+ parameter_names.include?(attribute_name.to_s.to_sym)
109
+ end
110
+
111
+ def parameter_index(attribute_name)
112
+ parameter_names.index(attribute_name.to_s.to_sym)
113
+ end
114
+
115
+ def get_parameter_attribute(attribute_name)
116
+ @args[parameter_index(attribute_getter(attribute_name))]
117
+ end
118
+
119
+ def set_parameter_attribute(attribute_name, *args)
120
+ @args[parameter_index(attribute_getter(attribute_name))] = args.size == 1 ? args.first : args
121
+ end
122
+
123
+ def has_attribute?(attribute_name, *args)
124
+ parameter_name?(attribute_name) or
125
+ (respond_to?(attribute_name, super: true) and respond_to?(attribute_setter(attribute_name), super: true))
126
+ end
127
+
128
+ def set_attribute(attribute_name, *args)
129
+ attribute_getter_name = attribute_getter(attribute_name)
130
+ attribute_setter_name = attribute_setter(attribute_name)
131
+ if parameter_name?(attribute_name)
132
+ return if attribute_getter_name == (args.size == 1 ? args.first : args)
133
+ set_parameter_attribute(attribute_getter_name, *args)
134
+ elsif (respond_to?(attribute_name, super: true) and respond_to?(attribute_setter_name, super: true))
135
+ return if self.send(attribute_getter_name) == (args.size == 1 ? args.first : args)
136
+ self.send(attribute_setter_name, *args)
137
+ end
138
+ end
139
+
140
+ def get_attribute(attribute_name)
141
+ if parameter_name?(attribute_name)
142
+ arg_index = parameter_index(attribute_name)
143
+ @args[arg_index] if arg_index
144
+ elsif (respond_to?(attribute_name, super: true) and respond_to?(attribute_setter(attribute_name), super: true))
145
+ self.send(attribute_name)
146
+ end
147
+ end
148
+
149
+ # TODO look why image is not working with the method_missing and respond_to? on shape
150
+ def method_missing(method_name, *args, &block)
151
+ if method_name.to_s.end_with?('=')
152
+ set_attribute(method_name, *args)
153
+ elsif has_attribute?(method_name) && args.empty?
154
+ get_attribute(method_name)
155
+ else # TODO support proxying calls to handle_observation_request for listeners just like WidgetProxy
156
+ super(method_name, *args, &block)
157
+ end
158
+ end
159
+
160
+ def respond_to?(method_name, *args, &block)
161
+ options = args.last if args.last.is_a?(Hash)
162
+ super_invocation = options && options[:super]
163
+ if !super_invocation && has_attribute?(method_name)
164
+ true
165
+ else
166
+ super(method_name, *args, &block)
167
+ end
168
+ end
169
+
76
170
  def attach(the_parent_dom_element)
77
171
  the_parent_dom_element.html("#{the_parent_dom_element.html()}\n#{@dom}")
78
172
  end
@@ -198,6 +198,7 @@ module Glimmer
198
198
  # delay this till all children rendered (perhaps post_add_content block)
199
199
  parent_dom_element.css('position', 'relative')
200
200
  parent_dom_element.css('margin-top', '30px')
201
+ parent_dom_element.css('height', '114%')
201
202
  redraw
202
203
  `$(#{path}).menu({
203
204
  position: { my: "top", at: "bottom" },
@@ -222,7 +223,6 @@ module Glimmer
222
223
  @visible = value
223
224
  if @visible
224
225
  parent.menu_requested = true
225
- parent.dom_element.css('position', 'relative')
226
226
  render
227
227
  dom_element.css('position', 'absolute')
228
228
  dom_element.css('left', parent.menu_x - parent.dom_element.offset.left)
@@ -295,6 +295,7 @@ module Glimmer
295
295
  end
296
296
 
297
297
  def font=(value)
298
+ return if value.nil?
298
299
  @font = value.is_a?(FontProxy) ? value : FontProxy.new(self, value)
299
300
  dom_element.css('font-family', @font.name) unless @font.nil?
300
301
  dom_element.css('font-style', 'italic') if @font&.style == :italic || [@font&.style].flatten.compact.include?(:italic)
@@ -25,10 +25,54 @@ class Tetris
25
25
  include Glimmer::UI::CustomWidget
26
26
 
27
27
  options :game_playfield, :block_size, :row, :column
28
+
29
+ attr_accessor :bevel_pixel_size
30
+
31
+ before_body do
32
+ self.bevel_pixel_size = 0.16*block_size.to_f
33
+ end
28
34
 
29
35
  body {
30
36
  canvas { |canvas_proxy|
31
37
  background <= [game_playfield[row][column], :color]
38
+ polygon(0, 0, block_size, 0, block_size - bevel_pixel_size, bevel_pixel_size, bevel_pixel_size, bevel_pixel_size) {
39
+ background <= [game_playfield[row][column], :color, on_read: ->(color_value) {
40
+ unless color_value.nil?
41
+ color = color(color_value)
42
+ rgb(color.red + 4*BEVEL_CONSTANT, color.green + 4*BEVEL_CONSTANT, color.blue + 4*BEVEL_CONSTANT)
43
+ end
44
+ }]
45
+ }
46
+ polygon(block_size, 0, block_size - bevel_pixel_size, bevel_pixel_size, block_size - bevel_pixel_size, block_size - bevel_pixel_size, block_size, block_size) {
47
+ background <= [game_playfield[row][column], :color, on_read: ->(color_value) {
48
+ unless color_value.nil?
49
+ color = color(color_value)
50
+ rgb(color.red - BEVEL_CONSTANT, color.green - BEVEL_CONSTANT, color.blue - BEVEL_CONSTANT)
51
+ end
52
+ }]
53
+ }
54
+ polygon(block_size, block_size, 0, block_size, bevel_pixel_size, block_size - bevel_pixel_size, block_size - bevel_pixel_size, block_size - bevel_pixel_size) {
55
+ background <= [game_playfield[row][column], :color, on_read: ->(color_value) {
56
+ unless color_value.nil?
57
+ color = color(color_value)
58
+ rgb(color.red - 2*BEVEL_CONSTANT, color.green - 2*BEVEL_CONSTANT, color.blue - 2*BEVEL_CONSTANT)
59
+ end
60
+ }]
61
+ }
62
+ polygon(0, 0, 0, block_size, bevel_pixel_size, block_size - bevel_pixel_size, bevel_pixel_size, bevel_pixel_size) {
63
+ background <= [game_playfield[row][column], :color, on_read: ->(color_value) {
64
+ unless color_value.nil?
65
+ color = color(color_value)
66
+ rgb(color.red - BEVEL_CONSTANT, color.green - BEVEL_CONSTANT, color.blue - BEVEL_CONSTANT)
67
+ end
68
+ }]
69
+ }
70
+ rectangle(0, 0, block_size, block_size) {
71
+ foreground <= [game_playfield[row][column], :color, on_read: ->(color_value) {
72
+ color_value == Model::Block::COLOR_CLEAR ? :gray : color_value
73
+ }]
74
+ }
75
+
32
76
  }
33
77
  }
34
78
  end
@@ -29,7 +29,7 @@ require_relative 'tetris/view/tetris_menu_bar'
29
29
  class Tetris
30
30
  include Glimmer::UI::CustomShell
31
31
 
32
- BLOCK_SIZE = 7
32
+ BLOCK_SIZE = 37
33
33
  FONT_NAME = 'Menlo'
34
34
  FONT_TITLE_HEIGHT = 32
35
35
  FONT_TITLE_STYLE = :bold
@@ -143,7 +143,7 @@ class Tetris
143
143
  def show_about_dialog
144
144
  message_box {
145
145
  text 'Glimmer Tetris'
146
- message "Glimmer Tetris\n\nGlimmer DSL for SWT Sample\n\nUse arrow keys for movement\nand right/left alt/shift keys for rotation\nAlternatively:\nLeft is A\nRight is D\nDown is S\nUp is W\nRotate Left is Q\nRotate Right is E\n\nCopyright (c) 2007-2021 Andy Maleh"
146
+ message "Glimmer Tetris\n\nGlimmer DSL for SWT Sample\n\nLeft is A\nRight is D\nDown is S\nUp is W\nRotate Left is Q\nRotate Right is E\nAlternatively:\nUse arrow keys for movement\nand right/left alt/shift keys for rotation\n\nCopyright (c) 2007-2021 Andy Maleh"
147
147
  }.open
148
148
  end
149
149
  end
@@ -70,9 +70,10 @@ class Weather
70
70
  text temp_unit
71
71
  background DEFAULT_BACKGROUND
72
72
 
73
- rectangle(0, 0, [:default, -2], [:default, -2], 15, 15) {
74
- foreground DEFAULT_FOREGROUND
75
- }
73
+ # TODO enable once Canvas Shape DSL is supported under any widget (not just canvas)
74
+ # rectangle(0, 0, [:default, -2], [:default, -2], 15, 15) {
75
+ # foreground DEFAULT_FOREGROUND
76
+ # }
76
77
 
77
78
  %w[temp temp_min temp_max feels_like].each do |field_name|
78
79
  temp_field(field_name, temp_unit)
@@ -21,9 +21,21 @@
21
21
 
22
22
  class HelloCanvas
23
23
  include Glimmer::UI::CustomShell
24
-
24
+
25
+ attr_accessor :artist
26
+
25
27
  before_body do
26
28
  @image_object = image(File.expand_path('./images/scaffold_app.png', __dir__), width: 50)
29
+ @artist = ''
30
+ end
31
+
32
+ after_body do
33
+ Thread.new do
34
+ 'Picasso'.chars.async_each do |character|
35
+ sleep(0.5)
36
+ self.artist += character
37
+ end
38
+ end
27
39
  end
28
40
 
29
41
  body {
@@ -61,7 +73,10 @@ class HelloCanvas
61
73
  arc(210, 210, 100, 100, 30, -77) {
62
74
  background :red
63
75
  }
64
- text('Picasso', 67, 103) {
76
+ text {
77
+ string <= [self, :artist]
78
+ x 67
79
+ y 103
65
80
  foreground :dark_magenta
66
81
  font name: 'Courier', height: 30
67
82
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-opal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.28.2
4
+ version: 0.28.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-31 00:00:00.000000000 Z
11
+ date: 2021-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer