glimmer-dsl-swt 4.20.13.8 → 4.20.13.9

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: 59508a178a1694489ba4ec995672f08a0997b01c8ebaeb39cecd2db250d0f88b
4
- data.tar.gz: 9610a96bf71aa15a581dedda77f9c11942286f1ff5f7ac96369624c97a798f28
3
+ metadata.gz: c7f34d2baa127f20cc05b387d51afed496456ee236e5a206594c1b5bd672aa56
4
+ data.tar.gz: e19feae85a8f5b29fee1c40eb259618b95b235ce7b41e847e8277a124e5ae362
5
5
  SHA512:
6
- metadata.gz: 1f2219231093b33e6c32637dd2a6ee2249e3c64daf3f92355c57ab170d15c6bfd4930d540c3703c0a4c926ff9e6c322ddc4dd119938be9bc23ccf19935c84675
7
- data.tar.gz: 98c6a6e4b2f26fde8d9741eb04054866c145366c27a728343f71f6f960c5eba411fa127167101da055d96241b3c66fb7c7d8dbba91256fa9688d694165158cdc
6
+ metadata.gz: e8fa48e0b887ed4a772eda18f997ed91f5ad2005d3aeae9aa1e1fccd2baffbdeb3e9578a56c2ca51b04eda425dc7b1ef420bf9bb6ab1b2fe28bde0aefc820dd2
7
+ data.tar.gz: 89a9947c73556344f300e7db6fe8d43913f1d089c041d5416b9c0b69367549764978c990737da74c157d573118d81c0a771ff06025676b5b3ba781f30e095853
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.7
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
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.7 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.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).
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.7
329
+ jgem install glimmer-dsl-swt -v 4.20.13.9
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.7'
357
+ gem 'glimmer-dsl-swt', '~> 4.20.13.9'
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.7
378
+ Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.20.13.9
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.8
1
+ 4.20.13.9
@@ -62,6 +62,7 @@
62
62
  - [Tic Tac Toe](#tic-tac-toe)
63
63
  - [Contact Manager](#contact-manager)
64
64
  - [Glimmer Tetris](#glimmer-tetris)
65
+ - [Klondike Solitaire](#klondike-solitaire)
65
66
  - [Mandelbrot Fractal](#mandelbrot-fractal)
66
67
  - [Stock Ticker](#stock-ticker)
67
68
  - [Metronome](#metronome)
@@ -1098,6 +1099,18 @@ Code:
1098
1099
 
1099
1100
  ![Tetris Help Menu](/images/glimmer-tetris-help-menu.png)
1100
1101
 
1102
+ #### Klondike Solitaire
1103
+
1104
+ This sample demonstrates how to build an interactive card game with MVC architecture, custom-shell/custom-widgets, data-binding, observers, and drag & drop.
1105
+
1106
+ Code:
1107
+
1108
+ [samples/elaborate/klondike_solitaire.rb](/samples/elaborate/klondike_solitaire.rb)
1109
+
1110
+ ![Tetris](/images/glimmer-klondike-solitaire.png)
1111
+
1112
+ ![Tetris](/images/glimmer-klondike-solitaire-played.png)
1113
+
1101
1114
  #### Mandelbrot Fractal
1102
1115
 
1103
1116
  This sample demonstrates how to render canvas graphics with multi-threaded processing taking advantage of all CPU cores and doing background processing of images.
Binary file
@@ -11,6 +11,10 @@ class KlondikeSolitaire
11
11
  PLAYING_CARD_WIDTH = 50
12
12
  PLAYING_CARD_HEIGHT = 80
13
13
  PLAYING_CARD_SPACING = 5
14
+ MARGIN = 15
15
+ TABLEAU_WIDTH = 2*MARGIN + 7*(PLAYING_CARD_WIDTH + PLAYING_CARD_SPACING)
16
+ TABLEAU_HEIGHT = 400
17
+
14
18
 
15
19
  ## Add options like the following to configure CustomShell by outside consumers
16
20
  #
@@ -48,20 +52,42 @@ class KlondikeSolitaire
48
52
  row_layout(:vertical) {
49
53
  fill true
50
54
  center true
55
+ margin_width 0
56
+ margin_height 0
57
+ margin_top 15
51
58
  }
52
- minimum_size 400, 400
59
+ minimum_size TABLEAU_WIDTH, TABLEAU_HEIGHT
53
60
  text "Glimmer Klondike Solitaire"
54
61
  background :dark_green
55
62
 
56
63
  action_panel(game: @game)
57
64
  tableau(game: @game) {
58
65
  layout_data {
59
- width 380
60
- height 400
66
+ width TABLEAU_WIDTH
67
+ height TABLEAU_HEIGHT
61
68
  }
62
69
  }
63
70
 
64
71
  menu_bar {
72
+ menu {
73
+ text '&Game'
74
+ menu_item {
75
+ text '&Restart'
76
+ accelerator (OS.mac? ? :command : :ctrl), :r
77
+
78
+ on_widget_selected {
79
+ @game.restart!
80
+ }
81
+ }
82
+ menu_item {
83
+ text 'E&xit'
84
+ accelerator :alt, :f4
85
+
86
+ on_widget_selected {
87
+ body_root.close
88
+ }
89
+ }
90
+ }
65
91
  menu {
66
92
  text '&Help'
67
93
  menu_item {
@@ -22,6 +22,34 @@ class KlondikeSolitaire
22
22
  new(rank, suit)
23
23
  end
24
24
  end
25
+
26
+ def rank_text(rank)
27
+ case rank
28
+ when 1
29
+ 'A'
30
+ when 11
31
+ 'J'
32
+ when 12
33
+ 'Q'
34
+ when 13
35
+ 'K'
36
+ else
37
+ rank
38
+ end
39
+ end
40
+
41
+ def suit_text(suit)
42
+ case suit
43
+ when :spades
44
+ "♠"
45
+ when :hearts
46
+ "♥"
47
+ when :clubs
48
+ "♣"
49
+ when :diamonds
50
+ "♦"
51
+ end
52
+ end
25
53
  end
26
54
 
27
55
  attr_reader :rank, :suit
@@ -45,6 +73,14 @@ class KlondikeSolitaire
45
73
  def to_s
46
74
  "Playing Card #{rank}#{suit.to_s[0].upcase}"
47
75
  end
76
+
77
+ def suit_text
78
+ self.class.suit_text(suit)
79
+ end
80
+
81
+ def rank_text
82
+ self.class.rank_text(rank)
83
+ end
48
84
  end
49
85
  end
50
86
  end
@@ -1,3 +1,5 @@
1
+ require_relative '../model/playing_card'
2
+
1
3
  class KlondikeSolitaire
2
4
  module View
3
5
  class EmptyPlayingCard
@@ -11,10 +13,11 @@ class KlondikeSolitaire
11
13
 
12
14
  if suit
13
15
  text {
14
- string suit.to_s[0].upcase
16
+ string Model::PlayingCard.suit_text(suit)
15
17
  x :default
16
18
  y :default
17
19
  is_transparent true
20
+ foreground Model::PlayingCard::BLACK_SUITS.include?(suit) ? :black : :red
18
21
  }
19
22
  end
20
23
  }
@@ -21,7 +21,7 @@ class KlondikeSolitaire
21
21
 
22
22
  unless model.hidden?
23
23
  text {
24
- string model ? "#{model.rank} #{model.suit.to_s[0].upcase}" : ""
24
+ string model ? "#{model.rank_text}#{model.suit_text}" : ""
25
25
  x 5
26
26
  y 5
27
27
  foreground model ? model.color : :transparent
@@ -18,14 +18,14 @@ class KlondikeSolitaire
18
18
 
19
19
  # row 1
20
20
  @foundation_piles = Model::PlayingCard::SUITS.each_with_index.map do |suit, i|
21
- foundation_pile(pile_x: i*(PLAYING_CARD_WIDTH + PLAYING_CARD_SPACING), pile_y: 0, game: game, suit: suit)
21
+ foundation_pile(pile_x: MARGIN + i*(PLAYING_CARD_WIDTH + PLAYING_CARD_SPACING), pile_y: 0, game: game, suit: suit)
22
22
  end
23
- @dealt_pile = dealt_pile(pile_x: 5*(PLAYING_CARD_WIDTH + PLAYING_CARD_SPACING), pile_y: 0, model: game.dealt_pile)
24
- @dealing_pile = dealing_pile(pile_x: 6*(PLAYING_CARD_WIDTH + PLAYING_CARD_SPACING), pile_y: 0, model: game.dealing_pile)
23
+ @dealt_pile = dealt_pile(pile_x: MARGIN + 5*(PLAYING_CARD_WIDTH + PLAYING_CARD_SPACING), pile_y: 0, model: game.dealt_pile)
24
+ @dealing_pile = dealing_pile(pile_x: MARGIN + 6*(PLAYING_CARD_WIDTH + PLAYING_CARD_SPACING), pile_y: 0, model: game.dealing_pile)
25
25
 
26
26
  # row 2
27
27
  @column_piles = 7.times.map do |n|
28
- column_pile(pile_x: n*(PLAYING_CARD_WIDTH + PLAYING_CARD_SPACING), pile_y: PLAYING_CARD_HEIGHT + PLAYING_CARD_SPACING, model: game.column_piles[n])
28
+ column_pile(pile_x: MARGIN + n*(PLAYING_CARD_WIDTH + PLAYING_CARD_SPACING), pile_y: PLAYING_CARD_HEIGHT + PLAYING_CARD_SPACING, model: game.column_piles[n])
29
29
  end
30
30
 
31
31
  on_mouse_up do |event|
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.8
4
+ version: 4.20.13.9
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-30 00:00:00.000000000 Z
11
+ date: 2021-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement