glimmer-dsl-swt 4.18.7.0 → 4.18.7.1

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: 3b4bc038d1fcf459041884946826daa84949318cd2d588f30bbc91ce9cc343f3
4
- data.tar.gz: 143c076d20310e24ca2a6bd5db70f7bd87bd7c7b171a501c23874cdfd1a989f8
3
+ metadata.gz: 8c03c6efd05eba6fe6eec003225d5058e15ff231c888bf6858e1ba5a24bbe632
4
+ data.tar.gz: 2a093d8817f965994c0d10830b9ef7f78820992b9cdc81a13455a03b859b1b9e
5
5
  SHA512:
6
- metadata.gz: ae508739a7a491f83853d67867b0c1600323216615909a1cca6aac4b2f373d5d74cad21c6dd08275ed83bc4e537e4b13ef357fdda436cbc6966dec821a3aade7
7
- data.tar.gz: 7c8110b246fbc0ee40d99fd930be19d782e75846ada53ad2fe09c742cec5bf2de36f59ccbabd4600d81bc6ac4b7183fae397c6590bce2fd8377d7ca38c89e3f1
6
+ metadata.gz: 03c8cf962cbfdee80d1b308c2c0d33a1ba721bb6c9b765b45764c47f14eeee24f0a3034998f843097e016d7c44353e0541cea1d01c702a037622c64580ee22c8
7
+ data.tar.gz: 27dfa02af89e29c5481ca00cf68a095701fc6bfdde523e574512a52ff5906560546364eab798facf244b81da9446becd3c15a9e037570c80b03af971bcc449b3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.18.7.1
4
+
5
+ - Hello, Canvas Animation Data Binding! Sample
6
+ - Metronome Elaborate Sample
7
+ - Update Hello, Spinner! Sample to data bind a Thank you message to selected value
8
+
3
9
  ### 4.18.7.0
4
10
 
5
11
  - Support direct use of the `shape` keyword as a shape composite that could contain other shapes and shares common attributes (e.g. background color) with all of them
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.18.7.0
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.18.7.1
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)
@@ -13,7 +13,7 @@
13
13
  [<img src="https://covers.oreillystatic.com/images/9780596519650/lrg.jpg" width=105 /><br />
14
14
  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)
15
15
 
16
- [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.18.7.0 includes [SWT 4.18](https://download.eclipse.org/eclipse/downloads/drops4/R-4.18-202012021800/), which was released on December 2, 2020. 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.
16
+ [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.18.7.1 includes [SWT 4.18](https://download.eclipse.org/eclipse/downloads/drops4/R-4.18-202012021800/), which was released on December 2, 2020. 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.
17
17
 
18
18
  [Glimmer DSL for SWT receives two updates per month](https://rubygems.org/gems/glimmer-dsl-swt/versions). You can trust [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) with your Ruby desktop GUI development needs! [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) brings great ideas to the table, such as declarative programming via domain specific languages, currently under-utilized in the GUI domain. That said, it may not be feature complete enough for everybody's needs, so please help make [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) even better by providing feedback and [contributing](#contributing) when possible. The project is very active, so any feature suggestions that are accepted could be implemented within weeks if not days. Also, you are welcome to [hire me](#hire-me) full-time if you want long-term development of [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) for your project needs.
19
19
 
@@ -340,7 +340,7 @@ jgem install glimmer-dsl-swt
340
340
 
341
341
  Or this command if you want a specific version:
342
342
  ```
343
- jgem install glimmer-dsl-swt -v 4.18.7.0
343
+ jgem install glimmer-dsl-swt -v 4.18.7.1
344
344
  ```
345
345
 
346
346
  `jgem` is JRuby's version of `gem` command.
@@ -358,7 +358,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
358
358
 
359
359
  Add the following to `Gemfile`:
360
360
  ```
361
- gem 'glimmer-dsl-swt', '~> 4.18.7.0'
361
+ gem 'glimmer-dsl-swt', '~> 4.18.7.1'
362
362
  ```
363
363
 
364
364
  And, then run:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.18.7.0
1
+ 4.18.7.1
@@ -2191,7 +2191,7 @@ API of Animation Object (returned from `animation` keyword):
2191
2191
  - `#cycle_limited?` returns true if `cycle_count` is specified
2192
2192
  - `#duration_limited?` returns true if `duration_limit` is specified
2193
2193
 
2194
- Learn more at the [Hello, Canvas Animation! Sample](GLIMMER_SAMPLES.md#hello-canvas-animation).
2194
+ Learn more at the [Hello, Canvas Animation!](GLIMMER_SAMPLES.md#hello-canvas-animation) and [Hello, Canvas Animation Data Binding!](GLIMMER_SAMPLES.md#hello-canvas-animation-data-binding) samples.
2195
2195
 
2196
2196
  If there is anything missing you would like added to the Glimmer Animation DSL that you saw available in the SWT APIs, you may [report an issue](https://github.com/AndyObtiva/glimmer-dsl-swt/issues) or implement yourself and [contribute](#contributing) via a Pull Request.
2197
2197
 
@@ -32,6 +32,7 @@
32
32
  - [Hello, Code Text!](#hello-code-text)
33
33
  - [Hello, Canvas!](#hello-canvas)
34
34
  - [Hello, Canvas Animation!](#hello-canvas-animation)
35
+ - [Hello, Canvas Animation Data Binding!](#hello-canvas-animation-data-binding)
35
36
  - [Hello, Canvas Transform!](#hello-canvas-transform)
36
37
  - [Hello, Canvas Path!](#hello-canvas-path)
37
38
  - [Hello, Canvas Data Binding!](#hello-canvas-data-binding)
@@ -50,6 +51,7 @@
50
51
  - [Glimmer Tetris](#glimmer-tetris)
51
52
  - [Mandelbrot Fractal](#mandelbrot-fractal)
52
53
  - [Stock Ticker](#stock-ticker)
54
+ - [Metronome](#metronome)
53
55
  - [External Samples](#external-samples)
54
56
  - [Glimmer Calculator](#glimmer-calculator)
55
57
  - [Gladiator](#gladiator)
@@ -609,6 +611,18 @@ Hello, Canvas Animation Another Frame!
609
611
 
610
612
  ![Hello Canvas Animation Frame 2](/images/glimmer-hello-canvas-animation-frame2.png)
611
613
 
614
+ #### Hello, Canvas Animation Data Binding!
615
+
616
+ This sample demonstrates the use of the [Canvas Animation DSL](#canvas-animation-dsl) with data-binding.
617
+
618
+ Code:
619
+
620
+ [samples/hello/hello_canvas_animation_data_binding.rb](/samples/hello/hello_canvas_animation_data_binding.rb)
621
+
622
+ Hello, Canvas Animation Data Binding!
623
+
624
+ ![Hello Canvas Animation Data Binding](/images/glimmer-hello-canvas-animation-data-binding.gif)
625
+
612
626
  #### Hello, Canvas Transform!
613
627
 
614
628
  This sample demonstrates the use of the `transform` keyword as part of the [Transform DSL](#canvas-transform-dsl) within the [Shape DSL](#canvas-shape-dsl).
@@ -879,6 +893,20 @@ Code:
879
893
 
880
894
  ![Stock Ticker](/images/glimmer-stock-ticker.gif)
881
895
 
896
+ #### Metronome
897
+
898
+ This sample demonstrates a Metronome that accepts a beat count and bpm rate, ticking at every beat, with an uptick at the beginning of the rhythm interval.
899
+
900
+ It takes advantage of the Canvas Shape DSL, data-binding, and the Java Sound library. It employs a hybrid approach of relying on standard widget layouts (grid layout) and canvas shape x,y placement.
901
+
902
+ Code:
903
+
904
+ [samples/elaborate/metronome.rb](/samples/elaborate/metronome.rb)
905
+
906
+ ![Metronome](/images/glimmer-metronome.gif)
907
+
908
+ [Download video with sound](/videos/glimmer-metronome.mp4?raw=true).
909
+
882
910
  ### External Samples
883
911
 
884
912
  #### Glimmer Calculator
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: glimmer-dsl-swt 4.18.7.0 ruby lib
5
+ # stub: glimmer-dsl-swt 4.18.7.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "glimmer-dsl-swt".freeze
9
- s.version = "4.18.7.0"
9
+ s.version = "4.18.7.1"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["AndyMaleh".freeze]
14
- s.date = "2021-03-04"
14
+ s.date = "2021-03-05"
15
15
  s.description = "Glimmer DSL for SWT (JRuby Desktop Development GUI Framework) is a native-GUI cross-platform desktop development library written in JRuby, an OS-threaded faster JVM version of Ruby. Glimmer's main innovation is a declarative Ruby DSL that enables productive and efficient authoring of desktop application user-interfaces by relying on the robust Eclipse SWT library. Glimmer additionally innovates by having built-in data-binding support, which greatly facilitates synchronizing the GUI with domain models, thus achieving true decoupling of object oriented components and enabling developers to solve business problems (test-first) without worrying about GUI concerns, or alternatively drive development GUI-first, and then write clean business models (test-first) afterwards. Not only does Glimmer provide a large set of GUI widgets, but it also supports drawing Canvas Graphics like Shapes and Animations. To get started quickly, Glimmer offers scaffolding options for Apps, Gems, and Custom Widgets. Glimmer also includes native-executable packaging support, sorely lacking in other libraries, thus enabling the delivery of desktop apps written in Ruby as truly native DMG/PKG/APP files on the Mac + App Store, MSI/EXE files on Windows, and Gem Packaged Shell Scripts on Linux.".freeze
16
16
  s.email = "andy.am@gmail.com".freeze
17
17
  s.executables = ["glimmer".freeze, "girb".freeze]
@@ -169,6 +169,7 @@ Gem::Specification.new do |s|
169
169
  "samples/elaborate/login.rb",
170
170
  "samples/elaborate/mandelbrot_fractal.rb",
171
171
  "samples/elaborate/meta_sample.rb",
172
+ "samples/elaborate/metronome.rb",
172
173
  "samples/elaborate/stock_ticker.rb",
173
174
  "samples/elaborate/tetris.rb",
174
175
  "samples/elaborate/tetris/model/block.rb",
@@ -188,6 +189,7 @@ Gem::Specification.new do |s|
188
189
  "samples/hello/hello_button.rb",
189
190
  "samples/hello/hello_canvas.rb",
190
191
  "samples/hello/hello_canvas_animation.rb",
192
+ "samples/hello/hello_canvas_animation_data_binding.rb",
191
193
  "samples/hello/hello_canvas_data_binding.rb",
192
194
  "samples/hello/hello_canvas_path.rb",
193
195
  "samples/hello/hello_canvas_transform.rb",
@@ -228,6 +230,8 @@ Gem::Specification.new do |s|
228
230
  "samples/hello/hello_table/baseball_park.png",
229
231
  "samples/hello/hello_tree.rb",
230
232
  "samples/hello/hello_world.rb",
233
+ "sounds/metronome-down.wav",
234
+ "sounds/metronome-up.wav",
231
235
  "vendor/swt/linux/swt.jar",
232
236
  "vendor/swt/mac/swt.jar",
233
237
  "vendor/swt/windows/swt.jar"
@@ -0,0 +1,154 @@
1
+ require 'glimmer-dsl-swt'
2
+
3
+ class Metronome
4
+ class Beat
5
+ attr_accessor :on
6
+
7
+ def off!
8
+ self.on = false
9
+ end
10
+
11
+ def on!
12
+ self.on = true
13
+ end
14
+ end
15
+
16
+ class Rhythm
17
+ attr_reader :beat_count
18
+ attr_accessor :beats, :bpm
19
+
20
+ def initialize(beat_count)
21
+ self.beat_count = beat_count
22
+ @bpm = 120
23
+ end
24
+
25
+ def beat_count=(value)
26
+ @beat_count = value
27
+ reset_beats!
28
+ end
29
+
30
+ def reset_beats!
31
+ @beats = beat_count.times.map {Beat.new}
32
+ @beats.first.on!
33
+ end
34
+ end
35
+
36
+ include Glimmer::UI::CustomShell
37
+
38
+ import 'javax.sound.sampled'
39
+
40
+ GEM_ROOT = File.expand_path(File.join('..', '..'), __dir__)
41
+ FILE_SOUND_METRONOME_UP = File.join(GEM_ROOT, 'sounds', 'metronome-up.wav')
42
+ FILE_SOUND_METRONOME_DOWN = File.join(GEM_ROOT, 'sounds', 'metronome-down.wav')
43
+
44
+ attr_accessor :rhythm
45
+
46
+ before_body {
47
+ @rhythm = Rhythm.new(4)
48
+ }
49
+
50
+ body {
51
+ shell {
52
+ row_layout(:vertical) {
53
+ center true
54
+ }
55
+ text 'Glimmer Metronome'
56
+
57
+ label {
58
+ text 'Beat Count'
59
+ font height: 30, style: :bold
60
+ }
61
+
62
+ spinner {
63
+ minimum 1
64
+ maximum 64
65
+ selection bind(self, 'rhythm.beat_count', after_write: ->(v) {restart_metronome})
66
+ font height: 30
67
+ }
68
+
69
+ label {
70
+ text 'BPM'
71
+ font height: 30, style: :bold
72
+ }
73
+
74
+ spinner {
75
+ minimum 30
76
+ maximum 1000
77
+ selection bind(self, 'rhythm.bpm')
78
+ font height: 30
79
+ }
80
+
81
+ @beat_container = beat_container
82
+
83
+ on_swt_show {
84
+ start_metronome
85
+ }
86
+
87
+ on_widget_disposed {
88
+ stop_metronome
89
+ }
90
+ }
91
+ }
92
+
93
+ def beat_container
94
+ composite {
95
+ grid_layout(@rhythm.beat_count, true) {
96
+ margin_left 10
97
+ }
98
+
99
+ @rhythm.beat_count.times { |n|
100
+ canvas {
101
+ rectangle(0, 0, 50, 50, 36, 36) {
102
+ background bind(self, "rhythm.beats[#{n}].on") {|on| on ? :red : :yellow}
103
+ }
104
+ }
105
+ }
106
+ }
107
+ end
108
+
109
+ def start_metronome
110
+ @thread ||= Thread.new {
111
+ @rhythm.beat_count.times.cycle { |n|
112
+ sleep(60.0/@rhythm.bpm.to_f)
113
+ @rhythm.beats.each(&:off!)
114
+ @rhythm.beats[n].on!
115
+ sound_file = n == 0 ? FILE_SOUND_METRONOME_UP : FILE_SOUND_METRONOME_DOWN
116
+ play_sound(sound_file)
117
+ }
118
+ }
119
+ if @beat_container.nil?
120
+ body_root.content {
121
+ @beat_container = beat_container
122
+ }
123
+ body_root.layout(true, true)
124
+ body_root.pack(true)
125
+ end
126
+ end
127
+
128
+ def stop_metronome
129
+ @thread&.kill # safe since no stored data is involved
130
+ @thread = nil
131
+ @beat_container&.dispose
132
+ @beat_container = nil
133
+ end
134
+
135
+ def restart_metronome
136
+ stop_metronome
137
+ start_metronome
138
+ end
139
+
140
+ # Play sound with the Java Sound library
141
+ def play_sound(sound_file)
142
+ begin
143
+ file_or_stream = java.io.File.new(sound_file)
144
+ audio_stream = AudioSystem.get_audio_input_stream(file_or_stream)
145
+ clip = AudioSystem.clip
146
+ clip.open(audio_stream)
147
+ clip.start
148
+ rescue => e
149
+ puts e.full_message
150
+ end
151
+ end
152
+ end
153
+
154
+ Metronome.launch
@@ -0,0 +1,45 @@
1
+ require 'glimmer-dsl-swt'
2
+ require 'bigdecimal'
3
+
4
+ class HelloAnimationDataBinding
5
+ include Glimmer::UI::CustomShell
6
+
7
+ attr_accessor :delay_time
8
+
9
+ before_body {
10
+ @delay_time = 0.050
11
+ }
12
+
13
+ body {
14
+ shell {
15
+ text 'Hello, Canvas Animation Data Binding!'
16
+ minimum_size 320, 320
17
+
18
+ canvas {
19
+ grid_layout
20
+
21
+ spinner {
22
+ layout_data(:center, :center, true, true) {
23
+ minimum_width 75
24
+ }
25
+ digits 3
26
+ minimum 1
27
+ maximum 100
28
+ selection bind(self, :delay_time, on_read: ->(v) {(BigDecimal(v.to_s)*1000).to_f}, on_write: ->(v) {(BigDecimal(v.to_s)/1000).to_f})
29
+ }
30
+ animation {
31
+ every bind(self, :delay_time)
32
+
33
+ frame { |index|
34
+ background rgb(index%100, index%100 + 100, index%55 + 200)
35
+ oval(index*3%300, index*3%300, 20, 20) {
36
+ background :yellow
37
+ }
38
+ }
39
+ }
40
+ }
41
+ }
42
+ }
43
+ end
44
+
45
+ HelloAnimationDataBinding.launch
@@ -30,7 +30,7 @@ class HelloSpinner
30
30
 
31
31
  before_body {
32
32
  @person = Person.new
33
- @person.donation = 500
33
+ @person.donation = 500 # in cents
34
34
  }
35
35
 
36
36
  body {
@@ -57,12 +57,17 @@ class HelloSpinner
57
57
 
58
58
  spinner {
59
59
  digits 2 # digits after the decimal point
60
- minimum 500 # minimum value (including digits after the decimal point)
60
+ minimum 100 # minimum value (including digits after the decimal point)
61
61
  maximum 15000 # maximum value (including digits after the decimal point)
62
62
  increment 500 # increment on up and down (including digits after the decimal point)
63
63
  page_increment 5000 # page increment on page up and page down (including digits after the decimal point)
64
64
  selection bind(@person, :donation) # selection must be set last if other properties are configured to ensure value is within bounds
65
65
  }
66
+
67
+ label {
68
+ text bind(@person, :donation) {|value| "Thank you for your donation of $#{"%.2f" % (value.to_f / 100.0)}"}
69
+ }
70
+
66
71
  }
67
72
  }
68
73
  }
Binary file
Binary file
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.18.7.0
4
+ version: 4.18.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-04 00:00:00.000000000 Z
11
+ date: 2021-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -488,6 +488,7 @@ files:
488
488
  - samples/elaborate/login.rb
489
489
  - samples/elaborate/mandelbrot_fractal.rb
490
490
  - samples/elaborate/meta_sample.rb
491
+ - samples/elaborate/metronome.rb
491
492
  - samples/elaborate/stock_ticker.rb
492
493
  - samples/elaborate/tetris.rb
493
494
  - samples/elaborate/tetris/model/block.rb
@@ -507,6 +508,7 @@ files:
507
508
  - samples/hello/hello_button.rb
508
509
  - samples/hello/hello_canvas.rb
509
510
  - samples/hello/hello_canvas_animation.rb
511
+ - samples/hello/hello_canvas_animation_data_binding.rb
510
512
  - samples/hello/hello_canvas_data_binding.rb
511
513
  - samples/hello/hello_canvas_path.rb
512
514
  - samples/hello/hello_canvas_transform.rb
@@ -547,6 +549,8 @@ files:
547
549
  - samples/hello/hello_table/baseball_park.png
548
550
  - samples/hello/hello_tree.rb
549
551
  - samples/hello/hello_world.rb
552
+ - sounds/metronome-down.wav
553
+ - sounds/metronome-up.wav
550
554
  - vendor/swt/linux/swt.jar
551
555
  - vendor/swt/mac/swt.jar
552
556
  - vendor/swt/windows/swt.jar