glimmer-dsl-swt 4.18.2.5 → 4.18.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +130 -24
- data/VERSION +1 -1
- data/glimmer-dsl-swt.gemspec +7 -3
- data/lib/glimmer/dsl/swt/dsl.rb +1 -0
- data/lib/glimmer/dsl/swt/multiply_expression.rb +53 -0
- data/lib/glimmer/dsl/swt/property_expression.rb +4 -2
- data/lib/glimmer/dsl/swt/transform_expression.rb +55 -0
- data/lib/glimmer/swt/custom/drawable.rb +1 -1
- data/lib/glimmer/swt/custom/shape.rb +13 -4
- data/lib/glimmer/swt/transform_proxy.rb +109 -0
- data/samples/hello/hello_canvas_transform.rb +40 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1323fa9209cf80b8c8333bcefb49a4ea682494a63aab2a594d7c7325e5f07833
|
4
|
+
data.tar.gz: 8d190e9c23540f238d23ffee220da4abd751499a7c8f230a86deb93e11f742d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7f842d5fc21e75a1edbf6b07f470ee4b85aa6c462c60f0611143db7fa7ba0c5d2606d70fffd96d5abed5d3cef993b190d9e87bbb731278b7ad466d44c606abb
|
7
|
+
data.tar.gz: e02f1e221a4473975fcbd5afc57e5fb7ab99fe45905f88d6be6547f8f8434959ba7ab0d44518ef90873182170a5c5867f9fe075bef8bebbc94fa528b7aef939e
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
### 4.18.3.0
|
4
|
+
|
5
|
+
- Canvas Transform DSL (DSL declared Transform objects are auto-disposed after getting used by their parent shape)
|
6
|
+
- Canvas support a top-level Transform DSL fluent interface for methods that use Transform arguments manually (e.g. tr1 = transform.rotate(90).translate(0, -100))
|
7
|
+
- Hello, Canvas Transformation!
|
8
|
+
|
3
9
|
### 4.18.2.5
|
4
10
|
|
5
11
|
- ColorProxy args now are automatically fit into 0..255 bounds upon use of the `color`/`rgb`/`rgba` keywords
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
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 SWT 4.18.
|
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 SWT 4.18.3.0
|
2
2
|
## JRuby Desktop Development GUI Framework
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/glimmer-dsl-swt.svg)](http://badge.fury.io/rb/glimmer-dsl-swt)
|
4
4
|
[![Travis CI](https://travis-ci.com/AndyObtiva/glimmer-dsl-swt.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer-dsl-swt)
|
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
**[Contributors Wanted! (Submit a Glimmer App Sample to Get Started)](#contributing)**
|
10
10
|
|
11
|
-
[Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer) is a native-GUI cross-platform desktop development library written in [JRuby](https://www.jruby.org/), an OS-threaded faster JVM version of [Ruby](https://www.ruby-lang.org/en/). [Glimmer](https://github.com/AndyObtiva/glimmer)'s main innovation is a declarative [Ruby DSL](#glimmer-dsl-syntax) that enables productive and efficient authoring of desktop application user-interfaces by relying on the robust [Eclipse SWT library](https://www.eclipse.org/swt/). [Glimmer](https://rubygems.org/gems/glimmer) additionally innovates by having built-in [data-binding](#data-binding) support, which greatly facilitates synchronizing the GUI with domain models, thus achieving true decoupling of object oriented components and enabling developers to solve business problems (test-first) without worrying about GUI concerns, or alternatively drive development GUI-first, and then write clean business models (test-first) afterwards. Not only does Glimmer provide a large set of GUI [widgets](#widgets), but it also supports drawing Canvas Graphics like [Shapes](#canvas-shape-dsl) and [Animations](#canvas-animation-dsl). To get started quickly, [Glimmer](https://rubygems.org/gems/glimmer)
|
11
|
+
[Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer) is a native-GUI cross-platform desktop development library written in [JRuby](https://www.jruby.org/), an OS-threaded faster JVM version of [Ruby](https://www.ruby-lang.org/en/). [Glimmer](https://github.com/AndyObtiva/glimmer)'s main innovation is a declarative [Ruby DSL](#glimmer-dsl-syntax) that enables productive and efficient authoring of desktop application user-interfaces by relying on the robust [Eclipse SWT library](https://www.eclipse.org/swt/). [Glimmer](https://rubygems.org/gems/glimmer) additionally innovates by having built-in [data-binding](#data-binding) support, which greatly facilitates synchronizing the GUI with domain models, thus achieving true decoupling of object oriented components and enabling developers to solve business problems (test-first) without worrying about GUI concerns, or alternatively drive development GUI-first, and then write clean business models (test-first) afterwards. Not only does Glimmer provide a large set of GUI [widgets](#widgets), but it also supports drawing Canvas Graphics like [Shapes](#canvas-shape-dsl) and [Animations](#canvas-animation-dsl). To get started quickly, [Glimmer](https://rubygems.org/gems/glimmer) s [scaffolding](#scaffolding) options for [Apps](#in-production), [Gems](#custom-shell-gem), and [Custom Widgets](#custom-widgets). [Glimmer](https://rubygems.org/gems/glimmer) also includes native-executable [packaging](#packaging--distribution) support, sorely lacking in other libraries, thus enabling the delivery of desktop apps written in [Ruby](https://www.ruby-lang.org/en/) as truly native DMG/PKG/APP files on the [Mac](https://www.apple.com/ca/macos) + [App Store](https://developer.apple.com/macos/distribution/), MSI/EXE files on [Windows](https://www.microsoft.com/en-ca/windows), and [Gem Packaged Shell Scripts](#custom-shell-gem) on [Linux](https://www.linux.org/).
|
12
12
|
|
13
13
|
[Glimmer receives two updates per month](https://rubygems.org/gems/glimmer-dsl-swt/versions). You can trust [Glimmer](https://rubygems.org/gems/glimmer) with your Ruby desktop GUI development needs. Please make [Glimmer](https://rubygems.org/gems/glimmer) even better by providing feedback and [contributing](#contributing) when possible.
|
14
14
|
|
@@ -24,7 +24,7 @@ Glimmer DSL gems:
|
|
24
24
|
- [glimmer-dsl-opal](https://github.com/AndyObtiva/glimmer-dsl-opal): Glimmer DSL for Opal (Pure Ruby Web GUI and Auto-Webifier of Desktop Apps)
|
25
25
|
- [glimmer-dsl-xml](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML)
|
26
26
|
- [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS
|
27
|
-
- [glimmer-dsl-tk](https://github.com/AndyObtiva/glimmer-dsl-tk): Glimmer DSL for Tk (Ruby Desktop Development GUI Library)
|
27
|
+
- [glimmer-dsl-tk](https://github.com/AndyObtiva/glimmer-dsl-tk): Glimmer DSL for Tk (MRI Ruby Desktop Development GUI Library)
|
28
28
|
|
29
29
|
## Examples
|
30
30
|
|
@@ -226,7 +226,7 @@ Glimmer App:
|
|
226
226
|
|
227
227
|
[![Math Bowling App Screenshot](https://raw.githubusercontent.com/AndyObtiva/MathBowling/master/Math-Bowling-Screenshot.png)](https://github.com/AndyObtiva/MathBowling)
|
228
228
|
|
229
|
-
**Note:** I offer Glimmer as
|
229
|
+
**Note:** I offer Glimmer DSL for SWT as a free and open-source [Ruby Gem](https://rubygems.org/gems/glimmer-dsl-swt) that represents my interests in Ruby Programming, Desktop GUI application development with SWT, Object Oriented Design, Design Patterns, and Software Architecture.
|
230
230
|
Additionally, I am sharing my professional experience and expertise in Eclipse SWT given that I am an [EclipseCon](http://andymaleh.blogspot.com/2007/03/eclipsecon-2007-day-3.html)/[EclipseWorld](http://andymaleh.blogspot.com/2008/11/eclipseworld-2008-highlights.html) presenter and have built professional applications in SWT/JFace/RCP for Obtiva and the Pampered Chef in the past. This is also done in the hopes that it would indirectly bring me work in a field I am extremely passionate about.
|
231
231
|
That said, please keep in mind that I myself am learning topics in Software Engineering too everyday, including newer editions of SWT and JRuby, which seem to pop up every quarter.
|
232
232
|
If you see anything that needs to be improved, please do not hesitate to contact me on [Gitter](https://gitter.im/AndyObtiva/glimmer) or submit [Issues](https://github.com/AndyObtiva/glimmer-dsl-swt/issues)/[Pull-Requests](https://github.com/AndyObtiva/glimmer-dsl-swt/pulls).
|
@@ -288,6 +288,7 @@ If you see anything that needs to be improved, please do not hesitate to contact
|
|
288
288
|
- [Layouts](#layouts)
|
289
289
|
- [Layout Data](#layout-data)
|
290
290
|
- [Canvas Shape DSL](#canvas-shape-dsl)
|
291
|
+
- [Canvas Transform DSL](#canvas-transform-dsl)
|
291
292
|
- [Canvas Animation DSL](#canvas-animation-dsl)
|
292
293
|
- [Data-Binding](#data-binding)
|
293
294
|
- [General Examples](#general-examples)
|
@@ -364,6 +365,7 @@ If you see anything that needs to be improved, please do not hesitate to contact
|
|
364
365
|
- [Hello, Dialog!](#hello-dialog)
|
365
366
|
- [Hello, Canvas!](#hello-canvas)
|
366
367
|
- [Hello, Canvas Animation!](#hello-canvas-animation)
|
368
|
+
- [Hello, Canvas Transform!](#hello-canvas-transform)
|
367
369
|
- [Elaborate Samples](#elaborate-samples)
|
368
370
|
- [User Profile](#user-profile)
|
369
371
|
- [Login](#login)
|
@@ -403,7 +405,7 @@ If you see anything that needs to be improved, please do not hesitate to contact
|
|
403
405
|
|
404
406
|
## Background
|
405
407
|
|
406
|
-
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.
|
408
|
+
[Ruby](https://www.ruby-lang.org) 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](https://www.ruby-lang.org) 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](https://www.eclipse.org/swt/), JFace, and RCP can help fill the gap of desktop application development with Ruby.
|
407
409
|
|
408
410
|
## Platform Support
|
409
411
|
|
@@ -458,7 +460,7 @@ jgem install glimmer-dsl-swt
|
|
458
460
|
|
459
461
|
Or this command if you want a specific version:
|
460
462
|
```
|
461
|
-
jgem install glimmer-dsl-swt -v 4.18.
|
463
|
+
jgem install glimmer-dsl-swt -v 4.18.3.0
|
462
464
|
|
463
465
|
|
464
466
|
```
|
@@ -478,7 +480,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
|
|
478
480
|
|
479
481
|
Add the following to `Gemfile`:
|
480
482
|
```
|
481
|
-
gem 'glimmer-dsl-swt', '~> 4.18.
|
483
|
+
gem 'glimmer-dsl-swt', '~> 4.18.3.0
|
482
484
|
'
|
483
485
|
```
|
484
486
|
|
@@ -537,7 +539,7 @@ bin/glimmer samples
|
|
537
539
|
Below are the full usage instructions that come up when running `glimmer` without args.
|
538
540
|
|
539
541
|
```
|
540
|
-
Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.18.
|
542
|
+
Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.18.3.0
|
541
543
|
|
542
544
|
|
543
545
|
|
@@ -1018,7 +1020,7 @@ Output:
|
|
1018
1020
|
|
1019
1021
|
Css glimmer-dsl-css 1.1.0 AndyMaleh Glimmer DSL for CSS
|
1020
1022
|
Opal glimmer-dsl-opal 0.10.2 AndyMaleh Glimmer DSL for Opal
|
1021
|
-
Swt glimmer-dsl-swt 4.18.
|
1023
|
+
Swt glimmer-dsl-swt 4.18.3.0
|
1022
1024
|
|
1023
1025
|
AndyMaleh Glimmer DSL for SWT
|
1024
1026
|
Tk glimmer-dsl-tk 0.0.6 AndyMaleh Glimmer DSL for Tk
|
@@ -1098,6 +1100,8 @@ Watch out for hands-on examples in this README indicated by "you may copy/paste
|
|
1098
1100
|
|
1099
1101
|
Keep in mind that all samples live under [https://github.com/AndyObtiva/glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt)
|
1100
1102
|
|
1103
|
+
If you need a more GUI interactive option to experiement with Glimmer GUI DSL Syntax, you may try the ["Ugliest Editor Ever"](https://github.com/AndyObtiva/glimmer-cs-gladiator) or just build your own using the [Glimmer DSL for SWT Ruby Gem](https://rubygems.org/gems/glimmer-dsl-swt).
|
1104
|
+
|
1101
1105
|
## Glimmer GUI DSL Syntax
|
1102
1106
|
|
1103
1107
|
Glimmer's core is a GUI DSL with a lightweight visual syntax that makes it easy to visualize the nesting of widgets in the GUI hierarchy tree.
|
@@ -1507,7 +1511,7 @@ Although SWT Display is not technically a widget, it has similar APIs and DSL su
|
|
1507
1511
|
|
1508
1512
|
#### Multi-Threading
|
1509
1513
|
|
1510
|
-
[JRuby](https://www.jruby.org/) supports [truly parallel multi-threading](https://github.com/jruby/jruby/wiki/Concurrency-in-jruby) since it relies on the JVM (Java Virtual Machine). As such, it enables development of highly-interactive desktop applications that can do background work while the user is interacting with the GUI.
|
1514
|
+
[JRuby](https://www.jruby.org/) supports [truly parallel multi-threading](https://github.com/jruby/jruby/wiki/Concurrency-in-jruby) since it relies on the JVM (Java Virtual Machine). As such, it enables development of highly-interactive desktop applications that can do background work while the user is interacting with the GUI. However, any code that interacts with the GUI from a thread other than the main (first) GUI thread must do so only through sync_exec (if it is standard synchronous code) or async_exec.
|
1511
1515
|
|
1512
1516
|
##### async_exec
|
1513
1517
|
|
@@ -1938,7 +1942,7 @@ style = swt(:shell_trim, :max!) # creates a shell trim style without the maximiz
|
|
1938
1942
|
|
1939
1943
|
SWT Shell widget by default is resizable. To make it non-resizable, one must pass a complicated style bit concoction like `swt(:shell_trim, :resize!, :max!)`.
|
1940
1944
|
|
1941
|
-
Glimmer makes this easier by alternatively
|
1945
|
+
Glimmer makes this easier by alternatively ing a `:no_resize` extra SWT style, added for convenience.
|
1942
1946
|
This makes declaring a non-resizable window as easy as:
|
1943
1947
|
|
1944
1948
|
```ruby
|
@@ -2339,6 +2343,7 @@ Here is a list of supported attributes nestable within a block under shapes:
|
|
2339
2343
|
- `line_style` line join style (SWT style value of `:line_solid`, `:line_dash`, `:line_dot`, `:line_dashdot`, or `:line_dashdotdot`)
|
2340
2344
|
- `line_width` line width in integer (used in draw operations)
|
2341
2345
|
- `text_anti_alias` enables text antialiasing (SWT style value of `:default`, `:off`, `:on` whereby `:default` applies OS default, which varies per OS)
|
2346
|
+
- `transform` sets transform object using [Canvas Transform DSL](#canvas-transform-dsl) syntax
|
2342
2347
|
|
2343
2348
|
Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
|
2344
2349
|
|
@@ -2387,6 +2392,8 @@ If you get extremely stuck, remember that you could always default to direct [SW
|
|
2387
2392
|
Example of manually doing the same things as in the above example without relying on the declarative Glimmer Shape DSL:
|
2388
2393
|
|
2389
2394
|
```ruby
|
2395
|
+
image_object = image(File.expand_path('./icons/scaffold_app.png'), width: 100)
|
2396
|
+
|
2390
2397
|
include Glimmer
|
2391
2398
|
|
2392
2399
|
shell {
|
@@ -2397,17 +2404,23 @@ shell {
|
|
2397
2404
|
background :yellow
|
2398
2405
|
|
2399
2406
|
on_paint_control { |event|
|
2400
|
-
event.gc.
|
2401
|
-
event.gc.
|
2407
|
+
event.gc.set_background(color(:red).swt_color)
|
2408
|
+
event.gc.fill_rectangle(0, 0, 220, 400)
|
2402
2409
|
|
2403
|
-
event.gc.
|
2404
|
-
event.gc.
|
2410
|
+
event.gc.set_background(color(:magenta).swt_color)
|
2411
|
+
event.gc.fill_roundRectangle(50, 20, 300, 150, 30, 50)
|
2405
2412
|
|
2406
|
-
event.gc.
|
2407
|
-
event.gc.
|
2413
|
+
event.gc.set_background(color(:dark_magenta).swt_color)
|
2414
|
+
event.gc.fill_gradientRectangle(150, 200, 100, 70, true)
|
2408
2415
|
|
2409
|
-
event.gc.
|
2410
|
-
event.gc.
|
2416
|
+
event.gc.set_foreground(color(:dark_blue).swt_color)
|
2417
|
+
event.gc.draw_rectangle(200, 80, 108, 36)
|
2418
|
+
|
2419
|
+
event.gc.set_foreground(color(:black).swt_color)
|
2420
|
+
event.gc.set_lineWidth(3)
|
2421
|
+
event.gc.draw_rectangle(200, 80, 108, 36)
|
2422
|
+
|
2423
|
+
event.gc.draw_image(image_object.swt_image, 70, 50)
|
2411
2424
|
}
|
2412
2425
|
}
|
2413
2426
|
}.open
|
@@ -2419,6 +2432,86 @@ In any case, if there is anything missing you would like added to the Glimmer Sh
|
|
2419
2432
|
|
2420
2433
|
Keep in mind that the Shape DSL can be used inside any widget, not just `canvas`. Unlike shapes on a `canvas`, which are standalone graphics, when included in a widget, which already has its own look and feel, shapes are used as a decorative add-on that complements its look by getting painted on top of it. For example, shapes were used to decorate `composite` blocks in the [Tetris](#tetris) sample to have a more bevel look. In summary, Shapes can be used in a hybrid approach (shapes inside a widget), not just standalone in a `canvas`.
|
2421
2434
|
|
2435
|
+
### Canvas Transform DSL
|
2436
|
+
|
2437
|
+
The transform DSL builds [org.eclipse.swt.graphics.Transform](https://help.eclipse.org/2020-12/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/graphics/Transform.html) objects with a nice declarative syntax.
|
2438
|
+
|
2439
|
+
`transform` keyword builds a `Transform` object. It optionally takes the transformation matrix elements: (m11, m12, m21, m22, dx, dy)
|
2440
|
+
|
2441
|
+
The first 2 values represent the 1st row, the second 2 values represent the 2nd row, and the last 2 values represent translation on the x and y axes
|
2442
|
+
|
2443
|
+
Additionally, Transform operation keywords may be nested within the `transform` keyword to set its properties:
|
2444
|
+
- `identity` resets transform to identity (no transformation)
|
2445
|
+
- `invert` inverts a transform
|
2446
|
+
- `multiply(&block)` multiplies by another transform (takes a block representing properties of another transform, no need for using the word transform again)
|
2447
|
+
- `rotate(angle)` rotates by angle degrees
|
2448
|
+
- `scale(x, y)` scales a shape (stretch)
|
2449
|
+
- `shear(x, y)` shear effect
|
2450
|
+
- `translate(x, y)` translate x and y coordinates (move)
|
2451
|
+
- `elements(m11, m12, m21, m22, dx, dy)` resets all values of the transform matrix (first 2 values represent the 1st row, second 2 values represent the 2nd row, the last 2 values represent translation on x and y axes)
|
2452
|
+
|
2453
|
+
Also, setting `transform` to `nil` after a previous `transform` has been set is like calling `identity`. It resets the transform.
|
2454
|
+
|
2455
|
+
Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
|
2456
|
+
|
2457
|
+
```ruby
|
2458
|
+
include Glimmer
|
2459
|
+
|
2460
|
+
shell {
|
2461
|
+
text 'Canvas Transform Example'
|
2462
|
+
minimum_size 330, 352
|
2463
|
+
|
2464
|
+
canvas { |canvas_proxy|
|
2465
|
+
background :white
|
2466
|
+
|
2467
|
+
text('glimmer', 0, 0) {
|
2468
|
+
foreground :red
|
2469
|
+
transform {
|
2470
|
+
translate 220, 100
|
2471
|
+
scale 2.5, 2.5
|
2472
|
+
rotate 90
|
2473
|
+
}
|
2474
|
+
}
|
2475
|
+
text('glimmer', 0, 0) {
|
2476
|
+
foreground :dark_green
|
2477
|
+
transform {
|
2478
|
+
translate 0, 0
|
2479
|
+
shear 2, 3
|
2480
|
+
scale 2, 2
|
2481
|
+
}
|
2482
|
+
}
|
2483
|
+
text('glimmer', 0, 0) {
|
2484
|
+
foreground :blue
|
2485
|
+
transform {
|
2486
|
+
translate 0, 220
|
2487
|
+
scale 3, 3
|
2488
|
+
}
|
2489
|
+
}
|
2490
|
+
}
|
2491
|
+
}.open
|
2492
|
+
```
|
2493
|
+
|
2494
|
+
![Canvas Transform Example](images/glimmer-example-canvas-transform.png)
|
2495
|
+
|
2496
|
+
#### Top-Level Transform Fluent Interface
|
2497
|
+
|
2498
|
+
When using a transform at the top-level (outside of shell), you get a fluent interface to faciliate manual constructioni and use.
|
2499
|
+
|
2500
|
+
Example:
|
2501
|
+
|
2502
|
+
```ruby
|
2503
|
+
transform(1, 1, 4, 2, 2, 4).
|
2504
|
+
multiply(1, 2, 3, 4,3,4).
|
2505
|
+
scale(1, 2, 3, 4, 5, 6).
|
2506
|
+
rotate(45).
|
2507
|
+
scale(2, 4).
|
2508
|
+
invert.
|
2509
|
+
shear(2, 4).
|
2510
|
+
translate(3, 7)
|
2511
|
+
```
|
2512
|
+
|
2513
|
+
Learn more at the [Hello, Canvas Transform! Sample](#hello-canvas-transform).
|
2514
|
+
|
2422
2515
|
### Canvas Animation DSL
|
2423
2516
|
|
2424
2517
|
(note: this is a very new feature of Glimmer. It may change a bit while getting battle tested. As always, you could default to basic SWT usage if needed.)
|
@@ -2843,7 +2936,7 @@ Glimmer automatic table sorting supports `String`, `Integer`, and `Float` column
|
|
2843
2936
|
|
2844
2937
|
In cases where data is nil, depending on the data-type, it is automatically converted to `Float` with `to_f`, `Integer` with `to_i`, or `String` with `to_s`.
|
2845
2938
|
|
2846
|
-
Should you have a special data type that could not be compared automatically, Glimmer
|
2939
|
+
Should you have a special data type that could not be compared automatically, Glimmer s the following 3 alternatives for custom sorting:
|
2847
2940
|
- `sort_property`: this may be set to an alternative property to the one data-bound to the table column. For example, a table column called 'adult', which returns `true` or `false` may be sorted with `sort_property :dob` instead. This also support multi-property (aka multi-column) sorting (e.g. `sort_property :dob, :name`).
|
2848
2941
|
- `sort_by(&block)`: this works just like Ruby `Enumerable` `sort_by`. The block receives the table column data as argument.
|
2849
2942
|
- `sort(&comparator)`: this works just like Ruby `Enumerable` `sort`. The comparator block receives two objects from the table column data.
|
@@ -2938,7 +3031,7 @@ a text widget to the user to change the selected or passed tree item text into s
|
|
2938
3031
|
|
2939
3032
|
`date_time` represents the SWT DateTime widget.
|
2940
3033
|
|
2941
|
-
Glimmer
|
3034
|
+
Glimmer s the following alias keywords for it for convenience:
|
2942
3035
|
- `date`: `date_time(:date)`
|
2943
3036
|
- `date_drop_down`: `date_time(:date, :drop_down)`
|
2944
3037
|
- `time`: `date_time(:time)`
|
@@ -3143,7 +3236,7 @@ Approach #1 is a casual Ruby-based approach. Approach #2 is the official Glimmer
|
|
3143
3236
|
|
3144
3237
|
A developer might start with approach #1 to eliminate duplication in a view and later upgrade it to approach #2 when needing to export a custom widget to make it available in many views.
|
3145
3238
|
|
3146
|
-
Class-based Custom Widgets
|
3239
|
+
Class-based Custom Widgets a number of benefits over method-based custom widgets, such as built-in support for passing SWT style, nested block of extra widgets and properties, and `before_body`/`after_body` hooks.
|
3147
3240
|
|
3148
3241
|
#### Simple Example
|
3149
3242
|
|
@@ -3405,7 +3498,7 @@ You may check out [Hello, Custom Shell!](#hello-custom-shell) for another exampl
|
|
3405
3498
|
|
3406
3499
|
### Drag and Drop
|
3407
3500
|
|
3408
|
-
Glimmer
|
3501
|
+
Glimmer s Drag and Drop support, thanks to [SWT](https://www.eclipse.org/swt/) and Glimmer's lightweight [DSL syntax](#glimmer-dsl-syntax).
|
3409
3502
|
|
3410
3503
|
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)
|
3411
3504
|
|
@@ -4581,6 +4674,19 @@ Hello, Canvas Animation Another Frame!
|
|
4581
4674
|
|
4582
4675
|
![Hello Canvas Animation Frame 2](images/glimmer-hello-canvas-animation-frame2.png)
|
4583
4676
|
|
4677
|
+
#### Hello, Canvas Transform!
|
4678
|
+
|
4679
|
+
This sample demonstrates the use of the `transform` keyword as part of the [Transform DSL](#canvas-transform-dsl) within the [Shape DSL](#canvas-shape-dsl).
|
4680
|
+
|
4681
|
+
Code:
|
4682
|
+
|
4683
|
+
[samples/hello/hello_canvas_transform.rb](samples/hello/hello_canvas_transform.rb)
|
4684
|
+
|
4685
|
+
Hello, Canvas Transform!
|
4686
|
+
|
4687
|
+
![Hello Canvas Transform](images/glimmer-hello-canvas-transform.png)
|
4688
|
+
|
4689
|
+
|
4584
4690
|
### Elaborate Samples
|
4585
4691
|
|
4586
4692
|
For more elaborate samples, check the following:
|
@@ -4824,7 +4930,7 @@ Pass `-v` to javapackager in `Glimmer::RakeTask::Package.javapackager_extra_args
|
|
4824
4930
|
|
4825
4931
|
### Windows Application Packaging
|
4826
4932
|
|
4827
|
-
Windows
|
4933
|
+
Windows s two options for setup packaging:
|
4828
4934
|
- `msi` (recommended): simpler packaging option. Requires [WiX Toolset](https://wixtoolset.org/) and [.NET Framework](https://dotnet.microsoft.com/download/dotnet-framework). Simply run `glimmer package[msi]` (or `glimmer package:native[msi]` if it's not your first time) and it will give you more details on the pre-requisites you need to install (e.g. [WiX Toolset](https://wixtoolset.org/) and [.NET Framework 3.5 SP1](https://dotnet.microsoft.com/download/dotnet-framework/net35-sp1)).
|
4829
4935
|
- `exe`: more advanced packaging option. Requires [Inno Setup](https://jrsoftware.org/isinfo.php). Simply run `glimmer package[exe]` (or `glimmer package:native[exe]` if it's not your first time) and it will tell you what you need to install.
|
4830
4936
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.18.
|
1
|
+
4.18.3.0
|
data/glimmer-dsl-swt.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: glimmer-dsl-swt 4.18.
|
5
|
+
# stub: glimmer-dsl-swt 4.18.3.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "glimmer-dsl-swt".freeze
|
9
|
-
s.version = "4.18.
|
9
|
+
s.version = "4.18.3.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["AndyMaleh".freeze]
|
14
|
-
s.date = "2021-01-
|
14
|
+
s.date = "2021-01-26"
|
15
15
|
s.description = "Glimmer DSL for SWT (JRuby Desktop Development GUI Framework) is a native-GUI cross-platform desktop development library written in JRuby, an OS-threaded faster JVM version of Ruby. Glimmer's main innovation is a declarative Ruby DSL that enables productive and efficient authoring of desktop application user-interfaces by relying on the robust Eclipse SWT library. Glimmer additionally innovates by having built-in data-binding support, which greatly facilitates synchronizing the GUI with domain models, thus achieving true decoupling of object oriented components and enabling developers to solve business problems (test-first) without worrying about GUI concerns, or alternatively drive development GUI-first, and then write clean business models (test-first) afterwards. Not only does Glimmer provide a large set of GUI widgets, but it also supports drawing Canvas Graphics like Shapes and Animations. To get started quickly, Glimmer offers scaffolding options for Apps, Gems, and Custom Widgets. Glimmer also includes native-executable packaging support, sorely lacking in other libraries, thus enabling the delivery of desktop apps written in Ruby as truly native DMG/PKG/APP files on the Mac + App Store, MSI/EXE files on Windows, and Gem Packaged Shell Scripts on Linux.".freeze
|
16
16
|
s.email = "andy.am@gmail.com".freeze
|
17
17
|
s.executables = ["glimmer".freeze, "girb".freeze]
|
@@ -69,6 +69,7 @@ Gem::Specification.new do |s|
|
|
69
69
|
"lib/glimmer/dsl/swt/menu_bar_expression.rb",
|
70
70
|
"lib/glimmer/dsl/swt/menu_expression.rb",
|
71
71
|
"lib/glimmer/dsl/swt/message_box_expression.rb",
|
72
|
+
"lib/glimmer/dsl/swt/multiply_expression.rb",
|
72
73
|
"lib/glimmer/dsl/swt/observe_expression.rb",
|
73
74
|
"lib/glimmer/dsl/swt/property_expression.rb",
|
74
75
|
"lib/glimmer/dsl/swt/radio_group_selection_data_binding_expression.rb",
|
@@ -80,6 +81,7 @@ Gem::Specification.new do |s|
|
|
80
81
|
"lib/glimmer/dsl/swt/sync_exec_expression.rb",
|
81
82
|
"lib/glimmer/dsl/swt/tab_item_expression.rb",
|
82
83
|
"lib/glimmer/dsl/swt/table_items_data_binding_expression.rb",
|
84
|
+
"lib/glimmer/dsl/swt/transform_expression.rb",
|
83
85
|
"lib/glimmer/dsl/swt/tree_items_data_binding_expression.rb",
|
84
86
|
"lib/glimmer/dsl/swt/tree_properties_expression.rb",
|
85
87
|
"lib/glimmer/dsl/swt/widget_expression.rb",
|
@@ -120,6 +122,7 @@ Gem::Specification.new do |s|
|
|
120
122
|
"lib/glimmer/swt/tab_item_proxy.rb",
|
121
123
|
"lib/glimmer/swt/table_column_proxy.rb",
|
122
124
|
"lib/glimmer/swt/table_proxy.rb",
|
125
|
+
"lib/glimmer/swt/transform_proxy.rb",
|
123
126
|
"lib/glimmer/swt/tree_proxy.rb",
|
124
127
|
"lib/glimmer/swt/widget_listener_proxy.rb",
|
125
128
|
"lib/glimmer/swt/widget_proxy.rb",
|
@@ -148,6 +151,7 @@ Gem::Specification.new do |s|
|
|
148
151
|
"samples/hello/hello_button.rb",
|
149
152
|
"samples/hello/hello_canvas.rb",
|
150
153
|
"samples/hello/hello_canvas_animation.rb",
|
154
|
+
"samples/hello/hello_canvas_transform.rb",
|
151
155
|
"samples/hello/hello_checkbox.rb",
|
152
156
|
"samples/hello/hello_checkbox_group.rb",
|
153
157
|
"samples/hello/hello_combo.rb",
|
data/lib/glimmer/dsl/swt/dsl.rb
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
# Copyright (c) 2007-2021 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'glimmer/dsl/expression'
|
23
|
+
require 'glimmer/dsl/parent_expression'
|
24
|
+
require 'glimmer/swt/transform_proxy'
|
25
|
+
|
26
|
+
module Glimmer
|
27
|
+
module DSL
|
28
|
+
module SWT
|
29
|
+
# Special treatment for transform {multiply(){} } operation
|
30
|
+
class MultiplyExpression < Expression
|
31
|
+
include ParentExpression
|
32
|
+
|
33
|
+
def can_interpret?(parent, keyword, *args, &block)
|
34
|
+
keyword == 'multiply' and
|
35
|
+
parent.is_a?(Glimmer::SWT::TransformProxy)
|
36
|
+
end
|
37
|
+
|
38
|
+
def interpret(parent, keyword, *args, &block)
|
39
|
+
Glimmer::SWT::TransformProxy.new(parent, *args, multiply: true)
|
40
|
+
end
|
41
|
+
|
42
|
+
def add_content(parent, &block)
|
43
|
+
super
|
44
|
+
parent.post_add_content
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -21,13 +21,15 @@
|
|
21
21
|
|
22
22
|
require 'glimmer/dsl/expression'
|
23
23
|
|
24
|
+
require 'glimmer/swt/transform_proxy'
|
25
|
+
|
24
26
|
module Glimmer
|
25
27
|
module DSL
|
26
28
|
module SWT
|
27
29
|
class PropertyExpression < Expression
|
28
30
|
def can_interpret?(parent, keyword, *args, &block)
|
29
31
|
block.nil? and
|
30
|
-
args.size > 0 and
|
32
|
+
(args.size > 0 || parent.is_a?(Glimmer::SWT::TransformProxy)) and
|
31
33
|
parent.respond_to?(:set_attribute) and
|
32
34
|
parent.respond_to?(:has_attribute?) and
|
33
35
|
parent.has_attribute?(keyword, *args) and
|
@@ -36,7 +38,7 @@ module Glimmer
|
|
36
38
|
|
37
39
|
def interpret(parent, keyword, *args, &block)
|
38
40
|
parent.set_attribute(keyword, *args)
|
39
|
-
|
41
|
+
parent
|
40
42
|
end
|
41
43
|
end
|
42
44
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# Copyright (c) 2007-2021 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'glimmer/dsl/static_expression'
|
23
|
+
require 'glimmer/dsl/top_level_expression'
|
24
|
+
require 'glimmer/dsl/parent_expression'
|
25
|
+
require 'glimmer/swt/custom/shape'
|
26
|
+
require 'glimmer/swt/transform_proxy'
|
27
|
+
|
28
|
+
module Glimmer
|
29
|
+
module DSL
|
30
|
+
module SWT
|
31
|
+
class TransformExpression < StaticExpression
|
32
|
+
include TopLevelExpression
|
33
|
+
include ParentExpression
|
34
|
+
|
35
|
+
def can_interpret?(parent, keyword, *args, &block)
|
36
|
+
super and
|
37
|
+
(parent.nil? or parent.is_a?(Glimmer::SWT::Custom::Shape))
|
38
|
+
end
|
39
|
+
|
40
|
+
def interpret(parent, keyword, *args, &block)
|
41
|
+
Glimmer::SWT::TransformProxy.new(parent, *args)
|
42
|
+
end
|
43
|
+
|
44
|
+
def add_content(parent, &block)
|
45
|
+
super
|
46
|
+
parent.post_add_content
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -36,7 +36,7 @@ module Glimmer
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def resetup_shape_paint_listeners
|
39
|
-
# TODO consider performance
|
39
|
+
# TODO consider performance optimization relating to order of shape rendering (affecting only further shapes not previous ones)
|
40
40
|
shapes.each do |shape|
|
41
41
|
shape.paint_listener_proxy&.unregister
|
42
42
|
shape.setup_paint_listener
|
@@ -24,6 +24,7 @@ require 'glimmer/swt/swt_proxy'
|
|
24
24
|
require 'glimmer/swt/display_proxy'
|
25
25
|
require 'glimmer/swt/color_proxy'
|
26
26
|
require 'glimmer/swt/font_proxy'
|
27
|
+
require 'glimmer/swt/transform_proxy'
|
27
28
|
|
28
29
|
module Glimmer
|
29
30
|
module SWT
|
@@ -115,6 +116,7 @@ module Glimmer
|
|
115
116
|
end
|
116
117
|
|
117
118
|
def apply_property_arg_conversions(method_name, property, args)
|
119
|
+
args = args.dup
|
118
120
|
the_java_method = org.eclipse.swt.graphics.GC.java_class.declared_instance_methods.detect {|m| m.name == method_name}
|
119
121
|
if (args.first.is_a?(Symbol) || args.first.is_a?(String))
|
120
122
|
if the_java_method.parameter_types.first == Color.java_class
|
@@ -133,6 +135,9 @@ module Glimmer
|
|
133
135
|
if args.first.is_a?(FontProxy)
|
134
136
|
args[0] = args[0].swt_font
|
135
137
|
end
|
138
|
+
if args.first.is_a?(TransformProxy)
|
139
|
+
args[0] = args[0].swt_transform
|
140
|
+
end
|
136
141
|
if ['setBackgroundPattern', 'setForegroundPattern'].include?(method_name.to_s)
|
137
142
|
args.each_with_index do |arg, i|
|
138
143
|
if arg.is_a?(Symbol) || arg.is_a?(String)
|
@@ -145,7 +150,7 @@ module Glimmer
|
|
145
150
|
args[0] = org.eclipse.swt.graphics.Pattern.new(*new_args)
|
146
151
|
args[1..-1] = []
|
147
152
|
end
|
148
|
-
|
153
|
+
args
|
149
154
|
end
|
150
155
|
|
151
156
|
def apply_shape_arg_conversions(method_name, args)
|
@@ -193,7 +198,7 @@ module Glimmer
|
|
193
198
|
@parent.redraw
|
194
199
|
end
|
195
200
|
end
|
196
|
-
|
201
|
+
|
197
202
|
def get_attribute(attribute_name)
|
198
203
|
@properties.symbolize_keys[attribute_name.to_s.to_sym]
|
199
204
|
end
|
@@ -210,10 +215,14 @@ module Glimmer
|
|
210
215
|
@properties['background'] = [@parent.background] if fill? && !@properties.keys.map(&:to_s).include?('background')
|
211
216
|
@properties['foreground'] = [@parent.foreground] if draw? && !@properties.keys.map(&:to_s).include?('foreground')
|
212
217
|
@properties['font'] = [@parent.font] if draw? && !@properties.keys.map(&:to_s).include?('font')
|
218
|
+
@properties['transform'] = [nil] if !@properties.keys.map(&:to_s).include?('transform')
|
213
219
|
@properties.each do |property, args|
|
214
220
|
method_name = attribute_setter(property)
|
215
|
-
apply_property_arg_conversions(method_name, property, args)
|
216
|
-
paint_event.gc.send(method_name, *
|
221
|
+
converted_args = apply_property_arg_conversions(method_name, property, args)
|
222
|
+
paint_event.gc.send(method_name, *converted_args)
|
223
|
+
if property == 'transform' && args.first.is_a?(TransformProxy)
|
224
|
+
args.first.swt_transform.dispose
|
225
|
+
end
|
217
226
|
end
|
218
227
|
apply_shape_arg_conversions(@method_name, @args)
|
219
228
|
apply_shape_arg_defaults(@method_name, @args)
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# Copyright (c) 2007-2021 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'glimmer/swt/display_proxy'
|
23
|
+
require 'glimmer/swt/properties'
|
24
|
+
require 'glimmer/swt/custom/shape'
|
25
|
+
|
26
|
+
module Glimmer
|
27
|
+
module SWT
|
28
|
+
# Proxy for org.eclipse.swt.graphics.Transform
|
29
|
+
#
|
30
|
+
# Follows the Proxy Design Pattern
|
31
|
+
class TransformProxy
|
32
|
+
include Properties
|
33
|
+
|
34
|
+
include_package 'org.eclipse.swt.graphics'
|
35
|
+
include_package 'org.eclipse.swt.widgets'
|
36
|
+
|
37
|
+
attr_reader :swt_transform, :parent
|
38
|
+
|
39
|
+
def initialize(parent, *args, swt_transform: nil, multiply: false)
|
40
|
+
@parent = parent
|
41
|
+
@multiply = multiply
|
42
|
+
if swt_transform.nil?
|
43
|
+
if !args.first.is_a?(Display) && !args.first.is_a?(DisplayProxy)
|
44
|
+
args.prepend DisplayProxy.instance.swt_display
|
45
|
+
end
|
46
|
+
if args.first.is_a?(DisplayProxy)
|
47
|
+
args[0] = args[0].swt_display
|
48
|
+
end
|
49
|
+
if args.last.is_a?(TransformProxy)
|
50
|
+
args[-1] = args[-1].swt_transform
|
51
|
+
end
|
52
|
+
if args.last.nil? || args.last.is_a?(Transform)
|
53
|
+
@swt_transform = args.last
|
54
|
+
@parent&.set_attribute('transform', self)
|
55
|
+
else
|
56
|
+
@swt_transform = Transform.new(*args)
|
57
|
+
end
|
58
|
+
else
|
59
|
+
@swt_transform = swt_transform
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def post_add_content
|
64
|
+
if @multiply
|
65
|
+
@parent.multiply(@swt_transform)
|
66
|
+
else
|
67
|
+
@parent&.set_attribute('transform', self)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def content(&block)
|
72
|
+
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::SWT::TransformExpression.new, &block)
|
73
|
+
end
|
74
|
+
|
75
|
+
def has_attribute?(attribute_name, *args)
|
76
|
+
@swt_transform.respond_to?(attribute_name) || @swt_transform.respond_to?(attribute_setter(attribute_name))
|
77
|
+
end
|
78
|
+
|
79
|
+
def set_attribute(attribute_name, *args)
|
80
|
+
if @swt_transform.respond_to?(attribute_name)
|
81
|
+
@swt_transform.send(attribute_name, *args)
|
82
|
+
elsif @swt_transform.respond_to?(attribute_setter(attribute_name))
|
83
|
+
@swt_transform.send(attribute_setter(attribute_name), *args)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def get_attribute(attribute_name)
|
88
|
+
if @swt_transform.respond_to?(attribute_getter(attribute_name))
|
89
|
+
@swt_transform.send(attribute_getter(attribute_name))
|
90
|
+
else
|
91
|
+
@swt_transform.send(attribute_name)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def method_missing(method_name, *args, &block)
|
96
|
+
result = @swt_transform.send(method_name, *args, &block)
|
97
|
+
result.nil? ? self : result
|
98
|
+
rescue => e
|
99
|
+
Glimmer::Config.logger.debug {"Neither MessageBoxProxy nor #{@swt_transform.class.name} can handle the method ##{method}"}
|
100
|
+
super
|
101
|
+
end
|
102
|
+
|
103
|
+
def respond_to?(method, *args, &block)
|
104
|
+
super ||
|
105
|
+
@swt_transform.respond_to?(method, *args, &block)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
include Glimmer
|
2
|
+
|
3
|
+
glimmer_logo = File.expand_path('../../images/glimmer-logo-hi-res.png', __dir__)
|
4
|
+
|
5
|
+
shell {
|
6
|
+
text 'Hello, Canvas Transform!'
|
7
|
+
minimum_size 330, 352
|
8
|
+
|
9
|
+
canvas { |canvas_proxy|
|
10
|
+
background :white
|
11
|
+
|
12
|
+
image(glimmer_logo, 0, 0) {
|
13
|
+
transform {
|
14
|
+
translate 110, 110
|
15
|
+
rotate 90
|
16
|
+
scale 0.21, 0.21
|
17
|
+
}
|
18
|
+
}
|
19
|
+
image(glimmer_logo, 0, 0) {
|
20
|
+
transform {
|
21
|
+
translate 110, 220
|
22
|
+
scale 0.21, 0.21
|
23
|
+
}
|
24
|
+
}
|
25
|
+
image(glimmer_logo, 0, 0) {
|
26
|
+
transform {
|
27
|
+
translate 220, 220
|
28
|
+
rotate 270
|
29
|
+
scale 0.21, 0.21
|
30
|
+
}
|
31
|
+
}
|
32
|
+
image(glimmer_logo, 0, 0) {
|
33
|
+
transform {
|
34
|
+
translate 220, 110
|
35
|
+
rotate 180
|
36
|
+
scale 0.21, 0.21
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}.open
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-swt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.18.
|
4
|
+
version: 4.18.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AndyMaleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -402,6 +402,7 @@ files:
|
|
402
402
|
- lib/glimmer/dsl/swt/menu_bar_expression.rb
|
403
403
|
- lib/glimmer/dsl/swt/menu_expression.rb
|
404
404
|
- lib/glimmer/dsl/swt/message_box_expression.rb
|
405
|
+
- lib/glimmer/dsl/swt/multiply_expression.rb
|
405
406
|
- lib/glimmer/dsl/swt/observe_expression.rb
|
406
407
|
- lib/glimmer/dsl/swt/property_expression.rb
|
407
408
|
- lib/glimmer/dsl/swt/radio_group_selection_data_binding_expression.rb
|
@@ -413,6 +414,7 @@ files:
|
|
413
414
|
- lib/glimmer/dsl/swt/sync_exec_expression.rb
|
414
415
|
- lib/glimmer/dsl/swt/tab_item_expression.rb
|
415
416
|
- lib/glimmer/dsl/swt/table_items_data_binding_expression.rb
|
417
|
+
- lib/glimmer/dsl/swt/transform_expression.rb
|
416
418
|
- lib/glimmer/dsl/swt/tree_items_data_binding_expression.rb
|
417
419
|
- lib/glimmer/dsl/swt/tree_properties_expression.rb
|
418
420
|
- lib/glimmer/dsl/swt/widget_expression.rb
|
@@ -453,6 +455,7 @@ files:
|
|
453
455
|
- lib/glimmer/swt/tab_item_proxy.rb
|
454
456
|
- lib/glimmer/swt/table_column_proxy.rb
|
455
457
|
- lib/glimmer/swt/table_proxy.rb
|
458
|
+
- lib/glimmer/swt/transform_proxy.rb
|
456
459
|
- lib/glimmer/swt/tree_proxy.rb
|
457
460
|
- lib/glimmer/swt/widget_listener_proxy.rb
|
458
461
|
- lib/glimmer/swt/widget_proxy.rb
|
@@ -481,6 +484,7 @@ files:
|
|
481
484
|
- samples/hello/hello_button.rb
|
482
485
|
- samples/hello/hello_canvas.rb
|
483
486
|
- samples/hello/hello_canvas_animation.rb
|
487
|
+
- samples/hello/hello_canvas_transform.rb
|
484
488
|
- samples/hello/hello_checkbox.rb
|
485
489
|
- samples/hello/hello_checkbox_group.rb
|
486
490
|
- samples/hello/hello_combo.rb
|