glimmer 0.8.0 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +233 -117
- data/VERSION +1 -1
- data/lib/glimmer.rb +1 -20
- data/lib/glimmer/config.rb +0 -13
- data/lib/glimmer/data_binding/observable_array.rb +32 -53
- data/lib/glimmer/data_binding/observable_model.rb +10 -14
- data/lib/glimmer/data_binding/observer.rb +3 -0
- data/lib/glimmer/dsl/engine.rb +33 -18
- data/lib/glimmer/dsl/expression.rb +0 -7
- data/lib/glimmer/dsl/static_expression.rb +2 -2
- metadata +47 -166
- data/RUBY_VERSION +0 -1
- data/bin/girb +0 -10
- data/bin/girb_runner.rb +0 -13
- data/bin/glimmer +0 -5
- data/icons/scaffold_app.icns +0 -0
- data/lib/glimmer/css/rule.rb +0 -25
- data/lib/glimmer/css/style_sheet.rb +0 -19
- data/lib/glimmer/data_binding/list_selection_binding.rb +0 -52
- data/lib/glimmer/data_binding/observable_widget.rb +0 -17
- data/lib/glimmer/data_binding/shine.rb +0 -23
- data/lib/glimmer/data_binding/table_items_binding.rb +0 -47
- data/lib/glimmer/data_binding/tree_items_binding.rb +0 -71
- data/lib/glimmer/data_binding/widget_binding.rb +0 -33
- data/lib/glimmer/dsl/css/css_expression.rb +0 -21
- data/lib/glimmer/dsl/css/dsl.rb +0 -10
- data/lib/glimmer/dsl/css/dynamic_property_expression.rb +0 -12
- data/lib/glimmer/dsl/css/property_expression.rb +0 -22
- data/lib/glimmer/dsl/css/pv_expression.rb +0 -17
- data/lib/glimmer/dsl/css/rule_expression.rb +0 -25
- data/lib/glimmer/dsl/css/s_expression.rb +0 -26
- data/lib/glimmer/dsl/swt/async_exec_expression.rb +0 -14
- data/lib/glimmer/dsl/swt/bind_expression.rb +0 -37
- data/lib/glimmer/dsl/swt/color_expression.rb +0 -19
- data/lib/glimmer/dsl/swt/column_properties_expression.rb +0 -24
- data/lib/glimmer/dsl/swt/combo_selection_data_binding_expression.rb +0 -42
- data/lib/glimmer/dsl/swt/custom_widget_expression.rb +0 -36
- data/lib/glimmer/dsl/swt/data_binding_expression.rb +0 -34
- data/lib/glimmer/dsl/swt/dialog_expression.rb +0 -26
- data/lib/glimmer/dsl/swt/display_expression.rb +0 -19
- data/lib/glimmer/dsl/swt/dsl.rb +0 -28
- data/lib/glimmer/dsl/swt/exec_expression.rb +0 -28
- data/lib/glimmer/dsl/swt/layout_data_expression.rb +0 -25
- data/lib/glimmer/dsl/swt/layout_expression.rb +0 -27
- data/lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb +0 -44
- data/lib/glimmer/dsl/swt/menu_bar_expression.rb +0 -33
- data/lib/glimmer/dsl/swt/menu_expression.rb +0 -32
- data/lib/glimmer/dsl/swt/observe_expression.rb +0 -32
- data/lib/glimmer/dsl/swt/property_expression.rb +0 -22
- data/lib/glimmer/dsl/swt/rgb_expression.rb +0 -12
- data/lib/glimmer/dsl/swt/rgba_expression.rb +0 -12
- data/lib/glimmer/dsl/swt/shell_expression.rb +0 -25
- data/lib/glimmer/dsl/swt/swt_expression.rb +0 -25
- data/lib/glimmer/dsl/swt/sync_exec_expression.rb +0 -15
- data/lib/glimmer/dsl/swt/tab_item_expression.rb +0 -33
- data/lib/glimmer/dsl/swt/table_items_data_binding_expression.rb +0 -31
- data/lib/glimmer/dsl/swt/tree_items_data_binding_expression.rb +0 -31
- data/lib/glimmer/dsl/swt/tree_properties_expression.rb +0 -26
- data/lib/glimmer/dsl/swt/widget_expression.rb +0 -34
- data/lib/glimmer/dsl/swt/widget_listener_expression.rb +0 -32
- data/lib/glimmer/dsl/xml/dsl.rb +0 -11
- data/lib/glimmer/dsl/xml/html_expression.rb +0 -25
- data/lib/glimmer/dsl/xml/meta_expression.rb +0 -23
- data/lib/glimmer/dsl/xml/name_space_expression.rb +0 -37
- data/lib/glimmer/dsl/xml/node_parent_expression.rb +0 -33
- data/lib/glimmer/dsl/xml/tag_expression.rb +0 -29
- data/lib/glimmer/dsl/xml/text_expression.rb +0 -22
- data/lib/glimmer/dsl/xml/xml_expression.rb +0 -21
- data/lib/glimmer/launcher.rb +0 -199
- data/lib/glimmer/package.rb +0 -7
- data/lib/glimmer/rake_task.rb +0 -89
- data/lib/glimmer/scaffold.rb +0 -582
- data/lib/glimmer/swt/color_proxy.rb +0 -53
- data/lib/glimmer/swt/display_proxy.rb +0 -88
- data/lib/glimmer/swt/font_proxy.rb +0 -72
- data/lib/glimmer/swt/layout_data_proxy.rb +0 -84
- data/lib/glimmer/swt/layout_proxy.rb +0 -82
- data/lib/glimmer/swt/menu_proxy.rb +0 -101
- data/lib/glimmer/swt/packages.rb +0 -13
- data/lib/glimmer/swt/shell_proxy.rb +0 -145
- data/lib/glimmer/swt/swt_proxy.rb +0 -106
- data/lib/glimmer/swt/tab_item_proxy.rb +0 -65
- data/lib/glimmer/swt/tree_proxy.rb +0 -120
- data/lib/glimmer/swt/widget_listener_proxy.rb +0 -34
- data/lib/glimmer/swt/widget_proxy.rb +0 -489
- data/lib/glimmer/ui/custom_shell.rb +0 -45
- data/lib/glimmer/ui/custom_widget.rb +0 -244
- data/lib/glimmer/util/proc_tracker.rb +0 -16
- data/lib/glimmer/xml/depth_first_search_iterator.rb +0 -22
- data/lib/glimmer/xml/name_space_visitor.rb +0 -21
- data/lib/glimmer/xml/node.rb +0 -75
- data/lib/glimmer/xml/node_visitor.rb +0 -13
- data/lib/glimmer/xml/xml_visitor.rb +0 -65
- data/vendor/swt/linux/swt.jar +0 -0
- data/vendor/swt/mac/swt.jar +0 -0
- data/vendor/swt/windows/swt.jar +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d387850f085c102bcaf51d9f9f1250cf02124372beed08612bc2dde2766f387
|
4
|
+
data.tar.gz: 828032e8a3d6779e47d63c054cf15211ec8b989a58af47ba1aedfed36e696b67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e7d349b48f19af94bab354eceef736e6c58e9d4e608582fb12c1677c453dfff5ee02c74a968133e985239a18f0058f66b35a4199fc4c3ac63b29cb0d80a7f91
|
7
|
+
data.tar.gz: 2d4f7f4600517ca0f6e9f08946b37f7aaff9740dc3f49b1844147d6635cd4cce053af200e1c58c0a5eac8523d4cce2f9601ead454665049919954498d697c32e
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,14 +1,19 @@
|
|
1
|
-
#
|
1
|
+
# <img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=105 /> Glimmer - Ruby Desktop Development GUI Library
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/glimmer.svg)](http://badge.fury.io/rb/glimmer)
|
3
|
-
[![Travis CI](https://travis-ci.com/AndyObtiva/glimmer.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer)
|
4
|
-
[![
|
5
|
-
[![Maintainability](https://api.codeclimate.com/v1/badges/38fbc278022862794414/maintainability)](https://codeclimate.com/github/AndyObtiva/glimmer/maintainability)
|
3
|
+
[![Travis CI](https://travis-ci.com/AndyObtiva/glimmer.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer)
|
4
|
+
[![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)
|
6
5
|
|
7
6
|
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
7
|
|
9
8
|
[<img src="https://covers.oreillystatic.com/images/9780596519650/lrg.jpg" width=105 /><br />
|
10
9
|
Featured in<br />JRuby Cookbook](http://shop.oreilly.com/product/9780596519650.do)
|
11
10
|
|
11
|
+
Glimmer DSL gems:
|
12
|
+
- [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (Desktop GUI)
|
13
|
+
- [glimmer-dsl-opal](https://github.com/AndyObtiva/glimmer-dsl-opal): Glimmer DSL for Opal (Web GUI Adapter for Desktop Apps)
|
14
|
+
- [glimmer-dsl-xml](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML)
|
15
|
+
- [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS (Cascading Style Sheets)
|
16
|
+
|
12
17
|
## Examples
|
13
18
|
|
14
19
|
### Hello, World!
|
@@ -71,11 +76,13 @@ Glimmer app:
|
|
71
76
|
|
72
77
|
![Tic Tac Toe](images/glimmer-tic-tac-toe.png)
|
73
78
|
|
74
|
-
NOTE: Glimmer is in beta mode. Please help make better by adopting for small or low risk projects and providing feedback.
|
79
|
+
NOTE: Glimmer is in beta mode. Please help make better by [contributing](#contributing), adopting for small or low risk projects, and providing feedback.
|
80
|
+
|
81
|
+
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
82
|
|
76
|
-
## Table of
|
83
|
+
## Table of contents
|
77
84
|
|
78
|
-
- [Glimmer
|
85
|
+
- [Glimmer - Ruby Desktop Development GUI Library](#glimmer---ruby-desktop-development-gui-library)
|
79
86
|
- [Examples](#examples)
|
80
87
|
- [Hello, World!](#hello-world)
|
81
88
|
- [Tic Tac Toe](#tic-tac-toe)
|
@@ -89,23 +96,55 @@ NOTE: Glimmer is in beta mode. Please help make better by adopting for small or
|
|
89
96
|
- [Basic Usage](#basic-usage)
|
90
97
|
- [Advanced Usage](#advanced-usage)
|
91
98
|
- [Scaffolding](#scaffolding)
|
99
|
+
- [App](#app)
|
100
|
+
- [Custom Shell](#custom-shell)
|
101
|
+
- [Custom Widget](#custom-widget)
|
102
|
+
- [Custom Shell Gem](#custom-shell-gem)
|
103
|
+
- [Custom Widget Gem](#custom-widget-gem)
|
92
104
|
- [Girb (Glimmer irb) Command](#girb-glimmer-irb-command)
|
93
105
|
- [Glimmer DSL Syntax](#glimmer-dsl-syntax)
|
94
106
|
- [Widgets](#widgets)
|
107
|
+
- [Display](#display)
|
108
|
+
- [SWT Proxies](#swt-proxies)
|
109
|
+
- [Dialog](#dialog)
|
110
|
+
- [Menus](#menus)
|
95
111
|
- [Widget Styles](#widget-styles)
|
112
|
+
- [Explicit SWT Style Bit](#explicit-swt-style-bit)
|
113
|
+
- [Negative SWT Style Bits](#negative-swt-style-bits)
|
114
|
+
- [Extra SWT Styles](#extra-swt-styles)
|
96
115
|
- [Widget Properties](#widget-properties)
|
116
|
+
- [Colors](#colors)
|
117
|
+
- [Fonts](#fonts)
|
97
118
|
- [Layouts](#layouts)
|
98
119
|
- [Layout Data](#layout-data)
|
99
120
|
- [Data-Binding](#data-binding)
|
121
|
+
- [General Examples](#general-examples)
|
122
|
+
- [Combo](#combo)
|
123
|
+
- [List](#list)
|
124
|
+
- [Table](#table)
|
125
|
+
- [Tree](#tree)
|
100
126
|
- [Observer](#observer)
|
127
|
+
- [Observing Widgets](#observing-widgets)
|
128
|
+
- [Observing Models](#observing-models)
|
101
129
|
- [Custom Widgets](#custom-widgets)
|
130
|
+
- [Simple Example](#simple-example)
|
131
|
+
- [Hook Example](#hook-example)
|
132
|
+
- [Content/Options Example](#contentoptions-example)
|
133
|
+
- [Gotcha](#gotcha)
|
102
134
|
- [Custom Shells](#custom-shells)
|
103
135
|
- [Miscellaneous](#miscellaneous)
|
136
|
+
- [Multi-DSL Support](#multi-dsl-support)
|
137
|
+
- [Application Menu Items (About/Preferences)](#application-menu-items-aboutpreferences)
|
138
|
+
- [App Name and Version](#app-name-and-version)
|
139
|
+
- [Video Widget](#video-widget)
|
140
|
+
- [Browser Widget](#browser-widget)
|
104
141
|
- [Glimmer Style Guide](#glimmer-style-guide)
|
105
142
|
- [Samples](#samples)
|
106
143
|
- [Hello Samples](#hello-samples)
|
107
144
|
- [Elaborate Samples](#elaborate-samples)
|
108
145
|
- [External Samples](#external-samples)
|
146
|
+
- [Glimmer Calculator](#glimmer-calculator)
|
147
|
+
- [Gladiator](#gladiator)
|
109
148
|
- [In Production](#in-production)
|
110
149
|
- [SWT Reference](#swt-reference)
|
111
150
|
- [SWT Packages](#swt-packages)
|
@@ -150,12 +189,11 @@ More info about the SWT GUI on various platforms can be found on the Eclipse WIK
|
|
150
189
|
https://wiki.eclipse.org/SWT/Devel/Gtk/Dev_guide#Win32.2FCocoa.2FGTK
|
151
190
|
https://www.eclipse.org/swt/faq.php
|
152
191
|
|
153
|
-
|
154
192
|
## Pre-requisites
|
155
193
|
|
156
194
|
- SWT 4.15 (comes included in Glimmer gem)
|
157
195
|
- JRuby 9.2.11.1 (supporting Ruby 2.5.x syntax) (find at [https://www.jruby.org/download](https://www.jruby.org/download))
|
158
|
-
-
|
196
|
+
- JDK 8 - 10 (find at [https://www.oracle.com/java/technologies/javase-downloads.html](https://www.oracle.com/java/technologies/javase-downloads.html))
|
159
197
|
- (Optional) RVM is needed for [Scaffolding](#scaffolding) only (find at [https://rvm.io/](https://rvm.io/))
|
160
198
|
|
161
199
|
On **Mac** and **Linux**, an easy way to obtain JRuby is through [RVM](http://rvm.io) by running:
|
@@ -168,13 +206,13 @@ Glimmer might still work on lower versions of Java, JRuby and SWT, but there are
|
|
168
206
|
|
169
207
|
## Setup
|
170
208
|
|
171
|
-
Please follow these instructions to make the `glimmer` command available on your system.
|
209
|
+
Please follow these instructions to make the `glimmer` command available on your system via the [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem.
|
172
210
|
|
173
211
|
### Option 1: Direct Install
|
174
212
|
|
175
213
|
Run this command to install directly:
|
176
214
|
```
|
177
|
-
jgem install glimmer -v 0.
|
215
|
+
jgem install glimmer-dsl-swt -v 0.1.2
|
178
216
|
```
|
179
217
|
|
180
218
|
`jgem` is JRuby's version of `gem` command.
|
@@ -185,7 +223,7 @@ Otherwise, you may also run `jruby -S gem install ...`
|
|
185
223
|
|
186
224
|
Add the following to `Gemfile`:
|
187
225
|
```
|
188
|
-
gem 'glimmer', '~> 0.
|
226
|
+
gem 'glimmer-dsl-swt', '~> 0.1.2'
|
189
227
|
```
|
190
228
|
|
191
229
|
And, then run:
|
@@ -193,6 +231,8 @@ And, then run:
|
|
193
231
|
jruby -S bundle install
|
194
232
|
```
|
195
233
|
|
234
|
+
You may learn more about other Glimmer related gems ([`glimmer-dsl-opal`](https://github.com/AndyObtiva/glimmer-dsl-opal), [`glimmer-dsl-xml`](https://github.com/AndyObtiva/glimmer-dsl-xml), and [`glimmer-dsl-css`](https://github.com/AndyObtiva/glimmer-dsl-css)) at [Multi-DSL Support](#multi-dsl-support)
|
235
|
+
|
196
236
|
## Glimmer Command
|
197
237
|
|
198
238
|
### Basic Usage
|
@@ -394,7 +434,7 @@ With Glimmer installed, you may want to run `girb` instead of standard `irb` to
|
|
394
434
|
girb
|
395
435
|
```
|
396
436
|
|
397
|
-
If you cloned
|
437
|
+
If you cloned [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) project locally, you may run `bin/girb` instead.
|
398
438
|
|
399
439
|
```
|
400
440
|
bin/girb
|
@@ -402,6 +442,8 @@ bin/girb
|
|
402
442
|
|
403
443
|
Watch out for hands-on examples in this README indicated by "you may copy/paste in [`girb`](#girb-glimmer-irb-command)"
|
404
444
|
|
445
|
+
Keep in mind that all samples live under [https://github.com/AndyObtiva/glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt)
|
446
|
+
|
405
447
|
## Glimmer DSL Syntax
|
406
448
|
|
407
449
|
Glimmer DSL syntax consists of static keywords and dynamic keywords to build and bind user-interface objects.
|
@@ -1100,7 +1142,7 @@ https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/
|
|
1100
1142
|
|
1101
1143
|
Data-binding is done with `bind` command following widget property to bind and taking model and bindable attribute as arguments.
|
1102
1144
|
|
1103
|
-
#### General
|
1145
|
+
#### General Examples
|
1104
1146
|
|
1105
1147
|
`text bind(contact, :first_name)`
|
1106
1148
|
|
@@ -1271,7 +1313,62 @@ The Glimmer code is not much different from above except for passing the `:multi
|
|
1271
1313
|
|
1272
1314
|
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
1315
|
|
1274
|
-
You may learn more about Glimmer's data-binding syntax by reading the
|
1316
|
+
You may learn more about Glimmer's data-binding syntax by reading the code under the [samples](samples) directory.
|
1317
|
+
|
1318
|
+
#### Table
|
1319
|
+
|
1320
|
+
The SWT Tree widget renders a multi-column data table, such as a contact listing or a sales report.
|
1321
|
+
|
1322
|
+
To data-bind a Table, you need the main model, the collection property, and the text display attribute for each table column.
|
1323
|
+
|
1324
|
+
This involves using the `bind` keyword mentioned above in addition to a special `column_properties` keyword that takes the table column text attribute methods.
|
1325
|
+
|
1326
|
+
It assumes you have defined the table columns via `table_column` widget.
|
1327
|
+
|
1328
|
+
Example:
|
1329
|
+
|
1330
|
+
```ruby
|
1331
|
+
shell {
|
1332
|
+
@table = table {
|
1333
|
+
table_column {
|
1334
|
+
text "Name"
|
1335
|
+
width 120
|
1336
|
+
}
|
1337
|
+
table_column {
|
1338
|
+
text "Age"
|
1339
|
+
width 120
|
1340
|
+
}
|
1341
|
+
table_column {
|
1342
|
+
text "Adult"
|
1343
|
+
width 120
|
1344
|
+
}
|
1345
|
+
items bind(group, :people), column_properties(:name, :age, :adult)
|
1346
|
+
selection bind(group, :selected_person)
|
1347
|
+
}
|
1348
|
+
}
|
1349
|
+
```
|
1350
|
+
|
1351
|
+
The code above includes two data-bindings:
|
1352
|
+
- 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.
|
1353
|
+
- 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)
|
1354
|
+
|
1355
|
+
Additionally, Table `items` data-binding automatically stores each node model unto the SWT TableItem object via `setData` method. This enables things like searchability.
|
1356
|
+
|
1357
|
+
The table widget in Glimmer is represented by a subclass of `WidgetProxy` called `TableProxy`.
|
1358
|
+
TableProxy includes a `search` method that takes a block to look for a table item.
|
1359
|
+
|
1360
|
+
Example:
|
1361
|
+
|
1362
|
+
```ruby
|
1363
|
+
found_array = @table.search { |table_item| table_item.getData == company.owner }
|
1364
|
+
```
|
1365
|
+
|
1366
|
+
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.
|
1367
|
+
|
1368
|
+
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)`.
|
1369
|
+
This automatically leverages the SWT TableEditor custom class behind the scenes, displaying a text widget to the user to change the selected or
|
1370
|
+
passed table item text into something else.
|
1371
|
+
It automatically persists the change to `items` data-bound model on ENTER/FOCUS-OUT or cancels on ESC/NO-CHANGE.
|
1275
1372
|
|
1276
1373
|
#### Tree
|
1277
1374
|
|
@@ -1487,7 +1584,9 @@ Glimmer supports creating custom widgets with minimal code, which automatically
|
|
1487
1584
|
|
1488
1585
|
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
1586
|
|
1490
|
-
#### Example
|
1587
|
+
#### Simple Example
|
1588
|
+
|
1589
|
+
(you may copy/paste in [`girb`](#girb-glimmer-irb-command))
|
1491
1590
|
|
1492
1591
|
Definition:
|
1493
1592
|
```ruby
|
@@ -1513,7 +1612,9 @@ shell {
|
|
1513
1612
|
|
1514
1613
|
As you can see, `RedLabel` became Glimmer DSL keyword: `red_label`
|
1515
1614
|
|
1516
|
-
####
|
1615
|
+
#### Hook Example
|
1616
|
+
|
1617
|
+
(you may copy/paste in [`girb`](#girb-glimmer-irb-command))
|
1517
1618
|
|
1518
1619
|
Definition:
|
1519
1620
|
```ruby
|
@@ -1562,7 +1663,9 @@ Additionally, custom widgets can call the following class methods:
|
|
1562
1663
|
- `::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)
|
1563
1664
|
- `::option(option_name, default: nil)`: declares a single option taking option name and default value as arguments (also generates attribute accessors just like `::options`)
|
1564
1665
|
|
1565
|
-
#### Content/Options Example
|
1666
|
+
#### Content/Options Example
|
1667
|
+
|
1668
|
+
(you may copy/paste in [`girb`](#girb-glimmer-irb-command))
|
1566
1669
|
|
1567
1670
|
Definition:
|
1568
1671
|
```ruby
|
@@ -1703,92 +1806,19 @@ shell { |app_shell|
|
|
1703
1806
|
|
1704
1807
|
### Miscellaneous
|
1705
1808
|
|
1706
|
-
####
|
1707
|
-
|
1708
|
-
Mac applications always have About and Preferences menu items. Glimmer provides widget observer hooks for them on the `display`:
|
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
|
-
class Example
|
1716
|
-
def initialize
|
1717
|
-
display {
|
1718
|
-
on_about {
|
1719
|
-
message_box = MessageBox.new(@shell_proxy.swt_widget)
|
1720
|
-
message_box.setText("About")
|
1721
|
-
message_box.setMessage("About Application")
|
1722
|
-
message_box.open
|
1723
|
-
}
|
1724
|
-
on_preferences {
|
1725
|
-
preferences_dialog = dialog {
|
1726
|
-
text 'Preferences'
|
1727
|
-
row_layout {
|
1728
|
-
type :vertical
|
1729
|
-
margin_left 15
|
1730
|
-
margin_top 15
|
1731
|
-
margin_right 15
|
1732
|
-
margin_bottom 15
|
1733
|
-
}
|
1734
|
-
label {
|
1735
|
-
text 'Check one of these options:'
|
1736
|
-
}
|
1737
|
-
button(:radio) {
|
1738
|
-
text 'Option 1'
|
1739
|
-
}
|
1740
|
-
button(:radio) {
|
1741
|
-
text 'Option 2'
|
1742
|
-
}
|
1743
|
-
}
|
1744
|
-
preferences_dialog.open
|
1745
|
-
}
|
1746
|
-
}
|
1747
|
-
@shell_proxy = shell {
|
1748
|
-
text 'Application Menu Items'
|
1749
|
-
fill_layout {
|
1750
|
-
margin_width 15
|
1751
|
-
margin_height 15
|
1752
|
-
}
|
1753
|
-
label {
|
1754
|
-
text 'Application Menu Items'
|
1755
|
-
font height: 30
|
1756
|
-
}
|
1757
|
-
}
|
1758
|
-
@shell_proxy.open
|
1759
|
-
end
|
1760
|
-
end
|
1761
|
-
|
1762
|
-
Example.new
|
1763
|
-
```
|
1764
|
-
|
1765
|
-
#### App Name and Version
|
1766
|
-
|
1767
|
-
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.
|
1768
|
-
|
1769
|
-
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).
|
1770
|
-
|
1771
|
-
Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
|
1772
|
-
|
1773
|
-
```ruby
|
1774
|
-
Display.setAppName('Glimmer Demo')
|
1775
|
-
|
1776
|
-
shell(:no_resize) {
|
1777
|
-
text "Glimmer"
|
1778
|
-
label {
|
1779
|
-
text "Hello, World!"
|
1780
|
-
}
|
1781
|
-
}.open
|
1782
|
-
```
|
1809
|
+
#### Multi-DSL Support
|
1783
1810
|
|
1784
|
-
|
1811
|
+
Glimmer is a DSL engine that supports multiple DSLs (Domain Specific Languages):
|
1812
|
+
- [SWT](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (Desktop GUI)
|
1813
|
+
- [Opal](https://github.com/AndyObtiva/glimmer-dsl-opal): Glimmer DSL for Opal (Web GUI Adapter for Desktop Apps)
|
1814
|
+
- [XML](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML) - Useful with [SWT Browser Widget](#browser-widget)
|
1815
|
+
- [CSS](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS (Cascading Style Sheets) - Useful with [SWT Browser Widget](#browser-widget)
|
1785
1816
|
|
1786
|
-
|
1817
|
+
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.
|
1787
1818
|
|
1788
|
-
|
1789
|
-
and switches DSLs accordingly. Once done processing a top-level keyword, it switches back to the prior DSL automatically.
|
1819
|
+
##### SWT
|
1790
1820
|
|
1791
|
-
|
1821
|
+
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:
|
1792
1822
|
- `shell`
|
1793
1823
|
- `display`
|
1794
1824
|
- `color`
|
@@ -1796,7 +1826,13 @@ For example, the SWT DSL has the following top-level keywords:
|
|
1796
1826
|
- `async_exec`
|
1797
1827
|
- `sync_exec`
|
1798
1828
|
|
1799
|
-
#####
|
1829
|
+
##### Opal
|
1830
|
+
|
1831
|
+
Full instructions are found in the [Opal](https://github.com/AndyObtiva/glimmer-dsl-opal) DSL page.
|
1832
|
+
|
1833
|
+
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.
|
1834
|
+
|
1835
|
+
##### XML
|
1800
1836
|
|
1801
1837
|
Simply start with `html` keyword and add HTML inside its block using Glimmer DSL syntax.
|
1802
1838
|
Once done, you may call `to_s`, `to_xml`, or `to_html` to get the formatted HTML output.
|
@@ -1874,8 +1910,7 @@ Output:
|
|
1874
1910
|
<DOCUMENT><document:body document:id="main"></document:body></DOCUMENT>
|
1875
1911
|
```
|
1876
1912
|
|
1877
|
-
|
1878
|
-
##### CSS DSL
|
1913
|
+
##### CSS
|
1879
1914
|
|
1880
1915
|
Simply start with `css` keyword and add stylesheet rule sets inside its block using Glimmer DSL syntax.
|
1881
1916
|
Once done, you may call `to_s` or `to_css` to get the formatted CSS output.
|
@@ -1911,6 +1946,86 @@ Glimmer provides a number of methods on Glimmer::DSL::Engine to configure DSL su
|
|
1911
1946
|
- `Glimmer::DSL::Engine.enable_dsl(dsl_name)`: Re-enables disabled DSL
|
1912
1947
|
- `Glimmer::DSL::Engine.enabled_dsls=(dsl_names)`: Disables all DSLs except the ones specified.
|
1913
1948
|
|
1949
|
+
#### Application Menu Items (About/Preferences)
|
1950
|
+
|
1951
|
+
Mac applications always have About and Preferences menu items. Glimmer provides widget observer hooks for them on the `display`:
|
1952
|
+
- `on_about`: executes code when user selects App Name -> About
|
1953
|
+
- `on_preferences`: executes code when user selects App Name -> Preferences or hits 'CMD+,' on the Mac
|
1954
|
+
|
1955
|
+
Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
|
1956
|
+
|
1957
|
+
```ruby
|
1958
|
+
class Example
|
1959
|
+
def initialize
|
1960
|
+
display {
|
1961
|
+
on_about {
|
1962
|
+
message_box = MessageBox.new(@shell_proxy.swt_widget)
|
1963
|
+
message_box.setText("About")
|
1964
|
+
message_box.setMessage("About Application")
|
1965
|
+
message_box.open
|
1966
|
+
}
|
1967
|
+
on_preferences {
|
1968
|
+
preferences_dialog = dialog {
|
1969
|
+
text 'Preferences'
|
1970
|
+
row_layout {
|
1971
|
+
type :vertical
|
1972
|
+
margin_left 15
|
1973
|
+
margin_top 15
|
1974
|
+
margin_right 15
|
1975
|
+
margin_bottom 15
|
1976
|
+
}
|
1977
|
+
label {
|
1978
|
+
text 'Check one of these options:'
|
1979
|
+
}
|
1980
|
+
button(:radio) {
|
1981
|
+
text 'Option 1'
|
1982
|
+
}
|
1983
|
+
button(:radio) {
|
1984
|
+
text 'Option 2'
|
1985
|
+
}
|
1986
|
+
}
|
1987
|
+
preferences_dialog.open
|
1988
|
+
}
|
1989
|
+
}
|
1990
|
+
@shell_proxy = shell {
|
1991
|
+
text 'Application Menu Items'
|
1992
|
+
fill_layout {
|
1993
|
+
margin_width 15
|
1994
|
+
margin_height 15
|
1995
|
+
}
|
1996
|
+
label {
|
1997
|
+
text 'Application Menu Items'
|
1998
|
+
font height: 30
|
1999
|
+
}
|
2000
|
+
}
|
2001
|
+
@shell_proxy.open
|
2002
|
+
end
|
2003
|
+
end
|
2004
|
+
|
2005
|
+
Example.new
|
2006
|
+
```
|
2007
|
+
|
2008
|
+
#### App Name and Version
|
2009
|
+
|
2010
|
+
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.
|
2011
|
+
|
2012
|
+
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).
|
2013
|
+
|
2014
|
+
Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
|
2015
|
+
|
2016
|
+
```ruby
|
2017
|
+
Display.setAppName('Glimmer Demo')
|
2018
|
+
|
2019
|
+
shell(:no_resize) {
|
2020
|
+
text "Glimmer"
|
2021
|
+
label {
|
2022
|
+
text "Hello, World!"
|
2023
|
+
}
|
2024
|
+
}.open
|
2025
|
+
```
|
2026
|
+
|
2027
|
+
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.
|
2028
|
+
|
1914
2029
|
#### Video Widget
|
1915
2030
|
|
1916
2031
|
![Video Widget](images/glimmer-video-widget.png)
|
@@ -1934,7 +2049,7 @@ shell {
|
|
1934
2049
|
}.open
|
1935
2050
|
```
|
1936
2051
|
|
1937
|
-
Example rendering HTML with JavaScript on document ready (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
|
2052
|
+
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)):
|
1938
2053
|
|
1939
2054
|
```ruby
|
1940
2055
|
shell {
|
@@ -1955,7 +2070,7 @@ shell {
|
|
1955
2070
|
}.open
|
1956
2071
|
```
|
1957
2072
|
|
1958
|
-
This relies on Glimmer's [Multi-DSL Support](
|
2073
|
+
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).
|
1959
2074
|
|
1960
2075
|
## Glimmer Style Guide
|
1961
2076
|
|
@@ -2008,15 +2123,15 @@ glimmer samples/elaborate/tic_tac_toe.rb # demonstrates a full MVC application
|
|
2008
2123
|
|
2009
2124
|
### External Samples
|
2010
2125
|
|
2011
|
-
####
|
2126
|
+
#### Glimmer Calculator
|
2012
2127
|
|
2013
|
-
|
2128
|
+
[<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)
|
2014
2129
|
|
2015
2130
|
[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).
|
2016
2131
|
|
2017
|
-
####
|
2132
|
+
#### Gladiator
|
2018
2133
|
|
2019
|
-
|
2134
|
+
[<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-gladiator/v0.1.5/images/glimmer-gladiator.png" />](https://github.com/AndyObtiva/glimmer-cs-gladiator)
|
2020
2135
|
|
2021
2136
|
[Gladiator](https://github.com/AndyObtiva/glimmer-cs-gladiator) (short for Glimmer Editor) is a Glimmer sample project under on-going development.
|
2022
2137
|
You may check it out to learn how to build a Glimmer Custom Shell gem.
|
@@ -2201,6 +2316,8 @@ The Glimmer rake task allows passing extra options to javapackager via:
|
|
2201
2316
|
Example (Rakefile):
|
2202
2317
|
|
2203
2318
|
```ruby
|
2319
|
+
require 'glimmer/rake_task'
|
2320
|
+
|
2204
2321
|
Glimmer::Package.javapackager_extra_args = '-BlicenseType="MIT" -Bmac.category="public.app-category.business" -Bmac.signing-key-developer-id-app="Andy Maleh"'
|
2205
2322
|
```
|
2206
2323
|
|
@@ -2284,10 +2401,11 @@ Exec failed with code 2 command [[/usr/bin/SetFile, -c, icnC, /var/folders/4_/g1
|
|
2284
2401
|
## Resources
|
2285
2402
|
|
2286
2403
|
* [Code Master Blog](http://andymaleh.blogspot.com/search/label/Glimmer)
|
2287
|
-
* [Eclipse Zone Tutorial](http://eclipse.dzone.com/articles/an-introduction-glimmer)
|
2288
|
-
* [InfoQ Article](http://www.infoq.com/news/2008/02/glimmer-jruby-swt)
|
2289
|
-
* [RubyConf 2008 Video](https://confreaks.tv/videos/rubyconf2008-desktop-development-with-glimmer)
|
2290
2404
|
* [JRuby Cookbook by Justin Edelson & Henry Liu](http://shop.oreilly.com/product/9780596519650.do)
|
2405
|
+
* [MountainWest RubyConf 2011 Video](https://confreaks.tv/videos/mwrc2011-whatever-happened-to-desktop-development-in-ruby)
|
2406
|
+
* [RubyConf 2008 Video](https://confreaks.tv/videos/rubyconf2008-desktop-development-with-glimmer)
|
2407
|
+
* [InfoQ Article](http://www.infoq.com/news/2008/02/glimmer-jruby-swt)
|
2408
|
+
* [DZone Tutorial](https://dzone.com/articles/an-introduction-glimmer)
|
2291
2409
|
|
2292
2410
|
## Help
|
2293
2411
|
|
@@ -2297,17 +2415,15 @@ You may submit [issues](https://github.com/AndyObtiva/glimmer/issues) on [GitHub
|
|
2297
2415
|
|
2298
2416
|
[Click here to submit an issue.](https://github.com/AndyObtiva/glimmer/issues)
|
2299
2417
|
|
2300
|
-
###
|
2301
|
-
|
2302
|
-
If you need live help, try the [#glimmer](http://widget.mibbit.com/?settings=7514b8a196f8f1de939a351245db7aa8&server=irc.mibbit.net&channel=%23glimmer) IRC channel on [irc.mibbit.net](http://widget.mibbit.com/?settings=7514b8a196f8f1de939a351245db7aa8&server=irc.mibbit.net&channel=%23glimmer). If no one was available, you may [leave a GitHub issue](https://github.com/AndyObtiva/glimmer/issues) to schedule a meetup on IRC.
|
2418
|
+
### Chat
|
2303
2419
|
|
2304
|
-
|
2420
|
+
If you need live help, try to [![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)
|
2305
2421
|
|
2306
2422
|
## Feature Suggestions
|
2307
2423
|
|
2308
2424
|
These features have been suggested. You might see them in a future version of Glimmer. You are welcome to contribute more feature suggestions.
|
2309
2425
|
|
2310
|
-
[TODO.md](TODO.md)
|
2426
|
+
[TODO.md](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/TODO.md)
|
2311
2427
|
|
2312
2428
|
## Change Log
|
2313
2429
|
|