glimmer-dsl-swt 4.20.12.0 → 4.20.12.4

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: db6def93b1e2b7c5b5275126e53dbb42e23021721f41a23f98528d1f69f01f1b
4
- data.tar.gz: 4d5b8fc17d10df490b1614e573d8a678c418f10cc2e5d43d0352905cf5245b1f
3
+ metadata.gz: 20ac26497d5bf601549eb0f566099c6dd5e37a6ca9c471bbd5169b0a7a46b560
4
+ data.tar.gz: 183f6ad0365f4022279bf16024551581ece3b171c9ce5683266c0448684c1d9a
5
5
  SHA512:
6
- metadata.gz: fae5f9df309f2e0aada6c7557abb786faffc4cfdac5f82945183389bff644376106f0b41d1bc2b9b0d0cd2aaa14a07f2ad506545290cc7870354c377cad98c06
7
- data.tar.gz: 85fabb309339aed175bb2bc662af3b9ba9f8b365114bbdaf3f4a642b94187bf2f07406c32c716b3ab71bcfa739a64ff53e7b846a9228e18ed0fe6d84f9890e3a
6
+ metadata.gz: d6b00d1a29dd7b31f9411f33862b7cf762f5bd83cc83ccab83800c725e6b7284814826f943192e4cf1650fad1bf22b0ee5c7d97809431b66e038b7dec75758fe
7
+ data.tar.gz: ec109fc95534945204495fed7b37d66172261b4ee826e20412e43cfeb03a3615ec6d9eb612bcea58c8b3fb89e53ed09a6d4b496dfd71e5761a94f928a23994fb
data/CHANGELOG.md CHANGED
@@ -1,9 +1,28 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.20.12.4
4
+
5
+ - Update Hello, Shape! to take advantage of shape listeners (on mouse click, change color)
6
+
7
+ ### 4.20.12.3
8
+
9
+ - Make Custom Shapes support on_event listeners just like Shapes
10
+ - Update Hello, Custom Shape! to take advantage of custom shape listeners (on mouse click, change color)
11
+
12
+ ### 4.20.12.2
13
+
14
+ - Make Shape listeners check inclusion against all sub-shapes
15
+ - Refactor Hello, Canvas Drag & Drop! sample to use composite shapes (e.g. ball containing a ball border)
16
+
17
+ ### 4.20.12.1
18
+
19
+ - Hello, Canvas Drag & Drop! sample
20
+
3
21
  ### 4.20.12.0
4
22
 
5
23
  - Canvas Shape Listeners: on_mouse_up, on_mouse_down, on_mouse_move, on_drag_detected
6
24
  - Make scaffolding not generate an empty () after shell
25
+ - Hello, Canvas Shape Listeners! Sample
7
26
 
8
27
  ### 4.20.11.1
9
28
 
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.0
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
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.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).
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).
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.0
329
+ jgem install glimmer-dsl-swt -v 4.20.12.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.12.0'
357
+ gem 'glimmer-dsl-swt', '~> 4.20.12.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.12.0
378
+ Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.20.12.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.12.0
1
+ 4.20.12.4
@@ -45,6 +45,7 @@
45
45
  - [Hello, Canvas Path!](#hello-canvas-path)
46
46
  - [Hello, Canvas Data Binding!](#hello-canvas-data-binding)
47
47
  - [Hello, Canvas Shape Listeners!](#hello-canvas-shape-listeners)
48
+ - [Hello, Canvas Drag and Drop!](#hello-canvas-drag-and-drop)
48
49
  - [Hello, Cursor!](#hello-cursor)
49
50
  - [Hello, Progress Bar!](#hello-progress-bar)
50
51
  - [Hello, Tree!](#hello-tree)
@@ -833,6 +834,16 @@ Hello, Canvas Shape Listeners! - Dragged Circle
833
834
 
834
835
  ![Hello Canvas Shape Listeners Dragged](/images/glimmer-hello-canvas-shape-listeners-dragged.png)
835
836
 
837
+ #### Hello, Canvas Drag and Drop!
838
+
839
+ This sample demonstrates Canvas Shape DSL drag and drop (different from standard widget drag and drop).
840
+
841
+ Code:
842
+
843
+ [samples/hello/hello_canvas_drag_and_drop.rb](/samples/hello/hello_canvas_drag_and_drop.rb)
844
+
845
+ ![Hello Canvas Drag and Drop](/images/glimmer-hello-canvas-drag-and-drop.gif)
846
+
836
847
  #### Hello, Cursor!
837
848
 
838
849
  This sample demonstrates the use of the `cursor` property keyword to change the mouse cursor.
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?}"}
@@ -509,6 +509,7 @@ module Glimmer
509
509
  def set_attribute(attribute_name, *args)
510
510
  options = args.last if args.last.is_a?(Hash)
511
511
  args.pop if !options.nil? && !options[:redraw].nil?
512
+ options ||= {}
512
513
  perform_redraw = @perform_redraw
513
514
  perform_redraw = options[:redraw] if perform_redraw.nil? && !options.nil?
514
515
  perform_redraw ||= true
@@ -529,11 +530,12 @@ module Glimmer
529
530
  @properties[ruby_attribute_getter_name] = args
530
531
  amend_method_name_options_based_on_properties! if @content_added && new_property
531
532
  property_change = true
533
+ calculated_paint_args_changed! if container?
532
534
  end
533
535
  if @content_added && perform_redraw && !drawable.is_disposed
534
536
  redrawn = false
535
537
  unless property_change
536
- @calculated_paint_args = false
538
+ calculated_paint_args_changed!(children: false)
537
539
  if is_a?(PathSegment)
538
540
  root_path&.calculated_path_args = @calculated_path_args = false
539
541
  calculated_args_changed!
@@ -549,7 +551,7 @@ module Glimmer
549
551
  end
550
552
  # TODO consider redrawing an image proxy's gc in the future
551
553
  # TODO consider ensuring only a single redraw happens for a hierarchy of nested shapes
552
- drawable.redraw unless redrawn || drawable.is_a?(ImageProxy)
554
+ drawable.redraw if !redrawn && !drawable.is_a?(ImageProxy)
553
555
  end
554
556
  end
555
557
 
@@ -570,7 +572,9 @@ module Glimmer
570
572
 
571
573
  def handle_observation_request(observation_request, &block)
572
574
  shape_block = lambda do |event|
573
- block.call(event) if include?(event.x, event.y)
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
574
578
  end
575
579
  drawable.handle_observation_request(observation_request, &shape_block)
576
580
  end
@@ -788,7 +792,7 @@ module Glimmer
788
792
  extent_args << extent_flags unless extent_flags.nil?
789
793
  self.extent = paint_event.gc.send("#{@name}Extent", *extent_args)
790
794
  end
791
- if !@extent.nil? && (old_extent&.x != @extent&.x || old_extent&.y != @extent&.y)
795
+ if !@extent.nil? && (old_extent&.x != @extent&.x || old_extent&.y != @extent&.y) # TODO add a check to text content changing too
792
796
  calculated_args_changed!
793
797
  parent.calculated_args_changed_for_defaults! if parent.is_a?(Shape)
794
798
  end
@@ -810,6 +814,12 @@ module Glimmer
810
814
  shapes.each(&:calculated_args_changed!) if children
811
815
  end
812
816
 
817
+ def calculated_paint_args_changed!(children: true)
818
+ @calculated_paint_args = nil
819
+ @all_parent_properties = nil
820
+ shapes.each(&:calculated_paint_args_changed!) if children
821
+ end
822
+
813
823
  # Notifies object that calculated args changed for defaults. Returns true if redrawing and false otherwise.
814
824
  def calculated_args_changed_for_defaults!
815
825
  has_default_dimensions = default_width? || default_height?
@@ -1203,7 +1213,8 @@ module Glimmer
1203
1213
  end
1204
1214
  end
1205
1215
  else
1206
- @properties = all_parent_properties.merge(@properties)
1216
+ @original_properties ||= @properties
1217
+ @properties = all_parent_properties.merge(@original_properties)
1207
1218
  @properties['background'] = [@drawable.background] if fill? && !has_some_background?
1208
1219
  @properties['foreground'] = [@drawable.foreground] if @drawable.respond_to?(:foreground) && draw? && !has_some_foreground?
1209
1220
  # TODO regarding alpha, make sure to reset it to parent stored alpha once we allow setting shape properties on parents directly without shapes
@@ -180,7 +180,7 @@ module Glimmer
180
180
  raise Glimmer::Error, 'Invalid custom shape for having no body! Please define body block!' if body_block.nil?
181
181
  @body_root = instance_exec(&body_block)
182
182
  raise Glimmer::Error, 'Invalid custom shape for having an empty body! Please fill body block!' if @body_root.nil?
183
- auto_exec do
183
+ auto_exec do # TODO is this necessary given shape is a lightweight construct (not SWT widget) ?
184
184
  @body_root.set_data('custom_shape', self)
185
185
  end
186
186
  execute_hook('after_body')
@@ -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
@@ -0,0 +1,101 @@
1
+ require 'glimmer-dsl-swt'
2
+
3
+ class HelloCanvasDragAndDrop
4
+ include Glimmer::UI::CustomShell
5
+
6
+ body {
7
+ shell {
8
+ row_layout(:vertical) {
9
+ margin_width 0
10
+ margin_height 0
11
+ fill true
12
+ center true
13
+ }
14
+ text 'Hello, Canvas Drag & Drop!'
15
+
16
+ label(:center) {
17
+ text 'Drag orange balls and drop in the square.'
18
+ font height: 16
19
+ }
20
+
21
+ canvas {
22
+ layout_data {
23
+ width 350
24
+ height 350
25
+ }
26
+
27
+ background :white
28
+
29
+ @drop_square = rectangle(150, 260, 50, 50) {
30
+ background :white
31
+
32
+ # unspecified width and height become max width and max height by default
33
+ @drop_square_border = rectangle(0, 0) {
34
+ foreground :black
35
+ line_width 3
36
+ line_style :dash
37
+ }
38
+
39
+ @number_shape = text {
40
+ x :default
41
+ y :default
42
+ string '0'
43
+ }
44
+
45
+ on_mouse_move do
46
+ if @dragging
47
+ @drop_square_border.foreground = :red
48
+ end
49
+ end
50
+
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
+ }
61
+ }
62
+ @dragging.dispose
63
+ end
64
+ end
65
+ }
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
+
84
+ on_mouse_up do
85
+ @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
+ end
96
+ }
97
+ }
98
+ }
99
+ end
100
+
101
+ HelloCanvasDragAndDrop.launch
@@ -65,8 +65,13 @@ 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
+
71
+ # on mouse click, change color
72
+ on_mouse_up do
73
+ a_stick_figure.foreground = rgb(rand*255, rand*255, rand*255)
74
+ end
70
75
  }
71
76
  }
72
77
  }
@@ -37,8 +37,13 @@ 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
+
43
+ # on mouse click, change color
44
+ on_mouse_up do
45
+ a_stick_figure.foreground = rgb(rand*255, rand*255, rand*255)
46
+ end
42
47
  }
43
48
  }
44
49
  }
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.0
4
+ version: 4.20.12.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-26 00:00:00.000000000 Z
11
+ date: 2021-07-27 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
@@ -576,6 +576,7 @@ files:
576
576
  - samples/hello/hello_canvas_animation.rb
577
577
  - samples/hello/hello_canvas_animation_multi.rb
578
578
  - samples/hello/hello_canvas_data_binding.rb
579
+ - samples/hello/hello_canvas_drag_and_drop.rb
579
580
  - samples/hello/hello_canvas_path.rb
580
581
  - samples/hello/hello_canvas_shape_listeners.rb
581
582
  - samples/hello/hello_canvas_transform.rb