glimmer-dsl-fx 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +56 -0
- data/README.md +442 -0
- data/VERSION +1 -0
- data/bin/girb +66 -0
- data/bin/girb_runner.rb +83 -0
- data/glimmer-dsl-fx.gemspec +0 -0
- data/lib/glimmer/dsl/fx/attribute_expression.rb +79 -0
- data/lib/glimmer/dsl/fx/control_expression.rb +88 -0
- data/lib/glimmer/dsl/fx/dsl.rb +83 -0
- data/lib/glimmer/dsl/fx/observe_expression.rb +73 -0
- data/lib/glimmer/dsl/fx/on_expression.rb +76 -0
- data/lib/glimmer/fx/control_proxy/app_proxy.rb +89 -0
- data/lib/glimmer/fx/control_proxy/main_window_proxy.rb +83 -0
- data/lib/glimmer/fx/control_proxy.rb +219 -0
- data/lib/glimmer/fx.rb +77 -0
- data/lib/glimmer-dsl-fx.rb +84 -0
- data/samples/hello/hello_button.rb +24 -0
- data/samples/hello/hello_world.rb +9 -0
- metadata +198 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ee2c82b5a89c8d320b83b272d1c0291b6027ac4c2760276146e180c42ab9801d
|
4
|
+
data.tar.gz: db77449c81eb1c9da2860a55bd89ff5a067326e0f21a34c5041f14c37e0ab0d5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 618d244b3abcbcd42571f25cf04ec5ebd261bd78f557d067e8c7b971eeab06009e8e3cd934dc5c5af3f561d209745ba39a9c0a26faf911873f02b392b1375577
|
7
|
+
data.tar.gz: 1f57ea3a301de20a427e0af491a1f43d9e5d731e6621b0e3ddb5604479f32347ee4ede6f9e23f777f02851b099f5c5b363184d2463ad05ae72a2e00248edbcae
|
data/CHANGELOG.md
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
2
|
+
Version 3, 29 June 2007
|
3
|
+
|
4
|
+
Copyright © 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
5
|
+
|
6
|
+
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
7
|
+
|
8
|
+
This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.
|
9
|
+
|
10
|
+
0. Additional Definitions.
|
11
|
+
As used herein, “this License” refers to version 3 of the GNU Lesser General Public License, and the “GNU GPL” refers to version 3 of the GNU General Public License.
|
12
|
+
|
13
|
+
“The Library” refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
|
14
|
+
|
15
|
+
An “Application” is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.
|
16
|
+
|
17
|
+
A “Combined Work” is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the “Linked Version”.
|
18
|
+
|
19
|
+
The “Minimal Corresponding Source” for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.
|
20
|
+
|
21
|
+
The “Corresponding Application Code” for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.
|
22
|
+
|
23
|
+
1. Exception to Section 3 of the GNU GPL.
|
24
|
+
You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.
|
25
|
+
|
26
|
+
2. Conveying Modified Versions.
|
27
|
+
If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:
|
28
|
+
|
29
|
+
a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or
|
30
|
+
b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.
|
31
|
+
3. Object Code Incorporating Material from Library Header Files.
|
32
|
+
The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:
|
33
|
+
|
34
|
+
a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.
|
35
|
+
b) Accompany the object code with a copy of the GNU GPL and this license document.
|
36
|
+
4. Combined Works.
|
37
|
+
You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:
|
38
|
+
|
39
|
+
a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.
|
40
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
|
41
|
+
c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
|
42
|
+
d) Do one of the following:
|
43
|
+
0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
|
44
|
+
1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.
|
45
|
+
e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)
|
46
|
+
5. Combined Libraries.
|
47
|
+
You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:
|
48
|
+
|
49
|
+
a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.
|
50
|
+
b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
|
51
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
52
|
+
The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
53
|
+
|
54
|
+
Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.
|
55
|
+
|
56
|
+
If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.
|
data/README.md
ADDED
@@ -0,0 +1,442 @@
|
|
1
|
+
# [<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 FX 0.0.1
|
2
|
+
## FOX Toolkit Ruby Desktop Development GUI Library
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/glimmer-dsl-fx.svg)](http://badge.fury.io/rb/glimmer-dsl-fx)
|
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)
|
5
|
+
|
6
|
+
[Glimmer](https://github.com/AndyObtiva/glimmer) DSL for [FX](http://www.fox-toolkit.org/) enables building desktop applications with the [FOX Toolkit](http://www.fox-toolkit.org/) via [FXRuby](https://github.com/larskanis/fxruby).
|
7
|
+
|
8
|
+
[FOX Toolkit](http://www.fox-toolkit.org/) is the most popular cross-platform desktop GUI toolkit in [Ruby](https://www.ruby-lang.org/), having [900k+ FXRuby gem downloads](https://rubygems.org/gems/fxruby) and counting!
|
9
|
+
|
10
|
+
[Glimmer DSL for FX](https://rubygems.org/gems/glimmer-dsl-fx) aims to supercharge productivity and maintainability in developing [FOX Toolkit Ruby](https://rubygems.org/gems/fxruby) applications by providing a DSL similar to [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) having:
|
11
|
+
- Declarative DSL syntax that visually maps to the GUI widget hierarchy
|
12
|
+
- Convention over configuration via smart defaults and automation of low-level details
|
13
|
+
- Requiring the least amount of syntax possible to build GUI
|
14
|
+
- Custom control support
|
15
|
+
- Bidirectional Data-Binding to declaratively wire and automatically synchronize GUI with Business Models
|
16
|
+
- Scaffolding for new custom widgets, apps, and gems
|
17
|
+
- Native-Executable packaging on Mac, Windows, and Linux.
|
18
|
+
|
19
|
+
Hello, World!
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
app('HelloWorld', 'Glimmer') {
|
23
|
+
main_window('Hello, World!') {
|
24
|
+
label('Hello, World!')
|
25
|
+
}
|
26
|
+
}.run
|
27
|
+
```
|
28
|
+
|
29
|
+
![hello world screenshot mac](/screenshots/glimmer-dsl-fx-mac-hello-world.png)
|
30
|
+
|
31
|
+
NOTE: Glimmer DSL for FX is currently in early alpha mode (incomplete proof-of-concept). Please help make better by contributing, adopting for small or low risk projects, and providing feedback. It is still an early alpha, so the more feedback and issues you report the better.
|
32
|
+
|
33
|
+
Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interested in:
|
34
|
+
- [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)
|
35
|
+
- [glimmer-dsl-opal](https://github.com/AndyObtiva/glimmer-dsl-opal): Glimmer DSL for Opal (Pure Ruby Web GUI and Auto-Webifier of Desktop Apps)
|
36
|
+
- [glimmer-dsl-tk](https://github.com/AndyObtiva/glimmer-dsl-tk): Glimmer DSL for Tk (MRI Ruby Desktop Development GUI Library)
|
37
|
+
- [glimmer-dsl-libui](https://github.com/AndyObtiva/glimmer-dsl-libui): Glimmer DSL for Tk (Prerequisite-Free Ruby Desktop Development GUI Library)
|
38
|
+
- [glimmer-dsl-xml](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML)
|
39
|
+
- [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS
|
40
|
+
|
41
|
+
## Prerequisites
|
42
|
+
|
43
|
+
### Linux
|
44
|
+
|
45
|
+
Run:
|
46
|
+
|
47
|
+
```
|
48
|
+
sudo apt-get install g++ libxrandr-dev libfox-1.6-dev
|
49
|
+
```
|
50
|
+
|
51
|
+
### Mac
|
52
|
+
|
53
|
+
Make sure [Homebrew](https://brew.sh/) is installed (e.g. by running `/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"`).
|
54
|
+
|
55
|
+
Run:
|
56
|
+
|
57
|
+
```
|
58
|
+
brew install fox
|
59
|
+
brew install xquartz
|
60
|
+
```
|
61
|
+
|
62
|
+
### Windows
|
63
|
+
|
64
|
+
The [glimmer-dsl-fx](https://rubygems.org/gems/glimmer-dsl-fx) gem already contains all required library dependencies.
|
65
|
+
|
66
|
+
## Setup
|
67
|
+
|
68
|
+
### Option 1: Install
|
69
|
+
|
70
|
+
Run this command to install directly:
|
71
|
+
```
|
72
|
+
gem install glimmer-dsl-fx
|
73
|
+
```
|
74
|
+
|
75
|
+
### Option 2: Bundler
|
76
|
+
|
77
|
+
Add the following to `Gemfile`:
|
78
|
+
```
|
79
|
+
gem 'glimmer-dsl-fx', '~> 0.0.1'
|
80
|
+
```
|
81
|
+
|
82
|
+
And, then run:
|
83
|
+
```
|
84
|
+
bundle
|
85
|
+
```
|
86
|
+
|
87
|
+
## Usage
|
88
|
+
|
89
|
+
Require the library and mixin the `Glimmer` module to utilize the Glimmer GUI DSL for FX:
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
app('HelloWorld', 'Glimmer') {
|
93
|
+
main_window('Hello, World!') {
|
94
|
+
label('Hello, World!')
|
95
|
+
}
|
96
|
+
}.run
|
97
|
+
```
|
98
|
+
|
99
|
+
For actual application development outside of simple demos, mixin the `Glimmer` module into a custom application class instead:
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
require 'glimmer-dsl-fx'
|
103
|
+
|
104
|
+
class SomeGlimmerApplication
|
105
|
+
include Glimmer
|
106
|
+
|
107
|
+
def launch
|
108
|
+
app('HelloWorld', 'Glimmer') {
|
109
|
+
main_window('Hello, World!') {
|
110
|
+
label('Hello, World!')
|
111
|
+
}
|
112
|
+
}.run
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
SomeGlimmerApplication.new.launch
|
117
|
+
```
|
118
|
+
|
119
|
+
## Glimmer GUI DSL
|
120
|
+
|
121
|
+
The Glimmer GUI DSL enables development of desktop graphical user interfaces in a manner similar to HTML, but in one language, Ruby, thus avoiding the multi-language separation dissonance encountered on the web, especially given that Ruby looping/conditional constructs do not need scriptlets to be added around View code. This makes desktop development extremely productive.
|
122
|
+
|
123
|
+
1 - Keywords
|
124
|
+
|
125
|
+
Always start with `app`.
|
126
|
+
|
127
|
+
Inside `app`, nest `main_window`, and inside `main_window`, you may declare any [FOX Toolkit control](http://www.fox-toolkit.org/ref16/classes.html) with its keyword, which is the underscored version of the class name minus the `FX` prefix. For example, `label` is the keyword for [`FXLabel`](http://www.fox-toolkit.org/ref16/classFX_1_1FXLabel.html)
|
128
|
+
|
129
|
+
Examples:
|
130
|
+
|
131
|
+
```ruby
|
132
|
+
label
|
133
|
+
button
|
134
|
+
text_field
|
135
|
+
```
|
136
|
+
|
137
|
+
2 - Arguments
|
138
|
+
|
139
|
+
Every [FOX Toolkit](http://www.fox-toolkit.org/) control usually requires one main argument that is [the second argument in the C++ API](http://www.fox-toolkit.org/ref16/classFX_1_1FXButton.html#a0) (e.g. button text or text_field column width) and extra kwargs specific to each control, like `:opts`, `:width`, and `:height` for `button`.
|
140
|
+
|
141
|
+
The [FOX Toolkit](http://www.fox-toolkit.org/) `:opts` argument value is usually bit-or'ed `Fox` constants (e.g. `FRAME_RAISED|FRAME_THICK`). In [Glimmer DSL for FX](https://rubygems.org/gems/glimmer-dsl-fx), you simply supply them as a downcased underscored `Symbol` `Array` separated by commas (e.g. `[:frame_raised, :frame_thick]`)
|
142
|
+
|
143
|
+
Example:
|
144
|
+
|
145
|
+
```ruby
|
146
|
+
label('Full Name', opts: [:layout_top, :justify_left])
|
147
|
+
button('Submit Form', opts: [:frame_raised, :frame_thick], icon: submit_icon, width: 300, height: 200)
|
148
|
+
text_field(20, opts: [:justify_right, :frame_sunken, :frame_thick, :layout_side_top])
|
149
|
+
```
|
150
|
+
|
151
|
+
The recommended style is to always wrap arguments with parentheses for control keywords.
|
152
|
+
|
153
|
+
3 - Content Block
|
154
|
+
|
155
|
+
You may pass a content block to any [FOX Toolkit](http://www.fox-toolkit.org/) control keyword, which contains attributes and/or nested controls.
|
156
|
+
|
157
|
+
Example:
|
158
|
+
|
159
|
+
```ruby
|
160
|
+
app('HelloWorld', 'Glimmer') {
|
161
|
+
main_window('Hello, World!') {
|
162
|
+
width 320
|
163
|
+
height 240
|
164
|
+
|
165
|
+
vertical_frame {
|
166
|
+
label('Hello, Label!')
|
167
|
+
button('Hello, Button!')
|
168
|
+
}
|
169
|
+
}
|
170
|
+
}.run
|
171
|
+
```
|
172
|
+
|
173
|
+
The recommended style for the content block is always curly braces `{}` to denote as View nesting code different from looping/conditional logic, which utilizes `do;end` instead.
|
174
|
+
|
175
|
+
Attribute arguments never have parentheses.
|
176
|
+
|
177
|
+
4 - Listeners
|
178
|
+
|
179
|
+
You may declare listeners with `on(message_type) {...}` where `message_type` is an underscored `Symbol` version of a `Fox::SEL_XYZ` message type constant (e.g. `SEL_COMMAND`, `SEL_SELECTED`, `SEL_KEYPRESS`, `SEL_KEYRELEASE`, `SEL_CLICKED`, `SEL_LEFTBUTTONPRESS`, or `SEL_LEFTBUTTONRELEASE`), but without the `SEL_` prefix. For example: `on(:command) {...}`, `on(:selected) {...}`, `on(:keypress) {...}`, `on(:keyrelease) {...}`, `on(:clicked) {...}`, `on(:leftbuttonpress) {...}`, and `on(:leftbuttonrelease) {...}`.
|
180
|
+
|
181
|
+
Example:
|
182
|
+
|
183
|
+
```ruby
|
184
|
+
app('HelloWorld', 'Glimmer') {
|
185
|
+
main_window('Hello, World!') {
|
186
|
+
button('Hello, Button!') { |b|
|
187
|
+
on(:command) {
|
188
|
+
b.text = 'Clicked'
|
189
|
+
}
|
190
|
+
}
|
191
|
+
}
|
192
|
+
}.run
|
193
|
+
```
|
194
|
+
|
195
|
+
The recommended style for listeners is always a `do; end` block.
|
196
|
+
|
197
|
+
5 - Component Proxy & Methods
|
198
|
+
|
199
|
+
When utilizing the Glimmer GUI DSL, you get back proxy objects that wrap [FOX Toolkit](http://www.fox-toolkit.org/) controls. To access the original control wrapped by the proxy object, you may call the `#fx` method.
|
200
|
+
|
201
|
+
Furthermore, you may invoke any method available on the control indirectly on the proxy object, like the `#text` method on `label`.
|
202
|
+
|
203
|
+
```ruby
|
204
|
+
label1 = nil
|
205
|
+
app('HelloWorld', 'Glimmer') {
|
206
|
+
main_window('Hello, World!') {
|
207
|
+
label1 = label('Full Name')
|
208
|
+
}
|
209
|
+
}
|
210
|
+
puts label1.text # prints: Full Name
|
211
|
+
puts label1.fx.text # prints: Full Name
|
212
|
+
label1.text = 'Name'
|
213
|
+
puts label1.text # prints: Name
|
214
|
+
puts label1.fx.text # prints: Name
|
215
|
+
label1.fx.text = 'Whole Name'
|
216
|
+
puts label1.text # prints: Whole Name
|
217
|
+
puts label1.fx.text # prints: Whole Name
|
218
|
+
```
|
219
|
+
|
220
|
+
6 - Observe Model Attributes
|
221
|
+
|
222
|
+
In Smalltalk-MVC ([Model View Controller](https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller) Architectural Pattern), the View is an active View that observes the Model for changes and updates itself.
|
223
|
+
|
224
|
+
![MVC](http://3.bp.blogspot.com/-4eW59Ao0ess/ToiBzAiYdZI/AAAAAAAAAOg/SiYa6XHwBFE/s320/Screen+shot+2011-10-02+at+10.22.11+AM.png)
|
225
|
+
|
226
|
+
This can be achieved with the Glimmer GUI DSL using the `observe` keyword, which takes a model (any object, including `self`) and attribute Symbol or String expression (e.g. `:count` or `'address.street'`), and decouples the Model from the View.
|
227
|
+
|
228
|
+
The model is automatically enhanced as an `Glimmer::DataBinding::ObservableModel` / `Glimmer::DataBinding::ObservableHash` / `Glimmer::DataBinding::ObservableArray` depending on its type to support notifying observers of attribute changes (when performed using the attribute writer, which automatically calls added method `notify_observers(attribute)`)
|
229
|
+
|
230
|
+
Note that it is usually recommended to observe external model objects (not `self`), but `self` is OK in very simple cases or presentation-related attributes only.
|
231
|
+
|
232
|
+
Example:
|
233
|
+
|
234
|
+
```ruby
|
235
|
+
require 'glimmer-dsl-fx'
|
236
|
+
|
237
|
+
class Counter
|
238
|
+
attr_accessor :count
|
239
|
+
|
240
|
+
def initialize
|
241
|
+
self.count = 0
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
class HelloButton
|
246
|
+
include Glimmer
|
247
|
+
|
248
|
+
def initialize
|
249
|
+
@counter = Counter.new
|
250
|
+
|
251
|
+
observe(@counter, :count) do |new_count|
|
252
|
+
@button.text = "Click To Increment: #{new_count}"
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
def launch
|
257
|
+
app('HelloButton', 'Glimmer') {
|
258
|
+
main_window('Hello, Button!') {
|
259
|
+
@button = button('Click To Increment: 0') {
|
260
|
+
on(:command) do
|
261
|
+
@counter.count += 1
|
262
|
+
end
|
263
|
+
}
|
264
|
+
}
|
265
|
+
}.run
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
HelloButton.new.launch
|
270
|
+
```
|
271
|
+
|
272
|
+
![screenshots/glimmer-dsl-fx-mac-hello-button.png](screenshots/glimmer-dsl-fx-mac-hello-button.png)
|
273
|
+
|
274
|
+
## Smart Defaults and Conventions
|
275
|
+
|
276
|
+
- `app` automatically shows `main_window` upon calling `run` while staring the main event loop.
|
277
|
+
- `app` automatically invokes `open -a /Applications/Utilities/XQuartz.app` upon running on Mac.
|
278
|
+
- Declaring `app` multiple times always returns the first `app` created ([FOX Toolkit](http://www.fox-toolkit.org/) does not support multiple `app` instances)
|
279
|
+
|
280
|
+
## Girb (Glimmer IRB)
|
281
|
+
|
282
|
+
You can run the `girb` command (`bin/girb` if you cloned the project locally):
|
283
|
+
|
284
|
+
```
|
285
|
+
girb
|
286
|
+
```
|
287
|
+
|
288
|
+
![girb screenshot mac](/screenshots/glimmer-dsl-fx-mac-girb.png)
|
289
|
+
|
290
|
+
This gives you `irb` with the `glimmer-dsl-fx` gem loaded and the `Glimmer` module mixed into the main object for easy experimentation with GUI.
|
291
|
+
|
292
|
+
Note: GIRB for Glimmer DSL for FX 0.0.1 is still very rudimentary and does not support entering code for multiple applications, yet only one. You would have to exit and re-enter after each application entered.
|
293
|
+
|
294
|
+
Gotcha: On the Mac, when you close a window opened in `girb`, it remains open until you enter `exit`.
|
295
|
+
|
296
|
+
## Samples
|
297
|
+
|
298
|
+
You may checkout the [samples](samples) directory for examples of using [Glimmer DSL for FX](https://rubygems.org/gems/glimmer-dsl-fx).
|
299
|
+
|
300
|
+
### Hello Samples
|
301
|
+
|
302
|
+
#### Hello, World!
|
303
|
+
|
304
|
+
[samples/hello/hello_world.rb](/samples/hello/hello_world.rb)
|
305
|
+
|
306
|
+
![hello world screenshot Mac](/screenshots/glimmer-dsl-fx-mac-hello-world.png)
|
307
|
+
|
308
|
+
Run (via installed gem):
|
309
|
+
|
310
|
+
```
|
311
|
+
ruby -r glimmer-dsl-fx -e "require 'samples/hello/hello_world'"
|
312
|
+
```
|
313
|
+
|
314
|
+
Run (via locally cloned project):
|
315
|
+
|
316
|
+
```
|
317
|
+
ruby -r ./lib/glimmer-dsl-fx.rb samples/hello/hello_world.rb
|
318
|
+
```
|
319
|
+
|
320
|
+
Code:
|
321
|
+
|
322
|
+
```ruby
|
323
|
+
require 'glimmer-dsl-fx'
|
324
|
+
|
325
|
+
include Glimmer
|
326
|
+
|
327
|
+
app('HelloWorld', 'Glimmer') {
|
328
|
+
main_window('Hello, World!') {
|
329
|
+
label('Hello, World!')
|
330
|
+
}
|
331
|
+
}.run
|
332
|
+
```
|
333
|
+
|
334
|
+
#### Hello, Button!
|
335
|
+
|
336
|
+
[samples/hello/hello_button.rb](/samples/hello/hello_button.rb)
|
337
|
+
|
338
|
+
![hello button screenshot](/screenshots/glimmer-dsl-fx-mac-hello-button.png)
|
339
|
+
|
340
|
+
Run (via installed gem):
|
341
|
+
|
342
|
+
```
|
343
|
+
ruby -r glimmer-dsl-fx -e "require 'samples/hello/hello_button'"
|
344
|
+
```
|
345
|
+
|
346
|
+
Run (via locally cloned project):
|
347
|
+
|
348
|
+
```
|
349
|
+
ruby -r ./lib/glimmer-dsl-fx.rb samples/hello/hello_button.rb
|
350
|
+
```
|
351
|
+
|
352
|
+
Code:
|
353
|
+
|
354
|
+
```ruby
|
355
|
+
require 'glimmer-dsl-fx'
|
356
|
+
|
357
|
+
class HelloButton
|
358
|
+
include Glimmer
|
359
|
+
|
360
|
+
def initialize
|
361
|
+
@count = 0
|
362
|
+
end
|
363
|
+
|
364
|
+
def launch
|
365
|
+
app('HelloButton', 'Glimmer') {
|
366
|
+
main_window('Hello, Button!') {
|
367
|
+
@button = button("Click To Increment: 0") {
|
368
|
+
on(:command) do
|
369
|
+
@count += 1
|
370
|
+
@button.text = "Click To Increment: #{@count}"
|
371
|
+
end
|
372
|
+
}
|
373
|
+
}
|
374
|
+
}.run
|
375
|
+
end
|
376
|
+
end
|
377
|
+
|
378
|
+
HelloButton.new.launch
|
379
|
+
```
|
380
|
+
|
381
|
+
## Resources
|
382
|
+
|
383
|
+
- fxruby gem: https://github.com/larskanis/fxruby
|
384
|
+
- FOX Toolkit: http://www.fox-toolkit.org
|
385
|
+
- FOX Toolkit Documentation: http://www.fox-toolkit.org/doc.html
|
386
|
+
- FOX Toolkit 1.6 API Reference: http://www.fox-toolkit.org/ref16/classes.html
|
387
|
+
|
388
|
+
## Process
|
389
|
+
|
390
|
+
[Glimmer Process](https://github.com/AndyObtiva/glimmer/blob/master/PROCESS.md)
|
391
|
+
|
392
|
+
## Help
|
393
|
+
|
394
|
+
### Issues
|
395
|
+
|
396
|
+
If you encounter [issues](https://github.com/AndyObtiva/glimmer-dsl-fx/issues) that are not reported, discover missing features that are not mentioned in [TODO.md](TODO.md), or think up better ways to use FX than what is possible with [Glimmer DSL for FX](https://rubygems.org/gems/glimmer-dsl-fx), you may submit an [issue](https://github.com/AndyObtiva/glimmer-dsl-fx/issues/new) or [pull request](https://github.com/AndyObtiva/glimmer-dsl-fx/compare) on [GitHub](https://github.com). In the meantime while waiting for a fix, you may try older gem versions of [Glimmer DSL for FX](https://rubygems.org/gems/glimmer-dsl-fx) in case you find one that does not have the issue and actually works.
|
397
|
+
|
398
|
+
### Chat
|
399
|
+
|
400
|
+
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)
|
401
|
+
|
402
|
+
## Planned Features and Feature Suggestions
|
403
|
+
|
404
|
+
These features have been planned or suggested. You might see them in a future version of [Glimmer DSL for FX](https://rubygems.org/gems/glimmer-dsl-fx). You are welcome to contribute more feature suggestions.
|
405
|
+
|
406
|
+
[TODO.md](TODO.md)
|
407
|
+
|
408
|
+
## Change Log
|
409
|
+
|
410
|
+
[CHANGELOG.md](CHANGELOG.md)
|
411
|
+
|
412
|
+
## Contributing
|
413
|
+
|
414
|
+
- Check out the latest master to make sure the feature hasn't been
|
415
|
+
implemented or the bug hasn't been fixed yet.
|
416
|
+
- Check out the issue tracker to make sure someone already hasn't
|
417
|
+
requested it and/or contributed it.
|
418
|
+
- Fork the project.
|
419
|
+
- Start a feature/bugfix branch.
|
420
|
+
- Commit and push until you are happy with your contribution.
|
421
|
+
- Make sure to add tests for it. This is important so I don't break it
|
422
|
+
in a future version unintentionally.
|
423
|
+
- Please try not to mess with the Rakefile, version, or history. If
|
424
|
+
you want to have your own version, or is otherwise necessary, that
|
425
|
+
is fine, but please isolate to its own commit so I can cherry-pick
|
426
|
+
around it.
|
427
|
+
|
428
|
+
## Contributors
|
429
|
+
|
430
|
+
* [Andy Maleh](https://github.com/AndyObtiva) (Founder)
|
431
|
+
|
432
|
+
[Click here to view contributor commits.](https://github.com/AndyObtiva/glimmer-dsl-fx/graphs/contributors)
|
433
|
+
|
434
|
+
## Copyright
|
435
|
+
|
436
|
+
[LGPL](LICENSE.txt)
|
437
|
+
|
438
|
+
Copyright (c) 2021 Andy Maleh.
|
439
|
+
|
440
|
+
--
|
441
|
+
|
442
|
+
[<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=40 />](https://github.com/AndyObtiva/glimmer) Built for [Glimmer](https://github.com/AndyObtiva/glimmer) (DSL Framework).
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/bin/girb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Copyright (c) 2021 Andy Maleh
|
4
|
+
#
|
5
|
+
# GNU LESSER GENERAL PUBLIC LICENSE
|
6
|
+
# Version 3, 29 June 2007
|
7
|
+
#
|
8
|
+
# Copyright © 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
9
|
+
#
|
10
|
+
# Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
11
|
+
#
|
12
|
+
# This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.
|
13
|
+
#
|
14
|
+
# 0. Additional Definitions.
|
15
|
+
# As used herein, “this License” refers to version 3 of the GNU Lesser General Public License, and the “GNU GPL” refers to version 3 of the GNU General Public License.
|
16
|
+
#
|
17
|
+
# “The Library” refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
|
18
|
+
#
|
19
|
+
# An “Application” is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.
|
20
|
+
#
|
21
|
+
# A “Combined Work” is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the “Linked Version”.
|
22
|
+
#
|
23
|
+
# The “Minimal Corresponding Source” for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.
|
24
|
+
#
|
25
|
+
# The “Corresponding Application Code” for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.
|
26
|
+
#
|
27
|
+
# 1. Exception to Section 3 of the GNU GPL.
|
28
|
+
# You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.
|
29
|
+
#
|
30
|
+
# 2. Conveying Modified Versions.
|
31
|
+
# If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:
|
32
|
+
#
|
33
|
+
# a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or
|
34
|
+
# b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.
|
35
|
+
# 3. Object Code Incorporating Material from Library Header Files.
|
36
|
+
# The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:
|
37
|
+
#
|
38
|
+
# a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.
|
39
|
+
# b) Accompany the object code with a copy of the GNU GPL and this license document.
|
40
|
+
# 4. Combined Works.
|
41
|
+
# You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:
|
42
|
+
#
|
43
|
+
# a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.
|
44
|
+
# b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
|
45
|
+
# c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
|
46
|
+
# d) Do one of the following:
|
47
|
+
# 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
|
48
|
+
# 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.
|
49
|
+
# e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)
|
50
|
+
# 5. Combined Libraries.
|
51
|
+
# You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:
|
52
|
+
#
|
53
|
+
# a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.
|
54
|
+
# b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
|
55
|
+
# 6. Revised Versions of the GNU Lesser General Public License.
|
56
|
+
# The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
57
|
+
#
|
58
|
+
# Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.
|
59
|
+
#
|
60
|
+
# If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.
|
61
|
+
|
62
|
+
require_relative 'girb_runner'
|
63
|
+
|
64
|
+
require 'irb'
|
65
|
+
|
66
|
+
IRB.start('.')
|