README.md in glimmer-dsl-swt-4.17.2.0 vs README.md in glimmer-dsl-swt-4.17.2.1
- old
+ new
@@ -1,6 +1,6 @@
-# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for SWT 4.17.2.0
+# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for SWT 4.17.2.1
## JRuby Desktop Development GUI Library
[![Gem Version](https://badge.fury.io/rb/glimmer-dsl-swt.svg)](http://badge.fury.io/rb/glimmer-dsl-swt)
[![Travis CI](https://travis-ci.com/AndyObtiva/glimmer-dsl-swt.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer-dsl-swt)
[![Coverage Status](https://coveralls.io/repos/github/AndyObtiva/glimmer-dsl-swt/badge.svg?branch=master)](https://coveralls.io/github/AndyObtiva/glimmer-dsl-swt?branch=master)
[![Maintainability](https://api.codeclimate.com/v1/badges/aaf1cba142dd351f84bd/maintainability)](https://codeclimate.com/github/AndyObtiva/glimmer-dsl-swt/maintainability)
@@ -333,10 +333,12 @@
- [Hello, Message Box!](#hello-message-box)
- [Hello, Browser!](#hello-browser)
- [Hello, Drag and Drop!](#hello-drag-and-drop)
- [Hello, Menu Bar!](#hello-menu-bar)
- [Hello, Pop Up Context Menu!](#hello-pop-up-context-menu)
+ - [Hello, Custom Widget!](#hello-custom-widget)
+ - [Hello, Custom Shell!](#hello-custom-shell)
- [Elaborate Samples](#elaborate-samples)
- [User Profile](#user-profile)
- [Login](#login)
- [Tic Tac Toe Sample](#tic-tac-toe-sample)
- [Contact Manager Sample](#contact-manager-sample)
@@ -414,11 +416,11 @@
If you intend to build a Glimmer app from scratch with [scaffolding](#scaffolding), pick Option 1 ([Direct Install](#option-1-direct-install)) as well.
Otherwise, Option 2 ([Bundler](#option-2-bundler)) can be followed in rare cases where you want to build an app without [scaffolding](#scaffolding).
-Note: if you encounter any [issues](https://github.com/AndyObtiva/glimmer-dsl-swt/issues), please [report](https://github.com/AndyObtiva/glimmer-dsl-swt/issues) and then go back in the list of [Glimmer Releases](https://rubygems.org/gems/glimmer-dsl-swt/versions) until you find one that works for you.
+Note: if you encounter any [issues](https://github.com/AndyObtiva/glimmer-dsl-swt/issues), please [report](https://github.com/AndyObtiva/glimmer-dsl-swt/issues) and then install a previous version instead from the list of [Glimmer Releases](https://rubygems.org/gems/glimmer-dsl-swt/versions).
### Option 1: Direct Install
(Use for [Scaffolding](#scaffolding))
Run this command to install directly:
@@ -426,11 +428,11 @@
jgem install glimmer-dsl-swt
```
Or this command if you want a specific version:
```
-jgem install glimmer-dsl-swt -v 4.17.2.0
+jgem install glimmer-dsl-swt -v 4.17.2.1
```
Note: Gem version numbers are in sync with the SWT library versions. The first two digits represent the SWT version number. The last two digits represent the minor and patch versions of Glimmer DSL for SWT.
`jgem` is JRuby's version of `gem` command.
@@ -503,23 +505,25 @@
### Advanced Usage
Below are the full usage instructions that come up when running `glimmer` without args.
```
-Glimmer (Ruby Desktop Development GUI Library) - JRuby Gem: glimmer-dsl-swt v4.17.2.0
+Glimmer (Ruby Desktop Development GUI Library) - JRuby Gem: glimmer-dsl-swt v4.17.2.1
-Usage: glimmer [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
+Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
Runs Glimmer applications and tasks.
When applications are specified, they are run using JRuby,
automatically preloading the glimmer Ruby gem and SWT jar dependency.
Optionally, extra Glimmer options, JRuby options, and/or environment variables may be passed in.
Glimmer options:
-- "--quiet" : Does not announce file path of Glimmer application being launched
+- "--bundler=GROUP" : Activates gems in Bundler default group in Gemfile
+- "--pd=BOOLEAN" : Requires puts_debuggerer to enable pd method
+- "--quiet=BOOLEAN" : Does not announce file path of Glimmer application being launched
- "--debug" : Displays extra debugging information, passes "--debug" to JRuby, and enables debug logging
- "--log-level=VALUE" : Sets Glimmer's Ruby logger level ("ERROR" / "WARN" / "INFO" / "DEBUG"; default is none)
Tasks are run via rake. Some tasks take arguments in square brackets.
@@ -616,11 +620,11 @@
This will run the hello_tab sample and output its code:
```
$ glimmer sample:run[hello_tab]
-# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.0/samples/hello/hello_tab.rb
+# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.1/samples/hello/hello_tab.rb
class HelloTab
include Glimmer
def launch
shell {
@@ -661,11 +665,11 @@
Example:
```
$ glimmer sample:code[tic_tac_toe]
-# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.0/samples/elaborate/tic_tac_toe.rb
+# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.1/samples/elaborate/tic_tac_toe.rb
require_relative "tic_tac_toe/board"
class TicTacToe
include Glimmer
@@ -722,11 +726,11 @@
TicTacToe.new.open
# # #
-# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.0/samples/elaborate/tic_tac_toe/cell.rb
+# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.1/samples/elaborate/tic_tac_toe/cell.rb
class TicTacToe
class Cell
EMPTY = ""
attr_accessor :sign, :empty
@@ -755,11 +759,11 @@
end
# # #
-# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.0/samples/elaborate/tic_tac_toe/board.rb
+# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.1/samples/elaborate/tic_tac_toe/board.rb
require_relative 'cell'
class TicTacToe
class Board
@@ -1187,11 +1191,11 @@
Name Gem Version Author Description
Css glimmer-dsl-css 0.2.0 AndyMaleh Glimmer DSL for CSS
Opal glimmer-dsl-opal 0.1.0 AndyMaleh Glimmer DSL for Opal
- Swt glimmer-dsl-swt 4.17.2.0 AndyMaleh Glimmer DSL for SWT
+ Swt glimmer-dsl-swt 4.17.2.1 AndyMaleh Glimmer DSL for SWT
Tk glimmer-dsl-tk 0.0.5 AndyMaleh Glimmer DSL for Tk
Xml glimmer-dsl-xml 0.2.0 AndyMaleh Glimmer DSL for XML
```
### Packaging
@@ -2658,12 +2662,18 @@
}.open
```
As you can see, `RedLabel` became Glimmer DSL keyword: `red_label`
-#### Lifecycle Hook Example
+#### Custom Widget Lifecycle Hooks
+You may execute code before or after evaluating the body with these lifecycle hooks:
+- `before_body`: takes a block that executes in the custom widget instance scope before calling `body`. Useful for initializing variables to later use in `body`
+- `after_body`: takes a block that executes in the custom widget instance scope after calling `body`. Useful for setting up observers on widgets built in `body` (set in instance variables) and linking to other shells.
+
+#### Lifecycle Hooks Example
+
(you may copy/paste in [`girb`](#girb-glimmer-irb-command))
Definition:
```ruby
module Red
@@ -2753,16 +2763,10 @@
}.open
```
Notice how `:no_focus` was the `swt_style` value, followed by the `options` hash `{orientation: :horizontal, bg_color: :white}`, and finally the `content` block containing the label with `'SANDWICH CONTENT'`
-#### Custom Widget Lifecycle Hooks
-
-Last but not least, these are the available lifecycle hooks:
-- `before_body`: takes a block that executes in the custom widget instance scope before calling `body`. Useful for initializing variables to later use in `body`
-- `after_body`: takes a block that executes in the custom widget instance scope after calling `body`. Useful for setting up observers on widgets built in `body` (set in instance variables) and linking to other shells.
-
#### Gotcha
Beware of defining a custom attribute that is a common SWT widget property name.
For example, if you define `text=` and `text` methods to accept a custom text and then later you write this body:
@@ -2794,10 +2798,12 @@
#### Final Notes
This [Eclipse guide](https://www.eclipse.org/articles/Article-Writing%20Your%20Own%20Widget/Writing%20Your%20Own%20Widget.htm) for how to write custom SWT widgets is also applicable to Glimmer Custom Widgets written in Ruby. I recommend reading it:
[https://www.eclipse.org/articles/Article-Writing%20Your%20Own%20Widget/Writing%20Your%20Own%20Widget.htm](https://www.eclipse.org/articles/Article-Writing%20Your%20Own%20Widget/Writing%20Your%20Own%20Widget.htm)
+Also, you may check out [Hello, Custom Widget!](#hello-custom-widget) for another example.
+
### Custom Shells
Custom shells are a kind of custom widgets that have shells only as the body root. They can be self-contained applications that may be opened and hidden/closed independently of the main app.
They may also be chained in a wizard fashion.
@@ -2859,10 +2865,12 @@
}
}
}.open
```
+You may check out [Hello, Custom Shell!](#hello-custom-shell) for another example.
+
### Drag and Drop
Glimmer offers Drag and Drop support, thanks to [SWT](https://www.eclipse.org/swt/) and Glimmer's lightweight [DSL syntax](#glimmer-dsl-syntax).
You may learn more about SWT Drag and Drop support over here: [https://www.eclipse.org/articles/Article-SWT-DND/DND-in-SWT.html](https://www.eclipse.org/articles/Article-SWT-DND/DND-in-SWT.html)
@@ -2919,13 +2927,12 @@
### Miscellaneous
#### Multi-DSL Support
-Glimmer is a DSL Framework that supports multiple DSLs (Domain Specific Languages):
-- [SWT](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (JRuby Desktop Development GUI Library)
-- [Tk](https://github.com/AndyObtiva/glimmer-dsl-tk): Glimmer DSL for Tk (Ruby Desktop Development GUI Library)
+Glimmer is a DSL engine that supports multiple DSLs (Domain Specific Languages):
+- [SWT](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (Desktop GUI)
- [Opal](https://github.com/AndyObtiva/glimmer-dsl-opal): Glimmer DSL for Opal (Web GUI Adapter for Desktop Apps)
- [XML](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML) - Useful with [SWT Browser Widget](#browser-widget)
- [CSS](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS (Cascading Style Sheets) - Useful with [SWT Browser Widget](#browser-widget)
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.
@@ -3609,9 +3616,44 @@
glimmer sample:run[hello_pop_up_context_menu]
```
![Hello Pop Up Context Menu](images/glimmer-hello-pop-up-context-menu.png)
![Hello Pop Up Context Menu Popped Up](images/glimmer-hello-pop-up-context-menu-popped-up.png)
+
+#### Hello, Custom Widget!
+
+This sample demonstrates the use of a custom widget in Glimmer.
+
+Code:
+
+[samples/hello/hello_custom_widget.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_custom_widget.rb)
+
+Run:
+
+```
+glimmer sample:run[hello_custom_widget]
+```
+
+![Hello Custom Widget](images/glimmer-hello-custom-widget.gif)
+
+#### Hello, Custom Shell!
+
+This sample demonstrates the use of a custom shell (aka custom window) in Glimmer.
+
+Code:
+
+[samples/hello/hello_custom_shell.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_custom_shell.rb)
+
+Run:
+
+```
+glimmer sample:run[hello_custom_shell]
+```
+
+![Hello Custom Shell](images/glimmer-hello-custom-shell.png)
+![Hello Custom Shell Email1](images/glimmer-hello-custom-shell-email1.png)
+![Hello Custom Shell Email2](images/glimmer-hello-custom-shell-email2.png)
+![Hello Custom Shell Email3](images/glimmer-hello-custom-shell-email3.png)
### Elaborate Samples
For more elaborate samples, check the following: