glimmer 0.7.8 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +232 -108
  4. data/VERSION +1 -1
  5. data/lib/glimmer.rb +1 -20
  6. data/lib/glimmer/config.rb +0 -13
  7. data/lib/glimmer/dsl/engine.rb +33 -18
  8. data/lib/glimmer/dsl/expression.rb +0 -7
  9. data/lib/glimmer/dsl/static_expression.rb +2 -2
  10. metadata +48 -172
  11. data/RUBY_VERSION +0 -1
  12. data/bin/girb +0 -10
  13. data/bin/girb_runner.rb +0 -13
  14. data/bin/glimmer +0 -5
  15. data/icons/scaffold_app.icns +0 -0
  16. data/lib/glimmer/css/rule.rb +0 -25
  17. data/lib/glimmer/css/style_sheet.rb +0 -19
  18. data/lib/glimmer/data_binding/list_selection_binding.rb +0 -52
  19. data/lib/glimmer/data_binding/model_binding.rb +0 -248
  20. data/lib/glimmer/data_binding/observable.rb +0 -21
  21. data/lib/glimmer/data_binding/observable_array.rb +0 -107
  22. data/lib/glimmer/data_binding/observable_model.rb +0 -108
  23. data/lib/glimmer/data_binding/observable_widget.rb +0 -17
  24. data/lib/glimmer/data_binding/observer.rb +0 -124
  25. data/lib/glimmer/data_binding/shine.rb +0 -23
  26. data/lib/glimmer/data_binding/table_items_binding.rb +0 -47
  27. data/lib/glimmer/data_binding/tree_items_binding.rb +0 -71
  28. data/lib/glimmer/data_binding/widget_binding.rb +0 -33
  29. data/lib/glimmer/dsl/css/css_expression.rb +0 -21
  30. data/lib/glimmer/dsl/css/dsl.rb +0 -10
  31. data/lib/glimmer/dsl/css/dynamic_property_expression.rb +0 -12
  32. data/lib/glimmer/dsl/css/property_expression.rb +0 -22
  33. data/lib/glimmer/dsl/css/pv_expression.rb +0 -17
  34. data/lib/glimmer/dsl/css/rule_expression.rb +0 -25
  35. data/lib/glimmer/dsl/css/s_expression.rb +0 -26
  36. data/lib/glimmer/dsl/swt/async_exec_expression.rb +0 -14
  37. data/lib/glimmer/dsl/swt/bind_expression.rb +0 -37
  38. data/lib/glimmer/dsl/swt/color_expression.rb +0 -19
  39. data/lib/glimmer/dsl/swt/column_properties_expression.rb +0 -24
  40. data/lib/glimmer/dsl/swt/combo_selection_data_binding_expression.rb +0 -42
  41. data/lib/glimmer/dsl/swt/custom_widget_expression.rb +0 -36
  42. data/lib/glimmer/dsl/swt/data_binding_expression.rb +0 -34
  43. data/lib/glimmer/dsl/swt/dialog_expression.rb +0 -26
  44. data/lib/glimmer/dsl/swt/display_expression.rb +0 -19
  45. data/lib/glimmer/dsl/swt/dsl.rb +0 -28
  46. data/lib/glimmer/dsl/swt/exec_expression.rb +0 -28
  47. data/lib/glimmer/dsl/swt/layout_data_expression.rb +0 -25
  48. data/lib/glimmer/dsl/swt/layout_expression.rb +0 -27
  49. data/lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb +0 -44
  50. data/lib/glimmer/dsl/swt/menu_bar_expression.rb +0 -33
  51. data/lib/glimmer/dsl/swt/menu_expression.rb +0 -32
  52. data/lib/glimmer/dsl/swt/observe_expression.rb +0 -32
  53. data/lib/glimmer/dsl/swt/property_expression.rb +0 -22
  54. data/lib/glimmer/dsl/swt/rgb_expression.rb +0 -12
  55. data/lib/glimmer/dsl/swt/rgba_expression.rb +0 -12
  56. data/lib/glimmer/dsl/swt/shell_expression.rb +0 -25
  57. data/lib/glimmer/dsl/swt/swt_expression.rb +0 -25
  58. data/lib/glimmer/dsl/swt/sync_exec_expression.rb +0 -15
  59. data/lib/glimmer/dsl/swt/tab_item_expression.rb +0 -33
  60. data/lib/glimmer/dsl/swt/table_items_data_binding_expression.rb +0 -31
  61. data/lib/glimmer/dsl/swt/tree_items_data_binding_expression.rb +0 -31
  62. data/lib/glimmer/dsl/swt/tree_properties_expression.rb +0 -26
  63. data/lib/glimmer/dsl/swt/widget_expression.rb +0 -34
  64. data/lib/glimmer/dsl/swt/widget_listener_expression.rb +0 -32
  65. data/lib/glimmer/dsl/xml/dsl.rb +0 -11
  66. data/lib/glimmer/dsl/xml/html_expression.rb +0 -25
  67. data/lib/glimmer/dsl/xml/meta_expression.rb +0 -23
  68. data/lib/glimmer/dsl/xml/name_space_expression.rb +0 -37
  69. data/lib/glimmer/dsl/xml/node_parent_expression.rb +0 -33
  70. data/lib/glimmer/dsl/xml/tag_expression.rb +0 -29
  71. data/lib/glimmer/dsl/xml/text_expression.rb +0 -22
  72. data/lib/glimmer/dsl/xml/xml_expression.rb +0 -21
  73. data/lib/glimmer/launcher.rb +0 -199
  74. data/lib/glimmer/package.rb +0 -7
  75. data/lib/glimmer/rake_task.rb +0 -89
  76. data/lib/glimmer/scaffold.rb +0 -588
  77. data/lib/glimmer/swt/color_proxy.rb +0 -53
  78. data/lib/glimmer/swt/display_proxy.rb +0 -74
  79. data/lib/glimmer/swt/font_proxy.rb +0 -72
  80. data/lib/glimmer/swt/layout_data_proxy.rb +0 -84
  81. data/lib/glimmer/swt/layout_proxy.rb +0 -82
  82. data/lib/glimmer/swt/menu_proxy.rb +0 -84
  83. data/lib/glimmer/swt/packages.rb +0 -13
  84. data/lib/glimmer/swt/shell_proxy.rb +0 -170
  85. data/lib/glimmer/swt/swt_proxy.rb +0 -106
  86. data/lib/glimmer/swt/tab_item_proxy.rb +0 -65
  87. data/lib/glimmer/swt/tree_proxy.rb +0 -120
  88. data/lib/glimmer/swt/widget_listener_proxy.rb +0 -34
  89. data/lib/glimmer/swt/widget_proxy.rb +0 -489
  90. data/lib/glimmer/ui/custom_shell.rb +0 -45
  91. data/lib/glimmer/ui/custom_widget.rb +0 -244
  92. data/lib/glimmer/util/proc_tracker.rb +0 -16
  93. data/lib/glimmer/xml/depth_first_search_iterator.rb +0 -22
  94. data/lib/glimmer/xml/name_space_visitor.rb +0 -21
  95. data/lib/glimmer/xml/node.rb +0 -75
  96. data/lib/glimmer/xml/node_visitor.rb +0 -13
  97. data/lib/glimmer/xml/xml_visitor.rb +0 -65
  98. data/vendor/swt/linux/swt.jar +0 -0
  99. data/vendor/swt/mac/swt.jar +0 -0
  100. data/vendor/swt/windows/swt.jar +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a3d10cd74668598ac83511994d117f3b99f7332d798d671ddc412dcac3c92fa
4
- data.tar.gz: 1daf7b7330d0e73790ec98c5ef3afdf3f991f0f447f5b72ce47bc70901bb8baa
3
+ metadata.gz: 9a0e5867d64de61a6733bb4946eb3b366ae854a72bf99cdc048707c00cd9c276
4
+ data.tar.gz: b3735c7bff7ee61219f822378b59077e00f9957ed1031b09fd1e3f461eb90868
5
5
  SHA512:
6
- metadata.gz: 81136d0e73a2e26f01bc16b8986f8569910a63509730766d6cb70a533e1fbe38fdce3bfc7e0488d5bbe2a76e10413a46b0765811960698f70a343d45ab3c78a2
7
- data.tar.gz: e20bab1be17773690ac997385921e47520e324afe3b4efcf0f0b6ae4dcf00cd6bcaea9b36c048c9c1eec54023af4c853e8c9aaa55138b40fa58f4262cbd09872
6
+ metadata.gz: b5e181bff40082c4620fc6ad1a306af61c7d59e24a30c13c6038606f008d9480da5532d07a704d0c39563318c23935efb909f958f596b7c49c5f2a6843ace165
7
+ data.tar.gz: 0562d569471bb792943cac85d0c3a79462573074e1ad634fb0aac1f1e9b53bbe9121d8534f9ea1ce94f5b30b0c47947618e73938e38d72695cecbfba48684210
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011 Andy Maleh
1
+ Copyright (c) 2011-2020 Andy Maleh
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
- # Glimmer 0.7.8 Beta (Desktop Development Library for Ruby)
1
+ # Glimmer - Ruby Desktop Development GUI Library
2
2
  [![Gem Version](https://badge.fury.io/rb/glimmer.svg)](http://badge.fury.io/rb/glimmer)
3
3
  [![Travis CI](https://travis-ci.com/AndyObtiva/glimmer.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer)
4
- [![Test Coverage](https://api.codeclimate.com/v1/badges/38fbc278022862794414/test_coverage)](https://codeclimate.com/github/AndyObtiva/glimmer/test_coverage)
5
- [![Maintainability](https://api.codeclimate.com/v1/badges/38fbc278022862794414/maintainability)](https://codeclimate.com/github/AndyObtiva/glimmer/maintainability)
6
4
 
7
5
  Glimmer is a native-GUI 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 GUI with domain models. As a result, that achieves true decoupling of object oriented components, enabling developers to solve business problems without worrying about GUI concerns, or alternatively drive development GUI-first, and then write clean business models test-first afterwards.
8
6
 
@@ -71,11 +69,13 @@ Glimmer app:
71
69
 
72
70
  ![Tic Tac Toe](images/glimmer-tic-tac-toe.png)
73
71
 
74
- NOTE: Glimmer is in beta mode. Please help make better by adopting for small or low risk projects and providing feedback.
72
+ NOTE: Glimmer is in beta mode. Please help make better by [contributing](#contributing), adopting for small or low risk projects, and providing feedback.
75
73
 
76
- ## Table of Contents
74
+ Ruby is a dynamically-typed object-oriented language, which provides great productivity gains due to its powerful expressive syntax and dynamic nature. While it is proven by the Ruby on Rails framework for web development, it currently lacks a robust platform-independent framework for building desktop applications. Given that Java libraries can now be utilized in Ruby code through JRuby, Eclipse technologies, such as SWT, JFace, and RCP can help fill the gap of desktop application development with Ruby.
75
+
76
+ ## Table of contents
77
77
 
78
- - [Glimmer 0.7.8 Beta (Desktop Development Library for Ruby)](#glimmer-078-beta-desktop-development-library-for-ruby)
78
+ - [Glimmer - Ruby Desktop Development GUI Library](#glimmer---ruby-desktop-development-gui-library)
79
79
  - [Examples](#examples)
80
80
  - [Hello, World!](#hello-world)
81
81
  - [Tic Tac Toe](#tic-tac-toe)
@@ -89,23 +89,55 @@ NOTE: Glimmer is in beta mode. Please help make better by adopting for small or
89
89
  - [Basic Usage](#basic-usage)
90
90
  - [Advanced Usage](#advanced-usage)
91
91
  - [Scaffolding](#scaffolding)
92
+ - [App](#app)
93
+ - [Custom Shell](#custom-shell)
94
+ - [Custom Widget](#custom-widget)
95
+ - [Custom Shell Gem](#custom-shell-gem)
96
+ - [Custom Widget Gem](#custom-widget-gem)
92
97
  - [Girb (Glimmer irb) Command](#girb-glimmer-irb-command)
93
98
  - [Glimmer DSL Syntax](#glimmer-dsl-syntax)
94
99
  - [Widgets](#widgets)
100
+ - [Display](#display)
101
+ - [SWT Proxies](#swt-proxies)
102
+ - [Dialog](#dialog)
103
+ - [Menus](#menus)
95
104
  - [Widget Styles](#widget-styles)
105
+ - [Explicit SWT Style Bit](#explicit-swt-style-bit)
106
+ - [Negative SWT Style Bits](#negative-swt-style-bits)
107
+ - [Extra SWT Styles](#extra-swt-styles)
96
108
  - [Widget Properties](#widget-properties)
109
+ - [Colors](#colors)
110
+ - [Fonts](#fonts)
97
111
  - [Layouts](#layouts)
98
112
  - [Layout Data](#layout-data)
99
113
  - [Data-Binding](#data-binding)
114
+ - [General Examples](#general-examples)
115
+ - [Combo](#combo)
116
+ - [List](#list)
117
+ - [Table](#table)
118
+ - [Tree](#tree)
100
119
  - [Observer](#observer)
120
+ - [Observing Widgets](#observing-widgets)
121
+ - [Observing Models](#observing-models)
101
122
  - [Custom Widgets](#custom-widgets)
123
+ - [Simple Example](#simple-example)
124
+ - [Hook Example](#hook-example)
125
+ - [Content/Options Example](#contentoptions-example)
126
+ - [Gotcha](#gotcha)
102
127
  - [Custom Shells](#custom-shells)
103
128
  - [Miscellaneous](#miscellaneous)
129
+ - [Multi-DSL Support](#multi-dsl-support)
130
+ - [Application Menu Items (About/Preferences)](#application-menu-items-aboutpreferences)
131
+ - [App Name and Version](#app-name-and-version)
132
+ - [Video Widget](#video-widget)
133
+ - [Browser Widget](#browser-widget)
104
134
  - [Glimmer Style Guide](#glimmer-style-guide)
105
135
  - [Samples](#samples)
106
136
  - [Hello Samples](#hello-samples)
107
137
  - [Elaborate Samples](#elaborate-samples)
108
138
  - [External Samples](#external-samples)
139
+ - [Glimmer Calculator](#glimmer-calculator)
140
+ - [Gladiator](#gladiator)
109
141
  - [In Production](#in-production)
110
142
  - [SWT Reference](#swt-reference)
111
143
  - [SWT Packages](#swt-packages)
@@ -150,12 +182,11 @@ More info about the SWT GUI on various platforms can be found on the Eclipse WIK
150
182
  https://wiki.eclipse.org/SWT/Devel/Gtk/Dev_guide#Win32.2FCocoa.2FGTK
151
183
  https://www.eclipse.org/swt/faq.php
152
184
 
153
-
154
185
  ## Pre-requisites
155
186
 
156
187
  - SWT 4.15 (comes included in Glimmer gem)
157
188
  - JRuby 9.2.11.1 (supporting Ruby 2.5.x syntax) (find at [https://www.jruby.org/download](https://www.jruby.org/download))
158
- - Java SE Runtime Environment 7 or higher (find at [https://www.oracle.com/java/technologies/javase-downloads.html](https://www.oracle.com/java/technologies/javase-downloads.html))
189
+ - JDK 8 - 10 (find at [https://www.oracle.com/java/technologies/javase-downloads.html](https://www.oracle.com/java/technologies/javase-downloads.html))
159
190
  - (Optional) RVM is needed for [Scaffolding](#scaffolding) only (find at [https://rvm.io/](https://rvm.io/))
160
191
 
161
192
  On **Mac** and **Linux**, an easy way to obtain JRuby is through [RVM](http://rvm.io) by running:
@@ -174,7 +205,7 @@ Please follow these instructions to make the `glimmer` command available on your
174
205
 
175
206
  Run this command to install directly:
176
207
  ```
177
- jgem install glimmer -v 0.7.8
208
+ jgem install glimmer-dsl-swt -v 0.1.0
178
209
  ```
179
210
 
180
211
  `jgem` is JRuby's version of `gem` command.
@@ -185,7 +216,7 @@ Otherwise, you may also run `jruby -S gem install ...`
185
216
 
186
217
  Add the following to `Gemfile`:
187
218
  ```
188
- gem 'glimmer', '~> 0.7.8'
219
+ gem 'glimmer-dsl-swt', '~> 0.1.0'
189
220
  ```
190
221
 
191
222
  And, then run:
@@ -193,6 +224,8 @@ And, then run:
193
224
  jruby -S bundle install
194
225
  ```
195
226
 
227
+ You may learn more about other Glimmer related gems at [Multi-DSL Support](#multi-dsl-support)
228
+
196
229
  ## Glimmer Command
197
230
 
198
231
  ### Basic Usage
@@ -247,7 +280,7 @@ automatically preloading the glimmer Ruby gem and SWT jar dependency.
247
280
  Optionally, extra Glimmer options, JRuby options and environment variables may be passed in.
248
281
 
249
282
  Glimmer options:
250
- - "--quiet" : Does not announce file path of Glimmer application being launched nor enable logging
283
+ - "--quiet" : Does not announce file path of Glimmer application being launched
251
284
  - "--debug" : Displays extra debugging information, passes "--debug" to JRuby, and enables debug logging
252
285
  - "--log-level=VALUE" : Sets Glimmer's Ruby logger level ("ERROR" / "WARN" / "INFO" / "DEBUG"; default is none)
253
286
 
@@ -394,7 +427,7 @@ With Glimmer installed, you may want to run `girb` instead of standard `irb` to
394
427
  girb
395
428
  ```
396
429
 
397
- If you cloned this project locally, you may run `bin/girb` instead.
430
+ If you cloned [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) project locally, you may run `bin/girb` instead.
398
431
 
399
432
  ```
400
433
  bin/girb
@@ -402,6 +435,8 @@ bin/girb
402
435
 
403
436
  Watch out for hands-on examples in this README indicated by "you may copy/paste in [`girb`](#girb-glimmer-irb-command)"
404
437
 
438
+ Keep in mind that all samples live under [https://github.com/AndyObtiva/glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt)
439
+
405
440
  ## Glimmer DSL Syntax
406
441
 
407
442
  Glimmer DSL syntax consists of static keywords and dynamic keywords to build and bind user-interface objects.
@@ -632,7 +667,7 @@ Shell widget proxy has extra methods specific to SWT Shell:
632
667
 
633
668
  Dialog is a variation on Shell. It is basically a shell that is modal (blocks what's behind it) and belongs to another shell. It only has a close button.
634
669
 
635
- Glimmer facilitates building dialogs by using the `dialog` keyword, which automatically adds the SWT::DIALOG_TRIM and SWT::APPLICATION_MODAL [widget styles](#widget-styles) needed for a dialog.
670
+ Glimmer facilitates building dialogs by using the `dialog` keyword, which automatically adds the SWT.DIALOG_TRIM and SWT.APPLICATION_MODAL [widget styles](#widget-styles) needed for a dialog.
636
671
 
637
672
  #### Menus
638
673
 
@@ -1100,7 +1135,7 @@ https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/
1100
1135
 
1101
1136
  Data-binding is done with `bind` command following widget property to bind and taking model and bindable attribute as arguments.
1102
1137
 
1103
- #### General data-binding examples:
1138
+ #### General Examples
1104
1139
 
1105
1140
  `text bind(contact, :first_name)`
1106
1141
 
@@ -1271,7 +1306,62 @@ The Glimmer code is not much different from above except for passing the `:multi
1271
1306
 
1272
1307
  Note that in all the data-binding examples above, there was also an observer attached to the `button` widget to trigger an action on the model, which in turn triggers a data-binding update on the `list` or `combo`. Observers will be discussed in more details in the [next section](#observer).
1273
1308
 
1274
- You may learn more about Glimmer's data-binding syntax by reading the [Eclipse Zone Tutorial](http://eclipse.dzone.com/articles/an-introduction-glimmer) mentioned in resources and opening up the samples under the [samples](samples) directory.
1309
+ You may learn more about Glimmer's data-binding syntax by reading the code under the [samples](samples) directory.
1310
+
1311
+ #### Table
1312
+
1313
+ The SWT Tree widget renders a multi-column data table, such as a contact listing or a sales report.
1314
+
1315
+ To data-bind a Table, you need the main model, the collection property, and the text display attribute for each table column.
1316
+
1317
+ This involves using the `bind` keyword mentioned above in addition to a special `column_properties` keyword that takes the table column text attribute methods.
1318
+
1319
+ It assumes you have defined the table columns via `table_column` widget.
1320
+
1321
+ Example:
1322
+
1323
+ ```ruby
1324
+ shell {
1325
+ @table = table {
1326
+ table_column {
1327
+ text "Name"
1328
+ width 120
1329
+ }
1330
+ table_column {
1331
+ text "Age"
1332
+ width 120
1333
+ }
1334
+ table_column {
1335
+ text "Adult"
1336
+ width 120
1337
+ }
1338
+ items bind(group, :people), column_properties(:name, :age, :adult)
1339
+ selection bind(group, :selected_person)
1340
+ }
1341
+ }
1342
+ ```
1343
+
1344
+ The code above includes two data-bindings:
1345
+ - Table `items`, which first bind to the model collection property (group.people), and then maps each column property (name, age, adult) for displaying each table item column.
1346
+ - Table `selection`, which binds the single table item selected by the user to the attribute denoted by the `bind` keyword (or binds multiple table items selected for a table with `:multi` SWT style)
1347
+
1348
+ Additionally, Table `items` data-binding automatically stores each node model unto the SWT TableItem object via `setData` method. This enables things like searchability.
1349
+
1350
+ The table widget in Glimmer is represented by a subclass of `WidgetProxy` called `TableProxy`.
1351
+ TableProxy includes a `search` method that takes a block to look for a table item.
1352
+
1353
+ Example:
1354
+
1355
+ ```ruby
1356
+ found_array = @table.search { |table_item| table_item.getData == company.owner }
1357
+ ```
1358
+
1359
+ This finds a person. The array is a Java array. This enables easy passing of it to SWT `Table#setSelection` method, which expects a Java array of `TableItem` objects.
1360
+
1361
+ To edit a table, you must invoke `TableProxy#edit_selected_table_item(column_index, before_write: nil, after_write: nil, after_cancel: nil)` or `TableProxy#edit_table_item(table_item, column_index, before_write: nil, after_write: nil, after_cancel: nil)`.
1362
+ This automatically leverages the SWT TableEditor custom class behind the scenes, displaying a text widget to the user to change the selected or
1363
+ passed table item text into something else.
1364
+ It automatically persists the change to `items` data-bound model on ENTER/FOCUS-OUT or cancels on ESC/NO-CHANGE.
1275
1365
 
1276
1366
  #### Tree
1277
1367
 
@@ -1324,7 +1414,7 @@ Glimmer supports observing widgets with two main types of events:
1324
1414
 
1325
1415
  Additionally, there are two more types of events:
1326
1416
  - SWT `display` supports global listeners called filters that run on any widget. They are hooked via `on_event_{swt-event-constant}`
1327
- - the `shell` widget supports Mac application menu item observers (`on_about` and `on_preferences`), which you can read about under [Miscellaneous](#miscellaneous).
1417
+ - SWT `display` supports Mac application menu item observers (`on_about` and `on_preferences`), which you can read about under [Miscellaneous](#miscellaneous).
1328
1418
 
1329
1419
  Number 1 is more commonly used in SWT applications, so make it your starting point. Number 2 covers events not found in number 1, so look into it if you don't find an SWT listener you need in number 1.
1330
1420
 
@@ -1487,7 +1577,9 @@ Glimmer supports creating custom widgets with minimal code, which automatically
1487
1577
 
1488
1578
  Simply create a new class that includes `Glimmer::UI::CustomWidget` and put Glimmer DSL code in its `#body` block (its return value is stored in `#body_root` attribute). Glimmer will then automatically recognize this class by convention when it encounters a keyword matching the class name converted to underscored lowercase (and namespace double-colons `::` replaced with double-underscores `__`)
1489
1579
 
1490
- #### Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
1580
+ #### Simple Example
1581
+
1582
+ (you may copy/paste in [`girb`](#girb-glimmer-irb-command))
1491
1583
 
1492
1584
  Definition:
1493
1585
  ```ruby
@@ -1513,7 +1605,9 @@ shell {
1513
1605
 
1514
1606
  As you can see, `RedLabel` became Glimmer DSL keyword: `red_label`
1515
1607
 
1516
- #### Another Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
1608
+ #### Hook Example
1609
+
1610
+ (you may copy/paste in [`girb`](#girb-glimmer-irb-command))
1517
1611
 
1518
1612
  Definition:
1519
1613
  ```ruby
@@ -1559,10 +1653,12 @@ Custom Widgets have the following attributes available to call from inside the `
1559
1653
  - `#swt_widget`: actual SWT widget for `body_root`
1560
1654
 
1561
1655
  Additionally, custom widgets can call the following class methods:
1562
- - `.options`: declares a list of options by taking an option name array (symbols/strings). This generates option attribute accessors (e.g. `options :orientation, :bg_color` generates `#orientation`, `#orientation=(v)`, `#bg_color`, and `#bg_color=(v)` attribute accessors)
1563
- - `.option`: declares a single option taking option name and default value as arguments (also generates attribute accessors just like `.options`)
1656
+ - `::options(*option_names)`: declares a list of options by taking an option name array (symbols/strings). This generates option attribute accessors (e.g. `options :orientation, :bg_color` generates `#orientation`, `#orientation=(v)`, `#bg_color`, and `#bg_color=(v)` attribute accessors)
1657
+ - `::option(option_name, default: nil)`: declares a single option taking option name and default value as arguments (also generates attribute accessors just like `::options`)
1658
+
1659
+ #### Content/Options Example
1564
1660
 
1565
- #### Content/Options Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
1661
+ (you may copy/paste in [`girb`](#girb-glimmer-irb-command))
1566
1662
 
1567
1663
  Definition:
1568
1664
  ```ruby
@@ -1570,7 +1666,7 @@ class Sandwich
1570
1666
  include Glimmer::UI::CustomWidget
1571
1667
 
1572
1668
  options :orientation, :bg_color
1573
- option :fg_color, :black
1669
+ option :fg_color, default: :black
1574
1670
 
1575
1671
  body {
1576
1672
  composite(swt_style) { # gets custom widget style
@@ -1703,83 +1799,19 @@ shell { |app_shell|
1703
1799
 
1704
1800
  ### Miscellaneous
1705
1801
 
1706
- #### Application Menu Items (About/Preferences)
1707
-
1708
- Mac applications always have About and Preferences menu items. Glimmer provides widget observer hooks for them on the `shell` widget:
1709
- - `on_about`: executes code when user selects App Name -> About
1710
- - `on_preferences`: executes code when user selects App Name -> Preferences or hits 'CMD+,' on the Mac
1711
-
1712
- Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
1713
-
1714
- ```ruby
1715
- shell { |shell_proxy|
1716
- text 'Application Menu Items'
1717
- fill_layout {
1718
- margin_width 15
1719
- margin_height 15
1720
- }
1721
- label {
1722
- text 'Application Menu Items'
1723
- font height: 30
1724
- }
1725
- on_about {
1726
- message_box = MessageBox.new(shell_proxy.swt_widget)
1727
- message_box.setText("About")
1728
- message_box.setMessage("About Application")
1729
- message_box.open
1730
- }
1731
- on_preferences {
1732
- preferences_dialog = shell(:dialog_trim, :application_modal) {
1733
- text 'Preferences'
1734
- row_layout {
1735
- type :vertical
1736
- margin_left 15
1737
- margin_top 15
1738
- margin_right 15
1739
- margin_bottom 15
1740
- }
1741
- label {
1742
- text 'Check one of these options:'
1743
- }
1744
- button(:radio) {
1745
- text 'Option 1'
1746
- }
1747
- button(:radio) {
1748
- text 'Option 2'
1749
- }
1750
- }
1751
- preferences_dialog.open
1752
- }
1753
- }.open
1754
- ```
1755
-
1756
- #### App Name and Version
1757
-
1758
- Application name (shows up on the Mac in top menu bar) and version may be specified upon [packaging](#packaging--distribution) by specifying "-Bmac.CFBundleName" and "-Bmac.CFBundleVersion" options.
1759
-
1760
- Still, if you would like proper application name to show up on the Mac top menu bar during development, you may do so by invoking the SWT Display.setAppName method before any Display object has been instantiated (i.e. before any Glimmer widget like shell has been declared).
1761
-
1762
- Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
1763
-
1764
- ```ruby
1765
- Display.setAppName('Glimmer Demo')
1766
-
1767
- shell(:no_resize) {
1768
- text "Glimmer"
1769
- label {
1770
- text "Hello, World!"
1771
- }
1772
- }.open
1773
- ```
1802
+ #### Multi-DSL Support
1774
1803
 
1775
- Also, you may invoke `Display.setAppVersion('1.0.0')` if needed for OS app version identification reasons during development, replacing `'1.0.0'` with your application version.
1804
+ Glimmer is a DSL engine that supports multiple DSLs (Domain Specific Languages):
1805
+ - [SWT](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (Desktop GUI)
1806
+ - [Opal](https://github.com/AndyObtiva/glimmer-dsl-opal): Glimmer DSL for Opal (Web GUI Adapter for Desktop Apps)
1807
+ - [XML](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML) - Useful with [SWT Browser Widget](#browser-widget)
1808
+ - [CSS](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS (Cascading Style Sheets) - Useful with [SWT Browser Widget](#browser-widget)
1776
1809
 
1777
- #### Multi-DSL Support
1810
+ Glimmer automatically recognizes top-level keywords in each DSL and activates DSL accordingly. Glimmer allows mixing DSLs, which comes in handy when doing things like using the SWT Browser widget with XML and CSS. Once done processing a nested DSL top-level keyword, Glimmer switches back to the prior DSL automatically.
1778
1811
 
1779
- 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
1780
- and switches DSLs accordingly. Once done processing a top-level keyword, it switches back to the prior DSL automatically.
1812
+ ##### SWT
1781
1813
 
1782
- For example, the SWT DSL has the following top-level keywords:
1814
+ The SWT DSL was already covered in detail. However, for the sake of mixing DSLs, you need to know that the SWT DSL has the following top-level keywords:
1783
1815
  - `shell`
1784
1816
  - `display`
1785
1817
  - `color`
@@ -1787,7 +1819,13 @@ For example, the SWT DSL has the following top-level keywords:
1787
1819
  - `async_exec`
1788
1820
  - `sync_exec`
1789
1821
 
1790
- ##### XML DSL
1822
+ ##### Opal
1823
+
1824
+ Full instructions are found in the [Opal](https://github.com/AndyObtiva/glimmer-dsl-opal) DSL page.
1825
+
1826
+ The [Opal](https://github.com/AndyObtiva/glimmer-dsl-opal) DSL is simply a web GUI adapter for desktop apps written in Glimmer. As such, it supports all the DSL keywords of the SWT DSL and shares the same top-level keywords.
1827
+
1828
+ ##### XML
1791
1829
 
1792
1830
  Simply start with `html` keyword and add HTML inside its block using Glimmer DSL syntax.
1793
1831
  Once done, you may call `to_s`, `to_xml`, or `to_html` to get the formatted HTML output.
@@ -1865,8 +1903,7 @@ Output:
1865
1903
  <DOCUMENT><document:body document:id="main"></document:body></DOCUMENT>
1866
1904
  ```
1867
1905
 
1868
-
1869
- ##### CSS DSL
1906
+ ##### CSS
1870
1907
 
1871
1908
  Simply start with `css` keyword and add stylesheet rule sets inside its block using Glimmer DSL syntax.
1872
1909
  Once done, you may call `to_s` or `to_css` to get the formatted CSS output.
@@ -1902,6 +1939,86 @@ Glimmer provides a number of methods on Glimmer::DSL::Engine to configure DSL su
1902
1939
  - `Glimmer::DSL::Engine.enable_dsl(dsl_name)`: Re-enables disabled DSL
1903
1940
  - `Glimmer::DSL::Engine.enabled_dsls=(dsl_names)`: Disables all DSLs except the ones specified.
1904
1941
 
1942
+ #### Application Menu Items (About/Preferences)
1943
+
1944
+ Mac applications always have About and Preferences menu items. Glimmer provides widget observer hooks for them on the `display`:
1945
+ - `on_about`: executes code when user selects App Name -> About
1946
+ - `on_preferences`: executes code when user selects App Name -> Preferences or hits 'CMD+,' on the Mac
1947
+
1948
+ Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
1949
+
1950
+ ```ruby
1951
+ class Example
1952
+ def initialize
1953
+ display {
1954
+ on_about {
1955
+ message_box = MessageBox.new(@shell_proxy.swt_widget)
1956
+ message_box.setText("About")
1957
+ message_box.setMessage("About Application")
1958
+ message_box.open
1959
+ }
1960
+ on_preferences {
1961
+ preferences_dialog = dialog {
1962
+ text 'Preferences'
1963
+ row_layout {
1964
+ type :vertical
1965
+ margin_left 15
1966
+ margin_top 15
1967
+ margin_right 15
1968
+ margin_bottom 15
1969
+ }
1970
+ label {
1971
+ text 'Check one of these options:'
1972
+ }
1973
+ button(:radio) {
1974
+ text 'Option 1'
1975
+ }
1976
+ button(:radio) {
1977
+ text 'Option 2'
1978
+ }
1979
+ }
1980
+ preferences_dialog.open
1981
+ }
1982
+ }
1983
+ @shell_proxy = shell {
1984
+ text 'Application Menu Items'
1985
+ fill_layout {
1986
+ margin_width 15
1987
+ margin_height 15
1988
+ }
1989
+ label {
1990
+ text 'Application Menu Items'
1991
+ font height: 30
1992
+ }
1993
+ }
1994
+ @shell_proxy.open
1995
+ end
1996
+ end
1997
+
1998
+ Example.new
1999
+ ```
2000
+
2001
+ #### App Name and Version
2002
+
2003
+ Application name (shows up on the Mac in top menu bar) and version may be specified upon [packaging](#packaging--distribution) by specifying "-Bmac.CFBundleName" and "-Bmac.CFBundleVersion" options.
2004
+
2005
+ Still, if you would like proper application name to show up on the Mac top menu bar during development, you may do so by invoking the SWT Display.setAppName method before any Display object has been instantiated (i.e. before any Glimmer widget like shell has been declared).
2006
+
2007
+ Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
2008
+
2009
+ ```ruby
2010
+ Display.setAppName('Glimmer Demo')
2011
+
2012
+ shell(:no_resize) {
2013
+ text "Glimmer"
2014
+ label {
2015
+ text "Hello, World!"
2016
+ }
2017
+ }.open
2018
+ ```
2019
+
2020
+ Also, you may invoke `Display.setAppVersion('1.0.0')` if needed for OS app version identification reasons during development, replacing `'1.0.0'` with your application version.
2021
+
1905
2022
  #### Video Widget
1906
2023
 
1907
2024
  ![Video Widget](images/glimmer-video-widget.png)
@@ -1925,7 +2042,7 @@ shell {
1925
2042
  }.open
1926
2043
  ```
1927
2044
 
1928
- Example rendering HTML with JavaScript on document ready (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
2045
+ Example rendering HTML with JavaScript on document ready (you may copy/paste in [`girb`](#girb-glimmer-irb-command) provided you install and require [glimmer-dsl-xml gem](https://github.com/AndyObtiva/glimmer-dsl-xml)):
1929
2046
 
1930
2047
  ```ruby
1931
2048
  shell {
@@ -1946,7 +2063,7 @@ shell {
1946
2063
  }.open
1947
2064
  ```
1948
2065
 
1949
- This relies on Glimmer's [Multi-DSL Support](https://github.com/AndyObtiva/glimmer/tree/development#multi-dsl-support) for building the HTML text using Glimmer XML DSL.
2066
+ This relies on Glimmer's [Multi-DSL Support](#multi-dsl-support) for building the HTML text using [Glimmer XML DSL](https://github.com/AndyObtiva/glimmer-dsl-xml).
1950
2067
 
1951
2068
  ## Glimmer Style Guide
1952
2069
 
@@ -1999,15 +2116,15 @@ glimmer samples/elaborate/tic_tac_toe.rb # demonstrates a full MVC application
1999
2116
 
2000
2117
  ### External Samples
2001
2118
 
2002
- #### [Glimmer Calculator](https://github.com/AndyObtiva/glimmer-cs-calculator)
2119
+ #### Glimmer Calculator
2003
2120
 
2004
- ![Glimmer Calculator](https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-calculator/v1.0.0/glimmer-cs-calculator-screenshot.png)
2121
+ [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-calculator/v1.0.0/glimmer-cs-calculator-screenshot.png" />](https://github.com/AndyObtiva/glimmer-cs-calculator)
2005
2122
 
2006
2123
  [Glimmer Calculator](https://github.com/AndyObtiva/glimmer-cs-calculator) is a basic calculator sample project demonstrating data-binding and TDD (test-driven-development) with Glimmer following the MVP pattern (Model-View-Presenter).
2007
2124
 
2008
- #### [Gladiator](https://github.com/AndyObtiva/glimmer-cs-gladiator)
2125
+ #### Gladiator
2009
2126
 
2010
- ![Gladiator](https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-gladiator/v0.1.5/images/glimmer-gladiator.png)
2127
+ [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-gladiator/v0.1.5/images/glimmer-gladiator.png" />](https://github.com/AndyObtiva/glimmer-cs-gladiator)
2011
2128
 
2012
2129
  [Gladiator](https://github.com/AndyObtiva/glimmer-cs-gladiator) (short for Glimmer Editor) is a Glimmer sample project under on-going development.
2013
2130
  You may check it out to learn how to build a Glimmer Custom Shell gem.
@@ -2192,6 +2309,8 @@ The Glimmer rake task allows passing extra options to javapackager via:
2192
2309
  Example (Rakefile):
2193
2310
 
2194
2311
  ```ruby
2312
+ require 'glimmer/rake_task'
2313
+
2195
2314
  Glimmer::Package.javapackager_extra_args = '-BlicenseType="MIT" -Bmac.category="public.app-category.business" -Bmac.signing-key-developer-id-app="Andy Maleh"'
2196
2315
  ```
2197
2316
 
@@ -2272,13 +2391,18 @@ By the way, keep in mind that during normal operation, it does also indicate a f
2272
2391
  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
2273
2392
  ```
2274
2393
 
2394
+ ## Limitations
2395
+
2396
+ - Glimmer apps have a long startup up time and can take anywhere between 12 and 30 seconds to start depending on the app and the machine. Once started, Glimmer apps run very fast and perform very responsively since Ruby is more than fast and capable for handling desktop GUIs. In any case, one idea to address this limitation is to include a background service (daemon) that can launch Glimmer apps instantly or near instantly by keeping a JRuby runtime started and ready at all times.
2397
+
2275
2398
  ## Resources
2276
2399
 
2277
2400
  * [Code Master Blog](http://andymaleh.blogspot.com/search/label/Glimmer)
2278
- * [Eclipse Zone Tutorial](http://eclipse.dzone.com/articles/an-introduction-glimmer)
2279
- * [InfoQ Article](http://www.infoq.com/news/2008/02/glimmer-jruby-swt)
2280
- * [RubyConf 2008 Video](https://confreaks.tv/videos/rubyconf2008-desktop-development-with-glimmer)
2281
2401
  * [JRuby Cookbook by Justin Edelson & Henry Liu](http://shop.oreilly.com/product/9780596519650.do)
2402
+ * [MountainWest RubyConf 2011 Video](https://confreaks.tv/videos/mwrc2011-whatever-happened-to-desktop-development-in-ruby)
2403
+ * [RubyConf 2008 Video](https://confreaks.tv/videos/rubyconf2008-desktop-development-with-glimmer)
2404
+ * [InfoQ Article](http://www.infoq.com/news/2008/02/glimmer-jruby-swt)
2405
+ * [DZone Tutorial](https://dzone.com/articles/an-introduction-glimmer)
2282
2406
 
2283
2407
  ## Help
2284
2408
 
@@ -2298,7 +2422,7 @@ If you need live help, try the [#glimmer](http://widget.mibbit.com/?settings=751
2298
2422
 
2299
2423
  These features have been suggested. You might see them in a future version of Glimmer. You are welcome to contribute more feature suggestions.
2300
2424
 
2301
- [TODO.md](TODO.md)
2425
+ [TODO.md](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/TODO.md)
2302
2426
 
2303
2427
  ## Change Log
2304
2428