glimmer-dsl-opal 0.26.2 → 0.28.1

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: dd9df390a04a8efb59afa0dcfe42a88d3a2ebcc89b19f51b5daf325e85495898
4
- data.tar.gz: f842142ce4346af198197cacaa1695eddc9f15f684c4b4250ebed41872d9253f
3
+ metadata.gz: 4fe3d0b1328a0e5a9f0ea452608d31a75c0fe5d1d24f1a988a8474ab89b415b9
4
+ data.tar.gz: b575cc548458f30e64ddd5e29d3fc85673382306c16a125a9f4620d9f477fde4
5
5
  SHA512:
6
- metadata.gz: 1090a9d0bf0cab0bb673e32ce5711e3d034866e4d195995db125b40a43fa798f09f6944ba2e2bfbb38d06731248717bc38fd166d50c543e6271564aa8e80f978
7
- data.tar.gz: 57e6aa38f7829508d5a6f0a54814ada1d58c79fda05f56d353a069271960727b9d92c2bb642839215a6942958d267d00e9befc7b5f688755037fe46fcd7b8f53
6
+ metadata.gz: ebb320d8c8a58c55a424a1eb44ddee3d041d99a69610c5932caa9bc03ad891b48a7f03206d9112195bcd901611ed6ebbf08b2dee88eb7fc4ef8f7dfb2280c16e
7
+ data.tar.gz: 4221da20509698c503f374b4fd127ea732e4b86280c246c617c2d2a750982840a3523a72eb76da53caeb5eb580c06937de7706d4dde631ffd5ee59d22da14a45
data/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.28.1
4
+
5
+ - Support `arc` Canvas Shape DSL keyword (partial support whereby width is assumed to be equal to height to start from a circle basis)
6
+ - Use `arc` in Hello, Canvas! sample
7
+
8
+ ## 0.28.0
9
+
10
+ - Initial support for Canvas Shape DSL keywords (no-databinding, nesting, or gradients yet):
11
+ - `line`
12
+ - `point`
13
+ - `oval`
14
+ - `polygon`
15
+ - `polyline`
16
+ - `rectangle`
17
+ - `string`
18
+ - `text`
19
+ - Minimal initial version of Hello, Canvas! sample
20
+
21
+ ## 0.27.0
22
+
23
+ - Hello, Text!
24
+ - Support unbordered `text` widget if SWT style `:none` was passed
25
+ - Support `:center`, `:left`, `:right` SWT styles for `text` widget
26
+ - Support `:read_only` SWT style for `text` widget
27
+ - Support `text` widget `on_verify_text` `event.doit = false` cancellation feature
28
+
29
+ ## 0.26.3
30
+
31
+ - Support key_event.key_location in all key capturing widgets, not just display
32
+
3
33
  ## 0.26.2
4
34
 
5
35
  - Support key_event.key_location to distinguish between left and right alt/shift/command/ctrl buttons
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.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))
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))
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.2'
274
+ gem 'glimmer-dsl-opal', '~> 0.28.1'
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 all shapes except `arc` and `image`, 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.2
1
+ 0.28.1
@@ -30,6 +30,7 @@ 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'
33
34
 
34
35
  module Glimmer
35
36
  module DSL
@@ -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) &&
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
@@ -55,45 +55,6 @@ module Glimmer
55
55
  }
56
56
  }
57
57
  },
58
- 'on_key_pressed' => {
59
- event: 'keydown',
60
- event_handler: -> (event_listener) {
61
- -> (event) {
62
- @last_key_pressed_event = event
63
- @text = event.target.value
64
- # TODO generalize this solution to all widgets that support key presses
65
- # TODO support event.location once DOM3 is supported by opal-jquery
66
- event.define_singleton_method(:keyCode) {event.which}
67
- event.define_singleton_method(:key_code, &event.method(:keyCode))
68
- event.define_singleton_method(:character) {event.which.chr}
69
- event.define_singleton_method(:stateMask) do
70
- state_mask = 0
71
- state_mask |= SWTProxy[:alt] if event.alt_key
72
- state_mask |= SWTProxy[:ctrl] if event.ctrl_key
73
- state_mask |= SWTProxy[:shift] if event.shift_key
74
- state_mask |= SWTProxy[:command] if event.meta_key
75
- state_mask
76
- end
77
- event.define_singleton_method(:state_mask, &event.method(:stateMask))
78
- doit = true
79
- event.define_singleton_method(:doit=) do |value|
80
- doit = value
81
- end
82
- event.define_singleton_method(:doit) { doit }
83
- event_listener.call(event)
84
-
85
- # TODO Fix doit false, it's not stopping input
86
- unless doit
87
- event.prevent
88
- event.prevent_default
89
- event.stop_propagation
90
- event.stop_immediate_propagation
91
- end
92
-
93
- doit
94
- }
95
- }
96
- },
97
58
  }
98
59
  end
99
60
 
@@ -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,50 @@
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 Line < Shape
33
+
34
+ def element
35
+ 'line'
36
+ end
37
+
38
+ def dom
39
+ shape_id = id
40
+ shape_class = name
41
+ @dom ||= xml {
42
+ line(id: shape_id, class: shape_class, x1: @args[0], y1: @args[1], x2: @args[2], y2: @args[3])
43
+ }.to_s
44
+ end
45
+
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end