glimmer-dsl-swt 4.18.3.4 → 4.18.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +55 -0
  3. data/README.md +600 -331
  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/swt/custom/code_text.rb +200 -51
  10. data/lib/glimmer/swt/custom/drawable.rb +1 -4
  11. data/lib/glimmer/swt/custom/shape.rb +50 -6
  12. data/lib/glimmer/swt/date_time_proxy.rb +1 -3
  13. data/lib/glimmer/swt/display_proxy.rb +11 -0
  14. data/lib/glimmer/swt/font_proxy.rb +1 -0
  15. data/lib/glimmer/swt/image_proxy.rb +11 -0
  16. data/lib/glimmer/swt/layout_proxy.rb +4 -1
  17. data/lib/glimmer/swt/shell_proxy.rb +4 -1
  18. data/lib/glimmer/swt/table_proxy.rb +17 -13
  19. data/lib/glimmer/swt/widget_proxy.rb +11 -3
  20. data/samples/elaborate/meta_sample.rb +15 -4
  21. data/samples/elaborate/meta_sample/meta_sample_logo.png +0 -0
  22. data/samples/elaborate/tetris.rb +16 -6
  23. data/samples/elaborate/tetris/model/game.rb +3 -3
  24. data/samples/elaborate/tetris/model/past_game.rb +14 -1
  25. data/samples/elaborate/tetris/view/block.rb +1 -1
  26. data/samples/elaborate/tetris/view/high_score_dialog.rb +1 -10
  27. data/samples/elaborate/tetris/view/playfield.rb +1 -1
  28. data/samples/elaborate/tetris/view/tetris_menu_bar.rb +13 -11
  29. data/samples/hello/hello_canvas.rb +7 -6
  30. data/samples/hello/hello_canvas_animation.rb +3 -3
  31. data/samples/hello/hello_canvas_transform.rb +1 -1
  32. data/samples/hello/hello_canvas_transform/hello_canvas_transform_image.png +0 -0
  33. data/samples/hello/hello_code_text.rb +104 -0
  34. data/samples/hello/hello_table.rb +7 -4
  35. data/samples/hello/hello_table/baseball_park.png +0 -0
  36. metadata +7 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 63410b8b302bc061b5089d24bcadaacbd54b83bbb581ffecd0a46c7c026329c1
4
- data.tar.gz: 60da9c410a221130713e209c0e6127d3e04f17feccbcb29788c2234a90802bb9
3
+ metadata.gz: 961d9ddec901003644771059d3e3914ec041fe72e6d551ea1aa89c0f755725ee
4
+ data.tar.gz: 5dc835b1580c1f5125531f80efb9620cf39b8ccb905dc991bf771c38bcac1816
5
5
  SHA512:
6
- metadata.gz: 81a1feac2ef1bf9c7329d26714d0d7c61b926f710a785f0b7d2e1a424b2548cf159604ada03f368996c99cb45d0834bb362a715cbfae0fa5ec1b4e5af659ee8b
7
- data.tar.gz: a4c1e06cf9aa7f3b656e9d5d22d56883f1def62865b1aa56555041c8238c07e0f333f17cd6f6108ada800e1738294f148757752e4609e1dd34dcbdc8183bd1ba
6
+ metadata.gz: b21c2e5bc842dd1ef9d937b37fa72567d76b8c3ee4ae823952d982a2e80d078b50f383738b70f40655c241d1c697a5ce10ae74c9b43dce7685ca6d9d4683ebe9
7
+ data.tar.gz: 1862c2516f8237a426cbddb6a331d74bc5112950491abb9d78a5086df8e9343408146d17c05e0c10613f68828d1a9081ec54ba118f8d4b8ab80d25b567d4c1b5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,60 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.18.4.3
4
+
5
+ - Fix flashing issue when using ShellProxy#pack_same_size on Windows
6
+ - Double buffer Hello, Canvas Animation! Sample to remove flickering
7
+ - Tetris - Added `:double_buffered` SWT style for Tetris Playfield and Block to avoid rendering flicker on Windows
8
+ - Tetris - Substituted command key with control on Windows/Linux to make Tetris menu shortcuts work (e.g. CTRL+P pauses)
9
+ - Tetris - Workaround for Windows issue with tetromino down invisibility upon holding down arrow key (now holding down does only one down)
10
+
11
+ ### 4.18.4.2
12
+
13
+ - Remove Tetris Clear button from High Score dialog (since it is available via menu and is rarely used)
14
+ - Make right control button rotate right with Tetris
15
+ - Avoid adding the widget listeners for read_only data-binding (instead of just relying on ModelBinding raising exceptions)
16
+ - Clean up the meta sample code_text style by removing root composite margins/spacing
17
+ - Made background for top label of Hello, Table! transparent for Windows
18
+ - Fix `glimmer samples` command and Meta-Sample on Windows
19
+ - Fix Tetris on Windows
20
+ - Fix Hello, Canvas on Windows
21
+ - Fix Hello, Canvas Transform when launched from `glimmer samples`
22
+ - Fix Table editing write_on_cancel option use on Windows
23
+ - Fix issue with adding content to the end of a styled text widget breaking line number scrolling
24
+ - Fix issue with code_text not showing line numbers for extra new lines at the end
25
+
26
+ ### 4.18.4.1
27
+
28
+ - Support data-binding of `code_text` with lines enabled.
29
+ - Upgrade the Glimmer Meta-Sample with code_text lines: {width: 2}
30
+ - With code_text lines enabled, support setting/data-binding properties on root composite via nesting `root { }` underneath
31
+ - With code_text lines enabled, support setting/data-binding properties on line numbers styled text widget via nesting `line_numbers { }` underneath
32
+ - Update the Hello, Code Text! sample to remove borders and line numbers background in the JavaScript example
33
+ - Fix issue with updating layout upon later reopening layout/layout data via `proxy.content {}` method
34
+
35
+ ### 4.18.4.0
36
+
37
+ - 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})
38
+ - code_text support select all via CMD+A
39
+ - code_text support end of line via CTRL+E and beginning of line via CTRL+A
40
+ - Support automatic inferrence of Canvas Shape DSL gradient option (just like fill option)
41
+ - Support automatic inferrence of Canvas Shape DSL round option (just like fill option)
42
+ - Add a background image to Hello, Table! Sample + font/color changes
43
+ - Make Canvas patterns auto-reused and auto-disposed when canvas is disposed
44
+ - Make Canvas images auto-dispose themselves when canvas is disposed
45
+ - Update Hello, Code Text!
46
+ - Change Glimmer Tetris Sample up arrow default to rotate left
47
+ - Fix issue with "undefined method lex for nil:NilClass" in `code_text`
48
+
49
+ ### 4.18.3.5
50
+
51
+ - 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
52
+ - Make code_text custom widget support multiple code languages via `language: 'java'` option
53
+ - Make code_text custom widget support multiple themes via `theme: 'github'` option
54
+ - Hello, Code Text! Sample
55
+ - 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
56
+ - Fix issue with setting date geting rejected in `date_time` for month or day being incompatible with the year/month/day combo
57
+
3
58
  ### 4.18.3.4
