glimmer-dsl-swt 4.20.13.0 → 4.20.13.4
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 -5
- data/VERSION +1 -1
- data/glimmer-dsl-swt.gemspec +0 -0
- data/lib/glimmer/swt/custom/drawable.rb +4 -0
- data/lib/glimmer/swt/custom/shape.rb +40 -25
- data/samples/hello/hello_canvas_drag_and_drop.rb +20 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae711a0eacc8c77e76d141a6eb1576b904aa95f6c3df8fa842fbec5f9c491a7a
|
4
|
+
data.tar.gz: e0784d7f5899ddf32bac4212432b0b118e579e989d8e6ad2565b7f9061d0b9b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c34d8c0ac635256a80f21bdf0c14b0235a13f8d14415227e16de24076d46eee269834ef9c1ec59dfa608e09c5b51534d2069f25c08e8f18c77e5c8c5707f0195
|
7
|
+
data.tar.gz: adae4e6f727036983b50a021fdd7401deed05227c8f32325fda605ceb046460cf6795326cb80715d45aa38abb891ae909a14c133e931196b1e100c733549ab82
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
### 4.20.13.4
|
4
|
+
|
5
|
+
- Improved shape drag and drop checking for inclusion in drop target when there are multiple drop targets
|
6
|
+
|
7
|
+
### 4.20.13.3
|
8
|
+
|
9
|
+
- Fix issue regarding `nil` calculated_width/calculated_height encountered in Shape#contain?
|
10
|
+
|
11
|
+
### 4.20.13.2
|
12
|
+
|
13
|
+
- Support `drop_event.doit = false` to deny dropping and move dragged shape back to where it was
|
14
|
+
|
15
|
+
### 4.20.13.1
|
16
|
+
|
17
|
+
- Supporting having a `drag_source` that is dragged and not dropped at a target go back to its original position
|
18
|
+
- Fix issue of dragged shape getting obscured by ensuring that it is rendered on top of all other shapes
|
19
|
+
- Fix issue with shapes obscured by shapes on top of them getting preference when dragged (surprising behavior). Now, the top-most shapes get dragged first if they overlap with others.
|
20
|
+
|
3
21
|
### 4.20.13.0
|
4
22
|
|
5
23
|
- Shape `drag_and_move true` property to make shapes movable via dragging
|
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.4
|
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.4 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.4
|
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.4'
|
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.4
|
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.4
|
data/glimmer-dsl-swt.gemspec
CHANGED
Binary file
|
@@ -120,6 +120,10 @@ module Glimmer
|
|
120
120
|
paintable_shapes.each do |shape|
|
121
121
|
shape.paint(paint_event)
|
122
122
|
end
|
123
|
+
# When dragging, render dragged shape again on top of everything else.
|
124
|
+
if !@image_double_buffered && Glimmer::SWT::Custom::Shape.dragging?
|
125
|
+
Glimmer::SWT::Custom::Shape.dragged_shape.paint(paint_event)
|
126
|
+
end
|
123
127
|
end
|
124
128
|
if @image_double_buffered
|
125
129
|
if @image_proxy_buffer.nil?
|
@@ -62,7 +62,7 @@ module Glimmer
|
|
62
62
|
class Shape
|
63
63
|
include Properties
|
64
64
|
|
65
|
-
DropEvent = Struct.new(:x, :y, :dragged_shape, :dragged_shape_original_x, :dragged_shape_original_y, :dragging_x, :dragging_y, keyword_init: true)
|
65
|
+
DropEvent = Struct.new(:doit, :x, :y, :dragged_shape, :dragged_shape_original_x, :dragged_shape_original_y, :dragging_x, :dragging_y, :drop_shapes, keyword_init: true)
|
66
66
|
|
67
67
|
class << self
|
68
68
|
attr_accessor :dragging, :dragging_x, :dragging_y, :dragged_shape, :dragged_shape_original_x, :dragged_shape_original_y
|
@@ -132,6 +132,11 @@ module Glimmer
|
|
132
132
|
def flyweight_patterns
|
133
133
|
@flyweight_patterns ||= {}
|
134
134
|
end
|
135
|
+
|
136
|
+
# shapes that have defined on_drop expecting to received a dragged shape
|
137
|
+
def drop_shapes
|
138
|
+
@drop_shapes ||= []
|
139
|
+
end
|
135
140
|
end
|
136
141
|
|
137
142
|
attr_reader :drawable, :parent, :name, :args, :options, :shapes, :properties
|
@@ -212,7 +217,7 @@ module Glimmer
|
|
212
217
|
# some shapes may choose to provide a fuzz factor to make usage of this method for mouse clicking more user friendly
|
213
218
|
def contain?(x, y)
|
214
219
|
# assume a rectangular filled shape by default (works for several shapes like image, text, and focus)
|
215
|
-
x.between?(self.absolute_x, self.absolute_x + calculated_width) && y.between?(self.absolute_y, self.absolute_y + calculated_height)
|
220
|
+
x.between?(self.absolute_x, self.absolute_x + calculated_width.to_f) && y.between?(self.absolute_y, self.absolute_y + calculated_height.to_f)
|
216
221
|
end
|
217
222
|
|
218
223
|
# Returns if shape includes a point. When the shape is filled, this is the same as contain. When the shape is drawn, it only returns true if the point lies on the edge (boundary/border)
|
@@ -223,6 +228,11 @@ module Glimmer
|
|
223
228
|
contain?(x, y)
|
224
229
|
end
|
225
230
|
|
231
|
+
def include_with_children?(x, y)
|
232
|
+
included = include?(x, y)
|
233
|
+
included ||= expanded_shapes.detect { |shape| shape.include?(x, y) }
|
234
|
+
end
|
235
|
+
|
226
236
|
# Indicates if a shape's x, y, width, height differ from its bounds calculation (e.g. arc / polygon)
|
227
237
|
def irregular?
|
228
238
|
false
|
@@ -570,35 +580,40 @@ module Glimmer
|
|
570
580
|
@properties[attribute_name.to_s]
|
571
581
|
end
|
572
582
|
end
|
573
|
-
|
583
|
+
|
574
584
|
def can_handle_observation_request?(observation_request)
|
575
585
|
drawable.can_handle_observation_request?(observation_request)
|
576
586
|
end
|
577
587
|
|
578
588
|
def handle_observation_request(observation_request, &block)
|
579
589
|
shape_block = lambda do |event|
|
580
|
-
|
581
|
-
included ||= expanded_shapes.detect { |shape| shape.include?(event.x, event.y) }
|
582
|
-
block.call(event) if included
|
590
|
+
block.call(event) if include_with_children?(event.x, event.y)
|
583
591
|
end
|
584
592
|
if observation_request == 'on_drop'
|
593
|
+
Shape.drop_shapes << self
|
585
594
|
handle_observation_request('on_mouse_up') do |event|
|
586
|
-
if Shape.
|
595
|
+
if Shape.dragging && include_with_children?(event.x, event.y)
|
587
596
|
drop_event = DropEvent.new(
|
597
|
+
doit: true,
|
588
598
|
dragged_shape: Shape.dragged_shape,
|
589
599
|
dragged_shape_original_x: Shape.dragged_shape_original_x,
|
590
600
|
dragged_shape_original_y: Shape.dragged_shape_original_y,
|
591
601
|
dragging_x: Shape.dragging_x,
|
592
602
|
dragging_y: Shape.dragging_y,
|
603
|
+
drop_shapes: Shape.drop_shapes,
|
593
604
|
x: event.x,
|
594
605
|
y: event.y
|
595
606
|
)
|
596
607
|
begin
|
597
|
-
|
608
|
+
block.call(drop_event)
|
598
609
|
rescue => e
|
599
610
|
Glimmer::Config.logger.error e.full_message
|
600
611
|
ensure
|
601
612
|
Shape.dragging = false
|
613
|
+
if !drop_event.doit && Shape.dragged_shape
|
614
|
+
Shape.dragged_shape.x = Shape.dragged_shape_original_x
|
615
|
+
Shape.dragged_shape.y = Shape.dragged_shape_original_y
|
616
|
+
end
|
602
617
|
Shape.dragged_shape = nil
|
603
618
|
end
|
604
619
|
end
|
@@ -648,14 +663,12 @@ module Glimmer
|
|
648
663
|
@drag_and_move = drag_and_move_value
|
649
664
|
if @drag_and_move && !drag_and_move_old_value
|
650
665
|
@on_drag_detected = handle_observation_request('on_drag_detected') do |event|
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
Shape.dragged_shape_original_y = y
|
658
|
-
end
|
666
|
+
Shape.dragging = true
|
667
|
+
Shape.dragging_x = event.x
|
668
|
+
Shape.dragging_y = event.y
|
669
|
+
Shape.dragged_shape = self
|
670
|
+
Shape.dragged_shape_original_x = x
|
671
|
+
Shape.dragged_shape_original_y = y
|
659
672
|
end
|
660
673
|
@drawable_on_mouse_move = drawable.handle_observation_request('on_mouse_move') do |event|
|
661
674
|
if Shape.dragging && Shape.dragged_shape == self
|
@@ -685,14 +698,12 @@ module Glimmer
|
|
685
698
|
@drag_source = drag_source_value
|
686
699
|
if @drag_source && !drag_source_old_value
|
687
700
|
@on_drag_detected = handle_observation_request('on_drag_detected') do |event|
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
Shape.dragged_shape_original_y = y
|
695
|
-
end
|
701
|
+
Shape.dragging = true
|
702
|
+
Shape.dragging_x = event.x
|
703
|
+
Shape.dragging_y = event.y
|
704
|
+
Shape.dragged_shape = self
|
705
|
+
Shape.dragged_shape_original_x = x
|
706
|
+
Shape.dragged_shape_original_y = y
|
696
707
|
end
|
697
708
|
@drawable_on_mouse_move = drawable.handle_observation_request('on_mouse_move') do |event|
|
698
709
|
if Shape.dragging && Shape.dragged_shape == self
|
@@ -702,8 +713,11 @@ module Glimmer
|
|
702
713
|
end
|
703
714
|
end
|
704
715
|
@drawable_on_mouse_up = drawable.handle_observation_request('on_mouse_up') do |event|
|
705
|
-
if Shape.dragging && Shape.dragged_shape == self
|
716
|
+
if Shape.dragging && Shape.dragged_shape == self && !Shape.drop_shapes.detect {|shape| shape.include_with_children?(event.x, event.y)}
|
706
717
|
Shape.dragging = false
|
718
|
+
Shape.dragged_shape.x = Shape.dragged_shape_original_x
|
719
|
+
Shape.dragged_shape.y = Shape.dragged_shape_original_y
|
720
|
+
Shape.dragged_shape = nil
|
707
721
|
end
|
708
722
|
end
|
709
723
|
elsif !@drag_source && drag_source_old_value
|
@@ -767,6 +781,7 @@ module Glimmer
|
|
767
781
|
shapes.dup.each {|shape| shape.dispose(dispose_images: dispose_images, dispose_patterns: dispose_patterns, redraw: false) }
|
768
782
|
end
|
769
783
|
end
|
784
|
+
alias dispose_shapes clear_shapes
|
770
785
|
|
771
786
|
# Indicate if this is a container shape (meaning a shape bag that is just there to contain nested shapes, but doesn't render anything of its own)
|
772
787
|
def container?
|
@@ -25,6 +25,21 @@ class HelloCanvasDragAndDrop
|
|
25
25
|
}
|
26
26
|
|
27
27
|
background :white
|
28
|
+
|
29
|
+
10.times do |n|
|
30
|
+
an_oval = oval((rand*300).to_i, (rand*200).to_i, 50, 50) {
|
31
|
+
background rgb(255, 165, 0)
|
32
|
+
|
33
|
+
# declare shape as a drag source, which unlike `drag_and_move true`, it means the shape now
|
34
|
+
# goes back to original position if not dropped at an on_drop shape target
|
35
|
+
drag_source true
|
36
|
+
|
37
|
+
# unspecified width and height become max width and max height by default
|
38
|
+
oval(0, 0) {
|
39
|
+
foreground :black
|
40
|
+
}
|
41
|
+
}
|
42
|
+
end
|
28
43
|
|
29
44
|
@drop_square = rectangle(150, 260, 50, 50) {
|
30
45
|
background :white
|
@@ -46,7 +61,9 @@ class HelloCanvasDragAndDrop
|
|
46
61
|
@drop_square_border.foreground = :red if Glimmer::SWT::Custom::Shape.dragging?
|
47
62
|
end
|
48
63
|
|
49
|
-
on_drop do |
|
64
|
+
on_drop do |drop_event|
|
65
|
+
# drop_event attributes: :x, :y, :dragged_shape, :dragged_shape_original_x, :dragged_shape_original_y, :dragging_x, :dragging_y, :drop_shapes
|
66
|
+
# drop_event.doit = false # drop event can be cancelled by setting doit attribute to false
|
50
67
|
ball_count = @number_shape.string.to_i
|
51
68
|
@number_shape.dispose
|
52
69
|
@drop_square.content {
|
@@ -56,22 +73,10 @@ class HelloCanvasDragAndDrop
|
|
56
73
|
string (ball_count + 1).to_s
|
57
74
|
}
|
58
75
|
}
|
59
|
-
|
76
|
+
drop_event.dragged_shape.dispose
|
60
77
|
end
|
61
78
|
}
|
62
|
-
|
63
|
-
10.times do |n|
|
64
|
-
an_oval = oval((rand*300).to_i, (rand*200).to_i, 50, 50) {
|
65
|
-
background rgb(255, 165, 0)
|
66
|
-
drag_source true
|
67
|
-
|
68
|
-
# unspecified width and height become max width and max height by default
|
69
|
-
oval(0, 0) {
|
70
|
-
foreground :black
|
71
|
-
}
|
72
|
-
}
|
73
|
-
end
|
74
|
-
|
79
|
+
|
75
80
|
on_mouse_up do
|
76
81
|
@drop_square_border.foreground = :black
|
77
82
|
end
|
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.20.13.
|
4
|
+
version: 4.20.13.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|