glimmer-dsl-swt 4.20.12.2 → 4.20.13.1

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: 94916ca37afe49d1a86e6cdc4dbc26ea0c427aeb367933bff3545cff184af89c
4
- data.tar.gz: 9f661b2400af578023b997e2fd157a2ed83f9472be8e87a06a8e05f03b8c4510
3
+ metadata.gz: 52a35ca793ca95839f0f328a465b2d9dafc008d5434520b92e2411ce19bde4ad
4
+ data.tar.gz: 7ec9d1550c1aedcb265761bb3f8c6b295a7d1d28af1944b81dcd4c8a4eb9e0f3
5
5
  SHA512:
6
- metadata.gz: ae954846060d6f0128a1a0451cfabedd7b5911585c14276223660a8ed1783951e2c21207c03375b79c7c1fd56155f1611259c755964b4929cdbdd2c1c8751280
7
- data.tar.gz: fffe1578254cc9f8fa633f519d4948a3f8f94712d5e5e16167ecbb3faf7d1cc7d37da40bd73a4bbb755aa75091682f50df450589e1c1b8a8bc8a582e67be7c4f
6
+ metadata.gz: bf6b815412f32c1a8d986c2f927f845abbebdc051adf9edfb64dfa4472715ef08970bc05dd69833de7311e596b01dc21735570175ffb74b08bc8c1888ebe46d0
7
+ data.tar.gz: fb05c6d864f98d744e57507c0c00145d1b19f689f76b4970d1c6901390ff94a8c4eea0bc81c6b7c3fb27371c3b46e23c28a9911853654d9adb97a77dbffa62d6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.20.13.1
4
+
5
+ - Supporting having a `drag_source` that is dragged and not dropped at a target go back to its original position
6
+ - Fix issue of dragged shape getting obscured by ensuring that it is rendered on top of all other shapes
7
+ - 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.
8
+
9
+ ### 4.20.13.0
10
+
11
+ - Shape `drag_and_move true` property to make shapes movable via dragging
12
+ - Shape `drag_source true` and `on_drop {|event| }` built-in support for drag and drop
13
+ - Refactor Hello, Canvas Drag and Drop! to use new Shape built-in support for drag and drop
14
+
15
+ ### 4.20.12.4
16
+
17
+ - Update Hello, Shape! to take advantage of shape listeners (on mouse click, change color)
18
+
19
+ ### 4.20.12.3
20
+
21
+ - Make Custom Shapes support on_event listeners just like Shapes
22
+ - Update Hello, Custom Shape! to take advantage of custom shape listeners (on mouse click, change color)
23
+
3
24
  ### 4.20.12.2
4
25
 
