glimmer-dsl-opal 0.7.4 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +35 -0
  3. data/README.md +783 -163
  4. data/VERSION +1 -1
  5. data/lib/glimmer-dsl-opal.rb +15 -3
  6. data/lib/glimmer-dsl-opal/ext/class.rb +10 -0
  7. data/lib/{file.rb → glimmer-dsl-opal/ext/file.rb} +0 -0
  8. data/lib/glimmer-dsl-opal/ext/glimmer/dsl/engine.rb +46 -0
  9. data/lib/glimmer-dsl-opal/samples/elaborate/contact_manager.rb +50 -23
  10. data/lib/glimmer-dsl-opal/samples/elaborate/login.rb +22 -5
  11. data/lib/glimmer-dsl-opal/samples/elaborate/tic_tac_toe.rb +1 -1
  12. data/lib/glimmer-dsl-opal/samples/hello/hello_browser.rb +23 -0
  13. data/lib/glimmer-dsl-opal/samples/hello/hello_computed.rb +27 -0
  14. data/lib/glimmer-dsl-opal/samples/hello/hello_computed/contact.rb +21 -0
  15. data/lib/glimmer-dsl-opal/samples/hello/hello_list_multi_selection.rb +62 -32
  16. data/lib/glimmer-dsl-opal/samples/hello/hello_list_single_selection.rb +47 -22
  17. data/lib/glimmer-dsl-opal/samples/hello/hello_menu_bar.rb +241 -0
  18. data/lib/glimmer-dsl-opal/samples/hello/hello_message_box.rb +37 -0
  19. data/lib/glimmer-dsl-opal/samples/hello/hello_pop_up_context_menu.rb +84 -0
  20. data/lib/glimmer-dsl-opal/samples/hello/hello_world.rb +3 -3
  21. data/lib/glimmer/config/opal_logger.rb +16 -0
  22. data/lib/glimmer/data_binding/observable_element.rb +1 -1
  23. data/lib/glimmer/dsl/opal/custom_widget_expression.rb +2 -1
  24. data/lib/glimmer/dsl/opal/dsl.rb +2 -0
  25. data/lib/glimmer/dsl/opal/menu_bar_expression.rb +54 -0
  26. data/lib/glimmer/dsl/opal/menu_expression.rb +61 -0
  27. data/lib/glimmer/dsl/opal/shell_expression.rb +0 -4
  28. data/lib/glimmer/dsl/opal/widget_expression.rb +3 -2
  29. data/lib/glimmer/dsl/opal/widget_listener_expression.rb +2 -2
  30. data/lib/glimmer/swt/custom/checkbox_group.rb +2 -2
  31. data/lib/glimmer/swt/custom/radio_group.rb +2 -2
  32. data/lib/glimmer/swt/display_proxy.rb +4 -4
  33. data/lib/glimmer/swt/event_listener_proxy.rb +14 -4
  34. data/lib/glimmer/swt/grid_layout_proxy.rb +14 -4
  35. data/lib/glimmer/swt/label_proxy.rb +27 -3
  36. data/lib/glimmer/swt/latest_message_box_proxy.rb +42 -0
  37. data/lib/glimmer/swt/latest_shell_proxy.rb +42 -0
  38. data/lib/glimmer/swt/layout_data_proxy.rb +2 -5
  39. data/lib/glimmer/swt/list_proxy.rb +15 -0
  40. data/lib/glimmer/swt/menu_item_proxy.rb +174 -0
  41. data/lib/glimmer/swt/menu_proxy.rb +273 -0
  42. data/lib/glimmer/swt/message_box_proxy.rb +79 -63
  43. data/lib/glimmer/swt/property_owner.rb +2 -0
  44. data/lib/glimmer/swt/radio_proxy.rb +1 -1
  45. data/lib/glimmer/swt/shell_proxy.rb +34 -189
  46. data/lib/glimmer/swt/tab_folder_proxy.rb +43 -0
  47. data/lib/glimmer/swt/table_column_proxy.rb +3 -2
  48. data/lib/glimmer/swt/table_editor.rb +1 -1
  49. data/lib/glimmer/swt/table_item_proxy.rb +7 -5
  50. data/lib/glimmer/swt/table_proxy.rb +10 -0
  51. data/lib/glimmer/swt/widget_proxy.rb +325 -31
  52. data/lib/glimmer/ui/custom_shell.rb +1 -1
  53. data/lib/glimmer/ui/custom_widget.rb +3 -3
  54. data/lib/net/http.rb +21 -0
  55. metadata +25 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b7eae61c6229ea57329b4ef092da209e5fb6df422c81250cb23e9b5a389a8e48
4
- data.tar.gz: a88dc02904e056011e050f552735227a5dd9ebf2232875f934f39da7f0b117d6
3
+ metadata.gz: 159e8bd7346ef3d7e2894c0f287ed0fa96dd34a96cfad59034099df69f77ef8b
4
+ data.tar.gz: 9863d34cd1fc923975aba466215b7a22bfead7bc68c6997f46225b418ad34f28
5
5
  SHA512:
6
- metadata.gz: b7d86f37ff864394d31403aa99c4af80248e389dbbe894cf5dd615c3bae6b0b8c21e6191e7d75bc3a753c8227db1cf730ccc14feaae42395c89a62af15ee573e
7
- data.tar.gz: 5b0c73b30a581c883a45c832817eed87e9260cb236056718083a42d67f0c93af397d58e052e231503d59f2e8ada03287cde0b5c89bf35729be5889924b7ed2fb
6
+ metadata.gz: 2839f731ac510af7526979ef5dafeb42369f854fcacf12dfd27abc45525fbfd6df56fde597d615926ff1b0f9072806380dd6a6f80451740a2d94519d2616ef10
7
+ data.tar.gz: c7488ce34ce88a15a72c822d8dcfb9b7c7376b1089060e51f985209160dbce51463326efd17524069d1e9c6089c991c4029d4c74b91c7c336f39f4d583378e39
@@ -1,5 +1,40 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.9.2
4
+
5
+ - Fixed issue with opening message_box after internalizing the Document.ready? block
6
+ - Fixed issue with replacing newlines with HTML newlines in `label` and `message_box` text
7
+
8
+ ## 0.9.1
9
+
10
+ - Log errors to error stream ($stderr) instead of standard out (STDOUT)
11
+ - Fixed issue with opening shell caused by internalizing the Document.ready? block
12
+
13
+ ## 0.9.0
14
+
15
+ - Support `menu_bar`
16
+ - Hello, Menu Bar! Sample
17
+ - Remove the need to call Document.ready? before opening a Glimmer shell
18
+ - Support opening a message_box before creating a shell
19
+
20
+ ## 0.8.0
21
+
22
+ - Hello, Pop Up Context Menu! Sample
23
+ - Hello Message Box!
24
+ - Update hello list samples
25
+ - Support context menus `menu`/`menu_item` directly under a widget (using jQuery UI)
26
+ - Support generating new lines when entering `label` `text` with \n (auto-converting to <br />)
27
+ - Support generating new lines when entering `message_box` `message` with \n (auto-converting to <br />)
28
+ - Support having any widget contribute static CSS to ShellProxy
29
+ - Add Kernel#include_package shim to allow running JRuby include_package from Glimmer DSL for SWT without failing
30
+ - Add WidgetProxy#swt_widget to allow running include_package from Glimmer DSL for SWT without failing
31
+
32
+ ## 0.7.5
33
+
34
+ - Update login sample from Glimmer DSL for SWT's latest changes
35
+ - Update contact_manager sample from Glimmer DSL for SWT's latest changes
36
+ - Fixed issue regarding unavailable localStorage data when accessed by custom_widget_expression in hello_checkbox_group, hello_radio_group, and hello_custom_widget
37
+
3
38
  ## 0.7.4
4
39
 
5
40
  - Hello, Button! Sample
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 Opal 0.7.4 (Pure Ruby Web GUI)
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 Opal 0.9.2 (Pure Ruby Web GUI)
2
2
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-opal.svg)](http://badge.fury.io/rb/glimmer-dsl-opal)
3
3
  [![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4
4
 
@@ -12,55 +12,138 @@ Use in one of two ways:
12
12
 
13
13
  Glimmer DSL for Opal successfully reuses the entire [Glimmer](https://github.com/AndyObtiva/glimmer) core DSL engine in [Opal Ruby](https://opalrb.com/) inside a web browser, and as such inherits the full range of powerful Glimmer desktop [data-binding](https://github.com/AndyObtiva/glimmer#data-binding) capabilities for the web.
14
14
 
15
- #### Tic Tac Toe Sample
15
+ #### Hello, Table! Sample
16
16
 
17
- Add the following require statement to `app/assets/javascripts/application.rb` in a [Glimmer setup](#setup) Rails app:
18
-
19
- ```ruby
20
- require 'glimmer-dsl-opal/samples/elaborate/tic_tac_toe'
21
- ```
22
-
23
- Glimmer GUI code from [glimmer-dsl-opal/samples/elaborate/tic_tac_toe.rb](lib/glimmer-dsl-opal/samples/elaborate/tic_tac_toe.rb):
17
+ Glimmer GUI code from [glimmer-dsl-opal/samples/hello/hello_table.rb](lib/glimmer-dsl-opal/samples/hello/hello_table.rb):
24
18
 
25
19
  ```ruby
26
20
  # ...
27
- @shell = shell {
28
- text "Tic-Tac-Toe"
29
- minimum_size 150, 178
30
- composite {
31
- grid_layout 3, true
32
- (1..3).each { |row|
33
- (1..3).each { |column|
34
- button {
35
- layout_data :fill, :fill, true, true
36
- text bind(@tic_tac_toe_board[row, column], :sign)
37
- enabled bind(@tic_tac_toe_board[row, column], :empty)
38
- font style: :bold, height: 20
39
- on_widget_selected {
40
- @tic_tac_toe_board.mark(row, column)
41
- }
42
- }
43
- }
44
- }
45
- }
21
+ shell {
22
+ grid_layout
23
+
24
+ text 'Hello, Table!'
25
+
26
+ label {
27
+ layout_data :center, :center, true, false
28
+
29
+ text 'Baseball Playoff Schedule'
30
+ font height: 30, style: :bold
31
+ }
32
+
33
+ combo(:read_only) {
34
+ layout_data :center, :center, true, false
35
+ selection bind(BaseballGame, :playoff_type)
36
+ font height: 16
37
+ }
38
+
39
+ table(:editable) { |table_proxy|
40
+ layout_data :fill, :fill, true, true
41
+
42
+ table_column {
43
+ text 'Game Date'
44
+ width 150
45
+ sort_property :date # ensure sorting by real date value (not `game_date` string specified in items below)
46
+ editor :date_drop_down, property: :date_time
47
+ }
48
+ table_column {
49
+ text 'Game Time'
50
+ width 150
51
+ sort_property :time # ensure sorting by real time value (not `game_time` string specified in items below)
52
+ editor :time, property: :date_time
53
+ }
54
+ table_column {
55
+ text 'Ballpark'
56
+ width 180
57
+ editor :none
58
+ }
59
+ table_column {
60
+ text 'Home Team'
61
+ width 150
62
+ editor :combo, :read_only # read_only is simply an SWT style passed to combo widget
63
+ }
64
+ table_column {
65
+ text 'Away Team'
66
+ width 150
67
+ editor :combo, :read_only # read_only is simply an SWT style passed to combo widget
68
+ }
69
+ table_column {
70
+ text 'Promotion'
71
+ width 150
72
+ # default text editor is used here
46
73
  }
74
+
75
+ # Data-bind table items (rows) to a model collection property, specifying column properties ordering per nested model
76
+ items bind(BaseballGame, :schedule), column_properties(:game_date, :game_time, :ballpark, :home_team, :away_team, :promotion)
77
+
78
+ # Data-bind table selection
79
+ selection bind(BaseballGame, :selected_game)
80
+
81
+ # Default initial sort property
82
+ sort_property :date
83
+
84
+ # Sort by these additional properties after handling sort by the column the user clicked
85
+ additional_sort_properties :date, :time, :home_team, :away_team, :ballpark, :promotion
86
+ }
87
+
88
+ button {
89
+ text 'Book Selected Game'
90
+ layout_data :center, :center, true, false
91
+ font height: 16
92
+ enabled bind(BaseballGame, :selected_game)
93
+
94
+ on_widget_selected {
95
+ book_selected_game
96
+ }
97
+ }
98
+ }.open
47
99
  # ...
48
100
  ```
49
- Tic Tac Toe on the web (using the [glimmer-dsl-opal](https://rubygems.org/gems/glimmer-dsl-opal) gem):
50
101
 
51
- ![Glimmer DSL for Opal Tic Tac Toe](images/glimmer-dsl-opal-tic-tac-toe.png)
52
- ![Glimmer DSL for Opal Tic Tac Toe In Progress](images/glimmer-dsl-opal-tic-tac-toe-in-progress.png)
53
- ![Glimmer DSL for Opal Tic Tac Toe Game Over](images/glimmer-dsl-opal-tic-tac-toe-game-over.png)
102
+ **Hello, Table! originally running on the desktop (using the [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):**
54
103
 
55
- Tic Tac Toe on the desktop with the same exact code (using the [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
104
+ ![Glimmer DSL for SWT Hello Table](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-table.png)
56
105
 
57
- ![Glimmer DSL for SWT Tic Tac Toe](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-tic-tac-toe.png)
58
- ![Glimmer DSL for SWT Tic Tac Toe In Progress](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-tic-tac-toe-in-progress.png)
59
- ![Glimmer DSL for SWT Tic Tac Toe Game Over](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-tic-tac-toe-game-over.png)
106
+ **Hello, Table! (same code) running on the web via Opal on Rails (using the [glimmer-dsl-opal](https://rubygems.org/gems/glimmer-dsl-opal) gem):**
107
+
108
+ ![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table.png)
109
+
110
+ Hello, Table! Editing Game Date
111
+
112
+ ![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-editing-game-date.png)
113
+
114
+ Hello, Table! Editing Game Time
115
+
116
+ ![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-editing-game-time.png)
117
+
118
+ Hello, Table! Editing Home Team
60
119
 
61
- NOTE: **Alpha Version** 0.7.4 only supports bare-minimum capabilities for the following [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) [samples](https://github.com/AndyObtiva/glimmer#samples):
120
+ ![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-editing-home-team.png)
62
121
 
63
- Hello:
122
+ Hello, Table! Sorted Game Date Ascending
123
+
124
+ ![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-sorted-game-date-ascending.png)
125
+
126
+ Hello, Table! Sorted Game Date Descending
127
+
128
+ ![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-sorted-game-date-descending.png)
129
+
130
+ Hello, Table! Playoff Type Combo
131
+
132
+ ![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-playoff-type-combo.png)
133
+
134
+ Hello, Table! Playoff Type Changed
135
+
136
+ ![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-playoff-type-changed.png)
137
+
138
+ Hello, Table! Game Booked
139
+
140
+ ![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-game-booked.png)
141
+
142
+ NOTE: Glimmer DSL for Opal is an alpha project. Please help make better by contributing, adopting for small or low risk projects, and providing feedback. It is still an early alpha, so the more feedback and issues you report the better.
143
+
144
+ **Alpha Version** 0.9.2 only supports bare-minimum capabilities for the following [samples](https://github.com/AndyObtiva/glimmer-dsl-opal#samples) (originally written in [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt)):
145
+
146
+ [Hello samples](#hello-samples):
64
147
 
65
148
  - [Hello, World!](#hello-world)
66
149
  - [Hello, Combo!](#hello-combo)
@@ -79,8 +162,11 @@ Hello:
79
162
  - [Hello, Date Time!](#hello-date-time)
80
163
  - [Hello, Table!](#hello-table)
81
164
  - [Hello, Button!](#hello-button)
165
+ - [Hello, Message Box!](#hello-message-box)
166
+ - [Hello, Pop Up Context Menu!](#hello-pop-up-context-menu)
167
+ - [Hello, Menu Bar!](#hello-menu-bar)
82
168
 
83
- Elaborate:
169
+ [Elaborate samples](#elaborate-samples):
84
170
 
85
171
  - [Login](#login)
86
172
  - [Tic Tac Toe](#tic-tac-toe)
@@ -101,40 +187,68 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
101
187
  The following keywords from [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) have partial support in Opal:
102
188
 
103
189
  Widgets:
104
- - `shell`
105
- - `label`
106
- - `combo`
107
- - `button`
108
- - `text`
109
- - `composite`
110
- - `list` & `list(:multi)`
111
- - `tab_folder`
112
- - `tab_item`
113
- - `table`
114
- - `table_column`
115
- - `message_box`
116
- - Glimmer::UI::CustomWidget: ability to define any keyword as a custom widget
117
- - Glimmer::UI::CustomShell: ability to define any keyword as a custom shell (aka custom window) that opens in a new browser window (tab) automatically unless there is no shell open in the current browser window (tab)
190
+ - `button`: featured in [Hello, Checkbox!](#hello-checkbox) / [Hello, Button!](#hello-button) / [Hello, Table!](#hello-table) / [Hello, Radio Group!](#hello-radio-group) / [Hello, Radio!](#hello-radio) / [Hello, Message Box!](#hello-message-box) / [Hello, List Single Selection!](#hello-list-single-selection) / [Hello, List Multi Selection!](#hello-list-multi-selection) / [Hello, Group!](#hello-group) / [Hello, Combo!](#hello-combo) / [Hello, Checkbox Group!](#hello-checkbox-group) / [Contact Manager](#contact-manager) / [Tic Tac Toe](#tic-tac-toe) / [Login](#login)
191
+ - `browser`: featured in [Hello, Browser!](#hello-browser)
192
+ - `calendar`: featured in [Hello, Date Time!](#hello-date-time)
193
+ - `checkbox`: featured in [Hello, Checkbox Group!](#hello-checkbox-group) / [Hello, Checkbox!](#hello-checkbox)
194
+ - `checkbox_group`: featured in [Hello, Checkbox Group!](#hello-checkbox-group)
195
+ - `combo`: featured in [Hello, Table!](#hello-table) / [Hello, Combo!](#hello-combo)
196
+ - `composite`: featured in [Hello, Radio!](#hello-radio) / [Hello, Computed!](#hello-computed) / [Hello, Checkbox!](#hello-checkbox) / [Tic Tac Toe](#tic-tac-toe) / [Login](#login) / [Contact Manager](#contact-manager)
197
+ - `date`: featured in [Hello, Table!](#hello-table) / [Hello, Date Time!](#hello-date-time) / [Hello, Custom Shell!](#hello-custom-shell) / [Tic Tac Toe](#tic-tac-toe)
198
+ - `date_drop_down`: featured in [Hello, Table!](#hello-table) / [Hello, Date Time!](#hello-date-time)
199
+ - `group`: featured in [Hello, Group!](#hello-group) / [Contact Manager](#contact-manager)
200
+ - `label`: featured in [Hello, Computed!](#hello-computed) / [Hello, Checkbox Group!](#hello-checkbox-group) / [Hello, Checkbox!](#hello-checkbox) / [Hello, World!](#hello-world) / [Hello, Table!](#hello-table) / [Hello, Tab!](#hello-tab) / [Hello, Radio Group!](#hello-radio-group) / [Hello, Radio!](#hello-radio) / [Hello, Pop Up Context Menu!](#hello-pop-up-context-menu) / [Hello, Menu Bar!](#hello-menu-bar) / [Hello, Date Time!](#hello-date-time) / [Hello, Custom Widget!](#hello-custom-widget) / [Hello, Custom Shell!](#hello-custom-shell) / [Contact Manager](#contact-manager) / [Login](#login)
201
+ - `list` (w/ optional `:multi` SWT style): featured in [Hello, List Single Selection!](#hello-list-single-selection) / [Hello, List Multi Selection!](#hello-list-multi-selection) / [Contact Manager](#contact-manager)
202
+ - `menu`: featured in [Hello, Menu Bar!](#hello-menu-bar) / [Hello, Pop Up Context Menu!](#hello-pop-up-context-menu) / [Hello, Table!](#hello-table)
203
+ - `menu_bar`: featured in [Hello, Menu Bar!](#hello-menu-bar)
204
+ - `menu_item`: featured in [Hello, Table!](#hello-table) / [Hello, Pop Up Context Menu!](#hello-pop-up-context-menu) / [Hello, Menu Bar!](#hello-menu-bar)
205
+ - `message_box`: featured in [Hello, Table!](#hello-table) / [Hello, Pop Up Context Menu!](#hello-pop-up-context-menu) / [Hello, Message Box!](#hello-message-box) / [Hello, Menu Bar!](#hello-menu-bar)
206
+ - `radio`: featured in [Hello, Radio!](#hello-radio) / [Hello, Group!](#hello-group)
207
+ - `radio_group`: featured in [Hello, Radio Group!](#hello-radio-group)
208
+ - `scrolled_composite`
209
+ - `shell`: featured in [Hello, Checkbox!](#hello-checkbox) / [Hello, Button!](#hello-button) / [Hello, Table!](#hello-table) / [Hello, Tab!](#hello-tab) / [Hello, Radio Group!](#hello-radio-group) / [Hello, Radio!](#hello-radio) / [Hello, List Single Selection!](#hello-list-single-selection) / [Hello, List Multi Selection!](#hello-list-multi-selection) / [Hello, Group!](#hello-group) / [Hello, Date Time!](#hello-date-time) / [Hello, Custom Shell!](#hello-custom-shell) / [Hello, Computed!](#hello-computed) / [Hello, Combo!](#hello-combo) / [Hello, Checkbox Group!](#hello-checkbox-group) / [Contact Manager](#contact-manager) / [Tic Tac Toe](#tic-tac-toe) / [Login](#login)
210
+ - `tab_folder`: featured in [Hello, Tab!](#hello-tab)
211
+ - `tab_item`: featured in [Hello, Tab!](#hello-tab)
212
+ - `table`: featured in [Hello, Custom Shell!](#hello-custom-shell) / [Hello, Table!](#hello-table) / [Contact Manager](#contact-manager)
213
+ - `table_column`: featured in [Hello, Table!](#hello-table) / [Hello, Custom Shell!](#hello-custom-shell) / [Contact Manager](#contact-manager)
214
+ - `text`: featured in [Hello, Computed!](#hello-computed) / [Login](#login) / [Contact Manager](#contact-manager)
215
+ - `time`: featured in [Hello, Table!](#hello-table) / [Hello, Date Time!](#hello-date-time)
216
+ - Glimmer::UI::CustomWidget: ability to define any keyword as a custom widget - featured in [Hello, Custom Widget!](#hello-custom-widget)
217
+ - Glimmer::UI::CustomShell: ability to define any keyword as a custom shell (aka custom window) that opens in a new browser window (tab) automatically unless there is no shell open in the current browser window (tab) - featured in [Hello, Custom Shell!](#hello-custom-shell)
118
218
 
119
219
  Layouts:
120
- - `grid_layout`
121
- - `row_layout`
122
- - `fill_layout`
123
- - `layout_data`
220
+ - `grid_layout`: featured in [Hello, Custom Shell!](#hello-custom-shell) / [Hello, Computed!](#hello-computed) / [Hello, Table!](#hello-table) / [Hello, Pop Up Context Menu!](#hello-pop-up-context-menu) / [Hello, Menu Bar!](#hello-menu-bar) / [Hello, List Single Selection!](#hello-list-single-selection) / [Hello, List Multi Selection!](#hello-list-multi-selection) / [Contact Manager](#contact-manager) / [Login](#login) / [Tic Tac Toe](#tic-tac-toe)
221
+ - `row_layout`: featured in [Hello, Radio Group!](#hello-radio-group) / [Hello, Radio!](#hello-radio) / [Hello, Group!](#hello-group) / [Hello, Date Time!](#hello-date-time) / [Hello, Combo!](#hello-combo) / [Hello, Checkbox Group!](#hello-checkbox-group) / [Hello, Checkbox!](#hello-checkbox) / [Contact Manager](#contact-manager)
222
+ - `fill_layout`: featured in [Hello, Custom Widget!](#hello-custom-widget)
223
+ - `layout_data`: featured in [Hello, Table!](#hello-table) / [Hello, Custom Shell!](#hello-custom-shell) / [Hello, Computed!](#hello-computed) / [Tic Tac Toe](#tic-tac-toe) / [Contact Manager](#contact-manager)
124
224
 
125
- Graphics:
126
- - `color`
127
- - `font`
225
+ Graphics/Style:
226
+ - `color`: featured in [Hello, Custom Widget!](#hello-custom-widget) / [Hello, Menu Bar!](#hello-menu-bar)
227
+ - `font`: featured in [Hello, Checkbox Group!](#hello-checkbox-group) / [Hello, Checkbox!](#hello-checkbox) / [Hello, Table!](#hello-table) / [Hello, Radio Group!](#hello-radio-group) / [Hello, Radio!](#hello-radio) / [Hello, Pop Up Context Menu!](#hello-pop-up-context-menu) / [Hello, Menu Bar!](#hello-menu-bar) / [Hello, Group!](#hello-group) / [Hello, Date Time!](#hello-date-time) / [Hello, Custom Widget!](#hello-custom-widget) / [Hello, Custom Shell!](#hello-custom-shell) / [Contact Manager](#contact-manager) / [Tic Tac Toe](#tic-tac-toe)
228
+ - `Point` class used in setting location on widgets
229
+ - `swt` and `SWT` class to set SWT styles on widgets - featured in [Hello, Custom Shell!](#hello-custom-shell) / [Login](#login) / [Contact Manager](#contact-manager)
128
230
 
129
231
  Data-Binding/Observers:
130
- - `bind`
131
- - `observe`
132
- - `on_widget_selected`
232
+ - `bind`: featured in [Hello, Computed!](#hello-computed) / [Hello, Combo!](#hello-combo) / [Hello, Checkbox Group!](#hello-checkbox-group) / [Hello, Checkbox!](#hello-checkbox) / [Hello, Button!](#hello-button) / [Hello, Table!](#hello-table) / [Hello, Radio Group!](#hello-radio-group) / [Hello, Radio!](#hello-radio) / [Hello, List Single Selection!](#hello-list-single-selection) / [Hello, List Multi Selection!](#hello-list-multi-selection) / [Hello, Group!](#hello-group) / [Hello, Date Time!](#hello-date-time) / [Hello, Custom Widget!](#hello-custom-widget) / [Hello, Custom Shell!](#hello-custom-shell) / [Login](#login) / [Contact Manager](#contact-manager) / [Tic Tac Toe](#tic-tac-toe)
233
+ - `observe`: featured in [Hello, Table!](#hello-table) / [Tic Tac Toe](#tic-tac-toe)
234
+ - `on_widget_selected`: featured in [Hello, Combo!](#hello-combo) / [Hello, Checkbox Group!](#hello-checkbox-group) / [Hello, Checkbox!](#hello-checkbox) / [Hello, Button!](#hello-button) / [Hello, Table!](#hello-table) / [Hello, Radio Group!](#hello-radio-group) / [Hello, Radio!](#hello-radio) / [Hello, Pop Up Context Menu!](#hello-pop-up-context-menu) / [Hello, Message Box!](#hello-message-box) / [Hello, Menu Bar!](#hello-menu-bar) / [Hello, List Single Selection!](#hello-list-single-selection) / [Hello, List Multi Selection!](#hello-list-multi-selection) / [Hello, Group!](#hello-group) / [Contact Manager](#contact-manager) / [Login](#login) / [Tic Tac Toe](#tic-tac-toe)
133
235
  - `on_modify_text`
236
+ - `on_key_pressed` (and SWT alias `on_swt_keydown`) - featured in [Login](#login) / [Contact Manager](#contact-manager)
237
+ - `on_key_released` (and SWT alias `on_swt_keyup`)
238
+ - `on_mouse_down` (and SWT alias `on_swt_mousedown`)
239
+ - `on_mouse_up` (and SWT alias `on_swt_mouseup`) - featured in [Hello, Custom Shell!](#hello-custom-shell) / [Contact Manager](#contact-manager)
134
240
 
135
241
  Event loop:
136
- - `display`
137
- - `async_exec`
242
+ - `display`: featured in [Tic Tac Toe](#tic-tac-toe)
243
+ - `async_exec`: featured in [Hello, Custom Widget!](#hello-custom-widget) / [Hello, Custom Shell!](#hello-custom-shell)
244
+
245
+ ## Principles
246
+
247
+ - **Live purely in Rubyland via the Glimmer GUI DSL**, completely oblivious to web browser technologies.
248
+ - **Forget Routers!** Glimmer DSL for Opal supports auto-routing of custom shells (windows), which are opened as separate tabs in a web browser with automatically generated routes and bookmarkable URLs.
249
+ - **HTML is strictly made for creating documents not interactive applications**. As such, software engineers can avoid it and focus on creating web applications more productively with Glimmer DSL for Opal in pure Ruby instead (just like they do in desktop development) while content creators and web designers can be the ones responsible for creating HTML documents for web content purposes only as HTML was originally intended. That way, Glimmer web GUI is used and embedded in web pages when providing users with applications while the rest of the web pages are maintained by non-engineers as pure HTML. This achieves a correct separation of responsibilities and better productivity and maintainability.
250
+ - **Approximate styles by developers via the Glimmer GUI DSL. Perfect styles by designers via pure CSS**. Developers can simply build GUI with approximate styling similar to desktop GUI without worrying about pixel-perfect aethetics. Web designers can take styling further with pure CSS since every HTML element auto-generated by Glimmer DSL for Opal has a predictable ID and CSS class. This achieves a proper separation of responsibilities between developers and designers.
251
+ - **Web servers are used just like servers in traditional client/server architecture**, meaning they simply provide RMI services to enable centralizing some of the application logic and data in the cloud to make available everywhere and enable data-sharing with others.
138
252
 
139
253
  ## Background
140
254
 
@@ -146,12 +260,6 @@ Last but not least, you would likely want some special branding on the web, so y
146
260
 
147
261
  Alternatively, web developers may directly use [Glimmer DSL for Opal](https://rubygems.org/gems/glimmer-dsl-opal) to build the GUI of web apps since it is as simple as desktop development, thus requiring a lot less code that is in pure Ruby only (as demonstrated in examples below) and avoiding opaque web concepts like 'render' and 'reactive' due to treating GUI as persistent just like desktop apps do. No HTML/JS/CSS skills are even required. Still, web designers may be involved with CSS only if needed, thanks to the clean semantic markup [Glimmer DSL for Opal](https://rubygems.org/gems/glimmer-dsl-opal) automatically produces.
148
262
 
149
- ## Principles
150
-
151
- - Live purely in Rubyland via the Glimmer GUI DSL, completely oblivious to web browser technologies.
152
- - Forget Routers! Glimmer DSL for Opal supports auto-routing of custom shells (windows), which are opened as separate tabs in a web browser with automatically generated routes and bookmarkable URLs.
153
- - HTML is strictly made for creating documents not interactive applications. As such, software engineers can avoid and focus on creating web applications with Glimmer DSL for Opal in pure Ruby while content creators and web designers are the ones responsible for creating HTML documents for content purposes only as HTML was originally intended. As such, Glimmer web GUI built by software engineers gets embedded in the body of a web page with content around it maintained by content creators and web designers. This achieves a correct separation of responsibilities and better maintainability.
154
-
155
263
  ## Pre-requisites
156
264
 
157
265
  - Rails 5: [https://github.com/rails/rails/tree/5-2-stable](https://github.com/rails/rails/tree/5-2-stable)
@@ -186,7 +294,7 @@ Add the following to `Gemfile`:
186
294
  gem 'opal-rails', '~> 1.1.2'
187
295
  gem 'opal-async', '~> 1.2.0'
188
296
  gem 'opal-jquery', '~> 0.4.4'
189
- gem 'glimmer-dsl-opal', '~> 0.7.4'
297
+ gem 'glimmer-dsl-opal', '~> 0.9.2'
190
298
  gem 'glimmer-dsl-xml', '~> 1.1.0', require: false
191
299
  gem 'glimmer-dsl-css', '~> 1.1.0', require: false
192
300
 
@@ -211,12 +319,6 @@ Modify `config/routes.rb`:
211
319
  root to: 'welcomes#index'
212
320
  ```
213
321
 
214
- Add the following line to the top of an empty `app/assets/javascripts/application.rb` (replacing `application.js`)
215
-
216
- ```ruby
217
- require 'glimmer-dsl-opal' # brings opal and other dependencies automatically
218
- ```
219
-
220
322
  Edit `app/views/layouts/application.html.erb` and add the following below other `stylesheet_link_tag` declarations:
221
323
 
222
324
  ```erb
@@ -225,41 +327,49 @@ Edit `app/views/layouts/application.html.erb` and add the following below other
225
327
 
226
328
  Clear the file `app/views/welcomes/index.html.erb` from any content.
227
329
 
228
- Open `app/assets/javascripts/application.rb`, add a `Document.ready?` block, and add inside it Glimmer GUI DSL code or a require statement for one of the samples below.
330
+ Add the following line to the top of an empty `app/assets/javascripts/application.rb` (replacing `application.js`), and add Glimmer GUI DSL code or a require statement for one of the samples below.
229
331
 
230
332
  ```ruby
231
- Document.ready? do
232
- # require-statement/code goes here.
233
- end
333
+ require 'glimmer-dsl-opal' # brings opal and other dependencies automatically
334
+
335
+ # require-statement/code goes here.
234
336
  ```
235
337
 
236
338
  Example to confirm setup is working:
237
339
 
238
340
  ```ruby
239
- Document.ready? do
240
- include Glimmer
241
-
242
- shell {
243
- fill_layout
244
- text 'Example to confirm setup is working'
245
- label {
246
- text "Welcome to Glimmer DSL for Opal!"
247
- foreground :red
248
- font height: 24
249
- }
250
- }.open
251
- end
341
+ require 'glimmer-dsl-opal'
342
+
343
+ include Glimmer
344
+
345
+ shell {
346
+ fill_layout
347
+ text 'Example to confirm setup is working'
348
+ label {
349
+ text "Welcome to Glimmer DSL for Opal!"
350
+ foreground :red
351
+ font height: 24
352
+ }
353
+ }.open
252
354
  ```
253
355
 
254
356
  ## Samples
255
357
 
256
358
  Follow the instructions below to try out [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) samples webified via [glimmer-dsl-opal](https://rubygems.org/gems/glimmer-dsl-opal)
257
359
 
258
- Also, this external sample app contains all the samples mentioned below configured inside a Rails 5 [Opal](https://opalrb.com/) app with all the pre-requisites ready to go for convenience:
360
+ The [Hello samples](#hello-samples) demonstrate tiny building blocks (widgets) for building full fledged applications.
361
+
362
+ The [Elaborate samples](#elaborate-samples) demonstrate more advanced sample applications that assemble multiple building blocks.
363
+
364
+ This external sample app contains all the samples mentioned below configured inside a Rails [Opal](https://opalrb.com/) app with all the pre-requisites ready to go for convenience:
365
+
366
+ [https://github.com/AndyObtiva/sample-glimmer-dsl-opal-rails-app](https://github.com/AndyObtiva/sample-glimmer-dsl-opal-rails-app)
259
367
 
260
- [https://github.com/AndyObtiva/sample-glimmer-dsl-opal-rails5-app](https://github.com/AndyObtiva/sample-glimmer-dsl-opal-rails5-app)
368
+ You may visit a Heroku hosted version at:
261
369
 
262
- Some of the screenshots might be out of date with updates done to samples in both [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) and [glimmer-dsl-opal](https://github.com/AndyObtiva/glimmer-dsl-opal).
370
+ https://sample-glimmer-dsl-opal-app.herokuapp.com/
371
+
372
+ Note: Some of the screenshots might be out of date with updates done to samples in both [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) and [glimmer-dsl-opal](https://github.com/AndyObtiva/glimmer-dsl-opal).
263
373
 
264
374
  ### Hello Samples
265
375
 
@@ -566,44 +676,53 @@ require 'glimmer-dsl-opal/samples/hello/hello_list_multi_selection'
566
676
  Or add the Glimmer code directly if you prefer to play around with it:
567
677
 
568
678
  ```ruby
569
- class Person
570
- attr_accessor :provinces, :provinces_options
571
-
572
- def initialize
573
- self.provinces_options=[
574
- "",
575
- "Quebec",
576
- "Ontario",
577
- "Manitoba",
578
- "Saskatchewan",
579
- "Alberta",
580
- "British Columbia",
581
- "Nova Skotia",
582
- "Newfoundland"
583
- ]
584
- self.provinces = ["Quebec", "Manitoba", "Alberta"]
585
- end
586
-
587
- def reset_provinces
588
- self.provinces = ["Quebec", "Manitoba", "Alberta"]
589
- end
590
- end
591
-
592
679
  class HelloListMultiSelection
680
+ class Person
681
+ attr_accessor :provinces, :provinces_options
682
+
683
+ def initialize
684
+ self.provinces_options = [
685
+ '',
686
+ 'Alberta',
687
+ 'British Columbia',
688
+ 'Manitoba',
689
+ 'New Brunswick',
690
+ 'Newfoundland and Labrador',
691
+ 'Northwest Territories',
692
+ 'Nova Scotia',
693
+ 'Nunavut',
694
+ 'Ontario',
695
+ 'Prince Edward Island',
696
+ 'Quebec',
697
+ 'Saskatchewan',
698
+ 'Yukon'
699
+ ]
700
+ reset_provinces
701
+ end
702
+
703
+ def reset_provinces
704
+ self.provinces = ['Quebec', 'Manitoba', 'Alberta']
705
+ end
706
+ end
707
+
593
708
  include Glimmer
709
+
594
710
  def launch
595
711
  person = Person.new
712
+
596
713
  shell {
597
- composite {
598
- list(:multi) {
599
- selection bind(person, :provinces)
600
- }
601
- button {
602
- text "Reset"
603
- on_widget_selected do
604
- person.reset_provinces
605
- end
606
- }
714
+ grid_layout
715
+
716
+ text 'Hello, List Multi Selection!'
717
+
718
+ list(:multi) {
719
+ selection bind(person, :provinces)
720
+ }
721
+
722
+ button {
723
+ text 'Reset Selections To Default Values'
724
+
725
+ on_widget_selected { person.reset_provinces }
607
726
  }
608
727
  }.open
609
728
  end
@@ -1954,6 +2073,450 @@ You should see "Hello, Button!"
1954
2073
  ![Glimmer DSL for Opal Hello Button](images/glimmer-dsl-opal-hello-button.png)
1955
2074
  ![Glimmer DSL for Opal Hello Button](images/glimmer-dsl-opal-hello-button-incremented.png)
1956
2075
 
2076
+ #### Hello, Message Box!
2077
+
2078
+ Add the following require statement to `app/assets/javascripts/application.rb`
2079
+
2080
+ ```ruby
2081
+ require 'glimmer-dsl-opal/samples/hello/hello_message_box'
2082
+ ```
2083
+
2084
+ Or add the Glimmer code directly if you prefer to play around with it:
2085
+
2086
+ ```ruby
2087
+ include Glimmer
2088
+
2089
+ shell {
2090
+ text 'Hello, Message Box!'
2091
+
2092
+ button {
2093
+ text 'Please Click To Win a Surprise'
2094
+
2095
+ on_widget_selected {
2096
+ message_box {
2097
+ text 'Surprise'
2098
+ message "Congratulations!\n\nYou won $1,000,000!"
2099
+ }.open
2100
+ }
2101
+ }
2102
+ }.open
2103
+ ```
2104
+
2105
+ Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
2106
+
2107
+ ![Glimmer DSL for SWT Message Box](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-message-box.png)
2108
+ ![Glimmer DSL for SWT Message Box Dialog](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-message-box-dialog.png)
2109
+
2110
+ Glimmer app on the web (using `glimmer-dsl-opal` gem):
2111
+
2112
+ Start the Rails server:
2113
+ ```
2114
+ rails s
2115
+ ```
2116
+
2117
+ Visit `http://localhost:3000`
2118
+
2119
+ You should see "Hello, Message Box!"
2120
+
2121
+ ![Glimmer DSL for Opal Hello Message Box](images/glimmer-dsl-opal-hello-message-box.png)
2122
+ ![Glimmer DSL for Opal Hello Message Box Dialog](images/glimmer-dsl-opal-hello-message-box-dialog.png)
2123
+
2124
+ #### Hello, Pop Up Context Menu!
2125
+
2126
+ Add the following require statement to `app/assets/javascripts/application.rb`
2127
+
2128
+ ```ruby
2129
+ require 'glimmer-dsl-opal/samples/hello/hello_pop_up_context_menu'
2130
+ ```
2131
+
2132
+ Or add the Glimmer code directly if you prefer to play around with it:
2133
+
2134
+ ```ruby
2135
+ include Glimmer
2136
+
2137
+ shell {
2138
+ grid_layout {
2139
+ margin_width 0
2140
+ margin_height 0
2141
+ }
2142
+
2143
+ text 'Hello, Pop Up Context Menu!'
2144
+
2145
+ label {
2146
+ text "Right-Click on the Text to\nPop Up a Context Menu"
2147
+ font height: 50
2148
+
2149
+ menu {
2150
+ menu {
2151
+ text '&History'
2152
+ menu {
2153
+ text '&Recent'
2154
+ menu_item {
2155
+ text 'File 1'
2156
+ on_widget_selected {
2157
+ message_box {
2158
+ text 'File 1'
2159
+ message 'File 1 Contents'
2160
+ }.open
2161
+ }
2162
+ }
2163
+ menu_item {
2164
+ text 'File 2'
2165
+ on_widget_selected {
2166
+ message_box {
2167
+ text 'File 2'
2168
+ message 'File 2 Contents'
2169
+ }.open
2170
+ }
2171
+ }
2172
+ }
2173
+ menu {
2174
+ text '&Archived'
2175
+ menu_item {
2176
+ text 'File 3'
2177
+ on_widget_selected {
2178
+ message_box {
2179
+ text 'File 3'
2180
+ message 'File 3 Contents'
2181
+ }.open
2182
+ }
2183
+ }
2184
+ menu_item {
2185
+ text 'File 4'
2186
+ on_widget_selected {
2187
+ message_box {
2188
+ text 'File 4'
2189
+ message 'File 4 Contents'
2190
+ }.open
2191
+ }
2192
+ }
2193
+ }
2194
+ }
2195
+ }
2196
+ }
2197
+ }.open
2198
+ ```
2199
+
2200
+ Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
2201
+
2202
+ ![Glimmer DSL for SWT Hello Pop Up Context Menu Popped Up](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-pop-up-context-menu.png)
2203
+ ![Glimmer DSL for SWT Hello Pop Up Context Menu](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-pop-up-context-menu-popped-up.png)
2204
+
2205
+ Glimmer app on the web (using `glimmer-dsl-opal` gem):
2206
+
2207
+ Start the Rails server:
2208
+ ```
2209
+ rails s
2210
+ ```
2211
+
2212
+ Visit `http://localhost:3000`
2213
+
2214
+ You should see "Hello, Pop Up Context Menu!"
2215
+
2216
+ ![Glimmer DSL for Opal Hello Pop Up Context Menu](images/glimmer-dsl-opal-hello-pop-up-context-menu.png)
2217
+ ![Glimmer DSL for Opal Hello Pop Up Context Menu Popped Up](images/glimmer-dsl-opal-hello-pop-up-context-menu-popped-up.png)
2218
+
2219
+ #### Hello, Menu Bar!
2220
+
2221
+ This sample demonstrates a menu bar similar to the File menu bar you see at the top of desktop applications.
2222
+
2223
+ In web applications, it is typically used to provide website information architecture by denoting things like Products, News, Careers, and About.
2224
+
2225
+ In web applications, it is also typically styled by CSS with margin/padding around every menu, distancing it from the top.
2226
+
2227
+ When auto-webifying a pre-existing desktop application, the menu bar can be hidden with CSS if not needed, or simply shown on hover only. Web designers could decide these things to their heart's content with pure CSS independently of the developers' code.
2228
+
2229
+ Add the following require statement to `app/assets/javascripts/application.rb`
2230
+
2231
+ ```ruby
2232
+ require 'glimmer-dsl-opal/samples/hello/hello_menu_bar'
2233
+ ```
2234
+
2235
+ Or add the Glimmer code directly if you prefer to play around with it:
2236
+
2237
+ ```ruby
2238
+ include Glimmer
2239
+
2240
+ COLORS = [:white, :red, :yellow, :green, :blue, :magenta, :gray, :black]
2241
+
2242
+ shell {
2243
+ grid_layout {
2244
+ margin_width 0
2245
+ margin_height 0
2246
+ }
2247
+
2248
+ text 'Hello, Menu Bar!'
2249
+
2250
+ @label = label(:center) {
2251
+ font height: 50
2252
+ text 'Check Out The Menu Bar Above!'
2253
+ }
2254
+
2255
+ menu_bar {
2256
+ menu {
2257
+ text '&File'
2258
+ menu_item {
2259
+ text '&New'
2260
+ accelerator :command, :N
2261
+
2262
+ on_widget_selected {
2263
+ message_box {
2264
+ text 'New'
2265
+ message 'New file created.'
2266
+ }.open
2267
+ }
2268
+ }
2269
+ menu_item {
2270
+ text '&Open...'
2271
+ accelerator :command, :O
2272
+
2273
+ on_widget_selected {
2274
+ message_box {
2275
+ text 'Open'
2276
+ message 'Opening File...'
2277
+ }.open
2278
+ }
2279
+ }
2280
+ menu {
2281
+ text 'Open &Recent'
2282
+ menu_item {
2283
+ text 'File 1'
2284
+ on_widget_selected {
2285
+ message_box {
2286
+ text 'File 1'
2287
+ message 'File 1 Contents'
2288
+ }.open
2289
+ }
2290
+ }
2291
+ menu_item {
2292
+ text 'File 2'
2293
+ on_widget_selected {
2294
+ message_box {
2295
+ text 'File 2'
2296
+ message 'File 2 Contents'
2297
+ }.open
2298
+ }
2299
+ }
2300
+ }
2301
+ menu_item(:separator)
2302
+ menu_item {
2303
+ text 'E&xit'
2304
+
2305
+ on_widget_selected {
2306
+ exit(0)
2307
+ }
2308
+ }
2309
+ }
2310
+ menu {
2311
+ text '&Edit'
2312
+ menu_item {
2313
+ text 'Cut'
2314
+ accelerator :command, :X
2315
+ }
2316
+ menu_item {
2317
+ text 'Copy'
2318
+ accelerator :command, :C
2319
+ }
2320
+ menu_item {
2321
+ text 'Paste'
2322
+ accelerator :command, :V
2323
+ }
2324
+ }
2325
+ menu {
2326
+ text '&Options'
2327
+
2328
+ menu_item(:radio) {
2329
+ text '&Enabled'
2330
+
2331
+ on_widget_selected {
2332
+ @select_one_menu.enabled = true
2333
+ @select_multiple_menu.enabled = true
2334
+ }
2335
+ }
2336
+ @select_one_menu = menu {
2337
+ text '&Select One'
2338
+ enabled false
2339
+
2340
+ menu_item(:radio) {
2341
+ text 'Option 1'
2342
+ }
2343
+ menu_item(:radio) {
2344
+ text 'Option 2'
2345
+ }
2346
+ menu_item(:radio) {
2347
+ text 'Option 3'
2348
+ }
2349
+ }
2350
+ @select_multiple_menu = menu {
2351
+ text '&Select Multiple'
2352
+ enabled false
2353
+
2354
+ menu_item(:check) {
2355
+ text 'Option 4'
2356
+ }
2357
+ menu_item(:check) {
2358
+ text 'Option 5'
2359
+ }
2360
+ menu_item(:check) {
2361
+ text 'Option 6'
2362
+ }
2363
+ }
2364
+ }
2365
+ menu {
2366
+ text '&Format'
2367
+ menu {
2368
+ text '&Background Color'
2369
+ COLORS.each { |color_style|
2370
+ menu_item(:radio) {
2371
+ text color_style.to_s.split('_').map(&:capitalize).join(' ')
2372
+
2373
+ on_widget_selected {
2374
+ @label.background = color_style
2375
+ }
2376
+ }
2377
+ }
2378
+ }
2379
+ menu {
2380
+ text 'Foreground &Color'
2381
+ COLORS.each { |color_style|
2382
+ menu_item(:radio) {
2383
+ text color_style.to_s.split('_').map(&:capitalize).join(' ')
2384
+
2385
+ on_widget_selected {
2386
+ @label.foreground = color_style
2387
+ }
2388
+ }
2389
+ }
2390
+ }
2391
+ }
2392
+ menu {
2393
+ text '&View'
2394
+ menu_item(:radio) {
2395
+ text 'Small'
2396
+
2397
+ on_widget_selected {
2398
+ @label.font = {height: 25}
2399
+ @label.parent.pack
2400
+ }
2401
+ }
2402
+ menu_item(:radio) {
2403
+ text 'Medium'
2404
+ selection true
2405
+
2406
+ on_widget_selected {
2407
+ @label.font = {height: 50}
2408
+ @label.parent.pack
2409
+ }
2410
+ }
2411
+ menu_item(:radio) {
2412
+ text 'Large'
2413
+
2414
+ on_widget_selected {
2415
+ @label.font = {height: 75}
2416
+ @label.parent.pack
2417
+ }
2418
+ }
2419
+ }
2420
+ menu {
2421
+ text '&Help'
2422
+ menu_item {
2423
+ text '&Manual'
2424
+ accelerator :command, :shift, :M
2425
+
2426
+ on_widget_selected {
2427
+ message_box {
2428
+ text 'Manual'
2429
+ message 'Manual Contents'
2430
+ }.open
2431
+ }
2432
+ }
2433
+ menu_item {
2434
+ text '&Tutorial'
2435
+ accelerator :command, :shift, :T
2436
+
2437
+ on_widget_selected {
2438
+ message_box {
2439
+ text 'Tutorial'
2440
+ message 'Tutorial Contents'
2441
+ }.open
2442
+ }
2443
+ }
2444
+ menu_item(:separator)
2445
+ menu_item {
2446
+ text '&Report an Issue...'
2447
+
2448
+ on_widget_selected {
2449
+ message_box {
2450
+ text 'Report an Issue'
2451
+ message 'Reporting an issue...'
2452
+ }.open
2453
+ }
2454
+ }
2455
+ }
2456
+ }
2457
+ }.open
2458
+ ```
2459
+
2460
+ Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
2461
+
2462
+ ![Hello Menu Bar](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar.png)
2463
+
2464
+ ![Hello Menu Bar File Menu](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar-file-menu.png)
2465
+
2466
+ ![Hello Menu Bar Edit Menu](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar-edit-menu.png)
2467
+
2468
+ ![Hello Menu Bar Options Menu Disabled](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar-options-menu-disabled.png)
2469
+
2470
+ ![Hello Menu Bar Options Menu Select One](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar-options-menu-select-one.png)
2471
+
2472
+ ![Hello Menu Bar Options Menu Select Multiple](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar-options-menu-select-multiple.png)
2473
+
2474
+ ![Hello Menu Bar Format Menu Background Color](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar-format-menu-background-color.png)
2475
+
2476
+ ![Hello Menu Bar Format Menu Foreground Color](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar-format-menu-foreground-color.png)
2477
+
2478
+ ![Hello Menu Bar View Menu](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar-view-menu.png)
2479
+
2480
+ ![Hello Menu Bar View Small](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar-view-small.png)
2481
+
2482
+ ![Hello Menu Bar View Large](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar-view-large.png)
2483
+
2484
+ ![Hello Menu Bar Help Menu](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar-help-menu.png)
2485
+
2486
+ Glimmer app on the web (using `glimmer-dsl-opal` gem):
2487
+
2488
+ Start the Rails server:
2489
+ ```
2490
+ rails s
2491
+ ```
2492
+
2493
+ Visit `http://localhost:3000`
2494
+
2495
+ You should see "Hello, Menu Bar!"
2496
+
2497
+ ![Hello Menu Bar](images/glimmer-dsl-opal-hello-menu-bar.png)
2498
+
2499
+ ![Hello Menu Bar File Menu](images/glimmer-dsl-opal-hello-menu-bar-file-menu.png)
2500
+
2501
+ ![Hello Menu Bar Edit Menu](images/glimmer-dsl-opal-hello-menu-bar-edit-menu.png)
2502
+
2503
+ ![Hello Menu Bar Options Menu Disabled](images/glimmer-dsl-opal-hello-menu-bar-options-menu-disabled.png)
2504
+
2505
+ ![Hello Menu Bar Options Menu Select One](images/glimmer-dsl-opal-hello-menu-bar-options-menu-select-one.png)
2506
+
2507
+ ![Hello Menu Bar Options Menu Select Multiple](images/glimmer-dsl-opal-hello-menu-bar-options-menu-select-multiple.png)
2508
+
2509
+ ![Hello Menu Bar Format Menu Background Color](images/glimmer-dsl-opal-hello-menu-bar-format-menu-background-color.png)
2510
+
2511
+ ![Hello Menu Bar Format Menu Foreground Color](images/glimmer-dsl-opal-hello-menu-bar-format-menu-foreground-color.png)
2512
+
2513
+ ![Hello Menu Bar View Menu](images/glimmer-dsl-opal-hello-menu-bar-view-menu.png)
2514
+
2515
+ ![Hello Menu Bar View Small](images/glimmer-dsl-opal-hello-menu-bar-view-small.png)
2516
+
2517
+ ![Hello Menu Bar View Large](images/glimmer-dsl-opal-hello-menu-bar-view-large.png)
2518
+
2519
+ ![Hello Menu Bar Help Menu](images/glimmer-dsl-opal-hello-menu-bar-help-menu.png)
1957
2520
 
1958
2521
  ### Elaborate Samples
1959
2522
 
@@ -1970,7 +2533,6 @@ Or add the Glimmer code directly if you prefer to play around with it:
1970
2533
  ```ruby
1971
2534
  require "observer"
1972
2535
 
1973
- #Presents login screen data
1974
2536
  class LoginPresenter
1975
2537
 
1976
2538
  attr_accessor :user_name
@@ -1986,10 +2548,13 @@ class LoginPresenter
1986
2548
  def status=(status)
1987
2549
  @status = status
1988
2550
 
1989
- #TODO add feature to bind dependent properties to master property (2017-07-25 nested data binding)
1990
2551
  notify_observers("logged_in")
1991
2552
  notify_observers("logged_out")
1992
2553
  end
2554
+
2555
+ def valid?
2556
+ !@user_name.to_s.strip.empty? && !@password.to_s.strip.empty?
2557
+ end
1993
2558
 
1994
2559
  def logged_in
1995
2560
  self.status == "Logged In"
@@ -2000,6 +2565,7 @@ class LoginPresenter
2000
2565
  end
2001
2566
 
2002
2567
  def login
2568
+ return unless valid?
2003
2569
  self.status = "Logged In"
2004
2570
  end
2005
2571
 
@@ -2011,7 +2577,6 @@ class LoginPresenter
2011
2577
 
2012
2578
  end
2013
2579
 
2014
- #Login screen
2015
2580
  class Login
2016
2581
  include Glimmer
2017
2582
 
@@ -2023,15 +2588,21 @@ class Login
2023
2588
  grid_layout 2, false #two columns with differing widths
2024
2589
 
2025
2590
  label { text "Username:" } # goes in column 1
2026
- text { # goes in column 2
2591
+ @user_name_text = text { # goes in column 2
2027
2592
  text bind(presenter, :user_name)
2028
2593
  enabled bind(presenter, :logged_out)
2594
+ on_key_pressed { |event|
2595
+ @password_text.set_focus if event.keyCode == swt(:cr)
2596
+ }
2029
2597
  }
2030
2598
 
2031
2599
  label { text "Password:" }
2032
- text(:password, :border) {
2600
+ @password_text = text(:password, :border) {
2033
2601
  text bind(presenter, :password)
2034
2602
  enabled bind(presenter, :logged_out)
2603
+ on_key_pressed { |event|
2604
+ presenter.login if event.keyCode == swt(:cr)
2605
+ }
2035
2606
  }
2036
2607
 
2037
2608
  label { text "Status:" }
@@ -2041,12 +2612,21 @@ class Login
2041
2612
  text "Login"
2042
2613
  enabled bind(presenter, :logged_out)
2043
2614
  on_widget_selected { presenter.login }
2615
+ on_key_pressed { |event|
2616
+ presenter.login if event.keyCode == swt(:cr)
2617
+ }
2044
2618
  }
2045
2619
 
2046
2620
  button {
2047
2621
  text "Logout"
2048
2622
  enabled bind(presenter, :logged_in)
2049
2623
  on_widget_selected { presenter.logout }
2624
+ on_key_pressed { |event|
2625
+ if event.keyCode == swt(:cr)
2626
+ presenter.logout
2627
+ @user_name_text.set_focus
2628
+ end
2629
+ }
2050
2630
  }
2051
2631
  }
2052
2632
  }
@@ -2529,41 +3109,76 @@ class ContactManager
2529
3109
  shell {
2530
3110
  text "Contact Manager"
2531
3111
  composite {
2532
- composite {
2533
- grid_layout 2, false
2534
- label {text "First &Name: "}
3112
+ group {
3113
+ grid_layout(2, false) {
3114
+ margin_width 0
3115
+ margin_height 0
3116
+ }
3117
+ layout_data :fill, :center, true, false
3118
+ text 'Lookup Contacts'
3119
+ font height: 24
3120
+
3121
+ label {
3122
+ layout_data :right, :center, false, false
3123
+ text "First &Name: "
3124
+ font height: 16
3125
+ }
2535
3126
  text {
3127
+ layout_data :fill, :center, true, false
2536
3128
  text bind(@contact_manager_presenter, :first_name)
2537
3129
  on_key_pressed {|key_event|
2538
- @contact_manager_presenter.find if key_event.keyCode == Glimmer::SWT::SWTProxy[:cr]
3130
+ @contact_manager_presenter.find if key_event.keyCode == swt(:cr)
2539
3131
  }
2540
3132
  }
2541
- label {text "&Last Name: "}
3133
+
3134
+ label {
3135
+ layout_data :right, :center, false, false
3136
+ text "&Last Name: "
3137
+ font height: 16
3138
+ }
2542
3139
  text {
3140
+ layout_data :fill, :center, true, false
2543
3141
  text bind(@contact_manager_presenter, :last_name)
2544
3142
  on_key_pressed {|key_event|
2545
- @contact_manager_presenter.find if key_event.keyCode == Glimmer::SWT::SWTProxy[:cr]
3143
+ @contact_manager_presenter.find if key_event.keyCode == swt(:cr)
2546
3144
  }
2547
3145
  }
2548
- label {text "&Email: "}
3146
+
3147
+ label {
3148
+ layout_data :right, :center, false, false
3149
+ text "&Email: "
3150
+ font height: 16
3151
+ }
2549
3152
  text {
3153
+ layout_data :fill, :center, true, false
2550
3154
  text bind(@contact_manager_presenter, :email)
2551
3155
  on_key_pressed {|key_event|
2552
- @contact_manager_presenter.find if key_event.keyCode == Glimmer::SWT::SWTProxy[:cr]
3156
+ @contact_manager_presenter.find if key_event.keyCode == swt(:cr)
2553
3157
  }
2554
3158
  }
3159
+
2555
3160
  composite {
2556
- grid_layout 2, false
3161
+ row_layout {
3162
+ margin_width 0
3163
+ margin_height 0
3164
+ }
3165
+ layout_data(:right, :center, false, false) {
3166
+ horizontal_span 2
3167
+ }
3168
+
2557
3169
  button {
2558
3170
  text "&Find"
2559
- on_widget_selected {
2560
- @contact_manager_presenter.find
3171
+ on_widget_selected { @contact_manager_presenter.find }
3172
+ on_key_pressed {|key_event|
3173
+ @contact_manager_presenter.find if key_event.keyCode == swt(:cr)
2561
3174
  }
2562
3175
  }
3176
+
2563
3177
  button {
2564
3178
  text "&List All"
2565
- on_widget_selected {
2566
- @contact_manager_presenter.list
3179
+ on_widget_selected { @contact_manager_presenter.list }
3180
+ on_key_pressed {|key_event|
3181
+ @contact_manager_presenter.list if key_event.keyCode == swt(:cr)
2567
3182
  }
2568
3183
  }
2569
3184
  }
@@ -2580,26 +3195,18 @@ class ContactManager
2580
3195
  table_column {
2581
3196
  text "First Name"
2582
3197
  width 80
2583
- on_widget_selected {
2584
- @contact_manager_presenter.toggle_sort(:first_name)
2585
- }
2586
3198
  }
2587
3199
  table_column {
2588
3200
  text "Last Name"
2589
3201
  width 80
2590
- on_widget_selected {
2591
- @contact_manager_presenter.toggle_sort(:last_name)
2592
- }
2593
3202
  }
2594
3203
  table_column {
2595
3204
  text "Email"
2596
3205
  width 200
2597
- on_widget_selected {
2598
- @contact_manager_presenter.toggle_sort(:email)
2599
- }
2600
3206
  }
2601
- items bind(@contact_manager_presenter, :results), column_properties(:first_name, :last_name, :email)
2602
- on_mouse_down { |event|
3207
+ items bind(@contact_manager_presenter, :results),
3208
+ column_properties(:first_name, :last_name, :email)
3209
+ on_mouse_up { |event|
2603
3210
  table_proxy.edit_table_item(event.table_item, event.column_index)
2604
3211
  }
2605
3212
  }
@@ -2609,7 +3216,6 @@ class ContactManager
2609
3216
  end
2610
3217
 
2611
3218
  ContactManager.new.launch
2612
-
2613
3219
  ```
2614
3220
  Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
2615
3221
 
@@ -2706,13 +3312,27 @@ You should see "Apple Calculator Theme"
2706
3312
 
2707
3313
  [![Glimmer Calculator Opal Apple Calculator Theme](https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-calculator/master/glimmer-cs-calculator-screenshot-opal-apple.png)](http://glimmer-cs-calculator-server.herokuapp.com/welcomes/apple)
2708
3314
 
3315
+ ## Glimmer Supporting Libraries
3316
+
3317
+ Here is a list of notable 3rd party gems used by Glimmer DSL for Opal:
3318
+ - [glimmer-dsl-xml](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML & HTML in pure Ruby.
3319
+ - [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS (Cascading Style Sheets) in pure Ruby.
3320
+ - [opal-async](https://github.com/AndyObtiva/opal-async): Non-blocking tasks and enumerators for Opal.
3321
+ - [to_collection](https://github.com/AndyObtiva/to_collection): Treat an array of objects and a singular object uniformly as a collection of objects.
3322
+
3323
+ ## Glimmer Process
3324
+
3325
+ [Glimmer Process](https://github.com/AndyObtiva/glimmer/blob/master/PROCESS.md) is the lightweight software development process used for building Glimmer libraries and Glimmer apps, which goes beyond Agile, rendering all Agile processes obsolete. [Glimmer Process](https://github.com/AndyObtiva/glimmer/blob/master/PROCESS.md) is simply made up of 7 guidelines to pick and choose as necessary until software development needs are satisfied.
3326
+
3327
+ Learn more by reading the [GPG](https://github.com/AndyObtiva/glimmer/blob/master/PROCESS.md) (Glimmer Process Guidelines)
3328
+
2709
3329
  ## Help
2710
3330
 
2711
3331
  ### Issues
2712
3332
 
2713
- You may submit [issues](https://github.com/AndyObtiva/glimmer/issues) on [GitHub](https://github.com/AndyObtiva/glimmer/issues).
3333
+ You may submit [issues](https://github.com/AndyObtiva/glimmer-dsl-opal/issues) on [GitHub](https://github.com/AndyObtiva/glimmer-dsl-opal/issues).
2714
3334
 
2715
- [Click here to submit an issue.](https://github.com/AndyObtiva/glimmer/issues)
3335
+ [Click here to submit an issue.](https://github.com/AndyObtiva/glimmer-dsl-opal/issues)
2716
3336
 
2717
3337
  ### Chat
2718
3338