glimmer-dsl-swt 4.20.9.1 → 4.20.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e37d0806e8aaa9348e085cee3068003ab71eba9b55dcf9dc0a6dc19df8f9a351
4
- data.tar.gz: ffc3acfdc525c51c694d1461f28955b77b3f33869abfb6a9fc7b2c40624085c4
3
+ metadata.gz: 22a275c90700a95d9bb50a11500062bc752ae0993177af88f8c84afb150615e2
4
+ data.tar.gz: fa1470d45be2485bd2304eccfb8f93a0f45b841c81bc7891de65144fb6e7b8ac
5
5
  SHA512:
6
- metadata.gz: 85e233e9aca10e9674ef33ec09ab00ecbe04d122f9bc9e6bbbba24d48b187bf9f89eaa55bf8b4001eec37b4825995e2e8427f39ede64f76d51767ee1e60421a5
7
- data.tar.gz: d168d8a89386a65ee536e372eeb0f4b958e536db7d8ec0f6b280dc8249b268108997e037b107aa59c3fe1f59bb8003c9a7b5c557749a31c962eb2cbb97d90d42
6
+ metadata.gz: 72447b790c797f63c78ce456cfe638a74140294e3f710432465a773e63c97c5198ecec9c5d4a6cc6de36a8bfbb5ec743300c3ffdd2db2c638ab031bbf125d44d
7
+ data.tar.gz: 577412f2a8a2313f3fc61568ac4d435e6d7158725ff2199eaef5e935c165745a872971f4fb8d48d8d8d0ae3d1a3b19078d956f65e54da7b9c0dcd582c7d73a5a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.20.11.0
4
+
5
+ - Shape `#center_x`/`#center_y` methods to identify a shape's center point
6
+ - Shape `#rotate` method to rotate around center point
7
+
8
+ ### 4.20.10.2
9
+
10
+ - Fix issue "Resolve 'NameError: uninitialized constant Glimmer::DataBinding' on Windows" https://github.com/AndyObtiva/glimmer-dsl-swt/issues/9 (originally in https://github.com/AMaleh/glimmer-dsl-swt/pull/1)
11
+
12
+ ### 4.20.10.1
13
+
14
+ - Hello, Scale! sample.
15
+
16
+ ### 4.20.10.0
17
+
18
+ - Support noun alternatives for `Canvas Transform DSL` operations:
19
+ - `multiply(&block)` => `multiplication(&block)`
20
+ - `invert` => `inversion`
21
+ - `rotate(angle)` => `rotation(angle)`
22
+ - `translate(x, y)` => `translation(x, y)`
23
+
3
24
  ### 4.20.9.1
4
25
 
5
26
  - Fix issue with not being able to use :default x/y location with composite/custom shapes containing lines
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.9.1
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.11.0
2
2
  ## JRuby Desktop Development GUI Framework
3
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-swt.svg)](http://badge.fury.io/rb/glimmer-dsl-swt)
4
4
  [![Travis CI](https://travis-ci.com/AndyObtiva/glimmer-dsl-swt.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer-dsl-swt)
@@ -15,7 +15,7 @@
15
15
  [<img src="https://covers.oreillystatic.com/images/9780596519650/lrg.jpg" width=105 /><br />
16
16
  Featured in JRuby Cookbook](http://shop.oreilly.com/product/9780596519650.do) and [Chalmers/Gothenburg University Software Engineering Master's Lecture Material](http://www.cse.chalmers.se/~bergert/slides/guest_lecture_DSLs.pdf)
17
17
 
18
- [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.20.9.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).
18
+ [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.20.11.0 includes [SWT 4.20](https://download.eclipse.org/eclipse/downloads/drops4/R-4.20-202106111600/), which was released on June 11, 2021. Gem version numbers are in sync with the SWT library versions. The first two digits represent the SWT version number. The last two digits represent the minor and patch versions of Glimmer DSL for SWT. Note that SWT now supports AARCH64 on Mac and Linux, but it is not fully tested in Glimmer DSL for SWT yet, so deem its support experimental for the time being without guarantees for functionality until declared otherwise (report any issues you may encounter).
19
19
 
20
20
  **Starting in version 4.20.0.0, [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) comes with the new [***Shine***](/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#shine) syntax** for highly intuitive and visually expressive View/Model Attribute Mapping, relying on `<=>` for bidirectional (two-way) data-binding and `<=` for unidirectional (one-way) data-binding, providing an alternative to the `bind` keyword (keep in mind that it is still a beta, so default back to `bind` whenever needed).
21
21
 
@@ -347,7 +347,7 @@ jgem install glimmer-dsl-swt
347
347
 
348
348
  Or this command if you want a specific version:
349
349
  ```
350
- jgem install glimmer-dsl-swt -v 4.20.9.1
350
+ jgem install glimmer-dsl-swt -v 4.20.11.0
351
351
  ```
352
352
 
353
353
  `jgem` is JRuby's version of `gem` command.
@@ -375,7 +375,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
375
375
 
376
376
  Add the following to `Gemfile`:
377
377
  ```
378
- gem 'glimmer-dsl-swt', '~> 4.20.9.1'
378
+ gem 'glimmer-dsl-swt', '~> 4.20.11.0'
379
379
  ```
380
380
 
381
381
  And, then run:
@@ -396,7 +396,7 @@ glimmer
396
396
  ```
397
397
 
398
398
  ```
399
- Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.20.9.1
399
+ Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.20.11.0
400
400
 
401
401
  Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
402
402
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.20.9.1
1
+ 4.20.11.0
@@ -1901,6 +1901,8 @@ They are implemented with the help of the highly robust Java built-in shape geom
1901
1901
  - `Shape#contain?(x, y)` : indicates if shape contains x, y point
1902
1902
  - `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)
1903
1903
  - `Shape#move_by(x_delta, y_delta)` : moves shape object at x, y location
1904
+ - `Shape#rotate(angle)` : rotates around center by an angle (not cumulative, reseting angle on every call)
1905
+ - `Shape#rotatation_angle` : current rotation angle (according to use of rotate method)
1904
1906
  - `Shape#dispose` : disposes of shape, removing it form its parent canvas, widget, or shape
1905
1907
  - `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 {}`.
1906
1908
  - `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)
@@ -1921,6 +1923,10 @@ They are implemented with the help of the highly robust Java built-in shape geom
1921
1923
  - `Shape#default_y?` : calculated top-left corner y position
1922
1924
  - `Shape#calculated_x` : calculated top-left corner x position when default/delta is set (i.e. centered within parent)
1923
1925
  - `Shape#calculated_y` : calculated top-left corner y position when default/delta is set (i.e. centered within parent)
1926
+ - `Shape#center_x` : center x
1927
+ - `Shape#center_y` : center y
1928
+ - `Shape#x_end` : right-most included x coordinate
1929
+ - `Shape#y_end` : bottom-most included y coordinate
1924
1930
 
1925
1931
  Check [Hello, Canvas!](GLIMMER_SAMPLES.md#hello-canvas) for an example.
1926
1932
 
@@ -2165,12 +2171,12 @@ The first 2 values represent the 1st row, the second 2 values represent the 2nd
2165
2171
 
2166
2172
  Additionally, Transform operation keywords may be nested within the `transform` keyword to set its properties:
2167
2173
  - `identity` resets transform to identity (no transformation)
2168
- - `invert` inverts a transform
2169
- - `multiply(&block)` multiplies by another transform (takes a block representing properties of another transform, no need for using the word transform again)
2170
- - `rotate(angle)` rotates by angle degrees
2174
+ - `invert` (alias: `inversion`) inverts a transform
2175
+ - `multiply(&transform_properties_block)` (alias: `multiplication`) multiplies by another transform (takes a block representing properties of another transform, no need for using the word transform again)
2176
+ - `rotate(angle)` (alias: `rotation`) rotates by angle degrees
2171
2177
  - `scale(x, y)` scales a shape (stretch)
2172
2178
  - `shear(x, y)` shear effect
2173
- - `translate(x, y)` translate x and y coordinates (move)
2179
+ - `translate(x, y)` (alias: `translation`) translate x and y coordinates (move)
2174
2180
  - `elements(m11, m12, m21, m22, dx, dy)` resets all values of the transform matrix (first 2 values represent the 1st row, second 2 values represent the 2nd row, the last 2 values represent translation on x and y axes)
2175
2181
 
2176
2182
  Also, setting `transform` to `nil` after a previous `transform` has been set is like calling `identity`. It resets the transform.
@@ -32,6 +32,7 @@
32
32
  - [Hello, Directory Dialog!](#hello-directory-dialog)
33
33
  - [Hello, File Dialog!](#hello-file-dialog)
34
34
  - [Hello, Date Time!](#hello-date-time)
35
+ - [Hello, Scale!](#hello-scale)
35
36
  - [Hello, Spinner!](#hello-spinner)
36
37
  - [Hello, Table!](#hello-table)
37
38
  - [Hello, Link!](#hello-link)
@@ -593,6 +594,18 @@ Hello, Date Time!
593
594
 
594
595
  ![Hello Date Time](/images/glimmer-hello-date-time.png)
595
596
 
597
+ #### Hello, Scale!
598
+
599
+ This sample demonstrates the use of `scale` widget in Glimmer
600
+
601
+ Code:
602
+
603
+ [samples/hello/hello_scale.rb](/samples/hello/hello_scale.rb)
604
+
605
+ Hello, Scale!
606
+
607
+ ![Hello Scale](/images/glimmer-hello-scale.png)
608
+
596
609
  #### Hello, Spinner!
597
610
 
598
611
  This sample demonstrates the use of `spinner` widget in Glimmer
Binary file
@@ -31,7 +31,10 @@ module Glimmer
31
31
  include ParentExpression
32
32
 
33
33
  def can_interpret?(parent, keyword, *args, &block)
34
- keyword == 'multiply' and
34
+ (
35
+ keyword == 'multiply' or
36
+ keyword == 'multiplication'
37
+ ) and
35
38
  parent.is_a?(Glimmer::SWT::TransformProxy)
36
39
  end
37
40
 
@@ -19,6 +19,7 @@
19
19
  # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
+ require 'glimmer/data_binding/observable_model'
22
23
  require 'glimmer/swt/properties'
23
24
  require 'glimmer/swt/custom/shape'
24
25
  require 'bigdecimal'
@@ -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/ui/custom_widget'
2
23
 
3
24
  module Glimmer
@@ -240,6 +240,45 @@ module Glimmer
240
240
  end
241
241
  end
242
242
 
243
+ # rotates shape for an angle around its center
244
+ # this operation is not cumulative (it resets angle every time)
245
+ # consumers may inspect corresponding rotation_angle attribute to know which angle the shape is currently at for convenience
246
+ # this overrides any pre-existing transforms that are applied to shape
247
+ def rotate(angle)
248
+ half_width = calculated_width/2.0
249
+ half_height = calculated_height/2.0
250
+ self.transform = Glimmer::SWT::TransformProxy.new(self).translate(half_width, half_height).rotate(angle).translate(-1.0*half_width, -1.0*half_height)
251
+ @rotation_angle = angle
252
+ end
253
+
254
+ # returns rotation angle
255
+ # consumers may inspect rotation_angle attribute to know which angle the shape is rotated at via rotate method
256
+ # it is not guaranteed to give the right result if a transform is applied outside of rotate method.
257
+ # starts at 0
258
+ def rotation_angle
259
+ @rotation_angle.to_f
260
+ end
261
+
262
+ def center_x
263
+ center_x_dependencies = [x_end, calculated_width]
264
+ if center_x_dependencies != @center_x_dependencies
265
+ @center_x_dependencies = center_x_dependencies
266
+ the_x_end, the_calculated_width = center_x_dependencies
267
+ @center_x = the_x_end - the_calculated_width/2.0
268
+ end
269
+ @center_x
270
+ end
271
+
272
+ def center_y
273
+ center_y_dependencies = [y_end, calculated_height]
274
+ if center_y_dependencies != @center_y_dependencies
275
+ @center_y_dependencies = center_y_dependencies
276
+ the_y_end, the_calculated_height = center_y_dependencies
277
+ @center_y = the_y_end - the_calculated_height/2.0
278
+ end
279
+ @center_y
280
+ end
281
+
243
282
  def content(&block)
244
283
  Glimmer::SWT::DisplayProxy.instance.auto_exec do
245
284
  Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::SWT::ShapeExpression.new, @name, &block)
@@ -936,7 +975,7 @@ module Glimmer
936
975
  @x_end
937
976
  end
938
977
 
939
- # right-most y coordinate in this shape (adding up its height and location)
978
+ # bottom-most y coordinate in this shape (adding up its height and location)
940
979
  def y_end
941
980
  y_end_dependencies = [calculated_height, default_y?, !default_y? && y]
942
981
  if y_end_dependencies != @y_end_dependencies
@@ -25,6 +25,7 @@ require 'glimmer/swt/display_proxy'
25
25
  require 'glimmer/swt/color_proxy'
26
26
  require 'glimmer/swt/font_proxy'
27
27
  require 'glimmer/swt/transform_proxy'
28
+ require 'glimmer/swt/image_proxy'
28
29
 
29
30
  module Glimmer
30
31
  module SWT
@@ -69,11 +70,15 @@ module Glimmer
69
70
  end
70
71
 
71
72
  def width
72
- dest_width || image.bounds.width
73
+ dest_width || image_proxy.bounds.width
73
74
  end
74
75
 
75
76
  def height
76
- dest_height || image.bounds.height
77
+ dest_height || image_proxy.bounds.height
78
+ end
79
+
80
+ def image_proxy
81
+ ImageProxy.create(image)
77
82
  end
78
83
 
79
84
  def default_x?
@@ -34,6 +34,12 @@ module Glimmer
34
34
  include_package 'org.eclipse.swt.graphics'
35
35
  include_package 'org.eclipse.swt.widgets'
36
36
 
37
+ ATTRIBUTE_ALIASES = {
38
+ 'rotation' => 'rotate',
39
+ 'translation' => 'translate',
40
+ 'inversion' => 'invert',
41
+ }
42
+
37
43
  attr_reader :swt_transform, :parent
38
44
 
39
45
  def initialize(parent, *args, swt_transform: nil, multiply: false)
@@ -81,10 +87,11 @@ module Glimmer
81
87
  end
82
88
 
83
89
  def has_attribute?(attribute_name, *args)
84
- Glimmer::SWT::DisplayProxy.instance.auto_exec { @swt_transform.respond_to?(attribute_name) } || super
90
+ ATTRIBUTE_ALIASES.keys.include?(attribute_name.to_s) || Glimmer::SWT::DisplayProxy.instance.auto_exec { @swt_transform.respond_to?(attribute_name) } || super
85
91
  end
86
92
 
87
93
  def set_attribute(attribute_name, *args)
94
+ attribute_name = ATTRIBUTE_ALIASES[attribute_name.to_s] || attribute_name
88
95
  if @swt_transform.respond_to?(attribute_name)
89
96
  Glimmer::SWT::DisplayProxy.instance.auto_exec { @swt_transform.send(attribute_name, *args) }
90
97
  else
@@ -92,6 +99,11 @@ module Glimmer
92
99
  end
93
100
  end
94
101
 
102
+ def get_attribute(attribute_name)
103
+ attribute_name = ATTRIBUTE_ALIASES[attribute_name.to_s] || attribute_name
104
+ super(attribute_name)
105
+ end
106
+
95
107
  def method_missing(method_name, *args, &block)
96
108
  result = Glimmer::SWT::DisplayProxy.instance.auto_exec { @swt_transform.send(method_name, *args, &block) }
97
109
  result.nil? ? self : result
@@ -13,28 +13,29 @@ shell {
13
13
 
14
14
  image(glimmer_logo, 0, 0) {
15
15
  transform {
16
- translate 110, 110
17
- rotate 90
16
+ translation 110, 110
17
+ rotation 90
18
18
  scale 0.21, 0.21
19
+ # also supports inversion, identity, shear, and multiplication {transform properties}
19
20
  }
20
21
  }
21
22
  image(glimmer_logo, 0, 0) {
22
23
  transform {
23
- translate 110, 220
24
+ translation 110, 220
24
25
  scale 0.21, 0.21
25
26
  }
26
27
  }
27
28
  image(glimmer_logo, 0, 0) {
28
29
  transform {
29
- translate 220, 220
30
- rotate 270
30
+ translation 220, 220
31
+ rotation 270
31
32
  scale 0.21, 0.21
32
33
  }
33
34
  }
34
35
  image(glimmer_logo, 0, 0) {
35
36
  transform {
36
- translate 220, 110
37
- rotate 180
37
+ translation 220, 110
38
+ rotation 180
38
39
  scale 0.21, 0.21
39
40
  }
40
41
  }
@@ -0,0 +1,57 @@
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-dsl-swt'
23
+
24
+ class HelloScale
25
+ include Glimmer::UI::CustomShell
26
+
27
+ attr_accessor :value
28
+
29
+ before_body {
30
+ @value = 50
31
+ }
32
+
33
+ body {
34
+ shell {
35
+ row_layout(:vertical) {
36
+ fill true
37
+ center true
38
+ }
39
+
40
+ text 'Hello, Scale!'
41
+
42
+ label(:center) {
43
+ text <= [self, :value]
44
+ }
45
+
46
+ scale { # optionally takes :vertical or :horizontal (default) SWT style
47
+ minimum 0
48
+ maximum 100
49
+ selection <=> [self, :value]
50
+ }
51
+
52
+ }
53
+
54
+ }
55
+ end
56
+
57
+ HelloScale.launch
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.9.1
4
+ version: 4.20.11.0
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-21 00:00:00.000000000 Z
11
+ date: 2021-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -610,6 +610,7 @@ files:
610
610
  - samples/hello/hello_radio.rb
611
611
  - samples/hello/hello_radio_group.rb
612
612
  - samples/hello/hello_sash_form.rb
613
+ - samples/hello/hello_scale.rb
613
614
  - samples/hello/hello_shape.rb
614
615
  - samples/hello/hello_shell.rb
615
616
  - samples/hello/hello_spinner.rb