glimmer-dsl-swt 4.20.12.4 → 4.20.13.0

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: 3f381c0b3d2f94fb562307642fe38f69d806f1bd48432e49f1039dc19f23084e
4
+ data.tar.gz: 9e9965fcbc725ef7da7a4fb1b79d6026dc5ed4865fa4e81d19805ce93fd63db8
5
5
  SHA512:
6
- metadata.gz: d6b00d1a29dd7b31f9411f33862b7cf762f5bd83cc83ccab83800c725e6b7284814826f943192e4cf1650fad1bf22b0ee5c7d97809431b66e038b7dec75758fe
7
- data.tar.gz: ec109fc95534945204495fed7b37d66172261b4ee826e20412e43cfeb03a3615ec6d9eb612bcea58c8b3fb89e53ed09a6d4b496dfd71e5761a94f928a23994fb
6
+ metadata.gz: 4fb4fb09032cf57af92d9afd700ee81c6bf7ebb5969abbf5e1927bfccb3604269f49a6e79a9761cddd005ea506146e50aa76dbcd34cb64aba16136b18b4b191c
7
+ data.tar.gz: b5c319a6c4d14d014297ffaa2f1a6d3195a662cd7d4604bd4685cbd026feee873c80ec400c1b47f680867f3176fef854048359bbbbba1db21f5dc89a25c3f9e7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.20.13.0
4
+
5
+ - Shape `drag_and_move true` property to make shapes movable via dragging
6
+ - Shape `drag_source true` and `on_drop {|event| }` built-in support for drag and drop
7
+ - Refactor Hello, Canvas Drag and Drop! to use new Shape built-in support for drag and drop
8
+
3
9
  ### 4.20.12.4
4
10
 
5
11
  - 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.0
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.0 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.0
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.0'
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.0
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.0
Binary file
@@ -62,7 +62,12 @@ 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)
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)
@@ -565,7 +570,7 @@ module Glimmer
565
570
  @properties[attribute_name.to_s]
566
571
  end
567
572
  end
568
-
573
+
569
574
  def can_handle_observation_request?(observation_request)
570
575
  drawable.can_handle_observation_request?(observation_request)
571
576
  end
@@ -576,7 +581,31 @@ module Glimmer
576
581
  included ||= expanded_shapes.detect { |shape| shape.include?(event.x, event.y) }
577
582
  block.call(event) if included
578
583
  end
579
- drawable.handle_observation_request(observation_request, &shape_block)
584
+ if observation_request == 'on_drop'
585
+ handle_observation_request('on_mouse_up') do |event|
586
+ if Shape.dragged_shape
587
+ drop_event = DropEvent.new(
588
+ dragged_shape: Shape.dragged_shape,
589
+ dragged_shape_original_x: Shape.dragged_shape_original_x,
590
+ dragged_shape_original_y: Shape.dragged_shape_original_y,
591
+ dragging_x: Shape.dragging_x,
592
+ dragging_y: Shape.dragging_y,
593
+ x: event.x,
594
+ y: event.y
595
+ )
596
+ begin
597
+ shape_block.call(drop_event)
598
+ rescue => e
599
+ Glimmer::Config.logger.error e.full_message
600
+ ensure
601
+ Shape.dragging = false
602
+ Shape.dragged_shape = nil
603
+ end
604
+ end
605
+ end
606
+ else
607
+ drawable.handle_observation_request(observation_request, &shape_block)
608
+ end
580
609
  end
581
610
 
582
611
  # Sets data just like SWT widgets
@@ -599,7 +628,7 @@ module Glimmer
599
628
  set_attribute(method_name, *args)
600
629
  elsif has_attribute?(method_name)
601
630
  get_attribute(method_name)
602
- else
631
+ else # TODO support proxying calls to handle_observation_request for listeners just like WidgetProxy
603
632
  super
604
633
  end
605
634
  end
@@ -613,6 +642,80 @@ module Glimmer
613
642
  super
614
643
  end
615
644
  end
