glimmer-dsl-opal 0.21.0 → 0.22.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: 4dbe9f418aaf69cea9d11235337a4915e0545e0fcded7591f5b8e04c7195721d
4
- data.tar.gz: dabf17fe41390a4ea6d5f4d88d71c27782eaf0ef96948f67845d9d8ab8bdbc0a
3
+ metadata.gz: 167c3eec05fdb361d6e3f28d47ee672ee0e835264da34e017c3f72fbd04ac900
4
+ data.tar.gz: ae462638ff85959876a28c4ccd69a04ccd6c3bd4ac543428b400ecd8fe5666c9
5
5
  SHA512:
6
- metadata.gz: 0f84635205c0f8a86575fee0c1b72760052bb3722467196d067f469111f923d4195264ab4563bf3b5e37155d51e061d7d1f35f2b43acd77ca4d922ceabba4255
7
- data.tar.gz: 6f6f984e402e801fe336448ab7997ac2dacb40d1fe2a05c35ae4a937394325b48de250c98e4cf6fde8313b3f6d73d88eab180520b889bdd9f146828565baf1af
6
+ metadata.gz: c6435a394aaa0d03b39aaebacd4ef7b9bbea9b7ae6cd2f82b5573fc533e5d7ea5c795ee57fb7a70305b4c32f3bf1cfdeeed596387d5e8ac025cc741ab3977ece
7
+ data.tar.gz: c4dbcc37ac1c17c9ed6438f75940c34cda97194018e4b5dfb98d16354503cd6059cff762c6eaacf5d59c8897183083c50179597b572d5a8ead9241e3474a88e5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.22.0
4
+
5
+ - Support widget `cursor` attribute
6
+ - Hello, Cursor! sample
7
+
3
8
  ## 0.21.0
4
9
 
5
10
  - Support `scale` widget
data/README.md CHANGED
@@ -143,7 +143,7 @@ Hello, Table! Game Booked
143
143
 
144
144
  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.
145
145
 
146
- **Alpha Version** 0.21.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))
146
+ **Alpha Version** 0.22.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))
147
147
 
148
148
  Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
149
149
  - [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)
