glimmer-dsl-opal 0.26.3 → 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: cabde097ac994643d49e0af9b78fc1bbc7b2eb15857deb8741c557f4e676a4da
4
- data.tar.gz: a198b93dc21bc2ea93e8542a84bbb83919be9ad0d63355f27dcf1fe4991b682c
3
+ metadata.gz: 87981d1ce51eda46029d81945b4a0135e0b08a54d9b935504ab015d789d0b417
4
+ data.tar.gz: 0db15d4faaff573e66074299725c052814f3d291cff145f8c871ee95f1b5bfc2
5
5
  SHA512:
6
- metadata.gz: b77f3a496e6dd8e8afea59185ba46306b07e9cb0e4fb5e41b97151886292ab1735008e5a58f08251874e25ede8b781f819498f2ef0c84ba4f357f8c13b7c2c0a
7
- data.tar.gz: bc9646367d1cd6476f60edf98cf2a94ff24dd6bff14756b3bcbc1365e79a3cb22869c626bc897f94784c59e3cffe30fe5c5e8fe90915a23fc042d3b4f836ffae
6
+ metadata.gz: 441432dc7b68d4163d9a08b0e8df43580692fa84ff1091ee6f6f6e71abf9199a96038a2df17d017d9fed4016457d5254b7667f71d7f4880fc63dd12f23f4918c
7
+ data.tar.gz: edee0a32bfcc5f41a756a837fe904d63039160c446578c4a843190285bd7edb9d99aec946e69c2b956d8ef3cdfd2ee06221061d217aac789c502a7f37c87fd8f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
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
+
8
+ ## 0.28.1
9
+
10
+ - Support `arc` Canvas Shape DSL keyword (partial support whereby width is assumed to be equal to height to start from a circle basis)
11
+ - Use `arc` in Hello, Canvas! sample
12
+
13
+ ## 0.28.0
14
+
15
+ - Initial support for Canvas Shape DSL keywords (no-databinding, nesting, or gradients yet):
16
+ - `line`
17
+ - `point`
18
+ - `oval`
19
+ - `polygon`
20
+ - `polyline`
21
+ - `rectangle`
22
+ - `string`
23
+ - `text`
24
+ - Minimal initial version of Hello, Canvas! sample
25
+
26
+ ## 0.27.0
27
+
28
+ - Hello, Text!
29
+ - Support unbordered `text` widget if SWT style `:none` was passed
30
+ - Support `:center`, `:left`, `:right` SWT styles for `text` widget
31
+ - Support `:read_only` SWT style for `text` widget
32
+ - Support `text` widget `on_verify_text` `event.doit = false` cancellation feature
33
+
3
34
  ## 0.26.3
4
35
 