4
59
 
5
60
  - Support building Image objects with the Glimmer Canvas Shape DSL
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.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.4.3
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:
164
+
165
+ ![Hello Table](images/glimmer-hello-table.png)
91
166
 
92
- ![Tic Tac Toe](images/glimmer-tic-tac-toe-in-progress.png)
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)
@@ -459,9 +456,10 @@ https://www.eclipse.org/swt/faq.php
459
456
 
460
457
  ## Pre-requisites
461
458
 
462
- - JDK 8u241 (1.8.0_241) (find at https://www.oracle.com/java/technologies/javase/javase8u211-later-archive-downloads.html)
459
+ - JDK 8u241 (1.8.0_241) (find at https://www.oracle.com/java/technologies/javase/javase8u211-later-archive-downloads.html / On Windows, ensure PATH includes Java bin directory like C:\Program Files\Java\jdk1.8.0_241\bin for javapackager to work during packaging Glimmer applications)
463
460
  - JRuby 9.2.14.0 (supporting Ruby 2.5.x syntax) (get via [RVM](http://rvm.io) on Mac and Linux or find at [https://www.jruby.org/download](https://www.jruby.org/download) for Windows)
464
461
  - SWT 4.18 (already included in the [glimmer-dsl-swt](https://rubygems.org/gems/glimmer-dsl-swt) gem)
462
+ - Git (comes with Mac and Linux. Install on Windows: https://git-scm.com/download/win )
465
463
 
466
464
  To obtain JRuby through [RVM](http://rvm.io), you may run:
467
465
 
@@ -481,7 +479,7 @@ If you intend to build a Glimmer app from scratch with [scaffolding](#scaffoldin
481
479
 
482
480
  Otherwise, Option 2 ([Bundler](#option-2-bundler)) can be followed in rare cases where you want to build an app without [scaffolding](#scaffolding).
483
481
 
484
- Note: if you encounter any [issues](https://github.com/AndyObtiva/glimmer-dsl-swt/issues), please [report](https://github.com/AndyObtiva/glimmer-dsl-swt/issues) and then install a previous version instead from the list of [Glimmer Releases](https://rubygems.org/gems/glimmer-dsl-swt/versions).
482
+ **Note:** if you encounter any [issues](https://github.com/AndyObtiva/glimmer-dsl-swt/issues), please [report](https://github.com/AndyObtiva/glimmer-dsl-swt/issues) and then install a previous version instead from the list of [Glimmer Releases](https://rubygems.org/gems/glimmer-dsl-swt/versions) (keep looking back till you find one that works). Do not be disheartened as nearly everything is only a few days of work away. That said, keep in mind that this project is free and open source, meaning provided as is, so do not expect anything, but if you help with reporting and contributing, you could speed things up or even become part of the project.
485
483
 
486
484
  ### Option 1: Direct Install
487
485
  (Use for [Scaffolding](#scaffolding))
@@ -493,9 +491,7 @@ jgem install glimmer-dsl-swt
493
491
 
494
492
  Or this command if you want a specific version:
495
493
  ```
496
- jgem install glimmer-dsl-swt -v 4.18.3.4
497
-
498
-
494
+ jgem install glimmer-dsl-swt -v 4.18.4.3
499
495
  ```
500
496
 
501
497
  `jgem` is JRuby's version of `gem` command.
@@ -513,8 +509,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
513
509
 
514
510
  Add the following to `Gemfile`:
515
511
  ```
516
- gem 'glimmer-dsl-swt', '~> 4.18.3.4
517
- '
512
+ gem 'glimmer-dsl-swt', '~> 4.18.4.3'
518
513
  ```
519
514
 
520
515
  And, then run:
@@ -572,9 +567,7 @@ bin/glimmer samples
572
567
  Below are the full usage instructions that come up when running `glimmer` without args.
573
568
 
574
569
  ```
575
- Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.18.3.4
576
-
577
-
570
+ Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.18.4.3
578
571
 
579
572
  Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
580
573
 
@@ -596,8 +589,8 @@ Tasks are run via rake. Some tasks take arguments in square brackets.
596
589
 
597
590
  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
591
 
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]
592
+ Select a Glimmer task to run: (Press ↑/↓ arrow to move, Enter to select and letters to filter)
593
+ ‣ glimmer list:gems:customshell[query] # List Glimmer custom shell gems available at rubygems.org (query is optional) [alt: list:gems:cs]
601
594
  glimmer list:gems:customwidget[query] # List Glimmer custom widget gems available at rubygems.org (query is optional) [alt: list:gems:cw]
602
595
  glimmer list:gems:dsl[query] # List Glimmer DSL gems available at rubygems.org (query is optional)
603
596
  glimmer package[type] # Package app for distribution (generating config, jar, and native files) (type is optional)
@@ -1053,9 +1046,7 @@ Output:
1053
1046
 
1054
1047
  Css glimmer-dsl-css 1.1.0 AndyMaleh Glimmer DSL for CSS
1055
1048
  Opal glimmer-dsl-opal 0.10.2 AndyMaleh Glimmer DSL for Opal
1056
- Swt glimmer-dsl-swt 4.18.3.4
1057
-
1058
- AndyMaleh Glimmer DSL for SWT
1049
+ Swt glimmer-dsl-swt 4.18.4.3 AndyMaleh Glimmer DSL for SWT
1059
1050
  Tk glimmer-dsl-tk 0.0.6 AndyMaleh Glimmer DSL for Tk
1060
1051
  Xml glimmer-dsl-xml 1.1.0 AndyMaleh Glimmer DSL for XML
1061
1052
  ```
@@ -1895,6 +1886,79 @@ Glimmer provides smart defaults for the `scrolled_composite` widget by:
1895
1886
  - 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
1887
  - Automatically setting the expand horizontal and expand vertical SWT properties to `true`
1897
1888
 
1889
+ #### Sash Form Widget
1890
+
1891
+ `sash_form` is an SWT built-in custom widget that provides a resizable sash that splits a window area into two or more panes.
1892
+
1893
+ It can be customized with the `weights` attribute by setting initial weights to size the panes at first display.
1894
+
1895
+ 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)
1896
+
1897
+ Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
1898
+
1899
+ ```ruby
1900
+ shell {
1901
+ text 'Sash Form Example'
1902
+ sash_form {
1903
+ label {
1904
+ text '(resize >>)'
1905
+ background :dark_green
1906
+ foreground :white
1907
+ font height: 20
1908
+ }
1909
+ label {
1910
+ text '(<< resize)'
1911
+ background :red
1912
+ foreground :white
1913
+ font height: 20
1914
+ }
1915
+ weights 1, 2
1916
+ }
1917
+ }.open
1918
+ ```
1919
+
1920
+ You may check out a more full-fledged example in [Hello, Sash Form!](#hello-sash-form)
1921
+
1922
+ ![Hello Sash Form](images/glimmer-hello-sash-form.png)
1923
+
1924
+ #### Browser Widget
1925
+
1926
+ ![Hello Browser](images/glimmer-hello-browser.png)
1927
+
1928
+ 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).
1929
+
1930
+ Example loading a URL (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
1931
+
1932
+ ```ruby
1933
+ shell {
1934
+ minimum_size 1024, 860
1935
+ browser {
1936
+ url 'http://brightonresort.com/about'
1937
+ }
1938
+ }.open
1939
+ ```
1940
+
1941
+ 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)):
1942
+
1943
+ ```ruby
1944
+ shell {
1945
+ minimum_size 130, 130
1946
+ @browser = browser {
1947
+ text html {
1948
+ head {
1949
+ meta(name: "viewport", content: "width=device-width, initial-scale=2.0")
1950
+ }
1951
+ body {
1952
+ h1 { "Hello, World!" }
1953
+ }
1954
+ }
1955
+ on_completed { # on load of the page execute this JavaScript
1956
+ @browser.swt_widget.execute("alert('Hello, World!');")
1957
+ }
1958
+ }
1959
+ }.open
1960
+ ```
1961
+
1898
1962
  ### Widget Styles
1899
1963
 
1900
1964
  SWT widgets receive `SWT` styles in their constructor as per this guide:
@@ -2339,25 +2403,28 @@ https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/
2339
2403
 
2340
2404
  ### Canvas Shape DSL
2341
2405
 
2406
+ **(ALPHA FEATURE)**
2407
+
2342
2408
  Glimmer supports drawing graphics directly on a `canvas` widget via SWT (or any widget for that matter though `canvas` is recommended for drawing).
2343
2409
 
2344
2410
  This is accomplished via the Shape DSL a sub-DSL of the Glimmer GUI DSL, which makes it possible to draw graphics declaratively with very understandable and maintainable syntax.
2345
2411
 
2346
2412
  Shape keywords and their args (including defaults) are listed below (they basically match method names and arguments on [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) minus the `draw` or `fill` prefix in downcase):
2347
- - `arc(x, y, width, height, startAngle, arcAngle, fill: false)` arc is part of a circle within an oval area, denoted by start angle (degrees) and end angle (degrees)
2348
- - `focus(x, y, width, height)` this is just like rectangle but its foreground color is always that of the OS widget focus color (useful when capturing user interaction via a shape)
2413
+ - `arc​(x, y, width, height, startAngle, arcAngle, fill: false)` arc is part of a circle within an oval area, denoted by start angle (degrees) and end angle (degrees)
2414
+ - `focus​(x, y, width, height)` this is just like rectangle but its foreground color is always that of the OS widget focus color (useful when capturing user interaction via a shape)
2349
2415
  - `image(image, x, y)` [image](#image)
2350
2416
  - `line(x1, y1, x2, y2)` line
2351
2417
  - `oval(x, y, width, height, fill: false)` oval if width does not match heigh and circle if width matches height. Can be optionally filled.
2352
- - `point(x, y)` point
2418
+ - `point​(x, y)` point
2353
2419
  - `polygon(pointArray, fill: false)` polygon consisting of points, which close automatically to form a shape that can be optionally filled (when points only form a line, it does not show up as filled)
2354
2420
  - `polyline(pointArray)` polyline is just like a polygon, but it does not close up to form a shape, remaining open (unless the points close themselves by having the last point or an intermediate point match the first)
2355
2421
  - `rectangle(x, y, width, height, fill: false)` standard rectangle, which can be optionally filled
2356
2422
  - `rectangle(x, y, width, height, arcWidth = 60, arcHeight = 60, fill: false, round: true)` round rectangle, which can be optionally filled, and takes optional extra round angle arguments
2357
- - `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
2423
+ - `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
2424
  - `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
2425
 
2360
2426
  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.
2427
+ 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
2428
 
2362
2429
  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
2430
 
@@ -2367,7 +2434,7 @@ Here is a list of supported attributes nestable within a block under shapes:
2367
2434
  - `antialias` enables antialiasing (SWT style value of `:default`, `:off`, `:on` whereby `:default` applies OS default, which varies per OS)
2368
2435
  - `background` sets fill color for fillable shapes (standard color symbol (e.g. `:red`), `rgb(red_integer, green_integer, blue_integer)` color, or Color/ColorProxy object directly)
2369
2436
  - `background_pattern` sets fill gradient/image pattern for fillable shape background (takes the same arguments as the SWT [Pattern](https://help.eclipse.org/2020-12/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/graphics/Pattern.html) class [e.g. `background_pattern 2.3, 4.2, 5.4, 7.2, :red, :blue`] / note: this feature isn't extensively tested yet)
2370
- - `clipping` clips area of painting (numeric values for `(x, y, width, height)`)
2437
+ - `clipping` clips area of painting (​numeric values for `(x, y, width, height)`)
2371
2438
  - `fill_rule` sets filling rule (SWT style value of `:fill_even_odd` or `:fill_winding`)
2372
2439
  - `font` sets font (Hash of `:name`, `:height`, and `:style` just like standard widget font property, or Font/FontProxy object directly)
2373
2440
  - `foreground` sets draw color for drawable shapes (standard color symbol (e.g. `:red`), `rgb(red_integer, green_integer, blue_integer)` color, or Color/ColorProxy object directly)
@@ -2381,6 +2448,8 @@ Here is a list of supported attributes nestable within a block under shapes:
2381
2448
  - `text_anti_alias` enables text antialiasing (SWT style value of `:default`, `:off`, `:on` whereby `:default` applies OS default, which varies per OS)
2382
2449
  - `transform` sets transform object using [Canvas Transform DSL](#canvas-transform-dsl) syntax
2383
2450
 
2451
+ 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.
2452
+
2384
2453
  Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
2385
2454
 
2386
2455
  ```ruby
@@ -2567,6 +2636,8 @@ shell {
2567
2636
 
2568
2637
  ### Canvas Transform DSL
2569
2638
 
2639
+ **(ALPHA FEATURE)**
2640
+
2570
2641
  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.
2571
2642
 
2572
2643
  `transform` keyword builds a `Transform` object. It optionally takes the transformation matrix elements: (m11, m12, m21, m22, dx, dy)
@@ -2649,6 +2720,8 @@ Learn more at the [Hello, Canvas Transform! Sample](#hello-canvas-transform).
2649
2720
 
2650
2721
  ### Canvas Animation DSL
2651
2722
 
2723
+ **(EARLY ALPHA FEATURE)**
2724
+
2652
2725
  (note: this is a very new feature of Glimmer. It may change a bit while getting battle tested. As always, you could default to basic SWT usage if needed.)
2653
2726
 
2654
2727
  Glimmer additionally provides built-in support for animations via a declarative Animation DSL, another sub-DSL of the Glimmer GUI DSL.
@@ -2709,6 +2782,12 @@ Learn more at the [Hello, Canvas Animation! Sample](#hello-canvas-animation).
2709
2782
 
2710
2783
  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.
2711
2784
 
2785
+ #### Animation via Data-Binding
2786
+
2787
+ 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.
2788
+
2789
+ The [Glimmer Tetris](#glimmer-tetris) sample provides a good example of that.
2790
+
2712
2791
  ### Data-Binding
2713
2792
 
2714
2793
  Data-binding is done with `bind` command following widget property to bind and taking model and bindable attribute as arguments.
@@ -3211,7 +3290,7 @@ https://help.eclipse.org/2019-12/index.jsp?topic=%2Forg.eclipse.platform.doc.isv
3211
3290
 
3212
3291
  It has `addSelectionListener`. Additionally, under its `Control` super class, it has `addControlListener`, `addDragDetectListener`, `addFocusListener`, `addGestureListener`, `addHelpListener`, `addKeyListener`, `addMenuDetectListener`, `addMouseListener`, `addMouseMoveListener`, `addMouseTrackListener`, `addMouseWheelListener`, `addPaintListener`, `addTouchListener`, and `addTraverseListener`
3213
3292
 
3214
- Suppose, we select `addSelectionListener`, which is responsible for what happens when a user selects a button (clicks it). Then, open its argument `SelectionListener` SWT API, and you find the event (instance) methods: `widgetDefaultSelected` and `widgetSelected​`. Let's select the second one, which is what gets invoked when a button is clicked.
3293
+ Suppose, we select `addSelectionListener`, which is responsible for what happens when a user selects a button (clicks it). Then, open its argument `SelectionListener` SWT API, and you find the event (instance) methods: `widgetDefaultSelected` and `widgetSelected​`. Let's select the second one, which is what gets invoked when a button is clicked.
3215
3294
 
3216
3295
  Now, Glimmer simplifies the process of hooking into that listener (observer) by neither requiring you to call the `addSelectionListener` method nor requiring you to implement/extend the `SelectionListener` API.
3217
3296
 
@@ -3526,7 +3605,7 @@ shell {
3526
3605
 
3527
3606
  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'`
3528
3607
 
3529
- #### Gotcha
3608
+ #### Custom Widget Gotchas
3530
3609
 
3531
3610
  Beware of defining a custom attribute that is a common SWT widget property name.
3532
3611
  For example, if you define `text=` and `text` methods to accept a custom text and then later you write this body:
@@ -3556,6 +3635,315 @@ body {
3556
3635
 
3557
3636
  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`.
3558
3637
 
3638
+ #### Built-In Custom Widgets
3639
+
3640
+ ##### Checkbox Group Custom Widget
3641
+
3642
+ `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.
3643
+
3644
+ `checkbox_group` consists of a root `composite` (with `grid_layout 1, false` by default) that holds nested `checkbox` (`button(:check)`) widgets.
3645
+
3646
+ The `selection` property determines which `checkbox` buttons are checked. It expects an `Array` of `String` objects
3647
+ The `selection_indices` property determines which `checkbox` button indices are checked. It expects an `Array` of index `Integer` objects that are zero-based.
3648
+ The `checkboxes` property returns the list of nested `checkbox` widgets.
3649
+
3650
+ 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.
3651
+
3652
+ You may see an example at the [Hello, Checkbox Group!](#hello-checkbox-group) sample.
3653
+
3654
+ ![Hello Checkbox Group](images/glimmer-hello-checkbox-group.png)
3655
+
3656
+ ##### Radio Group Custom Widget
3657
+
3658
+ `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.
3659
+
3660
+ `radio_group` consists of a root `composite` (with `grid_layout 1, false` by default) that holds nested `radio` widgets.
3661
+
3662
+ The `selection` property determines which `radio` button is selected. It expects a `String`
3663
+ The `selection_index` property determines which `radio` button index is selected. It expects an index integer that is zero-based.
3664
+ The `radios` property returns the list of nested `radio` widgets.
3665
+
3666
+ 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.
3667
+
3668
+ This custom widget is used in the [Glimmer Meta-Sample (The Sample of Samples)](#samples):
3669
+
3670
+ ![Glimmer Meta-Sample](images/glimmer-meta-sample.png)
3671
+
3672
+ Glimmer Meta-Sample Code Example:
3673
+
3674
+ ```ruby
3675
+ # ...
3676
+ radio_group { |radio_group_proxy|
3677
+ row_layout(:vertical) {
3678
+ fill true
3679
+ }
3680
+ selection bind(sample_directory, :selected_sample_name)
3681
+ font height: 24
3682
+ }
3683
+
3684
+ # ...
3685
+ ```
3686
+
3687
+ You may see another example at the [Hello, Radio Group!](#hello-radio-group) sample.
3688
+
3689
+ ##### Code Text Custom Widget
3690
+
3691
+ `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.
3692
+
3693
+ It is used in the [Glimmer Meta-Sample (The Sample of Samples)](#samples):
3694
+
3695
+ ![Glimmer Meta-Sample](images/glimmer-meta-sample.png)
3696
+
3697
+ Glimmer Meta-Sample Code Example:
3698
+
3699
+ ```ruby
3700
+ # ...
3701
+ @code_text = code_text {
3702
+ text bind(SampleDirectory, 'selected_sample.code', read_only: true)
3703
+ editable bind(SampleDirectory, 'selected_sample.editable')
3704
+ }
3705
+ # ...
3706
+ ```
3707
+
3708
+ 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.
3709
+
3710
+ ###### Options
3711
+
3712
+ **lines**
3713
+ (default: false)
3714
+ **(ALPHA OPTION)**
3715
+
3716
+ Shows line numbers when set to true.
3717
+
3718
+ If set to a hash like `{width: 4}`, it sets the width of the line numbers lane in character count (default: 4)
3719
+
3720
+ **theme**
3721
+ (default: 'glimmer')
3722
+
3723
+ Changes syntax color highlighting theme. Can be one of the following:
3724
+ - glimmer
3725
+ - github
3726
+ - pastie
3727
+
3728
+ **language**
3729
+ (default: `'ruby'`)
3730
+
3731
+ Sets the code language, which can be one of the following [rouge gem](#https://rubygems.org/gems/rouge) supported languages:
3732
+ - abap
3733
+ - actionscript
3734
+ - ada
3735
+ - apache
3736
+ - apex
3737
+ - apiblueprint
3738
+ - apple_script
3739
+ - armasm
3740
+ - augeas
3741
+ - awk
3742
+ - batchfile
3743
+ - bbcbasic
3744
+ - bibtex
3745
+ - biml
3746
+ - bpf
3747
+ - brainfuck
3748
+ - brightscript
3749
+ - bsl
3750
+ - c
3751
+ - ceylon
3752
+ - cfscript
3753
+ - clean
3754
+ - clojure
3755
+ - cmake
3756
+ - cmhg
3757
+ - coffeescript
3758
+ - common_lisp
3759
+ - conf
3760
+ - console
3761
+ - coq
3762
+ - cpp
3763
+ - crystal
3764
+ - csharp
3765
+ - css
3766
+ - csvs
3767
+ - cuda
3768
+ - cypher
3769
+ - cython
3770
+ - d
3771
+ - dart
3772
+ - datastudio
3773
+ - diff
3774
+ - digdag
3775
+ - docker
3776
+ - dot
3777
+ - ecl
3778
+ - eex
3779
+ - eiffel
3780
+ - elixir
3781
+ - elm
3782
+ - email
3783
+ - epp
3784
+ - erb
3785
+ - erlang
3786
+ - escape
3787
+ - factor
3788
+ - fortran
3789
+ - freefem
3790
+ - fsharp
3791
+ - gdscript
3792
+ - ghc_cmm
3793
+ - ghc_core
3794
+ - gherkin
3795
+ - glsl
3796
+ - go
3797
+ - gradle
3798
+ - graphql
3799
+ - groovy
3800
+ - hack
3801
+ - haml
3802
+ - handlebars
3803
+ - haskell
3804
+ - haxe
3805
+ - hcl
3806
+ - hlsl
3807
+ - hocon
3808
+ - hql
3809
+ - html
3810
+ - http
3811
+ - hylang
3812
+ - idlang
3813
+ - igorpro
3814
+ - ini
3815
+ - io
3816
+ - irb
3817
+ - isbl
3818
+ - j
3819
+ - janet
3820
+ - java
3821
+ - javascript
3822
+ - jinja
3823
+ - jsl
3824
+ - json
3825
+ - json_doc
3826
+ - jsonnet
3827
+ - jsp
3828
+ - jsx
3829
+ - julia
3830
+ - kotlin
3831
+ - lasso
3832
+ - liquid
3833
+ - literate_coffeescript
3834
+ - literate_haskell
3835
+ - livescript
3836
+ - llvm
3837
+ - lua
3838
+ - lustre
3839
+ - lutin
3840
+ - m68k
3841
+ - magik
3842
+ - make
3843
+ - markdown
3844
+ - mason
3845
+ - mathematica
3846
+ - matlab
3847
+ - minizinc
3848
+ - moonscript
3849
+ - mosel
3850
+ - msgtrans
3851
+ - mxml
3852
+ - nasm
3853
+ - nesasm
3854
+ - nginx
3855
+ - nim
3856
+ - nix
3857
+ - objective_c
3858
+ - objective_cpp
3859
+ - ocaml
3860
+ - ocl
3861
+ - openedge
3862
+ - opentype_feature_file
3863
+ - pascal
3864
+ - perl
3865
+ - php
3866
+ - plain_text
3867
+ - plist
3868
+ - pony
3869
+ - postscript
3870
+ - powershell
3871
+ - praat
3872
+ - prolog
3873
+ - prometheus
3874
+ - properties
3875
+ - protobuf
3876
+ - puppet
3877
+ - python
3878
+ - q
3879
+ - qml
3880
+ - r
3881
+ - racket
3882
+ - reasonml
3883
+ - rego
3884
+ - rescript
3885
+ - robot_framework
3886
+ - ruby
3887
+ - rust
3888
+ - sas
3889
+ - sass
3890
+ - scala
3891
+ - scheme
3892
+ - scss
3893
+ - sed
3894
+ - shell
3895
+ - sieve
3896
+ - slice
3897
+ - slim
3898
+ - smalltalk
3899
+ - smarty
3900
+ - sml
3901
+ - solidity
3902
+ - sparql
3903
+ - sqf
3904
+ - sql
3905
+ - ssh
3906
+ - supercollider
3907
+ - swift
3908
+ - systemd
3909
+ - tap
3910
+ - tcl
3911
+ - terraform
3912
+ - tex
3913
+ - toml
3914
+ - tsx
3915
+ - ttcn3
3916
+ - tulip
3917
+ - turtle
3918
+ - twig
3919
+ - typescript
3920
+ - vala
3921
+ - varnish
3922
+ - vb
3923
+ - velocity
3924
+ - verilog
3925
+ - vhdl
3926
+ - viml
3927
+ - vue
3928
+ - wollok
3929
+ - xml
3930
+ - xojo
3931
+ - xpath
3932
+ - xquery
3933
+ - yaml
3934
+ - yang
3935
+ - zig
3936
+
3937
+ Learn more at [Hello, Code Text!](#hello-code-text)
3938
+
3939
+ ##### Video Custom Custom Widget
3940
+
3941
+ [![Video Widget](images/glimmer-video-widget.png)](https://github.com/AndyObtiva/glimmer-cw-video)
3942
+
3943
+ 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).
3944
+
3945
+ Simply install the [glimmer-cw-video](https://rubygems.org/gems/glimmer-cw-video) gem.
3946
+
3559
3947
  #### Custom Widget Final Notes
3560
3948
 
3561
3949
  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:
@@ -3947,157 +4335,6 @@ You may run `glimmer` with the `--profile.graph` instead for a more detailed out
3947
4335
 
3948
4336
  Learn more at the [JRuby Performance Profile WIKI page](https://github.com/jruby/jruby/wiki/Profiling-JRuby).
3949
4337
 
3950
- #### Checkbox Group Widget
3951
-
3952
- `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.
3953
-
3954
- `checkbox_group` consists of a root `composite` (with `grid_layout 1, false` by default) that holds nested `checkbox` (`button(:check)`) widgets.
3955
-
3956
- The `selection` property determines which `checkbox` buttons are checked. It expects an `Array` of `String` objects
3957
- The `selection_indices` property determines which `checkbox` button indices are checked. It expects an `Array` of index `Integer` objects that are zero-based.
3958
- The `checkboxes` property returns the list of nested `checkbox` widgets.
3959
-
3960
- 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.
3961
-
3962
- You may see an example at the [Hello, Checkbox Group!](#hello-checkbox-group) sample.
3963
-
3964
- ![Hello Checkbox Group](images/glimmer-hello-checkbox-group.png)
3965
-
3966
- #### Radio Group Widget
3967
-
3968
- `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.
3969
-
3970
- `radio_group` consists of a root `composite` (with `grid_layout 1, false` by default) that holds nested `radio` widgets.
3971
-
3972
- The `selection` property determines which `radio` button is selected. It expects a `String`
3973
- The `selection_index` property determines which `radio` button index is selected. It expects an index integer that is zero-based.
3974
- The `radios` property returns the list of nested `radio` widgets.
3975
-
3976
- 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.
3977
-
3978
- This custom widget is used in the [Glimmer Meta-Sample (The Sample of Samples)](#samples):
3979
-
3980
- ![Glimmer Meta-Sample](images/glimmer-meta-sample.png)
3981
-
3982
- Glimmer Meta-Sample Code Example:
3983
-
3984
- ```ruby
3985
- # ...
3986
- radio_group { |radio_group_proxy|
3987
- row_layout(:vertical) {
3988
- fill true
3989
- }
3990
- selection bind(sample_directory, :selected_sample_name)
3991
- font height: 24
3992
- }
3993
-
3994
- # ...
3995
- ```
3996
-
3997
- You may see another example at the [Hello, Radio Group!](#hello-radio-group) sample.
3998
-
3999
- #### Code Text Widget
4000
-
4001
- `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.
4002
-
4003
- It is used in the [Glimmer Meta-Sample (The Sample of Samples)](#samples):
4004
-
4005
- ![Glimmer Meta-Sample](images/glimmer-meta-sample.png)
4006
-
4007
- Glimmer Meta-Sample Code Example:
4008
-
4009
- ```ruby
4010
- # ...
4011
- @code_text = code_text {
4012
- text bind(SampleDirectory, 'selected_sample.code', read_only: true)
4013
- editable bind(SampleDirectory, 'selected_sample.editable')
4014
- }
4015
- # ...
4016
- ```
4017
-
4018
- 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.
4019
-
4020
- #### Video Widget
4021
-
4022
- [![Video Widget](images/glimmer-video-widget.png)](https://github.com/AndyObtiva/glimmer-cw-video)
4023
-
4024
- Glimmer supports a [video custom widget](https://github.com/AndyObtiva/glimmer-cw-video) not in SWT.
4025
-
4026
- You may obtain via `glimmer-cw-video` gem.
4027
-
4028
- #### Sash Form Widget
4029
-
4030
- `sash_form` is an SWT built-in custom widget that provides a resizable sash that splits a window area into two or more panes.
4031
-
4032
- It can be customized with the `weights` attribute by setting initial weights to size the panes at first display.
4033
-
4034
- 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)
4035
-
4036
- Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
4037
-
4038
- ```ruby
4039
- shell {
4040
- text 'Sash Form Example'
4041
- sash_form {
4042
- label {
4043
- text '(resize >>)'
4044
- background :dark_green
4045
- foreground :white
4046
- font height: 20
4047
- }
4048
- label {
4049
- text '(<< resize)'
4050
- background :red
4051
- foreground :white
4052
- font height: 20
4053
- }
4054
- weights 1, 2
4055
- }
4056
- }.open
4057
- ```
4058
-
4059
- You may check out a more full-fledged example in [Hello, Sash Form!](#hello-sash-form)
4060
-
4061
- ![Hello Sash Form](images/glimmer-hello-sash-form.png)
4062
-
4063
- #### Browser Widget
4064
-
4065
- ![Hello Browser](images/glimmer-hello-browser.png)
4066
-
4067
- 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).
4068
-
4069
- Example loading a URL (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
4070
-
4071
- ```ruby
4072
- shell {
4073
- minimum_size 1024, 860
4074
- browser {
4075
- url 'http://brightonresort.com/about'
4076
- }
4077
- }.open
4078
- ```
4079
-
4080
- 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)):
4081
-
4082
- ```ruby
4083
- shell {
4084
- minimum_size 130, 130
4085
- @browser = browser {
4086
- text html {
4087
- head {
4088
- meta(name: "viewport", content: "width=device-width, initial-scale=2.0")
4089
- }
4090
- body {
4091
- h1 { "Hello, World!" }
4092
- }
4093
- }
4094
- on_completed { # on load of the page execute this JavaScript
4095
- @browser.swt_widget.execute("alert('Hello, World!');")
4096
- }
4097
- }
4098
- }.open
4099
- ```
4100
-
4101
4338
  ##### SWT Browser Style Options
4102
4339
 
4103
4340
  The `browser` widget can use a particular desktop browser by setting the SWT Style to:
@@ -4380,7 +4617,7 @@ bin/glimmer samples/hello/hello_canvas_transform.rb
4380
4617
 
4381
4618
  For hello-type simple samples, check the following.
4382
4619
 
4383
- #### Hello, World! Sample
4620
+ #### Hello, World!
4384
4621
 
4385
4622
  Code:
4386
4623
 
@@ -4835,6 +5072,26 @@ Hello, Dialog! Open Dialog
4835
5072
 
4836
5073
  ![Hello Dialog Open Dialog](images/glimmer-hello-dialog-open-dialog.png)
4837
5074
 
5075
+ #### Hello, Code Text!
5076
+
5077
+ This sample demonstrates the Glimmer Built-In [Code Text Custom Widget](#code-text-custom-widget).
5078
+
5079
+ Code:
5080
+
5081
+ [samples/hello/hello_code_text.rb](samples/hello/hello_code_text.rb)
5082
+
5083
+ Hello, Code Text! Ruby Language / Glimmer Theme / Show Line Numbers (default width of 4)
5084
+
5085
+ ![Hello Code Text Ruby](images/glimmer-hello-code-text-ruby.png)
5086
+
5087
+ Hello, Code Text! JavaScript Language / Pastie Theme / Show Line Numbers (custom width of 2)
5088
+
5089
+ ![Hello Code Text JavaScript](images/glimmer-hello-code-text-javascript.png)
5090
+
5091
+ Hello, Code Text! HTML Language / GitHub Theme / No Line Numbers
5092
+
5093
+ ![Hello Code Text HTML](images/glimmer-hello-code-text-html.png)
5094
+
4838
5095
  #### Hello, Canvas!
4839
5096
 
4840
5097
  This sample demonstrates the use of the `canvas` widget and [Shape DSL](#canvas-shape-dsl) in Glimmer.
@@ -4904,7 +5161,7 @@ Code:
4904
5161
  ![Login Filled In](images/glimmer-login-filled-in.png)
4905
5162
  ![Login Logged In](images/glimmer-login-logged-in.png)
4906
5163
 
4907
- #### Tic Tac Toe Sample
5164
+ #### Tic Tac Toe
4908
5165
 
4909
5166
  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)).
4910
5167
 
@@ -4918,7 +5175,7 @@ Code:
4918
5175
  ![Tic Tac Toe In Progress](images/glimmer-tic-tac-toe-in-progress.png)
4919
5176
  ![Tic Tac Toe Game Over](images/glimmer-tic-tac-toe-game-over.png)
4920
5177
 
4921
- #### Contact Manager Sample
5178
+ #### Contact Manager
4922
5179
 
4923
5180
  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)).
4924
5181
 
@@ -4946,10 +5203,12 @@ Contact Manager - Edit Done
4946
5203
 
4947
5204
  ![Contact Manager](images/glimmer-contact-manager-edit-done.png)
4948
5205
 
4949
- #### Tetris
5206
+ #### Glimmer Tetris
4950
5207
 
4951
5208
  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.
4952
5209
 
5210
+ Note that it works optimally on the Mac. It is very new, so it has not been optimized for Windows and Linux yet given their minor differences from the Mac.
5211
+
4953
5212
  Code:
4954
5213
 
4955
5214
  [samples/elaborate/tetris.rb](samples/elaborate/tetris.rb)
@@ -5023,7 +5282,7 @@ If you have a Glimmer app you would like referenced here, please mention in a Pu
5023
5282
 
5024
5283
  ## Packaging & Distribution
5025
5284
 
5026
- Note: this section mostly applies to Mac and Windows. On Linux, you can just run `glimmer package:gem` and after installing the gem, you get an executable matching the name of the app/custom-shell-gem you are building (e.g. `calculator` command becomes available after installing the [glimmer-cs-calculator](https://github.com/AndyObtiva/glimmer-cs-calculator) gem)
5285
+ Note: this section mostly applies to Mac and Windows. On Linux, you can just run `glimmer package:gem` and after installing the gem, you get an executable matching the name of the app/custom-shell-gem you are building (e.g. `calculator` command becomes available after installing the [glimmer-cs-calculator](https://github.com/AndyObtiva/glimmer-cs-calculator) gem). On Windows, ensure system PATH includes Java bin directory like "C:\Program Files\Java\jdk1.8.0_241\bin" for javapackager command to work during packaging Glimmer applications.
5027
5286
 
5028
5287
  Note 2: Glimmer packaging has a strong dependency on JDK8 at the moment. JDK9 & JDK10 might work, but JDK11 and onward definitely won't since they dropped javapackager, which later came back as jpackage in JDK14, but it's not ready for prime time yet. Just stick to JDK8 for now, strongly supported by Oracle for the next 6 years at least.
5029
5288
 
@@ -5033,7 +5292,7 @@ Glimmer simplifies the process of native-executable packaging and distribution o
5033
5292
  glimmer package
5034
5293
  ```
5035
5294
 
5036
- It works out of the box for any application scaffolded by [Glimmer Scaffolding](#scaffolding), generating all available packaging types on the current platform (e.g. `DMG`, `PKG`, `APP` on the Mac) and displaying a message indicating what pre-requisite setup tools are needed if not installed already (e.g. [Wix Toolset](https://wixtoolset.org/) to generate MSI files on Windows)
5295
+ It works out of the box for any application scaffolded by [Glimmer Scaffolding](#scaffolding), generating all available packaging types on the current platform (e.g. `DMG`, `PKG`, `APP` on the Mac) and displaying a message indicating what pre-requisite setup tools are needed if not installed already (e.g. [Wix Toolset](https://wixtoolset.org/) to generate MSI files on Windows). If you install Wix, make sure it is on the system PATH by adding for example "C:\Program Files (x86)\WiX Toolset v3.11\bin" to the Windows Environment Variables.
5037
5296
 
5038
5297
  You may choose to generate a specific type of packaging instead by addionally passing in the `[type]` option. For example, this generates an MSI setup file on Windows:
5039
5298
 
@@ -5181,7 +5440,7 @@ Glimmer::RakeTask::Package.javapackager_extra_args = '-Bmac.signing-key-develope
5181
5440
 
5182
5441
  Now, when you run `glimmer package`, it builds a self-signed DMG file. When you make available online, and users download, upon launching application, they are presented with your certificate, which they have to sign if they trust you in order to use the application.
5183
5442
 
5184
- ### Gotchas
5443
+ ### Packaging Gotchas
5185
5444
 
5186
5445
  1. Specifying License File
5187
5446
 
@@ -5214,6 +5473,16 @@ You can get around that in zsh by running glimmer package commands with `bash -c
5214
5473
  bash -c 'glimmer package'
5215
5474
  ```
5216
5475
 
5476
+ 4. Java on Windows System PATH
5477
+
5478
+ If you get any errors running Java on Windows, keep in mind that you need to have the Java binaries on the Windows System PATH environment variable:
5479
+ c:\program files\java\jre1.8.0_241
5480
+
5481
+ The problem is Oracle seems to be adding an indirect Java path junction in later versions of their installer:
5482
+ C:\Program Files (x86)\Common Files\Oracle\Java\javapath
5483
+
5484
+ Simply replace with the simple one above (setting the correct version number) and then reinstall JRuby to have it use Java from the right path.
5485
+
5217
5486
  ## App Updates
5218
5487
 
5219
5488
  Glimmer already supports automatic (and manual) app updates via the Mac App Store for Mac apps. Simply run the `glimmer package` command with the Mac App Store keys configured as per [Mac Application Distribution](mac-application-distribution) instructions and you get automatic (and manual) app update support courtesy of the Mac App Store.