glimmer-dsl-swt 4.20.12.4 → 4.20.13.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 20ac26497d5bf601549eb0f566099c6dd5e37a6ca9c471bbd5169b0a7a46b560
4
- data.tar.gz: 183f6ad0365f4022279bf16024551581ece3b171c9ce5683266c0448684c1d9a
3
+ metadata.gz: a2334810c1c1fb86f4539f50c79e463c1574abab93c58300e7352c68b1a6b77a
4
+ data.tar.gz: 8a64907ff1c3b7eabbd13e289fc7bb603886a9128981af6606082a323b31d952
5
5
  SHA512:
6
- metadata.gz: d6b00d1a29dd7b31f9411f33862b7cf762f5bd83cc83ccab83800c725e6b7284814826f943192e4cf1650fad1bf22b0ee5c7d97809431b66e038b7dec75758fe
7
- data.tar.gz: ec109fc95534945204495fed7b37d66172261b4ee826e20412e43cfeb03a3615ec6d9eb612bcea58c8b3fb89e53ed09a6d4b496dfd71e5761a94f928a23994fb
6
+ metadata.gz: 11fb6dea6fa4fdaccfde2ec485284a937eea521b7d41726b38c1e92cf098f2bd3d31ec739f5f1cf23f444df65983bea2a49b2dd2816d3dcc3f6a40720f8fc1a7
7
+ data.tar.gz: 936aa733ded3e24d379ee2f0bff42ec0d49abf8410578ebb42b686481a25b820c3a52eaa4bf9680b983e92e92a197b1c53703c54d564ff798fa917ca9de34984
data/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.20.13.3
4
+
5
+ - Fix issue regarding `nil` calculated_width/calculated_height encountered in Shape#contain?
6
+
7
+ ### 4.20.13.2
8
+
9
+ - Support `drop_event.doit = false` to deny dropping and move dragged shape back to where it was
10
+
11
+ ### 4.20.13.1
12
+
13
+ - Supporting having a `drag_source` that is dragged and not dropped at a target go back to its original position
14
+ - Fix issue of dragged shape getting obscured by ensuring that it is rendered on top of all other shapes
15
+ - 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.
16
+
17
+ ### 4.20.13.0
18
+
19
+ - Shape `drag_and_move true` property to make shapes movable via dragging
20
+ - Shape `drag_source true` and `on_drop {|event| }` built-in support for drag and drop
21
+ - Refactor Hello, Canvas Drag and Drop! to use new Shape built-in support for drag and drop
22
+
3
23
  ### 4.20.12.4
4
24
 
5
25
  - Update Hello, Shape! to take advantage of shape listeners (on mouse click, change color)
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.12.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.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.12.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).
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.12.4
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.12.4'
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.12.4
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.12.4
1
+ 4.20.13.3
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
@@ -207,7 +217,7 @@ module Glimmer
207
217
  # some shapes may choose to provide a fuzz factor to make usage of this method for mouse clicking more user friendly
208
218
  def contain?(x, y)
209
219
  # assume a rectangular filled shape by default (works for several shapes like image, text, and focus)
210
- 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)
211
221
  end
212
222
 
213
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)
@@ -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
- included = include?(event.x, event.y)
576
- included ||= expanded_shapes.detect { |shape| shape.include?(event.x, event.y) }
577
- block.call(event) if included
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 @dragging
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
- on_mouse_up do
52
- if @dragging
53
- ball_count = @number_shape.string.to_i
54
- @number_shape.dispose
55
- @drop_square.content {
56
- @number_shape = text {
57
- x :default
58
- y :default
59
- string (ball_count + 1).to_s
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
- @dragging.dispose
63
- end
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
  }
@@ -67,6 +67,7 @@ class HelloCustomShape
67
67
 
68
68
  a_stick_figure = stick_figure(x: x_location, y: y_location, width: 35+n*2, height: 35+n*2) {
69
69
  foreground foreground_color
70
+ drag_and_move true
70
71
 
71
72
  # on mouse click, change color
72
73
  on_mouse_up do
@@ -39,6 +39,7 @@ class HelloShape
39
39
 
40
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
42
43
 
43
44
  # on mouse click, change color
44
45
  on_mouse_up do
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.12.4
4
+ version: 4.20.13.3
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-27 00:00:00.000000000 Z
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