5
26
  - Make Shape listeners check inclusion against all sub-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.12.2
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
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.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).
18
+ [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.20.13.1 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.2
329
+ jgem install glimmer-dsl-swt -v 4.20.13.1
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.2'
357
+ gem 'glimmer-dsl-swt', '~> 4.20.13.1'
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.2
378
+ Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.20.13.1
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.2
1
+ 4.20.13.1
Binary file
@@ -39,7 +39,7 @@ module Glimmer
39
39
  SWT,
40
40
  %w[
41
41
  layout
42
- widget_listener
42
+ listener
43
43
  combo_selection_data_binding
44
44
  checkbox_group_selection_data_binding
45
45
  radio_group_selection_data_binding
@@ -22,17 +22,17 @@
22
22
  require 'glimmer/dsl/expression'
23
23
  require 'glimmer/swt/display_proxy'
24
24
  require 'glimmer/swt/custom/shape'
25
+ require 'glimmer/ui/custom_shape'
25
26
 
26
27
  module Glimmer
27
28
  module DSL
28
29
  module SWT
29
- class WidgetListenerExpression < Expression
30
- include_package 'org.eclipse.swt.widgets'
31
-
30
+ # Widget, Shape, and Display listener experssion
31
+ class ListenerExpression < Expression
32
32
  def can_interpret?(parent, keyword, *args, &block)
33
33
  Glimmer::Config.logger.debug {"keyword starts with on_: #{keyword.start_with?('on_')}"}
34
34
  return false unless keyword.start_with?('on_')
35
- proper_parent = parent.respond_to?(:swt_widget) || parent.is_a?(Glimmer::SWT::DisplayProxy) || parent.is_a?(Glimmer::SWT::Custom::Shape)
35
+ proper_parent = parent.respond_to?(:swt_widget) || parent.is_a?(Glimmer::SWT::DisplayProxy) || parent.is_a?(Glimmer::SWT::Custom::Shape) || parent.is_a?(Glimmer::UI::CustomShape)
36
36
  Glimmer::Config.logger.debug {"parent #{parent} is a widget, shape, or display: #{proper_parent}"}
37
37
  return false unless proper_parent
38
38
  Glimmer::Config.logger.debug {"block exists?: #{!block.nil?}"}
@@ -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(: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
@@ -509,6 +524,7 @@ module Glimmer
509
524
  def set_attribute(attribute_name, *args)
510
525
  options = args.last if args.last.is_a?(Hash)
511
526
  args.pop if !options.nil? && !options[:redraw].nil?
527
+ options ||= {}
512
528
  perform_redraw = @perform_redraw
513
529
  perform_redraw = options[:redraw] if perform_redraw.nil? && !options.nil?
514
530
  perform_redraw ||= true
@@ -529,11 +545,12 @@ module Glimmer
529
545
  @properties[ruby_attribute_getter_name] = args
530
546
  amend_method_name_options_based_on_properties! if @content_added && new_property
531
547
  property_change = true
548
+ calculated_paint_args_changed! if container?
532
549
  end
533
550
  if @content_added && perform_redraw && !drawable.is_disposed
534
551
  redrawn = false
535
552
  unless property_change
536
- @calculated_paint_args = false
553
+ calculated_paint_args_changed!(children: false)
537
554
  if is_a?(PathSegment)
538
555
  root_path&.calculated_path_args = @calculated_path_args = false
539
556
  calculated_args_changed!
@@ -549,7 +566,7 @@ module Glimmer
549
566
  end
550
567
  # TODO consider redrawing an image proxy's gc in the future
551
568
  # TODO consider ensuring only a single redraw happens for a hierarchy of nested shapes
552
- drawable.redraw unless redrawn || drawable.is_a?(ImageProxy)
569
+ drawable.redraw if !redrawn && !drawable.is_a?(ImageProxy)
553
570
  end
554
571
  end
555
572
 
@@ -570,11 +587,35 @@ module Glimmer
570
587
 
571
588
  def handle_observation_request(observation_request, &block)
572
589
  shape_block = lambda do |event|
573
- included = include?(event.x, event.y)
574
- included ||= shapes.to_a.detect { |shape| shape.include?(event.x, event.y) }
575
- 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
+ dragged_shape: Shape.dragged_shape,
598
+ dragged_shape_original_x: Shape.dragged_shape_original_x,
599
+ dragged_shape_original_y: Shape.dragged_shape_original_y,
600
+ dragging_x: Shape.dragging_x,
601
+ dragging_y: Shape.dragging_y,
602
+ drop_shapes: Shape.drop_shapes,
603
+ x: event.x,
604
+ y: event.y
605
+ )
606
+ begin
607
+ shape_block.call(drop_event)
608
+ rescue => e
609
+ Glimmer::Config.logger.error e.full_message
610
+ ensure
611
+ Shape.dragging = false
612
+ Shape.dragged_shape = nil
613
+ end
614
+ end
615
+ end
616
+ else
617
+ drawable.handle_observation_request(observation_request, &shape_block)
576
618
  end
577
- drawable.handle_observation_request(observation_request, &shape_block)
578
619
  end
579
620
 
580
621
  # Sets data just like SWT widgets
@@ -597,7 +638,7 @@ module Glimmer
597
638
  set_attribute(method_name, *args)
598
639
  elsif has_attribute?(method_name)
599
640
  get_attribute(method_name)
600
- else
641
+ else # TODO support proxying calls to handle_observation_request for listeners just like WidgetProxy
601
642
  super
602
643
  end
603
644
  end
@@ -611,6 +652,79 @@ module Glimmer
611
652
  super
612
653
  end
613
654
  end
655
+
656
+ def drag_and_move=(drag_and_move_value)
657
+ drag_and_move_old_value = @drag_and_move
658
+ @drag_and_move = drag_and_move_value
659
+ if @drag_and_move && !drag_and_move_old_value
660
+ @on_drag_detected = handle_observation_request('on_drag_detected') do |event|
661
+ Shape.dragging = true
662
+ Shape.dragging_x = event.x
663
+ Shape.dragging_y = event.y
664
+ Shape.dragged_shape = self
665
+ Shape.dragged_shape_original_x = x
666
+ Shape.dragged_shape_original_y = y
667
+ end
668
+ @drawable_on_mouse_move = drawable.handle_observation_request('on_mouse_move') do |event|
669
+ if Shape.dragging && Shape.dragged_shape == self
670
+ Shape.dragged_shape.move_by((event.x - Shape.dragging_x), (event.y - Shape.dragging_y))
671
+ Shape.dragging_x = event.x
672
+ Shape.dragging_y = event.y
673
+ end
674
+ end
675
+ @drawable_on_mouse_up = drawable.handle_observation_request('on_mouse_up') do |event|
676
+ if Shape.dragging && Shape.dragged_shape == self
677
+ Shape.dragging = false
678
+ end
679
+ end
680
+ elsif !@drag_and_move && drag_and_move_old_value
681
+ @on_drag_detected.deregister
682
+ @drawable_on_mouse_move.deregister
683
+ @drawable_on_mouse_up.deregister
684
+ end
685
+ end
686
+
687
+ def drag_and_move
688
+ @drag_and_move
689
+ end
690
+
691
+ def drag_source=(drag_source_value)
692
+ drag_source_old_value = @drag_source
693
+ @drag_source = drag_source_value
694
+ if @drag_source && !drag_source_old_value
695
+ @on_drag_detected = handle_observation_request('on_drag_detected') do |event|
696
+ Shape.dragging = true
697
+ Shape.dragging_x = event.x
698
+ Shape.dragging_y = event.y
699
+ Shape.dragged_shape = self
700
+ Shape.dragged_shape_original_x = x
701
+ Shape.dragged_shape_original_y = y
702
+ end
703
+ @drawable_on_mouse_move = drawable.handle_observation_request('on_mouse_move') do |event|
704
+ if Shape.dragging && Shape.dragged_shape == self
705
+ Shape.dragged_shape.move_by((event.x - Shape.dragging_x), (event.y - Shape.dragging_y))
706
+ Shape.dragging_x = event.x
707
+ Shape.dragging_y = event.y
708
+ end
709
+ end
710
+ @drawable_on_mouse_up = drawable.handle_observation_request('on_mouse_up') do |event|
711
+ if Shape.dragging && Shape.dragged_shape == self && !Shape.drop_shapes.detect {|shape| shape.include_with_children?(event.x, event.y)}
712
+ Shape.dragging = false
713
+ Shape.dragged_shape.x = Shape.dragged_shape_original_x
714
+ Shape.dragged_shape.y = Shape.dragged_shape_original_y
715
+ Shape.dragged_shape = nil
716
+ end
717
+ end
718
+ elsif !@drag_source && drag_source_old_value
719
+ @on_drag_detected.deregister
720
+ @drawable_on_mouse_move.deregister
721
+ @drawable_on_mouse_up.deregister
722
+ end
723
+ end
724
+
725
+ def drag_source
726
+ @drag_source
727
+ end
614
728
 
615
729
  def pattern(*args, type: nil)
616
730
  instance_variable_name = "@#{type}_pattern"
@@ -790,7 +904,7 @@ module Glimmer
790
904
  extent_args << extent_flags unless extent_flags.nil?
791
905
  self.extent = paint_event.gc.send("#{@name}Extent", *extent_args)
792
906
  end
793
- if !@extent.nil? && (old_extent&.x != @extent&.x || old_extent&.y != @extent&.y)
907
+ if !@extent.nil? && (old_extent&.x != @extent&.x || old_extent&.y != @extent&.y) # TODO add a check to text content changing too
794
908
  calculated_args_changed!
795
909
  parent.calculated_args_changed_for_defaults! if parent.is_a?(Shape)
796
910
  end
@@ -812,6 +926,12 @@ module Glimmer
812
926
  shapes.each(&:calculated_args_changed!) if children
813
927
  end
814
928
 
929
+ def calculated_paint_args_changed!(children: true)
930
+ @calculated_paint_args = nil
931
+ @all_parent_properties = nil
932
+ shapes.each(&:calculated_paint_args_changed!) if children
933
+ end
934
+
815
935
  # Notifies object that calculated args changed for defaults. Returns true if redrawing and false otherwise.
816
936
  def calculated_args_changed_for_defaults!
817
937
  has_default_dimensions = default_width? || default_height?
@@ -1205,7 +1325,8 @@ module Glimmer
1205
1325
  end
1206
1326
  end
1207
1327
  else
1208
- @properties = all_parent_properties.merge(@properties)
1328
+ @original_properties ||= @properties
1329
+ @properties = all_parent_properties.merge(@original_properties)
1209
1330
  @properties['background'] = [@drawable.background] if fill? && !has_some_background?
1210
1331
  @properties['foreground'] = [@drawable.foreground] if @drawable.respond_to?(:foreground) && draw? && !has_some_foreground?
1211
1332
  # TODO regarding alpha, make sure to reset it to parent stored alpha once we allow setting shape properties on parents directly without shapes
@@ -254,6 +254,16 @@ module Glimmer
254
254
  end
255
255
  end
256
256
 
257
+ # TODO consider bringing observer_registrations method from CustomWidget if needed
258
+
259
+ def can_handle_observation_request?(observation_request)
260
+ body_root&.can_handle_observation_request?(observation_request)
261
+ end
262
+
263
+ def handle_observation_request(observation_request, &block)
264
+ body_root.handle_observation_request(observation_request, &block)
265
+ end
266
+
257
267
  def method_missing(method, *args, &block)
258
268
  # TODO Consider supporting a glimmer error silencing option for methods defined here
259
269
  # but fail the glimmer DSL for the right reason to avoid seeing noise in the log output
@@ -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,26 @@ 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
+ ball_count = @number_shape.string.to_i
67
+ @number_shape.dispose
68
+ @drop_square.content {
69
+ @number_shape = text {
70
+ x :default
71
+ y :default
72
+ string (ball_count + 1).to_s
61
73
  }
62
- @dragging.dispose
63
- end
74
+ }
75
+ drop_event.dragged_shape.dispose
64
76
  end
65
77
  }
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
-
78
+
84
79
  on_mouse_up do
85
80
  @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
81
  end
96
82
  }
