glimmer-dsl-swt 4.20.13.12 → 4.20.13.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/README.md +5 -10
- data/VERSION +1 -1
- data/docs/reference/GLIMMER_SAMPLES.md +84 -2
- data/glimmer-dsl-swt.gemspec +0 -0
- data/lib/glimmer-dsl-swt.rb +1 -0
- data/lib/glimmer/swt/custom/drawable.rb +1 -0
- data/lib/glimmer/swt/custom/shape.rb +19 -0
- data/lib/glimmer/swt/custom/shape/arc.rb +2 -0
- data/lib/glimmer/swt/custom/shape/cubic.rb +1 -0
- data/lib/glimmer/swt/custom/shape/line.rb +1 -0
- data/lib/glimmer/swt/custom/shape/oval.rb +2 -0
- data/lib/glimmer/swt/custom/shape/path.rb +1 -5
- data/lib/glimmer/swt/custom/shape/point.rb +1 -0
- data/lib/glimmer/swt/custom/shape/polygon.rb +2 -0
- data/lib/glimmer/swt/custom/shape/polyline.rb +1 -0
- data/lib/glimmer/swt/custom/shape/rectangle.rb +1 -0
- data/lib/glimmer/swt/display_proxy.rb +8 -6
- data/lib/glimmer/ui/custom_shell.rb +1 -1
- data/lib/glimmer/ui/custom_widget.rb +3 -3
- data/samples/elaborate/battleship.rb +79 -0
- data/samples/elaborate/battleship/model/cell.rb +84 -0
- data/samples/elaborate/battleship/model/game.rb +143 -0
- data/samples/elaborate/battleship/model/grid.rb +54 -0
- data/samples/elaborate/battleship/model/ship.rb +114 -0
- data/samples/elaborate/battleship/model/ship_collection.rb +56 -0
- data/samples/elaborate/battleship/view/action_panel.rb +59 -0
- data/samples/elaborate/battleship/view/cell.rb +163 -0
- data/samples/elaborate/battleship/view/grid.rb +77 -0
- data/samples/elaborate/battleship/view/ship.rb +65 -0
- data/samples/elaborate/battleship/view/ship_collection.rb +49 -0
- data/samples/elaborate/connect4.rb +116 -0
- data/samples/elaborate/connect4/model/grid.rb +174 -0
- data/samples/elaborate/connect4/model/slot.rb +36 -0
- data/samples/elaborate/klondike_solitaire.rb +1 -1
- data/samples/elaborate/klondike_solitaire/view/column_pile.rb +0 -1
- data/samples/elaborate/klondike_solitaire/view/foundation_pile.rb +0 -2
- data/samples/elaborate/parking.rb +146 -0
- data/samples/elaborate/parking/model/parking_floor.rb +41 -0
- data/samples/elaborate/parking/model/parking_presenter.rb +42 -0
- data/samples/elaborate/parking/model/parking_spot.rb +46 -0
- data/samples/hello/hello_custom_shell.rb +2 -0
- metadata +20 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcbde18522dded899e463ea9f5e1d94325707b9403392717e624b7475e6e6725
|
4
|
+
data.tar.gz: 53c6de1396110f443afca9378642c66b8813e7fd329ba3f860951ccc4ec11793
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 186a4ebb62c01d54c91470623ea689e52b984e5fb01137bc78cc3113a2599fbfe20113b40e1afaa1adf1648af08e6df2f3bada47bb8afd2ab73730a1eb218a2b
|
7
|
+
data.tar.gz: e837367673f9b8964d97e34e5a1aa4162618b312aadf341808e3a50653dadaf1f387b4d7845caf584519c24a1d7c6b3cc9aa59c7f0f4be574875f3ac579be98e
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
### 4.20.13.16
|
4
|
+
|
5
|
+
- Fix issue with setting app name (via `Display.app_name=`) when app is not packaged (always gets set to Glimmer)
|
6
|
+
- Fix Hello, Custom Shell! sample
|
7
|
+
|
8
|
+
### 4.20.13.15
|
9
|
+
|
10
|
+
- Battleship elaborate sample
|
11
|
+
|
12
|
+
### 4.20.13.14
|
13
|
+
|
14
|
+
- Connect 4 elaborate sample
|
15
|
+
|
16
|
+
### 4.20.13.13
|
17
|
+
|
18
|
+
- Parking elaborate sample
|
19
|
+
- Support shape contain?/include? when a transform (e.g. rotation) is applied
|
20
|
+
|
3
21
|
### 4.20.13.12
|
4
22
|
|
5
23
|
- Fixed issue with dragged shapes having `drag_source true` not going back to original position when not dropped in a target if they were part of a composite shape
|
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.20.13.
|
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.20.13.16
|
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)
|
@@ -15,7 +15,7 @@
|
|
15
15
|
[<img src="https://covers.oreillystatic.com/images/9780596519650/lrg.jpg" width=105 /><br />
|
16
16
|
Featured in JRuby Cookbook](http://shop.oreilly.com/product/9780596519650.do) and [Chalmers/Gothenburg University Software Engineering Master's Lecture Material](http://www.cse.chalmers.se/~bergert/slides/guest_lecture_DSLs.pdf)
|
17
17
|
|
18
|
-
[Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.20.13.
|
18
|
+
[Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.20.13.16 includes [SWT 4.20](https://download.eclipse.org/eclipse/downloads/drops4/R-4.20-202106111600/), which was released on June 11, 2021. Gem version numbers are in sync with the SWT library versions. The first two digits represent the SWT version number. The last two digits represent the minor and patch versions of Glimmer DSL for SWT. Note that SWT now supports AARCH64 on Mac and Linux, but it is not fully tested in Glimmer DSL for SWT yet, so deem its support experimental for the time being without guarantees for functionality until declared otherwise (please report any issues you may encounter).
|
19
19
|
|
20
20
|
**Starting in version 4.20.0.0, [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) comes with the new [***Shine***](/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#shine) syntax** for highly intuitive and visually expressive View/Model Attribute Mapping, relying on `<=>` for bidirectional (two-way) data-binding and `<=` for unidirectional (one-way) data-binding, providing an alternative to the `bind` keyword (keep in mind that it is still a beta, so default back to `bind` whenever needed).
|
21
21
|
|
@@ -199,11 +199,6 @@ Glimmer app:
|
|
199
199
|
|
200
200
|
[![Math Bowling App Screenshot](https://raw.githubusercontent.com/AndyObtiva/MathBowling/master/Math-Bowling-Screenshot.png)](https://github.com/AndyObtiva/MathBowling)
|
201
201
|
|
202
|
-
**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.
|
203
|
-
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.
|
204
|
-
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.
|
205
|
-
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).
|
206
|
-
|
207
202
|
## Table of contents
|
208
203
|
|
209
204
|
- [Glimmer (JRuby Desktop Development GUI Framework)](#jruby-desktop-development-gui-framework)
|
@@ -326,7 +321,7 @@ jgem install glimmer-dsl-swt
|
|
326
321
|
|
327
322
|
Or this command if you want a specific version:
|
328
323
|
```
|
329
|
-
jgem install glimmer-dsl-swt -v 4.20.13.
|
324
|
+
jgem install glimmer-dsl-swt -v 4.20.13.16
|
330
325
|
```
|
331
326
|
|
332
327
|
`jgem` is JRuby's version of `gem` command.
|
@@ -354,7 +349,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
|
|
354
349
|
|
355
350
|
Add the following to `Gemfile`:
|
356
351
|
```
|
357
|
-
gem 'glimmer-dsl-swt', '~> 4.20.13.
|
352
|
+
gem 'glimmer-dsl-swt', '~> 4.20.13.16'
|
358
353
|
```
|
359
354
|
|
360
355
|
And, then run:
|
@@ -375,7 +370,7 @@ glimmer
|
|
375
370
|
```
|
376
371
|
|
377
372
|
```
|
378
|
-
Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.20.13.
|
373
|
+
Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.20.13.16
|
379
374
|
|
380
375
|
Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
|
381
376
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.20.13.
|
1
|
+
4.20.13.16
|
@@ -60,11 +60,14 @@
|
|
60
60
|
- [User Profile](#user-profile)
|
61
61
|
- [Login](#login)
|
62
62
|
- [Tic Tac Toe](#tic-tac-toe)
|
63
|
+
- [Connect 4](#connect-4)
|
63
64
|
- [Contact Manager](#contact-manager)
|
64
65
|
- [Game of Life](#game-of-life)
|
65
66
|
- [Glimmer Tetris](#glimmer-tetris)
|
66
67
|
- [Klondike Solitaire](#klondike-solitaire)
|
68
|
+
- [Battleship](#battleship)
|
67
69
|
- [Mandelbrot Fractal](#mandelbrot-fractal)
|
70
|
+
- [Parking](#parking)
|
68
71
|
- [Stock Ticker](#stock-ticker)
|
69
72
|
- [Metronome](#metronome)
|
70
73
|
- [Weather](#weather)
|
@@ -72,6 +75,7 @@
|
|
72
75
|
- [Glimmer Calculator](#glimmer-calculator)
|
73
76
|
- [Gladiator](#gladiator)
|
74
77
|
- [Timer](#timer)
|
78
|
+
- [Glimmer Klondike Solitaire](#glimmer-klondike-solitaire)
|
75
79
|
- [License](#license)
|
76
80
|
|
77
81
|
## Samples
|
@@ -1044,6 +1048,34 @@ Code:
|
|
1044
1048
|
![Tic Tac Toe In Progress](/images/glimmer-tic-tac-toe-in-progress.png)
|
1045
1049
|
![Tic Tac Toe Game Over](/images/glimmer-tic-tac-toe-game-over.png)
|
1046
1050
|
|
1051
|
+
#### Connect 4
|
1052
|
+
|
1053
|
+
This sample demonstrates a widget/shape hybrid MVC application, including GUI layout and data-binding.
|
1054
|
+
|
1055
|
+
Code:
|
1056
|
+
|
1057
|
+
[samples/elaborate/connect4.rb](/samples/elaborate/connect4.rb)
|
1058
|
+
|
1059
|
+
Connect 4
|
1060
|
+
|
1061
|
+
![Connect 4](/images/glimmer-connect4.png)
|
1062
|
+
|
1063
|
+
Connect 4 - About To Drop
|
1064
|
+
|
1065
|
+
![Connect 4 About To Drop](/images/glimmer-connect4-about-to-drop.png)
|
1066
|
+
|
1067
|
+
Connect 4 - Dropped Coin
|
1068
|
+
|
1069
|
+
![Connect 4 Dropped Coin](/images/glimmer-connect4-dropped-coin.png)
|
1070
|
+
|
1071
|
+
Connect 4 - Player 1 Wins (keeps the coin about to drop visual cue)
|
1072
|
+
|
1073
|
+
![Connect 4 Player 1 Wins](/images/glimmer-connect4-player1-wins.png)
|
1074
|
+
|
1075
|
+
Connect 4 - Game Over Message Box
|
1076
|
+
|
1077
|
+
![Connect 4 Game Over Message Box](/images/glimmer-connect4-game-over-dialog.png)
|
1078
|
+
|
1047
1079
|
#### Contact Manager
|
1048
1080
|
|
1049
1081
|
This sample demonstrates table data-binding, sorting, filtering, GUI layout, MVP pattern, and test-driven development (has [specs](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/spec/samples/elaborate/contact_manager/contact_manager_presenter_spec.rb)).
|
@@ -1074,7 +1106,7 @@ Contact Manager - Edit Done
|
|
1074
1106
|
|
1075
1107
|
#### Game of Life
|
1076
1108
|
|
1077
|
-
This sample demonstrates how to build an interactive canvas-based visualization of Conway's Game of Life (test-first), taking advantage of data-binding and multi-threading.
|
1109
|
+
This sample demonstrates how to build an interactive canvas-based visualization of Conway's Game of Life ([test-first](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/spec/samples/elaborate/game_of_life/model/grid_spec.rb)), taking advantage of data-binding and multi-threading.
|
1078
1110
|
|
1079
1111
|
Code:
|
1080
1112
|
|
@@ -1112,7 +1144,7 @@ Code:
|
|
1112
1144
|
|
1113
1145
|
#### Klondike Solitaire
|
1114
1146
|
|
1115
|
-
This sample demonstrates how to build an interactive card game with MVC architecture, canvas, custom-shapes, data-binding, observers, and drag & drop.
|
1147
|
+
This sample demonstrates how to build an interactive card game with MVC architecture, canvas, custom-shapes, data-binding, observers, and canvas shape drag & drop.
|
1116
1148
|
|
1117
1149
|
Code:
|
1118
1150
|
|
@@ -1122,6 +1154,26 @@ Code:
|
|
1122
1154
|
|
1123
1155
|
![Klondike Solitaire Played](/images/glimmer-klondike-solitaire-played.png)
|
1124
1156
|
|
1157
|
+
Check out a souped up large-card-size packaged version of the game in the [Glimmer Klondike Solitaire](#glimmer-klondike-solitaire) external sample.
|
1158
|
+
|
1159
|
+
#### Battleship
|
1160
|
+
|
1161
|
+
This sample demonstrates how to build an interactive board game with A.I., MVC architecture, hybrid canvas widget/shape approach, custom-widgets, data-binding, observers, and widget drag & drop.
|
1162
|
+
|
1163
|
+
Code:
|
1164
|
+
|
1165
|
+
[samples/elaborate/battleship.rb](/samples/elaborate/battleship.rb)
|
1166
|
+
|
1167
|
+
![Battleship](/images/glimmer-battleship.png)
|
1168
|
+
|
1169
|
+
![Battleship Placement](/images/glimmer-battleship-placement.png)
|
1170
|
+
|
1171
|
+
![Battleship Ready for Battle](/images/glimmer-battleship-ready-for-battle.png)
|
1172
|
+
|
1173
|
+
![Battleship Won](/images/glimmer-battleship-won.png)
|
1174
|
+
|
1175
|
+
![Battleship Game Over](/images/glimmer-battleship-game-over.png)
|
1176
|
+
|
1125
1177
|
#### Mandelbrot Fractal
|
1126
1178
|
|
1127
1179
|
This sample demonstrates how to render canvas graphics with multi-threaded processing taking advantage of all CPU cores and doing background processing of images.
|
@@ -1148,6 +1200,28 @@ Code:
|
|
1148
1200
|
|
1149
1201
|
![Mandelbrot Fractal Help Menu](/images/glimmer-mandelbrot-menu-help.png)
|
1150
1202
|
|
1203
|
+
#### Parking
|
1204
|
+
|
1205
|
+
This sample demonstrates how to use method-based custom shapes and how to take advantage of transforms (e.g. rotation).
|
1206
|
+
|
1207
|
+
It enables booking a parking spot at the entrance of a building's parking, which in a real scenario would have prompted for payment too.
|
1208
|
+
|
1209
|
+
Code:
|
1210
|
+
|
1211
|
+
[samples/elaborate/parking.rb](/samples/elaborate/parking.rb)
|
1212
|
+
|
1213
|
+
Parking
|
1214
|
+
|
1215
|
+
![Parking](/images/glimmer-parking.png)
|
1216
|
+
|
1217
|
+
Parking Floor 4
|
1218
|
+
|
1219
|
+
![Parking Floor 4](/images/glimmer-parking-floor4.png)
|
1220
|
+
|
1221
|
+
Parking Booked
|
1222
|
+
|
1223
|
+
![Parking Booked](/images/glimmer-parking-booked.png)
|
1224
|
+
|
1151
1225
|
#### Stock Ticker
|
1152
1226
|
|
1153
1227
|
This sample demonstrates a Stock Ticker that generates random stock price data for 4 different stocks and provides 4 different tab views of the graphed data using the [Canvas Path DSL](/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#canvas-path-dsl). It leverages a thread that runs in the background and ticks the stocks to generate random new stock prices before amending the graphed paths with them.
|
@@ -1223,6 +1297,14 @@ Gladiator is a good demonstration of:
|
|
1223
1297
|
|
1224
1298
|
[<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-timer/master/glimmer-timer-screenshot.png" />](https://github.com/AndyObtiva/glimmer-cs-timer)
|
1225
1299
|
|
1300
|
+
#### Glimmer Klondike Solitaire
|
1301
|
+
|
1302
|
+
This is a souped up version of the Klondike Solitaire elaborate sample, which is built as an external application to enable packaging as a native executable installer. Enjoy!
|
1303
|
+
|
1304
|
+
[<img alt="Glimmer Klondike Solitaire Icon" src="https://raw.githubusercontent.com/AndyObtiva/glimmer_klondike_solitaire/master/package/linux/Glimmer%20Klondike%20Solitaire.png" height=40 /> Glimmer Klondike Solitaire](https://github.com/AndyObtiva/glimmer_klondike_solitaire)
|
1305
|
+
|
1306
|
+
![Glimmer Klondike Solitaire](https://raw.githubusercontent.com/AndyObtiva/glimmer_klondike_solitaire/master/images/glimmer-klondike-solitaire.png)
|
1307
|
+
|
1226
1308
|
## License
|
1227
1309
|
|
1228
1310
|
[MIT](LICENSE.txt)
|
data/glimmer-dsl-swt.gemspec
CHANGED
Binary file
|
data/lib/glimmer-dsl-swt.rb
CHANGED
@@ -62,6 +62,7 @@ module Glimmer
|
|
62
62
|
# Optimize further by having a collection of disposable_shapes independent of shapes, which is much smaller and only has shapes that require disposal (shapes with patterns or image)
|
63
63
|
shapes.dup.each {|s| s.dispose(dispose_images: dispose_images, dispose_patterns: dispose_patterns) } if requires_shape_disposal?
|
64
64
|
end
|
65
|
+
alias dispose_shapes clear_shapes
|
65
66
|
|
66
67
|
def paint_pixel_by_pixel(width = nil, height = nil, &each_pixel_color)
|
67
68
|
if @image_double_buffered
|
@@ -216,6 +216,7 @@ module Glimmer
|
|
216
216
|
# Subclasses (like polygon) may override to indicate if a point x,y coordinates falls inside the shape
|
217
217
|
# some shapes may choose to provide a fuzz factor to make usage of this method for mouse clicking more user friendly
|
218
218
|
def contain?(x, y)
|
219
|
+
x, y = inverse_transform_point(x, y)
|
219
220
|
# assume a rectangular filled shape by default (works for several shapes like image, text, and focus)
|
220
221
|
x.between?(self.absolute_x, self.absolute_x + calculated_width.to_f) && y.between?(self.absolute_y, self.absolute_y + calculated_height.to_f)
|
221
222
|
end
|
@@ -232,6 +233,24 @@ module Glimmer
|
|
232
233
|
included = include?(x, y)
|
233
234
|
included ||= expanded_shapes.reject {|shape| shape == except_child}.detect { |shape| shape.include?(x, y) }
|
234
235
|
end
|
236
|
+
|
237
|
+
# if there is a transform, invert it and apply on x, y point coordinates
|
238
|
+
def inverse_transform_point(x, y)
|
239
|
+
current_transform = (transform || parent_shape_containers.map(&:transform).first)&.first
|
240
|
+
if current_transform
|
241
|
+
transform_array = [1,2,3,4,5,6].to_java(:float)
|
242
|
+
current_transform.getElements(transform_array)
|
243
|
+
inverse_transform = TransformProxy.new(DisplayProxy.instance.swt_display, *transform_array.to_a)
|
244
|
+
inverse_transform_array = [1,2,3,4,5,6].to_java(:float)
|
245
|
+
inverse_transform.getElements(inverse_transform_array)
|
246
|
+
matrix = Matrix[[inverse_transform_array[0], inverse_transform_array[1]], [inverse_transform_array[2], inverse_transform_array[3]]]
|
247
|
+
result = matrix * Matrix.column_vector([x, y])
|
248
|
+
x, y = result.to_a.flatten
|
249
|
+
x += inverse_transform_array[5]
|
250
|
+
y += inverse_transform_array[4]
|
251
|
+
end
|
252
|
+
[x, y]
|
253
|
+
end
|
235
254
|
|
236
255
|
# Indicates if a shape's x, y, width, height differ from its bounds calculation (e.g. arc / polygon)
|
237
256
|
def irregular?
|
@@ -53,6 +53,7 @@ module Glimmer
|
|
53
53
|
|
54
54
|
# checks if shape contains the point denoted by x and y
|
55
55
|
def contain?(x, y)
|
56
|
+
x, y = inverse_transform_point(x, y)
|
56
57
|
geometry.contains(x, y)
|
57
58
|
end
|
58
59
|
|
@@ -60,6 +61,7 @@ module Glimmer
|
|
60
61
|
if filled?
|
61
62
|
contain?(x, y)
|
62
63
|
else
|
64
|
+
x, y = inverse_transform_point(x, y)
|
63
65
|
# give it some fuzz to allow a larger region around the drawn oval to accept including a point (helps with mouse clickability on a shape)
|
64
66
|
outer_shape_geometry = java.awt.geom.Arc2D::Double.new(self.absolute_x, self.absolute_y, calculated_width + 3, calculated_height + 3, start_angle, arc_angle, java.awt.geom.Arc2D::PIE)
|
65
67
|
inner_shape_geometry = java.awt.geom.Arc2D::Double.new(self.absolute_x, self.absolute_y, calculated_width - 3, calculated_height - 3, start_angle, arc_angle, java.awt.geom.Arc2D::PIE)
|
@@ -55,6 +55,7 @@ module Glimmer
|
|
55
55
|
|
56
56
|
# checks if drawn or filled rectangle includes the point denoted by x and y (if drawn, it only returns true if point lies on the edge)
|
57
57
|
def include?(x, y, filled: nil)
|
58
|
+
x, y = inverse_transform_point(x, y)
|
58
59
|
filled = filled? if filled.nil?
|
59
60
|
makeshift_gc = org.eclipse.swt.graphics.GC.new(Glimmer::SWT::DisplayProxy.instance.swt_display)
|
60
61
|
swt_path = org.eclipse.swt.graphics.Path.new(Glimmer::SWT::DisplayProxy.instance.swt_display)
|
@@ -39,6 +39,7 @@ module Glimmer
|
|
39
39
|
|
40
40
|
# checks if shape contains the point denoted by x and y
|
41
41
|
def contain?(x, y)
|
42
|
+
x, y = inverse_transform_point(x, y)
|
42
43
|
shape_geometry = java.awt.geom.Ellipse2D::Double.new(self.absolute_x, self.absolute_y, calculated_width, calculated_height)
|
43
44
|
shape_geometry.contains(x, y)
|
44
45
|
end
|
@@ -48,6 +49,7 @@ module Glimmer
|
|
48
49
|
if filled?
|
49
50
|
contain?(x, y)
|
50
51
|
else
|
52
|
+
x, y = inverse_transform_point(x, y)
|
51
53
|
# give it some fuzz to allow a larger region around the drawn oval to accept including a point (helps with mouse clickability on a shape)
|
52
54
|
outer_shape_geometry = java.awt.geom.Ellipse2D::Double.new(self.absolute_x - 3, self.absolute_y - 3, calculated_width + 6, calculated_height + 6)
|
53
55
|
inner_shape_geometry = java.awt.geom.Ellipse2D::Double.new(self.absolute_x + 3, self.absolute_y + 3, calculated_width - 6, calculated_height - 6)
|
@@ -61,17 +61,13 @@ module Glimmer
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
def contain?(x, y)
|
65
|
-
makeshift_gc = org.eclipse.swt.graphics.GC.new(Glimmer::SWT::DisplayProxy.instance.swt_display)
|
66
|
-
@swt_path.contains(x.to_f, y.to_f, makeshift_gc, false)
|
67
|
-
end
|
68
|
-
|
69
64
|
def contain?(x, y)
|
70
65
|
include?(x, y, filled: true)
|
71
66
|
end
|
72
67
|
|
73
68
|
# checks if drawn or filled rectangle includes the point denoted by x and y (if drawn, it only returns true if point lies on the edge)
|
74
69
|
def include?(x, y, filled: nil)
|
70
|
+
x, y = inverse_transform_point(x, y)
|
75
71
|
filled = filled? if filled.nil?
|
76
72
|
makeshift_gc = org.eclipse.swt.graphics.GC.new(Glimmer::SWT::DisplayProxy.instance.swt_display)
|
77
73
|
@swt_path.contains(x.to_f, y.to_f, makeshift_gc, !filled)
|
@@ -49,6 +49,7 @@ module Glimmer
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def include?(x, y)
|
52
|
+
x, y = inverse_transform_point(x, y)
|
52
53
|
# give it some fuzz (helps makes mouse clicking easier)
|
53
54
|
x.to_i.between?(self.absolute_x.to_i - 2, self.absolute_x.to_i + 2) && y.to_i.between?(self.absolute_y.to_i - 2, self.absolute_y.to_i + 2)
|
54
55
|
end
|
@@ -152,6 +152,7 @@ module Glimmer
|
|
152
152
|
end
|
153
153
|
|
154
154
|
def contain?(x, y)
|
155
|
+
x, y = inverse_transform_point(x, y)
|
155
156
|
geometry.contains(x, y)
|
156
157
|
end
|
157
158
|
|
@@ -159,6 +160,7 @@ module Glimmer
|
|
159
160
|
if filled?
|
160
161
|
contain?(x, y)
|
161
162
|
else
|
163
|
+
x, y = inverse_transform_point(x, y)
|
162
164
|
comparison_lines = absolute_point_xy_array.zip(absolute_point_xy_array.rotate(1))
|
163
165
|
comparison_lines.any? {|line| Line.include?(line.first.first, line.first.last, line.last.first, line.last.last, x, y)}
|
164
166
|
end
|
@@ -130,6 +130,7 @@ module Glimmer
|
|
130
130
|
end
|
131
131
|
|
132
132
|
def include?(x, y)
|
133
|
+
x, y = inverse_transform_point(x, y)
|
133
134
|
comparison_lines = absolute_point_xy_array.zip(absolute_point_xy_array.rotate(1))
|
134
135
|
comparison_lines.pop # ignore last pair since you don't want to compare last point with first point
|
135
136
|
comparison_lines.any? {|line| Line.include?(line.first.first, line.first.last, line.last.first, line.last.last, x, y)}
|
@@ -85,6 +85,7 @@ module Glimmer
|
|
85
85
|
if filled?
|
86
86
|
contain?(x, y)
|
87
87
|
else
|
88
|
+
x, y = inverse_transform_point(x, y)
|
88
89
|
comparison_lines = absolute_point_xy_array.zip(absolute_point_xy_array.rotate(1))
|
89
90
|
comparison_lines.any? {|line| Line.include?(line.first.first, line.first.last, line.last.first, line.last.last, x, y)}
|
90
91
|
end
|
@@ -200,12 +200,14 @@ module Glimmer
|
|
200
200
|
elsif observation_request.start_with?('on_')
|
201
201
|
event_name = observation_request.sub(/^on_/, '')
|
202
202
|
if OBSERVED_MENU_ITEMS.include?(event_name) && OS.mac?
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
203
|
+
auto_exec do
|
204
|
+
system_menu = swt_display.getSystemMenu
|
205
|
+
menu_item = system_menu.getItems.find {|menu_item| menu_item.getID == SWTProxy["ID_#{event_name.upcase}"]}
|
206
|
+
listener = ConcreteListener.new(&block)
|
207
|
+
display_mac_event_registration = menu_item.addListener(SWTProxy[:Selection], listener)
|
208
|
+
Glimmer::UI::CustomWidget.current_custom_widgets.last&.observer_registrations&.push(display_mac_event_registration)
|
209
|
+
display_mac_event_registration
|
210
|
+
end
|
209
211
|
end
|
210
212
|
end
|
211
213
|
end
|
@@ -30,8 +30,8 @@ module Glimmer
|
|
30
30
|
|
31
31
|
class << self
|
32
32
|
def launch(*args, &content)
|
33
|
+
launched_custom_shell = send(keyword, *args, &content)
|
33
34
|
auto_exec do
|
34
|
-
launched_custom_shell = send(keyword, *args, &content)
|
35
35
|
launched_custom_shell.swt_widget.set_data('launched', true)
|
36
36
|
launched_custom_shell.open
|
37
37
|
end
|
@@ -176,16 +176,16 @@ module Glimmer
|
|
176
176
|
options ||= {}
|
177
177
|
@options = self.class.options.merge(options)
|
178
178
|
@content = Util::ProcTracker.new(content) if content
|
179
|
-
execute_hook('before_body')
|
179
|
+
auto_exec { execute_hook('before_body') }
|
180
180
|
body_block = self.class.instance_variable_get("@body_block")
|
181
181
|
raise Glimmer::Error, 'Invalid custom widget for having no body! Please define body block!' if body_block.nil?
|
182
|
-
@body_root = instance_exec(&body_block)
|
182
|
+
@body_root = auto_exec { instance_exec(&body_block) }
|
183
183
|
raise Glimmer::Error, 'Invalid custom widget for having an empty body! Please fill body block!' if @body_root.nil?
|
184
184
|
@swt_widget = @body_root.swt_widget
|
185
185
|
auto_exec do
|
186
186
|
@swt_widget.set_data('custom_widget', self)
|
187
187
|
end
|
188
|
-
execute_hook('after_body')
|
188
|
+
auto_exec { execute_hook('after_body') }
|
189
189
|
auto_exec do
|
190
190
|
@dispose_listener_registration = @body_root.on_widget_disposed do
|
191
191
|
observer_registrations.compact.each(&:deregister)
|