glimmer-dsl-swt 4.20.13.10 → 4.20.13.11

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: 982e9293313f88fc19f63d148e0b59b1dcda227e25bc47d9eb07377359b90084
4
- data.tar.gz: c90ad4be0b5ebf2aaa28b5b0376934e518f7fbe878a3ecb4a37982fa5feac554
3
+ metadata.gz: 431a3ee9e9fdbc1565e616a3ebee9e7bc7f026cae40d9c95a2df304647b3880b
4
+ data.tar.gz: 7b0bea9d898d0f42d5788ef36ce4279e81f3b3491c1102c148656f5c0e979328
5
5
  SHA512:
6
- metadata.gz: 6946dfd8d245a2ef28df3df0c7eb3b74213f4c912c69a6de5ce0bd4f42d7b69f87671df845a816c532d6b580bd0f9da535639368aba6ed0abd76d689c66ded07
7
- data.tar.gz: c630515458b13ab4b08c6c662c27759c9a0adb8903e5f0a5e20aba958792d3949f48ae47d9849ffddbe52d4a7b33887955979d76ffe6223871cc51e8f844c443
6
+ metadata.gz: 03a6fd9ea40d222acd37118cf42a7b299995ded46e334f8d9bff73fed74dc4db1e57913eaca40109bda7962977eafb546b92dbb8fdb72309ec9f5cf7c591d644
7
+ data.tar.gz: a9a3ed0e5e6cd57b26c64b6d030bdc35d14a29cb3576b11ed9e086d66a8dc7f76b206dd40539ed271e042b1073a85bca53f24415c68058df71b4571de93a161b
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.10
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.11
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.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).
18
+ [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.20.13.11 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.10
329
+ jgem install glimmer-dsl-swt -v 4.20.13.11
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.10'
357
+ gem 'glimmer-dsl-swt', '~> 4.20.13.11'
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.10
378
+ Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.20.13.11
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.10
1
+ 4.20.13.11
@@ -61,6 +61,7 @@
61
61
  - [Login](#login)
62
62
  - [Tic Tac Toe](#tic-tac-toe)
63
63
  - [Contact Manager](#contact-manager)
64
+ - [Game of Life](#game-of-life)
64
65
  - [Glimmer Tetris](#glimmer-tetris)
65
66
  - [Klondike Solitaire](#klondike-solitaire)
66
67
  - [Mandelbrot Fractal](#mandelbrot-fractal)
@@ -1071,6 +1072,16 @@ Contact Manager - Edit Done
1071
1072
 
1072
1073
  ![Contact Manager](/images/glimmer-contact-manager-edit-done.png)
1073
1074
 
1075
+ #### Game of Life
1076
+
1077
+ This sample demonstrates how to build an interactive canvas-based visualization of Conway's Game of Life (test-first), taking advantage of data-binding and multi-threading.
1078
+
1079
+ Code:
1080
+
1081
+ [samples/elaborate/game_of_life.rb](/samples/elaborate/game_of_life.rb)
1082
+
1083
+ ![Game of Life](/images/glimmer-game-of-life.gif)
1084
+
1074
1085
  #### Glimmer Tetris
1075
1086
 
1076
1087
  This sample demonstrates how to build an interactive animated game with MVC architecture, custom-shell/custom-widgets, multi-threading, asynchronous programming, data-binding, canvas shape graphic decorations, canvas shape icon image generation, and keyboard events/shortcuts.
@@ -1101,15 +1112,15 @@ Code:
1101
1112
 
1102
1113
  #### Klondike Solitaire
1103
1114
 
1104
- This sample demonstrates how to build an interactive card game with MVC architecture, custom-shell/custom-widgets, data-binding, observers, and drag & drop.
1115
+ This sample demonstrates how to build an interactive card game with MVC architecture, canvas, custom-shapes, data-binding, observers, and drag & drop.
1105
1116
 
1106
1117
  Code:
1107
1118
 
1108
1119
  [samples/elaborate/klondike_solitaire.rb](/samples/elaborate/klondike_solitaire.rb)
1109
1120
 
1110
- ![Tetris](/images/glimmer-klondike-solitaire.png)
1121
+ ![Klondike Solitaire](/images/glimmer-klondike-solitaire.png)
1111
1122
 
1112
- ![Tetris](/images/glimmer-klondike-solitaire-played.png)
1123
+ ![Klondike Solitaire Played](/images/glimmer-klondike-solitaire-played.png)
1113
1124
 
1114
1125
  #### Mandelbrot Fractal
1115
1126
 
Binary file
@@ -0,0 +1,111 @@
1
+ # Copyright (c) 2007-2021 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require 'glimmer-dsl-swt'
23
+
24
+ require_relative 'game_of_life/model/grid'
25
+
26
+ class GameOfLife
27
+ include Glimmer::UI::CustomShell
28
+
29
+ WIDTH = 20
30
+ HEIGHT = 20
31
+ CELL_WIDTH = 25
32
+ CELL_HEIGHT = 25
33
+
34
+ before_body do
35
+ @grid = GameOfLife::Model::Grid.new(WIDTH, HEIGHT)
36
+ end
37
+
38
+ body {
39
+ shell {
40
+ row_layout :vertical
41
+ text "Conway's Game of Life (Glimmer Edition)"
42
+
43
+ canvas {
44
+ layout_data {
45
+ width WIDTH*CELL_WIDTH
46
+ height HEIGHT*CELL_HEIGHT
47
+ }
48
+ (0...HEIGHT).each do |row_index|
49
+ (0...WIDTH).each do |column_index|
50
+ rectangle(column_index*CELL_WIDTH, row_index*CELL_HEIGHT, CELL_WIDTH, CELL_HEIGHT) {
51
+ background <= [@grid.cell_rows[row_index][column_index], "alive", on_read: ->(a) {a ? :black : :white}]
52
+
53
+ on_mouse_down {
54
+ @grid.cell_rows[row_index][column_index].toggle_aliveness!
55
+ }
56
+ }
57
+ end
58
+ end
59
+ }
60
+
61
+ composite {
62
+ row_layout(:horizontal) {
63
+ margin_width 0
64
+ }
65
+
66
+ button {
67
+ text 'Step'
68
+ enabled <= [@grid, :playing, on_read: :! ]
69
+
70
+ on_widget_selected {
71
+ @grid.step!
72
+ }
73
+ }
74
+
75
+ button {
76
+ text 'Clear'
77
+ enabled <= [@grid, :playing, on_read: :! ]
78
+
79
+ on_widget_selected {
80
+ @grid.clear!
81
+ }
82
+ }
83
+
84
+ button {
85
+ text <= [@grid, :playing, on_read: ->(p) { p ? 'Stop' : 'Play' }]
86
+
87
+ on_widget_selected {
88
+ @grid.toggle_playback!
89
+ }
90
+ }
91
+
92
+ label {
93
+ text 'Slower'
94
+ }
95
+
96
+ scale {
97
+ minimum 1
98
+ maximum 100
99
+ selection <=> [@grid, :speed]
100
+ }
101
+
102
+ label {
103
+ text 'Faster'
104
+ }
105
+
106
+ }
107
+ }
108
+ }
109
+ end
110
+
111
+ GameOfLife.launch
@@ -0,0 +1,51 @@
1
+ class GameOfLife
2
+ module Model
3
+ class Cell
4
+ attr_reader :grid, :row_index, :column_index
5
+ attr_accessor :alive
6
+ alias alive? alive
7
+
8
+ def initialize(grid, row_index, column_index, alive=false)
9
+ @grid = grid
10
+ @row_index = row_index
11
+ @column_index = column_index
12
+ @alive = alive
13
+ end
14
+
15
+ def live!
16
+ self.alive = true
17
+ end
18
+
19
+ def die!
20
+ self.alive = false
21
+ end
22
+
23
+ def toggle_aliveness!
24
+ return if grid.playing?
25
+ dead ? live! : die!
26
+ end
27
+
28
+ def dead?
29
+ !alive?
30
+ end
31
+ alias dead dead?
32
+
33
+ # step into the next generation
34
+ def step!
35
+ self.alive = (alive? && alive_neighbor_count.between?(2, 3)) || (dead? && alive_neighbor_count == 3)
36
+ end
37
+
38
+ def alive_neighbor_count
39
+ [row_index - 1, 0].max.upto([row_index + 1, grid.row_count - 1].min).map do |current_row_index|
40
+ [column_index - 1, 0].max.upto([column_index + 1, grid.column_count - 1].min).map do |current_column_index|
41
+ if current_row_index == row_index && current_column_index == column_index
42
+ 0
43
+ else
44
+ grid.previous_cell_rows[current_row_index][current_column_index].alive? ? 1 : 0
45
+ end
46
+ end
47
+ end.flatten.reduce(:+)
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,76 @@
1
+ require_relative 'cell'
2
+
3
+ class GameOfLife
4
+ module Model
5
+ class Grid
6
+ include Glimmer # included only to utilize sync_exec/async_exec
7
+ DEFAULT_ROW_COUNT = 100
8
+ DEFAULT_COLUMN_COUNT = 100
9
+
10
+ attr_reader :row_count, :column_count
11
+ attr_accessor :cell_rows, :previous_cell_rows, :playing, :speed
12
+ alias playing? playing
13
+
14
+ def initialize(row_count=DEFAULT_ROW_COUNT, column_count=DEFAULT_COLUMN_COUNT)
15
+ @row_count = row_count
16
+ @column_count = column_count
17
+ @speed = 1.0
18
+ build_cells
19
+ end
20
+
21
+ def clear!
22
+ cell_rows.each do |row|
23
+ row.each do |cell|
24
+ cell.die!
25
+ end
26
+ end
27
+ end
28
+
29
+ # steps into the next generation of cells given their current neighbors
30
+ def step!
31
+ self.previous_cell_rows = cell_rows.map do |row|
32
+ row.map do |cell|
33
+ cell.clone
34
+ end
35
+ end
36
+ cell_rows.each do |row|
37
+ row.each do |cell|
38
+ cell.step!
39
+ end
40
+ end
41
+ end
42
+
43
+ def toggle_playback!
44
+ if playing?
45
+ stop!
46
+ else
47
+ play!
48
+ end
49
+ end
50
+
51
+ def play!
52
+ self.playing = true
53
+ Thread.new do
54
+ while @playing
55
+ sync_exec { step! }
56
+ sleep(1.0/@speed)
57
+ end
58
+ end
59
+ end
60
+
61
+ def stop!
62
+ self.playing = false
63
+ end
64
+
65
+ private
66
+
67
+ def build_cells
68
+ @cell_rows = @row_count.times.map do |row_index|
69
+ @column_count.times.map do |column_index|
70
+ Cell.new(self, row_index, column_index)
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-swt
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.20.13.10
4
+ version: 4.20.13.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-31 00:00:00.000000000 Z
11
+ date: 2021-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -545,6 +545,9 @@ files:
545
545
  - samples/elaborate/contact_manager/contact.rb
546
546
  - samples/elaborate/contact_manager/contact_manager_presenter.rb
547
547
  - samples/elaborate/contact_manager/contact_repository.rb
548
+ - samples/elaborate/game_of_life.rb
549
+ - samples/elaborate/game_of_life/model/cell.rb
550
+ - samples/elaborate/game_of_life/model/grid.rb
548
551
  - samples/elaborate/klondike_solitaire.rb
549
552
  - samples/elaborate/klondike_solitaire/model/column_pile.rb
550
553
  - samples/elaborate/klondike_solitaire/model/dealing_pile.rb