glimmer-dsl-swt 4.18.6.2 → 4.18.6.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: 6d4f89641fcc2573b43cd52e23cf4dda45aa209e55cd49cbe751f6a4b7bc85b1
4
- data.tar.gz: 9cf53e2b5aef11f838314b50188f63b3a69936ea31f54930da77bddfd561b08e
3
+ metadata.gz: 9db83aea9f51b0f0f2b7dfcb78a5180f00a5c7e7ebe7852f404c879c6417fa66
4
+ data.tar.gz: af21fa66dff5e22c878fe564dcdeb34c6d83a9b8afd8eb66e1c827c047a8d28c
5
5
  SHA512:
6
- metadata.gz: 355fe3aab4e45648832678ce3a2c00411129be61bbff91575f4c19b73254a82ab9fa58ce6acbac78d6dca4daf383340cd074e6ec5ea6128bcdb37df94befe125
7
- data.tar.gz: d30171ae846dc373fb4d58426bcdc64a179579c4f86ee749d16cb0a5f3440bc542305a91a1e0d5774b796e14750a1918ae4e8d3bb33b2eaff70da4fd3a7afff1
6
+ metadata.gz: 80c988832fe70bf8505aca306b88d34e35957e8a8a936c9ef874ad35566c71e98e766cd7b732dd73bf2e3c088a52d1480fabe20f77fc557fcc47c9f4ead8d817
7
+ data.tar.gz: 2b2a8f85e7ee15dc23f772a92c4ca4f9acad738ee22efc2a36dd45aab73e6f18e2e4f24b1efe1f7f68fa558ce7b2dc42f3a92c427c2c5074dab9a09c5979c0ec
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.18.6.3
4
+
5
+ - Support `Glimmer::SWT::Custom::Shape::PathSegment#dispose` method
6
+ - Amend Hello, Canvas Path! sample with ability to regenerate paths
7
+ - Make `tab_folder` preinit all its tabs by default while supporting the SWT style of `:initialize_tabs_on_select` to init tabs on first select instead.
8
+ - Support trimming line style symbols (no need to say line_ before each style. e.g. `:line_solid` becomes `:solid`) in Canvas Shape DSL line_style property
9
+ - Support `antialias true` as an alternative to `antialias :on`, `antialias false` as an alternative to `antialias :off`, and `antialias nil` as an alternative to `antialias :default`
10
+
3
11
  ### 4.18.6.2
4
12
 
5
13
  - Hello, Canvas Data Binding! Sample
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.6.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.18.6.3
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)
@@ -13,7 +13,7 @@
13
13
  [<img src="https://covers.oreillystatic.com/images/9780596519650/lrg.jpg" width=105 /><br />
14
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)
15
15
 
