glimmer-dsl-swt 4.18.4.6 → 4.18.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +4 -4
- data/VERSION +1 -1
- data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +43 -18
- data/glimmer-dsl-swt.gemspec +2 -2
- data/lib/glimmer/swt/custom/shape.rb +24 -24
- data/lib/glimmer/swt/widget_proxy.rb +1 -1
- data/samples/elaborate/tetris.rb +5 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51dc789287aa0203306dc929ed567af49696f266cab8581f5aa4252ec61055a0
|
4
|
+
data.tar.gz: 8c4f4042cb47f7a21b82894160358a70e119c2ddd4bee12ad3318e626c376f23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0a663e6bec722f38050619d6d9ffe5cd65cc3e7384a19447b2ce83d2ec7a24abb4b591e067c75616df5fa85647886ac78b565fe22f67c51381b09030cbd9ec4
|
7
|
+
data.tar.gz: f31423c8317d5199a1188daadb712b7933277714215a392870056e83d726a9ab27cd8b7b9fcbaf9446bab2c176145149a358049e80762f6b953814238a3d518e
|
data/CHANGELOG.md
CHANGED
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.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.4.7
|
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)
|
@@ -342,7 +342,7 @@ jgem install glimmer-dsl-swt
|
|
342
342
|
|
343
343
|
Or this command if you want a specific version:
|
344
344
|
```
|
345
|
-
jgem install glimmer-dsl-swt -v 4.18.4.
|
345
|
+
jgem install glimmer-dsl-swt -v 4.18.4.7
|
346
346
|
```
|
347
347
|
|
348
348
|
`jgem` is JRuby's version of `gem` command.
|
@@ -360,7 +360,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
|
|
360
360
|
|
361
361
|
Add the following to `Gemfile`:
|
362
362
|
```
|
363
|
-
gem 'glimmer-dsl-swt', '~> 4.18.4.
|
363
|
+
gem 'glimmer-dsl-swt', '~> 4.18.4.7'
|
364
364
|
```
|
365
365
|
|
366
366
|
And, then run:
|
@@ -433,7 +433,7 @@ Glimmer simplifies the process of native-executable packaging and distribution o
|
|
433
433
|
|
434
434
|
## App Updates
|
435
435
|
|
436
|
-
Glimmer
|
436
|
+
Glimmer already supports automatic (and manual) app updates via the Mac App Store for Mac apps. Simply run the `glimmer package` command with the Mac App Store keys configured as per [Mac Application Distribution](mac-application-distribution) instructions and you get automatic (and manual) app update support courtesy of the Mac App Store.
|
437
437
|
|
438
438
|
## Glimmer Supporting Libraries
|
439
439
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.18.4.
|
1
|
+
4.18.4.7
|
@@ -1282,6 +1282,8 @@ https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/
|
|
1282
1282
|
|
1283
1283
|
Glimmer supports drawing graphics directly on a `canvas` widget via SWT (or any widget for that matter though `canvas` is recommended for drawing).
|
1284
1284
|
|
1285
|
+
`canvas` has the `:double_buffered` SWT style by default to ensure flicker-free rendering. If you need to disable it for whatever reason, just pass the `:none` SWT style instead (e.g. `canvas(:none)`)
|
1286
|
+
|
1285
1287
|
This is accomplished via the Shape DSL a sub-DSL of the Glimmer GUI DSL, which makes it possible to draw graphics declaratively with very understandable and maintainable syntax.
|
1286
1288
|
|
1287
1289
|
Shape keywords and their args (including defaults) are listed below (they basically match method names and arguments on [org.eclipse.swt.graphics.GC](https://help.eclipse.org/2020-12/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/graphics/GC.html) minus the `draw` or `fill` prefix in downcase):
|
@@ -1367,9 +1369,31 @@ Screenshot:
|
|
1367
1369
|
|
1368
1370
|
Learn more at the [Hello, Canvas! Sample](#hello-canvas).
|
1369
1371
|
|
1370
|
-
|
1372
|
+
#### Pixel Graphics
|
1373
|
+
|
1374
|
+
**(Early Alpha Feature)**
|
1371
1375
|
|
1372
|
-
|
1376
|
+
If you need to paint pixel graphics, use the optimized `pixel` keyword alternative to `point`, which takes foreground as a hash argument and bypasses the [Glimmer DSL Engine chain of responsibility](https://github.com/AndyObtiva/glimmer#dsl-engine), thus rendering faster when having very large pixel numbers.
|
1377
|
+
|
1378
|
+
Example (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
|
1379
|
+
|
1380
|
+
```ruby
|
1381
|
+
shell {
|
1382
|
+
minimum_size 250, 265
|
1383
|
+
|
1384
|
+
canvas {
|
1385
|
+
250.times {|y|
|
1386
|
+
250.times {|x|
|
1387
|
+
pixel(x, y, foreground: color(y%255, x%255, (x+y)%255).swt_color)
|
1388
|
+
}
|
1389
|
+
}
|
1390
|
+
}
|
1391
|
+
}.open
|
1392
|
+
```
|
1393
|
+
|
1394
|
+
Remember that you could always default to direct [SWT GC Usage]([org.eclipse.swt.graphics.GC](https://help.eclipse.org/2020-12/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/graphics/GC.html) too for even faster performance (when rarely needed). Learn more at the [SWT Graphics Guide](https://www.eclipse.org/articles/Article-SWT-graphics/SWT_graphics.html) and [SWT Image Guide](https://www.eclipse.org/articles/Article-SWT-images/graphics-resources.html#Saving%20Images).
|
1395
|
+
|
1396
|
+
Example of manually doing the same things as in the Canvas Shape DSL example without relying on the declarative Glimmer Shape DSL:
|
1373
1397
|
|
1374
1398
|
```ruby
|
1375
1399
|
image_object = image(File.expand_path('./icons/scaffold_app.png'), width: 100)
|
@@ -1383,31 +1407,30 @@ shell {
|
|
1383
1407
|
canvas {
|
1384
1408
|
background :yellow
|
1385
1409
|
|
1386
|
-
on_paint_control { |
|
1387
|
-
|
1388
|
-
|
1410
|
+
on_paint_control { |paint_event|
|
1411
|
+
gc = paint_event.gc
|
1412
|
+
gc.background = color(:red).swt_color
|
1413
|
+
gc.fill_rectangle(0, 0, 220, 400)
|
1389
1414
|
|
1390
|
-
|
1391
|
-
|
1415
|
+
gc.background = color(:magenta).swt_color
|
1416
|
+
gc.fill_roundRectangle(50, 20, 300, 150, 30, 50)
|
1392
1417
|
|
1393
|
-
|
1394
|
-
|
1418
|
+
gc.background = color(:dark_magenta).swt_color
|
1419
|
+
gc.fill_gradientRectangle(150, 200, 100, 70, true)
|
1395
1420
|
|
1396
|
-
|
1397
|
-
|
1421
|
+
gc.foreground = color(:dark_blue).swt_color
|
1422
|
+
gc.draw_rectangle(200, 80, 108, 36)
|
1398
1423
|
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1424
|
+
gc.foreground = color(:black).swt_color
|
1425
|
+
gc.line_width = 3
|
1426
|
+
gc.draw_rectangle(200, 80, 108, 36)
|
1402
1427
|
|
1403
|
-
|
1428
|
+
gc.draw_image(image_object.swt_image, 70, 50)
|
1404
1429
|
}
|
1405
1430
|
}
|
1406
1431
|
}.open
|
1407
1432
|
```
|
1408
1433
|
|
1409
|
-
In any case, if there is anything missing you would like added to the Glimmer Shape DSL that you saw available in the SWT APIs, you may [report an issue](https://github.com/AndyObtiva/glimmer-dsl-swt/issues) or implement yourself and [contribute](#contributing) via a [Pull Request](https://github.com/AndyObtiva/glimmer-dsl-swt/pulls).
|
1410
|
-
|
1411
1434
|
#### Shapes inside a Widget
|
1412
1435
|
|
1413
1436
|
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`.
|
@@ -1595,7 +1618,7 @@ Learn more at the [Hello, Canvas Transform! Sample](#hello-canvas-transform).
|
|
1595
1618
|
|
1596
1619
|
### Canvas Animation DSL
|
1597
1620
|
|
1598
|
-
**(
|
1621
|
+
**(ALPHA FEATURE)**
|
1599
1622
|
|
1600
1623
|
(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.)
|
1601
1624
|
|
@@ -1605,6 +1628,8 @@ Animations take advantage of multi-threading, automatically running each animati
|
|
1605
1628
|
|
1606
1629
|
Multiple simultaneous animations are supported by declaring an animation per `canvas` (or widget) parent.
|
1607
1630
|
|
1631
|
+
`canvas` has the `:double_buffered` SWT style by default to ensure flicker-free rendering. If you need to disable it for whatever reason, just pass the `:none` SWT style instead (e.g. `canvas(:none)`)
|
1632
|
+
|
1608
1633
|
This example says it all (it moves a tiny red square across a blue background) (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
|
1609
1634
|
|
1610
1635
|
```ruby
|
data/glimmer-dsl-swt.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
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.4.
|
5
|
+
# stub: glimmer-dsl-swt 4.18.4.7 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "glimmer-dsl-swt".freeze
|
9
|
-
s.version = "4.18.4.
|
9
|
+
s.version = "4.18.4.7"
|
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]
|
@@ -133,7 +133,7 @@ module Glimmer
|
|
133
133
|
|
134
134
|
def post_add_content
|
135
135
|
unless @content_added
|
136
|
-
amend_method_name_options_based_on_properties
|
136
|
+
amend_method_name_options_based_on_properties!
|
137
137
|
@parent.setup_shape_painting
|
138
138
|
@content_added = true
|
139
139
|
end
|
@@ -177,41 +177,41 @@ module Glimmer
|
|
177
177
|
args
|
178
178
|
end
|
179
179
|
|
180
|
-
def apply_shape_arg_conversions
|
181
|
-
if args.size > 1 && (
|
182
|
-
args[0] = args.dup
|
183
|
-
args[1..-1] = []
|
180
|
+
def apply_shape_arg_conversions!
|
181
|
+
if @args.size > 1 && (['polygon', 'polyline'].include?(@name))
|
182
|
+
@args[0] = @args.dup
|
183
|
+
@args[1..-1] = []
|
184
184
|
end
|
185
185
|
end
|
186
186
|
|
187
|
-
def apply_shape_arg_defaults
|
188
|
-
if
|
189
|
-
(6 - args.size).times {args << 60}
|
190
|
-
elsif
|
191
|
-
args << true
|
192
|
-
elsif (
|
193
|
-
args << true
|
187
|
+
def apply_shape_arg_defaults!
|
188
|
+
if @name.include?('rectangle') && round? && @args.size.between?(4, 5)
|
189
|
+
(6 - @args.size).times {@args << 60}
|
190
|
+
elsif @name.include?('rectangle') && gradient? && @args.size == 4
|
191
|
+
@args << true
|
192
|
+
elsif (@name.include?('text') || @name.include?('String')) && !@properties.keys.map(&:to_s).include?('background') && @args.size == 3
|
193
|
+
@args << true
|
194
194
|
end
|
195
|
-
if
|
196
|
-
args[0] = ImageProxy.new(args[0])
|
195
|
+
if @name.include?('image') && @args.first.is_a?(String)
|
196
|
+
@args[0] = ImageProxy.new(@args[0])
|
197
197
|
end
|
198
|
-
if
|
199
|
-
@image = args[0] = args[0].swt_image
|
198
|
+
if @name.include?('image') && @args.first.is_a?(ImageProxy)
|
199
|
+
@image = @args[0] = @args[0].swt_image
|
200
200
|
end
|
201
201
|
end
|
202
202
|
|
203
203
|
# Tolerates shape extra args added by user by mistake
|
204
204
|
# (e.g. happens when switching from round rectangle to a standard one without removing all extra args)
|
205
|
-
def tolerate_shape_extra_args
|
205
|
+
def tolerate_shape_extra_args!
|
206
206
|
the_java_method_arg_count = org.eclipse.swt.graphics.GC.java_class.declared_instance_methods.select do |m|
|
207
|
-
m.name == method_name.camelcase(:lower)
|
207
|
+
m.name == @method_name.camelcase(:lower)
|
208
208
|
end.map(&:parameter_types).map(&:size).max
|
209
|
-
if args.size > the_java_method_arg_count
|
210
|
-
args[the_java_method_arg_count..-1] = []
|
209
|
+
if @args.size > the_java_method_arg_count
|
210
|
+
@args[the_java_method_arg_count..-1] = []
|
211
211
|
end
|
212
212
|
end
|
213
213
|
|
214
|
-
def amend_method_name_options_based_on_properties
|
214
|
+
def amend_method_name_options_based_on_properties!
|
215
215
|
return if @name == 'point'
|
216
216
|
if has_some_background? && !has_some_foreground?
|
217
217
|
@options[:fill] = true
|
@@ -286,9 +286,9 @@ module Glimmer
|
|
286
286
|
converted_args = apply_property_arg_conversions(method_name, property, args)
|
287
287
|
@properties[property] = converted_args
|
288
288
|
end
|
289
|
-
apply_shape_arg_conversions
|
290
|
-
apply_shape_arg_defaults
|
291
|
-
tolerate_shape_extra_args
|
289
|
+
apply_shape_arg_conversions!
|
290
|
+
apply_shape_arg_defaults!
|
291
|
+
tolerate_shape_extra_args!
|
292
292
|
@calculated_paint_args = true
|
293
293
|
end
|
294
294
|
end
|
data/samples/elaborate/tetris.rb
CHANGED
@@ -155,19 +155,19 @@ class Tetris
|
|
155
155
|
color = colored ? color(([:white] + Model::Tetromino::LETTER_COLORS.values).sample) : color(:white)
|
156
156
|
x = column * icon_block_size
|
157
157
|
y = row * icon_block_size
|
158
|
-
rectangle(x, y, icon_block_size, icon_block_size
|
158
|
+
rectangle(x, y, icon_block_size, icon_block_size) {
|
159
159
|
background color
|
160
160
|
}
|
161
|
-
polygon(x, y, x + icon_block_size, y, x + icon_block_size - icon_bevel_pixel_size, y + icon_bevel_pixel_size, x + icon_bevel_pixel_size, y + icon_bevel_pixel_size
|
161
|
+
polygon(x, y, x + icon_block_size, y, x + icon_block_size - icon_bevel_pixel_size, y + icon_bevel_pixel_size, x + icon_bevel_pixel_size, y + icon_bevel_pixel_size) {
|
162
162
|
background rgb(color.red + 4*BEVEL_CONSTANT, color.green + 4*BEVEL_CONSTANT, color.blue + 4*BEVEL_CONSTANT)
|
163
163
|
}
|
164
|
-
polygon(x + icon_block_size, y, x + icon_block_size - icon_bevel_pixel_size, y + icon_bevel_pixel_size, x + icon_block_size - icon_bevel_pixel_size, y + icon_block_size - icon_bevel_pixel_size, x + icon_block_size, y + icon_block_size
|
164
|
+
polygon(x + icon_block_size, y, x + icon_block_size - icon_bevel_pixel_size, y + icon_bevel_pixel_size, x + icon_block_size - icon_bevel_pixel_size, y + icon_block_size - icon_bevel_pixel_size, x + icon_block_size, y + icon_block_size) {
|
165
165
|
background rgb(color.red - BEVEL_CONSTANT, color.green - BEVEL_CONSTANT, color.blue - BEVEL_CONSTANT)
|
166
166
|
}
|
167
|
-
polygon(x + icon_block_size, y + icon_block_size, x, y + icon_block_size, x + icon_bevel_pixel_size, y + icon_block_size - icon_bevel_pixel_size, x + icon_block_size - icon_bevel_pixel_size, y + icon_block_size - icon_bevel_pixel_size
|
167
|
+
polygon(x + icon_block_size, y + icon_block_size, x, y + icon_block_size, x + icon_bevel_pixel_size, y + icon_block_size - icon_bevel_pixel_size, x + icon_block_size - icon_bevel_pixel_size, y + icon_block_size - icon_bevel_pixel_size) {
|
168
168
|
background rgb(color.red - 2*BEVEL_CONSTANT, color.green - 2*BEVEL_CONSTANT, color.blue - 2*BEVEL_CONSTANT)
|
169
169
|
}
|
170
|
-
polygon(x, y, x, y + icon_block_size, x + icon_bevel_pixel_size, y + icon_block_size - icon_bevel_pixel_size, x + icon_bevel_pixel_size, y + icon_bevel_pixel_size
|
170
|
+
polygon(x, y, x, y + icon_block_size, x + icon_bevel_pixel_size, y + icon_block_size - icon_bevel_pixel_size, x + icon_bevel_pixel_size, y + icon_bevel_pixel_size) {
|
171
171
|
background rgb(color.red - BEVEL_CONSTANT, color.green - BEVEL_CONSTANT, color.blue - BEVEL_CONSTANT)
|
172
172
|
}
|
173
173
|
}
|