5
36
  - Support key_event.key_location in all key capturing widgets, not just display
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.26.3 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)
@@ -179,12 +179,14 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
179
179
  - [Hello, Radio!](#hello-radio)
180
180
  - [Hello, Radio Group!](#hello-radio-group)
181
181
  - [Hello, Group!](#hello-group)
182
+ - [Hello, Canvas!](#hello-canvas)
182
183
  - [Hello, C Combo!](#hello-c-combo)
183
184
  - [Hello, C Tab!](#hello-c-tab)
184
185
  - [Hello, Checkbox!](#hello-checkbox)
185
186
  - [Hello, Checkbox Group!](#hello-checkbox-group)
186
187
  - [Hello, Date Time!](#hello-date-time)
187
188
  - [Hello, Table!](#hello-table)
189
+ - [Hello, Text!](#hello-text)
188
190
  - [Hello, Button!](#hello-button)
189
191
  - [Hello, Arrow!](#hello-arrow)
190
192
  - [Hello, Message Box!](#hello-message-box)
@@ -269,7 +271,7 @@ gem 'opal', '1.0.5'
269
271
  gem 'opal-rails', '1.1.2'
270
272
  gem 'opal-async', '~> 1.4.0'
271
273
  gem 'opal-jquery', '~> 0.4.4'
272
- gem 'glimmer-dsl-opal', '~> 0.26.3'
274
+ gem 'glimmer-dsl-opal', '~> 0.28.2'
273
275
  gem 'glimmer-dsl-xml', '~> 1.2.0', require: false
274
276
  gem 'glimmer-dsl-css', '~> 1.2.0', require: false
275
277
 
@@ -392,6 +394,16 @@ Event loop:
392
394
  - `display`: featured in [Tic Tac Toe](#tic-tac-toe)
393
395
  - `async_exec`: featured in [Hello, Custom Widget!](#hello-custom-widget) / [Hello, Custom Shell!](#hello-custom-shell)
394
396
 
397
+ Canvas Shape DSL:
398
+ - `line`
399
+ - `point`
400
+ - `oval`
401
+ - `polygon`
402
+ - `polyline`
403
+ - `rectangle`
404
+ - `string`
405
+ - `text`
406
+
395
407
  ## Samples
396
408
 
397
409
  Follow the instructions below to try out [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) samples webified via [glimmer-dsl-opal](https://rubygems.org/gems/glimmer-dsl-opal)
@@ -1447,6 +1459,35 @@ You should see "Hello, Group!"
1447
1459
 
1448
1460
  ![Glimmer DSL for Opal Hello Group](images/glimmer-dsl-opal-hello-group.png)
1449
1461
 
1462
+ #### Hello, Canvas!
1463
+
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
+
1466
+ It [supports](#supported-glimmer-dsl-keywords) all shapes, but with no shape nesting, data-binding, or gradient support yet.
1467
+
1468
+ Add the following require statement to `app/assets/javascripts/application.rb`
1469
+
1470
+ ```ruby
1471
+ require 'glimmer-dsl-opal/samples/hello/hello_canvas'
1472
+ ```
1473
+
1474
+ Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
1475
+
1476
+ ![Glimmer DSL for SWT Hello Canvas](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-canvas.png)
1477
+
1478
+ Glimmer app on the web (using `glimmer-dsl-opal` gem):
1479
+
1480
+ Start the Rails server:
1481
+ ```
1482
+ rails s
1483
+ ```
1484
+
1485
+ Visit `http://localhost:3000`
1486
+
1487
+ You should see "Hello, Canvas!"
1488
+
1489
+ ![Glimmer DSL for Opal Hello Canvas](images/glimmer-dsl-opal-hello-canvas.png)
1490
+
1450
1491
  #### Hello, C Combo!
1451
1492
 
1452
1493
  This is the low level way of using `c_combo`
@@ -1733,6 +1774,31 @@ Hello, Table! Game Booked
1733
1774
 
1734
1775
  ![Glimmer DSL for Opal Hello Table](images/glimmer-dsl-opal-hello-table-game-booked.png)
1735
1776
 
1777
+ #### Hello, Text!
1778
+
1779
+ Add the following require statement to `app/assets/javascripts/application.rb`
1780
+
1781
+ ```ruby
1782
+ require 'glimmer-dsl-opal/samples/hello/hello_text'
1783
+ ```
1784
+
1785
+ Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
1786
+
1787
+ ![Glimmer DSL for SWT Hello Text](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-text.png)
1788
+
1789
+ Glimmer app on the web (using `glimmer-dsl-opal` gem):
1790
+
1791
+ Start the Rails server:
1792
+ ```
1793
+ rails s
1794
+ ```
1795
+
1796
+ Visit `http://localhost:3000`
1797
+
1798
+ You should see "Hello, Text!"
1799
+
1800
+ ![Glimmer DSL for Opal Hello Text](images/glimmer-dsl-opal-hello-text.png)
1801
+
1736
1802
  #### Hello, Button!
1737
1803
 
1738
1804
  Add the following require statement to `app/assets/javascripts/application.rb`
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.26.3
1
+ 0.28.2
@@ -30,6 +30,8 @@ require 'glimmer/dsl/opal/menu_expression'
30
30
  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
+ require 'glimmer/dsl/opal/shape_expression'
34
+ require 'glimmer/dsl/opal/image_expression'
33
35
 
34
36
  module Glimmer
35
37
  module DSL
@@ -46,6 +48,7 @@ module Glimmer
46
48
  checkbox_group_selection_data_binding
47
49
  data_binding
48
50
  font
51
+ image
49
52
  layout
50
53
  block_property
51
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
@@ -1,5 +1,28 @@
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
+
1
22
  require 'glimmer/dsl/expression'
2
23
  require 'glimmer/dsl/parent_expression'
24
+ require 'glimmer/swt/swt_proxy'
25
+ require 'glimmer/swt/custom/shape'
3
26
 
4
27
  module Glimmer
5
28
  module DSL
@@ -7,20 +30,25 @@ module Glimmer
7
30
  class ShapeExpression < Expression
8
31
  include ParentExpression
9
32
 
10
- INCLUDED_KEYWORDS = %w[rectangle polygon]
11
-
12
33
  def can_interpret?(parent, keyword, *args, &block)
13
- INCLUDED_KEYWORDS.include?(keyword)
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) and
36
+ (keyword != 'text' || args.size >= 3)
14
37
  end
15
-
38
+
16
39
  def interpret(parent, keyword, *args, &block)
17
- # TODO
40
+ Glimmer::SWT::Custom::Shape.create(parent, keyword, args, &block)
18
41
  end
19
42
 
20
43
  def add_content(parent, keyword, *args, &block)
21
- # TODO
44
+ super(parent, keyword, *args, &block)
45
+ parent.post_add_content
22
46
  end
47
+
23
48
  end
49
+
24
50
  end
51
+
25
52
  end
53
+
26
54
  end
@@ -28,7 +28,7 @@ module Glimmer
28
28
  attr_reader :closeable_children
29
29
 
30
30
  def initialize(parent, args, block)
31
- @closeable_children = args.detect { |arg| SWTProxy[:close] == SWTProxy[arg] }
31
+ @closeable_children = !!args.detect { |arg| SWTProxy[arg] == SWTProxy[:close] }
32
32
  super(parent, args, block)
33
33
  end
34
34
 
@@ -0,0 +1,27 @@
1
+ require 'glimmer/swt/composite_proxy'
2
+
3
+ module Glimmer
4
+ module SWT
5
+ class CanvasProxy < CompositeProxy
6
+ def default_layout
7
+ nil
8
+ end
9
+
10
+ def element
11
+ 'svg'
12
+ end
13
+
14
+ def dom
15
+ canvas_id = id
16
+ canvas_class = name
17
+ # TODO in the future, calculate width and height from children automatically (just like Glimmer DSL for SWT)
18
+ @dom ||= html {
19
+ svg(id: canvas_id, class: canvas_class) {
20
+ 'Sorry, your browser does not support inline SVG.'
21
+ }
22
+ }.to_s
23
+ end
24
+
25
+ end
26
+ end
27
+ end
@@ -78,8 +78,6 @@ module Glimmer
78
78
 
79
79
  end
80
80
 
81
- CanvasProxy = CompositeProxy # TODO implement fully eventually
82
-
83
81
  end
84
82
 
85
83
  end
@@ -0,0 +1,72 @@
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/transform_proxy'
27
+
28
+ module Glimmer
29
+ module SWT
30
+ module Custom
31
+ class Shape
32
+ class Arc < Shape
33
+
34
+ def post_add_content
35
+ @performing_post_add_content = true
36
+ render
37
+ @performing_post_add_content = false
38
+ end
39
+
40
+ def background=(value)
41
+ super(value)
42
+ self.foreground = value
43
+ end
44
+
45
+ def render(custom_parent_dom_element: nil, brand_new: false)
46
+ return unless @performing_post_add_content
47
+ the_parent_element = Native(`document.getElementById(#{parent.id})`)
48
+ params = { type: `Two.Types.svg` }
49
+ two = Native(`new Two(#{params})`)
50
+ two.appendTo(the_parent_element)
51
+ x = @args[0]
52
+ y = @args[1]
53
+ width = @args[2]
54
+ height = @args[3]
55
+ start_angle = -1*@args[4]
56
+ arc_angle = -1*@args[5]
57
+ end_angle = start_angle + arc_angle
58
+ rx = width / 2.0
59
+ ry = height / 2.0
60
+ cx = x + rx
61
+ cy = y + ry
62
+ arc = two.makeArcSegment(cx, cy, 0, ry, 2*`Math.PI`*(start_angle)/360.0, 2*`Math.PI`*(end_angle)/360.0);
63
+ arc.fill = background.to_css unless background.nil?
64
+ arc.stroke = foreground.to_css unless foreground.nil?
65
+ two.update
66
+ end
67
+
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -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