glimmer 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/README.markdown +212 -161
  3. data/RUBY_VERSION +1 -0
  4. data/VERSION +1 -0
  5. data/icons/scaffold_app.icns +0 -0
  6. data/lib/glimmer.rb +5 -47
  7. data/lib/glimmer/config.rb +35 -0
  8. data/lib/glimmer/css/{rule_set.rb → rule.rb} +3 -5
  9. data/lib/glimmer/css/style_sheet.rb +4 -5
  10. data/lib/glimmer/data_binding/observable_model.rb +1 -1
  11. data/lib/glimmer/dsl/css/dsl.rb +2 -2
  12. data/lib/glimmer/dsl/css/dynamic_property_expression.rb +12 -0
  13. data/lib/glimmer/dsl/css/property_expression.rb +3 -3
  14. data/lib/glimmer/dsl/css/pv_expression.rb +17 -0
  15. data/lib/glimmer/dsl/css/{rule_set_expression.rb → rule_expression.rb} +4 -4
  16. data/lib/glimmer/dsl/css/s_expression.rb +3 -3
  17. data/lib/glimmer/dsl/engine.rb +35 -5
  18. data/lib/glimmer/dsl/expression_handler.rb +3 -3
  19. data/lib/glimmer/dsl/swt/color_expression.rb +2 -0
  20. data/lib/glimmer/dsl/swt/dsl.rb +2 -0
  21. data/lib/glimmer/dsl/swt/tab_item_expression.rb +1 -1
  22. data/lib/glimmer/dsl/swt/widget_listener_expression.rb +5 -5
  23. data/lib/glimmer/dsl/xml/name_space_expression.rb +1 -1
  24. data/lib/glimmer/launcher.rb +64 -19
  25. data/lib/glimmer/rake_task.rb +64 -23
  26. data/lib/glimmer/scaffold.rb +442 -0
  27. data/lib/glimmer/swt/layout_data_proxy.rb +1 -1
  28. data/lib/glimmer/swt/layout_proxy.rb +2 -2
  29. data/lib/glimmer/swt/swt_proxy.rb +3 -3
  30. data/lib/glimmer/swt/widget_proxy.rb +5 -5
  31. data/lib/glimmer/ui/custom_widget.rb +3 -3
  32. data/lib/glimmer/xml/node.rb +1 -1
  33. data/lib/glimmer/xml/xml_visitor.rb +2 -2
  34. metadata +16 -42
  35. data/bin/gladiator +0 -6
  36. data/lib/glimmer/dsl/css/p_expression.rb +0 -25
  37. data/lib/glimmer/ui/video.rb +0 -289
  38. data/samples/gladiator.rb +0 -765
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3610ccbe7872450d8b38005411e05be5b282c6f9785dbb21f87a239944ff304b
4
- data.tar.gz: d80b1a110bd98b8dd5bd84be107ef9cd316af755cc052f94449b2249ddee1d4b
3
+ metadata.gz: a2c1935b1d8ac63f8f79323e754e9a32a6c3ed8465db80da479a36e28f377d7a
4
+ data.tar.gz: 1b64ca831d6d2b911278abfd6156fa6267a9a88b82bc8a5a5a4bf7b35c09c403
5
5
  SHA512:
6
- metadata.gz: 9d7810d076c698cab8d9c43fb4c7c3743ba37cad314e090e5d4112dcee50d6b5b5a389dce908e63e2c35a755079e944d69acff2b8ee9620f3541d474f97190a7
7
- data.tar.gz: 64843e0799b6c035ca8aafa09be1ace82fda2ae7c188553e4db61ed8579b33598bc0f141ee90d8fb99f2383e810059278f2dfec8f4cbb862eac7d6e6288c0ae7
6
+ metadata.gz: ccab304701eefa5bcd8560995878b2f50cf739f6ec092244b5a0bfdc686e15859f81f74c62939beaccb0efd5052a126adfe2dbde887afb13d697af7430b68f7f
7
+ data.tar.gz: 1ba3e00febd0b60e3c9105b0737c4a875c438cc450048c7cc49bc8d06a84eb0a311b3581d5c61845c3b0a17fd1ec7dbc554428d02b8d3853e048e14b3fcca9fb
@@ -1,4 +1,4 @@
1
- # Glimmer 0.6.0 Beta (JRuby Desktop UI DSL + Data-Binding)
1
+ # Glimmer 0.7.0 Beta (JRuby Desktop UI DSL + Data-Binding)
2
2
  [![Coverage Status](https://coveralls.io/repos/github/AndyObtiva/glimmer/badge.svg?branch=master)](https://coveralls.io/github/AndyObtiva/glimmer?branch=master)
3
3
 
4
4
  Glimmer is a native-UI cross-platform desktop development library written in Ruby. Glimmer's main innovation is a JRuby DSL that enables productive and efficient authoring of desktop application user-interfaces while relying on the robust Eclipse SWT library. Glimmer additionally innovates by having built-in data-binding support to greatly facilitate synchronizing the UI with domain models. As a result, that achieves true decoupling of object oriented components, enabling developers to solve business problems without worrying about UI concerns, or alternatively drive development UI-first, and then write clean business components test-first afterwards.
@@ -7,7 +7,7 @@ Glimmer is a native-UI cross-platform desktop development library written in Rub
7
7
 
8
8
  ### Hello World
9
9
 
10
- Glimmer code (from `samples/hello_world.rb`):
10
+ Glimmer code (from `samples/hello/hello_world.rb`):
11
11
  ```ruby
12
12
  include Glimmer
13
13
 
@@ -21,7 +21,7 @@ shell {
21
21
 
22
22
  Run:
23
23
  ```
24
- glimmer samples/hello_world.rb
24
+ glimmer samples/hello/hello_world.rb
25
25
  ```
26
26
 
27
27
  Glimmer app:
@@ -30,7 +30,7 @@ Glimmer app:
30
30
 
31
31
  ### Tic Tac Toe
32
32
 
33
- Glimmer code (from `samples/tictactoe/tic_tac_toe.rb`):
33
+ Glimmer code (from `samples/elaborate/tic_tac_toe.rb`):
34
34
 
35
35
  ```ruby
36
36
  # ...
@@ -58,7 +58,7 @@ shell {
58
58
  Run:
59
59
 
60
60
  ```
61
- glimmer samples/tictactoe/tic_tac_toe.rb
61
+ glimmer samples/elaborate/tic_tac_toe.rb
62
62
  ```
63
63
 
64
64
  Glimmer app:
@@ -70,7 +70,7 @@ NOTE: Glimmer is in beta mode. Please help make better by adopting for small or
70
70
  ## Table of Contents
71
71
 
72
72
  <!-- TOC START min:1 max:3 link:true asterisk:false update:true -->
73
- - [Glimmer 0.6.0 Beta (JRuby Desktop UI DSL + Data-Binding)](#glimmer-058-beta-jruby-desktop-ui-dsl--data-binding)
73
+ - [Glimmer 0.7.0 Beta (JRuby Desktop UI DSL + Data-Binding)](#glimmer-058-beta-jruby-desktop-ui-dsl--data-binding)
74
74
  - [Examples](#examples)
75
75
  - [Hello World](#hello-world)
76
76
  - [Tic Tac Toe](#tic-tac-toe)
@@ -143,9 +143,9 @@ https://www.eclipse.org/swt/faq.php
143
143
 
144
144
  ## Pre-requisites
145
145
 
146
- * Java SE Runtime Environment 7 or higher (find at https://www.oracle.com/java/technologies/javase-downloads.html)
147
- * JRuby 9.2.11.1 (supporting Ruby 2.5.x syntax) (find at https://www.jruby.org/download)
148
- * SWT 4.15 (comes included in Glimmer gem)
146
+ - SWT 4.15 (comes included in Glimmer gem)
147
+ - JRuby 9.2.11.1 (supporting Ruby 2.5.x syntax) (find at https://www.jruby.org/download)
148
+ - Java SE Runtime Environment 7 or higher (find at https://www.oracle.com/java/technologies/javase-downloads.html)
149
149
 
150
150
  On **Mac** and **Linux**, an easy way to obtain JRuby is through [RVM](http://rvm.io) by running:
151
151
 
@@ -163,14 +163,18 @@ Please follow these instructions to make the `glimmer` command available on your
163
163
 
164
164
  Run this command to install directly:
165
165
  ```
166
- jgem install glimmer -v 0.6.0
166
+ jgem install glimmer -v 0.7.0
167
167
  ```
168
168
 
169
+ `jgem` is JRuby's version of `gem` command.
170
+ RVM allows running `gem` as an alias.
171
+ Otherwise, you may also run `jruby -S gem install ...`
172
+
169
173
  ### Option 2: Bundler
170
174
 
171
175
  Add the following to `Gemfile`:
172
176
  ```
173
- gem 'glimmer', '~> 0.6.0'
177
+ gem 'glimmer', '~> 0.7.0'
174
178
  ```
175
179
 
176
180
  And, then run:
@@ -191,7 +195,7 @@ the glimmer ruby gem and SWT jar dependency.
191
195
 
192
196
  Example:
193
197
  ```
194
- glimmer samples/hello_world.rb
198
+ glimmer samples/hello/hello_world.rb
195
199
  ```
196
200
  This runs the Glimmer "Hello, World!" sample.
197
201
 
@@ -199,30 +203,166 @@ If you cloned this project locally, you may run `bin/glimmer` instead.
199
203
 
200
204
  Example:
201
205
  ```
202
- bin/glimmer samples/hello_world.rb
206
+ bin/glimmer samples/hello/hello_world.rb
203
207
  ```
204
208
 
205
209
  ### Advanced Usage
206
210
 
211
+ Below are the full usage instructions that come up when running `glimmer` without args.
212
+
207
213
  ```
208
- glimmer [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] application.rb [[application2.rb]...]
209
- ```
214
+ Usage: glimmer [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
215
+
216
+ Runs Glimmer applications/tasks.
217
+
218
+ Either a single task or one or more applications may be specified.
219
+
220
+ When a task is specified, it runs via rake. Some tasks take arguments in square brackets.
221
+
222
+ Available tasks are below (you may also lookup by adding `require 'glimmer/rake_task'` in Rakefile and running rake -T):
223
+ glimmer package # Package app for distribution (generating config, jar, and native files)
224
+ glimmer package:config # Generate JAR config file
225
+ glimmer package:jar # Generate JAR file
226
+ glimmer package:native # Generate Native files (DMG/PKG/APP on the Mac)
227
+ glimmer scaffold[app_name] # Scaffold a Glimmer application directory structure to begin building a new app
228
+ glimmer scaffold:custom_shell[custom_shell_name,namespace] # Scaffold a Glimmer::UI::CustomShell subclass (represents a full window view) under app/views (namespace is optional)
229
+ glimmer scaffold:custom_widget[custom_widget_name,namespace] # Scaffold a Glimmer::UI::CustomWidget subclass (represents a part of a view) under app/views (namespace is optional)
230
+ glimmer scaffold:custom_widget_gem[custom_widget_name,namespace] # Scaffold a Glimmer::UI::CustomWidget subclass (represents a part of a view) under its own Ruby gem project (namespace is required)
210
231
 
211
- Accepts JRuby options and multiple Glimmer applications to run simultaneously, each in a JRuby thread.
232
+ When applications are specified, they are run using JRuby,
233
+ automatically preloading the glimmer Ruby gem and SWT jar dependency.
212
234
 
213
- Example (JRuby option):
235
+ Optionally, extra Glimmer options, JRuby options and environment variables may be passed in.
236
+
237
+ Concerning Glimmer options:
238
+ - "--debug" : Displays extra debugging information and passes "--debug" to JRuby
239
+ - "--log-level=VALUE" : Sets Glimmer's Ruby logger level ("ERROR" / "WARN" / "INFO" / "DEBUG"; default is "WARN")
240
+
241
+ Example: glimmer samples/hello/hello_world.rb
242
+
243
+ This runs the Glimmer application samples/hello/hello_world.rb
214
244
  ```
215
- glimmer --debug samples/hello_world.rb
245
+
246
+ Example (Glimmer/JRuby option specified):
247
+ ```
248
+ glimmer --debug samples/hello/hello_world.rb
216
249
  ```
217
250
 
218
251
  Runs Glimmer application with JRuby debug option to enable JRuby debugging.
219
252
 
220
253
  Example (Multiple apps):
221
254
  ```
222
- glimmer samples/hello_world.rb samples/hello_tab.rb
255
+ glimmer samples/hello/hello_world.rb samples/hello_tab.rb
256
+ ```
257
+
258
+ Launches samples/hello/hello_world.rb and samples/hello_tab.rb at the same time, each in a separate JRuby thread.
259
+
260
+ ### Scaffolding
261
+
262
+ Glimmer borrows from Rails the idea of Scaffolding, that is generating a structure for your app files that
263
+ helps you get started just like true building scaffolding helps construction workers, civil engineers, and architects.
264
+
265
+ Glimmer scaffolding goes way beyond just scaffolding the app files that Rails does. It also packages it and launches it,
266
+ getting you to a running and delivered state of an advanced "Hello, World!" Glimmer application right off the bat.
267
+
268
+ This should greatly facilitate building a new Glimmer app by helping you be productive and focus on app details while
269
+ letting Glimmer scaffolding take care of initial app file structure concerns, such as adding:
270
+ - Main application class that includes Glimmer
271
+ - Main application view that houses main window content
272
+ - View and Model directories
273
+ - Rakefile including Glimmer tasks
274
+ - Version
275
+ - License
276
+ - Icon
277
+ - Bin file for starting application
278
+
279
+ #### App
280
+
281
+ Before you start, make sure you are in a JRuby environment with Glimmer gem installed as per "Direct Install" pre-requisites.
282
+
283
+ To scaffold a Glimmer app from scratch, run the following command:
284
+
285
+ ```
286
+ glimmer scaffold[AppName]
287
+ ```
288
+
289
+ This will generate an advanced "Hello, World!" app, package it as a Mac native file (DMG/PKG/APP), and launch it all in one fell swoop.
290
+
291
+ Suppose you run:
292
+
293
+ ```
294
+ glimmer scaffold[CarMaker]
295
+ ```
296
+
297
+ You should see output like the following:
298
+
299
+ ```
300
+ Created CarMaker/.ruby-version
301
+ Created CarMaker/.ruby-gemset
302
+ Created CarMaker/VERSION
303
+ Created CarMaker/LICENSE.txt
304
+ Created CarMaker/Gemfile
305
+ Created CarMaker/Rakefile
306
+ Created CarMaker/app/car_maker.rb
307
+ Created CarMaker/app/views/car_maker/app_view.rb
308
+ Created CarMaker/package/macosx/Car Maker.icns
309
+ Created CarMaker/bin/car_maker
310
+ ...
311
+ ```
312
+
313
+ Eventually, it will launch an advanced "Hello, World!" app window having the title of your application and a Mac icon.
314
+
315
+ ![Glimmer Scaffold App](images/glimmer-scaffolding-app.png)
316
+
317
+ #### Custom Shell
318
+
319
+ To scaffold a Glimmer custom shell (full window view) for an existing Glimmer app, run the following command:
320
+
321
+ ```
322
+ glimmer scaffold:custom_shell[custom_shell_name]
323
+ ```
324
+
325
+ #### Custom Widget
326
+
327
+ To scaffold a Glimmer custom widget (part of a view) for an existing Glimmer app, run the following command:
328
+
329
+ ```
330
+ glimmer scaffold:custom_widget[custom_widget_name]
331
+ ```
332
+
333
+ #### Custom Shell Gem
334
+
335
+ Custom shell gems are self-contained Glimmer apps as well as reusable custom shells.
336
+
337
+ To scaffold a Glimmer custom shell gem (full window view externalized into a gem) for an existing Glimmer app, run the following command:
338
+
339
+ ```
340
+ glimmer scaffold:custom_shell_gem[custom_shell_name, namespace]
341
+ ```
342
+
343
+ It is important to specify a namespace to avoid having your gem clash with existing gems.
344
+
345
+ The Ruby gem name will follow the convention "glimmer-cs-customwidgetname-namespace" (the 'cs' is for Custom Shell)
346
+
347
+ Only official Glimmer gems created by the Glimmer project committers will have no namespace (e.g. "glimmer-cs-gladiator" Ruby gem)
348
+
349
+ Example: [https://github.com/AndyObtiva/glimmer-cs-gladiator](https://github.com/AndyObtiva/glimmer-cs-gladiator)
350
+
351
+ #### Custom Widget Gem
352
+
353
+ To scaffold a Glimmer custom widget gem (part of a view externalized into a gem) for an existing Glimmer app, run the following command:
354
+
223
355
  ```
356
+ glimmer scaffold:custom_widget_gem[custom_widget_name, namespace]
357
+ ```
358
+
359
+ It is important to specify a namespace to avoid having your gem clash with existing gems.
360
+
361
+ The Ruby gem name will follow the convention "glimmer-cw-customwidgetname-namespace" (the 'cw' is for Custom Widget)
224
362
 
225
- Launches samples/hello_world.rb and samples/hello_tab.rb at the same time, each in a separate JRuby thread.
363
+ Only official Glimmer gems created by the Glimmer project committers will have no namespace (e.g. "glimmer-cw-video" Ruby gem)
364
+
365
+ Example: [https://github.com/AndyObtiva/glimmer-cw-video](https://github.com/AndyObtiva/glimmer-cw-video)
226
366
 
227
367
  ## Girb (Glimmer irb) Command
228
368
 
@@ -287,7 +427,7 @@ Every **widget** is sufficiently declared by name, but may optionally be accompa
287
427
  - SWT **style** ***argument*** wrapped by parenthesis according to [Glimmer Style Guide](#glimmer-coding-style) (see [next section](#widget-styles) for details).
288
428
  - Ruby block containing **properties** (widget attributes) and **content** (nested widgets)
289
429
 
290
- For example, if we were to revisit `samples/hello_world.rb` above (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
430
+ For example, if we were to revisit `samples/hello/hello_world.rb` above (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
291
431
 
292
432
  ```ruby
293
433
  shell {
@@ -341,7 +481,7 @@ It is centered upon initial display and has a minimum width of 130 (can be re-ce
341
481
 
342
482
  Check out the [samples](samples) directory for more examples.
343
483
 
344
- Example from [hello_tab.rb](samples/hello_tab.rb) sample (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
484
+ Example from [hello_tab.rb](samples/hello/hello_tab.rb) sample (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
345
485
 
346
486
  ![Hello Tab 1](images/glimmer-hello-tab1.png)
347
487
 
@@ -787,7 +927,7 @@ composite {
787
927
  # ...
788
928
  ```
789
929
 
790
- Here is a more sophisticated example taken from [hello_computed.rb](samples/hellocomputed/hello_computed.rb) sample:
930
+ Here is a more sophisticated example taken from [hello_computed.rb](samples/hello/hello_computed.rb) sample:
791
931
  ```ruby
792
932
  shell {
793
933
  text "Hello Computed"
@@ -970,7 +1110,7 @@ This example demonstrates computed value data binding whereby the value of `name
970
1110
 
971
1111
  This example demonstrates nested indexed computed value data binding whereby the value of `profiles[0].name` depends on changes to both nested `profiles[0].first_name` and `profiles[0].last_name`.
972
1112
 
973
- Example from [samples/hello_combo.rb](samples/hello_combo.rb) sample (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
1113
+ Example from [samples/hello/hello_combo.rb](samples/hello_combo.rb) sample (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
974
1114
 
975
1115
  ![Hello Combo](images/glimmer-hello-combo.png)
976
1116
 
@@ -1015,7 +1155,7 @@ HelloCombo.new.launch
1015
1155
 
1016
1156
  `combo` widget is data-bound to the country of a person. Note that it expects `person` object to have `:country` attribute and `:country_options` attribute containing all available countries.
1017
1157
 
1018
- Example from [samples/hello_list_single_selection.rb](samples/hello_list_single_selection.rb) sample:
1158
+ Example from [samples/hello/hello_list_single_selection.rb](samples/hello_list_single_selection.rb) sample:
1019
1159
 
1020
1160
  ![Hello List Single Selection](images/glimmer-hello-list-single-selection.png)
1021
1161
 
@@ -1039,7 +1179,7 @@ shell {
1039
1179
 
1040
1180
  Nonetheless, in the next example, a multi-selection list is declared instead allowing data-binding of multiple selection values to the bindable attribute on the model.
1041
1181
 
1042
- Example from [samples/hello_list_multi_selection.rb](samples/hello_list_multi_selection.rb) sample (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
1182
+ Example from [samples/hello/hello_list_multi_selection.rb](samples/hello_list_multi_selection.rb) sample (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
1043
1183
 
1044
1184
  ![Hello List Multi Selection](images/glimmer-hello-list-multi-selection.png)
1045
1185
 
@@ -1139,7 +1279,7 @@ shell {
1139
1279
  text bind(@tic_tac_toe_board[row, column], :sign)
1140
1280
  enabled bind(@tic_tac_toe_board[row, column], :empty)
1141
1281
  on_widget_selected {
1142
- @tic_tac_toe_board.mark_box(row, column)
1282
+ @tic_tac_toe_board.mark(row, column)
1143
1283
  }
1144
1284
  }
1145
1285
  }
@@ -1148,9 +1288,9 @@ shell {
1148
1288
  }
1149
1289
  ```
1150
1290
 
1151
- Note that every Tic Tac Toe grid cell has its `text` and `enabled` properties data-bound to the `sign` and `empty` attributes on the `TicTacToeBoard` model respectively.
1291
+ Note that every Tic Tac Toe grid cell has its `text` and `enabled` properties data-bound to the `sign` and `empty` attributes on the `TicTacToe::Board` model respectively.
1152
1292
 
1153
- Next however, each of these Tic Tac Toe grid cells, which are clickable buttons, have an `on_widget_selected` observer, which once triggered, marks the box (cell) on the `TicTacToeBoard` to make a move.
1293
+ Next however, each of these Tic Tac Toe grid cells, which are clickable buttons, have an `on_widget_selected` observer, which once triggered, marks the cell on the `TicTacToe::Board` to make a move.
1154
1294
 
1155
1295
  **Regarding number 2**, you can figure out all available events by looking at the `org.eclipse.swt.SWT` API:
1156
1296
 
@@ -1221,8 +1361,8 @@ class TicTacToe
1221
1361
  def initialize
1222
1362
  # ...
1223
1363
  observe(@tic_tac_toe_board, :game_status) { |game_status|
1224
- display_win_message if game_status == TicTacToeBoard::WIN
1225
- display_draw_message if game_status == TicTacToeBoard::DRAW
1364
+ display_win_message if game_status == Board::WIN
1365
+ display_draw_message if game_status == Board::DRAW
1226
1366
  }
1227
1367
  end
1228
1368
  # ...
@@ -1231,7 +1371,7 @@ end
1231
1371
 
1232
1372
  Observers can be a good mechanism for displaying dialog messages in Glimmer (using SWT's `MessageBox`).
1233
1373
 
1234
- Look at [`samples/tictactoe/tic_tac_toe.rb`](samples/tictactoe/tic_tac_toe.rb) for more details starting with the code included below.
1374
+ Look at [`samples/elaborate/tictactoe/tic_tac_toe.rb`](samples/tictactoe/tic_tac_toe.rb) for more details starting with the code included below.
1235
1375
 
1236
1376
  ```ruby
1237
1377
  class TicTacToe
@@ -1241,8 +1381,8 @@ class TicTacToe
1241
1381
  def initialize
1242
1382
  # ...
1243
1383
  observe(@tic_tac_toe_board, :game_status) { |game_status|
1244
- display_win_message if game_status == TicTacToeBoard::WIN
1245
- display_draw_message if game_status == TicTacToeBoard::DRAW
1384
+ display_win_message if game_status == Board::WIN
1385
+ display_draw_message if game_status == Board::DRAW
1246
1386
  }
1247
1387
  end
1248
1388
 
@@ -1561,11 +1701,12 @@ Also, you may invoke `Display.setAppVersion('1.0.0')` if needed for OS app versi
1561
1701
  #### Multi-DSL Support
1562
1702
 
1563
1703
  Glimmer supports two other DSLs in addition to the SWT DSL; that is Glimmer XML DSL and Glimmer CSS DSL. It also allows mixing DSLs, which comes in handy when doing things like using the `browser` widget. Glimmer automatically recognizes top-level keywords in each DSL
1564
- and switches DSLs accordingly until it finishes processes the top-level keywords, at which point it switches back to the prior DSL.
1704
+ and switches DSLs accordingly. Once done processing a top-level keyword, it switches back to the prior DSL automatically.
1565
1705
 
1566
1706
  For example, the SWT DSL has the following top-level keywords:
1567
1707
  - `shell`
1568
1708
  - `display`
1709
+ - `color`
1569
1710
  - `observe`
1570
1711
  - `async_exec`
1571
1712
  - `sync_exec`
@@ -1599,7 +1740,7 @@ puts @xml
1599
1740
  Output:
1600
1741
 
1601
1742
  ```
1602
- <html><head><meta name=\"viewport\" content=\"width=device-width, initial-scale=2.0\" /></head><body><h1>Hello, World!</h1></body></html>
1743
+ <html><head><meta name="viewport" content="width=device-width, initial-scale=2.0" /></head><body><h1>Hello, World!</h1></body></html>
1603
1744
  ```
1604
1745
 
1605
1746
  Example (explicit XML tag / you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
@@ -1629,7 +1770,7 @@ puts @xml
1629
1770
  Output:
1630
1771
 
1631
1772
  ```
1632
- <w3c:html id=\"thesis\" class=\"document\"><w3c:body id=\"main\"></w3c:body></w3c:html>
1773
+ <w3c:html id="thesis" class="document"><w3c:body id="main"></w3c:body></w3c:html>
1633
1774
  ```
1634
1775
 
1635
1776
  Example (XML namespaces using dot operator / you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
@@ -1656,16 +1797,21 @@ Once done, you may call `to_s` or `to_css` to get the formatted CSS output.
1656
1797
 
1657
1798
  `css` is the only top-level keyword in the Glimmer CSS DSL
1658
1799
 
1800
+ Selectors may be specified by `s` keyword or HTML element keyword directly (e.g. `body`)
1801
+ Rule property values may be specified by `pv` keyword or underscored property name directly (e.g. `font_size`)
1802
+
1659
1803
  Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
1660
1804
 
1661
1805
  ```ruby
1662
1806
  @css = css {
1663
1807
  body {
1664
- font_size "1.1em"
1808
+ font_size '1.1em'
1809
+ pv 'background', 'white'
1665
1810
  }
1666
1811
 
1667
1812
  s('body > h1') {
1668
1813
  background_color :red
1814
+ pv 'font-size', '2em'
1669
1815
  }
1670
1816
  }
1671
1817
  puts @css
@@ -1675,84 +1821,9 @@ puts @css
1675
1821
 
1676
1822
  ![Video Widget](images/glimmer-video-widget.png)
1677
1823
 
1678
- Glimmer comes with a video widget not in SWT. It comes with very basic video functionality at the moment, such as autoplay by default, displaying controls, looping, and setting background.
1679
-
1680
- Options (passed in an options hash as arguments to video widget):
1681
- - `autoplay` (true [default] or false): plays video automatically as soon as loaded
1682
- - `controls` (true [default] or false): displays controls
1683
- - `looped` (true or false [default]): plays video in looped mode
1684
- - `background` (Glimmer color [default: white]): sets background color just like with any other widget
1685
- - `fit_to_width` (true [default] or false): fits video width to widget allotted width regardless of video's original size. Maintains video aspect ratio.
1686
- - `fit_to_height` (true [default] or false): fits video height to widget allotted height regardless of video's original size. Maintains video aspect ratio.
1687
- - `offset_x` (integer [default: 0]): offset from left border. Could be a negative number if you want to show only an area of the video. Useful when fit_to_width is false to pick an area of the video to display.
1688
- - `offset_y` (integer [default: 0]): offset from top border. Could be a negative number if you want to show only an area of the video. Useful when fit_to_height is false to pick an area of the video to display.
1689
-
1690
- Methods:
1691
- - `#play`: plays video
1692
- - `#pause`: pauses video
1693
- - `#reload`: reloads video restarting from beginning
1694
- - `#position`: position in seconds (and fractions)
1695
- - `#position=`: seeks a new position in video
1696
- - `#duration`: length of video, maximum video position possible
1697
- - `#loaded?`: returns true when video has been initially loaded or reloaded
1698
- - `#playing?`: returns true when video is actively playing
1699
- - `#paused?`: returns true when video is not playing
1700
- - `#ended?`: returns true when video has reached the end (position == duration)
1701
-
1702
- Events (to observe):
1703
- - `on_loaded`: invoked when video `#loaded?` becomes true
1704
- - `on_ended`: invoked when video `#ended?` becomes true
1705
- - `on_playing`: invoked when video `#playing?` becomes true
1706
- - `on_paused`: invoked when video `#paused?` becomes true
1707
-
1708
- Example ([samples/video/hello_video.rb](samples/video/hello_video.rb)):
1709
-
1710
- ```ruby
1711
- # ...
1712
- shell {
1713
- video(file: video_file)
1714
- }.open
1715
- ```
1716
-
1717
- Example ([samples/video/hello_looped_video_with_black_background.rb](samples/video/hello_looped_video_with_black_background.rb)):
1718
-
1719
- ```ruby
1720
- # ...
1721
- shell {
1722
- minimum_size 1024, 640
1723
- video(file: video_file, looped: true, background: :black)
1724
- }.open
1725
- ```
1824
+ Glimmer supports a [video custom widget](https://github.com/AndyObtiva/glimmer-cw-video) not in SWT.
1726
1825
 
1727
- Example ([samples/video/hello_video_observers.rb](samples/video/hello_video_observers.rb)):
1728
-
1729
- ```ruby
1730
- # ...
1731
- def display_video_status(video, status)
1732
- message_box = MessageBox.new(video.swt_widget.getShell)
1733
- message_box.setText(status)
1734
- message = "Video Position: #{video.position} seconds\n"
1735
- message += "Video Duration: #{video.duration} seconds"
1736
- message_box.setMessage(message)
1737
- message_box.open
1738
- end
1739
-
1740
- @shell = shell {
1741
- minimum_size 800, 500
1742
- @video = video(file: video_file, background: :black) {
1743
- on_playing {
1744
- display_video_status(@video, 'Playing')
1745
- }
1746
- on_paused {
1747
- display_video_status(@video, 'Paused')
1748
- }
1749
- on_ended {
1750
- display_video_status(@video, 'Ended')
1751
- }
1752
- }
1753
- }
1754
- @shell.open
1755
- ```
1826
+ You may obtain via `glimmer-cw-video` gem.
1756
1827
 
1757
1828
  #### Browser Widget
1758
1829
 
@@ -1822,16 +1893,13 @@ samples/launch
1822
1893
  For "Hello, World!" type samples, check the following:
1823
1894
 
1824
1895
  ```
1825
- glimmer samples/hello_world.rb
1826
- glimmer samples/hello_browser.rb
1827
- glimmer samples/hello_tab.rb
1828
- glimmer samples/hello_combo.rb
1829
- glimmer samples/hello_list_single_selection.rb
1830
- glimmer samples/hello_list_multi_selection.rb
1831
- glimmer samples/hellocomputed/hello_computed.rb
1832
- glimmer samples/video/hello_video.rb
1833
- glimmer samples/video/hello_looped_video_with_black_background.rb
1834
- glimmer samples/video/hello_video_observers.rb
1896
+ glimmer samples/hello/hello_world.rb
1897
+ glimmer samples/hello/hello_browser.rb # demonstrates browser widget
1898
+ glimmer samples/hello/hello_tab.rb # demonstrates tabs
1899
+ glimmer samples/hello/hello_combo.rb # demonstrates combo data-binding
1900
+ glimmer samples/hello/hello_list_single_selection.rb # demonstrates list single-selection data-binding
1901
+ glimmer samples/hello/hello_list_multi_selection.rb # demonstrates list multi-selection data-binding
1902
+ glimmer samples/hello/hello_computed.rb # demonstrates computed data-binding
1835
1903
  ```
1836
1904
 
1837
1905
  ### Elaborate Samples
@@ -1839,42 +1907,15 @@ glimmer samples/video/hello_video_observers.rb
1839
1907
  For more elaborate samples, check the following:
1840
1908
 
1841
1909
  ```
1842
- glimmer samples/login.rb # demonstrates basic data-binding
1843
- glimmer samples/contactmanager/contact_manager.rb # demonstrates table data-binding
1844
- glimmer samples/tictactoe/tic_tac_toe.rb # demonstrates a full MVC application
1845
- glimmer samples/gladiator.rb # demonstrates a text editor with tree/list data-binding
1910
+ glimmer samples/elaborate/login.rb # demonstrates general data-binding
1911
+ glimmer samples/elaborate/contact_manager.rb # demonstrates table data-binding
1912
+ glimmer samples/elaborate/tic_tac_toe.rb # demonstrates a full MVC application
1846
1913
  ```
1847
1914
 
1848
1915
  ![Gladiator](images/glimmer-gladiator.png)
1849
1916
 
1850
- Gladiator (short for Glimmer Editor) is an on-going sample project under continuous development. It is used as the main text editor for developing Glimmer.
1851
-
1852
- It currently supports the following text editing features:
1853
- - File explorer navigation to open file
1854
- - File lookup by name
1855
- - Find & Replace
1856
- - Show Line Numbers
1857
- - Jump to Line
1858
- - Remember last opened file, caret position, and top line
1859
- - Autosave on focus out/quit/open new file
1860
- - Watch open file for external changes to reflect in editor
1861
- - Duplicate Line(s)
1862
- - Kill Line(s)
1863
- - Move up one line
1864
- - Move down one line
1865
-
1866
- Gladiator has been made available in [Glimmer's gem](https://rubygems.org/gems/glimmer) via the `gladiator` command should others find useful too.
1867
-
1868
- If you cloned this project and followed [CONTRIBUTING.md](CONTRIBUTING.md) instructions, you may invoke via `bin/gladiator` instead.
1869
-
1870
- Gotcha:
1871
-
1872
- Gladiator repetitively displays a signaling error that is harmless in practice:
1873
- ```
1874
- The signal HUP is in use by the JVM and will not work correctly on this platform
1875
- The signal INT is in use by the JVM and will not work correctly on this platform
1876
- The signal TERM is in use by the JVM and will not work correctly on this platform
1877
- ```
1917
+ [Gladiator](https://github.com/AndyObtiva/glimmer-cs-gladiator) (short for Glimmer Editor) is a Glimmer sample project under on-going development.
1918
+ You may check it out to learn how to build a Glimmer Custom Shell gem.
1878
1919
 
1879
1920
  ## In Production
1880
1921
 
@@ -1944,11 +1985,12 @@ https://github.com/jruby/jruby/wiki/CallingJavaFromJRuby
1944
1985
 
1945
1986
  ## Logging
1946
1987
 
1947
- Glimmer comes with a Ruby Logger accessible via `Glimmer.logger`
1988
+ Glimmer comes with a Ruby Logger accessible via `Glimmer::Config.logger`
1948
1989
  Its level of logging defaults to `Logger::WARN`
1949
1990
  It may be configured to show a different level of logging as follows:
1950
1991
  ```ruby
1951
- Glimmer.logger&.level = Logger::DEBUG
1992
+ Glimmer::Config.enable_logging
1993
+ Glimmer::Config.logger.level = Logger::DEBUG
1952
1994
  ```
1953
1995
  This results in more verbose debugging log to `STDOUT`, which is helpful in troubleshooting Glimmer DSL syntax when needed.
1954
1996
 
@@ -2048,6 +2090,7 @@ In order to explicitly configure javapackager, Mac package attributes, or sign y
2048
2090
  - https://docs.oracle.com/javase/8/docs/technotes/tools/unix/javapackager.html
2049
2091
  - https://docs.oracle.com/javase/8/docs/technotes/guides/deploy/self-contained-packaging.html#BCGICFDB
2050
2092
  - https://docs.oracle.com/javase/8/docs/technotes/guides/deploy/self-contained-packaging.html
2093
+ - https://developer.apple.com/library/archive/releasenotes/General/SubmittingToMacAppStore/index.html#//apple_ref/doc/uid/TP40010572-CH16-SW8
2051
2094
 
2052
2095
  The Glimmer rake task allows passing extra options to javapackager via:
2053
2096
  - `Glimmer::Packager.javapackager_extra_args="..."` in your application Rakefile
@@ -2056,9 +2099,13 @@ The Glimmer rake task allows passing extra options to javapackager via:
2056
2099
  Example (Rakefile):
2057
2100
 
2058
2101
  ```ruby
2059
- Glimmer::Package.javapackager_extra_args = '-BlicenseType="MIT" -Bmac.category="arithmetic" -Bmac.signing-key-developer-id-app="Andy Maleh"'
2102
+ Glimmer::Package.javapackager_extra_args = '-BlicenseType="MIT" -Bmac.category="public.app-category.business" -Bmac.signing-key-developer-id-app="Andy Maleh"'
2060
2103
  ```
2061
2104
 
2105
+ Note that `mac.category` defaults to "public.app-category.business", but can be overridden with one of the category UTI values mentioned here:
2106
+
2107
+ https://developer.apple.com/library/archive/releasenotes/General/SubmittingToMacAppStore/index.html#//apple_ref/doc/uid/TP40010572-CH16-SW8
2108
+
2062
2109
  Example (env var):
2063
2110
 
2064
2111
  ```
@@ -2126,7 +2173,11 @@ Glimmer::Package.javapackager_extra_args = '-srcfiles "ACME.txt" -BlicenseFile="
2126
2173
 
2127
2174
  If you run `rake glimmer:package` multiple times, sometimes it leaves a mounted DMG project in your finder. Unmount before you run the command again or it might fail with an error saying: "Error: Bundler "DMG Installer" (dmg) failed to produce a bundle."
2128
2175
 
2129
- By the way, keep in mind that during normal operation, it does also indicate a false-negative while completing successfully (please ignore): "Exec failed with code 2 command [[/usr/bin/SetFile, -c, icnC, /var/folders/4_/g1sw__tx6mjdgyh3mky7vydc0000gp/T/fxbundler4076750801763032201/images/MathBowling/.VolumeIcon.icns] in unspecified directory"
2176
+ By the way, keep in mind that during normal operation, it does also indicate a false-negative while completing successfully similar to the following (please ignore):
2177
+
2178
+ ```
2179
+ Exec failed with code 2 command [[/usr/bin/SetFile, -c, icnC, /var/folders/4_/g1sw__tx6mjdgyh3mky7vydc0000gp/T/fxbundler4076750801763032201/images/MathBowling/.VolumeIcon.icns] in unspecified directory
2180
+ ```
2130
2181
 
2131
2182
  ## Resources
2132
2183