glimmer-dsl-swt 4.20.13.9 → 4.20.13.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/README.md +5 -5
  4. data/VERSION +1 -1
  5. data/docs/reference/GLIMMER_STYLE_GUIDE.md +2 -1
  6. data/glimmer-dsl-swt.gemspec +0 -0
  7. data/lib/glimmer/rake_task/scaffold.rb +14 -14
  8. data/lib/glimmer/swt/custom/code_text.rb +4 -4
  9. data/samples/elaborate/calculator.rb +2 -2
  10. data/samples/elaborate/contact_manager.rb +2 -2
  11. data/samples/elaborate/klondike_solitaire.rb +2 -21
  12. data/samples/elaborate/klondike_solitaire/view/empty_playing_card.rb +8 -3
  13. data/samples/elaborate/klondike_solitaire/view/foundation_pile.rb +4 -4
  14. data/samples/elaborate/klondike_solitaire/view/hidden_playing_card.rb +8 -1
  15. data/samples/elaborate/klondike_solitaire/view/playing_card.rb +2 -2
  16. data/samples/elaborate/login.rb +2 -2
  17. data/samples/elaborate/mandelbrot_fractal.rb +12 -12
  18. data/samples/elaborate/meta_sample.rb +2 -2
  19. data/samples/elaborate/metronome.rb +2 -2
  20. data/samples/elaborate/stock_ticker.rb +8 -8
  21. data/samples/elaborate/tetris.rb +4 -4
  22. data/samples/elaborate/tetris/view/bevel.rb +2 -2
  23. data/samples/elaborate/tetris/view/score_lane.rb +2 -2
  24. data/samples/elaborate/tic_tac_toe.rb +6 -6
  25. data/samples/elaborate/timer.rb +4 -4
  26. data/samples/elaborate/weather.rb +4 -4
  27. data/samples/hello/hello_button.rb +2 -2
  28. data/samples/hello/hello_c_combo.rb +2 -2
  29. data/samples/hello/hello_canvas.rb +4 -4
  30. data/samples/hello/hello_canvas_animation.rb +2 -2
  31. data/samples/hello/hello_canvas_data_binding.rb +2 -2
  32. data/samples/hello/hello_checkbox.rb +2 -2
  33. data/samples/hello/hello_checkbox_group.rb +2 -2
  34. data/samples/hello/hello_code_text.rb +2 -2
  35. data/samples/hello/hello_color_dialog.rb +2 -2
  36. data/samples/hello/hello_combo.rb +2 -2
  37. data/samples/hello/hello_computed.rb +14 -22
  38. data/samples/hello/hello_cool_bar.rb +2 -2
  39. data/samples/hello/hello_cursor.rb +2 -2
  40. data/samples/hello/hello_custom_shape.rb +2 -2
  41. data/samples/hello/hello_custom_shell.rb +2 -2
  42. data/samples/hello/hello_custom_widget.rb +4 -4
  43. data/samples/hello/hello_date_time.rb +2 -2
  44. data/samples/hello/hello_directory_dialog.rb +2 -2
  45. data/samples/hello/hello_file_dialog.rb +2 -2
  46. data/samples/hello/hello_font_dialog.rb +2 -2
  47. data/samples/hello/hello_group.rb +2 -2
  48. data/samples/hello/hello_list_multi_selection.rb +2 -2
  49. data/samples/hello/hello_list_single_selection.rb +2 -2
  50. data/samples/hello/hello_progress_bar.rb +2 -2
  51. data/samples/hello/hello_radio.rb +2 -2
  52. data/samples/hello/hello_radio_group.rb +2 -2
  53. data/samples/hello/hello_scale.rb +2 -2
  54. data/samples/hello/hello_spinner.rb +2 -2
  55. data/samples/hello/hello_table.rb +2 -2
  56. data/samples/hello/hello_text.rb +2 -2
  57. data/samples/hello/hello_tool_bar.rb +2 -2
  58. data/samples/hello/hello_tray_item.rb +2 -2
  59. data/samples/hello/hello_tree.rb +4 -4
  60. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c7f34d2baa127f20cc05b387d51afed496456ee236e5a206594c1b5bd672aa56
4
- data.tar.gz: e19feae85a8f5b29fee1c40eb259618b95b235ce7b41e847e8277a124e5ae362
3
+ metadata.gz: 982e9293313f88fc19f63d148e0b59b1dcda227e25bc47d9eb07377359b90084
4
+ data.tar.gz: c90ad4be0b5ebf2aaa28b5b0376934e518f7fbe878a3ecb4a37982fa5feac554
5
5
  SHA512:
6
- metadata.gz: e8fa48e0b887ed4a772eda18f997ed91f5ad2005d3aeae9aa1e1fccd2baffbdeb3e9578a56c2ca51b04eda425dc7b1ef420bf9bb6ab1b2fe28bde0aefc820dd2
7
- data.tar.gz: 89a9947c73556344f300e7db6fe8d43913f1d089c041d5416b9c0b69367549764978c990737da74c157d573118d81c0a771ff06025676b5b3ba781f30e095853
6
+ metadata.gz: 6946dfd8d245a2ef28df3df0c7eb3b74213f4c912c69a6de5ce0bd4f42d7b69f87671df845a816c532d6b580bd0f9da535639368aba6ed0abd76d689c66ded07
7
+ data.tar.gz: c630515458b13ab4b08c6c662c27759c9a0adb8903e5f0a5e20aba958792d3949f48ae47d9849ffddbe52d4a7b33887955979d76ffe6223871cc51e8f844c443
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.20.13.10
4
+
5
+ - Update Glimmer Style Guide, scaffolding, and samples to have `before_body` and `after_body` in custom widgets/shells/shapes always take a `do; end` block since they contain logic not visuals
6
+
7
+ ### 4.20.13.9
8
+
9
+ - Update Klondike Solitaire to have playing card suit symbols and avoid clipping of cards on the boundaries
10
+
3
11
  ### 4.20.13.8
4
12
 
5
13
  - Glimmer Klondike Solitaire elaborate sample
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for SWT 4.20.13.9
1
+ # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for SWT 4.20.13.10
2
2
  ## JRuby Desktop Development GUI Framework
3
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-swt.svg)](http://badge.fury.io/rb/glimmer-dsl-swt)
4
4
  [![Travis CI](https://travis-ci.com/AndyObtiva/glimmer-dsl-swt.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer-dsl-swt)
@@ -15,7 +15,7 @@
15
15
  [<img src="https://covers.oreillystatic.com/images/9780596519650/lrg.jpg" width=105 /><br />
16
16
  Featured in JRuby Cookbook](http://shop.oreilly.com/product/9780596519650.do) and [Chalmers/Gothenburg University Software Engineering Master's Lecture Material](http://www.cse.chalmers.se/~bergert/slides/guest_lecture_DSLs.pdf)
17
17
 
18
- [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.20.13.9 includes [SWT 4.20](https://download.eclipse.org/eclipse/downloads/drops4/R-4.20-202106111600/), which was released on June 11, 2021. Gem version numbers are in sync with the SWT library versions. The first two digits represent the SWT version number. The last two digits represent the minor and patch versions of Glimmer DSL for SWT. Note that SWT now supports AARCH64 on Mac and Linux, but it is not fully tested in Glimmer DSL for SWT yet, so deem its support experimental for the time being without guarantees for functionality until declared otherwise (report any issues you may encounter).
18
+ [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.20.13.10 includes [SWT 4.20](https://download.eclipse.org/eclipse/downloads/drops4/R-4.20-202106111600/), which was released on June 11, 2021. Gem version numbers are in sync with the SWT library versions. The first two digits represent the SWT version number. The last two digits represent the minor and patch versions of Glimmer DSL for SWT. Note that SWT now supports AARCH64 on Mac and Linux, but it is not fully tested in Glimmer DSL for SWT yet, so deem its support experimental for the time being without guarantees for functionality until declared otherwise (report any issues you may encounter).
19
19
 
20
20
  **Starting in version 4.20.0.0, [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) comes with the new [***Shine***](/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#shine) syntax** for highly intuitive and visually expressive View/Model Attribute Mapping, relying on `<=>` for bidirectional (two-way) data-binding and `<=` for unidirectional (one-way) data-binding, providing an alternative to the `bind` keyword (keep in mind that it is still a beta, so default back to `bind` whenever needed).
21
21
 
@@ -326,7 +326,7 @@ jgem install glimmer-dsl-swt
326
326
 
327
327
  Or this command if you want a specific version:
328
328
  ```
329
- jgem install glimmer-dsl-swt -v 4.20.13.9
329
+ jgem install glimmer-dsl-swt -v 4.20.13.10
330
330
  ```
331
331
 
332
332
  `jgem` is JRuby's version of `gem` command.
@@ -354,7 +354,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
354
354
 
355
355
  Add the following to `Gemfile`:
356
356
  ```
357
- gem 'glimmer-dsl-swt', '~> 4.20.13.9'
357
+ gem 'glimmer-dsl-swt', '~> 4.20.13.10'
358
358
  ```
359
359
 
360
360
  And, then run:
@@ -375,7 +375,7 @@ glimmer
375
375
  ```
376
376
 
377
377
  ```
378
- Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.20.13.9
378
+ Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.20.13.10
379
379
 
380
380
  Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
381
381
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.20.13.9
1
+ 4.20.13.10
@@ -10,6 +10,7 @@
10
10
  - Widget listeners are always declared starting with `on_` prefix and affixing listener event method name afterwards in underscored lowercase form. Their multi-line blocks rely on the `do; end` style.
11
11
  - Widget listeners are always followed by a block using curly braces (Only when declared in DSL. When invoked on widget object directly outside of GUI declarations, standard Ruby conventions apply)
12
12
  - Data-binding is done via `bind` keyword, which always takes arguments wrapped in parentheses
13
- - Custom widget `body`, `before_body`, and `after_body` blocks open their blocks and close them with curly braces.
13
+ - Custom widget/shell/shape `body` blocks open and close with curly braces.
14
+ - Custom widget/shell/shape `before_body` and `after_body` blocks are declared as `do; end` blocks.
14
15
  - Custom widgets receive additional keyword arguments called options, which come after the SWT styles.
15
16
  - Pure logic multi-line blocks that do not constitute GUI DSL view elements (such as `Thread.new`, `loop`, `each` and `observe` blocks) rely on the `do; end` style to clearly separate logic code from view code.
Binary file
@@ -607,7 +607,7 @@ module Glimmer
607
607
 
608
608
  if %i[gem app desktopify].include?(shell_type)
609
609
  custom_shell_file_content += <<-MULTI_LINE_STRING
610
- before_body {
610
+ before_body do
611
611
  Display.app_name = '#{shell_type == :gem ? human_name(custom_shell_name) : human_name(namespace)}'
612
612
  Display.app_version = VERSION
613
613
  @display = display {
@@ -618,13 +618,13 @@ module Glimmer
618
618
  #{shell_type == :desktopify ? 'display_about_dialog' : 'display_preferences_dialog'}
619
619
  }
620
620
  }
621
- }
621
+ end
622
622
  MULTI_LINE_STRING
623
623
  else
624
624
  custom_shell_file_content += <<-MULTI_LINE_STRING
625
- # before_body {
625
+ # before_body do
626
626
  #
627
- # }
627
+ # end
628
628
  MULTI_LINE_STRING
629
629
  end
630
630
 
@@ -632,9 +632,9 @@ module Glimmer
632
632
 
633
633
  ## Use after_body block to setup observers for widgets in body
634
634
  #
635
- # after_body {
635
+ # after_body do
636
636
  #
637
- # }
637
+ # end
638
638
 
639
639
  ## Add widget content inside custom shell body
640
640
  ## Top-most widget must be a shell or another custom shell
@@ -767,15 +767,15 @@ end
767
767
  ## Use before_body block to pre-initialize variables to use in body
768
768
  #
769
769
  #
770
- # before_body {
770
+ # before_body do
771
771
  #
772
- # }
772
+ # end
773
773
 
774
774
  ## Use after_body block to setup observers for widgets in body
775
775
  #
776
- # after_body {
776
+ # after_body do
777
777
  #
778
- # }
778
+ # end
779
779
 
780
780
  ## Add widget content under custom widget body
781
781
  ##
@@ -817,15 +817,15 @@ end
817
817
  ## Use before_body block to pre-initialize variables to use in body
818
818
  #
819
819
  #
820
- # before_body {
820
+ # before_body do
821
821
  #
822
- # }
822
+ # end
823
823
 
824
824
  ## Use after_body block to setup observers for shapes in body
825
825
  #
826
- # after_body {
826
+ # after_body do
827
827
  #
828
- # }
828
+ # end
829
829
 
830
830
  ## Add shape content under custom shape body
831
831
  #
@@ -121,7 +121,7 @@ module Glimmer
121
121
  @line_numbers_styled_text_proxy.content(&block)
122
122
  end
123
123
 
124
- before_body {
124
+ before_body do
125
125
  require 'rouge'
126
126
  require 'ext/rouge/themes/glimmer'
127
127
  @swt_style = swt_style == 0 ? [:border, :multi, :v_scroll, :h_scroll] : swt_style
@@ -132,11 +132,11 @@ module Glimmer
132
132
  @lines_width = lines[:width]
133
133
  end
134
134
  @dsl_mode = true
135
- }
135
+ end
136
136
 
137
- after_body {
137
+ after_body do
138
138
  @dsl_mode = nil
139
- }
139
+ end
140
140
 
141
141
  body {
142
142
  if lines
@@ -15,7 +15,7 @@ class Calculator
15
15
 
16
16
  attr_reader :presenter
17
17
 
18
- before_body {
18
+ before_body do
19
19
  @presenter = Model::Presenter.new
20
20
 
21
21
  Display.setAppName('Glimmer Calculator')
@@ -30,7 +30,7 @@ class Calculator
30
30
  display_about_dialog
31
31
  }
32
32
  }
33
- }
33
+ end
34
34
 
35
35
  body {
36
36
  shell {
@@ -26,10 +26,10 @@ require_relative "contact_manager/contact_manager_presenter"
26
26
  class ContactManager
27
27
  include Glimmer::UI::CustomShell
28
28
 
29
- before_body {
29
+ before_body do
30
30
  @contact_manager_presenter = ContactManagerPresenter.new
31
31
  @contact_manager_presenter.list
32
- }
32
+ end
33
33
 
34
34
  body {
35
35
  shell {
@@ -15,17 +15,7 @@ class KlondikeSolitaire
15
15
  TABLEAU_WIDTH = 2*MARGIN + 7*(PLAYING_CARD_WIDTH + PLAYING_CARD_SPACING)
16
16
  TABLEAU_HEIGHT = 400
17
17
 
18
-
19
- ## Add options like the following to configure CustomShell by outside consumers
20
- #
21
- # options :title, :background_color
22
- # option :width, default: 320
23
- # option :height, default: 240
24
-
25
- ## Use before_body block to pre-initialize variables to use in body
26
- #
27
- #
28
- before_body {
18
+ before_body do
29
19
  @game = Model::Game.new
30
20
  Display.app_name = 'Glimmer Klondike Solitaire'
31
21
  @display = display {
@@ -36,17 +26,8 @@ class KlondikeSolitaire
36
26
  display_about_dialog
37
27
  }
38
28
  }
39
- }
40
-
41
- ## Use after_body block to setup observers for widgets in body
42
- #
43
- # after_body {
44
- #
45
- # }
29
+ end
46
30
 
47
- ## Add widget content inside custom shell body
48
- ## Top-most widget must be a shell or another custom shell
49
- #
50
31
  body {
51
32
  shell(:no_resize) {
52
33
  row_layout(:vertical) {
@@ -5,10 +5,15 @@ class KlondikeSolitaire
5
5
  class EmptyPlayingCard
6
6
  include Glimmer::UI::CustomShape
7
7
 
8
- option :suit
9
-
8
+ options :card_x, :card_y, :suit
9
+
10
+ before_body do
11
+ self.card_x ||= 0
12
+ self.card_y ||= 0
13
+ end
14
+
10
15
  body {
11
- rectangle(0, 0, 49, 79, 15, 15) {
16
+ rectangle(card_x, card_y, 49, 79, 15, 15) {
12
17
  foreground :gray
13
18
 
14
19
  if suit
@@ -10,12 +10,12 @@ class KlondikeSolitaire
10
10
 
11
11
  attr_accessor :current_image, :model
12
12
 
13
- before_body {
13
+ before_body do
14
14
  self.current_image = image(50, 80) {empty_playing_card(suit: suit)}
15
15
  self.model = game.foundation_piles[Model::PlayingCard::SUITS.index(suit)]
16
- }
16
+ end
17
17
 
18
- after_body {
18
+ after_body do
19
19
  observe(model, 'playing_cards.last') do |last_card|
20
20
  if last_card
21
21
  body_root.content {
@@ -28,7 +28,7 @@ class KlondikeSolitaire
28
28
  }
29
29
  end
30
30
  end
31
- }
31
+ end
32
32
 
33
33
  body {
34
34
  shape(pile_x, pile_y) {
@@ -3,8 +3,15 @@ class KlondikeSolitaire
3
3
  class HiddenPlayingCard
4
4
  include Glimmer::UI::CustomShape
5
5
 
6
+ options :card_x, :card_y
7
+
8
+ before_body do
9
+ self.card_x ||= 0
10
+ self.card_y ||= 0
11
+ end
12
+
6
13
  body {
7
- rectangle(0, 0, 49, 79, 15, 15) {
14
+ rectangle(card_x, card_y, 49, 79, 15, 15) {
8
15
  background :red
9
16
 
10
17
  # border
@@ -5,10 +5,10 @@ class KlondikeSolitaire
5
5
 
6
6
  options :card_x, :card_y, :model, :parent_pile
7
7
 
8
- before_body {
8
+ before_body do
9
9
  self.card_x ||= 0
10
10
  self.card_y ||= 0
11
- }
11
+ end
12
12
 
13
13
  body {
14
14
  rectangle(card_x, card_y, 49, 79, 15, 15) {
@@ -65,9 +65,9 @@ end
65
65
  class Login
66
66
  include Glimmer::UI::CustomShell
67
67
 
68
- before_body {
68
+ before_body do
69
69
  @presenter = LoginPresenter.new
70
- }
70
+ end
71
71
 
72
72
  body {
73
73
  shell {
@@ -149,33 +149,33 @@ class MandelbrotFractal
149
149
 
150
150
  option :zoom, default: 1.0
151
151
 
152
- before_body {
152
+ before_body do
153
153
  Display.app_name = 'Mandelbrot Fractal'
154
154
  # pre-calculate mandelbrot image
155
155
  @mandelbrot_image = build_mandelbrot_image
156
- }
156
+ end
157
157
 
158
- after_body {
159
- observe(Mandelbrot, :work_in_progress) {
158
+ after_body do
159
+ observe(Mandelbrot, :work_in_progress) do
160
160
  update_mandelbrot_shell_title!
161
- }
162
- observe(Mandelbrot, :zoom) {
161
+ end
162
+ observe(Mandelbrot, :zoom) do
163
163
  update_mandelbrot_shell_title!
164
- }
164
+ end
165
165
  # pre-calculate zoomed mandelbrot images even before the user zooms in
166
166
  puts 'Starting background calculation thread...'
167
- @thread = Thread.new {
167
+ @thread = Thread.new do
168
168
  future_zoom = 1.5
169
- loop {
169
+ loop do
170
170
  puts "Creating mandelbrot for background calculation at zoom: #{future_zoom}"
171
171
  the_mandelbrot = Mandelbrot.for(max_iterations: color_palette.size - 1, zoom: future_zoom, background: true)
172
172
  pixels = the_mandelbrot.calculate_points
173
173
  build_mandelbrot_image(mandelbrot_zoom: future_zoom)
174
174
  @canvas.cursor = :cross unless @canvas.disposed?
175
175
  future_zoom += 0.5
176
- }
177
- }
178
- }
176
+ end
177
+ end
178
+ end
179
179
 
180
180
  body {
181
181
  shell(:no_resize) {
@@ -192,13 +192,13 @@ end
192
192
  class MetaSampleApplication
193
193
  include Glimmer::UI::CustomShell
194
194
 
195
- before_body {
195
+ before_body do
196
196
  Sample.ensure_user_glimmer_directory
197
197
  selected_sample_directory = SampleDirectory.sample_directories.first
198
198
  selected_sample = selected_sample_directory.samples.first
199
199
  selected_sample_directory.selected_sample_name = selected_sample.name
200
200
  Display.app_name = 'Glimmer Meta-Sample'
201
- }
201
+ end
202
202
 
203
203
  body {
204
204
  shell(:fill_screen) {
@@ -64,9 +64,9 @@ class Metronome
64
64
 
65
65
  attr_accessor :rhythm
66
66
 
67
- before_body {
67
+ before_body do
68
68
  @rhythm = Rhythm.new(4)
69
- }
69
+ end
70
70
 
71
71
  body {
72
72
  shell(:no_resize) {
@@ -65,7 +65,7 @@ class StockTicker
65
65
 
66
66
  include Glimmer::UI::CustomShell
67
67
 
68
- before_body {
68
+ before_body do
69
69
  @stocks = [
70
70
  Stock.new('DELL', 81),
71
71
  Stock.new('AAPL', 121),
@@ -126,16 +126,16 @@ class StockTicker
126
126
  end
127
127
  end
128
128
  end
129
- }
129
+ end
130
130
 
131
- after_body {
132
- @thread = Thread.new {
133
- loop {
131
+ after_body do
132
+ @thread = Thread.new do
133
+ loop do
134
134
  @stocks.each(&:tick!)
135
135
  sleep(0.01)
136
- }
137
- }
138
- }
136
+ end
137
+ end
138
+ end
139
139
 
140
140
  body {
141
141
  shell {
@@ -43,7 +43,7 @@ class Tetris
43
43
 
44
44
  attr_reader :game
45
45
 
46
- before_body {
46
+ before_body do
47
47
  @mutex = Mutex.new
48
48
  @game = Model::Game.new(playfield_width, playfield_height)
49
49
 
@@ -99,9 +99,9 @@ class Tetris
99
99
  exit(0)
100
100
  }
101
101
  }
102
- }
102
+ end
103
103
 
104
- after_body {
104
+ after_body do
105
105
  observe(@game, :game_over) do |game_over|
106
106
  if game_over
107
107
  show_high_score_dialog
@@ -117,7 +117,7 @@ class Tetris
117
117
  end
118
118
  end
119
119
  @game.start!
120
- }
120
+ end
121
121
 
122
122
  body {
123
123
  shell(:no_resize) {
@@ -29,9 +29,9 @@ class Tetris
29
29
  option :x, default: 0
30
30
  option :y, default: 0
31
31
 
32
- before_body {
32
+ before_body do
33
33
  self.bevel_pixel_size = 0.16*size.to_f if bevel_pixel_size.nil?
34
- }
34
+ end
35
35
 
36
36
  body {
37
37
  rectangle(x, y, size, size) {
@@ -29,10 +29,10 @@ class Tetris
29
29
 
30
30
  options :block_size, :game
31
31
 
32
- before_body {
32
+ before_body do
33
33
  @font_name = FONT_NAME
34
34
  @font_height = FONT_TITLE_HEIGHT
35
- }
35
+ end
36
36
 
37
37
  body {
38
38
  composite {
@@ -26,16 +26,16 @@ require_relative "tic_tac_toe/board"
26
26
  class TicTacToe
27
27
  include Glimmer::UI::CustomShell
28
28
 
29
- before_body {
29
+ before_body do
30
30
  @tic_tac_toe_board = Board.new
31
- }
31
+ end
32
32
 
33
- after_body {
34
- observe(@tic_tac_toe_board, :game_status) { |game_status|
33
+ after_body do
34
+ observe(@tic_tac_toe_board, :game_status) do |game_status|
35
35
  display_win_message if game_status == Board::WIN
36
36
  display_draw_message if game_status == Board::DRAW
37
- }
38
- }
37
+ end
38
+ end
39
39
 
40
40
  body {
41
41
  shell {
@@ -20,7 +20,7 @@ class Timer
20
20
  ## Use before_body block to pre-initialize variables to use in body
21
21
  #
22
22
  #
23
- before_body {
23
+ before_body do
24
24
  Display.setAppName('Glimmer Timer')
25
25
 
26
26
  @display = display {
@@ -34,11 +34,11 @@ class Timer
34
34
 
35
35
  @min = 0
36
36
  @sec = 0
37
- }
37
+ end
38
38
 
39
39
  ## Use after_body block to setup observers for widgets in body
40
40
  #
41
- after_body {
41
+ after_body do
42
42
  Thread.new {
43
43
  loop {
44
44
  sleep(1)
@@ -56,7 +56,7 @@ class Timer
56
56
  end
57
57
  }
58
58
  }
59
- }
59
+ end
60
60
 
61
61
  ## Add widget content inside custom shell body
62
62
  ## Top-most widget must be a shell or another custom shell
@@ -33,13 +33,13 @@ class Weather
33
33
 
34
34
  attr_accessor :city, :temp, :temp_min, :temp_max, :feels_like, :humidity
35
35
 
36
- before_body {
36
+ before_body do
37
37
  @weather_mutex = Mutex.new
38
38
  self.city = 'Montreal, QC, CA'
39
39
  fetch_weather!
40
- }
40
+ end
41
41
 
42
- after_body {
42
+ after_body do
43
43
  Thread.new do
44
44
  loop do
45
45
  sleep(10)
@@ -47,7 +47,7 @@ class Weather
47
47
  fetch_weather!
48
48
  end
49
49
  end
50
- }
50
+ end
51
51
 
52
52
  body {
53
53
  shell(:no_resize) {
@@ -26,9 +26,9 @@ class HelloButton
26
26
 
27
27
  attr_accessor :count
28
28
 
29
- before_body {
29
+ before_body do
30
30
  @count = 0
31
- }
31
+ end
32
32
 
33
33
  body {
34
34
  shell {
@@ -38,9 +38,9 @@ class HelloCCombo
38
38
 
39
39
  include Glimmer::UI::CustomShell
40
40
 
41
- before_body {
41
+ before_body do
42
42
  @person = Person.new
43
- }
43
+ end
44
44
 
45
45
  body {
46
46
  shell {
@@ -27,19 +27,19 @@ class HelloCanvas
27
27
  attr_accessor :selected_shape
28
28
  attr_accessor :artist
29
29
 
30
- before_body {
30
+ before_body do
31
31
  @image_object = image(File.expand_path('../../icons/scaffold_app.png', __dir__), width: 50)
32
32
  @artist = ''
33
- }
33
+ end
34
34
 
35
- after_body {
35
+ after_body do
36
36
  Thread.new {
37
37
  'Picasso'.chars.each do |character|
38
38
  sleep(1)
39
39
  self.artist += character
40
40
  end
41
41
  }
42
- }
42
+ end
43
43
 
44
44
  body {
45
45
  shell {
@@ -27,14 +27,14 @@ class HelloCanvasAnimation
27
27
 
28
28
  attr_accessor :animation_every, :animation_fps, :animation_frame_count, :animation_duration_limit, :animation_started, :animation_finished
29
29
 
30
- before_body {
30
+ before_body do
31
31
  @animation_every = 0.050 # seconds
32
32
  @animation_fps = 0
33
33
  @animation_frame_count = 100
34
34
  @animation_duration_limit = 0 # seconds
35
35
  @animation_started = true
36
36
  @animation_finished = false
37
- }
37
+ end
38
38
 
39
39
  body {
40
40
  shell {
@@ -37,7 +37,7 @@ class HelloCanvasDataBinding
37
37
  [:solid, :dash, :dot, :dashdot, :dashdotdot]
38
38
  end
39
39
 
40
- before_body {
40
+ before_body do
41
41
  self.x1_value = 0
42
42
  self.y1_value = 0
43
43
  self.x2_value = CANVAS_WIDTH
@@ -47,7 +47,7 @@ class HelloCanvasDataBinding
47
47
  self.foreground_blue = 228
48
48
  self.line_width_value = 3
49
49
  self.line_style_value = :dot
50
- }
50
+ end
51
51
 
52
52
  body {
53
53
  shell {
@@ -39,9 +39,9 @@ class HelloCheckbox
39
39
 
40
40
  include Glimmer::UI::CustomShell
41
41
 
42
- before_body {
42
+ before_body do
43
43
  @person = Person.new
44
- }
44
+ end
45
45
 
46
46
  body {
47
47
  shell {
@@ -43,9 +43,9 @@ class HelloCheckboxGroup
43
43
 
44
44
  include Glimmer::UI::CustomShell
45
45
 
46
- before_body {
46
+ before_body do
47
47
  @person = Person.new
48
- }
48
+ end
49
49
 
50
50
  body {
51
51
  shell {
@@ -26,7 +26,7 @@ class HelloCodeText
26
26
 
27
27
  attr_accessor :ruby_code, :js_code, :html_code
28
28
 
29
- before_body {
29
+ before_body do
30
30
  self.ruby_code = <<~RUBY
31
31
  greeting = 'Hello, World!'
32
32
 
@@ -73,7 +73,7 @@ class HelloCodeText
73
73
  </body>
74
74
  </html>
75
75
  HTML
76
- }
76
+ end
77
77
 
78
78
  body {
79
79
  shell {
@@ -26,9 +26,9 @@ class HelloColorDialog
26
26
 
27
27
  attr_accessor :selected_color
28
28
 
29
- before_body {
29
+ before_body do
30
30
  self.selected_color = :black
31
- }
31
+ end
32
32
 
33
33
  body {
34
34
  shell {
@@ -37,9 +37,9 @@ class HelloCombo
37
37
 
38
38
  include Glimmer::UI::CustomShell
39
39
 
40
- before_body {
40
+ before_body do
41
41
  @person = Person.new
42
- }
42
+ end
43
43
 
44
44
  body {
45
45
  shell {
@@ -44,13 +44,13 @@ class HelloComputed
44
44
 
45
45
  include Glimmer::UI::CustomShell
46
46
 
47
- before_body {
47
+ before_body do
48
48
  @contact = Contact.new(
49
49
  first_name: 'Barry',
50
50
  last_name: 'McKibbin',
51
51
  year_of_birth: 1985
52
52
  )
53
- }
53
+ end
54
54
 
55
55
  body {
56
56
  shell {
@@ -66,51 +66,43 @@ class HelloComputed
66
66
 
67
67
  label {text 'First &Name: '}
68
68
  text {
69
+ fill_horizontally_layout_data
69
70
  text <=> [@contact, :first_name]
70
- layout_data {
71
- horizontal_alignment :fill
72
- grab_excess_horizontal_space true
73
- }
74
71
  }
75
72
 
76
73
  label {text '&Last Name: '}
77
74
  text {
75
+ fill_horizontally_layout_data
78
76
  text <=> [@contact, :last_name]
79
- layout_data {
80
- horizontal_alignment :fill
81
- grab_excess_horizontal_space true
82
- }
83
77
  }
84
78
 
85
79
  label {text '&Year of Birth: '}
86
80
  text {
81
+ fill_horizontally_layout_data
87
82
  text <=> [@contact, :year_of_birth]
88
- layout_data {
89
- horizontal_alignment :fill
90
- grab_excess_horizontal_space true
91
- }
92
83
  }
93
84
 
94
85
  label {text 'Name: '}
95
86
  label {
87
+ fill_horizontally_layout_data
96
88
  text <= [@contact, :name, computed_by: [:first_name, :last_name]]
97
- layout_data {
98
- horizontal_alignment :fill
99
- grab_excess_horizontal_space true
100
- }
101
89
  }
102
90
 
103
91
  label {text 'Age: '}
104
92
  label {
93
+ fill_horizontally_layout_data
105
94
  text <= [@contact, :age, on_write: :to_i, computed_by: [:year_of_birth]]
106
- layout_data {
107
- horizontal_alignment :fill
108
- grab_excess_horizontal_space true
109
- }
110
95
  }
111
96
  }
112
97
  }
113
98
  }
99
+
100
+ def fill_horizontally_layout_data
101
+ layout_data {
102
+ horizontal_alignment :fill
103
+ grab_excess_horizontal_space true
104
+ }
105
+ end
114
106
  end
115
107
 
116
108
  HelloComputed.launch
@@ -30,9 +30,9 @@ class HelloCoolBar
30
30
  (10..30).to_a.map(&:to_s)
31
31
  end
32
32
 
33
- before_body {
33
+ before_body do
34
34
  self.font_size = '30'
35
- }
35
+ end
36
36
 
37
37
  body {
38
38
  shell {
@@ -31,11 +31,11 @@ class HelloCursor
31
31
  Glimmer::SWT::SWTProxy.cursor_options
32
32
  end
33
33
 
34
- after_body {
34
+ after_body do
35
35
  observe(self, :selected_cursor) {
36
36
  body_root.cursor = selected_cursor
37
37
  }
38
- }
38
+ end
39
39
 
40
40
  body {
41
41
  shell {
@@ -27,12 +27,12 @@ class StickFigure
27
27
 
28
28
  options :x, :y, :width, :height
29
29
 
30
- before_body {
30
+ before_body do
31
31
  @head_width = width*0.2
32
32
  @head_height = height*0.2
33
33
  @trunk_height = height*0.4
34
34
  @extremity_length = height*0.4
35
- }
35
+ end
36
36
 
37
37
  body {
38
38
  shape(x + @head_width/2.0 + @extremity_length, y) {
@@ -34,9 +34,9 @@ class EmailShell
34
34
  # single option with default value
35
35
  option :to, default: '"John Irwin" <john.irwin@example.com>'
36
36
 
37
- before_body {
37
+ before_body do
38
38
  @swt_style |= swt(:shell_trim, :modeless)
39
- }
39
+ end
40
40
 
41
41
  body {
42
42
  # pass received swt_style through to shell to customize it (e.g. :dialog_trim for a blocking shell)
@@ -34,12 +34,12 @@ class GreetingLabel
34
34
  # internal attribute (not a custom widget option)
35
35
  attr_accessor :color
36
36
 
37
- before_body {
37
+ before_body do
38
38
  @font = {height: 24, style: :bold}
39
39
  @color = :black
40
- }
40
+ end
41
41
 
42
- after_body {
42
+ after_body do
43
43
  return if colors.nil?
44
44
 
45
45
  Thread.new {
@@ -48,7 +48,7 @@ class GreetingLabel
48
48
  sleep(1)
49
49
  }
50
50
  }
51
- }
51
+ end
52
52
 
53
53
  body {
54
54
  # pass received swt_style through to label to customize (e.g. :center to center text)
@@ -28,10 +28,10 @@ class HelloDateTime
28
28
 
29
29
  include Glimmer::UI::CustomShell
30
30
 
31
- before_body {
31
+ before_body do
32
32
  @person = Person.new
33
33
  @person.date_of_birth = DateTime.new(2013, 7, 12, 18, 37, 23)
34
- }
34
+ end
35
35
 
36
36
  body {
37
37
  shell {
@@ -26,9 +26,9 @@ class HelloDirectoryDialog
26
26
 
27
27
  attr_accessor :selected_directory
28
28
 
29
- before_body {
29
+ before_body do
30
30
  @selected_directory = 'Please select a directory.'
31
- }
31
+ end
32
32
 
33
33
  body {
34
34
  shell {
@@ -26,9 +26,9 @@ class HelloFileDialog
26
26
 
27
27
  attr_accessor :selected_file
28
28
 
29
- before_body {
29
+ before_body do
30
30
  @selected_file = 'Please select a file.'
31
- }
31
+ end
32
32
 
33
33
  body {
34
34
  shell {
@@ -26,9 +26,9 @@ class HelloFontDialog
26
26
 
27
27
  attr_accessor :selected_font_data
28
28
 
29
- before_body {
29
+ before_body do
30
30
  @selected_font_data = FontData.new('Times New Roman', 40, swt(:bold))
31
- }
31
+ end
32
32
 
33
33
  body {
34
34
  shell {
@@ -41,9 +41,9 @@ class HelloGroup
41
41
 
42
42
  include Glimmer::UI::CustomShell
43
43
 
44
- before_body {
44
+ before_body do
45
45
  @person = Person.new
46
- }
46
+ end
47
47
 
48
48
  body {
49
49
  shell {
@@ -52,9 +52,9 @@ class HelloListMultiSelection
52
52
 
53
53
  include Glimmer::UI::CustomShell
54
54
 
55
- before_body {
55
+ before_body do
56
56
  @person = Person.new
57
- }
57
+ end
58
58
 
59
59
  body {
60
60
  shell {
@@ -37,9 +37,9 @@ class HelloListSingleSelection
37
37
 
38
38
  include Glimmer::UI::CustomShell
39
39
 
40
- before_body {
40
+ before_body do
41
41
  @person = Person.new
42
- }
42
+ end
43
43
 
44
44
  body {
45
45
  shell {
@@ -28,13 +28,13 @@ class HelloProgressBar
28
28
  attr_accessor :minimum, :maximum, :selection, :delay
29
29
  end
30
30
 
31
- before_body {
31
+ before_body do
32
32
  @progress_model = ProgressModel.new
33
33
  @progress_model.minimum = 0
34
34
  @progress_model.maximum = 100
35
35
  @progress_model.selection = 0
36
36
  @progress_model.delay = 0.01
37
- }
37
+ end
38
38
 
39
39
  body {
40
40
  shell {
@@ -41,9 +41,9 @@ class HelloRadio
41
41
 
42
42
  include Glimmer::UI::CustomShell
43
43
 
44
- before_body {
44
+ before_body do
45
45
  @person = Person.new
46
- }
46
+ end
47
47
 
48
48
  body {
49
49
  shell {
@@ -48,9 +48,9 @@ class HelloRadioGroup
48
48
 
49
49
  include Glimmer::UI::CustomShell
50
50
 
51
- before_body {
51
+ before_body do
52
52
  @person = Person.new
53
- }
53
+ end
54
54
 
55
55
  body {
56
56
  shell {
@@ -26,9 +26,9 @@ class HelloScale
26
26
 
27
27
  attr_accessor :value
28
28
 
29
- before_body {
29
+ before_body do
30
30
  @value = 50
31
- }
31
+ end
32
32
 
33
33
  body {
34
34
  shell {
@@ -28,10 +28,10 @@ class HelloSpinner
28
28
 
29
29
  include Glimmer::UI::CustomShell
30
30
 
31
- before_body {
31
+ before_body do
32
32
  @person = Person.new
33
33
  @person.donation = 500 # in cents
34
- }
34
+ end
35
35
 
36
36
  body {
37
37
  shell {
@@ -183,9 +183,9 @@ class HelloTable
183
183
 
184
184
  include Glimmer::UI::CustomShell
185
185
 
186
- before_body {
186
+ before_body do
187
187
  Display.app_name = 'Hello, Table!'
188
- }
188
+ end
189
189
 
190
190
  body {
191
191
  shell {
@@ -5,7 +5,7 @@ class HelloText
5
5
 
6
6
  attr_accessor :default, :center, :left, :right, :password, :telephone, :read_only, :wrap, :multi
7
7
 
8
- before_body {
8
+ before_body do
9
9
  self.default = 'default is :border style'
10
10
  self.center = 'centered'
11
11
  self.left = 'left-aligned'
@@ -15,7 +15,7 @@ class HelloText
15
15
  self.read_only = 'Telephone area code is 555'
16
16
  self.wrap = 'wraps if text content is too long like this example'
17
17
  self.multi = "multi-line enables hitting enter,\nbut does not wrap by default"
18
- }
18
+ end
19
19
 
20
20
  body {
21
21
  shell {
@@ -30,9 +30,9 @@ class HelloToolBar
30
30
  (10..30).to_a.map(&:to_s)
31
31
  end
32
32
 
33
- before_body {
33
+ before_body do
34
34
  self.font_size = '30'
35
- }
35
+ end
36
36
 
37
37
  body {
38
38
  shell {
@@ -27,7 +27,7 @@ class HelloTrayItem
27
27
  # boolean that indicates if application is visible
28
28
  attr_accessor :show_application
29
29
 
30
- before_body {
30
+ before_body do
31
31
  # application starts visible
32
32
  @show_application = true
33
33
  # pre-render an icon image using the Canvas Shape DSL
@@ -48,7 +48,7 @@ class HelloTrayItem
48
48
  foreground :white
49
49
  }
50
50
  }
51
- }
51
+ end
52
52
 
53
53
  body {
54
54
  shell(:shell_trim, :on_top) { # make it always appear on top of everything
@@ -288,13 +288,13 @@ class HelloTree
288
288
 
289
289
  include Glimmer::UI::CustomShell
290
290
 
291
- before_body {
291
+ before_body do
292
292
  Employee.selected_employee = Employee.ceo
293
- }
293
+ end
294
294
 
295
- after_body {
295
+ after_body do
296
296
  @tree.items.first.expanded = true
297
- }
297
+ end
298
298
 
299
299
  body {
300
300
  shell {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-swt
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.20.13.9
4
+ version: 4.20.13.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh