glimmer-dsl-opal 0.7.5 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +35 -0
- data/README.md +756 -139
- data/VERSION +1 -1
- data/lib/glimmer-dsl-opal.rb +16 -4
- data/lib/glimmer-dsl-opal/ext/class.rb +10 -0
- data/lib/{file.rb → glimmer-dsl-opal/ext/file.rb} +0 -0
- data/lib/glimmer-dsl-opal/ext/glimmer/dsl/engine.rb +46 -0
- data/lib/glimmer-dsl-opal/samples/elaborate/tic_tac_toe.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_browser.rb +23 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_computed.rb +27 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_computed/contact.rb +21 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_list_multi_selection.rb +62 -32
- data/lib/glimmer-dsl-opal/samples/hello/hello_list_single_selection.rb +47 -22
- data/lib/glimmer-dsl-opal/samples/hello/hello_menu_bar.rb +241 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_message_box.rb +37 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_pop_up_context_menu.rb +84 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_world.rb +3 -3
- data/lib/glimmer/config/opal_logger.rb +16 -0
- data/lib/glimmer/data_binding/observable_element.rb +1 -1
- data/lib/glimmer/dsl/opal/custom_widget_expression.rb +1 -1
- data/lib/glimmer/dsl/opal/dsl.rb +2 -0
- data/lib/glimmer/dsl/opal/menu_bar_expression.rb +54 -0
- data/lib/glimmer/dsl/opal/menu_expression.rb +61 -0
- data/lib/glimmer/dsl/opal/shell_expression.rb +0 -4
- data/lib/glimmer/dsl/opal/widget_expression.rb +3 -2
- data/lib/glimmer/dsl/opal/widget_listener_expression.rb +2 -2
- data/lib/glimmer/swt/custom/checkbox_group.rb +2 -2
- data/lib/glimmer/swt/custom/radio_group.rb +2 -2
- data/lib/glimmer/swt/display_proxy.rb +4 -4
- data/lib/glimmer/swt/event_listener_proxy.rb +14 -4
- data/lib/glimmer/swt/grid_layout_proxy.rb +1 -0
- data/lib/glimmer/swt/label_proxy.rb +27 -3
- data/lib/{glimmer-dsl-opal/ext/struct.rb → glimmer/swt/latest_message_box_proxy.rb} +16 -11
- data/lib/glimmer/swt/latest_shell_proxy.rb +55 -0
- data/lib/glimmer/swt/list_proxy.rb +15 -0
- data/lib/glimmer/swt/menu_item_proxy.rb +174 -0
- data/lib/glimmer/swt/menu_proxy.rb +273 -0
- data/lib/glimmer/swt/message_box_proxy.rb +79 -63
- data/lib/glimmer/swt/property_owner.rb +2 -0
- data/lib/glimmer/swt/radio_proxy.rb +1 -1
- data/lib/glimmer/swt/shell_proxy.rb +34 -189
- data/lib/glimmer/swt/tab_folder_proxy.rb +43 -0
- data/lib/glimmer/swt/table_column_proxy.rb +3 -2
- data/lib/glimmer/swt/table_editor.rb +1 -1
- data/lib/glimmer/swt/table_item_proxy.rb +7 -5
- data/lib/glimmer/swt/table_proxy.rb +10 -0
- data/lib/glimmer/swt/widget_proxy.rb +325 -31
- data/lib/glimmer/ui/custom_shell.rb +2 -2
- data/lib/glimmer/ui/custom_widget.rb +3 -3
- data/lib/net/http.rb +30 -2
- metadata +45 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 413c672e156087e669f81c8c73c6dfcc6b29146f058c6c317c80cfa1f10d9e31
|
4
|
+
data.tar.gz: 930793a35af93d316d44652ba386fab64b73bef069feb6a8919136db61879238
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 606f6324b4018f8a3dfd4df28c885825cf889d39674a6c80cc835f3035b3e58d64e3b88a18f258cd940ba99ad12b679d381f34cf4c171eb4d5ccb43bf2d91efa
|
7
|
+
data.tar.gz: 79ede1aea3bc7639489eb10feef5f12a89d75150b04a750ad44b3b2934f8a485e97ce71d6061e2500b96b11e42fa501f32ebc467b2a5c647d9bdd2dd6e615ef4
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,40 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.9.3
|
4
|
+
|
5
|
+
- Extracted pure Ruby Struct to pure-struct gem (since it's also used by YASL)
|
6
|
+
- Alpha experimental incomplete implementation of Net::HTTP.post_form
|
7
|
+
- Fixed issue with not being able to interact with a shell proxy (LatestShellProxy) after opening (made class autoupgradable to attached ShellProxy after document ready)
|
8
|
+
|
9
|
+
## 0.9.2
|
10
|
+
|
11
|
+
- Fixed issue with opening message_box after internalizing the Document.ready? block
|
12
|
+
- Fixed issue with replacing newlines with HTML newlines in `label` and `message_box` text
|
13
|
+
|
14
|
+
## 0.9.1
|
15
|
+
|
16
|
+
- Log errors to error stream ($stderr) instead of standard out (STDOUT)
|
17
|
+
- Fixed issue with opening shell caused by internalizing the Document.ready? block
|
18
|
+
|
19
|
+
## 0.9.0
|
20
|
+
|
21
|
+
- Support `menu_bar`
|
22
|
+
- Hello, Menu Bar! Sample
|
23
|
+
- Remove the need to call Document.ready? before opening a Glimmer shell
|
24
|
+
- Support opening a message_box before creating a shell
|
25
|
+
|
26
|
+
## 0.8.0
|
27
|
+
|
28
|
+
- Hello, Pop Up Context Menu! Sample
|
29
|
+
- Hello Message Box!
|
30
|
+
- Update hello list samples
|
31
|
+
- Support context menus `menu`/`menu_item` directly under a widget (using jQuery UI)
|
32
|
+
- Support generating new lines when entering `label` `text` with \n (auto-converting to <br />)
|
33
|
+
- Support generating new lines when entering `message_box` `message` with \n (auto-converting to <br />)
|
34
|
+
- Support having any widget contribute static CSS to ShellProxy
|
35
|
+
- Add Kernel#include_package shim to allow running JRuby include_package from Glimmer DSL for SWT without failing
|
36
|
+
- Add WidgetProxy#swt_widget to allow running include_package from Glimmer DSL for SWT without failing
|
37
|
+
|
3
38
|
## 0.7.5
|
4
39
|
|
5
40
|
- Update login sample from Glimmer DSL for SWT's latest changes
|
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.
|
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.3 (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,53 +12,136 @@ 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
|
-
####
|
15
|
+
#### Hello, Table! Sample
|
16
16
|
|
17
|
-
|
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
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
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
|
46
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
|
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
|
-
!
|
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
|
-
|
104
|
+
![Glimmer DSL for SWT Hello Table](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-table.png)
|
56
105
|
|
57
|
-
!
|
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):**
|
60
107
|
|
61
|
-
|
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
|
119
|
+
|
120
|
+
![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-editing-home-team.png)
|
121
|
+
|
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.3 only supports bare-minimum capabilities for the following [samples](https://github.com/AndyObtiva/glimmer-dsl-opal#samples) (originally written for [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt)):
|
62
145
|
|
63
146
|
[Hello samples](#hello-samples):
|
64
147
|
|
@@ -79,6 +162,9 @@ NOTE: **Alpha Version** 0.7.5 only supports bare-minimum capabilities for the fo
|
|
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
169
|
[Elaborate samples](#elaborate-samples):
|
84
170
|
|
@@ -86,7 +172,7 @@ NOTE: **Alpha Version** 0.7.5 only supports bare-minimum capabilities for the fo
|
|
86
172
|
- [Tic Tac Toe](#tic-tac-toe)
|
87
173
|
- [Contact Manager](#contact-manager)
|
88
174
|
|
89
|
-
External:
|
175
|
+
[External samples](#external-samples):
|
90
176
|
|
91
177
|
- [Glimmer Calculator](#glimmer-calculator)
|
92
178
|
|
@@ -96,56 +182,64 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
|
|
96
182
|
- [glimmer-dsl-xml](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML)
|
97
183
|
- [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS (Cascading Style Sheets)
|
98
184
|
|
99
|
-
##
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
-
|
105
|
-
-
|
106
|
-
-
|
107
|
-
-
|
108
|
-
-
|
109
|
-
-
|
110
|
-
-
|
111
|
-
-
|
112
|
-
-
|
113
|
-
-
|
114
|
-
-
|
115
|
-
-
|
116
|
-
-
|
117
|
-
-
|
118
|
-
|
119
|
-
|
120
|
-
-
|
121
|
-
-
|
122
|
-
-
|
123
|
-
-
|
124
|
-
|
125
|
-
|
126
|
-
-
|
127
|
-
-
|
128
|
-
|
129
|
-
|
130
|
-
-
|
131
|
-
-
|
132
|
-
-
|
133
|
-
-
|
134
|
-
|
135
|
-
|
136
|
-
-
|
137
|
-
-
|
185
|
+
## Table of Contents
|
186
|
+
|
187
|
+
- [Glimmer DSL for Opal 0.9.2 (Pure Ruby Web GUI)](#-glimmer-dsl-for-opal-092-pure-ruby-web-gui)
|
188
|
+
- [Principles](#principles)
|
189
|
+
- [Background](#background)
|
190
|
+
- [Pre-requisites](#pre-requisites)
|
191
|
+
- [Setup](#setup)
|
192
|
+
- [Supported Glimmer DSL Keywords](#supported-glimmer-dsl-keywords)
|
193
|
+
- [Samples](#samples)
|
194
|
+
- [Hello Samples](#hello-samples)
|
195
|
+
- [Hello, World!](#hello-world)
|
196
|
+
- [Hello, Combo!](#hello-combo)
|
197
|
+
- [Hello, Computed!](#hello-computed)
|
198
|
+
- [Hello, List Single Selection!](#hello-list-single-selection)
|
199
|
+
- [Hello, List Multi Selection!](#hello-list-multi-selection)
|
200
|
+
- [Hello, Browser!](#hello-browser)
|
201
|
+
- [Hello, Tab!](#hello-tab)
|
202
|
+
- [Hello, Custom Widget!](#hello-custom-widget)
|
203
|
+
- [Hello, Custom Shell!](#hello-custom-shell)
|
204
|
+
- [Hello, Radio!](#hello-radio)
|
205
|
+
- [Hello, Radio Group!](#hello-radio-group)
|
206
|
+
- [Hello, Group!](#hello-group)
|
207
|
+
- [Hello, Checkbox!](#hello-checkbox)
|
208
|
+
- [Hello, Checkbox Group!](#hello-checkbox-group)
|
209
|
+
- [Hello, Date Time!](#hello-date-time)
|
210
|
+
- [Hello, Table!](#hello-table)
|
211
|
+
- [Hello, Button!](#hello-button)
|
212
|
+
- [Hello, Message Box!](#hello-message-box)
|
213
|
+
- [Hello, Pop Up Context Menu!](#hello-pop-up-context-menu)
|
214
|
+
- [Hello, Menu Bar!](#hello-menu-bar)
|
215
|
+
- [Elaborate Samples](#elaborate-samples)
|
216
|
+
- [Login](#login)
|
217
|
+
- [Tic Tac Toe](#tic-tac-toe)
|
218
|
+
- [Contact Manager](#contact-manager)
|
219
|
+
- [External Samples](#external-samples)
|
220
|
+
- [Glimmer Calculator](#glimmer-calculator)
|
221
|
+
- [Glimmer Supporting Libraries](#glimmer-supporting-libraries)
|
222
|
+
- [Glimmer Process](#glimmer-process)
|
223
|
+
- [Help](#help)
|
224
|
+
- [Issues](#issues)
|
225
|
+
- [Chat](#chat)
|
226
|
+
- [Feature Suggestions](#feature-suggestions)
|
227
|
+
- [Change Log](#change-log)
|
228
|
+
- [Contributing](#contributing)
|
229
|
+
- [Contributors](#contributors)
|
230
|
+
- [License](#license)
|
138
231
|
|
139
232
|
## Principles
|
140
233
|
|
141
234
|
- **Live purely in Rubyland via the Glimmer GUI DSL**, completely oblivious to web browser technologies.
|
142
235
|
- **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.
|
143
|
-
- **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 (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.
|
236
|
+
- **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.
|
237
|
+
- **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 and mockups without worrying about pixel-perfect aesthetics. 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.
|
144
238
|
- **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.
|
145
239
|
|
146
240
|
## Background
|
147
241
|
|
148
|
-
The original idea behind Glimmer DSL for Opal was that you start by having a [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) desktop app that communicates with a Rails API for any web/cloud concerns. The pure Ruby [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) is very simple, so it is more productive to build GUI in it since it does not go through a server/client request/response cycle and can be iterated on locally with a much shorter feedback cycle. Once the GUI and the rest of the app is built. You simply embed it in a Rails app as a one line require statement
|
242
|
+
The original idea behind Glimmer DSL for Opal was that you start by having a [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) desktop app that communicates with a Rails API for any web/cloud concerns. The pure Ruby [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) is very simple, so it is more productive to build GUI in it since it does not go through a server/client request/response cycle and can be iterated on locally with a much shorter feedback cycle. Once the GUI and the rest of the app is built. You simply embed it in a Rails app as a one line require statement, and BOOM, it just works on the web inside a web browser with the same server/client communication you had in the desktop app (I am working on adding minimal support for net/http in Opal so that desktop apps that use it continue to work in a web browser. Until then, just use [Opal-jQuery](https://github.com/opal/opal-jquery) http support). That way, you get two apps for one: desktop and web.
|
149
243
|
|
150
244
|
Part of the idea is that web browsers just render GUI widgets similar to those of a desktop app (after all a web browser is a desktop app), so whether you run your GUI on the desktop or on the web should just be a low-level concern, hopefully automated completely with Glimmer DSL for Opal.
|
151
245
|
|
@@ -187,7 +281,7 @@ Add the following to `Gemfile`:
|
|
187
281
|
gem 'opal-rails', '~> 1.1.2'
|
188
282
|
gem 'opal-async', '~> 1.2.0'
|
189
283
|
gem 'opal-jquery', '~> 0.4.4'
|
190
|
-
gem 'glimmer-dsl-opal', '~> 0.
|
284
|
+
gem 'glimmer-dsl-opal', '~> 0.9.3'
|
191
285
|
gem 'glimmer-dsl-xml', '~> 1.1.0', require: false
|
192
286
|
gem 'glimmer-dsl-css', '~> 1.1.0', require: false
|
193
287
|
|
@@ -212,12 +306,6 @@ Modify `config/routes.rb`:
|
|
212
306
|
root to: 'welcomes#index'
|
213
307
|
```
|
214
308
|
|
215
|
-
Add the following line to the top of an empty `app/assets/javascripts/application.rb` (replacing `application.js`)
|
216
|
-
|
217
|
-
```ruby
|
218
|
-
require 'glimmer-dsl-opal' # brings opal and other dependencies automatically
|
219
|
-
```
|
220
|
-
|
221
309
|
Edit `app/views/layouts/application.html.erb` and add the following below other `stylesheet_link_tag` declarations:
|
222
310
|
|
223
311
|
```erb
|
@@ -226,37 +314,99 @@ Edit `app/views/layouts/application.html.erb` and add the following below other
|
|
226
314
|
|
227
315
|
Clear the file `app/views/welcomes/index.html.erb` from any content.
|
228
316
|
|
229
|
-
|
317
|
+
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.
|
230
318
|
|
231
319
|
```ruby
|
232
|
-
|
233
|
-
|
234
|
-
|
320
|
+
require 'glimmer-dsl-opal' # brings opal and other dependencies automatically
|
321
|
+
|
322
|
+
# require-statement/code goes here.
|
235
323
|
```
|
236
324
|
|
237
325
|
Example to confirm setup is working:
|
238
326
|
|
239
327
|
```ruby
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
}
|
252
|
-
|
328
|
+
require 'glimmer-dsl-opal'
|
329
|
+
|
330
|
+
include Glimmer
|
331
|
+
|
332
|
+
shell {
|
333
|
+
fill_layout
|
334
|
+
text 'Example to confirm setup is working'
|
335
|
+
label {
|
336
|
+
text "Welcome to Glimmer DSL for Opal!"
|
337
|
+
foreground :red
|
338
|
+
font height: 24
|
339
|
+
}
|
340
|
+
}.open
|
253
341
|
```
|
254
342
|
|
343
|
+
## Supported Glimmer DSL Keywords
|
344
|
+
|
345
|
+
The following keywords from [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) have partial support in Opal:
|
346
|
+
|
347
|
+
Widgets:
|
348
|
+
- `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)
|
349
|
+
- `browser`: featured in [Hello, Browser!](#hello-browser)
|
350
|
+
- `calendar`: featured in [Hello, Date Time!](#hello-date-time)
|
351
|
+
- `checkbox`: featured in [Hello, Checkbox Group!](#hello-checkbox-group) / [Hello, Checkbox!](#hello-checkbox)
|
352
|
+
- `checkbox_group`: featured in [Hello, Checkbox Group!](#hello-checkbox-group)
|
353
|
+
- `combo`: featured in [Hello, Table!](#hello-table) / [Hello, Combo!](#hello-combo)
|
354
|
+
- `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)
|
355
|
+
- `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)
|
356
|
+
- `date_drop_down`: featured in [Hello, Table!](#hello-table) / [Hello, Date Time!](#hello-date-time)
|
357
|
+
- `group`: featured in [Hello, Group!](#hello-group) / [Contact Manager](#contact-manager)
|
358
|
+
- `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)
|
359
|
+
- `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)
|
360
|
+
- `menu`: featured in [Hello, Menu Bar!](#hello-menu-bar) / [Hello, Pop Up Context Menu!](#hello-pop-up-context-menu) / [Hello, Table!](#hello-table)
|
361
|
+
- `menu_bar`: featured in [Hello, Menu Bar!](#hello-menu-bar)
|
362
|
+
- `menu_item`: featured in [Hello, Table!](#hello-table) / [Hello, Pop Up Context Menu!](#hello-pop-up-context-menu) / [Hello, Menu Bar!](#hello-menu-bar)
|
363
|
+
- `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)
|
364
|
+
- `radio`: featured in [Hello, Radio!](#hello-radio) / [Hello, Group!](#hello-group)
|
365
|
+
- `radio_group`: featured in [Hello, Radio Group!](#hello-radio-group)
|
366
|
+
- `scrolled_composite`
|
367
|
+
- `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)
|
368
|
+
- `tab_folder`: featured in [Hello, Tab!](#hello-tab)
|
369
|
+
- `tab_item`: featured in [Hello, Tab!](#hello-tab)
|
370
|
+
- `table`: featured in [Hello, Custom Shell!](#hello-custom-shell) / [Hello, Table!](#hello-table) / [Contact Manager](#contact-manager)
|
371
|
+
- `table_column`: featured in [Hello, Table!](#hello-table) / [Hello, Custom Shell!](#hello-custom-shell) / [Contact Manager](#contact-manager)
|
372
|
+
- `text`: featured in [Hello, Computed!](#hello-computed) / [Login](#login) / [Contact Manager](#contact-manager)
|
373
|
+
- `time`: featured in [Hello, Table!](#hello-table) / [Hello, Date Time!](#hello-date-time)
|
374
|
+
- Glimmer::UI::CustomWidget: ability to define any keyword as a custom widget - featured in [Hello, Custom Widget!](#hello-custom-widget)
|
375
|
+
- 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)
|
376
|
+
|
377
|
+
Layouts:
|
378
|
+
- `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)
|
379
|
+
- `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)
|
380
|
+
- `fill_layout`: featured in [Hello, Custom Widget!](#hello-custom-widget)
|
381
|
+
- `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)
|
382
|
+
|
383
|
+
Graphics/Style:
|
384
|
+
- `color`: featured in [Hello, Custom Widget!](#hello-custom-widget) / [Hello, Menu Bar!](#hello-menu-bar)
|
385
|
+
- `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)
|
386
|
+
- `Point` class used in setting location on widgets
|
387
|
+
- `swt` and `SWT` class to set SWT styles on widgets - featured in [Hello, Custom Shell!](#hello-custom-shell) / [Login](#login) / [Contact Manager](#contact-manager)
|
388
|
+
|
389
|
+
Data-Binding/Observers:
|
390
|
+
- `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)
|
391
|
+
- `observe`: featured in [Hello, Table!](#hello-table) / [Tic Tac Toe](#tic-tac-toe)
|
392
|
+
- `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)
|
393
|
+
- `on_modify_text`
|
394
|
+
- `on_key_pressed` (and SWT alias `on_swt_keydown`) - featured in [Login](#login) / [Contact Manager](#contact-manager)
|
395
|
+
- `on_key_released` (and SWT alias `on_swt_keyup`)
|
396
|
+
- `on_mouse_down` (and SWT alias `on_swt_mousedown`)
|
397
|
+
- `on_mouse_up` (and SWT alias `on_swt_mouseup`) - featured in [Hello, Custom Shell!](#hello-custom-shell) / [Contact Manager](#contact-manager)
|
398
|
+
|
399
|
+
Event loop:
|
400
|
+
- `display`: featured in [Tic Tac Toe](#tic-tac-toe)
|
401
|
+
- `async_exec`: featured in [Hello, Custom Widget!](#hello-custom-widget) / [Hello, Custom Shell!](#hello-custom-shell)
|
402
|
+
|
255
403
|
## Samples
|
256
404
|
|
257
405
|
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)
|
258
406
|
|
259
|
-
The [Hello samples](#hello-samples) demonstrate tiny building blocks for building full fledged applications.
|
407
|
+
The [Hello samples](#hello-samples) demonstrate tiny building blocks (widgets) for building full fledged applications.
|
408
|
+
|
409
|
+
The [Elaborate samples](#elaborate-samples) demonstrate more advanced sample applications that assemble multiple building blocks.
|
260
410
|
|
261
411
|
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:
|
262
412
|
|
@@ -573,44 +723,53 @@ require 'glimmer-dsl-opal/samples/hello/hello_list_multi_selection'
|
|
573
723
|
Or add the Glimmer code directly if you prefer to play around with it:
|
574
724
|
|
575
725
|
```ruby
|
576
|
-
class Person
|
577
|
-
attr_accessor :provinces, :provinces_options
|
578
|
-
|
579
|
-
def initialize
|
580
|
-
self.provinces_options=[
|
581
|
-
"",
|
582
|
-
"Quebec",
|
583
|
-
"Ontario",
|
584
|
-
"Manitoba",
|
585
|
-
"Saskatchewan",
|
586
|
-
"Alberta",
|
587
|
-
"British Columbia",
|
588
|
-
"Nova Skotia",
|
589
|
-
"Newfoundland"
|
590
|
-
]
|
591
|
-
self.provinces = ["Quebec", "Manitoba", "Alberta"]
|
592
|
-
end
|
593
|
-
|
594
|
-
def reset_provinces
|
595
|
-
self.provinces = ["Quebec", "Manitoba", "Alberta"]
|
596
|
-
end
|
597
|
-
end
|
598
|
-
|
599
726
|
class HelloListMultiSelection
|
727
|
+
class Person
|
728
|
+
attr_accessor :provinces, :provinces_options
|
729
|
+
|
730
|
+
def initialize
|
731
|
+
self.provinces_options = [
|
732
|
+
'',
|
733
|
+
'Alberta',
|
734
|
+
'British Columbia',
|
735
|
+
'Manitoba',
|
736
|
+
'New Brunswick',
|
737
|
+
'Newfoundland and Labrador',
|
738
|
+
'Northwest Territories',
|
739
|
+
'Nova Scotia',
|
740
|
+
'Nunavut',
|
741
|
+
'Ontario',
|
742
|
+
'Prince Edward Island',
|
743
|
+
'Quebec',
|
744
|
+
'Saskatchewan',
|
745
|
+
'Yukon'
|
746
|
+
]
|
747
|
+
reset_provinces
|
748
|
+
end
|
749
|
+
|
750
|
+
def reset_provinces
|
751
|
+
self.provinces = ['Quebec', 'Manitoba', 'Alberta']
|
752
|
+
end
|
753
|
+
end
|
754
|
+
|
600
755
|
include Glimmer
|
756
|
+
|
601
757
|
def launch
|
602
758
|
person = Person.new
|
759
|
+
|
603
760
|
shell {
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
761
|
+
grid_layout
|
762
|
+
|
763
|
+
text 'Hello, List Multi Selection!'
|
764
|
+
|
765
|
+
list(:multi) {
|
766
|
+
selection bind(person, :provinces)
|
767
|
+
}
|
768
|
+
|
769
|
+
button {
|
770
|
+
text 'Reset Selections To Default Values'
|
771
|
+
|
772
|
+
on_widget_selected { person.reset_provinces }
|
614
773
|
}
|
615
774
|
}.open
|
616
775
|
end
|
@@ -1961,6 +2120,450 @@ You should see "Hello, Button!"
|
|
1961
2120
|
![Glimmer DSL for Opal Hello Button](images/glimmer-dsl-opal-hello-button.png)
|
1962
2121
|
![Glimmer DSL for Opal Hello Button](images/glimmer-dsl-opal-hello-button-incremented.png)
|
1963
2122
|
|
2123
|
+
#### Hello, Message Box!
|
2124
|
+
|
2125
|
+
Add the following require statement to `app/assets/javascripts/application.rb`
|
2126
|
+
|
2127
|
+
```ruby
|
2128
|
+
require 'glimmer-dsl-opal/samples/hello/hello_message_box'
|
2129
|
+
```
|
2130
|
+
|
2131
|
+
Or add the Glimmer code directly if you prefer to play around with it:
|
2132
|
+
|
2133
|
+
```ruby
|
2134
|
+
include Glimmer
|
2135
|
+
|
2136
|
+
shell {
|
2137
|
+
text 'Hello, Message Box!'
|
2138
|
+
|
2139
|
+
button {
|
2140
|
+
text 'Please Click To Win a Surprise'
|
2141
|
+
|
2142
|
+
on_widget_selected {
|
2143
|
+
message_box {
|
2144
|
+
text 'Surprise'
|
2145
|
+
message "Congratulations!\n\nYou won $1,000,000!"
|
2146
|
+
}.open
|
2147
|
+
}
|
2148
|
+
}
|
2149
|
+
}.open
|
2150
|
+
```
|
2151
|
+
|
2152
|
+
Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
|
2153
|
+
|
2154
|
+
![Glimmer DSL for SWT Message Box](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-message-box.png)
|
2155
|
+
![Glimmer DSL for SWT Message Box Dialog](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-message-box-dialog.png)
|
2156
|
+
|
2157
|
+
Glimmer app on the web (using `glimmer-dsl-opal` gem):
|
2158
|
+
|
2159
|
+
Start the Rails server:
|
2160
|
+
```
|
2161
|
+
rails s
|
2162
|
+
```
|
2163
|
+
|
2164
|
+
Visit `http://localhost:3000`
|
2165
|
+
|
2166
|
+
You should see "Hello, Message Box!"
|
2167
|
+
|
2168
|
+
![Glimmer DSL for Opal Hello Message Box](images/glimmer-dsl-opal-hello-message-box.png)
|
2169
|
+
![Glimmer DSL for Opal Hello Message Box Dialog](images/glimmer-dsl-opal-hello-message-box-dialog.png)
|
2170
|
+
|
2171
|
+
#### Hello, Pop Up Context Menu!
|
2172
|
+
|
2173
|
+
Add the following require statement to `app/assets/javascripts/application.rb`
|
2174
|
+
|
2175
|
+
```ruby
|
2176
|
+
require 'glimmer-dsl-opal/samples/hello/hello_pop_up_context_menu'
|
2177
|
+
```
|
2178
|
+
|
2179
|
+
Or add the Glimmer code directly if you prefer to play around with it:
|
2180
|
+
|
2181
|
+
```ruby
|
2182
|
+
include Glimmer
|
2183
|
+
|
2184
|
+
shell {
|
2185
|
+
grid_layout {
|
2186
|
+
margin_width 0
|
2187
|
+
margin_height 0
|
2188
|
+
}
|
2189
|
+
|
2190
|
+
text 'Hello, Pop Up Context Menu!'
|
2191
|
+
|
2192
|
+
label {
|
2193
|
+
text "Right-Click on the Text to\nPop Up a Context Menu"
|
2194
|
+
font height: 50
|
2195
|
+
|
2196
|
+
menu {
|
2197
|
+
menu {
|
2198
|
+
text '&History'
|
2199
|
+
menu {
|
2200
|
+
text '&Recent'
|
2201
|
+
menu_item {
|
2202
|
+
text 'File 1'
|
2203
|
+
on_widget_selected {
|
2204
|
+
message_box {
|
2205
|
+
text 'File 1'
|
2206
|
+
message 'File 1 Contents'
|
2207
|
+
}.open
|
2208
|
+
}
|
2209
|
+
}
|
2210
|
+
menu_item {
|
2211
|
+
text 'File 2'
|
2212
|
+
on_widget_selected {
|
2213
|
+
message_box {
|
2214
|
+
text 'File 2'
|
2215
|
+
message 'File 2 Contents'
|
2216
|
+
}.open
|
2217
|
+
}
|
2218
|
+
}
|
2219
|
+
}
|
2220
|
+
menu {
|
2221
|
+
text '&Archived'
|
2222
|
+
menu_item {
|
2223
|
+
text 'File 3'
|
2224
|
+
on_widget_selected {
|
2225
|
+
message_box {
|
2226
|
+
text 'File 3'
|
2227
|
+
message 'File 3 Contents'
|
2228
|
+
}.open
|
2229
|
+
}
|
2230
|
+
}
|
2231
|
+
menu_item {
|
2232
|
+
text 'File 4'
|
2233
|
+
on_widget_selected {
|
2234
|
+
message_box {
|
2235
|
+
text 'File 4'
|
2236
|
+
message 'File 4 Contents'
|
2237
|
+
}.open
|
2238
|
+
}
|
2239
|
+
}
|
2240
|
+
}
|
2241
|
+
}
|
2242
|
+
}
|
2243
|
+
}
|
2244
|
+
}.open
|
2245
|
+
```
|
2246
|
+
|
2247
|
+
Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
|
2248
|
+
|
2249
|
+
![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)
|
2250
|
+
![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)
|
2251
|
+
|
2252
|
+
Glimmer app on the web (using `glimmer-dsl-opal` gem):
|
2253
|
+
|
2254
|
+
Start the Rails server:
|
2255
|
+
```
|
2256
|
+
rails s
|
2257
|
+
```
|
2258
|
+
|
2259
|
+
Visit `http://localhost:3000`
|
2260
|
+
|
2261
|
+
You should see "Hello, Pop Up Context Menu!"
|
2262
|
+
|
2263
|
+
![Glimmer DSL for Opal Hello Pop Up Context Menu](images/glimmer-dsl-opal-hello-pop-up-context-menu.png)
|
2264
|
+
![Glimmer DSL for Opal Hello Pop Up Context Menu Popped Up](images/glimmer-dsl-opal-hello-pop-up-context-menu-popped-up.png)
|
2265
|
+
|
2266
|
+
#### Hello, Menu Bar!
|
2267
|
+
|
2268
|
+
This sample demonstrates a menu bar similar to the File menu bar you see at the top of desktop applications.
|
2269
|
+
|
2270
|
+
In web applications, it is typically used to provide website information architecture by denoting things like Products, News, Careers, and About.
|
2271
|
+
|
2272
|
+
In web applications, it is also typically styled by CSS with margin/padding around every menu, distancing it from the top.
|
2273
|
+
|
2274
|
+
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.
|
2275
|
+
|
2276
|
+
Add the following require statement to `app/assets/javascripts/application.rb`
|
2277
|
+
|
2278
|
+
```ruby
|
2279
|
+
require 'glimmer-dsl-opal/samples/hello/hello_menu_bar'
|
2280
|
+
```
|
2281
|
+
|
2282
|
+
Or add the Glimmer code directly if you prefer to play around with it:
|
2283
|
+
|
2284
|
+
```ruby
|
2285
|
+
include Glimmer
|
2286
|
+
|
2287
|
+
COLORS = [:white, :red, :yellow, :green, :blue, :magenta, :gray, :black]
|
2288
|
+
|
2289
|
+
shell {
|
2290
|
+
grid_layout {
|
2291
|
+
margin_width 0
|
2292
|
+
margin_height 0
|
2293
|
+
}
|
2294
|
+
|
2295
|
+
text 'Hello, Menu Bar!'
|
2296
|
+
|
2297
|
+
@label = label(:center) {
|
2298
|
+
font height: 50
|
2299
|
+
text 'Check Out The Menu Bar Above!'
|
2300
|
+
}
|
2301
|
+
|
2302
|
+
menu_bar {
|
2303
|
+
menu {
|
2304
|
+
text '&File'
|
2305
|
+
menu_item {
|
2306
|
+
text '&New'
|
2307
|
+
accelerator :command, :N
|
2308
|
+
|
2309
|
+
on_widget_selected {
|
2310
|
+
message_box {
|
2311
|
+
text 'New'
|
2312
|
+
message 'New file created.'
|
2313
|
+
}.open
|
2314
|
+
}
|
2315
|
+
}
|
2316
|
+
menu_item {
|
2317
|
+
text '&Open...'
|
2318
|
+
accelerator :command, :O
|
2319
|
+
|
2320
|
+
on_widget_selected {
|
2321
|
+
message_box {
|
2322
|
+
text 'Open'
|
2323
|
+
message 'Opening File...'
|
2324
|
+
}.open
|
2325
|
+
}
|
2326
|
+
}
|
2327
|
+
menu {
|
2328
|
+
text 'Open &Recent'
|
2329
|
+
menu_item {
|
2330
|
+
text 'File 1'
|
2331
|
+
on_widget_selected {
|
2332
|
+
message_box {
|
2333
|
+
text 'File 1'
|
2334
|
+
message 'File 1 Contents'
|
2335
|
+
}.open
|
2336
|
+
}
|
2337
|
+
}
|
2338
|
+
menu_item {
|
2339
|
+
text 'File 2'
|
2340
|
+
on_widget_selected {
|
2341
|
+
message_box {
|
2342
|
+
text 'File 2'
|
2343
|
+
message 'File 2 Contents'
|
2344
|
+
}.open
|
2345
|
+
}
|
2346
|
+
}
|
2347
|
+
}
|
2348
|
+
menu_item(:separator)
|
2349
|
+
menu_item {
|
2350
|
+
text 'E&xit'
|
2351
|
+
|
2352
|
+
on_widget_selected {
|
2353
|
+
exit(0)
|
2354
|
+
}
|
2355
|
+
}
|
2356
|
+
}
|
2357
|
+
menu {
|
2358
|
+
text '&Edit'
|
2359
|
+
menu_item {
|
2360
|
+
text 'Cut'
|
2361
|
+
accelerator :command, :X
|
2362
|
+
}
|
2363
|
+
menu_item {
|
2364
|
+
text 'Copy'
|
2365
|
+
accelerator :command, :C
|
2366
|
+
}
|
2367
|
+
menu_item {
|
2368
|
+
text 'Paste'
|
2369
|
+
accelerator :command, :V
|
2370
|
+
}
|
2371
|
+
}
|
2372
|
+
menu {
|
2373
|
+
text '&Options'
|
2374
|
+
|
2375
|
+
menu_item(:radio) {
|
2376
|
+
text '&Enabled'
|
2377
|
+
|
2378
|
+
on_widget_selected {
|
2379
|
+
@select_one_menu.enabled = true
|
2380
|
+
@select_multiple_menu.enabled = true
|
2381
|
+
}
|
2382
|
+
}
|
2383
|
+
@select_one_menu = menu {
|
2384
|
+
text '&Select One'
|
2385
|
+
enabled false
|
2386
|
+
|
2387
|
+
menu_item(:radio) {
|
2388
|
+
text 'Option 1'
|
2389
|
+
}
|
2390
|
+
menu_item(:radio) {
|
2391
|
+
text 'Option 2'
|
2392
|
+
}
|
2393
|
+
menu_item(:radio) {
|
2394
|
+
text 'Option 3'
|
2395
|
+
}
|
2396
|
+
}
|
2397
|
+
@select_multiple_menu = menu {
|
2398
|
+
text '&Select Multiple'
|
2399
|
+
enabled false
|
2400
|
+
|
2401
|
+
menu_item(:check) {
|
2402
|
+
text 'Option 4'
|
2403
|
+
}
|
2404
|
+
menu_item(:check) {
|
2405
|
+
text 'Option 5'
|
2406
|
+
}
|
2407
|
+
menu_item(:check) {
|
2408
|
+
text 'Option 6'
|
2409
|
+
}
|
2410
|
+
}
|
2411
|
+
}
|
2412
|
+
menu {
|
2413
|
+
text '&Format'
|
2414
|
+
menu {
|
2415
|
+
text '&Background Color'
|
2416
|
+
COLORS.each { |color_style|
|
2417
|
+
menu_item(:radio) {
|
2418
|
+
text color_style.to_s.split('_').map(&:capitalize).join(' ')
|
2419
|
+
|
2420
|
+
on_widget_selected {
|
2421
|
+
@label.background = color_style
|
2422
|
+
}
|
2423
|
+
}
|
2424
|
+
}
|
2425
|
+
}
|
2426
|
+
menu {
|
2427
|
+
text 'Foreground &Color'
|
2428
|
+
COLORS.each { |color_style|
|
2429
|
+
menu_item(:radio) {
|
2430
|
+
text color_style.to_s.split('_').map(&:capitalize).join(' ')
|
2431
|
+
|
2432
|
+
on_widget_selected {
|
2433
|
+
@label.foreground = color_style
|
2434
|
+
}
|
2435
|
+
}
|
2436
|
+
}
|
2437
|
+
}
|
2438
|
+
}
|
2439
|
+
menu {
|
2440
|
+
text '&View'
|
2441
|
+
menu_item(:radio) {
|
2442
|
+
text 'Small'
|
2443
|
+
|
2444
|
+
on_widget_selected {
|
2445
|
+
@label.font = {height: 25}
|
2446
|
+
@label.parent.pack
|
2447
|
+
}
|
2448
|
+
}
|
2449
|
+
menu_item(:radio) {
|
2450
|
+
text 'Medium'
|
2451
|
+
selection true
|
2452
|
+
|
2453
|
+
on_widget_selected {
|
2454
|
+
@label.font = {height: 50}
|
2455
|
+
@label.parent.pack
|
2456
|
+
}
|
2457
|
+
}
|
2458
|
+
menu_item(:radio) {
|
2459
|
+
text 'Large'
|
2460
|
+
|
2461
|
+
on_widget_selected {
|
2462
|
+
@label.font = {height: 75}
|
2463
|
+
@label.parent.pack
|
2464
|
+
}
|
2465
|
+
}
|
2466
|
+
}
|
2467
|
+
menu {
|
2468
|
+
text '&Help'
|
2469
|
+
menu_item {
|
2470
|
+
text '&Manual'
|
2471
|
+
accelerator :command, :shift, :M
|
2472
|
+
|
2473
|
+
on_widget_selected {
|
2474
|
+
message_box {
|
2475
|
+
text 'Manual'
|
2476
|
+
message 'Manual Contents'
|
2477
|
+
}.open
|
2478
|
+
}
|
2479
|
+
}
|
2480
|
+
menu_item {
|
2481
|
+
text '&Tutorial'
|
2482
|
+
accelerator :command, :shift, :T
|
2483
|
+
|
2484
|
+
on_widget_selected {
|
2485
|
+
message_box {
|
2486
|
+
text 'Tutorial'
|
2487
|
+
message 'Tutorial Contents'
|
2488
|
+
}.open
|
2489
|
+
}
|
2490
|
+
}
|
2491
|
+
menu_item(:separator)
|
2492
|
+
menu_item {
|
2493
|
+
text '&Report an Issue...'
|
2494
|
+
|
2495
|
+
on_widget_selected {
|
2496
|
+
message_box {
|
2497
|
+
text 'Report an Issue'
|
2498
|
+
message 'Reporting an issue...'
|
2499
|
+
}.open
|
2500
|
+
}
|
2501
|
+
}
|
2502
|
+
}
|
2503
|
+
}
|
2504
|
+
}.open
|
2505
|
+
```
|
2506
|
+
|
2507
|
+
Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
|
2508
|
+
|
2509
|
+
![Hello Menu Bar](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar.png)
|
2510
|
+
|
2511
|
+
![Hello Menu Bar File Menu](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar-file-menu.png)
|
2512
|
+
|
2513
|
+
![Hello Menu Bar Edit Menu](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar-edit-menu.png)
|
2514
|
+
|
2515
|
+
![Hello Menu Bar Options Menu Disabled](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar-options-menu-disabled.png)
|
2516
|
+
|
2517
|
+
![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)
|
2518
|
+
|
2519
|
+
![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)
|
2520
|
+
|
2521
|
+
![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)
|
2522
|
+
|
2523
|
+
![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)
|
2524
|
+
|
2525
|
+
![Hello Menu Bar View Menu](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar-view-menu.png)
|
2526
|
+
|
2527
|
+
![Hello Menu Bar View Small](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar-view-small.png)
|
2528
|
+
|
2529
|
+
![Hello Menu Bar View Large](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar-view-large.png)
|
2530
|
+
|
2531
|
+
![Hello Menu Bar Help Menu](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-menu-bar-help-menu.png)
|
2532
|
+
|
2533
|
+
Glimmer app on the web (using `glimmer-dsl-opal` gem):
|
2534
|
+
|
2535
|
+
Start the Rails server:
|
2536
|
+
```
|
2537
|
+
rails s
|
2538
|
+
```
|
2539
|
+
|
2540
|
+
Visit `http://localhost:3000`
|
2541
|
+
|
2542
|
+
You should see "Hello, Menu Bar!"
|
2543
|
+
|
2544
|
+
![Hello Menu Bar](images/glimmer-dsl-opal-hello-menu-bar.png)
|
2545
|
+
|
2546
|
+
![Hello Menu Bar File Menu](images/glimmer-dsl-opal-hello-menu-bar-file-menu.png)
|
2547
|
+
|
2548
|
+
![Hello Menu Bar Edit Menu](images/glimmer-dsl-opal-hello-menu-bar-edit-menu.png)
|
2549
|
+
|
2550
|
+
![Hello Menu Bar Options Menu Disabled](images/glimmer-dsl-opal-hello-menu-bar-options-menu-disabled.png)
|
2551
|
+
|
2552
|
+
![Hello Menu Bar Options Menu Select One](images/glimmer-dsl-opal-hello-menu-bar-options-menu-select-one.png)
|
2553
|
+
|
2554
|
+
![Hello Menu Bar Options Menu Select Multiple](images/glimmer-dsl-opal-hello-menu-bar-options-menu-select-multiple.png)
|
2555
|
+
|
2556
|
+
![Hello Menu Bar Format Menu Background Color](images/glimmer-dsl-opal-hello-menu-bar-format-menu-background-color.png)
|
2557
|
+
|
2558
|
+
![Hello Menu Bar Format Menu Foreground Color](images/glimmer-dsl-opal-hello-menu-bar-format-menu-foreground-color.png)
|
2559
|
+
|
2560
|
+
![Hello Menu Bar View Menu](images/glimmer-dsl-opal-hello-menu-bar-view-menu.png)
|
2561
|
+
|
2562
|
+
![Hello Menu Bar View Small](images/glimmer-dsl-opal-hello-menu-bar-view-small.png)
|
2563
|
+
|
2564
|
+
![Hello Menu Bar View Large](images/glimmer-dsl-opal-hello-menu-bar-view-large.png)
|
2565
|
+
|
2566
|
+
![Hello Menu Bar Help Menu](images/glimmer-dsl-opal-hello-menu-bar-help-menu.png)
|
1964
2567
|
|
1965
2568
|
### Elaborate Samples
|
1966
2569
|
|
@@ -2756,13 +3359,27 @@ You should see "Apple Calculator Theme"
|
|
2756
3359
|
|
2757
3360
|
[![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)
|
2758
3361
|
|
3362
|
+
## Glimmer Supporting Libraries
|
3363
|
+
|
3364
|
+
Here is a list of notable 3rd party gems used by Glimmer DSL for Opal:
|
3365
|
+
- [glimmer-dsl-xml](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML & HTML in pure Ruby.
|
3366
|
+
- [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS (Cascading Style Sheets) in pure Ruby.
|
3367
|
+
- [opal-async](https://github.com/AndyObtiva/opal-async): Non-blocking tasks and enumerators for Opal.
|
3368
|
+
- [to_collection](https://github.com/AndyObtiva/to_collection): Treat an array of objects and a singular object uniformly as a collection of objects.
|
3369
|
+
|
3370
|
+
## Glimmer Process
|
3371
|
+
|
3372
|
+
[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.
|
3373
|
+
|
3374
|
+
Learn more by reading the [GPG](https://github.com/AndyObtiva/glimmer/blob/master/PROCESS.md) (Glimmer Process Guidelines)
|
3375
|
+
|
2759
3376
|
## Help
|
2760
3377
|
|
2761
3378
|
### Issues
|
2762
3379
|
|
2763
|
-
You may submit [issues](https://github.com/AndyObtiva/glimmer/issues) on [GitHub](https://github.com/AndyObtiva/glimmer/issues).
|
3380
|
+
You may submit [issues](https://github.com/AndyObtiva/glimmer-dsl-opal/issues) on [GitHub](https://github.com/AndyObtiva/glimmer-dsl-opal/issues).
|
2764
3381
|
|
2765
|
-
[Click here to submit an issue.](https://github.com/AndyObtiva/glimmer/issues)
|
3382
|
+
[Click here to submit an issue.](https://github.com/AndyObtiva/glimmer-dsl-opal/issues)
|
2766
3383
|
|
2767
3384
|
### Chat
|
2768
3385
|
|