16
- [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.18.6.2 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.
16
+ [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.18.6.3 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
17
 
18
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
19
 
@@ -340,7 +340,7 @@ jgem install glimmer-dsl-swt
340
340
 
341
341
  Or this command if you want a specific version:
342
342
  ```
343
- jgem install glimmer-dsl-swt -v 4.18.6.2
343
+ jgem install glimmer-dsl-swt -v 4.18.6.3
344
344
  ```
345
345
 
346
346
  `jgem` is JRuby's version of `gem` command.
@@ -358,7 +358,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
358
358
 
359
359
  Add the following to `Gemfile`:
360
360
  ```
361
- gem 'glimmer-dsl-swt', '~> 4.18.6.2'
361
+ gem 'glimmer-dsl-swt', '~> 4.18.6.3'
362
362
  ```
363
363
 
364
364
  And, then run:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.18.6.2
1
+ 4.18.6.3
@@ -410,6 +410,14 @@ Example (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
410
410
  @shell.open
411
411
  ```
412
412
 
413
+ ##### Tab Folder API
414
+
415
+ Unlike basic SWT usage, `tab_folder` has the smart default of pre-initializing all tabs so that they are properly sized/filled so no delays occur when a user browses through them for the first time by selecting unselected tabs.
416
+
417
+ The [Stock Ticker](/docs/reference/GLIMMER_SAMPLES.md#stock-ticker) sample takes advantage of this to ensure all tabs are pre-initialized and filled with rendered data even before the user selects any of them.
418
+
419
+ That said, `tab_folder` can optionally receive a custom Glimmer SWT style named `:initialize_tabs_on_select`, which disables that behavior by going back to SWT's default of initializing tabs upon first selection (e.g. upon clicking with the mouse).
420
+
413
421
  ##### Shell Icon
414
422
 
415
423
  To set the shell icon, simply set the `image` property under the `shell` widget. This shows up in the operating system toolbar and app-switcher (e.g. CMD+TAB) (and application window top-left corner in Windows)
@@ -1415,7 +1423,7 @@ Optionally, a shape keyword takes a block that can set any attributes from [org.
1415
1423
  Here is a list of supported attributes nestable within a block under shapes:
1416
1424
  - `advanced` enables advanced graphics subsystem (boolean value). Typically gets enabled automatically when setting alpha, antialias, patterns, interpolation, clipping. Rendering sometimes differs between advanced and non-advanced mode for basic graphics too, so you could enable manually if you prefer its look even for basic graphics.
1417
1425
  - `alpha` sets transparency (integer between `0` and `255`)
1418
- - `antialias` enables antialiasing (SWT style value of `:default`, `:off`, `:on` whereby `:default` applies OS default, which varies per OS)
1426
+ - `antialias` enables antialiasing (SWT style value of `:default` (or nil), `:off` (or false), `:on` (or true) whereby `:default` applies OS default, which varies per OS)
1419
1427
  - `background` sets fill color for fillable shapes (standard color symbol (e.g. `:red`), `rgb(red_integer, green_integer, blue_integer)` color, or Color/ColorProxy object directly)
1420
1428
  - `background_pattern` sets fill gradient/image pattern for fillable shape background (takes the same arguments as the SWT [Pattern](https://help.eclipse.org/2020-12/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/graphics/Pattern.html) class [e.g. `background_pattern 2.3, 4.2, 5.4, 7.2, :red, :blue`] / note: this feature isn't extensively tested yet)
1421
1429
  - `clipping` clips area of painting (numeric values for `(x, y, width, height)`)
@@ -1427,7 +1435,7 @@ Here is a list of supported attributes nestable within a block under shapes:
1427
1435
  - `line_cap` sets line cap (SWT style value of `:cap_flat`, `:cap_round`, or `:cap_square`)
1428
1436
  - `line_dash` line dash float values (automatically sets `line_style` to SWT style value of `:line_custom`)
1429
1437
  - `line_join` line join style (SWT style value of `:join_miter`, `:join_round`, or `:join_bevel`)
1430
- - `line_style` line join style (SWT style value of `:line_solid`, `:line_dash`, `:line_dot`, `:line_dashdot`, or `:line_dashdotdot`)
1438
+ - `line_style` line join style (SWT style value of `:solid`, `:dash`, `:dot`, `:dashdot`, `:dashdotdot`, or `:custom` while requiring `line_dash` attribute (or alternatively with `line_` prefix as per official SWT docs like `:line_solid` for `:solid`)
1431
1439
  - `line_width` line width in integer (used in draw operations)
1432
1440
  - `text_anti_alias` enables text antialiasing (SWT style value of `:default`, `:off`, `:on` whereby `:default` applies OS default, which varies per OS)
1433
1441
  - `transform` sets transform object using [Canvas Transform DSL](#canvas-transform-dsl) syntax
@@ -1476,7 +1484,7 @@ Screenshot:
1476
1484
 
1477
1485
  If you specify the x and y coordinates as `:default`, `nil`, or leave them out, they get calculated automatically by centering the shape within its parent `canvas`.
1478
1486
 
1479
- Note that you could shift a shape off its centered position within its parent `canvas` by using `x_delta` and `y_delta` instead of `x` and `y`
1487
+ Note that you could shift a shape off its centered position within its parent `canvas` by setting `x` to `[:default, x_delta]` and `y` to `[:default, y_delta]`
1480
1488
 
1481
1489
  The round and gradient options could be dropped since Glimmer DSL for SWT supports auto-inference of them based on shape parameters.
1482
1490
 
@@ -1633,9 +1641,11 @@ Shapes can be nested within each other. If you nest a shape within another, its
1633
1641
 
1634
1642
  As such, if you move the parent, it moves all its children with it.
1635
1643
 
1636
- If you specify the x and y coordinates as `:default`, `nil`, or leave them out, they get calculated automatically by centering the shape within its parent shape relatively.
1644
+ If you specify the `x` and `y` coordinates as `:default`, `nil`, or leave them out, they get calculated automatically by centering the shape within its parent shape relatively.
1637
1645
 
1638
- Note that you could shift a shape off its centered position within its parent shape by using `x_delta` and `y_delta` instead of `x` and `y`
1646
+ If you specify the `width` and `height` parameters as `:default`, `nil`, or leave them out, they get calculated automatically from the shape's nested children shapes (e.g calculating the dimensions of a text from its extent according to its font size).
1647
+
1648
+ Note that you could shift a shape off its centered position within its parent shape by setting `x` to `[:default, x_delta]` and `y` to `[:default, y_delta]`
1639
1649
 
1640
1650
  Check [Hello, Canvas!](GLIMMER_SAMPLES.md#hello-canvas) for an example that nests lines, points, a polyline, and an image within a drawn rectangle parent:
1641
1651
 
@@ -1767,8 +1777,24 @@ They are implemented with the help of the highly robust Java built-in shape geom
1767
1777
  - `Shape#contain?(x, y)` : indicates if shape contains x, y point
1768
1778
  - `Shape#include?(x, y)` : indicates if shape includes x, y point on the edge if drawn or inside if filled (include uses contain for filled shapes)
1769
1779
  - `Shape#move_by(x_delta, y_delta)` : moves shape object at x, y location
1780
+ - `Shape#dispose` : disposes of shape, removing it form its parent canvas, widget, or shape
1781
+ - `Shape#content {}` : reopens a shape to add more content inside it using the Glimmer GUI DSL (e.g. Canvas Shape DSL) just like `WidgetProxy#content {}`.
1770
1782
  - `Shape#size` : calculated size for shape bounding box (e.g. a polygon with an irregular shape will have its bounding box width and height calculated)
1771
1783
  - `Shape#bounds` : calculated bounds (x, y, width, height) for shape bounding box (e.g. a polygon with an irregular shape will have its bounding box top-left x, y, width and height calculated)
1784
+ - `Shape#width` : static (including `:default`) or derived width for shape (including irregular geometric shapes like Polygon)
1785
+ - `Shape#height` : static (including `:default`) or derived height for shape (including irregular geometric shapes like Polygon)
1786
+ - `Shape#default_width?` : whether `:default` or `[:default, delta]` is set for static width
1787
+ - `Shape#default_height?` : whether `:default` or `[:default, delta]` is set for static height
1788
+ - `Shape#calculated_width` : calculated width for shape when set to :default to indicate it is sized by its children (e.g. in the case of containing text with a specific font size not knowing its width/height dimensions in advance)
1789
+ - `Shape#calculated_height` : calculated height for shape when set to :default to indicate it is sized by its children (e.g. in the case of containing text with a specific font size not knowing its width/height dimensions in advance)
1790
+ - `Shape#x` : top-left corner x position, static or `:default` (could be relative if shape is nested within another shape)
1791
+ - `Shape#y` : top-left corner y position, static or `:default` (could be relative if shape is nested within another shape)
1792
+ - `Shape#absolute_x` : absolute top-left corner x position
1793
+ - `Shape#absolute_y` : absolute top-left corner y position
1794
+ - `Shape#default_x?` : whether x is specified via `:default` style to indicate centering within parent (or `[:default, offset]`)
1795
+ - `Shape#default_y?` : calculated top-left corner y position
1796
+ - `Shape#calculated_x` : calculated top-left corner x position when default/delta is set (i.e. centered within parent)
1797
+ - `Shape#calculated_y` : calculated top-left corner y position when default/delta is set (i.e. centered within parent)
1772
1798
 
1773
1799
  Check [Hello, Canvas!](GLIMMER_SAMPLES.md#hello-canvas) for an example.
1774
1800
 
@@ -1991,6 +2017,15 @@ Learn more at the [Hello, Canvas Path!](GLIMMER_SAMPLES.md#hello-canvas-path) an
1991
2017
 
1992
2018
  ![Stock Ticker](/images/glimmer-stock-ticker.gif)
1993
2019
 
2020
+ #### Canvas Path API
2021
+
2022
+ Every path segment object (mixing in [`Glimmer::SWT::Custom::PathSegment`](/lib/glimmer/swt/custom/shape/path_segment.rb) like `path`, `point`, `line`, `quad`, and `cubic`) has the following API methods:
2023
+ - `#path`: indicates which path the segment is part of.
2024
+ - `#path_root`: indicates the root path the segment is part of.
2025
+ - `#dispose`: disposes a path segment from its path
2026
+ - `#content {}` : reopens a path to add more segments inside it using the Glimmer GUI DSL (e.g. Canvas Path DSL) just like `WidgetProxy#content {}`.
2027
+ - `#first_path_segment?`: indicates if the path segment is the first in the path
2028
+
1994
2029
  ### Canvas Transform DSL
1995
2030
 
1996
2031
  **(ALPHA FEATURE)**
@@ -34,6 +34,7 @@
34
34
  - [Hello, Canvas Animation!](#hello-canvas-animation)
35
35
  - [Hello, Canvas Transform!](#hello-canvas-transform)
36
36
  - [Hello, Canvas Path!](#hello-canvas-path)
37
+ - [Hello, Canvas Data Binding!](#hello-canvas-data-binding)
37
38
  - [Hello, Cursor!](#hello-cursor)
38
39
  - [Hello, Progress Bar!](#hello-progress-bar)
39
40
  - [Hello, Tree!](#hello-tree)
@@ -630,6 +631,20 @@ Hello, Canvas Path!
630
631
 
631
632
  ![Hello Canvas Path](/images/glimmer-hello-canvas-path.png)
632
633
 
634
+ #### Hello, Canvas Data Binding!
635
+
636
+ This sample demonstrates Canvas Shape DSL data-binding.
637
+
638
+ Code:
639
+
640
+ [samples/hello/hello_canvas_data_binding.rb](/samples/hello/hello_canvas_data_binding.rb)
641
+
642
+ Hello, Canvas Data Binding!
643
+
644
+ ![Hello Canvas Data Binding](/images/glimmer-hello-canvas-data-binding.png)
645
+
646
+ ![Hello Canvas Data Binding Line Changed](/images/glimmer-hello-canvas-data-binding-line-changed.png)
647
+
633
648
  #### Hello, Cursor!
634
649
 
635
650
  This sample demonstrates the use of the `cursor` property keyword to change the mouse cursor.
@@ -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.6.2 ruby lib
5
+ # stub: glimmer-dsl-swt 4.18.6.3 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "glimmer-dsl-swt".freeze
9
- s.version = "4.18.6.2"
9
+ s.version = "4.18.6.3"
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-03-02"
14
+ s.date = "2021-03-03"
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]
@@ -148,6 +148,7 @@ Gem::Specification.new do |s|
148
148
  "lib/glimmer/swt/style_constantizable.rb",
149
149
  "lib/glimmer/swt/styled_text_proxy.rb",
150
150
  "lib/glimmer/swt/swt_proxy.rb",
151
+ "lib/glimmer/swt/tab_folder_proxy.rb",
151
152
  "lib/glimmer/swt/tab_item_proxy.rb",
152
153
  "lib/glimmer/swt/table_column_proxy.rb",
153
154
  "lib/glimmer/swt/table_proxy.rb",
@@ -69,3 +69,4 @@ require 'glimmer/swt/table_column_proxy'
69
69
  require 'glimmer/swt/sash_form_proxy'
70
70
  require 'glimmer/swt/styled_text_proxy'
71
71
  require 'glimmer/swt/date_time_proxy'
72
+ require 'glimmer/swt/tab_folder_proxy'
@@ -262,10 +262,23 @@ module Glimmer
262
262
  args[0] = args.dup
263
263
  args[1..-1] = []
264
264
  end
265
+ if method_name.to_s == 'setAntialias' && [nil, true, false].include?(args.first)
266
+ args[0] = case args.first
267
+ when true
268
+ args[0] = :on
269
+ when false
270
+ args[0] = :off
271
+ when nil
272
+ args[0] = :default
273
+ end
274
+ end
265
275
  if args.first.is_a?(Symbol) || args.first.is_a?(::String)
266
276
  if the_java_method.parameter_types.first == org.eclipse.swt.graphics.Color.java_class
267
277
  args[0] = ColorProxy.new(args[0])
268
278
  end
279
+ if method_name.to_s == 'setLineStyle'
280
+ args[0] = "line_#{args[0]}" if !args[0].to_s.downcase.start_with?('line_')
281
+ end
269
282
  if the_java_method.parameter_types.first == Java::int.java_class
270
283
  args[0] = SWTProxy.constant(args[0])
271
284
  end
@@ -503,7 +516,7 @@ module Glimmer
503
516
  pattern_args(type: 'foreground')
504
517
  end
505
518
 
506
- def dispose(dispose_images: true, dispose_patterns: true)
519
+ def dispose(dispose_images: true, dispose_patterns: true, redraw: true)
507
520
  shapes.each { |shape| shape.is_a?(Shape::Path) && shape.dispose }
508
521
  if dispose_patterns
509
522
  @background_pattern&.dispose
@@ -516,6 +529,7 @@ module Glimmer
516
529
  @image = nil
517
530
  end
518
531
  @parent.shapes.delete(self)
532
+ drawable.redraw if redraw && !drawable.is_a?(ImageProxy)
519
533
  end
520
534
 
521
535
  def paint(paint_event)
@@ -553,7 +567,7 @@ module Glimmer
553
567
  end
554
568
  @painting = false
555
569
  rescue => e
556
- Glimmer::Config.logger.error {"Error encountered in painting shape (#{self.inspect}) with calculated args (#{@calculated_args}) and args (#{@args})"}
570
+ Glimmer::Config.logger.error {"Error encountered in painting shape (#{self.inspect}) with method (#{@method_name}) calculated args (#{@calculated_args}) and args (#{@args})"}
557
571
  Glimmer::Config.logger.error {e.full_message}
558
572
  ensure
559
573
  @painting = false
@@ -52,8 +52,10 @@ module Glimmer
52
52
 
53
53
  def add_shape(shape)
54
54
  if shape.is_a?(PathSegment)
55
- @path_segments << shape
56
- @uncalculated_path_segments << shape
55
+ Glimmer::SWT::DisplayProxy.instance.auto_exec do
56
+ @path_segments << shape
57
+ @uncalculated_path_segments << shape
58
+ end
57
59
  else
58
60
  super
59
61
  end
@@ -80,27 +82,34 @@ module Glimmer
80
82
  end
81
83
 
82
84
  def post_dispose_content(path_segment)
83
- @path_segments.delete(path_segment)
84
- @uncalculated_path_segments = @path_segments.dup
85
- @swt_path&.dispose
86
- @swt_path = nil
87
- @args = []
88
- calculated_args_changed!(children: false)
85
+ Glimmer::SWT::DisplayProxy.instance.auto_exec do
86
+ @path_segments.delete(path_segment)
87
+ @uncalculated_path_segments = @path_segments.dup
88
+ @swt_path&.dispose
89
+ @swt_path = nil
90
+ @args = []
91
+ calculated_args_changed!(children: false)
92
+ end
89
93
  end
90
94
 
91
95
  def clear
92
- @path_segments.each { |path_segments| path_segments.class == Path && path_segments.dispose }
93
- @path_segments.clear
94
- @uncalculated_path_segments = @path_segments.dup
95
- @swt_path&.dispose
96
- @swt_path = nil
97
- @args = []
98
- calculated_args_changed!(children: false)
96
+ Glimmer::SWT::DisplayProxy.instance.auto_exec do
97
+ @path_segments.each { |path_segments| path_segments.class == Path && path_segments.dispose }
98
+ @path_segments.clear
99
+ @uncalculated_path_segments = @path_segments.dup
100
+ @swt_path&.dispose
101
+ @swt_path = nil
102
+ @args = []
103
+ calculated_args_changed!(children: false)
104
+ drawable.redraw unless drawable.is_a?(ImageProxy)
105
+ end
99
106
  end
100
107
 
101
- def dispose
102
- clear if self.class == Path
103
- super if parent.is_a?(Drawable)
108
+ def dispose(redraw: true)
109
+ Glimmer::SWT::DisplayProxy.instance.auto_exec do
110
+ clear if self.class == Path
111
+ super(redraw: redraw) if (parent.is_a?(Shape) && (!parent.is_a?(PathSegment) || !parent.part_of_path?)) || parent.is_a?(Drawable)
112
+ end
104
113
  end
105
114
 
106
115
  def calculated_args_changed!(children: true)
@@ -110,15 +119,19 @@ module Glimmer
110
119
  def calculated_args
111
120
  new_swt_path = @swt_path.nil? || !@calculated_paint_args || !@calculated_path_args
112
121
  if new_swt_path
113
- @swt_path&.dispose
114
- @swt_path = org.eclipse.swt.graphics.Path.new(Glimmer::SWT::DisplayProxy.instance.swt_display)
115
- @uncalculated_path_segments = @path_segments.dup
122
+ Glimmer::SWT::DisplayProxy.instance.auto_exec do
123
+ @swt_path&.dispose
124
+ @swt_path = org.eclipse.swt.graphics.Path.new(Glimmer::SWT::DisplayProxy.instance.swt_display)
125
+ @uncalculated_path_segments = @path_segments.dup
126
+ end
116
127
  end
117
128
  # TODO recreate @swt_path only if one of the children get disposed (must notify parent on dispose)
118
129
  @args = [@swt_path]
119
- @uncalculated_path_segments.each do |path_segment|
120
- path_segment.add_to_swt_path(@swt_path)
121
- @uncalculated_path_segments.delete(path_segment)
130
+ @uncalculated_path_segments.dup.each do |path_segment|
131
+ Glimmer::SWT::DisplayProxy.instance.auto_exec do
132
+ path_segment.add_to_swt_path(@swt_path)
133
+ @uncalculated_path_segments.delete(path_segment)
134
+ end
122
135
  end
123
136
  @calculated_path_args = true
124
137
  if new_swt_path
@@ -24,8 +24,6 @@ require 'glimmer/swt/custom/shape'
24
24
  module Glimmer
25
25
  module SWT
26
26
  module Custom
27
- # Represents a path to be drawn on a control/widget/canvas/display
28
- # That is because Shape is drawn on a parent as graphics and doesn't have an SWT widget for itself
29
27
  class Shape
30
28
  # Represents path segments like point, line, quad, and cubic curves
31
29
  # Shapes could mix in
@@ -77,10 +75,17 @@ module Glimmer
77
75
  true
78
76
  end
79
77
 
80
- def dispose
81
- parent.post_dispose_content(self) if parent.is_a?(Path)
82
- super if !part_of_path?
83
- drawable.redraw unless drawable.is_a?(ImageProxy)
78
+ def dispose(redraw: true)
79
+ Glimmer::SWT::DisplayProxy.instance.auto_exec do
80
+ # including classes could override to dispose of resources first
81
+ # afterwards, parent removes from its path segments with post_dispose_content
82
+ parent.post_dispose_content(self) if parent.is_a?(Path)
83
+ if part_of_path?
84
+ drawable.redraw if redraw && !drawable.is_a?(ImageProxy)
85
+ else
86
+ super(redraw: redraw)
87
+ end
88
+ end
84
89
  end
85
90
 
86
91
  def first_path_segment?
@@ -92,22 +97,19 @@ module Glimmer
92
97
  end
93
98
 
94
99
  def add_to_swt_path(swt_path)
95
- if @swt_path != swt_path
96
- @swt_path = swt_path
97
- the_path_segment_args = path_segment_args.dup
98
- if !is_a?(Point) && self.class != Path
99
- if !previous_point_connected?
100
- if the_path_segment_args.count == default_path_segment_arg_count
101
- point = the_path_segment_args.shift, the_path_segment_args.shift
102
- @swt_path.moveTo(*point)
103
- elsif first_path_segment?
104
- point = the_path_segment_args[0..1]
105
- @swt_path.moveTo(*point)
106
- end
100
+ the_path_segment_args = path_segment_args.dup
101
+ if !is_a?(Point) && self.class != Path
102
+ if !previous_point_connected?
103
+ if the_path_segment_args.count == default_path_segment_arg_count
104
+ point = the_path_segment_args.shift, the_path_segment_args.shift
105
+ swt_path.moveTo(*point)
106
+ elsif first_path_segment?
107
+ point = the_path_segment_args[0..1]
108
+ swt_path.moveTo(*point)
107
109
  end
108
110
  end
109
- @swt_path.send(path_segment_method_name, *the_path_segment_args)
110
111
  end
112
+ swt_path.send(path_segment_method_name, *the_path_segment_args)
111
113
  end
112
114
 
113
115
  def add_to_geometry(geometry)
@@ -0,0 +1,52 @@
1
+ # Copyright (c) 2007-2021 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require 'glimmer/swt/widget_proxy'
23
+
24
+ module Glimmer
25
+ module SWT
26
+ # Proxy for org.eclipse.swt.widgets.TabProxy
27
+ #
28
+ # Follows the Proxy Design Pattern
29
+ class TabFolderProxy < WidgetProxy
30
+ def initialize(underscored_widget_name, parent, args, swt_widget: nil)
31
+ @initialize_tabs_on_select = args.delete(:initialize_tabs_on_select)
32
+ super
33
+ end
34
+
35
+ def post_add_content
36
+ shown = false
37
+ unless @initialize_tabs_on_select
38
+ @show_listener = parent_proxy.on_swt_show do
39
+ unless shown
40
+ shown = true
41
+ self.items.to_a.each do |item|
42
+ self.selection = item
43
+ end
44
+ self.selection = self.items.first unless self.items.first.nil?
45
+ @show_listener.deregister
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -146,7 +146,6 @@ class StockTicker
146
146
  text 'Stock Ticker'
147
147
  minimum_size 650, 650
148
148
  background :white
149
-
150
149
  @tab_folder = tab_folder {
151
150
  @tabs.each do |tab|
152
151
  tab_item {
@@ -202,11 +201,6 @@ class StockTicker
202
201
  on_swt_show {
203
202
  Stock.price_min = 25
204
203
  Stock.price_max = @tabs.first[:canvas].bounds.height - 6
205
- # pre-initialize all tabs by selecting them so that they render content when they are later in the background
206
- @tab_folder.items.each do |item|
207
- @tab_folder.selection = item
208
- end
209
- @tab_folder.selection = @tab_folder.items.first
210
204
  }
211
205
 
212
206
  on_widget_disposed {
@@ -1,3 +1,24 @@
1
+ # Copyright (c) 2007-2021 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
1
22
  require 'glimmer-dsl-swt'
2
23
 
3
24
  class HelloCanvasDataBinding
@@ -13,7 +34,7 @@ class HelloCanvasDataBinding
13
34
  end
14
35
 
15
36
  def line_style_value_options
16
- [:line_solid, :line_dash, :line_dot, :line_dashdot, :line_dashdotdot]
37
+ [:solid, :dash, :dot, :dashdot, :dashdotdot]
17
38
  end
18
39
 
19
40
  before_body {
@@ -25,7 +46,7 @@ class HelloCanvasDataBinding
25
46
  self.foreground_green = 128
26
47
  self.foreground_blue = 228
27
48
  self.line_width_value = 3
28
- self.line_style_value = :line_dot
49
+ self.line_style_value = :dot
29
50
  }
30
51
 
31
52
  body {
@@ -81,7 +81,7 @@ shell {
81
81
  @path2.clear
82
82
  @path3.clear
83
83
  y1 = y2 = y3 = 300
84
- 730.times.each do |x|
84
+ 700.times.each do |x|
85
85
  x += 55
86
86
  x1 = x - 2
87
87
  x2 = x - 1
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.6.2
4
+ version: 4.18.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-02 00:00:00.000000000 Z
11
+ date: 2021-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -467,6 +467,7 @@ files:
467
467
  - lib/glimmer/swt/style_constantizable.rb
468
468
  - lib/glimmer/swt/styled_text_proxy.rb
469
469
  - lib/glimmer/swt/swt_proxy.rb
470
+ - lib/glimmer/swt/tab_folder_proxy.rb
470
471
  - lib/glimmer/swt/tab_item_proxy.rb
471
472
  - lib/glimmer/swt/table_column_proxy.rb
472
473
  - lib/glimmer/swt/table_proxy.rb