@@ -165,6 +165,7 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
165
165
  - [Hello, Combo!](#hello-combo)
166
166
  - [Hello, Composite!](#hello-composite)
167
167
  - [Hello, Computed!](#hello-computed)
168
+ - [Hello, Cursor!](#hello-cursor)
168
169
  - [Hello, Layout!](#hello-layout)
169
170
  - [Hello, List Single Selection!](#hello-list-single-selection)
170
171
  - [Hello, List Multi Selection!](#hello-list-multi-selection)
@@ -261,7 +262,7 @@ gem 'opal', '1.0.4'
261
262
  gem 'opal-rails', '1.1.2'
262
263
  gem 'opal-async', '~> 1.2.0'
263
264
  gem 'opal-jquery', '~> 0.4.4'
264
- gem 'glimmer-dsl-opal', '~> 0.21.0'
265
+ gem 'glimmer-dsl-opal', '~> 0.22.0'
265
266
  gem 'glimmer-dsl-xml', '~> 1.2.0', require: false
266
267
  gem 'glimmer-dsl-css', '~> 1.2.0', require: false
267
268
 
@@ -663,6 +664,32 @@ You should see "Hello, Computed!"
663
664
 
664
665
  ![Glimmer DSL for Opal Hello Computed](images/glimmer-dsl-opal-hello-computed.png)
665
666
 
667
+ #### Hello, Cursor!
668
+
669
+ Add the following require statement to `app/assets/javascripts/application.rb`
670
+
671
+
672
+ ```ruby
673
+ require 'glimmer-dsl-opal/samples/hello/hello_cursor'
674
+ ```
675
+
676
+ Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
677
+
678
+ ![Glimmer DSL for SWT Hello Cursor](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-cursor.gif)
679
+
680
+ Glimmer app on the web (using `glimmer-dsl-opal` gem):
681
+
682
+ Start the Rails server:
683
+ ```
684
+ rails s
685
+ ```
686
+
687
+ Visit `http://localhost:3000`
688
+
689
+ You should see "Hello, Cursor!"
690
+
691
+ ![Glimmer DSL for Opal Hello Cursor](images/glimmer-dsl-opal-hello-cursor.gif)
692
+
666
693
  #### Hello, Layout!
667
694
 
668
695
  Add the following require statement to `app/assets/javascripts/application.rb`
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.21.0
1
+ 0.22.0
@@ -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
+ class HelloCursor
23
+ include Glimmer::UI::CustomShell
24
+
25
+ attr_accessor :selected_cursor
26
+
27
+ # This method matches the name of the :selected_cursor property by convention
28
+ def selected_cursor_options
29
+ Glimmer::SWT::SWTProxy.cursor_options
30
+ end
31
+
32
+ after_body do
33
+ observe(self, :selected_cursor) {
34
+ body_root.cursor = selected_cursor
35
+ }
36
+ end
37
+
38
+ body {
39
+ shell {
40
+ grid_layout
41
+
42
+ text 'Hello, Cursor!'
43
+ cursor :wait
44
+
45
+ label {
46
+ text 'Please select a cursor style and see it change the mouse cursor (varies per platform):'
47
+ font style: :bold
48
+ cursor :no
49
+ }
50
+ radio_group {
51
+ grid_layout 5, true
52
+ selection <=> [self, :selected_cursor]
53
+ }
54
+ }
55
+ }
56
+ end
57
+
58
+ HelloCursor.launch
@@ -37,6 +37,9 @@ module Glimmer
37
37
  height: 100%;
38
38
  margin: 0;
39
39
  }
40
+ * {
41
+ cursor: inherit;
42
+ }
40
43
  .shell {
41
44
  height: 100%;
42
45
  margin: 0;
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2020-2021 Andy Maleh
2
- #
2
+ #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
5
5
  # "Software"), to deal in the Software without restriction, including
@@ -7,10 +7,10 @@
7
7
  # distribute, sublicense, and/or sell copies of the Software, and to
8
8
  # permit persons to whom the Software is furnished to do so, subject to
9
9
  # the following conditions:
10
- #
10
+ #
11
11
  # The above copyright notice and this permission notice shall be
12
12
  # included in all copies or substantial portions of the Software.
13
- #
13
+ #
14
14
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
15
  # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
16
  # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -27,8 +27,8 @@ module Glimmer
27
27
  # Proxy for org.eclipse.swt.SWT
28
28
  #
29
29
  # Follows the Proxy Design Pattern
30
- class SWTProxy
31
- include StyleConstantizable
30
+ class SWTProxy
31
+ include StyleConstantizable
32
32
 
33
33
  class << self
34
34
  def constant_source_class
@@ -42,12 +42,16 @@ module Glimmer
42
42
  def extra_styles
43
43
  EXTRA_STYLES
44
44
  end
45
+
46
+ def cursor_options
47
+ [:wait, :sizenwse, :appstarting, :no, :sizenesw, :sizeall, :help, :sizee, :sizewe, :sizen, :sizes, :sizew, :cross, :sizese, :ibeam, :arrow, :sizesw, :uparrow, :hand, :sizenw, :sizene, :sizens]
48
+ end
45
49
  end
46
50
 
47
51
  EXTRA_STYLES = {
48
52
  NO_RESIZE: self[:shell_trim, :resize!, :max!],
49
53
  NO_SORT: -7,
50
- }
54
+ }
51
55
  end
52
56
  end
53
57
  end
@@ -31,7 +31,32 @@ module Glimmer
31
31
  include Glimmer
32
32
  include PropertyOwner
33
33
 
34
- attr_reader :parent, :args, :path, :children, :enabled, :foreground, :background, :font, :focus, :disposed?, :rendered
34
+ SWT_CURSOR_TO_CSS_CURSOR_MAP = {
35
+ wait: 'wait',
36
+ sizenwse: 'nwse-resize',
37
+ appstarting: 'progress',
38
+ no: 'no-drop',
39
+ sizenesw: 'nesw-resize',
40
+ sizeall: 'all-scroll',
41
+ help: 'help',
42
+ sizee: 'e-resize',
43
+ sizewe: 'ew-resize',
44
+ sizen: 'n-resize',
45
+ sizes: 's-resize',
46
+ sizew: 'w-resize',
47
+ cross: 'crosshair',
48
+ sizese: 'se-resize',
49
+ ibeam: 'text',
50
+ arrow: 'default',
51
+ sizesw: 'sw-resize',
52
+ uparrow: 'alias',
53
+ hand: 'grab',
54
+ sizenw: 'nw-resize',
55
+ sizene: 'ne-resize',
56
+ sizens: 'ns-resize',
57
+ }
58
+
59
+ attr_reader :parent, :args, :path, :children, :enabled, :foreground, :background, :font, :focus, :disposed?, :rendered, :cursor
35
60
  attr_accessor :menu, :menu_requested, :menu_x, :menu_y
36
61
  alias isDisposed disposed?
37
62
  alias is_disposed disposed?
@@ -242,6 +267,11 @@ module Glimmer
242
267
  dom_element.css('font-size', "#{@font.height}px") unless @font.nil?
243
268
  end
244
269
 
270
+ def cursor=(value)
271
+ @cursor = value
272
+ dom_element.css('cursor', css_cursor)
273
+ end
274
+
245
275
  def focus=(value)
246
276
  @focus = value
247
277
  dom_element.focus # TODO consider if a delay or async_exec is needed here
@@ -968,6 +998,12 @@ module Glimmer
968
998
  }
969
999
  end
970
1000
 
1001
+ private
1002
+
1003
+ def css_cursor
1004
+ SWT_CURSOR_TO_CSS_CURSOR_MAP[@cursor]
1005
+ end
1006
+
971
1007
  end
972
1008
  end
973
1009
  end
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.21.0
4
+ version: 0.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
@@ -294,6 +294,7 @@ files:
294
294
  - lib/glimmer-dsl-opal/samples/hello/hello_combo.rb
295
295
  - lib/glimmer-dsl-opal/samples/hello/hello_composite.rb
296
296
  - lib/glimmer-dsl-opal/samples/hello/hello_computed.rb
297
+ - lib/glimmer-dsl-opal/samples/hello/hello_cursor.rb
297
298
  - lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb
298
299
  - lib/glimmer-dsl-opal/samples/hello/hello_custom_widget.rb
299
300
  - lib/glimmer-dsl-opal/samples/hello/hello_date_time.rb