README.markdown in glimmer-0.5.4 vs README.markdown in glimmer-0.5.5

- old
+ new

@@ -1,6 +1,6 @@ -# Glimmer 0.5.4 Beta (JRuby Desktop UI DSL + Data-Binding) +# Glimmer 0.5.5 Beta (JRuby Desktop UI DSL + Data-Binding) [![Coverage Status](https://coveralls.io/repos/github/AndyObtiva/glimmer/badge.svg?branch=master)](https://coveralls.io/github/AndyObtiva/glimmer?branch=master) 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 platform-native 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. ## Examples @@ -109,18 +109,18 @@ ### Option 1: Direct Install Run this command to install directly: ``` -jgem install glimmer -v 0.5.4 +jgem install glimmer -v 0.5.5 ``` ### Option 2: Bundler Add the following to `Gemfile`: ``` -gem 'glimmer', '~> 0.5.4' +gem 'glimmer', '~> 0.5.5' ``` And, then run: ``` jruby -S bundle install @@ -301,10 +301,87 @@ } } }.open ``` +#### Menus + +Glimmer DSL provides support for SWT Menu and MenuItem widgets. + +There are 2 main types of menus in SWT: +- Menu Bar (shows up on top) +- Pop Up Menu (shows up when right-clicking a widget) + +Underneath both types, there can be a 3rd menu type called Drop Down. + +Glimmer provides special support for Drop Down menus as it automatically instantiates associated Cascade menu items and wires together with proper parenting, swt styles, and calling setMenu. + +Example [Menu Bar] (you may copy/paste in [`girb`](#girb-glimmer-irb-command)): + +```ruby +shell { + menu_bar { + menu { + text "&File" + menu_item { + text "E&xit" + } + menu_item(0) { + text "&New" + } + menu(1) { + text "&Options" + menu_item(:radio) { + text "Option 1" + } + menu_item(:separator) + menu_item(:check) { + text "Option 3" + } + } + } + menu { + text "&History" + menu { + text "&Recent" + menu_item { + text "File 1" + } + menu_item { + text "File 2" + } + } + } + } +}.open +``` + +Example [Pop Up Menu] (you may copy/paste in [`girb`](#girb-glimmer-irb-command)): + +```ruby +shell { + label { + text 'Right-Click Me' + menu { + menu { + text '&History' + menu { + text "&Recent" + menu_item { + text "File 1" + } + menu_item { + text "File 2" + } + } + } + } + } +}.open +``` + + #### SWT Proxies Glimmer follows Proxy Design Pattern by having Ruby proxy wrappers for all SWT objects: - `Glimmer::SWT:WidgetProxy` wraps all descendants of `org.eclipse.swt.widgets.Widget` except the ones that have their own wrappers. - `Glimmer::SWT::ShellProxy` wraps `org.eclipse.swt.widgets.Shell` @@ -446,9 +523,26 @@ Glimmer makes this easier by alternatively offering `:no_resize` extra SWT style, added for convenience. This makes declaring an non-resizable window as easy as: ```ruby shell(:no_resize) { # ... } +``` + +#### Shell extra attributes + +Shell widget can receive a hash of extra attributes as the last argument (or alone): +- app_name: name to show for app (especially on the Mac) +- app_version: version to have OS recognize app by + +Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)): + +```ruby +shell(:no_resize, app_name: 'Glimmer Demo', app_version: '1.0') { + text "Glimmer" + label { + text "Hello, World!" + } +}.open ``` ### Widget Properties Widget properties such as text value, enablement, visibility, 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: