glimmer-dsl-swt 4.20.12.3 → 4.20.13.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -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 +123 -5
- data/samples/hello/hello_canvas_drag_and_drop.rb +29 -42
- data/samples/hello/hello_custom_shape.rb +1 -0
- data/samples/hello/hello_shape.rb +7 -1
- 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: 3d2fa9af6ffbacb6449131175cd36971568e98ed763ac861d4126bb638c8f975
|
4
|
+
data.tar.gz: ef23b0d547e1d42e2832f5f10c0b15b1c70ce3c8adb6b588b6b74dafa8b1e6de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58bfac7f7af0ef1de30e4d9db32fb8c218a272c6de892f0b59261e4c9e96458e1b50169e3ee8da96b2c686f05c8687ee79f801189a7eef3bd225bf42ad1e684c
|
7
|
+
data.tar.gz: 7f5ee3e3f28e7a8bdd32aeea1ac18f20953480ba4dbed2e186e5c299f1af8de908c32df2ae3cfe417599b5b684725cbf06697ec3802e1ab4abddc43946adcf79
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,25 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
### 4.20.13.2
|
4
|
+
|
5
|
+
- Support `drop_event.doit = false` to deny dropping and move dragged shape back to where it was
|
6
|
+
|
7
|
+
### 4.20.13.1
|
8
|
+
|
9
|
+
- Supporting having a `drag_source` that is dragged and not dropped at a target go back to its original position
|
10
|
+
- Fix issue of dragged shape getting obscured by ensuring that it is rendered on top of all other shapes
|
11
|
+
- 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.
|
12
|
+
|
13
|
+
### 4.20.13.0
|
14
|
+
|
15
|
+
- Shape `drag_and_move true` property to make shapes movable via dragging
|
16
|
+
- Shape `drag_source true` and `on_drop {|event| }` built-in support for drag and drop
|
17
|
+
- Refactor Hello, Canvas Drag and Drop! to use new Shape built-in support for drag and drop
|
18
|
+
|
19
|
+
### 4.20.12.4
|
20
|
+
|
21
|
+
- Update Hello, Shape! to take advantage of shape listeners (on mouse click, change color)
|
22
|
+
|
3
23
|
### 4.20.12.3
|
4
24
|
|
5
25
|
- Make Custom Shapes support on_event listeners just like Shapes
|
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.
|
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.2
|
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.
|
18
|
+
[Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.20.13.2 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.
|
329
|
+
jgem install glimmer-dsl-swt -v 4.20.13.2
|
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.
|
357
|
+
gem 'glimmer-dsl-swt', '~> 4.20.13.2'
|
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.
|
378
|
+
Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.20.13.2
|
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.
|
1
|
+
4.20.13.2
|
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,12 @@ module Glimmer
|
|
62
62
|
class Shape
|
63
63
|
include Properties
|
64
64
|
|
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
|
+
|
65
67
|
class << self
|
68
|
+
attr_accessor :dragging, :dragging_x, :dragging_y, :dragged_shape, :dragged_shape_original_x, :dragged_shape_original_y
|
69
|
+
alias dragging? dragging
|
70
|
+
|
66
71
|
def create(parent, keyword, *args, &property_block)
|
67
72
|
potential_shape_class_name = keyword.to_s.camelcase(:upper).to_sym
|
68
73
|
if constants.include?(potential_shape_class_name)
|
@@ -127,6 +132,11 @@ module Glimmer
|
|
127
132
|
def flyweight_patterns
|
128
133
|
@flyweight_patterns ||= {}
|
129
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
|
130
140
|
end
|
131
141
|
|
132
142
|
attr_reader :drawable, :parent, :name, :args, :options, :shapes, :properties
|
@@ -218,6 +228,11 @@ module Glimmer
|
|
218
228
|
contain?(x, y)
|
219
229
|
end
|
220
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
|
+
|
221
236
|
# Indicates if a shape's x, y, width, height differ from its bounds calculation (e.g. arc / polygon)
|
222
237
|
def irregular?
|
223
238
|
false
|
@@ -572,11 +587,40 @@ module Glimmer
|
|
572
587
|
|
573
588
|
def handle_observation_request(observation_request, &block)
|
574
589
|
shape_block = lambda do |event|
|
575
|
-
|
576
|
-
|
577
|
-
|
590
|
+
block.call(event) if include_with_children?(event.x, event.y)
|
591
|
+
end
|
592
|
+
if observation_request == 'on_drop'
|
593
|
+
Shape.drop_shapes << self
|
594
|
+
handle_observation_request('on_mouse_up') do |event|
|
595
|
+
if Shape.dragged_shape
|
596
|
+
drop_event = DropEvent.new(
|
597
|
+
doit: true,
|
598
|
+
dragged_shape: Shape.dragged_shape,
|
599
|
+
dragged_shape_original_x: Shape.dragged_shape_original_x,
|
600
|
+
dragged_shape_original_y: Shape.dragged_shape_original_y,
|
601
|
+
dragging_x: Shape.dragging_x,
|
602
|
+
dragging_y: Shape.dragging_y,
|
603
|
+
drop_shapes: Shape.drop_shapes,
|
604
|
+
x: event.x,
|
605
|
+
y: event.y
|
606
|
+
)
|
607
|
+
begin
|
608
|
+
shape_block.call(drop_event)
|
609
|
+
rescue => e
|
610
|
+
Glimmer::Config.logger.error e.full_message
|
611
|
+
ensure
|
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
|
617
|
+
Shape.dragged_shape = nil
|
618
|
+
end
|
619
|
+
end
|
620
|
+
end
|
621
|
+
else
|
622
|
+
drawable.handle_observation_request(observation_request, &shape_block)
|
578
623
|
end
|
579
|
-
drawable.handle_observation_request(observation_request, &shape_block)
|
580
624
|
end
|
581
625
|
|
582
626
|
# Sets data just like SWT widgets
|
@@ -599,7 +643,7 @@ module Glimmer
|
|
599
643
|
set_attribute(method_name, *args)
|
600
644
|
elsif has_attribute?(method_name)
|
601
645
|
get_attribute(method_name)
|
602
|
-
else
|
646
|
+
else # TODO support proxying calls to handle_observation_request for listeners just like WidgetProxy
|
603
647
|
super
|
604
648
|
end
|
605
649
|
end
|
@@ -613,6 +657,79 @@ module Glimmer
|
|
613
657
|
super
|
614
658
|
end
|
615
659
|
end
|
660
|
+
|
661
|
+
def drag_and_move=(drag_and_move_value)
|
662
|
+
drag_and_move_old_value = @drag_and_move
|
663
|
+
@drag_and_move = drag_and_move_value
|
664
|
+
if @drag_and_move && !drag_and_move_old_value
|
665
|
+
@on_drag_detected = handle_observation_request('on_drag_detected') do |event|
|
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
|
672
|
+
end
|
673
|
+
@drawable_on_mouse_move = drawable.handle_observation_request('on_mouse_move') do |event|
|
674
|
+
if Shape.dragging && Shape.dragged_shape == self
|
675
|
+
Shape.dragged_shape.move_by((event.x - Shape.dragging_x), (event.y - Shape.dragging_y))
|
676
|
+
Shape.dragging_x = event.x
|
677
|
+
Shape.dragging_y = event.y
|
678
|
+
end
|
679
|
+
end
|
680
|
+
@drawable_on_mouse_up = drawable.handle_observation_request('on_mouse_up') do |event|
|
681
|
+
if Shape.dragging && Shape.dragged_shape == self
|
682
|
+
Shape.dragging = false
|
683
|
+
end
|
684
|
+
end
|
685
|
+
elsif !@drag_and_move && drag_and_move_old_value
|
686
|
+
@on_drag_detected.deregister
|
687
|
+
@drawable_on_mouse_move.deregister
|
688
|
+
@drawable_on_mouse_up.deregister
|
689
|
+
end
|
690
|
+
end
|
691
|
+
|
692
|
+
def drag_and_move
|
693
|
+
@drag_and_move
|
694
|
+
end
|
695
|
+
|
696
|
+
def drag_source=(drag_source_value)
|
697
|
+
drag_source_old_value = @drag_source
|
698
|
+
@drag_source = drag_source_value
|
699
|
+
if @drag_source && !drag_source_old_value
|
700
|
+
@on_drag_detected = handle_observation_request('on_drag_detected') do |event|
|
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
|
707
|
+
end
|
708
|
+
@drawable_on_mouse_move = drawable.handle_observation_request('on_mouse_move') do |event|
|
709
|
+
if Shape.dragging && Shape.dragged_shape == self
|
710
|
+
Shape.dragged_shape.move_by((event.x - Shape.dragging_x), (event.y - Shape.dragging_y))
|
711
|
+
Shape.dragging_x = event.x
|
712
|
+
Shape.dragging_y = event.y
|
713
|
+
end
|
714
|
+
end
|
715
|
+
@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)}
|
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
|
721
|
+
end
|
722
|
+
end
|
723
|
+
elsif !@drag_source && drag_source_old_value
|
724
|
+
@on_drag_detected.deregister
|
725
|
+
@drawable_on_mouse_move.deregister
|
726
|
+
@drawable_on_mouse_up.deregister
|
727
|
+
end
|
728
|
+
end
|
729
|
+
|
730
|
+
def drag_source
|
731
|
+
@drag_source
|
732
|
+
end
|
616
733
|
|
617
734
|
def pattern(*args, type: nil)
|
618
735
|
instance_variable_name = "@#{type}_pattern"
|
@@ -664,6 +781,7 @@ module Glimmer
|
|
664
781
|
shapes.dup.each {|shape| shape.dispose(dispose_images: dispose_images, dispose_patterns: dispose_patterns, redraw: false) }
|
665
782
|
end
|
666
783
|
end
|
784
|
+
alias dispose_shapes clear_shapes
|
667
785
|
|
668
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)
|
669
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
|
@@ -43,55 +58,27 @@ class HelloCanvasDragAndDrop
|
|
43
58
|
}
|
44
59
|
|
45
60
|
on_mouse_move do
|
46
|
-
if
|
47
|
-
@drop_square_border.foreground = :red
|
48
|
-
end
|
61
|
+
@drop_square_border.foreground = :red if Glimmer::SWT::Custom::Shape.dragging?
|
49
62
|
end
|
50
63
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
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
|
67
|
+
ball_count = @number_shape.string.to_i
|
68
|
+
@number_shape.dispose
|
69
|
+
@drop_square.content {
|
70
|
+
@number_shape = text {
|
71
|
+
x :default
|
72
|
+
y :default
|
73
|
+
string (ball_count + 1).to_s
|
61
74
|
}
|
62
|
-
|
63
|
-
|
75
|
+
}
|
76
|
+
drop_event.dragged_shape.dispose
|
64
77
|
end
|
65
78
|
}
|
66
|
-
|
67
|
-
10.times do |n|
|
68
|
-
an_oval = oval((rand*300).to_i, (rand*200).to_i, 50, 50) {
|
69
|
-
background rgb(255, 165, 0)
|
70
|
-
|
71
|
-
# unspecified width and height become max width and max height by default
|
72
|
-
oval(0, 0) {
|
73
|
-
foreground :black
|
74
|
-
}
|
75
|
-
|
76
|
-
on_drag_detected do |event|
|
77
|
-
@dragging = an_oval
|
78
|
-
@last_x = event.x
|
79
|
-
@last_y = event.y
|
80
|
-
end
|
81
|
-
}
|
82
|
-
end
|
83
|
-
|
79
|
+
|
84
80
|
on_mouse_up do
|
85
81
|
@drop_square_border.foreground = :black
|
86
|
-
@dragging = nil
|
87
|
-
end
|
88
|
-
|
89
|
-
on_mouse_move do |event|
|
90
|
-
if @dragging
|
91
|
-
@dragging.move_by((event.x - @last_x), (event.y - @last_y))
|
92
|
-
@last_x = event.x
|
93
|
-
@last_y = event.y
|
94
|
-
end
|
95
82
|
end
|
96
83
|
}
|
97
84
|
}
|
@@ -37,8 +37,14 @@ class HelloShape
|
|
37
37
|
y_location = (rand*125).to_i%200 + (rand*15).to_i
|
38
38
|
foreground_color = rgb(rand*255, rand*255, rand*255)
|
39
39
|
|
40
|
-
stick_figure(x_location, y_location, 35+n*2, 35+n*2) {
|
40
|
+
a_stick_figure = stick_figure(x_location, y_location, 35+n*2, 35+n*2) {
|
41
41
|
foreground foreground_color
|
42
|
+
drag_and_move true
|
43
|
+
|
44
|
+
# on mouse click, change color
|
45
|
+
on_mouse_up do
|
46
|
+
a_stick_figure.foreground = rgb(rand*255, rand*255, rand*255)
|
47
|
+
end
|
42
48
|
}
|
43
49
|
}
|
44
50
|
}
|
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.
|
4
|
+
version: 4.20.13.2
|
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-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|