97
83
  }
@@ -65,8 +65,14 @@ class HelloCustomShape
65
65
  y_location = (rand*HEIGHT/2).to_i%HEIGHT + (rand*15).to_i
66
66
  foreground_color = rgb(rand*255, rand*255, rand*255)
67
67
 
68
- stick_figure(x: x_location, y: y_location, width: 35+n*2, height: 35+n*2) {
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
71
+
72
+ # on mouse click, change color
73
+ on_mouse_up do
74
+ a_stick_figure.foreground = rgb(rand*255, rand*255, rand*255)
75
+ end
70
76
  }
71
77
  }
72
78
  }
@@ -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.12.2
4
+ version: 4.20.13.1
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-26 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
@@ -438,6 +438,7 @@ files:
438
438
  - lib/glimmer/dsl/swt/layout_data_expression.rb
439
439
  - lib/glimmer/dsl/swt/layout_expression.rb
440
440
  - lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb
441
+ - lib/glimmer/dsl/swt/listener_expression.rb
441
442
  - lib/glimmer/dsl/swt/menu_bar_expression.rb
442
443
  - lib/glimmer/dsl/swt/menu_expression.rb
443
444
  - lib/glimmer/dsl/swt/message_box_expression.rb
@@ -462,7 +463,6 @@ files:
462
463
  - lib/glimmer/dsl/swt/tree_items_data_binding_expression.rb
463
464
  - lib/glimmer/dsl/swt/tree_properties_expression.rb
464
465
  - lib/glimmer/dsl/swt/widget_expression.rb
465
- - lib/glimmer/dsl/swt/widget_listener_expression.rb
466
466
  - lib/glimmer/launcher.rb
467
467
  - lib/glimmer/rake_task.rb
468
468
  - lib/glimmer/rake_task/list.rb