glimmer-dsl-swt 4.18.3.3 → 4.18.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +55 -0
  3. data/README.md +673 -325
  4. data/VERSION +1 -1
  5. data/glimmer-dsl-swt.gemspec +8 -3
  6. data/lib/ext/rouge/themes/glimmer.rb +29 -0
  7. data/lib/glimmer-dsl-swt.rb +0 -1
  8. data/lib/glimmer/data_binding/widget_binding.rb +1 -1
  9. data/lib/glimmer/dsl/swt/image_expression.rb +14 -6
  10. data/lib/glimmer/dsl/swt/layout_data_expression.rb +4 -4
  11. data/lib/glimmer/dsl/swt/layout_expression.rb +5 -3
  12. data/lib/glimmer/swt/custom/code_text.rb +200 -51
  13. data/lib/glimmer/swt/custom/drawable.rb +4 -6
  14. data/lib/glimmer/swt/custom/shape.rb +69 -12
  15. data/lib/glimmer/swt/date_time_proxy.rb +1 -3
  16. data/lib/glimmer/swt/display_proxy.rb +11 -0
  17. data/lib/glimmer/swt/font_proxy.rb +1 -0
  18. data/lib/glimmer/swt/image_proxy.rb +79 -1
  19. data/lib/glimmer/swt/layout_proxy.rb +4 -1
  20. data/lib/glimmer/swt/shell_proxy.rb +3 -0
  21. data/lib/glimmer/swt/table_proxy.rb +17 -13
  22. data/lib/glimmer/swt/widget_proxy.rb +12 -4
  23. data/lib/glimmer/ui/custom_widget.rb +2 -2
  24. data/samples/elaborate/meta_sample.rb +15 -4
  25. data/samples/elaborate/meta_sample/meta_sample_logo.png +0 -0
  26. data/samples/elaborate/tetris.rb +45 -6
  27. data/samples/elaborate/tetris/model/game.rb +30 -5
  28. data/samples/elaborate/tetris/model/past_game.rb +14 -1
  29. data/samples/elaborate/tetris/model/tetromino.rb +2 -2
  30. data/samples/elaborate/tetris/view/block.rb +8 -13
  31. data/samples/elaborate/tetris/view/high_score_dialog.rb +1 -10
  32. data/samples/elaborate/tetris/view/playfield.rb +1 -1
  33. data/samples/elaborate/tetris/view/tetris_menu_bar.rb +18 -0
  34. data/samples/hello/hello_canvas.rb +10 -9
  35. data/samples/hello/hello_canvas_animation.rb +5 -5
  36. data/samples/hello/hello_canvas_transform.rb +1 -1
  37. data/samples/hello/hello_canvas_transform/hello_canvas_transform_image.png +0 -0
  38. data/samples/hello/hello_code_text.rb +104 -0
  39. data/samples/hello/hello_table.rb +7 -4
  40. data/samples/hello/hello_table/baseball_park.png +0 -0
  41. metadata +7 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 59c5aae689604e6024a5bffb1053cd50cc05c1598dca6fc3a01510f17371deab
4
- data.tar.gz: 5fc97483b96bf334b1e25b30b8455ad41af3e6f56ae6f5310ac31504ce87c41d
3
+ metadata.gz: 3c4acc7755917941e9c8fd7d94f7712d29701ca4eefd1b31b20a9a46d41ec557
4
+ data.tar.gz: 3f59ee7617453a88165fa57594bcff2dea9831c70a821c11326ace68d66b8936
5
5
  SHA512:
6
- metadata.gz: fdf5681c5632aa64d15c9e2037757d4e7599fbcaeacc14acc1af1dd1669c205ca7a8730551277ae0a3cff5bb435a802dcbdb824e7dbc749f75471ba15079e999
7
- data.tar.gz: 5f96f41c1bdd491da20ae87ad1b2a5f072eeaca78c6e8f15a1a942390c2cc23b07259465452b242e0d61111a6881954458b5fe5214d77bfd4f45dd365ae0eb14
6
+ metadata.gz: 22e115579a74734199b02ce5e43cb15fd789424f063e0d805ff3e1058ec63067e01ea63df4b794e530a0268803bdd898211db3f31a99fe27c63f9ed21c1cb857
7
+ data.tar.gz: 85a7683f0e431252bf4e5490895fa029bfc961a17be3a6fa8e1d15ab4a6927acd8ddf834a46ada2dbaa1ce0aaaf68979c477edebae48e77de9c601a5dfd0d658
data/CHANGELOG.md CHANGED
@@ -1,8 +1,63 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.18.4.2
4
+
5
+ - Remove Tetris Clear button from High Score dialog (since it is available via menu and is rarely used)
6
+ - Make right control button rotate right with Tetris
7
+ - Avoid adding the widget listeners for read_only data-binding (instead of just relying on ModelBinding raising exceptions)
8
+ - Clean up the meta sample code_text style by removing root composite margins/spacing
9
+ - Made background for top label of Hello, Table! transparent for Windows
10
+ - Fix `glimmer samples` command and Meta-Sample on Windows
11
+ - Fix Tetris on Windows
12
+ - Fix Hello, Canvas on Windows
13
+ - Fix Hello, Canvas Transform when launched from `glimmer samples`
14
+ - Fix Table editing write_on_cancel option use on Windows
15
+ - Fix issue with adding content to the end of a styled text widget breaking line number scrolling
16
+ - Fix issue with code_text not showing line numbers for extra new lines at the end
17
+
18
+ ### 4.18.4.1
19
+
20
+ - Support data-binding of `code_text` with lines enabled.
21
+ - Upgrade the Glimmer Meta-Sample with code_text lines: {width: 2}
22
+ - With code_text lines enabled, support setting/data-binding properties on root composite via nesting `root { }` underneath
23
+ - With code_text lines enabled, support setting/data-binding properties on line numbers styled text widget via nesting `line_numbers { }` underneath
24
+ - Update the Hello, Code Text! sample to remove borders and line numbers background in the JavaScript example
25
+ - Fix issue with updating layout upon later reopening layout/layout data via `proxy.content {}` method
26
+
27
+ ### 4.18.4.0
28
+
29
+ - Extract line numbers part of text_editor widget from Gladiator into Glimmer code_text and make it an option (e.g. lines: true or lines: {width: 4})
30
+ - code_text support select all via CMD+A
31
+ - code_text support end of line via CTRL+E and beginning of line via CTRL+A
32
+ - Support automatic inferrence of Canvas Shape DSL gradient option (just like fill option)
33
+ - Support automatic inferrence of Canvas Shape DSL round option (just like fill option)
34
+ - Add a background image to Hello, Table! Sample + font/color changes
35
+ - Make Canvas patterns auto-reused and auto-disposed when canvas is disposed
36
+ - Make Canvas images auto-dispose themselves when canvas is disposed
37
+ - Update Hello, Code Text!
38
+ - Change Glimmer Tetris Sample up arrow default to rotate left
39
+ - Fix issue with "undefined method lex for nil:NilClass" in `code_text`
40
+
41
+ ### 4.18.3.5
42
+
43
+ - Add `write_on_cancel: true` option for TableProxy#edit_table_item to make cancel behave just like save for special cases where you cannot cancel except the edit mode itself
44
+ - Make code_text custom widget support multiple code languages via `language: 'java'` option
45
+ - Make code_text custom widget support multiple themes via `theme: 'github'` option
46
+ - Hello, Code Text! Sample
47
+ - Fix issue with High Score Dialog in Tetris Sample not sorting by scores correctly (string compare instead of numeric compare) until first game is completed
48
+ - Fix issue with setting date geting rejected in `date_time` for month or day being incompatible with the year/month/day combo
49
+
50
+ ### 4.18.3.4
51
+
52
+ - Support building Image objects with the Glimmer Canvas Shape DSL
53
+ - Tetris build icon image in-game by nesting Glimmer Shape DSL syntax
54
+ - Canvas Make shapes auto-fill if you specify a background only (no need to say fill: true) or not fill if you specify a foreground only
55
+ - Tetris option to switch Up Arrow between Instant Down, Rotate Right, and Rotate Left
56
+
3
57
  ### 4.18.3.3
4
58
 
5
59
  - Support Table data binding read_only_sort: true option to allow visual sorting without affecting model data
60
+ - on_quit to
6
61
  - Tetris Add lines and level to High Score Dialog
7
62
  - Tetris Immediate Drop on Arrow Up
8
63
  - Tetris Pause on showing High Score Dialog
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.3.3
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.4.2
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)
@@ -8,7 +8,7 @@
8
8
 
9
9
  **[Contributors Wanted! (Submit a Glimmer App Sample to Get Started)](#contributing)**
10
10
 
11
- [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer) is a native-GUI cross-platform desktop development library written in [JRuby](https://www.jruby.org/), an OS-threaded faster JVM version of [Ruby](https://www.ruby-lang.org/en/). [Glimmer](https://github.com/AndyObtiva/glimmer)'s main innovation is a declarative [Ruby DSL](#glimmer-dsl-syntax) that enables productive and efficient authoring of desktop application user-interfaces by relying on the robust [Eclipse SWT library](https://www.eclipse.org/swt/). [Glimmer](https://rubygems.org/gems/glimmer) additionally innovates by having built-in [data-binding](#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](#widgets), but it also supports drawing Canvas Graphics like [Shapes](#canvas-shape-dsl) and [Animations](#canvas-animation-dsl). To get started quickly, [Glimmer](https://rubygems.org/gems/glimmer) s [scaffolding](#scaffolding) options for [Apps](#in-production), [Gems](#custom-shell-gem), and [Custom Widgets](#custom-widgets). [Glimmer](https://rubygems.org/gems/glimmer) also includes native-executable [packaging](#packaging--distribution) support, sorely lacking in other libraries, thus enabling the delivery of desktop apps written in [Ruby](https://www.ruby-lang.org/en/) as truly native DMG/PKG/APP files on the [Mac](https://www.apple.com/ca/macos) + [App Store](https://developer.apple.com/macos/distribution/), MSI/EXE files on [Windows](https://www.microsoft.com/en-ca/windows), and [Gem Packaged Shell Scripts](#custom-shell-gem) on [Linux](https://www.linux.org/).
11
+ [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer) is a native-GUI cross-platform desktop development library written in [JRuby](https://www.jruby.org/), an OS-threaded faster JVM version of [Ruby](https://www.ruby-lang.org/en/). [Glimmer](https://github.com/AndyObtiva/glimmer)'s main innovation is a declarative [Ruby DSL](#glimmer-dsl-syntax) that enables productive and efficient authoring of desktop application user-interfaces by relying on the robust [Eclipse SWT library](https://www.eclipse.org/swt/). [Glimmer](https://rubygems.org/gems/glimmer) additionally innovates by having built-in [data-binding](#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](#widgets), but it also supports drawing Canvas Graphics like [Shapes](#canvas-shape-dsl) and [Animations](#canvas-animation-dsl). To get started quickly, [Glimmer](https://rubygems.org/gems/glimmer) offers [scaffolding](#scaffolding) options for [Apps](#in-production), [Gems](#custom-shell-gem), and [Custom Widgets](#custom-widgets). [Glimmer](https://rubygems.org/gems/glimmer) also includes native-executable [packaging](#packaging--distribution) support, sorely lacking in other libraries, thus enabling the delivery of desktop apps written in [Ruby](https://www.ruby-lang.org/en/) as truly native DMG/PKG/APP files on the [Mac](https://www.apple.com/ca/macos) + [App Store](https://developer.apple.com/macos/distribution/), MSI/EXE files on [Windows](https://www.microsoft.com/en-ca/windows), and [Gem Packaged Shell Scripts](#custom-shell-gem) on [Linux](https://www.linux.org/).
12
12
 
13
13
  [Glimmer receives two updates per month](https://rubygems.org/gems/glimmer-dsl-swt/versions). You can trust [Glimmer](https://rubygems.org/gems/glimmer) with your Ruby desktop GUI development needs. Please make [Glimmer](https://rubygems.org/gems/glimmer) even better by providing feedback and [contributing](#contributing) when possible.
14
14
 
@@ -28,9 +28,10 @@ Glimmer DSL gems:
28
28
 
29
29
  ## Examples
30
30
 
31
- ### Hello, World!
31
+ ### Hello, World! Sample
32
+
33
+ Glimmer GUI DSL code (from [samples/hello/hello_world.rb](samples/hello/hello_world.rb)):
32
34
 
33
- Glimmer code (from [samples/hello/hello_world.rb](samples/hello/hello_world.rb)):
34
35
  ```ruby
35
36
  include Glimmer
36
37
 
@@ -52,169 +53,163 @@ Glimmer app:
52
53
 
53
54
  ![Hello World](images/glimmer-hello-world.png)
54
55
 
55
- ### Tic Tac Toe
56
+ Learn more about [Hello, World!](#hello-world).
57
+
58
+ ### Hello, Table! Sample
56
59
 
57
- Glimmer code (from [samples/elaborate/tic_tac_toe.rb](samples/elaborate/tic_tac_toe.rb)):
60
+ Glimmer GUI DSL code (from [samples/hello/hello_table.rb](samples/hello/hello_table.rb)):
58
61
 
59
62
  ```ruby
60
- # ...
61
- @shell = shell {
62
- text "Tic-Tac-Toe"
63
- minimum_size 150, 178
64
- composite {
65
- grid_layout 3, true
66
- (1..3).each { |row|
67
- (1..3).each { |column|
68
- button {
69
- layout_data :fill, :fill, true, true
70
- text bind(@tic_tac_toe_board[row, column], :sign)
71
- enabled bind(@tic_tac_toe_board[row, column], :empty)
72
- font style: :bold, height: 20
73
- on_widget_selected {
74
- @tic_tac_toe_board.mark(row, column)
75
- }
76
- }
77
- }
63
+ # ... model code precedes
64
+ shell {
65
+ grid_layout
66
+
67
+ text 'Hello, Table!'
68
+ background_image File.expand_path('hello_table/baseball_park.png', __dir__)
69
+
70
+ label {
71
+ layout_data :center, :center, true, false
72
+
73
+ text 'BASEBALL PLAYOFF SCHEDULE'
74
+ foreground rgb(94, 107, 103)
75
+ font name: 'Optima', height: 38, style: :bold
76
+ }
77
+
78
+ combo(:read_only) {
79
+ layout_data :center, :center, true, false
80
+ selection bind(BaseballGame, :playoff_type)
81
+ font height: 14
82
+ }
83
+
84
+ table(:editable) { |table_proxy|
85
+ layout_data :fill, :fill, true, true
86
+
87
+ table_column {
88
+ text 'Game Date'
89
+ width 150
90
+ sort_property :date # ensure sorting by real date value (not `game_date` string specified in items below)
91
+ editor :date_drop_down, property: :date_time
92
+ }
93
+ table_column {
94
+ text 'Game Time'
95
+ width 150
96
+ sort_property :time # ensure sorting by real time value (not `game_time` string specified in items below)
97
+ editor :time, property: :date_time
98
+ }
99
+ table_column {
100
+ text 'Ballpark'
101
+ width 180
102
+ editor :none
103
+ }
104
+ table_column {
105
+ text 'Home Team'
106
+ width 150
107
+ editor :combo, :read_only # read_only is simply an SWT style passed to combo widget
108
+ }
109
+ table_column {
110
+ text 'Away Team'
111
+ width 150
112
+ editor :combo, :read_only # read_only is simply an SWT style passed to combo widget
113
+ }
114
+ table_column {
115
+ text 'Promotion'
116
+ width 150
117
+ # default text editor is used here
118
+ }
119
+
120
+ # Data-bind table items (rows) to a model collection property, specifying column properties ordering per nested model
121
+ items bind(BaseballGame, :schedule), column_properties(:game_date, :game_time, :ballpark, :home_team, :away_team, :promotion)
122
+
123
+ # Data-bind table selection
124
+ selection bind(BaseballGame, :selected_game)
125
+
126
+ # Default initial sort property
127
+ sort_property :date
128
+
129
+ # Sort by these additional properties after handling sort by the column the user clicked
130
+ additional_sort_properties :date, :time, :home_team, :away_team, :ballpark, :promotion
131
+
132
+ menu {
133
+ menu_item {
134
+ text 'Book'
135
+
136
+ on_widget_selected {
137
+ book_selected_game
78
138
  }
79
139
  }
80
140
  }
141
+ }
142
+
143
+ button {
144
+ text 'Book Selected Game'
145
+ layout_data :center, :center, true, false
146
+ font height: 14
147
+ enabled bind(BaseballGame, :selected_game)
148
+
149
+ on_widget_selected {
150
+ book_selected_game
151
+ }
152
+ }
153
+ }.open
81
154
  # ...
82
155
  ```
83
156
 
84
157
  Run via `glimmer samples` or directly:
85
158
 
86
159
  ```
87
- glimmer samples/elaborate/tic_tac_toe.rb
160
+ glimmer samples/hello/hello_table.rb
88
161
  ```
89
162
 
90
- Glimmer app:
163
+ Glimmer App:
91
164
 
92
- ![Tic Tac Toe](images/glimmer-tic-tac-toe-in-progress.png)
165
+ ![Hello Table](images/glimmer-hello-table.png)
166
+
167
+ Learn more about [Hello, Table!](#hello-table).
93
168
 
94
- ### Contact Manager
169
+ ### Tetris
95
170
 
96
- Glimmer code (from [samples/elaborate/contact_manager.rb](samples/elaborate/contact_manager.rb)):
171
+ Glimmer GUI DSL code (from [samples/elaborate/tetris.rb](samples/elaborate/tetris.rb)):
97
172
 
98
173
  ```ruby
99
- # ...
100
- shell {
101
- text "Contact Manager"
102
- composite {
103
- group {
104
- grid_layout(2, false) {
105
- margin_width 0
106
- margin_height 0
107
- }
108
- layout_data :fill, :center, true, false
109
- text 'Lookup Contacts'
110
- font height: 24
111
-
112
- label {
113
- layout_data :right, :center, false, false
114
- text "First &Name: "
115
- font height: 16
116
- }
117
- text {
118
- layout_data :fill, :center, true, false
119
- text bind(@contact_manager_presenter, :first_name)
120
- on_key_pressed {|key_event|
121
- @contact_manager_presenter.find if key_event.keyCode == swt(:cr)
122
- }
123
- }
124
-
125
- label {
126
- layout_data :right, :center, false, false
127
- text "&Last Name: "
128
- font height: 16
129
- }
130
- text {
131
- layout_data :fill, :center, true, false
132
- text bind(@contact_manager_presenter, :last_name)
133
- on_key_pressed {|key_event|
134
- @contact_manager_presenter.find if key_event.keyCode == swt(:cr)
135
- }
136
- }
137
-
138
- label {
139
- layout_data :right, :center, false, false
140
- text "&Email: "
141
- font height: 16
142
- }
143
- text {
144
- layout_data :fill, :center, true, false
145
- text bind(@contact_manager_presenter, :email)
146
- on_key_pressed {|key_event|
147
- @contact_manager_presenter.find if key_event.keyCode == swt(:cr)
148
- }
149
- }
150
-
151
- composite {
152
- row_layout {
153
- margin_width 0
154
- margin_height 0
155
- }
156
- layout_data(:right, :center, false, false) {
157
- horizontal_span 2
158
- }
159
-
160
- button {
161
- text "&Find"
162
- on_widget_selected { @contact_manager_presenter.find }
163
- on_key_pressed {|key_event|
164
- @contact_manager_presenter.find if key_event.keyCode == swt(:cr)
165
- }
166
- }
167
-
168
- button {
169
- text "&List All"
170
- on_widget_selected { @contact_manager_presenter.list }
171
- on_key_pressed {|key_event|
172
- @contact_manager_presenter.list if key_event.keyCode == swt(:cr)
173
- }
174
- }
175
- }
176
- }
174
+ # ... more code resides in other files (navigate sample files to learn more)
175
+ shell(:no_resize) {
176
+ grid_layout {
177
+ num_columns 2
178
+ make_columns_equal_width false
179
+ margin_width 0
180
+ margin_height 0
181
+ horizontal_spacing 0
182
+ }
183
+
184
+ text 'Glimmer Tetris'
185
+ minimum_size 475, 500
186
+ image tetris_icon
177
187
 
178
- table(:multi) { |table_proxy|
179
- layout_data {
180
- horizontal_alignment :fill
181
- vertical_alignment :fill
182
- grab_excess_horizontal_space true
183
- grab_excess_vertical_space true
184
- height_hint 200
185
- }
186
- table_column {
187
- text "First Name"
188
- width 80
189
- }
190
- table_column {
191
- text "Last Name"
192
- width 80
193
- }
194
- table_column {
195
- text "Email"
196
- width 200
197
- }
198
- items bind(@contact_manager_presenter, :results),
199
- column_properties(:first_name, :last_name, :email)
200
- on_mouse_up { |event|
201
- table_proxy.edit_table_item(event.table_item, event.column_index)
202
- }
203
- }
204
- }
205
- }.open
188
+ tetris_menu_bar(game: game)
189
+
190
+ playfield(game_playfield: game.playfield, playfield_width: playfield_width, playfield_height: playfield_height, block_size: BLOCK_SIZE)
191
+
192
+ score_lane(game: game, block_size: BLOCK_SIZE) {
193
+ layout_data(:fill, :fill, true, true)
194
+ }
195
+
196
+ on_widget_disposed {
197
+ deregister_observers
198
+ }
199
+ }
206
200
  # ...
207
201
  ```
208
202
 
209
203
  Run via `glimmer samples` or directly:
210
204
 
211
205
  ```
212
- glimmer samples/elaborate/contact_manager.rb
206
+ glimmer samples/elaborate/tetris.rb
213
207
  ```
214
208
 
215
- Glimmer App:
209
+ Glimmer app:
210
+
211
+ ![Tetris](images/glimmer-tetris.png)
216
212
 
217
- ![Contact Manager](images/glimmer-contact-manager.png)
218
213
 
219
214
  ### Desktop Apps Built with Glimmer DSL for SWT
220
215
 
@@ -235,9 +230,9 @@ If you see anything that needs to be improved, please do not hesitate to contact
235
230
 
236
231
  - [Glimmer (JRuby Desktop Development GUI Framework)](#jruby-desktop-development-gui-framework)
237
232
  - [Examples](#examples)
238
- - [Hello, World!](#hello-world)
239
- - [Tic Tac Toe](#tic-tac-toe)
240
- - [Contact Manager](#contact-manager)
233
+ - [Hello, World! Sample](#hello-world-sample)
234
+ - [Hello, Table! Sample](#hello-table-sample)
235
+ - [Tetris](#tetris)
241
236
  - [Desktop Apps Built with Glimmer DSL for SWT](#desktop-apps-built-with-glimmer-dsl-for-swt)
242
237
  - [Table of contents](#table-of-contents)
243
238
  - [Background](#background)
@@ -276,6 +271,8 @@ If you see anything that needs to be improved, please do not hesitate to contact
276
271
  - [Multi-Threading](#multi-threading)
277
272
  - [Menus](#menus)
278
273
  - [ScrolledComposite](#scrolledcomposite)
274
+ - [Sash Form Widget](#sash-form-widget)
275
+ - [Browser Widget](#browser-widget)
279
276
  - [Widget Styles](#widget-styles)
280
277
  - [Explicit SWT Style Bit](#explicit-swt-style-bit)
281
278
  - [Negative SWT Style Bits](#negative-swt-style-bits)
@@ -307,7 +304,12 @@ If you see anything that needs to be improved, please do not hesitate to contact
307
304
  - [Lifecycle Hooks Example](#lifecycle-hooks-example)
308
305
  - [Custom Widget API](#custom-widget-api)
309
306
  - [Content/Options Example](#contentoptions-example)
310
- - [Gotcha](#gotcha)
307
+ - [Custom Widget Gotchas](#custom-widget-gotchas)
308
+ - [Built-In Custom Widgets](#built-in-custom-widgets)
309
+ - [Checkbox Group Custom Widget](#checkbox-group-custom-widget)
310
+ - [Radio Group Custom Widget](#radio-group-custom-widget)
311
+ - [Code Text Custom Widget](#code-text-custom-widget)
312
+ - [Video Custom Widget](#video-custom-widget)
311
313
  - [Custom Widget Final Notes](#custom-widget-final-notes)
312
314
  - [Custom Shells](#custom-shells)
313
315
  - [Drag and Drop](#drag-and-drop)
@@ -315,12 +317,6 @@ If you see anything that needs to be improved, please do not hesitate to contact
315
317
  - [Multi-DSL Support](#multi-dsl-support)
316
318
  - [Application Menu Items (About/Preferences)](#application-menu-items-aboutpreferences)
317
319
  - [App Name and Version](#app-name-and-version)
318
- - [Checkbox Group Widget](#checkbox-group-widget)
319
- - [Radio Group Widget](#radio-group-widget)
320
- - [Code Text Widget](#code-text-widget)
321
- - [Video Widget](#video-widget)
322
- - [Sash Form Widget](#sash-form-widget)
323
- - [Browser Widget](#browser-widget)
324
320
  - [Glimmer Configuration](#glimmer-configuration)
325
321
  - [logger](#logger)
326
322
  - [logging_devices](#loggingdevices)
@@ -364,15 +360,16 @@ If you see anything that needs to be improved, please do not hesitate to contact
364
360
  - [Hello, Button!](#hello-button)
365
361
  - [Hello, Link!](#hello-link)
366
362
  - [Hello, Dialog!](#hello-dialog)
363
+ - [Hello, Code Text!](#hello-code-text)
367
364
  - [Hello, Canvas!](#hello-canvas)
368
365
  - [Hello, Canvas Animation!](#hello-canvas-animation)
369
366
  - [Hello, Canvas Transform!](#hello-canvas-transform)
370
367
  - [Elaborate Samples](#elaborate-samples)
371
368
  - [User Profile](#user-profile)
372
369
  - [Login](#login)
373
- - [Tic Tac Toe Sample](#tic-tac-toe-sample)
374
- - [Contact Manager Sample](#contact-manager-sample)
375
- - [Tetris](#tetris)
370
+ - [Tic Tac Toe Sample](#tic-tac-toe)
371
+ - [Contact Manager Sample](#contact-manager)
372
+ - [Glimmer Tetris](#glimmer-tetris)
376
373
  - [External Samples](#external-samples)
377
374
  - [Glimmer Calculator](#glimmer-calculator)
378
375
  - [Gladiator](#gladiator)
@@ -493,9 +490,7 @@ jgem install glimmer-dsl-swt
493
490
 
494
491
  Or this command if you want a specific version:
495
492
  ```
496
- jgem install glimmer-dsl-swt -v 4.18.3.3
497
-
498
-
493
+ jgem install glimmer-dsl-swt -v 4.18.4.2
499
494
  ```
500
495
 
501
496
  `jgem` is JRuby's version of `gem` command.
@@ -513,8 +508,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
513
508
 
514
509
  Add the following to `Gemfile`:
515
510
  ```
516
- gem 'glimmer-dsl-swt', '~> 4.18.3.3
517
- '
511
+ gem 'glimmer-dsl-swt', '~> 4.18.4.2'
518
512
  ```
519
513
 
520
514
  And, then run:
@@ -572,9 +566,7 @@ bin/glimmer samples
572
566
  Below are the full usage instructions that come up when running `glimmer` without args.
573
567
 
574
568
  ```
575
- Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.18.3.3
576
-
577
-
569
+ Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.18.4.2
578
570
 
579
571
  Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
580
572
 
@@ -596,8 +588,8 @@ Tasks are run via rake. Some tasks take arguments in square brackets.
596
588
 
597
589
  Available tasks are below (if you do not see any, please add `require 'glimmer/rake_task'` to Rakefile and rerun or run rake -T):
598
590
 
599
- Select a Glimmer task to run: (Press ↑/↓ arrow to move, Enter to select and letters to filter)
600
- glimmer list:gems:customshell[query] # List Glimmer custom shell gems available at rubygems.org (query is optional) [alt: list:gems:cs]
591
+ Select a Glimmer task to run: (Press ↑/↓ arrow to move, Enter to select and letters to filter)
592
+ ‣ glimmer list:gems:customshell[query] # List Glimmer custom shell gems available at rubygems.org (query is optional) [alt: list:gems:cs]
601
593
  glimmer list:gems:customwidget[query] # List Glimmer custom widget gems available at rubygems.org (query is optional) [alt: list:gems:cw]
602
594
  glimmer list:gems:dsl[query] # List Glimmer DSL gems available at rubygems.org (query is optional)
603
595
  glimmer package[type] # Package app for distribution (generating config, jar, and native files) (type is optional)
@@ -1053,9 +1045,7 @@ Output:
1053
1045
 
1054
1046
  Css glimmer-dsl-css 1.1.0 AndyMaleh Glimmer DSL for CSS
1055
1047
  Opal glimmer-dsl-opal 0.10.2 AndyMaleh Glimmer DSL for Opal
1056
- Swt glimmer-dsl-swt 4.18.3.3
1057
-
1058
- AndyMaleh Glimmer DSL for SWT
1048
+ Swt glimmer-dsl-swt 4.18.4.2 AndyMaleh Glimmer DSL for SWT
1059
1049
  Tk glimmer-dsl-tk 0.0.6 AndyMaleh Glimmer DSL for Tk
1060
1050
  Xml glimmer-dsl-xml 1.1.0 AndyMaleh Glimmer DSL for XML
1061
1051
  ```
@@ -1895,6 +1885,79 @@ Glimmer provides smart defaults for the `scrolled_composite` widget by:
1895
1885
  - Automatically setting the :h_scroll and :v_scroll SWT styles (can be set manually if only one of either :h_scroll or :v_scroll is desired )
1896
1886
  - Automatically setting the expand horizontal and expand vertical SWT properties to `true`
1897
1887
 
1888
+ #### Sash Form Widget
1889
+
1890
+ `sash_form` is an SWT built-in custom widget that provides a resizable sash that splits a window area into two or more panes.
1891
+
1892
+ It can be customized with the `weights` attribute by setting initial weights to size the panes at first display.
1893
+
1894
+ One noteworthy thing about the Glimmer implementation is that, unlike behavior in SWT, it allows declaring `weights` before the content of the `sash_form`, thus providing more natural and convenient syntax (Glimmer automatically takes care of sending that declaration to SWT at the end of declaring `sash_form` content as per the SWT requirements)
1895
+
1896
+ Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
1897
+
1898
+ ```ruby
1899
+ shell {
1900
+ text 'Sash Form Example'
1901
+ sash_form {
1902
+ label {
1903
+ text '(resize >>)'
1904
+ background :dark_green
1905
+ foreground :white
1906
+ font height: 20
1907
+ }
1908
+ label {
1909
+ text '(<< resize)'
1910
+ background :red
1911
+ foreground :white
1912
+ font height: 20
1913
+ }
1914
+ weights 1, 2
1915
+ }
1916
+ }.open
1917
+ ```
1918
+
1919
+ You may check out a more full-fledged example in [Hello, Sash Form!](#hello-sash-form)
1920
+
1921
+ ![Hello Sash Form](images/glimmer-hello-sash-form.png)
1922
+
1923
+ #### Browser Widget
1924
+
1925
+ ![Hello Browser](images/glimmer-hello-browser.png)
1926
+
1927
+ Glimmer supports the SWT Browser widget, which can load URLs or render HTML. It can even be instrumented with JavaScript when needed (though highly discouraged since it defeats the purpose of using Ruby except in very rare cases like leveraging a pre-existing web codebase in a desktop app).
1928
+
1929
+ Example loading a URL (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
1930
+
1931
+ ```ruby
1932
+ shell {
1933
+ minimum_size 1024, 860
1934
+ browser {
1935
+ url 'http://brightonresort.com/about'
1936
+ }
1937
+ }.open
1938
+ ```
1939
+
1940
+ Example rendering HTML with JavaScript on document ready (you may copy/paste in [`girb`](#girb-glimmer-irb-command) provided you install and require [glimmer-dsl-xml gem](https://github.com/AndyObtiva/glimmer-dsl-xml)):
1941
+
1942
+ ```ruby
1943
+ shell {
1944
+ minimum_size 130, 130
1945
+ @browser = browser {
1946
+ text html {
1947
+ head {
1948
+ meta(name: "viewport", content: "width=device-width, initial-scale=2.0")
1949
+ }
1950
+ body {
1951
+ h1 { "Hello, World!" }
1952
+ }
1953
+ }
1954
+ on_completed { # on load of the page execute this JavaScript
1955
+ @browser.swt_widget.execute("alert('Hello, World!');")
1956
+ }
1957
+ }
1958
+ }.open
1959
+ ```
1960
+
1898
1961
  ### Widget Styles
1899
1962
 
1900
1963
  SWT widgets receive `SWT` styles in their constructor as per this guide:
@@ -2357,7 +2420,8 @@ Shape keywords and their args (including defaults) are listed below (they basica
2357
2420
  - `rectangle​(x, y, width, height, vertical = true, fill: true, gradient: true)` gradient rectangle, which is always filled, and takes an optional extra argument to specify true for vertical gradient (default) and false for horizontal gradient
2358
2421
  - `text(string, x, y, flags = nil)` text with optional flags (flag format is `swt(comma_separated_flags)` where flags can be :draw_delimiter (i.e. new lines), :draw_tab, :draw_mnemonic, and :draw_transparent as explained in [GC API](https://help.eclipse.org/2020-12/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/graphics/GC.html))
2359
2422
 
2360
- Shape keywords that can be filled with color can take an keyword argument `fill: true` (defaults to false when not specified)
2423
+ Shape keywords that can be filled with color can take an keyword argument `fill: true`. Defaults to false when not specified unless background is set with no foreground (or foreground is set with no background), in which case a smart default is applied.
2424
+ Smart defaults can be applied to automatically infer `gradient: true` (rectangle with both foreground and background) and `round: true` (rectangle with more than 4 args, the extra args are numeric) as well.
2361
2425
 
2362
2426
  Optionally, a shape keyword takes a block that can set any attributes from [org.eclipse.swt.graphics.GC](https://help.eclipse.org/2020-12/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/graphics/GC.html) (methods starting with `set`), which enable setting the `background` for filling and `foreground` for drawing.
2363
2427
 
@@ -2381,6 +2445,8 @@ Here is a list of supported attributes nestable within a block under shapes:
2381
2445
  - `text_anti_alias` enables text antialiasing (SWT style value of `:default`, `:off`, `:on` whereby `:default` applies OS default, which varies per OS)
2382
2446
  - `transform` sets transform object using [Canvas Transform DSL](#canvas-transform-dsl) syntax
2383
2447
 
2448
+ Keep in mind that ordering of shapes matters as it is followed in painting. For example, it is recommended you paint filled shapes first and then drawn ones.
2449
+
2384
2450
  Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
2385
2451
 
2386
2452
  ```ruby
@@ -2395,10 +2461,10 @@ shell {
2395
2461
 
2396
2462
  canvas {
2397
2463
  background :dark_yellow
2398
- rectangle(0, 0, 220, 400, fill: true) {
2464
+ rectangle(0, 0, 220, 400) {
2399
2465
  background :dark_red
2400
2466
  }
2401
- rectangle(50, 20, 300, 150, 30, 50, round: true, fill: true) {
2467
+ rectangle(50, 20, 300, 150, 30, 50, round: true) {
2402
2468
  background :yellow
2403
2469
  }
2404
2470
  rectangle(150, 200, 100, 70, true, gradient: true) {
@@ -2468,6 +2534,103 @@ In any case, if there is anything missing you would like added to the Glimmer Sh
2468
2534
 
2469
2535
  Keep in mind that the Shape DSL can be used inside any widget, not just `canvas`. Unlike shapes on a `canvas`, which are standalone graphics, when included in a widget, which already has its own look and feel, shapes are used as a decorative add-on that complements its look by getting painted on top of it. For example, shapes were used to decorate `composite` blocks in the [Tetris](#tetris) sample to have a more bevel look. In summary, Shapes can be used in a hybrid approach (shapes inside a widget), not just standalone in a `canvas`.
2470
2536
 
2537
+ #### Shapes inside an Image
2538
+
2539
+ You can build an image using the Canvas Shape DSL (including setting the icon of the application).
2540
+
2541
+ Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
2542
+
2543
+ ```
2544
+ include Glimmer
2545
+
2546
+ shell {
2547
+ text 'Image Shape DSL Example'
2548
+ label {
2549
+ bevel_constant = 20
2550
+ icon_block_size = 64
2551
+ icon_bevel_size = icon_block_size.to_f / 25.to_f
2552
+ icon_bevel_pixel_size = 0.16*icon_block_size.to_f
2553
+ icon_size = 8
2554
+ icon_pixel_size = icon_block_size * icon_size
2555
+ image(icon_pixel_size, icon_pixel_size) {
2556
+ icon_size.times { |row|
2557
+ icon_size.times { |column|
2558
+ colored = row >= 1 && column.between?(1, 6)
2559
+ color = colored ? color([:white, :red, :blue, :green, :yellow, :magenta, :cyan, :dark_blue].sample) : color(:white)
2560
+ x = column * icon_block_size
2561
+ y = row * icon_block_size
2562
+ rectangle(x, y, icon_block_size, icon_block_size) {
2563
+ background color
2564
+ }
2565
+ polygon(x, y, x + icon_block_size, y, x + icon_block_size - icon_bevel_pixel_size, y + icon_bevel_pixel_size, x + icon_bevel_pixel_size, y + icon_bevel_pixel_size) {
2566
+ background rgb(color.red + 4*bevel_constant, color.green + 4*bevel_constant, color.blue + 4*bevel_constant)
2567
+ }
2568
+ polygon(x + icon_block_size, y, x + icon_block_size - icon_bevel_pixel_size, y + icon_bevel_pixel_size, x + icon_block_size - icon_bevel_pixel_size, y + icon_block_size - icon_bevel_pixel_size, x + icon_block_size, y + icon_block_size) {
2569
+ background rgb(color.red - bevel_constant, color.green - bevel_constant, color.blue - bevel_constant)
2570
+ }
2571
+ polygon(x + icon_block_size, y + icon_block_size, x, y + icon_block_size, x + icon_bevel_pixel_size, y + icon_block_size - icon_bevel_pixel_size, x + icon_block_size - icon_bevel_pixel_size, y + icon_block_size - icon_bevel_pixel_size) {
2572
+ background rgb(color.red - 2*bevel_constant, color.green - 2*bevel_constant, color.blue - 2*bevel_constant)
2573
+ }
2574
+ polygon(x, y, x, y + icon_block_size, x + icon_bevel_pixel_size, y + icon_block_size - icon_bevel_pixel_size, x + icon_bevel_pixel_size, y + icon_bevel_pixel_size) {
2575
+ background rgb(color.red - bevel_constant, color.green - bevel_constant, color.blue - bevel_constant)
2576
+ }
2577
+ }
2578
+ }
2579
+ }
2580
+ }
2581
+ }.open
2582
+ ```
2583
+
2584
+ ![Image Shape DSL](images/glimmer-example-image-shape-dsl.png)
2585
+
2586
+ Example setting the icon of the application (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
2587
+
2588
+ ```
2589
+ include Glimmer
2590
+
2591
+ shell {
2592
+ text 'Image Shape DSL Example'
2593
+ label {
2594
+ text 'Image Shape DSL Example'
2595
+ font height: 30
2596
+ }
2597
+ bevel_constant = 20
2598
+ icon_block_size = 64
2599
+ icon_bevel_size = icon_block_size.to_f / 25.to_f
2600
+ icon_bevel_pixel_size = 0.16*icon_block_size.to_f
2601
+ icon_size = 8
2602
+ icon_pixel_size = icon_block_size * icon_size
2603
+ image(icon_pixel_size, icon_pixel_size) {
2604
+ icon_size.times { |row|
2605
+ icon_size.times { |column|
2606
+ colored = row >= 1 && column.between?(1, 6)
2607
+ color = colored ? color([:white, :red, :blue, :green, :yellow, :magenta, :cyan, :dark_blue].sample) : color(:white)
2608
+ x = column * icon_block_size
2609
+ y = row * icon_block_size
2610
+ rectangle(x, y, icon_block_size, icon_block_size) {
2611
+ background color
2612
+ }
2613
+ polygon(x, y, x + icon_block_size, y, x + icon_block_size - icon_bevel_pixel_size, y + icon_bevel_pixel_size, x + icon_bevel_pixel_size, y + icon_bevel_pixel_size) {
2614
+ background rgb(color.red + 4*bevel_constant, color.green + 4*bevel_constant, color.blue + 4*bevel_constant)
2615
+ }
2616
+ polygon(x + icon_block_size, y, x + icon_block_size - icon_bevel_pixel_size, y + icon_bevel_pixel_size, x + icon_block_size - icon_bevel_pixel_size, y + icon_block_size - icon_bevel_pixel_size, x + icon_block_size, y + icon_block_size) {
2617
+ background rgb(color.red - bevel_constant, color.green - bevel_constant, color.blue - bevel_constant)
2618
+ }
2619
+ polygon(x + icon_block_size, y + icon_block_size, x, y + icon_block_size, x + icon_bevel_pixel_size, y + icon_block_size - icon_bevel_pixel_size, x + icon_block_size - icon_bevel_pixel_size, y + icon_block_size - icon_bevel_pixel_size) {
2620
+ background rgb(color.red - 2*bevel_constant, color.green - 2*bevel_constant, color.blue - 2*bevel_constant)
2621
+ }
2622
+ polygon(x, y, x, y + icon_block_size, x + icon_bevel_pixel_size, y + icon_block_size - icon_bevel_pixel_size, x + icon_bevel_pixel_size, y + icon_bevel_pixel_size) {
2623
+ background rgb(color.red - bevel_constant, color.green - bevel_constant, color.blue - bevel_constant)
2624
+ }
2625
+ }
2626
+ }
2627
+ }
2628
+ }.open
2629
+ ```
2630
+
2631
+ ![Image Shape DSL](images/glimmer-example-image-shape-dsl-app-switcher-icon.png)
2632
+
2633
+
2471
2634
  ### Canvas Transform DSL
2472
2635
 
2473
2636
  The transform DSL builds [org.eclipse.swt.graphics.Transform](https://help.eclipse.org/2020-12/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/graphics/Transform.html) objects with a nice declarative syntax.
@@ -2573,7 +2736,7 @@ shell {
2573
2736
 
2574
2737
  frame { |index|
2575
2738
  background rgb(index%100, index%100 + 100, index%55 + 200)
2576
- rectangle(index, index, 20, 20, fill: true) {
2739
+ rectangle(index, index, 20, 20) {
2577
2740
  background :red
2578
2741
  }
2579
2742
  }
@@ -2612,6 +2775,12 @@ Learn more at the [Hello, Canvas Animation! Sample](#hello-canvas-animation).
2612
2775
 
2613
2776
  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.
2614
2777
 
2778
+ #### Animation via Data-Binding
2779
+
2780
+ Animation could be alternatively implemented without the `animation` keyword through a loop that invokes model methods inside `sync_exec {}` (or `async_exec {}`), which indirectly cause updates to the GUI via data-binding.
2781
+
2782
+ The [Glimmer Tetris](#glimmer-tetris) sample provides a good example of that.
2783
+
2615
2784
  ### Data-Binding
2616
2785
 
2617
2786
  Data-binding is done with `bind` command following widget property to bind and taking model and bindable attribute as arguments.
@@ -3429,7 +3598,7 @@ shell {
3429
3598
 
3430
3599
  Notice how `:no_focus` was the `swt_style` value, followed by the `options` hash `{orientation: :horizontal, bg_color: :white}`, and finally the `content` block containing the label with `'SANDWICH CONTENT'`
3431
3600
 
3432
- #### Gotcha
3601
+ #### Custom Widget Gotchas
3433
3602
 
3434
3603
  Beware of defining a custom attribute that is a common SWT widget property name.
3435
3604
  For example, if you define `text=` and `text` methods to accept a custom text and then later you write this body:
@@ -3459,6 +3628,314 @@ body {
3459
3628
 
3460
3629
  The `text` method invoked in the custom widget body will call the one you defined above it. To avoid this gotcha, simply name the text property above something else, like `custom_text`.
3461
3630
 
3631
+ #### Built-In Custom Widgets
3632
+
3633
+ ##### Checkbox Group Custom Widget
3634
+
3635
+ `checkbox_group` (or alias `check_group`) is a Glimmer built-in custom widget that displays a list of `checkbox` buttons (`button(:check)`) based on its `items` property.
3636
+
3637
+ `checkbox_group` consists of a root `composite` (with `grid_layout 1, false` by default) that holds nested `checkbox` (`button(:check)`) widgets.
3638
+
3639
+ The `selection` property determines which `checkbox` buttons are checked. It expects an `Array` of `String` objects
3640
+ The `selection_indices` property determines which `checkbox` button indices are checked. It expects an `Array` of index `Integer` objects that are zero-based.
3641
+ The `checkboxes` property returns the list of nested `checkbox` widgets.
3642
+
3643
+ When data-binding `selection`, the model property should have a matching property with `_options` suffix (e.g. `activities_options` for `activities`) to provide an `Array` of `String` objects for `checkbox` buttons.
3644
+
3645
+ You may see an example at the [Hello, Checkbox Group!](#hello-checkbox-group) sample.
3646
+
3647
+ ![Hello Checkbox Group](images/glimmer-hello-checkbox-group.png)
3648
+
3649
+ ##### Radio Group Custom Widget
3650
+
3651
+ `radio_group` is a Glimmer built-in custom widget that displays a list of `radio` buttons (`button(:radio)`) based on its `items` property, which expects an `Array` of `String` objects.
3652
+
3653
+ `radio_group` consists of a root `composite` (with `grid_layout 1, false` by default) that holds nested `radio` widgets.
3654
+
3655
+ The `selection` property determines which `radio` button is selected. It expects a `String`
3656
+ The `selection_index` property determines which `radio` button index is selected. It expects an index integer that is zero-based.
3657
+ The `radios` property returns the list of nested `radio` widgets.
3658
+
3659
+ When data-binding `selection`, the model property should have a matching property with `_options` suffix (e.g. `country_options` for `country`) to provide text for `radio` buttons.
3660
+
3661
+ This custom widget is used in the [Glimmer Meta-Sample (The Sample of Samples)](#samples):
3662
+
3663
+ ![Glimmer Meta-Sample](images/glimmer-meta-sample.png)
3664
+
3665
+ Glimmer Meta-Sample Code Example:
3666
+
3667
+ ```ruby
3668
+ # ...
3669
+ radio_group { |radio_group_proxy|
3670
+ row_layout(:vertical) {
3671
+ fill true
3672
+ }
3673
+ selection bind(sample_directory, :selected_sample_name)
3674
+ font height: 24
3675
+ }
3676
+
3677
+ # ...
3678
+ ```
3679
+
3680
+ You may see another example at the [Hello, Radio Group!](#hello-radio-group) sample.
3681
+
3682
+ ##### Code Text Custom Widget
3683
+
3684
+ `code_text` is a Glimmer built-in custom widget that displays syntax highlighted Ruby code in a customized SWT [StyledText](https://help.eclipse.org/2020-09/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/custom/StyledText.html) widget.
3685
+
3686
+ It is used in the [Glimmer Meta-Sample (The Sample of Samples)](#samples):
3687
+
3688
+ ![Glimmer Meta-Sample](images/glimmer-meta-sample.png)
3689
+
3690
+ Glimmer Meta-Sample Code Example:
3691
+
3692
+ ```ruby
3693
+ # ...
3694
+ @code_text = code_text {
3695
+ text bind(SampleDirectory, 'selected_sample.code', read_only: true)
3696
+ editable bind(SampleDirectory, 'selected_sample.editable')
3697
+ }
3698
+ # ...
3699
+ ```
3700
+
3701
+ To use, simply use `code_text` in place of the `text` or `styled_text` widget. If you set its `text` value to Ruby code, it automatically styles it with syntax highlighting.
3702
+
3703
+ ###### Options
3704
+
3705
+ **lines**
3706
+ (default: false)
3707
+
3708
+ Shows line numbers when set to true.
3709
+
3710
+ If set to a hash like `{width: 4}`, it sets the width of the line numbers lane in character count (default: 4)
3711
+
3712
+ **theme**
3713
+ (default: 'glimmer')
3714
+
3715
+ Changes syntax color highlighting theme. Can be one of the following:
3716
+ - glimmer
3717
+ - github
3718
+ - pastie
3719
+
3720
+ **language**
3721
+ (default: `'ruby'`)
3722
+
3723
+ Sets the code language, which can be one of the following [rouge gem](#https://rubygems.org/gems/rouge) supported languages:
3724
+ - abap
3725
+ - actionscript
3726
+ - ada
3727
+ - apache
3728
+ - apex
3729
+ - apiblueprint
3730
+ - apple_script
3731
+ - armasm
3732
+ - augeas
3733
+ - awk
3734
+ - batchfile
3735
+ - bbcbasic
3736
+ - bibtex
3737
+ - biml
3738
+ - bpf
3739
+ - brainfuck
3740
+ - brightscript
3741
+ - bsl
3742
+ - c
3743
+ - ceylon
3744
+ - cfscript
3745
+ - clean
3746
+ - clojure
3747
+ - cmake
3748
+ - cmhg
3749
+ - coffeescript
3750
+ - common_lisp
3751
+ - conf
3752
+ - console
3753
+ - coq
3754
+ - cpp
3755
+ - crystal
3756
+ - csharp
3757
+ - css
3758
+ - csvs
3759
+ - cuda
3760
+ - cypher
3761
+ - cython
3762
+ - d
3763
+ - dart
3764
+ - datastudio
3765
+ - diff
3766
+ - digdag
3767
+ - docker
3768
+ - dot
3769
+ - ecl
3770
+ - eex
3771
+ - eiffel
3772
+ - elixir
3773
+ - elm
3774
+ - email
3775
+ - epp
3776
+ - erb
3777
+ - erlang
3778
+ - escape
3779
+ - factor
3780
+ - fortran
3781
+ - freefem
3782
+ - fsharp
3783
+ - gdscript
3784
+ - ghc_cmm
3785
+ - ghc_core
3786
+ - gherkin
3787
+ - glsl
3788
+ - go
3789
+ - gradle
3790
+ - graphql
3791
+ - groovy
3792
+ - hack
3793
+ - haml
3794
+ - handlebars
3795
+ - haskell
3796
+ - haxe
3797
+ - hcl
3798
+ - hlsl
3799
+ - hocon
3800
+ - hql
3801
+ - html
3802
+ - http
3803
+ - hylang
3804
+ - idlang
3805
+ - igorpro
3806
+ - ini
3807
+ - io
3808
+ - irb
3809
+ - isbl
3810
+ - j
3811
+ - janet
3812
+ - java
3813
+ - javascript
3814
+ - jinja
3815
+ - jsl
3816
+ - json
3817
+ - json_doc
3818
+ - jsonnet
3819
+ - jsp
3820
+ - jsx
3821
+ - julia
3822
+ - kotlin
3823
+ - lasso
3824
+ - liquid
3825
+ - literate_coffeescript
3826
+ - literate_haskell
3827
+ - livescript
3828
+ - llvm
3829
+ - lua
3830
+ - lustre
3831
+ - lutin
3832
+ - m68k
3833
+ - magik
3834
+ - make
3835
+ - markdown
3836
+ - mason
3837
+ - mathematica
3838
+ - matlab
3839
+ - minizinc
3840
+ - moonscript
3841
+ - mosel
3842
+ - msgtrans
3843
+ - mxml
3844
+ - nasm
3845
+ - nesasm
3846
+ - nginx
3847
+ - nim
3848
+ - nix
3849
+ - objective_c
3850
+ - objective_cpp
3851
+ - ocaml
3852
+ - ocl
3853
+ - openedge
3854
+ - opentype_feature_file
3855
+ - pascal
3856
+ - perl
3857
+ - php
3858
+ - plain_text
3859
+ - plist
3860
+ - pony
3861
+ - postscript
3862
+ - powershell
3863
+ - praat
3864
+ - prolog
3865
+ - prometheus
3866
+ - properties
3867
+ - protobuf
3868
+ - puppet
3869
+ - python
3870
+ - q
3871
+ - qml
3872
+ - r
3873
+ - racket
3874
+ - reasonml
3875
+ - rego
3876
+ - rescript
3877
+ - robot_framework
3878
+ - ruby
3879
+ - rust
3880
+ - sas
3881
+ - sass
3882
+ - scala
3883
+ - scheme
3884
+ - scss
3885
+ - sed
3886
+ - shell
3887
+ - sieve
3888
+ - slice
3889
+ - slim
3890
+ - smalltalk
3891
+ - smarty
3892
+ - sml
3893
+ - solidity
3894
+ - sparql
3895
+ - sqf
3896
+ - sql
3897
+ - ssh
3898
+ - supercollider
3899
+ - swift
3900
+ - systemd
3901
+ - tap
3902
+ - tcl
3903
+ - terraform
3904
+ - tex
3905
+ - toml
3906
+ - tsx
3907
+ - ttcn3
3908
+ - tulip
3909
+ - turtle
3910
+ - twig
3911
+ - typescript
3912
+ - vala
3913
+ - varnish
3914
+ - vb
3915
+ - velocity
3916
+ - verilog
3917
+ - vhdl
3918
+ - viml
3919
+ - vue
3920
+ - wollok
3921
+ - xml
3922
+ - xojo
3923
+ - xpath
3924
+ - xquery
3925
+ - yaml
3926
+ - yang
3927
+ - zig
3928
+
3929
+ Learn more at [Hello, Code Text!](#hello-code-text)
3930
+
3931
+ ##### Video Custom Custom Widget
3932
+
3933
+ [![Video Widget](images/glimmer-video-widget.png)](https://github.com/AndyObtiva/glimmer-cw-video)
3934
+
3935
+ Glimmer supports a [video custom widget](https://github.com/AndyObtiva/glimmer-cw-video) not in SWT, which was originally a Glimmer built-in custom widget, but has been later extracted into its own [Ruby gem](https://rubygems.org/gems/glimmer-cw-video).
3936
+
3937
+ Simply install the [glimmer-cw-video](https://rubygems.org/gems/glimmer-cw-video) gem.
3938
+
3462
3939
  #### Custom Widget Final Notes
3463
3940
 
3464
3941
  This [Eclipse guide](https://www.eclipse.org/articles/Article-Writing%20Your%20Own%20Widget/Writing%20Your%20Own%20Widget.htm) for how to write custom SWT widgets is also applicable to Glimmer Custom Widgets written in Ruby. I recommend reading it:
@@ -3850,157 +4327,6 @@ You may run `glimmer` with the `--profile.graph` instead for a more detailed out
3850
4327
 
3851
4328
  Learn more at the [JRuby Performance Profile WIKI page](https://github.com/jruby/jruby/wiki/Profiling-JRuby).
3852
4329
 
3853
- #### Checkbox Group Widget
3854
-
3855
- `checkbox_group` (or alias `check_group`) is a Glimmer built-in custom widget that displays a list of `checkbox` buttons (`button(:check)`) based on its `items` property.
3856
-
3857
- `checkbox_group` consists of a root `composite` (with `grid_layout 1, false` by default) that holds nested `checkbox` (`button(:check)`) widgets.
3858
-
3859
- The `selection` property determines which `checkbox` buttons are checked. It expects an `Array` of `String` objects
3860
- The `selection_indices` property determines which `checkbox` button indices are checked. It expects an `Array` of index `Integer` objects that are zero-based.
3861
- The `checkboxes` property returns the list of nested `checkbox` widgets.
3862
-
3863
- When data-binding `selection`, the model property should have a matching property with `_options` suffix (e.g. `activities_options` for `activities`) to provide an `Array` of `String` objects for `checkbox` buttons.
3864
-
3865
- You may see an example at the [Hello, Checkbox Group!](#hello-checkbox-group) sample.
3866
-
3867
- ![Hello Checkbox Group](images/glimmer-hello-checkbox-group.png)
3868
-
3869
- #### Radio Group Widget
3870
-
3871
- `radio_group` is a Glimmer built-in custom widget that displays a list of `radio` buttons (`button(:radio)`) based on its `items` property, which expects an `Array` of `String` objects.
3872
-
3873
- `radio_group` consists of a root `composite` (with `grid_layout 1, false` by default) that holds nested `radio` widgets.
3874
-
3875
- The `selection` property determines which `radio` button is selected. It expects a `String`
3876
- The `selection_index` property determines which `radio` button index is selected. It expects an index integer that is zero-based.
3877
- The `radios` property returns the list of nested `radio` widgets.
3878
-
3879
- When data-binding `selection`, the model property should have a matching property with `_options` suffix (e.g. `country_options` for `country`) to provide text for `radio` buttons.
3880
-
3881
- This custom widget is used in the [Glimmer Meta-Sample (The Sample of Samples)](#samples):
3882
-
3883
- ![Glimmer Meta-Sample](images/glimmer-meta-sample.png)
3884
-
3885
- Glimmer Meta-Sample Code Example:
3886
-
3887
- ```ruby
3888
- # ...
3889
- radio_group { |radio_group_proxy|
3890
- row_layout(:vertical) {
3891
- fill true
3892
- }
3893
- selection bind(sample_directory, :selected_sample_name)
3894
- font height: 24
3895
- }
3896
-
3897
- # ...
3898
- ```
3899
-
3900
- You may see another example at the [Hello, Radio Group!](#hello-radio-group) sample.
3901
-
3902
- #### Code Text Widget
3903
-
3904
- `code_text` is a Glimmer built-in custom widget that displays syntax highlighted Ruby code in a customized SWT [StyledText](https://help.eclipse.org/2020-09/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/custom/StyledText.html) widget.
3905
-
3906
- It is used in the [Glimmer Meta-Sample (The Sample of Samples)](#samples):
3907
-
3908
- ![Glimmer Meta-Sample](images/glimmer-meta-sample.png)
3909
-
3910
- Glimmer Meta-Sample Code Example:
3911
-
3912
- ```ruby
3913
- # ...
3914
- @code_text = code_text {
3915
- text bind(SampleDirectory, 'selected_sample.code', read_only: true)
3916
- editable bind(SampleDirectory, 'selected_sample.editable')
3917
- }
3918
- # ...
3919
- ```
3920
-
3921
- To use, simply use `code_text` in place of the `text` or `styled_text` widget. If you set its `text` value to Ruby code, it automatically styles it with syntax highlighting.
3922
-
3923
- #### Video Widget
3924
-
3925
- [![Video Widget](images/glimmer-video-widget.png)](https://github.com/AndyObtiva/glimmer-cw-video)
3926
-
3927
- Glimmer supports a [video custom widget](https://github.com/AndyObtiva/glimmer-cw-video) not in SWT.
3928
-
3929
- You may obtain via `glimmer-cw-video` gem.
3930
-
3931
- #### Sash Form Widget
3932
-
3933
- `sash_form` is an SWT built-in custom widget that provides a resizable sash that splits a window area into two or more panes.
3934
-
3935
- It can be customized with the `weights` attribute by setting initial weights to size the panes at first display.
3936
-
3937
- One noteworthy thing about the Glimmer implementation is that, unlike behavior in SWT, it allows declaring `weights` before the content of the `sash_form`, thus providing more natural and convenient syntax (Glimmer automatically takes care of sending that declaration to SWT at the end of declaring `sash_form` content as per the SWT requirements)
3938
-
3939
- Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
3940
-
3941
- ```ruby
3942
- shell {
3943
- text 'Sash Form Example'
3944
- sash_form {
3945
- label {
3946
- text '(resize >>)'
3947
- background :dark_green
3948
- foreground :white
3949
- font height: 20
3950
- }
3951
- label {
3952
- text '(<< resize)'
3953
- background :red
3954
- foreground :white
3955
- font height: 20
3956
- }
3957
- weights 1, 2
3958
- }
3959
- }.open
3960
- ```
3961
-
3962
- You may check out a more full-fledged example in [Hello, Sash Form!](#hello-sash-form)
3963
-
3964
- ![Hello Sash Form](images/glimmer-hello-sash-form.png)
3965
-
3966
- #### Browser Widget
3967
-
3968
- ![Hello Browser](images/glimmer-hello-browser.png)
3969
-
3970
- Glimmer supports the SWT Browser widget, which can load URLs or render HTML. It can even be instrumented with JavaScript when needed (though highly discouraged since it defeats the purpose of using Ruby except in very rare cases like leveraging a pre-existing web codebase in a desktop app).
3971
-
3972
- Example loading a URL (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
3973
-
3974
- ```ruby
3975
- shell {
3976
- minimum_size 1024, 860
3977
- browser {
3978
- url 'http://brightonresort.com/about'
3979
- }
3980
- }.open
3981
- ```
3982
-
3983
- Example rendering HTML with JavaScript on document ready (you may copy/paste in [`girb`](#girb-glimmer-irb-command) provided you install and require [glimmer-dsl-xml gem](https://github.com/AndyObtiva/glimmer-dsl-xml)):
3984
-
3985
- ```ruby
3986
- shell {
3987
- minimum_size 130, 130
3988
- @browser = browser {
3989
- text html {
3990
- head {
3991
- meta(name: "viewport", content: "width=device-width, initial-scale=2.0")
3992
- }
3993
- body {
3994
- h1 { "Hello, World!" }
3995
- }
3996
- }
3997
- on_completed { # on load of the page execute this JavaScript
3998
- @browser.swt_widget.execute("alert('Hello, World!');")
3999
- }
4000
- }
4001
- }.open
4002
- ```
4003
-
4004
4330
  ##### SWT Browser Style Options
4005
4331
 
4006
4332
  The `browser` widget can use a particular desktop browser by setting the SWT Style to:
@@ -4283,7 +4609,7 @@ bin/glimmer samples/hello/hello_canvas_transform.rb
4283
4609
 
4284
4610
  For hello-type simple samples, check the following.
4285
4611
 
4286
- #### Hello, World! Sample
4612
+ #### Hello, World!
4287
4613
 
4288
4614
  Code:
4289
4615
 
@@ -4738,6 +5064,26 @@ Hello, Dialog! Open Dialog
4738
5064
 
4739
5065
  ![Hello Dialog Open Dialog](images/glimmer-hello-dialog-open-dialog.png)
4740
5066
 
5067
+ #### Hello, Code Text!
5068
+
5069
+ This sample demonstrates the Glimmer Built-In [Code Text Custom Widget](#code-text-custom-widget).
5070
+
5071
+ Code:
5072
+
5073
+ [samples/hello/hello_code_text.rb](samples/hello/hello_code_text.rb)
5074
+
5075
+ Hello, Code Text! Ruby Language / Glimmer Theme / Show Line Numbers (default width of 4)
5076
+
5077
+ ![Hello Code Text Ruby](images/glimmer-hello-code-text-ruby.png)
5078
+
5079
+ Hello, Code Text! JavaScript Language / Pastie Theme / Show Line Numbers (custom width of 2)
5080
+
5081
+ ![Hello Code Text JavaScript](images/glimmer-hello-code-text-javascript.png)
5082
+
5083
+ Hello, Code Text! HTML Language / GitHub Theme / No Line Numbers
5084
+
5085
+ ![Hello Code Text HTML](images/glimmer-hello-code-text-html.png)
5086
+
4741
5087
  #### Hello, Canvas!
4742
5088
 
4743
5089
  This sample demonstrates the use of the `canvas` widget and [Shape DSL](#canvas-shape-dsl) in Glimmer.
@@ -4807,7 +5153,7 @@ Code:
4807
5153
  ![Login Filled In](images/glimmer-login-filled-in.png)
4808
5154
  ![Login Logged In](images/glimmer-login-logged-in.png)
4809
5155
 
4810
- #### Tic Tac Toe Sample
5156
+ #### Tic Tac Toe
4811
5157
 
4812
5158
  This sample demonstrates a full MVC application, including GUI layout, text and enablement data-binding, and test-driven development (has [specs](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/spec/samples/elaborate/tic_tac_toe/board_spec.rb)).
4813
5159
 
@@ -4821,7 +5167,7 @@ Code:
4821
5167
  ![Tic Tac Toe In Progress](images/glimmer-tic-tac-toe-in-progress.png)
4822
5168
  ![Tic Tac Toe Game Over](images/glimmer-tic-tac-toe-game-over.png)
4823
5169
 
4824
- #### Contact Manager Sample
5170
+ #### Contact Manager
4825
5171
 
4826
5172
  This sample demonstrates table data-binding, sorting, filtering, GUI layout, MVP pattern, and test-driven development (has [specs](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/spec/samples/elaborate/contact_manager/contact_manager_presenter_spec.rb)).
4827
5173
 
@@ -4849,14 +5195,16 @@ Contact Manager - Edit Done
4849
5195
 
4850
5196
  ![Contact Manager](images/glimmer-contact-manager-edit-done.png)
4851
5197
 
4852
- #### Tetris
5198
+ #### Glimmer Tetris
4853
5199
 
4854
- 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, and keyboard events.
5200
+ 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.
4855
5201
 
4856
5202
  Code:
4857
5203
 
4858
5204
  [samples/elaborate/tetris.rb](samples/elaborate/tetris.rb)
4859
5205
 
5206
+ ![Tetris Icon](images/glimmer-tetris-icon.png)
5207
+
4860
5208
  ![Tetris](images/glimmer-tetris.png)
4861
5209
 
4862
5210
  ![Tetris Game Over](images/glimmer-tetris-game-over.png)