glimmer-dsl-opal 0.26.1 → 0.28.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: e1bec8104295a4c2f4a5b3f6d1464c9e0b0f5175092e93b7dd9508a5c4feabd0
4
- data.tar.gz: 778f2026c647b7454d0586cf2310297d143d122a4b8937ec6189abdba260667d
3
+ metadata.gz: 0f9cfe8a0d719c4ae80348ac72fd00f41190c31f405a2e38916f271ca35fab26
4
+ data.tar.gz: 0e44d82d8e35f15b35861195ec782cce25d0f2265b960cc65866212908a3a477
5
5
  SHA512:
6
- metadata.gz: 33e3f1b4bd51b3cfdc34d9f24403bb47d0a889c235e169232a3e8b8dae6db26617110dd55f8ed4a40d752c2e5f60569ea70c2b95db7a4435f1a2fddac25e3d7f
7
- data.tar.gz: 8fafbadda7e92fcf19ac96b994e3dcb67ed25febcdd521a97e94f57a66f272312cbc6763a341c30b1f1cf46e27ff62928eaed02cf8f1aa91c72590794e6ec7ee
6
+ metadata.gz: 9f6321b66a2fbb55fb53f5d5d32031ef62afb8db46b0595161c6feaa41a0af01f12e44483c137c4ee06cced7633c0a6898f924f1ab46fc230d3d5c263762c8b8
7
+ data.tar.gz: 44add1a5d248c51c8876aefa4a48c26dba0fbe0a9acae9ad22eb22e0dd3785f3a5feeac2102dad98c0057bf030785bec97ef49b15a9a6b838ddc3d7016ae3646
data/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.28.0
4
+
5
+ - Initial support for Canvas Shape DSL keywords (no-databinding, nesting, or gradients yet):
6
+ - `line`
7
+ - `point`
8
+ - `oval`
9
+ - `polygon`
10
+ - `polyline`
11
+ - `rectangle`
12
+ - `string`
13
+ - `text`
14
+ - Minimal initial version of Hello, Canvas! sample
15
+
16
+ ## 0.27.0
17
+
18
+ - Hello, Text!
19
+ - Support unbordered `text` widget if SWT style `:none` was passed
20
+ - Support `:center`, `:left`, `:right` SWT styles for `text` widget
21
+ - Support `:read_only` SWT style for `text` widget
22
+ - Support `text` widget `on_verify_text` `event.doit = false` cancellation feature
23
+
24
+ ## 0.26.3
25
+
26
+ - Support key_event.key_location in all key capturing widgets, not just display
27
+
28
+ ## 0.26.2
29
+
30
+ - Support key_event.key_location to distinguish between left and right alt/shift/command/ctrl buttons
31
+ - Use right/left alt/shift keys in Tetris for rotate right and rotate left
32
+
3
33
  ## 0.26.1
4
34
 
5
35
  - Support display on_swt_keydown event keyCode/key_code values for arrow keys and alt/shift/ctrl
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.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.0 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.1'
274
+ gem 'glimmer-dsl-opal', '~> 0.28.0'
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`, 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.1
1
+ 0.28.0
@@ -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,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
@@ -0,0 +1,58 @@
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 Oval < Shape
33
+
34
+ def element
35
+ 'ellipse'
36
+ end
37
+
38
+ def dom
39
+ shape_id = id
40
+ shape_class = name
41
+ x = @args[0]
42
+ y = @args[1]
43
+ width = @args[2]
44
+ height = @args[3]
45
+ rx = width / 2.0
46
+ ry = height / 2.0
47
+ cx = x + rx
48
+ cy = y + ry
49
+ @dom ||= xml {
50
+ ellipse(id: shape_id, class: shape_class, cx: cx, cy: cy, rx: rx, ry: ry)
51
+ }.to_s
52
+ end
53
+
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end