glimmer-dsl-swt 4.20.13.9 → 4.20.13.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/README.md +5 -5
- data/VERSION +1 -1
- data/docs/reference/GLIMMER_SAMPLES.md +37 -3
- data/docs/reference/GLIMMER_STYLE_GUIDE.md +2 -1
- data/glimmer-dsl-swt.gemspec +0 -0
- data/lib/glimmer-dsl-swt.rb +1 -0
- data/lib/glimmer/rake_task/scaffold.rb +14 -14
- data/lib/glimmer/swt/custom/code_text.rb +4 -4
- data/lib/glimmer/swt/custom/drawable.rb +1 -0
- data/lib/glimmer/swt/custom/shape.rb +20 -1
- 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/samples/elaborate/calculator.rb +2 -2
- data/samples/elaborate/contact_manager.rb +2 -2
- data/samples/elaborate/game_of_life.rb +111 -0
- data/samples/elaborate/game_of_life/model/cell.rb +72 -0
- data/samples/elaborate/game_of_life/model/grid.rb +97 -0
- data/samples/elaborate/klondike_solitaire.rb +3 -22
- data/samples/elaborate/klondike_solitaire/view/empty_playing_card.rb +8 -3
- data/samples/elaborate/klondike_solitaire/view/foundation_pile.rb +4 -4
- data/samples/elaborate/klondike_solitaire/view/hidden_playing_card.rb +8 -1
- data/samples/elaborate/klondike_solitaire/view/playing_card.rb +2 -2
- data/samples/elaborate/login.rb +2 -2
- data/samples/elaborate/mandelbrot_fractal.rb +12 -12
- data/samples/elaborate/meta_sample.rb +2 -2
- data/samples/elaborate/metronome.rb +2 -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/elaborate/stock_ticker.rb +8 -8
- data/samples/elaborate/tetris.rb +4 -4
- data/samples/elaborate/tetris/view/bevel.rb +2 -2
- data/samples/elaborate/tetris/view/score_lane.rb +2 -2
- data/samples/elaborate/tic_tac_toe.rb +6 -6
- data/samples/elaborate/timer.rb +4 -4
- data/samples/elaborate/weather.rb +4 -4
- data/samples/hello/hello_button.rb +2 -2
- data/samples/hello/hello_c_combo.rb +2 -2
- data/samples/hello/hello_canvas.rb +4 -4
- data/samples/hello/hello_canvas_animation.rb +2 -2
- data/samples/hello/hello_canvas_data_binding.rb +2 -2
- data/samples/hello/hello_checkbox.rb +2 -2
- data/samples/hello/hello_checkbox_group.rb +2 -2
- data/samples/hello/hello_code_text.rb +2 -2
- data/samples/hello/hello_color_dialog.rb +2 -2
- data/samples/hello/hello_combo.rb +2 -2
- data/samples/hello/hello_computed.rb +14 -22
- data/samples/hello/hello_cool_bar.rb +2 -2
- data/samples/hello/hello_cursor.rb +2 -2
- data/samples/hello/hello_custom_shape.rb +2 -2
- data/samples/hello/hello_custom_shell.rb +2 -2
- data/samples/hello/hello_custom_widget.rb +4 -4
- data/samples/hello/hello_date_time.rb +2 -2
- data/samples/hello/hello_directory_dialog.rb +2 -2
- data/samples/hello/hello_file_dialog.rb +2 -2
- data/samples/hello/hello_font_dialog.rb +2 -2
- data/samples/hello/hello_group.rb +2 -2
- data/samples/hello/hello_list_multi_selection.rb +2 -2
- data/samples/hello/hello_list_single_selection.rb +2 -2
- data/samples/hello/hello_progress_bar.rb +2 -2
- data/samples/hello/hello_radio.rb +2 -2
- data/samples/hello/hello_radio_group.rb +2 -2
- data/samples/hello/hello_scale.rb +2 -2
- data/samples/hello/hello_spinner.rb +2 -2
- data/samples/hello/hello_table.rb +2 -2
- data/samples/hello/hello_text.rb +2 -2
- data/samples/hello/hello_tool_bar.rb +2 -2
- data/samples/hello/hello_tray_item.rb +2 -2
- data/samples/hello/hello_tree.rb +4 -4
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73c5a7ba90a7c91df55ac716b815e08e71b9ff13294ebf44e4c6587aa67080f2
|
4
|
+
data.tar.gz: 889670d6eba956aaf4cc267c8a70cf36283379369a51bed85b5b5dd2aadd2762
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 455e0b8626d4782e9ec122de48eae8ffec9688b2a724de11c858c4833925389ca3e2a46285e47e30b50e0fe414ccbe74f5dd869bbcbe03986e682dd5a1aad991
|
7
|
+
data.tar.gz: 4ae13e2fedaa551c03ff3b8919bfe9ffa4faf31b7b6b393ba37b91e1fb54c179703da2c3d5283446122a7867eb970373ed191289ad2ace0e92880058b633f573
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,26 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
### 4.20.13.13
|
4
|
+
|
5
|
+
- Parking elaborate sample
|
6
|
+
- Support shape contain?/include? when a transform (e.g. rotation) is applied
|
7
|
+
|
8
|
+
### 4.20.13.12
|
9
|
+
|
10
|
+
- 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
|
11
|
+
|
12
|
+
### 4.20.13.11
|
13
|
+
|
14
|
+
- Conway's Game of Life elaborate sample
|
15
|
+
|
16
|
+
### 4.20.13.10
|
17
|
+
|
18
|
+
- Update Glimmer Style Guide, scaffolding, and samples to have `before_body` and `after_body` in custom widgets/shells/shapes always take a `do; end` block since they contain logic not visuals
|
19
|
+
|
20
|
+
### 4.20.13.9
|
21
|
+
|
22
|
+
- Update Klondike Solitaire to have playing card suit symbols and avoid clipping of cards on the boundaries
|
23
|
+
|
3
24
|
### 4.20.13.8
|
4
25
|
|
5
26
|
- Glimmer Klondike Solitaire elaborate sample
|
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.13
|
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.13 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 (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
|
|
@@ -326,7 +326,7 @@ jgem install glimmer-dsl-swt
|
|
326
326
|
|
327
327
|
Or this command if you want a specific version:
|
328
328
|
```
|
329
|
-
jgem install glimmer-dsl-swt -v 4.20.13.
|
329
|
+
jgem install glimmer-dsl-swt -v 4.20.13.13
|
330
330
|
```
|
331
331
|
|
332
332
|
`jgem` is JRuby's version of `gem` command.
|
@@ -354,7 +354,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
|
|
354
354
|
|
355
355
|
Add the following to `Gemfile`:
|
356
356
|
```
|
357
|
-
gem 'glimmer-dsl-swt', '~> 4.20.13.
|
357
|
+
gem 'glimmer-dsl-swt', '~> 4.20.13.13'
|
358
358
|
```
|
359
359
|
|
360
360
|
And, then run:
|
@@ -375,7 +375,7 @@ glimmer
|
|
375
375
|
```
|
376
376
|
|
377
377
|
```
|
378
|
-
Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.20.13.
|
378
|
+
Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.20.13.13
|
379
379
|
|
380
380
|
Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
|
381
381
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.20.13.
|
1
|
+
4.20.13.13
|
@@ -61,9 +61,11 @@
|
|
61
61
|
- [Login](#login)
|
62
62
|
- [Tic Tac Toe](#tic-tac-toe)
|
63
63
|
- [Contact Manager](#contact-manager)
|
64
|
+
- [Game of Life](#game-of-life)
|
64
65
|
- [Glimmer Tetris](#glimmer-tetris)
|
65
66
|
- [Klondike Solitaire](#klondike-solitaire)
|
66
67
|
- [Mandelbrot Fractal](#mandelbrot-fractal)
|
68
|
+
- [Parking](#parking)
|
67
69
|
- [Stock Ticker](#stock-ticker)
|
68
70
|
- [Metronome](#metronome)
|
69
71
|
- [Weather](#weather)
|
@@ -1071,6 +1073,16 @@ Contact Manager - Edit Done
|
|
1071
1073
|
|
1072
1074
|
![Contact Manager](/images/glimmer-contact-manager-edit-done.png)
|
1073
1075
|
|
1076
|
+
#### Game of Life
|
1077
|
+
|
1078
|
+
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.
|
1079
|
+
|
1080
|
+
Code:
|
1081
|
+
|
1082
|
+
[samples/elaborate/game_of_life.rb](/samples/elaborate/game_of_life.rb)
|
1083
|
+
|
1084
|
+
![Game of Life](/images/glimmer-game-of-life.gif)
|
1085
|
+
|
1074
1086
|
#### Glimmer Tetris
|
1075
1087
|
|
1076
1088
|
This sample demonstrates how to build an interactive animated game with MVC architecture, custom-shell/custom-widgets, multi-threading, asynchronous programming, data-binding, canvas shape graphic decorations, canvas shape icon image generation, and keyboard events/shortcuts.
|
@@ -1101,15 +1113,15 @@ Code:
|
|
1101
1113
|
|
1102
1114
|
#### Klondike Solitaire
|
1103
1115
|
|
1104
|
-
This sample demonstrates how to build an interactive card game with MVC architecture, custom-
|
1116
|
+
This sample demonstrates how to build an interactive card game with MVC architecture, canvas, custom-shapes, data-binding, observers, and drag & drop.
|
1105
1117
|
|
1106
1118
|
Code:
|
1107
1119
|
|
1108
1120
|
[samples/elaborate/klondike_solitaire.rb](/samples/elaborate/klondike_solitaire.rb)
|
1109
1121
|
|
1110
|
-
![
|
1122
|
+
![Klondike Solitaire](/images/glimmer-klondike-solitaire.png)
|
1111
1123
|
|
1112
|
-
![
|
1124
|
+
![Klondike Solitaire Played](/images/glimmer-klondike-solitaire-played.png)
|
1113
1125
|
|
1114
1126
|
#### Mandelbrot Fractal
|
1115
1127
|
|
@@ -1137,6 +1149,28 @@ Code:
|
|
1137
1149
|
|
1138
1150
|
![Mandelbrot Fractal Help Menu](/images/glimmer-mandelbrot-menu-help.png)
|
1139
1151
|
|
1152
|
+
#### Parking
|
1153
|
+
|
1154
|
+
This sample demonstrates how to use method-based custom shapes and how to take advantage of transforms (e.g. rotation).
|
1155
|
+
|
1156
|
+
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.
|
1157
|
+
|
1158
|
+
Code:
|
1159
|
+
|
1160
|
+
[samples/elaborate/parking.rb](/samples/elaborate/parking.rb)
|
1161
|
+
|
1162
|
+
Parking
|
1163
|
+
|
1164
|
+
![Parking](/images/glimmer-parking.png)
|
1165
|
+
|
1166
|
+
Parking Floor 4
|
1167
|
+
|
1168
|
+
![Parking Floor 4](/images/glimmer-parking-floor4.png)
|
1169
|
+
|
1170
|
+
Parking Booked
|
1171
|
+
|
1172
|
+
![Parking Booked](/images/glimmer-parking-booked.png)
|
1173
|
+
|
1140
1174
|
#### Stock Ticker
|
1141
1175
|
|
1142
1176
|
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.
|
@@ -10,6 +10,7 @@
|
|
10
10
|
- Widget listeners are always declared starting with `on_` prefix and affixing listener event method name afterwards in underscored lowercase form. Their multi-line blocks rely on the `do; end` style.
|
11
11
|
- Widget listeners are always followed by a block using curly braces (Only when declared in DSL. When invoked on widget object directly outside of GUI declarations, standard Ruby conventions apply)
|
12
12
|
- Data-binding is done via `bind` keyword, which always takes arguments wrapped in parentheses
|
13
|
-
- Custom widget `body
|
13
|
+
- Custom widget/shell/shape `body` blocks open and close with curly braces.
|
14
|
+
- Custom widget/shell/shape `before_body` and `after_body` blocks are declared as `do; end` blocks.
|
14
15
|
- Custom widgets receive additional keyword arguments called options, which come after the SWT styles.
|
15
16
|
- Pure logic multi-line blocks that do not constitute GUI DSL view elements (such as `Thread.new`, `loop`, `each` and `observe` blocks) rely on the `do; end` style to clearly separate logic code from view code.
|
data/glimmer-dsl-swt.gemspec
CHANGED
Binary file
|
data/lib/glimmer-dsl-swt.rb
CHANGED
@@ -607,7 +607,7 @@ module Glimmer
|
|
607
607
|
|
608
608
|
if %i[gem app desktopify].include?(shell_type)
|
609
609
|
custom_shell_file_content += <<-MULTI_LINE_STRING
|
610
|
-
before_body
|
610
|
+
before_body do
|
611
611
|
Display.app_name = '#{shell_type == :gem ? human_name(custom_shell_name) : human_name(namespace)}'
|
612
612
|
Display.app_version = VERSION
|
613
613
|
@display = display {
|
@@ -618,13 +618,13 @@ module Glimmer
|
|
618
618
|
#{shell_type == :desktopify ? 'display_about_dialog' : 'display_preferences_dialog'}
|
619
619
|
}
|
620
620
|
}
|
621
|
-
|
621
|
+
end
|
622
622
|
MULTI_LINE_STRING
|
623
623
|
else
|
624
624
|
custom_shell_file_content += <<-MULTI_LINE_STRING
|
625
|
-
# before_body
|
625
|
+
# before_body do
|
626
626
|
#
|
627
|
-
#
|
627
|
+
# end
|
628
628
|
MULTI_LINE_STRING
|
629
629
|
end
|
630
630
|
|
@@ -632,9 +632,9 @@ module Glimmer
|
|
632
632
|
|
633
633
|
## Use after_body block to setup observers for widgets in body
|
634
634
|
#
|
635
|
-
# after_body
|
635
|
+
# after_body do
|
636
636
|
#
|
637
|
-
#
|
637
|
+
# end
|
638
638
|
|
639
639
|
## Add widget content inside custom shell body
|
640
640
|
## Top-most widget must be a shell or another custom shell
|
@@ -767,15 +767,15 @@ end
|
|
767
767
|
## Use before_body block to pre-initialize variables to use in body
|
768
768
|
#
|
769
769
|
#
|
770
|
-
# before_body
|
770
|
+
# before_body do
|
771
771
|
#
|
772
|
-
#
|
772
|
+
# end
|
773
773
|
|
774
774
|
## Use after_body block to setup observers for widgets in body
|
775
775
|
#
|
776
|
-
# after_body
|
776
|
+
# after_body do
|
777
777
|
#
|
778
|
-
#
|
778
|
+
# end
|
779
779
|
|
780
780
|
## Add widget content under custom widget body
|
781
781
|
##
|
@@ -817,15 +817,15 @@ end
|
|
817
817
|
## Use before_body block to pre-initialize variables to use in body
|
818
818
|
#
|
819
819
|
#
|
820
|
-
# before_body
|
820
|
+
# before_body do
|
821
821
|
#
|
822
|
-
#
|
822
|
+
# end
|
823
823
|
|
824
824
|
## Use after_body block to setup observers for shapes in body
|
825
825
|
#
|
826
|
-
# after_body
|
826
|
+
# after_body do
|
827
827
|
#
|
828
|
-
#
|
828
|
+
# end
|
829
829
|
|
830
830
|
## Add shape content under custom shape body
|
831
831
|
#
|
@@ -121,7 +121,7 @@ module Glimmer
|
|
121
121
|
@line_numbers_styled_text_proxy.content(&block)
|
122
122
|
end
|
123
123
|
|
124
|
-
before_body
|
124
|
+
before_body do
|
125
125
|
require 'rouge'
|
126
126
|
require 'ext/rouge/themes/glimmer'
|
127
127
|
@swt_style = swt_style == 0 ? [:border, :multi, :v_scroll, :h_scroll] : swt_style
|
@@ -132,11 +132,11 @@ module Glimmer
|
|
132
132
|
@lines_width = lines[:width]
|
133
133
|
end
|
134
134
|
@dsl_mode = true
|
135
|
-
|
135
|
+
end
|
136
136
|
|
137
|
-
after_body
|
137
|
+
after_body do
|
138
138
|
@dsl_mode = nil
|
139
|
-
|
139
|
+
end
|
140
140
|
|
141
141
|
body {
|
142
142
|
if lines
|
@@ -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?
|
@@ -713,7 +732,7 @@ module Glimmer
|
|
713
732
|
end
|
714
733
|
end
|
715
734
|
@drawable_on_mouse_up = drawable.handle_observation_request('on_mouse_up') do |event|
|
716
|
-
if Shape.dragging && Shape.dragged_shape == self && !Shape.drop_shapes.detect {|shape| shape.include_with_children?(event.x, event.y)}
|
735
|
+
if Shape.dragging && Shape.dragged_shape == self && !Shape.drop_shapes.detect {|shape| shape.include_with_children?(event.x, event.y, except_child: Shape.dragged_shape)}
|
717
736
|
Shape.dragging = false
|
718
737
|
Shape.dragged_shape.x = Shape.dragged_shape_original_x
|
719
738
|
Shape.dragged_shape.y = Shape.dragged_shape_original_y
|
@@ -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
|