glimmer-dsl-opal 0.28.1 → 0.28.2

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: 4fe3d0b1328a0e5a9f0ea452608d31a75c0fe5d1d24f1a988a8474ab89b415b9
4
- data.tar.gz: b575cc548458f30e64ddd5e29d3fc85673382306c16a125a9f4620d9f477fde4
3
+ metadata.gz: 87981d1ce51eda46029d81945b4a0135e0b08a54d9b935504ab015d789d0b417
4
+ data.tar.gz: 0db15d4faaff573e66074299725c052814f3d291cff145f8c871ee95f1b5bfc2
5
5
  SHA512:
6
- metadata.gz: ebb320d8c8a58c55a424a1eb44ddee3d041d99a69610c5932caa9bc03ad891b48a7f03206d9112195bcd901611ed6ebbf08b2dee88eb7fc4ef8f7dfb2280c16e
7
- data.tar.gz: 4221da20509698c503f374b4fd127ea732e4b86280c246c617c2d2a750982840a3523a72eb76da53caeb5eb580c06937de7706d4dde631ffd5ee59d22da14a45
6
+ metadata.gz: 441432dc7b68d4163d9a08b0e8df43580692fa84ff1091ee6f6f6e71abf9199a96038a2df17d017d9fed4016457d5254b7667f71d7f4880fc63dd12f23f4918c
7
+ data.tar.gz: edee0a32bfcc5f41a756a837fe904d63039160c446578c4a843190285bd7edb9d99aec946e69c2b956d8ef3cdfd2ee06221061d217aac789c502a7f37c87fd8f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.28.2
4
+
5
+ - Support `image` Canvas Shape DSL keyword
6
+ - Use `image` in Hello, Canvas! sample
7
+
3
8
  ## 0.28.1
4
9
 
5
10
  - Support `arc` Canvas Shape DSL keyword (partial support whereby width is assumed to be equal to height to start from a circle basis)
data/README.md CHANGED
@@ -145,7 +145,7 @@ Hello, Table! Game Booked
145
145
 
146
146
  NOTE: Glimmer DSL for Opal is an alpha project. Please help make better by contributing, adopting for small or low risk projects, and providing feedback. It is still an early alpha, so the more feedback and issues you report the better.
147
147
 
148
- **Alpha Version** 0.28.1 only supports bare-minimum capabilities for the included [samples](https://github.com/AndyObtiva/glimmer-dsl-opal#samples) (originally written for [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt))
148
+ **Alpha Version** 0.28.2 only supports bare-minimum capabilities for the included [samples](https://github.com/AndyObtiva/glimmer-dsl-opal#samples) (originally written for [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt))
149
149
 
150
150
  Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
151
151
  - [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)
@@ -271,7 +271,7 @@ gem 'opal', '1.0.5'
271
271
  gem 'opal-rails', '1.1.2'
272
272
  gem 'opal-async', '~> 1.4.0'
273
273
  gem 'opal-jquery', '~> 0.4.4'
274
- gem 'glimmer-dsl-opal', '~> 0.28.1'
274
+ gem 'glimmer-dsl-opal', '~> 0.28.2'
275
275
  gem 'glimmer-dsl-xml', '~> 1.2.0', require: false
276
276
  gem 'glimmer-dsl-css', '~> 1.2.0', require: false
277
277
 
@@ -1463,7 +1463,7 @@ You should see "Hello, Group!"
1463
1463
 
1464
1464
  This is a minimal initial version of the [Hello, Canvas! sample included in Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/docs/reference/GLIMMER_SAMPLES.md#hello-canvas).
1465
1465
 
1466
- It supports all shapes except `arc` and `image`, with no shape nesting, data-binding, or gradient support yet.
1466
+ It [supports](#supported-glimmer-dsl-keywords) all shapes, but with no shape nesting, data-binding, or gradient support yet.
1467
1467
 
1468
1468
  Add the following require statement to `app/assets/javascripts/application.rb`
1469
1469
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.28.1
1
+ 0.28.2
@@ -31,6 +31,7 @@ require 'glimmer/dsl/opal/dialog_expression'
31
31
  require 'glimmer/dsl/opal/shape_expression'
32
32
  require 'glimmer/dsl/opal/shine_data_binding_expression'
33
33
  require 'glimmer/dsl/opal/shape_expression'
34
+ require 'glimmer/dsl/opal/image_expression'
34
35
 
35
36
  module Glimmer
36
37
  module DSL
@@ -47,6 +48,7 @@ module Glimmer
47
48
  checkbox_group_selection_data_binding
48
49
  data_binding
49
50
  font
51
+ image
50
52
  layout
51
53
  block_property
52
54
  property
@@ -0,0 +1,67 @@
1
+ # Copyright (c) 2020-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/expression'
23
+ require 'glimmer/dsl/top_level_expression'
24
+ require 'glimmer/dsl/parent_expression'
25
+ require 'glimmer/swt/image_proxy'
26
+
27
+ module Glimmer
28
+ module DSL
29
+ module Opal
30
+ # image expression
31
+ # Note: Cannot be a static expression because it clashes with image property expression
32
+ class ImageExpression < Expression
33
+ include TopLevelExpression
34
+ include ParentExpression
35
+
36
+ def can_interpret?(parent, keyword, *args, &block)
37
+ options = args.last.is_a?(Hash) ? args.last : {}
38
+ (
39
+ (keyword == 'image') and
40
+ (
41
+ options.keys.include?(:top_level) or
42
+ (
43
+ !parent.is_a?(Glimmer::SWT::Custom::Shape) &&
44
+ !parent.is_a?(Glimmer::SWT::CanvasProxy)
45
+ ) or
46
+ (
47
+ args.size < 3
48
+ )
49
+ )
50
+ )
51
+ end
52
+
53
+ def interpret(parent, keyword, *args, &block)
54
+ # options = args.last.is_a?(Hash) ? args.last : {}
55
+ # args.unshift(parent) unless parent.nil? || options[:top_level]
56
+ Glimmer::SWT::ImageProxy.create(*args, &block)
57
+ end
58
+
59
+ def add_content(parent, keyword, *args, &block)
60
+ return if @create_pixel_by_pixel || block&.parameters&.count == 2
61
+ super
62
+ parent.post_add_content
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -32,7 +32,7 @@ module Glimmer
32
32
 
33
33
  def can_interpret?(parent, keyword, *args, &block)
34
34
  (parent.is_a?(Glimmer::SWT::WidgetProxy) or parent.is_a?(Glimmer::SWT::Custom::Shape)) and
35
- Glimmer::SWT::Custom::Shape.valid?(parent, keyword, args, &block) &&
35
+ Glimmer::SWT::Custom::Shape.valid?(parent, keyword, args, &block) and
36
36
  (keyword != 'text' || args.size >= 3)
37
37
  end
38
38
 
@@ -0,0 +1,54 @@
1
+ # Copyright (c) 2020-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/custom/shape'
23
+ require 'glimmer/swt/swt_proxy'
24
+ require 'glimmer/swt/display_proxy'
25
+ require 'glimmer/swt/color_proxy'
26
+ require 'glimmer/swt/image_proxy'
27
+ # require 'glimmer/swt/transform_proxy'
28
+
29
+ module Glimmer
30
+ module SWT
31
+ module Custom
32
+ class Shape
33
+ class Image < Shape
34
+
35
+ def element
36
+ 'image'
37
+ end
38
+
39
+ def dom
40
+ shape_id = id
41
+ shape_class = name
42
+ href = @args[0].is_a?(Glimmer::SWT::ImageProxy) ? @args[0].file_path : @args[0]
43
+ width = @args[0].is_a?(Glimmer::SWT::ImageProxy) ? @args[0].width : nil
44
+ height = @args[0].is_a?(Glimmer::SWT::ImageProxy) ? @args[0].height : nil
45
+ @dom ||= xml {
46
+ image(id: shape_id, class: shape_class, href: href, x: @args[1], y: @args[2], width: width, height: height)
47
+ }.to_s
48
+ end
49
+
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -101,6 +101,7 @@ module Glimmer
101
101
  end
102
102
 
103
103
  require 'glimmer/swt/custom/shape/arc'
104
+ require 'glimmer/swt/custom/shape/image'
104
105
  require 'glimmer/swt/custom/shape/line'
105
106
  require 'glimmer/swt/custom/shape/oval'
106
107
  require 'glimmer/swt/custom/shape/point'
@@ -0,0 +1,29 @@
1
+ module Glimmer
2
+ module SWT
3
+ # emulating org.eclipse.swt.graphics.Image
4
+ class ImageProxy
5
+ class << self
6
+ def create(*args, &content)
7
+ if args.size == 1 && args.first.is_a?(ImageProxy)
8
+ args.first
9
+ else
10
+ new(*args, &content)
11
+ end
12
+ end
13
+ end
14
+
15
+ attr_reader :file_path, :width, :height
16
+
17
+ def initialize(*args)
18
+ options = args.last.is_a?(Hash) ? args.last : {}
19
+ # TODO support a parent as a first argument before the file path
20
+ @file_path = args.first
21
+ @width = options[:width]
22
+ @height = options[:height]
23
+ end
24
+
25
+ # TODO implement scale_to
26
+ end
27
+ # TODO alias as org.eclipse.swt.graphics.Image
28
+ end
29
+ end
@@ -22,6 +22,10 @@
22
22
  class HelloCanvas
23
23
  include Glimmer::UI::CustomShell
24
24
 
25
+ before_body do
26
+ @image_object = image(File.expand_path('./images/scaffold_app.png', __dir__), width: 50)
27
+ end
28
+
25
29
  body {
26
30
  shell {
27
31
  text 'Hello, Canvas!'
@@ -61,6 +65,7 @@ class HelloCanvas
61
65
  foreground :dark_magenta
62
66
  font name: 'Courier', height: 30
63
67
  }
68
+ image(@image_object, 205, 55)
64
69
  polygon(250, 210, 260, 170, 270, 210, 290, 230) {
65
70
  background :dark_yellow
66
71
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-opal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.28.1
4
+ version: 0.28.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
@@ -339,6 +339,7 @@ files:
339
339
  - lib/glimmer-dsl-opal/samples/hello/images/mexico.png
340
340
  - lib/glimmer-dsl-opal/samples/hello/images/netherlands.png
341
341
  - lib/glimmer-dsl-opal/samples/hello/images/norway.png
342
+ - lib/glimmer-dsl-opal/samples/hello/images/scaffold_app.png
342
343
  - lib/glimmer-dsl-opal/samples/hello/images/usa.png
343
344
  - lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/GPL-LICENSE.txt
344
345
  - lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/MIT-LICENSE.txt
@@ -380,6 +381,7 @@ files:
380
381
  - lib/glimmer/dsl/opal/dsl.rb
381
382
  - lib/glimmer/dsl/opal/exec_expression.rb
382
383
  - lib/glimmer/dsl/opal/font_expression.rb
384
+ - lib/glimmer/dsl/opal/image_expression.rb
383
385
  - lib/glimmer/dsl/opal/layout_data_expression.rb
384
386
  - lib/glimmer/dsl/opal/layout_expression.rb
385
387
  - lib/glimmer/dsl/opal/list_selection_data_binding_expression.rb
@@ -419,6 +421,7 @@ files:
419
421
  - lib/glimmer/swt/custom/radio_group.rb
420
422
  - lib/glimmer/swt/custom/shape.rb
421
423
  - lib/glimmer/swt/custom/shape/arc.rb
424
+ - lib/glimmer/swt/custom/shape/image.rb
422
425
  - lib/glimmer/swt/custom/shape/line.rb
423
426
  - lib/glimmer/swt/custom/shape/oval.rb
424
427
  - lib/glimmer/swt/custom/shape/point.rb
@@ -434,6 +437,7 @@ files:
434
437
  - lib/glimmer/swt/font_proxy.rb
435
438
  - lib/glimmer/swt/grid_layout_proxy.rb
436
439
  - lib/glimmer/swt/group_proxy.rb
440
+ - lib/glimmer/swt/image_proxy.rb
437
441
  - lib/glimmer/swt/label_proxy.rb
438
442
  - lib/glimmer/swt/latest_dialog_proxy.rb
439
443
  - lib/glimmer/swt/latest_message_box_proxy.rb