645
+
646
+ def drag_and_move=(drag_and_move_value)
647
+ drag_and_move_old_value = @drag_and_move
648
+ @drag_and_move = drag_and_move_value
649
+ if @drag_and_move && !drag_and_move_old_value
650
+ @on_drag_detected = handle_observation_request('on_drag_detected') do |event|
651
+ if !Shape.dragging
652
+ Shape.dragging = true
653
+ Shape.dragging_x = event.x
654
+ Shape.dragging_y = event.y
655
+ Shape.dragged_shape = self
656
+ Shape.dragged_shape_original_x = x
657
+ Shape.dragged_shape_original_y = y
658
+ end
659
+ end
660
+ @drawable_on_mouse_move = drawable.handle_observation_request('on_mouse_move') do |event|
661
+ if Shape.dragging && Shape.dragged_shape == self
662
+ Shape.dragged_shape.move_by((event.x - Shape.dragging_x), (event.y - Shape.dragging_y))
663
+ Shape.dragging_x = event.x
664
+ Shape.dragging_y = event.y
665
+ end
666
+ end
667
+ @drawable_on_mouse_up = drawable.handle_observation_request('on_mouse_up') do |event|
668
+ if Shape.dragging && Shape.dragged_shape == self
669
+ Shape.dragging = false
670
+ end
671
+ end
672
+ elsif !@drag_and_move && drag_and_move_old_value
673
+ @on_drag_detected.deregister
674
+ @drawable_on_mouse_move.deregister
675
+ @drawable_on_mouse_up.deregister
676
+ end
677
+ end
678
+
679
+ def drag_and_move
680
+ @drag_and_move
681
+ end
682
+
683
+ def drag_source=(drag_source_value)
684
+ drag_source_old_value = @drag_source
685
+ @drag_source = drag_source_value
686
+ if @drag_source && !drag_source_old_value
687
+ @on_drag_detected = handle_observation_request('on_drag_detected') do |event|
688
+ if !Shape.dragging
689
+ Shape.dragging = true
690
+ Shape.dragging_x = event.x
691
+ Shape.dragging_y = event.y
692
+ Shape.dragged_shape = self
693
+ Shape.dragged_shape_original_x = x
694
+ Shape.dragged_shape_original_y = y
695
+ end
696
+ end
697
+ @drawable_on_mouse_move = drawable.handle_observation_request('on_mouse_move') do |event|
698
+ if Shape.dragging && Shape.dragged_shape == self
699
+ Shape.dragged_shape.move_by((event.x - Shape.dragging_x), (event.y - Shape.dragging_y))
700
+ Shape.dragging_x = event.x
701
+ Shape.dragging_y = event.y
702
+ end
703
+ end
704
+ @drawable_on_mouse_up = drawable.handle_observation_request('on_mouse_up') do |event|
705
+ if Shape.dragging && Shape.dragged_shape == self
706
+ Shape.dragging = false
707
+ end
708
+ end
709
+ elsif !@drag_source && drag_source_old_value
710
+ @on_drag_detected.deregister
711
+ @drawable_on_mouse_move.deregister
712
+ @drawable_on_mouse_up.deregister
713
+ end
714
+ end
715
+
716
+ def drag_source
717
+ @drag_source
718
+ end
616
719
 
617
720
  def pattern(*args, type: nil)
618
721
  instance_variable_name = "@#{type}_pattern"
@@ -43,55 +43,37 @@ class HelloCanvasDragAndDrop
43
43
  }
44
44
 
45
45
  on_mouse_move do
46
- if @dragging
47
- @drop_square_border.foreground = :red
48
- end
46
+ @drop_square_border.foreground = :red if Glimmer::SWT::Custom::Shape.dragging?
49
47
  end
50
48
 
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
- }
49
+ on_drop do |event|
50
+ ball_count = @number_shape.string.to_i
51
+ @number_shape.dispose
52
+ @drop_square.content {
53
+ @number_shape = text {
54
+ x :default
55
+ y :default
56
+ string (ball_count + 1).to_s
61
57
  }
62
- @dragging.dispose
63
- end
58
+ }
59
+ event.dragged_shape.dispose
64
60
  end
65
61
  }
66
62
 
67
63
  10.times do |n|
68
64
  an_oval = oval((rand*300).to_i, (rand*200).to_i, 50, 50) {
69
65
  background rgb(255, 165, 0)
66
+ drag_source true
70
67
 
71
68
  # unspecified width and height become max width and max height by default
72
69
  oval(0, 0) {
73
70
  foreground :black
74
71
  }
75
-
76
- on_drag_detected do |event|
77
- @dragging = an_oval
78
- @last_x = event.x
79
- @last_y = event.y
80
- end
81
72
  }
82
73
  end
83
74
 
84
75
  on_mouse_up do
85
76
  @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
77
  end
96
78
  }
97
79
  }
@@ -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,7 +1,7 @@
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.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh