glimmer-dsl-swt 4.18.5.4 → 4.18.5.5

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: 495c8eacce66f3b425a8f1603eea5051f5b776f0cb8e8550419382079c58e85e
4
- data.tar.gz: 7e922de5ff80a2e85facee8a36444fe70bd6a9e25a65416aeebec4bfabd10749
3
+ metadata.gz: 8fb342869be74c6e592466ad89d26798dde5cf8f3d6beb52b5bcf6a6e8f221f6
4
+ data.tar.gz: c75442b7c5aeac5d77878d52e969669ea677877c12a43c97081155c5412c9c4c
5
5
  SHA512:
6
- metadata.gz: 5ace8433246247b3210cced98a70bb45cfdc978808b632ad322b5c995a7b0e868fc7df9c6ed23293fd5845e50257696617ad9a85ad9e7a0f0b697aea55901cfc
7
- data.tar.gz: 58c632f794d07225737d101b68300db72c41b90778320765971e29539242d48260512db44c77ed99fb1aa9307056d24364a5bb57e400b3a0aab49c41ac8babb4
6
+ metadata.gz: d3e484674be4fa02ea232e1452a80c4fbb2f141bee407ef6ce922dd0f1e3616f6ee420fc57fdd3d9af6c9d993a88705d95e62d9a5573273e63638a5876bf53d9
7
+ data.tar.gz: 6a76ebd41db15abe32ae22b2c675199595e196251b03a84ddad99a3aa2b254b43b8e50e339579764de667e10e3673814fb4ab3886aa9f27a9f8c43a7ca16bdcd
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.18.5.5
4
+
5
+ - Automatically recalculate default size (width/height) to accomodate nested shapes when changing x/y/width/height sticking out of parent from right or bottom.
6
+ - Support special case of centering a nested shape with default x/y within a parent with default width/height calculated from nested shape
7
+ - Consider Canvas Shape DSL support for LineAttributes `line_dash_offset` and `line_miter_limit`
8
+ - Canvas Shape DSL Polygon `include?` does an outer/inner check of edge detection only
9
+ - Ensure all Canvas Shape DSL properties are restored upon painting a shape to what they were prior to painting that shape
10
+ - Fix issue with bringing high score dialog up in Tetris caused by latest dialog changes for supporting the new `color_dialog` and `font_dialog`
11
+
3
12
  ### 4.18.5.4
4
13
 
5
14
  - Support passing width, height as :default (or nil or not passed in if they are the last args) in all shapes that include other shapes to indicate they are calculated automatically from nested shapes, text/string extent, or otherwise defaulting to 0, 0
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.18.5.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.18.5.5
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)
@@ -10,15 +10,13 @@
10
10
 
11
11
  [Glimmer](https://github.com/AndyObtiva/glimmer) DSL for SWT is a native-GUI cross-platform desktop development library written in [JRuby](https://www.jruby.org/), an OS-threaded faster JVM version of [Ruby](https://www.ruby-lang.org/en/). [Glimmer](https://github.com/AndyObtiva/glimmer)'s main innovation is a declarative [Ruby DSL](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#glimmer-dsl-syntax) that enables productive and efficient authoring of desktop application user-interfaces by relying on the robust [Eclipse SWT library](https://www.eclipse.org/swt/). [Glimmer](https://rubygems.org/gems/glimmer) additionally innovates by having built-in [data-binding](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#data-binding) support, which greatly facilitates synchronizing the GUI with domain models, thus achieving true decoupling of object oriented components and enabling developers to solve business problems (test-first) without worrying about GUI concerns, or alternatively drive development GUI-first, and then write clean business models (test-first) afterwards. Not only does Glimmer provide a large set of GUI [widgets](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#widgets), but it also supports drawing Canvas Graphics like [Shapes](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#canvas-shape-dsl) and [Animations](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#canvas-animation-dsl). To get started quickly, [Glimmer](https://rubygems.org/gems/glimmer) offers [scaffolding](docs/reference/GLIMMER_COMMAND.md#scaffolding) options for [Apps](#in-production), [Gems](docs/reference/GLIMMER_COMMAND.md#custom-shell-gem), and [Custom Widgets](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#custom-widgets). [Glimmer](https://rubygems.org/gems/glimmer) also includes native-executable [packaging](docs/reference/GLIMMER_PACKAGING_AND_DISTRIBUTION.md) support, sorely lacking in other libraries, thus enabling the delivery of desktop apps written in [Ruby](https://www.ruby-lang.org/en/) as truly native DMG/PKG/APP files on the [Mac](https://www.apple.com/ca/macos) + [App Store](https://developer.apple.com/macos/distribution/), MSI/EXE files on [Windows](https://www.microsoft.com/en-ca/windows), and [Gem Packaged Shell Scripts](docs/reference/GLIMMER_COMMAND.md#packaging) on [Linux](https://www.linux.org/).
12
12
 
13
- [Glimmer receives two updates per month](https://rubygems.org/gems/glimmer-dsl-swt/versions). You can trust [Glimmer](https://rubygems.org/gems/glimmer) with your Ruby desktop GUI development needs. Please make [Glimmer](https://rubygems.org/gems/glimmer) even better by providing feedback and [contributing](#contributing) when possible.
14
-
15
- 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.
16
-
17
- [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) versions 4.18.x.y come with [SWT 4.18](https://download.eclipse.org/eclipse/downloads/drops4/R-4.18-202012021800/), which was released on December 2, 2020.
18
-
19
13
  [<img src="https://covers.oreillystatic.com/images/9780596519650/lrg.jpg" width=105 /><br />
20
14
  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)
21
15
 
16
+ [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.18.5.5 includes [SWT 4.18](https://download.eclipse.org/eclipse/downloads/drops4/R-4.18-202012021800/), which was released on December 2, 2020. 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.
17
+
18
+ [Glimmer DSL for SWT receives two updates per month](https://rubygems.org/gems/glimmer-dsl-swt/versions). You can trust [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) with your Ruby desktop GUI development needs! [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) brings great ideas to the table, such as declarative programming via domain specific languages, currently under-utilized in the GUI domain. That said, it may not be feature complete enough for everybody's needs, so please help make [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) even better by providing feedback and [contributing](#contributing) when possible. The project is very active, so any feature suggestions that are accepted could be implemented within weeks if not days. Also, you are welcome to [hire me](#hire-me) full-time if you want long-term development of [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) for your project needs.
19
+
22
20
  Glimmer DSL gems:
23
21
  - [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)
24
22
  - [glimmer-dsl-opal](https://github.com/AndyObtiva/glimmer-dsl-opal): Glimmer DSL for Opal (Pure Ruby Web GUI and Auto-Webifier of Desktop Apps)
@@ -342,7 +340,7 @@ jgem install glimmer-dsl-swt
342
340
 
343
341
  Or this command if you want a specific version:
344
342
  ```
345
- jgem install glimmer-dsl-swt -v 4.18.5.4
343
+ jgem install glimmer-dsl-swt -v 4.18.5.5
346
344
  ```
347
345
 
348
346
  `jgem` is JRuby's version of `gem` command.
@@ -360,7 +358,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
360
358
 
361
359
  Add the following to `Gemfile`:
362
360
  ```
363
- gem 'glimmer-dsl-swt', '~> 4.18.5.4'
361
+ gem 'glimmer-dsl-swt', '~> 4.18.5.5'
364
362
  ```
365
363
 
366
364
  And, then run:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.18.5.4
1
+ 4.18.5.5
@@ -564,6 +564,10 @@ Hello, Canvas!
564
564
 
565
565
  ![Hello Canvas](/images/glimmer-hello-canvas.png)
566
566
 
567
+ Hello, Canvas! Moving Shapes and Nested Shapes via Drag'n'Drop
568
+
569
+ ![Hello Canvas Moving Shapes](/images/glimmer-hello-canvas-moving-shapes.gif)
570
+
567
571
  Hello, Canvas! with Moved Shapes (via Drag'n'Drop)
568
572
 
569
573
  ![Hello Canvas Moved Shapes](/images/glimmer-hello-canvas-moved-shapes.png)
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: glimmer-dsl-swt 4.18.5.4 ruby lib
5
+ # stub: glimmer-dsl-swt 4.18.5.5 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "glimmer-dsl-swt".freeze
9
- s.version = "4.18.5.4"
9
+ s.version = "4.18.5.5"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["AndyMaleh".freeze]
14
- s.date = "2021-02-26"
14
+ s.date = "2021-02-27"
15
15
  s.description = "Glimmer DSL for SWT (JRuby Desktop Development GUI Framework) is a native-GUI cross-platform desktop development library written in JRuby, an OS-threaded faster JVM version of Ruby. Glimmer's main innovation is a declarative Ruby DSL that enables productive and efficient authoring of desktop application user-interfaces by relying on the robust Eclipse SWT library. Glimmer additionally innovates by having built-in data-binding support, which greatly facilitates synchronizing the GUI with domain models, thus achieving true decoupling of object oriented components and enabling developers to solve business problems (test-first) without worrying about GUI concerns, or alternatively drive development GUI-first, and then write clean business models (test-first) afterwards. Not only does Glimmer provide a large set of GUI widgets, but it also supports drawing Canvas Graphics like Shapes and Animations. To get started quickly, Glimmer offers scaffolding options for Apps, Gems, and Custom Widgets. Glimmer also includes native-executable packaging support, sorely lacking in other libraries, thus enabling the delivery of desktop apps written in Ruby as truly native DMG/PKG/APP files on the Mac + App Store, MSI/EXE files on Windows, and Gem Packaged Shell Scripts on Linux.".freeze
16
16
  s.email = "andy.am@gmail.com".freeze
17
17
  s.executables = ["glimmer".freeze, "girb".freeze]
@@ -26,6 +26,34 @@ require 'glimmer/swt/color_proxy'
26
26
  require 'glimmer/swt/font_proxy'
27
27
  require 'glimmer/swt/transform_proxy'
28
28
 
29
+ class Java::OrgEclipseSwtGraphics::GC
30
+ def setLineDashOffset(value)
31
+ lineMiterLimit = getLineAttributes&.miterLimit || 999_999
32
+ setLineAttributes(Java::OrgEclipseSwtGraphics::LineAttributes.new(getLineWidth, getLineCap, getLineJoin, getLineStyle, getLineDash.map(&:to_f).to_java(:float), value, lineMiterLimit))
33
+ end
34
+ alias set_line_dash_offset setLineDashOffset
35
+ alias line_dash_offset= setLineDashOffset
36
+
37
+ def getLineDashOffset
38
+ getLineAttributes&.dashOffset
39
+ end
40
+ alias get_line_dash_offset getLineDashOffset
41
+ alias line_dash_offset getLineDashOffset
42
+
43
+ def setLineMiterLimit(value)
44
+ lineDashOffset = getLineAttributes&.dashOffset || 0
45
+ setLineAttributes(Java::OrgEclipseSwtGraphics::LineAttributes.new(getLineWidth, getLineCap, getLineJoin, getLineStyle, getLineDash.map(&:to_f).to_java(:float), lineDashOffset, value))
46
+ end
47
+ alias set_line_miter_limit setLineMiterLimit
48
+ alias line_miter_limit= setLineMiterLimit
49
+
50
+ def getLineMiterLimit
51
+ getLineAttributes&.miterLimit
52
+ end
53
+ alias get_line_miter_limit getLineMiterLimit
54
+ alias line_miter_limit getLineMiterLimit
55
+ end
56
+
29
57
  module Glimmer
30
58
  module SWT
31
59
  module Custom
@@ -119,7 +147,7 @@ module Glimmer
119
147
 
120
148
  def add_shape(shape)
121
149
  @shapes << shape
122
- calculated_args_changed_for_default_size!
150
+ calculated_args_changed_for_defaults!
123
151
  end
124
152
 
125
153
  def draw?
@@ -145,6 +173,11 @@ module Glimmer
145
173
  org.eclipse.swt.graphics.Rectangle.new(absolute_x, absolute_y, calculated_width, calculated_height)
146
174
  end
147
175
 
176
+ # The bounding box top-left x and y
177
+ def location
178
+ org.eclipse.swt.graphics.Point.new(bounds.x, bounds.y)
179
+ end
180
+
148
181
  # The bounding box width and height (as a Point object with x being width and y being height)
149
182
  def size
150
183
  org.eclipse.swt.graphics.Point.new(calculated_width, calculated_height)
@@ -169,6 +202,11 @@ module Glimmer
169
202
  # assume a rectangular shape by default
170
203
  contain?(x, y)
171
204
  end
205
+
206
+ # Indicates if a shape's x, y, width, height differ from its bounds calculation (e.g. arc / polygon)
207
+ def irregular?
208
+ false
209
+ end
172
210
 
173
211
  # moves by x delta and y delta. Subclasses must implement
174
212
  # provdies a default implementation that assumes moving x and y is sufficient by default (not for polygons though, which must override)
@@ -206,12 +244,17 @@ module Glimmer
206
244
  def apply_property_arg_conversions(method_name, property, args)
207
245
  args = args.dup
208
246
  the_java_method = org.eclipse.swt.graphics.GC.java_class.declared_instance_methods.detect {|m| m.name == method_name}
247
+ return args if the_java_method.nil?
209
248
  if the_java_method.parameter_types.first == Color.java_class && args.first.is_a?(RGB)
210
249
  args[0] = [args[0].red, args[0].green, args[0].blue]
211
250
  end
212
251
  if ['setBackground', 'setForeground'].include?(method_name.to_s) && args.first.is_a?(Array)
213
252
  args[0] = ColorProxy.new(args[0])
214
253
  end
254
+ if method_name.to_s == 'setLineDash' && args.size > 1
255
+ args[0] = args.dup
256
+ args[1..-1] = []
257
+ end
215
258
  if args.first.is_a?(Symbol) || args.first.is_a?(::String)
216
259
  if the_java_method.parameter_types.first == Color.java_class
217
260
  args[0] = ColorProxy.new(args[0])
@@ -383,9 +426,12 @@ module Glimmer
383
426
  if @content_added && perform_redraw && !drawable.is_disposed
384
427
  @calculated_paint_args = false
385
428
  attribute_name = ruby_attribute_getter(attribute_name)
386
- @calculated_args = nil if location_parameter_names.map(&:to_s).include?(attribute_name)
429
+ if location_parameter_names.map(&:to_s).include?(attribute_name)
430
+ @calculated_args = nil
431
+ parent.calculated_args_changed_for_defaults! if parent.is_a?(Shape)
432
+ end
387
433
  if ['width', 'height'].include?(attribute_name)
388
- calculated_args_changed_for_default_size!
434
+ calculated_args_changed_for_defaults!
389
435
  end
390
436
  # TODO consider redrawing an image proxy's gc in the future
391
437
  drawable.redraw unless drawable.is_a?(ImageProxy)
@@ -457,10 +503,12 @@ module Glimmer
457
503
  end
458
504
  @parent.shapes.delete(self)
459
505
  end
460
-
506
+
461
507
  def paint(paint_event)
508
+ # pre-paint children an extra-time first when default width/height need to be calculated for defaults
462
509
  paint_children(paint_event) if default_width? || default_height?
463
510
  paint_self(paint_event)
511
+ # re-paint children from scratch in the special case of pre-calculating parent width/height to re-center within new parent dimensions
464
512
  shapes.each(&:calculated_args_changed!) if default_width? || default_height?
465
513
  paint_children(paint_event)
466
514
  rescue => e
@@ -471,9 +519,10 @@ module Glimmer
471
519
  def paint_self(paint_event)
472
520
  @painting = true
473
521
  calculate_paint_args!
522
+ @original_properties_backup = {}
474
523
  @properties.each do |property, args|
475
524
  method_name = attribute_setter(property)
476
- # TODO consider optimization of not setting a background/foreground/font if it didn't change from last shape
525
+ @original_properties_backup[method_name] = paint_event.gc.send(method_name.sub('set', 'get')) rescue nil
477
526
  paint_event.gc.send(method_name, *args)
478
527
  if property == 'transform' && args.first.is_a?(TransformProxy)
479
528
  args.first.swt_transform.dispose
@@ -485,6 +534,9 @@ module Glimmer
485
534
  end
486
535
  # paint unless parent's calculated args are not calculated yet, meaning it is about to get painted and trigger a paint on this child anyways
487
536
  paint_event.gc.send(@method_name, *@calculated_args) unless parent.is_a?(Shape) && !parent.calculated_args?
537
+ @original_properties_backup.each do |method_name, value|
538
+ paint_event.gc.send(method_name, value)
539
+ end
488
540
  @painting = false
489
541
  rescue => e
490
542
  Glimmer::Config.logger.error {"Error encountered in painting shape (#{self.inspect}) with calculated args (#{@calculated_args}) and args (#{@args})"}
@@ -509,7 +561,8 @@ module Glimmer
509
561
  self.extent = paint_event.gc.send("#{@name}Extent", *extent_args)
510
562
  end
511
563
  if !@extent.nil? && (old_extent&.x != @extent&.x || old_extent&.y != @extent&.y)
512
- parent.calculated_args_changed_for_default_size! if parent.is_a?(Shape)
564
+ calculated_args_changed!
565
+ parent.calculated_args_changed_for_defaults! if parent.is_a?(Shape)
513
566
  end
514
567
  end
515
568
 
@@ -527,16 +580,18 @@ module Glimmer
527
580
  (parent.is_a?(Shape) && (parent.absolute_x != @parent_absolute_x || parent.absolute_y != @parent_absolute_y))
528
581
  end
529
582
 
530
- def calculated_args_changed!
583
+ def calculated_args_changed!(children: true)
531
584
  # TODO add a children: true option to enable setting to false to avoid recalculating children args
532
585
  @calculated_args = nil
533
- shapes.each(&:calculated_args_changed!)
586
+ shapes.each(&:calculated_args_changed!) if children
534
587
  end
535
588
 
536
- def calculated_args_changed_for_default_size!
537
- @calculated_args = nil if default_width? || default_height?
538
- if parent.is_a?(Shape)
539
- parent.calculated_args_changed_for_default_size!
589
+ def calculated_args_changed_for_defaults!
590
+ has_default_dimensions = default_width? || default_height?
591
+ parent_calculated_args_changed_for_defaults = has_default_dimensions
592
+ @calculated_args = nil if default_x? || default_y? || has_default_dimensions
593
+ if has_default_dimensions && parent.is_a?(Shape)
594
+ parent.calculated_args_changed_for_defaults!
540
595
  elsif @content_added && !drawable.is_disposed
541
596
  # TODO consider optimizing in the future if needed by ensuring one redraw for all parents in the hierarchy at the end instead of doing one per parent that needs it
542
597
  drawable.redraw if !@painting && !drawable.is_a?(ImageProxy)
@@ -559,6 +614,10 @@ module Glimmer
559
614
  original_y = nil
560
615
  original_width = nil
561
616
  original_height = nil
617
+ if parent.is_a?(Shape)
618
+ @parent_absolute_x = parent.absolute_x
619
+ @parent_absolute_y = parent.absolute_y
620
+ end
562
621
  if default_width?
563
622
  original_width = width
564
623
  self.width = default_width + default_width_delta
@@ -576,11 +635,9 @@ module Glimmer
576
635
  self.y = default_y + default_y_delta
577
636
  end
578
637
  if parent.is_a?(Shape)
579
- @parent_absolute_x = parent.absolute_x
580
- @parent_absolute_y = parent.absolute_y
581
- move_by(parent.absolute_x, parent.absolute_y)
638
+ move_by(@parent_absolute_x, @parent_absolute_y)
582
639
  result_args = @args.clone
583
- move_by(-1*parent.absolute_x, -1*parent.absolute_y)
640
+ move_by(-1*@parent_absolute_x, -1*@parent_absolute_y)
584
641
  else
585
642
  result_args = @args.clone
586
643
  end
@@ -624,44 +681,42 @@ module Glimmer
624
681
 
625
682
  def default_x
626
683
  result = ((parent.size.x - size.x) / 2)
627
- result += parent.bounds.x - parent.absolute_x if parent.is_a?(Shape)
684
+ result += parent.bounds.x - parent.absolute_x if parent.is_a?(Shape) && parent.irregular?
628
685
  result
629
686
  end
630
687
 
631
688
  def default_y
632
689
  result = ((parent.size.y - size.y) / 2)
633
- result += parent.bounds.y - parent.absolute_y if parent.is_a?(Shape)
690
+ result += parent.bounds.y - parent.absolute_y if parent.is_a?(Shape) && parent.irregular?
634
691
  result
635
692
  end
636
693
 
637
694
  def default_width
638
- x_start_end_pairs = shapes.map do |shape|
639
- shape_x = shape.default_x? ? 0 : shape.x.to_f
695
+ # TODO consider caching
696
+ x_ends = shapes.map do |shape|
640
697
  shape_width = shape.calculated_width.to_f
641
- [shape_x, shape_x + shape_width]
698
+ shape_x = shape.default_x? ? 0 : shape.x.to_f
699
+ shape_x + shape_width
642
700
  end
643
- min_x = x_start_end_pairs.map(&:first).min.to_f
644
- max_x = x_start_end_pairs.map(&:last).max.to_f
645
- max_x - min_x
701
+ x_ends.max.to_f
646
702
  end
647
703
 
648
704
  def default_height
649
- y_start_end_pairs = shapes.map do |shape|
650
- shape_y = shape.default_y? ? 0 : shape.y.to_f
705
+ # TODO consider caching
706
+ y_ends = shapes.map do |shape|
651
707
  shape_height = shape.calculated_height.to_f
652
- [shape_y, shape_y + shape_height]
708
+ shape_y = shape.default_y? ? 0 : shape.y.to_f
709
+ shape_y + shape_height
653
710
  end
654
- min_y = y_start_end_pairs.map(&:first).min.to_f
655
- max_y = y_start_end_pairs.map(&:last).max.to_f
656
- max_y - min_y
711
+ y_ends.max.to_f
657
712
  end
658
713
 
659
714
  def calculated_width
660
- default_width? ? default_width : width
715
+ default_width? ? (default_width + default_width_delta) : width
661
716
  end
662
717
 
663
718
  def calculated_height
664
- default_height? ? default_height : height
719
+ default_height? ? (default_height + default_height_delta) : height
665
720
  end
666
721
 
667
722
  def default_x_delta
@@ -66,6 +66,11 @@ module Glimmer
66
66
  outer_shape_geometry.contains(x, y) && !inner_shape_geometry.contains(x, y)
67
67
  end
68
68
  end
69
+
70
+ def irregular?
71
+ true
72
+ end
73
+
69
74
  end
70
75
  end
71
76
  end
@@ -130,6 +130,11 @@ module Glimmer
130
130
  self.x2 += x_delta
131
131
  self.y2 += y_delta
132
132
  end
133
+
134
+ def irregular?
135
+ true
136
+ end
137
+
133
138
  end
134
139
  end
135
140
  end
@@ -139,14 +139,23 @@ module Glimmer
139
139
  bounds.height
140
140
  end
141
141
 
142
- def include?(x, y)
142
+ def contain?(x, y)
143
143
  geometry.contains(x, y)
144
144
  end
145
- alias contain? include? # TODO make include do an outer/inner check of edge detection only
146
-
145
+
146
+ def include?(x, y)
147
+ comparison_lines = absolute_point_xy_array.zip(absolute_point_xy_array.rotate(1))
148
+ comparison_lines.any? {|line| Line.include?(line.first.first, line.first.last, line.last.first, line.last.last, x, y)}
149
+ end
150
+
147
151
  def move_by(x_delta, y_delta)
148
152
  self.point_array = point_array.each_with_index.map {|coordinate, i| i.even? ? coordinate + x_delta : coordinate + y_delta}
149
153
  end
154
+
155
+ def irregular?
156
+ true
157
+ end
158
+
150
159
  end
151
160
  end
152
161
  end
@@ -134,6 +134,11 @@ module Glimmer
134
134
  def move_by(x_delta, y_delta)
135
135
  self.point_array = point_array.each_with_index.map {|coordinate, i| i.even? ? coordinate + x_delta : coordinate + y_delta}
136
136
  end
137
+
138
+ def irregular?
139
+ true
140
+ end
141
+
137
142
  end
138
143
  end
139
144
  end
@@ -52,6 +52,10 @@ module Glimmer
52
52
  def dialog_class(keyword)
53
53
  the_class = eval(keyword.camelcase(:upper))
54
54
  the_class if the_class.ancestors.include?(org.eclipse.swt.widgets.Dialog)
55
+ rescue => e
56
+ Glimmer::Config.logger.debug {"Dialog for keyword #{keyword} not found!"}
57
+ Glimmer::Config.logger.debug { e.full_message }
58
+ nil
55
59
  end
56
60
  end
57
61
 
@@ -56,9 +56,9 @@ class HelloCanvas
56
56
  rectangle([:default, -70], :default, :default, [:default, 1]) {
57
57
  foreground :cyan
58
58
  text {
59
- x :default, 1
60
- # y is assumed to be the default (centered within parent)
61
59
  string bind(self, :artist)
60
+ x :default, 1 # add 1 pixel to default x (shape centered within parent horizontally)
61
+ y :default, 1 # add 1 pixel to default y (shape centered within parent vertically)
62
62
  background :yellow
63
63
  foreground :dark_magenta
64
64
  font name: 'Courier', height: 30
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.18.5.4
4
+ version: 4.18.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-26 00:00:00.000000000 Z
11
+ date: 2021-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement