glimmer-dsl-swt 4.23.0.0 → 4.23.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/README.md +9 -9
- data/RUBY_VERSION +1 -1
- data/VERSION +1 -1
- data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +6 -4
- data/docs/reference/GLIMMER_SAMPLES.md +1 -1
- data/glimmer-dsl-swt.gemspec +0 -0
- data/lib/glimmer/swt/custom/code_text.rb +13 -19
- data/samples/elaborate/meta_sample/tutorials.yml +14 -0
- data/samples/elaborate/meta_sample.rb +59 -3
- data/samples/elaborate/tetris/model/game.rb +26 -24
- data/samples/elaborate/tetris/view/score_lane.rb +5 -1
- data/samples/elaborate/tetris/view/tetris_menu_bar.rb +19 -0
- data/samples/hello/hello_code_text.rb +11 -0
- data/samples/hello/hello_styled_text.rb +4 -4
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c37ec4445272c326501c750fcbb49f51476bb3a65caca31c5d41d23e5c8ed7b
|
4
|
+
data.tar.gz: 78f436deedcd9bc89ff9123cc475510cb8276f26d1ff4f4baa835ea94c6a4d8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16ca52eb3ce54d6483060ceb5c4ec9aa1d7faeb4cececd379fcef8d305e15dc12732a93ef06b6b373710f16155d9fff4cedd08c1bef49bdcf0c9573c60e56ebf
|
7
|
+
data.tar.gz: b656ab11c677463ecffe51591fb1eb06028f58d93c0037ee881d00f7c49815ad0f666e6cd91a02b7c373d9d2b30a58bd6501f7f93780a238b3654aedaf53bc3d
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 4.23.1.1
|
4
|
+
|
5
|
+
- Switch order of buttons in Glimmer Meta-Sample to put Tutorial first
|
6
|
+
- Make Glimmer Meta-Sample pull list of tutorials from GitHub to avoid needing to update gem when adding new tutorials
|
7
|
+
|
8
|
+
## 4.23.1.0
|
9
|
+
|
10
|
+
- Upgrade to JRuby 9.3.4.0
|
11
|
+
- Upgrade to glimmer 2.7.3
|
12
|
+
- Add "Tutorial" button to Glimmer Meta-Sample to show Youtube Video Tutorial
|
13
|
+
|
14
|
+
## 4.23.0.1
|
15
|
+
|
16
|
+
- Add "Speed" menu to the Tetris sample
|
17
|
+
- Add "Show Next Block Preview" View menu item to the Tetris sample
|
18
|
+
- Document Glimmer::UI::Application alias for Glimmer::UI::CustomShell
|
19
|
+
|
3
20
|
## 4.23.0.0
|
4
21
|
|
5
22
|
- Upgrade to SWT 4.23
|
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.23.
|
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.23.1.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)
|
@@ -19,7 +19,7 @@ Featured in JRuby Cookbook](http://shop.oreilly.com/product/9780596519650.do) an
|
|
19
19
|
|
20
20
|
![Eclipse SWT RCP NASA Mars Rover](/images/glimmer-eclipse-swt-rcp-nasa-mars-rover.png)
|
21
21
|
|
22
|
-
[Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.23.
|
22
|
+
[Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.23.1.1 includes [SWT 4.23](https://download.eclipse.org/eclipse/downloads/drops4/R-4.23-202203080310/), which was released on March 8, 2022. 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.
|
23
23
|
|
24
24
|
**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.
|
25
25
|
|
@@ -203,7 +203,7 @@ Glimmer app:
|
|
203
203
|
|
204
204
|
### Desktop Apps Built with Glimmer DSL for SWT
|
205
205
|
|
206
|
-
[<img alt="Are We There Yet Logo" src="https://raw.githubusercontent.com/AndyObtiva/are-we-there-yet/master/are-we-there-yet-logo.svg" width="40" />Are We There Yet?](https://github.com/AndyObtiva/are-we-there-yet) - Small Project Tracking App
|
206
|
+
[<img alt="Are We There Yet Logo" src="https://raw.githubusercontent.com/AndyObtiva/are-we-there-yet/master/are-we-there-yet-logo.svg" width="40" />Are We There Yet?](https://github.com/AndyObtiva/are-we-there-yet) - Small Project Tracking App (leveraging [ActiveRecord](https://rubygems.org/gems/activerecord) and [SQLite](https://www.sqlite.org/index.html))
|
207
207
|
|
208
208
|
[![Are We There Yet? App Screenshot](https://raw.githubusercontent.com/AndyObtiva/are-we-there-yet/master/are-we-there-yet-screenshot-windows.png)](https://github.com/AndyObtiva/are-we-there-yet)
|
209
209
|
|
@@ -303,7 +303,7 @@ https://www.eclipse.org/swt/faq.php
|
|
303
303
|
|
304
304
|
- JDK 18 (find at https://www.oracle.com/java/technologies/downloads / Ensure `PATH` env var includes Java bin directory for `jpackage` command to work when packaging Glimmer applications / Preferably setup `JAVA_HOME` env var too to point to JDK home directory before installing JRuby)
|
305
305
|
- [RVM](http://rvm.io) on Mac & Linux (not needed on Windows)
|
306
|
-
- JRuby 9.3.
|
306
|
+
- JRuby 9.3.4.0 (supporting Ruby 2.6.x syntax) (get via [RVM](http://rvm.io) on Mac and Linux by running `rvm install jruby-9.3.4.0`; On Windows, find at [https://www.jruby.org/download](https://www.jruby.org/download))
|
307
307
|
- SWT 4.23 (already included in the [glimmer-dsl-swt](https://rubygems.org/gems/glimmer-dsl-swt) gem). Note that SWT supports ARM64/AARCH64 on Mac and Linux since version 4.20
|
308
308
|
- Git (comes with Mac and Linux. Install on Windows: https://git-scm.com/download/win )
|
309
309
|
|
@@ -333,7 +333,7 @@ jgem install glimmer-dsl-swt
|
|
333
333
|
|
334
334
|
Or this command if you want a specific version:
|
335
335
|
```
|
336
|
-
jgem install glimmer-dsl-swt -v 4.23.
|
336
|
+
jgem install glimmer-dsl-swt -v 4.23.1.1
|
337
337
|
```
|
338
338
|
|
339
339
|
`jgem` is JRuby's version of `gem` command.
|
@@ -361,7 +361,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
|
|
361
361
|
|
362
362
|
Add the following to `Gemfile`:
|
363
363
|
```
|
364
|
-
gem 'glimmer-dsl-swt', '~> 4.23.
|
364
|
+
gem 'glimmer-dsl-swt', '~> 4.23.1.1'
|
365
365
|
```
|
366
366
|
|
367
367
|
And, then run:
|
@@ -384,7 +384,7 @@ glimmer
|
|
384
384
|
```
|
385
385
|
|
386
386
|
```
|
387
|
-
Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.23.
|
387
|
+
Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.23.1.1
|
388
388
|
|
389
389
|
Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
|
390
390
|
|
@@ -567,13 +567,13 @@ If you have a Glimmer app you would like referenced here, please mention in a Pu
|
|
567
567
|
|
568
568
|
### Are We There Yet?
|
569
569
|
|
570
|
-
This [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) application connects to a database using [ActiveRecord](https://rubygems.org/gems/activerecord).
|
570
|
+
This [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) application connects to a [SQLite](https://www.sqlite.org/index.html) database using [ActiveRecord](https://rubygems.org/gems/activerecord).
|
571
571
|
|
572
572
|
[<img alt="Are We There Yet Logo" src="https://raw.githubusercontent.com/AndyObtiva/are-we-there-yet/master/are-we-there-yet-logo.svg" width="40" />Are We There Yet?](https://github.com/AndyObtiva/are-we-there-yet): A tool that helps you learn when your small projects will finish
|
573
573
|
|
574
574
|
### Garderie Rainbow Daily Agenda
|
575
575
|
|
576
|
-
This [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) application connects to a [Rails](https://rubyonrails.org/) server to submit
|
576
|
+
This [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) application connects to a [Rails](https://rubyonrails.org/) server to submit a nursery child daily agenda via a REST API, storing data in [PostgreSQL](https://www.postgresql.org/).
|
577
577
|
|
578
578
|
[<img alt="Garderie Rainbow Daily Agenda Logo" src="https://github.com/AndyObtiva/garderie_rainbow_daily_agenda/raw/master/images/garderie_rainbow_daily_agenda_logo.png" width="40" />Garderie Rainbow Daily Agenda](https://github.com/AndyObtiva/garderie_rainbow_daily_agenda): A child nursery daily agenda reporting desktop app
|
579
579
|
|
data/RUBY_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
jruby-9.3.
|
1
|
+
jruby-9.3.4.0
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.23.
|
1
|
+
4.23.1.1
|
@@ -332,8 +332,8 @@ This is not an exaustive list, but should give you a good start in learning Glim
|
|
332
332
|
- `time`: featured in [Hello, Table!](/docs/reference/GLIMMER_SAMPLES.md#hello-table) / [Hello, Date Time!](/docs/reference/GLIMMER_SAMPLES.md#hello-date-time)
|
333
333
|
- `tool_bar`: featured in [Hello, Tool Bar!](/docs/reference/GLIMMER_SAMPLES.md#hello-tool-bar)
|
334
334
|
- `tool_item`: featured in [Hello, Tool Bar!](/docs/reference/GLIMMER_SAMPLES.md#hello-tool-bar)
|
335
|
-
- Glimmer::UI::CustomWidget
|
336
|
-
- Glimmer::UI::CustomShell: ability to define any keyword as a custom shell (aka custom window
|
335
|
+
- `Glimmer::UI::CustomWidget`: ability to define any keyword as a custom widget - featured in [Hello, Custom Widget!](/docs/reference/GLIMMER_SAMPLES.md#hello-custom-widget)
|
336
|
+
- `Glimmer::UI::CustomShell` (alias: `Glimmer::UI::Application`): ability to define any keyword as a custom shell (aka custom window or app) - featured in [Hello, Custom Shell!](/docs/reference/GLIMMER_SAMPLES.md#hello-custom-shell)
|
337
337
|
|
338
338
|
**Layouts:**
|
339
339
|
- `grid_layout`: featured in [Hello, Layout!](/docs/reference/GLIMMER_SAMPLES.md#hello-layout) / [Hello, Custom Shell!](/docs/reference/GLIMMER_SAMPLES.md#hello-custom-shell) / [Hello, Computed!](/docs/reference/GLIMMER_SAMPLES.md#hello-computed) / [Hello, Table!](/docs/reference/GLIMMER_SAMPLES.md#hello-table) / [Hello, Pop Up Context Menu!](/docs/reference/GLIMMER_SAMPLES.md#hello-pop-up-context-menu) / [Hello, Menu Bar!](/docs/reference/GLIMMER_SAMPLES.md#hello-menu-bar) / [Hello, List Single Selection!](/docs/reference/GLIMMER_SAMPLES.md#hello-list-single-selection) / [Hello, List Multi Selection!](/docs/reference/GLIMMER_SAMPLES.md#hello-list-multi-selection) / [Contact Manager](/docs/reference/GLIMMER_SAMPLES.md#contact-manager) / [Login](/docs/reference/GLIMMER_SAMPLES.md#login) / [Tic Tac Toe](/docs/reference/GLIMMER_SAMPLES.md#tic-tac-toe)
|
@@ -940,6 +940,8 @@ The system tray allows showing icons for various apps that need to stay on for e
|
|
940
940
|
|
941
941
|
In Glimmer DSL for SWT, generating tray items is automated via the `tray_item` keyword, which can be nested under `shell` and then have a child `menu` underneath that pops up when the user clicks on its icon in the system tray.
|
942
942
|
|
943
|
+
Note that if you would like to display notifications, you can use the [Nebula Notifier custom widget](https://github.com/AndyObtiva/glimmer-cw-nebula#notifier). Alternatively, you can look into the [Two Slices](https://github.com/sshtools/two-slices) Java library.
|
944
|
+
|
943
945
|
Note how the shell was declared with the `:on_top` style (in addition to the default, which is `:shell_trim`) to ensure it opens above all apps when the "Show Application" menu item is selected.
|
944
946
|
|
945
947
|
Example code:
|
@@ -3574,8 +3576,8 @@ Example:
|
|
3574
3576
|
```ruby
|
3575
3577
|
shell {
|
3576
3578
|
@tree = tree {
|
3577
|
-
items
|
3578
|
-
selection
|
3579
|
+
items <= [company, :owner, tree_properties: {children: :coworkers, text: :name}]
|
3580
|
+
selection <=> [company, :selected_coworker]
|
3579
3581
|
}
|
3580
3582
|
}
|
3581
3583
|
```
|
@@ -1082,7 +1082,7 @@ Hello, Cool Bar!
|
|
1082
1082
|
|
1083
1083
|
#### Hello, Tray Item!
|
1084
1084
|
|
1085
|
-
This sample demonstrates the use of `tray_item
|
1085
|
+
This sample demonstrates the use of [`tray_item`](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#tray-item), which enables hiding an app (sending to background) and showing again on top of all other apps. It can also show an About Message Box and exit completely if needed.
|
1086
1086
|
|
1087
1087
|
Code:
|
1088
1088
|
|
data/glimmer-dsl-swt.gemspec
CHANGED
Binary file
|
@@ -146,17 +146,11 @@ module Glimmer
|
|
146
146
|
@line_numbers_styled_text_proxy = styled_text(swt(swt(swt_style), :h_scroll!, :v_scroll!)) {
|
147
147
|
layout_data(:right, :fill, false, true)
|
148
148
|
|
149
|
-
text
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
},
|
155
|
-
after_read: lambda {
|
156
|
-
@line_numbers_styled_text_proxy&.top_pixel = styled_text_proxy_top_pixel unless styled_text_proxy_top_pixel.nil?
|
157
|
-
}
|
158
|
-
)
|
159
|
-
top_pixel bind(self, :styled_text_proxy_top_pixel, read_only: true)
|
149
|
+
text <= [self, :styled_text_proxy_text,
|
150
|
+
on_read: lambda { |text_value| line_numbers_text_from(text_value) },
|
151
|
+
after_read: lambda { @line_numbers_styled_text_proxy&.top_pixel = styled_text_proxy_top_pixel unless styled_text_proxy_top_pixel.nil? }
|
152
|
+
]
|
153
|
+
top_pixel <= [self, :styled_text_proxy_top_pixel]
|
160
154
|
font name: @font_name, height: OS.mac? ? 15 : 12
|
161
155
|
background color(:widget_background)
|
162
156
|
foreground :dark_blue
|
@@ -190,8 +184,8 @@ module Glimmer
|
|
190
184
|
# custom_widget_property_owner # TODO implement to route properties here without declaring method_missing
|
191
185
|
layout_data :fill, :fill, true, true if lines
|
192
186
|
|
193
|
-
text
|
194
|
-
top_pixel
|
187
|
+
text <=> [self, :styled_text_proxy_text] if lines
|
188
|
+
top_pixel <=> [self, :styled_text_proxy_top_pixel] if lines
|
195
189
|
font name: @font_name, height: OS.mac? ? 15 : 12
|
196
190
|
foreground rgb(75, 75, 75)
|
197
191
|
left_margin 5
|
@@ -223,10 +217,10 @@ module Glimmer
|
|
223
217
|
}
|
224
218
|
end
|
225
219
|
|
226
|
-
on_modify_text
|
220
|
+
on_modify_text do |event|
|
227
221
|
# clear unnecessary syntax highlighting cache on text updates, and do it async to avoid affecting performance
|
228
222
|
new_text = event.data
|
229
|
-
async_exec
|
223
|
+
async_exec do
|
230
224
|
unless @syntax_highlighting.nil?
|
231
225
|
lines = new_text.to_s.split("\n")
|
232
226
|
line_diff = @syntax_highlighting.keys - lines
|
@@ -234,10 +228,10 @@ module Glimmer
|
|
234
228
|
@syntax_highlighting.delete(line)
|
235
229
|
end
|
236
230
|
end
|
237
|
-
|
238
|
-
|
231
|
+
end
|
232
|
+
end
|
239
233
|
|
240
|
-
on_line_get_style
|
234
|
+
on_line_get_style do |line_style_event|
|
241
235
|
begin
|
242
236
|
styles = []
|
243
237
|
style_data = nil
|
@@ -259,7 +253,7 @@ module Glimmer
|
|
259
253
|
Glimmer::Config.logger.error {e.message}
|
260
254
|
Glimmer::Config.logger.error {e.full_message}
|
261
255
|
end
|
262
|
-
|
256
|
+
end
|
263
257
|
}
|
264
258
|
end
|
265
259
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
---
|
2
|
+
Hello, World!: Mi5phsSdNAA
|
3
|
+
Hello, Message Box!: N0sDcr0xp40
|
4
|
+
Hello, Tab!: cMwlYZ78uaQ
|
5
|
+
Hello, Layout!: dAVFR9Y_thY
|
6
|
+
Hello, File Dialog!: HwZRgdvKIDo
|
7
|
+
Hello, Label!: i1PFHr-F8fQ
|
8
|
+
Hello, Text!: pOaYB43G2pg
|
9
|
+
Login: C_vSvXH9ISw
|
10
|
+
Hello, Canvas Shape Listeners!: PV13YE-43M4
|
11
|
+
Hello, Styled Text!: ahs54DPmmso
|
12
|
+
Hello, Code Text!: y0rNzMURnHY
|
13
|
+
Hello, Tree!: M-ZOFyzbEKo
|
14
|
+
Hello, Table!: 3zyyXq7WJwc
|
@@ -21,8 +21,15 @@
|
|
21
21
|
|
22
22
|
require 'glimmer-dsl-swt'
|
23
23
|
require 'fileutils'
|
24
|
+
require 'yaml'
|
25
|
+
require 'net/http'
|
24
26
|
|
25
27
|
class Sample
|
28
|
+
UNEDITABLE = ['meta_sample.rb'] + (OS.windows? ? ['calculator.rb', 'weather.rb'] : []) # Windows StyledText does not support unicode characters found in certain samples
|
29
|
+
URL_TUTORIALS = 'https://raw.githubusercontent.com/AndyObtiva/glimmer-dsl-swt/master/samples/elaborate/meta_sample/tutorials.yml'
|
30
|
+
FILE_TUTORIALS = File.expand_path(File.join('meta_sample', 'tutorials.yml'), __dir__)
|
31
|
+
TUTORIALS = YAML.load_file(FILE_TUTORIALS)
|
32
|
+
|
26
33
|
class << self
|
27
34
|
def glimmer_directory
|
28
35
|
File.expand_path('../../..', __FILE__)
|
@@ -39,12 +46,35 @@ class Sample
|
|
39
46
|
@ensured_glimmer_directory = true
|
40
47
|
end
|
41
48
|
end
|
49
|
+
|
50
|
+
def tutorials
|
51
|
+
if remote_tutorials && !remote_tutorials.empty? && remote_tutorials != local_tutorials
|
52
|
+
remote_tutorials
|
53
|
+
else
|
54
|
+
local_tutorials
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def remote_tutorials
|
59
|
+
if @remote_tutorials.nil?
|
60
|
+
remote_tutorials_response = Net::HTTP.get_response(URI(URL_TUTORIALS))
|
61
|
+
raise "Error downloading remote tutorial list from #{URL_TUTORIALS} (defaulting to local list): HTTP status #{remote_tutorials_response.code} #{remote_tutorials_response.message}!" unless remote_tutorials_response.code.to_i.between?(200, 299)
|
62
|
+
remote_tutorials_yaml = remote_tutorials_response.body
|
63
|
+
@remote_tutorials = YAML.load(remote_tutorials_yaml)
|
64
|
+
end
|
65
|
+
@remote_tutorials
|
66
|
+
rescue => e
|
67
|
+
Glimmer::Config.logger.error e.full_message
|
68
|
+
nil
|
69
|
+
end
|
70
|
+
|
71
|
+
def local_tutorials
|
72
|
+
TUTORIALS
|
73
|
+
end
|
42
74
|
end
|
43
75
|
|
44
76
|
include Glimmer::DataBinding::ObservableModel
|
45
|
-
|
46
|
-
UNEDITABLE = ['meta_sample.rb'] + (OS.windows? ? ['calculator.rb', 'weather.rb'] : []) # Windows StyledText does not support unicode characters found in certain samples
|
47
|
-
|
77
|
+
|
48
78
|
attr_accessor :sample_directory, :file, :selected
|
49
79
|
|
50
80
|
def initialize(file, sample_directory: )
|
@@ -84,6 +114,14 @@ class Sample
|
|
84
114
|
File.basename(file) != 'meta_sample.rb'
|
85
115
|
end
|
86
116
|
|
117
|
+
def teachable
|
118
|
+
!!tutorial
|
119
|
+
end
|
120
|
+
|
121
|
+
def tutorial
|
122
|
+
Sample.tutorials[name]
|
123
|
+
end
|
124
|
+
|
87
125
|
def file_relative_path
|
88
126
|
file.sub(self.class.glimmer_directory, '')
|
89
127
|
end
|
@@ -244,10 +282,27 @@ class MetaSampleApplication
|
|
244
282
|
|
245
283
|
composite {
|
246
284
|
fill_layout
|
285
|
+
|
247
286
|
layout_data(:fill, :center, true, false) {
|
248
287
|
height_hint 96
|
249
288
|
}
|
250
289
|
|
290
|
+
button {
|
291
|
+
text 'Tutorial'
|
292
|
+
font height: 25
|
293
|
+
enabled <= [SampleDirectory, 'selected_sample.teachable']
|
294
|
+
|
295
|
+
on_widget_selected do
|
296
|
+
shell(:fill_screen) {
|
297
|
+
text "Glimmer DSL for SWT Video Tutorial - #{SampleDirectory.selected_sample.name}"
|
298
|
+
|
299
|
+
browser {
|
300
|
+
text "<iframe src='https://www.youtube.com/embed/#{SampleDirectory.selected_sample.tutorial}?autoplay=1' title='YouTube video player' frameborder='0' allow='accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture' allowfullscreen style='width: 100%; height: 100%;'></iframe>"
|
301
|
+
}
|
302
|
+
}.open
|
303
|
+
end
|
304
|
+
}
|
305
|
+
|
251
306
|
button {
|
252
307
|
text 'Launch'
|
253
308
|
font height: 25
|
@@ -261,6 +316,7 @@ class MetaSampleApplication
|
|
261
316
|
end
|
262
317
|
end
|
263
318
|
}
|
319
|
+
|
264
320
|
button {
|
265
321
|
text 'Reset'
|
266
322
|
font height: 25
|
@@ -36,21 +36,27 @@ class Tetris
|
|
36
36
|
PREVIEW_PLAYFIELD_WIDTH = 4
|
37
37
|
PREVIEW_PLAYFIELD_HEIGHT = 2
|
38
38
|
SCORE_MULTIPLIER = {1 => 40, 2 => 100, 3 => 300, 4 => 1200}
|
39
|
+
UP_ARROW_ACTIONS = %i[instant_down rotate_right rotate_left]
|
40
|
+
SPEEDS = %i[snail sloth turtle rabbit gorilla bear horse gazelle cheetah falcon]
|
41
|
+
SPEED_INITIAL_DELAYS = SPEEDS.each_with_index.inject({}) {|hash, speed_index_pair| hash.merge(speed_index_pair.first => 1.1 - speed_index_pair.last*(0.1)) }
|
39
42
|
|
40
43
|
attr_reader :playfield_width, :playfield_height
|
41
|
-
attr_accessor :game_over, :paused, :preview_tetromino, :lines, :score, :level, :high_scores, :beeping, :added_high_score, :show_high_scores, :up_arrow_action
|
44
|
+
attr_accessor :game_over, :paused, :preview_tetromino, :lines, :score, :level, :high_scores, :beeping, :added_high_score, :show_high_scores, :up_arrow_action, :show_preview_tetromino, :initial_delay
|
42
45
|
alias game_over? game_over
|
43
46
|
alias paused? paused
|
44
47
|
alias beeping? beeping
|
45
48
|
alias added_high_score? added_high_score
|
49
|
+
alias show_preview_tetromino? show_preview_tetromino
|
46
50
|
|
47
51
|
def initialize(playfield_width = PLAYFIELD_WIDTH, playfield_height = PLAYFIELD_HEIGHT)
|
52
|
+
@initial_delay = SPEED_INITIAL_DELAYS[:snail]
|
48
53
|
@playfield_width = playfield_width
|
49
54
|
@playfield_height = playfield_height
|
50
55
|
@high_scores = []
|
51
56
|
@show_high_scores = false
|
52
57
|
@beeping = true
|
53
58
|
@up_arrow_action = :rotate_left
|
59
|
+
@show_preview_tetromino = true
|
54
60
|
load_high_scores!
|
55
61
|
end
|
56
62
|
|
@@ -198,35 +204,31 @@ class Tetris
|
|
198
204
|
end
|
199
205
|
|
200
206
|
def delay
|
201
|
-
[
|
207
|
+
[@initial_delay - (level.to_i * 0.1), 0.001].max
|
202
208
|
end
|
203
209
|
|
204
210
|
def beep
|
205
211
|
@beeper&.call if beeping
|
206
212
|
end
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
def rotate_right_on_up=(value)
|
217
|
-
self.up_arrow_action = :rotate_right if value
|
218
|
-
end
|
219
|
-
|
220
|
-
def rotate_right_on_up
|
221
|
-
self.up_arrow_action == :rotate_right
|
222
|
-
end
|
223
|
-
|
224
|
-
def rotate_left_on_up=(value)
|
225
|
-
self.up_arrow_action = :rotate_left if value
|
213
|
+
|
214
|
+
SPEED_INITIAL_DELAYS.each do |speed, speed_initial_day|
|
215
|
+
define_method("speed_#{speed}=") do |is_true|
|
216
|
+
self.initial_delay = speed_initial_day if is_true
|
217
|
+
end
|
218
|
+
|
219
|
+
define_method("speed_#{speed}") do
|
220
|
+
self.initial_delay == speed_initial_day
|
221
|
+
end
|
226
222
|
end
|
227
|
-
|
228
|
-
|
229
|
-
|
223
|
+
|
224
|
+
UP_ARROW_ACTIONS.each do |up_arrow_action_symbol|
|
225
|
+
define_method("#{up_arrow_action_symbol}_on_up=") do |is_true|
|
226
|
+
self.up_arrow_action = up_arrow_action_symbol if is_true
|
227
|
+
end
|
228
|
+
|
229
|
+
define_method("#{up_arrow_action_symbol}_on_up") do
|
230
|
+
self.up_arrow_action == up_arrow_action_symbol
|
231
|
+
end
|
230
232
|
end
|
231
233
|
|
232
234
|
def reset_tetrominoes
|
@@ -44,11 +44,15 @@ class Tetris
|
|
44
44
|
margin_right block_size
|
45
45
|
margin_height block_size
|
46
46
|
}
|
47
|
+
|
47
48
|
label(:center) {
|
48
49
|
text 'Next'
|
49
50
|
font name: @font_name, height: @font_height, style: FONT_TITLE_STYLE
|
51
|
+
visible <= [game, :show_preview_tetromino]
|
52
|
+
}
|
53
|
+
playfield(game_playfield: game.preview_playfield, playfield_width: Model::Game::PREVIEW_PLAYFIELD_WIDTH, playfield_height: Model::Game::PREVIEW_PLAYFIELD_HEIGHT, block_size: block_size) {
|
54
|
+
visible <= [game, :show_preview_tetromino]
|
50
55
|
}
|
51
|
-
playfield(game_playfield: game.preview_playfield, playfield_width: Model::Game::PREVIEW_PLAYFIELD_WIDTH, playfield_height: Model::Game::PREVIEW_PLAYFIELD_HEIGHT, block_size: block_size)
|
52
56
|
|
53
57
|
label(:center) {
|
54
58
|
text 'Score'
|
@@ -71,6 +71,14 @@ class Tetris
|
|
71
71
|
menu {
|
72
72
|
text '&View'
|
73
73
|
|
74
|
+
menu_item(:check) {
|
75
|
+
text 'Show Next Block Preview'
|
76
|
+
accelerator COMMAND_KEY, :shift, :p
|
77
|
+
selection <=> [game, :show_preview_tetromino]
|
78
|
+
}
|
79
|
+
|
80
|
+
menu_item(:separator)
|
81
|
+
|
74
82
|
menu {
|
75
83
|
text '&High Scores'
|
76
84
|
menu_item(:check) {
|
@@ -89,6 +97,17 @@ class Tetris
|
|
89
97
|
}
|
90
98
|
} # end of menu
|
91
99
|
|
100
|
+
menu {
|
101
|
+
text '&Speed'
|
102
|
+
|
103
|
+
Model::Game::SPEEDS.each do |speed|
|
104
|
+
menu_item(:radio) {
|
105
|
+
text speed.to_s.capitalize
|
106
|
+
selection <=> [game, "speed_#{speed}", computed_by: :initial_delay]
|
107
|
+
}
|
108
|
+
end
|
109
|
+
}
|
110
|
+
|
92
111
|
menu {
|
93
112
|
text '&Options'
|
94
113
|
menu_item(:check) {
|
@@ -83,30 +83,41 @@ class HelloCodeText
|
|
83
83
|
tab_folder {
|
84
84
|
tab_item {
|
85
85
|
fill_layout
|
86
|
+
|
86
87
|
text 'Ruby (glimmer theme)'
|
88
|
+
|
87
89
|
code_text(language: 'ruby', theme: 'glimmer', lines: true) {
|
88
90
|
text <=> [self, :ruby_code]
|
89
91
|
}
|
90
92
|
}
|
93
|
+
|
91
94
|
tab_item {
|
92
95
|
fill_layout
|
96
|
+
|
93
97
|
text 'JavaScript (pastie theme)'
|
98
|
+
|
94
99
|
code_text(:multi, :h_scroll, :v_scroll, language: 'javascript', theme: 'pastie', lines: {width: 2}) {
|
95
100
|
root {
|
96
101
|
grid_layout(2, false) {
|
97
102
|
margin_width 2
|
98
103
|
}
|
104
|
+
|
99
105
|
background :white
|
100
106
|
}
|
107
|
+
|
101
108
|
line_numbers {
|
102
109
|
background :white
|
103
110
|
}
|
111
|
+
|
104
112
|
text <=> [self, :js_code]
|
105
113
|
}
|
106
114
|
}
|
115
|
+
|
107
116
|
tab_item {
|
108
117
|
fill_layout
|
118
|
+
|
109
119
|
text 'HTML (github theme)'
|
120
|
+
|
110
121
|
code_text(language: 'html', theme: 'github') { # default is lines: false
|
111
122
|
text <=> [self, :html_code]
|
112
123
|
}
|
@@ -82,22 +82,22 @@ shell {
|
|
82
82
|
line_size = line_style_event.lineText.size
|
83
83
|
style_range = StyleRange.new(line_offset, line_size, color(:blue).swt_color, nil, swt(:italic))
|
84
84
|
style_range.font = Font.new(display.swt_display, 'Times New Roman', 18, swt(:normal))
|
85
|
-
line_style_event.styles = [style_range]
|
85
|
+
line_style_event.styles = [style_range]
|
86
86
|
elsif @presenter.line_index_for_offset(line_offset) % 52 < 26
|
87
87
|
line_size = line_style_event.lineText.size
|
88
88
|
style_range = StyleRange.new(line_offset, line_size, color(:dark_green).swt_color, color(:yellow).swt_color, swt(:bold))
|
89
|
-
line_style_event.styles = [style_range]
|
89
|
+
line_style_event.styles = [style_range]
|
90
90
|
elsif @presenter.line_index_for_offset(line_offset) % 52 < 39
|
91
91
|
line_size = line_style_event.lineText.size
|
92
92
|
style_range = StyleRange.new(line_offset, line_size, color(:red).swt_color, nil, swt(:normal))
|
93
93
|
style_range.underline = true
|
94
94
|
style_range.font = Font.new(display.swt_display, 'Arial', 16, swt(:normal))
|
95
|
-
line_style_event.styles = [style_range]
|
95
|
+
line_style_event.styles = [style_range]
|
96
96
|
else
|
97
97
|
line_size = line_style_event.lineText.size
|
98
98
|
style_range = StyleRange.new(line_offset, line_size, color(:dark_magenta).swt_color, color(:cyan).swt_color, swt(:normal))
|
99
99
|
style_range.strikeout = true
|
100
|
-
line_style_event.styles = [style_range]
|
100
|
+
line_style_event.styles = [style_range]
|
101
101
|
end
|
102
102
|
end
|
103
103
|
}
|
metadata
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-swt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.23.
|
4
|
+
version: 4.23.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03
|
11
|
+
date: 2022-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
15
15
|
requirements:
|
16
16
|
- - "~>"
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: 2.
|
18
|
+
version: 2.7.3
|
19
19
|
name: glimmer
|
20
20
|
prerelease: false
|
21
21
|
type: :runtime
|
@@ -23,7 +23,7 @@ dependencies:
|
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: 2.7.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
29
29
|
requirements:
|
@@ -564,6 +564,7 @@ files:
|
|
564
564
|
- samples/elaborate/login.rb
|
565
565
|
- samples/elaborate/mandelbrot_fractal.rb
|
566
566
|
- samples/elaborate/meta_sample.rb
|
567
|
+
- samples/elaborate/meta_sample/tutorials.yml
|
567
568
|
- samples/elaborate/metronome.rb
|
568
569
|
- samples/elaborate/parking.rb
|
569
570
|
- samples/elaborate/parking/model/parking_floor.rb
|