README.markdown in glimmer-0.3.2 vs README.markdown in glimmer-0.3.3
- old
+ new
@@ -100,18 +100,18 @@
### Option 1: Direct Install
Run this command to install directly:
```
-jgem install glimmer -v 0.3.2
+jgem install glimmer -v 0.3.3
```
### Option 2: Bundler
Add the following to `Gemfile`:
```
-gem 'glimmer', '~> 0.3.2'
+gem 'glimmer', '~> 0.3.3'
```
And, then run:
```
bundle install
@@ -150,18 +150,113 @@
- `tab_item`: wrapper for `org.eclipse.swt.widgets.TabItem`
- `table`: wrapper for `org.eclipse.swt.widgets.Table`
- `table_column`: wrapper for `org.eclipse.swt.widgets.TableColumn`
- `tree`: wrapper for `org.eclipse.swt.widgets.Tree`
+### Widget Styles
+
+SWT widgets receive `SWT` styles in their constructor as per this guide:
+
+https://wiki.eclipse.org/SWT_Widget_Style_Bits
+
+Glimmer DSL facilitates that by passing symbols representing `SWT` constants as widget method arguments (i.e. inside widget `()` parentheses. See example below) in lower case version (e.g. `SWT::MULTI` becomes `:multi`).
+
+These styles customize widget look, feel, and behavior.
+
+Example:
+```ruby
+list(:multi) { # SWT styles go inside ()
+ # ...
+}
+```
+
+Passing `:multi` to `list` widget enables list element multi-selection.
+
+```ruby
+composite(:border) { # SWT styles go inside ()
+ # ...
+}
+```
+
+Passing `:border` to `composite` widget ensures it has a border.
+
+When you need to pass in **multiple SWT styles**, simply separate by commas.
+
+Example:
+```ruby
+text(:center, :border) { # Multiple SWT styles separated by comma
+ # ...
+}
+```
+
+Glimmer ships with SWT style **smart defaults** so you wouldn't have to set them yourself most of the time (albeit you can always override them):
+
+- `text(:border)`
+- `table(:border)`
+- `spinner(:border)`
+- `list(:border, :v_scroll)`
+- `button(:push)`
+
+You may check out all available `SWT` styles here:
+
+https://help.eclipse.org/2019-12/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/SWT.html
+
### Widget Properties
-Widget properties (e.g. `text`) may be set with methods matching their names in lower snakecase.
+Widget properties such as value, enablement, and layout details are set within the widget block using methods matching SWT widget property names in lower snakecase. You may refer to SWT widget guide for details on available widget properties:
-Widget property examples:
-- `text` to set text value of a `label`
-- `gridData` to set grid data of a `composite`
+https://help.eclipse.org/2019-12/topic/org.eclipse.platform.doc.isv/guide/swt_widgets_controls.htm?cp=2_0_7_0_0
+
+Code examples:
+
+```ruby
+label {
+ text "Hello World!" # SWT properties go inside {} block
+}
+```
+
+In the above example, the `label` widget `text` property was set to "Hello World!".
+
+```ruby
+button {
+ enabled bind(@tic_tac_toe_board.box(row, column), :empty)
+}
+```
+
+In the above example, the `text` widget `enabled` property was data-bound to `#empty` method on `@tic_tac_toe_board.box(row, column)` (learn more about data-binding below)
+
+### Color
+
+Color makes up a subset of widget properties. SWT accepts color objects created with RGB (Red Green Blue) or RGBA (Red Green Blue Alpha). Glimmer supports constructing color objects using the `rgb` and `rgba` DSL methods.
+
+Example:
+
+```ruby
+label {
+ background rgb(144, 240, 244)
+ foreground rgba(38, 92, 232, 255)
+}
+```
+
+SWT also supports all standard colors available as constants under the `SWT` namespace (e.g. `SWT::COLOR_BLUE`)
+
+Glimmer accepts these constants as Ruby symbols prefixed by `color_`.
+
+Example:
+
+```ruby
+label {
+ background :color_white
+ foreground :color_black
+}
+```
+
+You may check out all available standard colors in `SWT` over here:
+
+https://help.eclipse.org/2019-12/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/SWT.html
+
### Data-Binding
Data-binding is done with `bind` command following widget property to bind and taking model and bindable attribute as arguments.
Data-binding examples:
@@ -182,13 +277,13 @@
The fifth 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`.
You may learn more about Glimmer's syntax by reading the Eclipse Zone Tutorial mentioned in resources and opening up the samples under the `samples` folder.
-### Observer/Observable
+### Observer
-Glimmer comes with the two classes `Observer`/`Observable`, which are used internally for data-binding, but can also be used externally for custom use of the Observer Pattern.
+Glimmer comes with `Observer` module, which is used internally for data-binding, but can also be used externally for custom use of the Observer Pattern.
In summary, the class that needs to observe an object, must include Observer and implement `#update(changed_value)` method. The class to be observed doesn't need to do anything. It will automatically be enhanced by Glimmer for observation.
Observers can be a good mechanism for displaying dialog messages with Glimmer (using SWT's `MessageBox`).
@@ -237,11 +332,14 @@
Here is a list of SWT widgets:
https://help.eclipse.org/2019-12/topic/org.eclipse.platform.doc.isv/guide/swt_widgets_controls.htm?cp=2_0_7_0_0
+Here is a list of SWT style bits:
+https://wiki.eclipse.org/SWT_Widget_Style_Bits
+
## Girb (Glimmer irb)
With Glimmer installed, you may run want to run `girb` instead of standard `irb` to have SWT preloaded and the Glimmer library required and included for quick Glimmer coding/testing.
## Logging
@@ -297,18 +395,23 @@
## Feature Suggestions
These features have been suggested. You might see them in a future version of Glimmer. You are welcome to contribute more feature suggestions.
-- Auto-include SWT packages when including Glimmer
- Glimmer Application: provide a standard structure for building a Glimmer app
- Glimmer Component: Glimmer already supports components by externalizing to objects, but it would be good if there is a module to include so Glimmer would automatically register
a new component and extend the DSL with it
-- **Nested indexed property data binding**: a complementary feature to nested property data binding that binds to a collection element by index (e.g. `bind(user, 'addresses[1].street')`)
-- **bind_collection**: an iterator that enables spawning widgets based on a variable collection (e.g. `bind_collection('user.addresses') { |address| address_widget {...} }` spawns 3 `AddressWidget`s if `user.addresses` is set with 3 addresses; and replaces with 2 `AddressWidget`s if `user.addresses` is reset with 2 addresses only). Needs further thought on naming and functionality.
+- Glimmer Wizard: provide a standard structure for building a Glimmer wizard (multi-step/multi-screen process)
+- bind_collection: an iterator that enables spawning widgets based on a variable collection (e.g. `bind_collection('user.addresses') { |address| address_widget {...} }` spawns 3 `AddressWidget`s if `user.addresses` is set with 3 addresses; and replaces with 2 `AddressWidget`s if `user.addresses` is reset with 2 addresses only). Needs further thought on naming and functionality.
- Automatic relayout of "glimmer components" when disposing one or as an option
- Consider using Ruby Refinements for Glimmer
-
+- Add 'font' to Glimmer DSL to build font objects easily
+- Add grid layout support to Glimmer DSL to layout grid components easily
+- Add rerendering support to Glimmer to rerender any widget easily
+- Avoid disposing display when disposing a shell to allow recycling
+- Provide a display builder method to use independently of shell
+- Supported a single computed data binding as a string (not array)
+- Disallow use of SWT::CONSTANTs with ORing since it's not intuitive at all
## Contributors
* Andy Maleh (Founder)
* Dennis Theisen