glimmer-dsl-opal 0.20.0 → 0.22.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: 531f953f5ec4fe36dfa9a7bc8e7a98e5155c8dced489215e74b6679543feff1b
4
- data.tar.gz: 3e429ff4bac544027a49e458c75b670adf0d3f6110da692f151da6153511e889
3
+ metadata.gz: b25cb50adf580107747fab7e5e98f1eb5d93bbf91e0a460d8ed1a3bc671bde84
4
+ data.tar.gz: 12c5551fc10de17736f0186e10582e4fdbb2ec08176e33813d1cc2b77fedc523
5
5
  SHA512:
6
- metadata.gz: 2822a5d9881c20c06c31b4a1115cf08a1cc5e79db5da15ca2cf8491a9f1c9e7114ccb8380e94af27b55f14e7e533a2247890cd11ea06bd2d8a82b7038c9e628d
7
- data.tar.gz: ea93b2b373f4aea2c742c09d1e05752899c91ba62d12b5e5cde96492631984cf49e70fcbc8d744ea516ac2bbd42fc00bd58d84b0cc8f297cb04d0d6a45d34210
6
+ metadata.gz: 1f9940b3b91abb63277fddbb9186996ab5433e512f58981516bdcb24e40504c23c2960a22182fd498a255937478f0dab6e9eb5e2d499200036c619abe7724445
7
+ data.tar.gz: 10608c56db367b7dea3a0a2c8b55b747eef1a2407c23ee3b88208255fc488462f4e0b6fafb3b7c741d382956ce06982b6913f870d71623f74aa7f236323f0991
data/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.22.1
4
+
5
+ - User Profile elaborate sample
6
+
7
+ ## 0.22.0
8
+
9
+ - Support widget `cursor` attribute
10
+ - Hello, Cursor! sample
11
+
12
+ ## 0.21.0
13
+
14
+ - Support `scale` widget
15
+ - Hello, Scale!
16
+ - Support `slider` widget
17
+ - Hello, Slider!
18
+
19
+ ## 0.20.1
20
+
21
+ - Support `spinner` automatic insertion of decimal point when `digits` attribute is specified
22
+
3
23
  ## 0.20.0
4
24
 
5
25
  - Support `spinner` widget (leaving out automatic insertion of decimal point when digits are specified)
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.20.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.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))
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)
@@ -189,8 +190,9 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
189
190
  - [Hello, Dialog!](#hello-dialog)
190
191
  - [Elaborate Samples](#elaborate-samples)
191
192
  - [Login](#login)
192
- - [Tic Tac Toe](#tic-tac-toe)
193
193
  - [Contact Manager](#contact-manager)
194
+ - [Tic Tac Toe](#tic-tac-toe)
195
+ - [User Profile](#user-profile)
194
196
  - [Weather](#weather)
195
197
  - [External Samples](#external-samples)
196
198
  - [Glimmer Calculator](#glimmer-calculator)
@@ -261,7 +263,7 @@ gem 'opal', '1.0.4'
261
263
  gem 'opal-rails', '1.1.2'
262
264
  gem 'opal-async', '~> 1.2.0'
263
265
  gem 'opal-jquery', '~> 0.4.4'
264
- gem 'glimmer-dsl-opal', '~> 0.20.0'
266
+ gem 'glimmer-dsl-opal', '~> 0.22.1'
265
267
  gem 'glimmer-dsl-xml', '~> 1.2.0', require: false
266
268
  gem 'glimmer-dsl-css', '~> 1.2.0', require: false
267
269
 
@@ -663,6 +665,32 @@ You should see "Hello, Computed!"
663
665
 
664
666
  ![Glimmer DSL for Opal Hello Computed](images/glimmer-dsl-opal-hello-computed.png)
665
667
 
668
+ #### Hello, Cursor!
669
+
670
+ Add the following require statement to `app/assets/javascripts/application.rb`
671
+
672
+
673
+ ```ruby
674
+ require 'glimmer-dsl-opal/samples/hello/hello_cursor'
675
+ ```
676
+
677
+ Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
678
+
679
+ ![Glimmer DSL for SWT Hello Cursor](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-cursor.gif)
680
+
681
+ Glimmer app on the web (using `glimmer-dsl-opal` gem):
682
+
683
+ Start the Rails server:
684
+ ```
685
+ rails s
686
+ ```
687
+
688
+ Visit `http://localhost:3000`
689
+
690
+ You should see "Hello, Cursor!"
691
+
692
+ ![Glimmer DSL for Opal Hello Cursor](images/glimmer-dsl-opal-hello-cursor.gif)
693
+
666
694
  #### Hello, Layout!
667
695
 
668
696
  Add the following require statement to `app/assets/javascripts/application.rb`
@@ -799,6 +827,56 @@ You should see "Hello, Arrow!"
799
827
 
800
828
  ![Glimmer DSL for Opal Hello Arrow](images/glimmer-dsl-opal-hello-arrow-item-selected.png)
801
829
 
830
+ #### Hello, Scale!
831
+
832
+ Add the following require statement to `app/assets/javascripts/application.rb`
833
+
834
+ ```ruby
835
+ require 'glimmer-dsl-opal/samples/hello/hello_scale'
836
+ ```
837
+
838
+ Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
839
+
840
+ ![Glimmer DSL for SWT Hello Scale](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-scale.png)
841
+
842
+ Glimmer app on the web (using `glimmer-dsl-opal` gem):
843
+
844
+ Start the Rails server:
845
+ ```
846
+ rails s
847
+ ```
848
+
849
+ Visit `http://localhost:3000`
850
+
851
+ You should see "Hello, Scale!"
852
+
853
+ ![Glimmer DSL for Opal Hello Scale](images/glimmer-dsl-opal-hello-scale.png)
854
+
855
+ #### Hello, Slider!
856
+
857
+ Add the following require statement to `app/assets/javascripts/application.rb`
858
+
859
+ ```ruby
860
+ require 'glimmer-dsl-opal/samples/hello/hello_slider'
861
+ ```
862
+
863
+ Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
864
+
865
+ ![Glimmer DSL for SWT Hello Slider](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-slider.png)
866
+
867
+ Glimmer app on the web (using `glimmer-dsl-opal` gem):
868
+
869
+ Start the Rails server:
870
+ ```
871
+ rails s
872
+ ```
873
+
874
+ Visit `http://localhost:3000`
875
+
876
+ You should see "Hello, Slider!"
877
+
878
+ ![Glimmer DSL for Opal Hello Slider](images/glimmer-dsl-opal-hello-slider.png)
879
+
802
880
  #### Hello, Spinner!
803
881
 
804
882
  Add the following require statement to `app/assets/javascripts/application.rb`
@@ -2350,36 +2428,6 @@ You should see "Login" dialog
2350
2428
  ![Glimmer DSL for Opal Login Filled In](images/glimmer-dsl-opal-login-filled-in.png)
2351
2429
  ![Glimmer DSL for Opal Login Logged In](images/glimmer-dsl-opal-login-logged-in.png)
2352
2430
 
2353
- #### Tic Tac Toe
2354
-
2355
- Add the following require statement to `app/assets/javascripts/application.rb`
2356
-
2357
- ```ruby
2358
- require 'glimmer-dsl-opal/samples/elaborate/tic_tac_toe'
2359
- ```
2360
-
2361
- ```ruby
2362
- Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
2363
-
2364
- ![Glimmer DSL for SWT Tic Tac Toe](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-tic-tac-toe.png)
2365
- ![Glimmer DSL for SWT Tic Tac Toe In Progress](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-tic-tac-toe-in-progress.png)
2366
- ![Glimmer DSL for SWT Tic Tac Toe Game Over](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-tic-tac-toe-game-over.png)
2367
-
2368
- Glimmer app on the web (using `glimmer-dsl-opal` gem):
2369
-
2370
- Start the Rails server:
2371
- ```
2372
- rails s
2373
- ```
2374
-
2375
- Visit `http://localhost:3000`
2376
-
2377
- You should see "Tic Tac Toe"
2378
-
2379
- ![Glimmer DSL for Opal Tic Tac Toe](images/glimmer-dsl-opal-tic-tac-toe.png)
2380
- ![Glimmer DSL for Opal Tic Tac Toe In Progress](images/glimmer-dsl-opal-tic-tac-toe-in-progress.png)
2381
- ![Glimmer DSL for Opal Tic Tac Toe Game Over](images/glimmer-dsl-opal-tic-tac-toe-game-over.png)
2382
-
2383
2431
  #### Contact Manager
2384
2432
 
2385
2433
  Add the following require statement to `app/assets/javascripts/application.rb`
@@ -2419,7 +2467,7 @@ rails s
2419
2467
 
2420
2468
  Visit `http://localhost:3000`
2421
2469
 
2422
- You should see "Tic Tac Toe"
2470
+ You should see "Contact Manager"
2423
2471
 
2424
2472
  Glimmer DSL for Opal Contact Manager
2425
2473
 
@@ -2441,6 +2489,62 @@ Glimmer DSL for Opal Contact Manager Edit Done
2441
2489
 
2442
2490
  ![Glimmer DSL for Opal Contact Manager Edit Done](images/glimmer-dsl-opal-contact-manager-edit-done.png)
2443
2491
 
2492
+ #### Tic Tac Toe
2493
+
2494
+ Add the following require statement to `app/assets/javascripts/application.rb`
2495
+
2496
+ ```ruby
2497
+ require 'glimmer-dsl-opal/samples/elaborate/tic_tac_toe'
2498
+ ```
2499
+
2500
+ Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
2501
+
2502
+ ![Glimmer DSL for SWT Tic Tac Toe](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-tic-tac-toe.png)
2503
+ ![Glimmer DSL for SWT Tic Tac Toe In Progress](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-tic-tac-toe-in-progress.png)
2504
+ ![Glimmer DSL for SWT Tic Tac Toe Game Over](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-tic-tac-toe-game-over.png)
2505
+
2506
+ Glimmer app on the web (using `glimmer-dsl-opal` gem):
2507
+
2508
+ Start the Rails server:
2509
+ ```
2510
+ rails s
2511
+ ```
2512
+
2513
+ Visit `http://localhost:3000`
2514
+
2515
+ You should see "Tic Tac Toe"
2516
+
2517
+ ![Glimmer DSL for Opal Tic Tac Toe](images/glimmer-dsl-opal-tic-tac-toe.png)
2518
+ ![Glimmer DSL for Opal Tic Tac Toe In Progress](images/glimmer-dsl-opal-tic-tac-toe-in-progress.png)
2519
+ ![Glimmer DSL for Opal Tic Tac Toe Game Over](images/glimmer-dsl-opal-tic-tac-toe-game-over.png)
2520
+
2521
+ #### User Profile
2522
+
2523
+ Code: [lib/glimmer-dsl-opal/samples/elaborate/user_profile](lib/glimmer-dsl-opal/samples/elaborate/user_profile.rb)
2524
+
2525
+ Add the following require statement to `app/assets/javascripts/application.rb`
2526
+
2527
+ ```ruby
2528
+ require 'glimmer-dsl-opal/samples/elaborate/user_profile'
2529
+ ```
2530
+
2531
+ Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
2532
+
2533
+ ![User Profile](https://github.com/AMaleh/glimmer-dsl-swt/raw/master/images/glimmer-user-profile.png)
2534
+
2535
+ Glimmer app on the web (using `glimmer-dsl-opal` gem):
2536
+
2537
+ Start the Rails server:
2538
+ ```
2539
+ rails s
2540
+ ```
2541
+
2542
+ Visit `http://localhost:3000`
2543
+
2544
+ You should see "User Profile"
2545
+
2546
+ ![Opal User Profile](/images/glimmer-dsl-opal-user-profile.png)
2547
+
2444
2548
  #### Weather
2445
2549
 
2446
2550
  Code: [lib/glimmer-dsl-opal/samples/elaborate/weather](lib/glimmer-dsl-opal/samples/elaborate/weather.rb)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.20.0
1
+ 0.22.1
@@ -0,0 +1,78 @@
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
+ include Glimmer
23
+
24
+ # A version of this was featured in a dzone article as an intro to Glimmer syntax:
25
+ # https://dzone.com/articles/an-introduction-glimmer
26
+ shell { |shell_proxy|
27
+ text "User Profile"
28
+
29
+ composite {
30
+ grid_layout 2, false
31
+
32
+ group {
33
+ text "Name"
34
+ grid_layout 2, false
35
+ layout_data :fill, :fill, true, true
36
+ label {text "First"}; text {text "Bullet"}
37
+ label {text "Last"}; text {text "Tooth"}
38
+ }
39
+
40
+ group {
41
+ layout_data :fill, :fill, true, true
42
+ text "Gender"
43
+ radio {text "Male"; selection true}
44
+ radio {text "Female"}
45
+ }
46
+
47
+ group {
48
+ layout_data :fill, :fill, true, true
49
+ text "Role"
50
+ check {text "Student"; selection true}
51
+ check {text "Employee"; selection true}
52
+ }
53
+
54
+ group {
55
+ text "Experience"
56
+ row_layout
57
+ layout_data :fill, :fill, true, true
58
+ spinner {selection 5}; label {text "years"}
59
+ }
60
+
61
+ button {
62
+ text "save"
63
+ layout_data :right, :center, true, true
64
+ on_widget_selected {
65
+ message_box {
66
+ text 'Profile Saved!'
67
+ message 'User profile has been saved!'
68
+ }.open
69
+ }
70
+ }
71
+
72
+ button {
73
+ text "close"
74
+ layout_data :left, :center, true, true
75
+ on_widget_selected { shell_proxy.close }
76
+ }
77
+ }
78
+ }.open
@@ -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
@@ -0,0 +1,55 @@
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 HelloScale
23
+ include Glimmer::UI::CustomShell
24
+
25
+ attr_accessor :value
26
+
27
+ before_body do
28
+ @value = 50
29
+ end
30
+
31
+ body {
32
+ shell {
33
+ row_layout(:vertical) {
34
+ fill true
35
+ center true
36
+ }
37
+
38
+ text 'Hello, Scale!'
39
+
40
+ label(:center) {
41
+ text <= [self, :value]
42
+ }
43
+
44
+ scale { # optionally takes :vertical or :horizontal (default) SWT style
45
+ minimum 0
46
+ maximum 100
47
+ selection <=> [self, :value]
48
+ }
49
+
50
+ }
51
+
52
+ }
53
+ end
54
+
55
+ HelloScale.launch
@@ -0,0 +1,56 @@
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 HelloSlider
23
+ include Glimmer::UI::CustomShell
24
+
25
+ attr_accessor :value
26
+
27
+ before_body do
28
+ @value = 50
29
+ end
30
+
31
+ body {
32
+ shell {
33
+ row_layout(:vertical) {
34
+ fill true
35
+ center true
36
+ }
37
+
38
+ text 'Hello, Slider!'
39
+
40
+ label(:center) {
41
+ text <= [self, :value]
42
+ }
43
+
44
+ slider { # optionally takes :vertical or :horizontal (default) SWT style
45
+ minimum 0
46
+ maximum 110 # leave room for 10 extra (slider stops at 100)
47
+ page_increment 10 # page increment occurs when clicking area between slider and beginning or end
48
+ selection <=> [self, :value]
49
+ }
50
+
51
+ }
52
+
53
+ }
54
+ end
55
+
56
+ HelloSlider.launch
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2007-2021 Andy Maleh
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
@@ -0,0 +1,98 @@
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/widget_proxy'
23
+
24
+ module Glimmer
25
+ module SWT
26
+ class ScaleProxy < WidgetProxy
27
+ attr_reader :selection, :minimum, :maximum, :increment
28
+
29
+ def initialize(parent, args, block)
30
+ super(parent, args, block)
31
+ dom_element.slider
32
+ end
33
+
34
+ def selection=(value)
35
+ old_value = @selection.to_f
36
+ @selection = value.to_f
37
+ dom_element.slider('option', 'value', @selection)
38
+ end
39
+ alias set_selection selection=
40
+
41
+ def minimum=(value)
42
+ @minimum = value.to_f
43
+ dom_element.slider('option', 'min', @minimum)
44
+ end
45
+
46
+ def maximum=(value)
47
+ @maximum = value.to_f
48
+ dom_element.slider('option', 'max', @maximum)
49
+ end
50
+
51
+ def increment=(value)
52
+ @increment = value.to_f
53
+ dom_element.slider('option', 'step', @increment)
54
+ end
55
+
56
+ def element
57
+ 'div'
58
+ end
59
+
60
+ def observation_request_to_event_mapping
61
+ {
62
+ 'on_widget_selected' => [
63
+ {
64
+ event: 'change',
65
+ event_handler: -> (event_listener) {
66
+ -> (event) {
67
+ self.selection = dom_element.slider('option', 'value')
68
+ event_listener.call(event)
69
+ }
70
+ }
71
+ },
72
+ {
73
+ event: 'slidestop',
74
+ event_handler: -> (event_listener) {
75
+ -> (event) {
76
+ self.selection = dom_element.slider('option', 'value')
77
+ event_listener.call(event)
78
+ }
79
+ }
80
+ },
81
+ ],
82
+ }
83
+ end
84
+
85
+ def dom
86
+ scale_selection = @selection
87
+ scale_id = id
88
+ scale_style = css
89
+ scale_class = name
90
+ options = {type: 'text', id: scale_id, style: scale_style, class: scale_class, value: scale_selection}
91
+ options = options.merge('disabled': 'disabled') unless @enabled
92
+ @dom ||= html {
93
+ div(options)
94
+ }.to_s
95
+ end
96
+ end
97
+ end
98
+ end
@@ -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;
@@ -0,0 +1,100 @@
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/widget_proxy'
23
+
24
+ module Glimmer
25
+ module SWT
26
+ class SliderProxy < WidgetProxy
27
+ attr_reader :selection, :minimum, :maximum, :page_increment
28
+
29
+ def initialize(parent, args, block)
30
+ super(parent, args, block)
31
+ dom_element.slider
32
+ self.page_increment = 10 # default page increment
33
+ end
34
+
35
+ def selection=(value)
36
+ old_value = @selection.to_f
37
+ @selection = value.to_f
38
+ dom_element.slider('option', 'value', @selection)
39
+ end
40
+ alias set_selection selection=
41
+
42
+ def minimum=(value)
43
+ @minimum = value.to_f
44
+ dom_element.slider('option', 'min', @minimum)
45
+ end
46
+
47
+ def maximum=(value)
48
+ # being compatible with slider quirk in Glimmer DSL for SWT (does not reach max yet max - 10)
49
+ @maximum = value.to_f - 10
50
+ dom_element.slider('option', 'max', @maximum)
51
+ end
52
+
53
+ def page_increment=(value)
54
+ @page_increment = value.to_f
55
+ dom_element.slider('option', 'step', @page_increment)
56
+ end
57
+
58
+ def element
59
+ 'div'
60
+ end
61
+
62
+ def observation_request_to_event_mapping
63
+ {
64
+ 'on_widget_selected' => [
65
+ {
66
+ event: 'change',
67
+ event_handler: -> (event_listener) {
68
+ -> (event) {
69
+ self.selection = dom_element.slider('option', 'value')
70
+ event_listener.call(event)
71
+ }
72
+ }
73
+ },
74
+ {
75
+ event: 'slidestop',
76
+ event_handler: -> (event_listener) {
77
+ -> (event) {
78
+ self.selection = dom_element.slider('option', 'value')
79
+ event_listener.call(event)
80
+ }
81
+ }
82
+ },
83
+ ],
84
+ }
85
+ end
86
+
87
+ def dom
88
+ slider_selection = @selection
89
+ slider_id = id
90
+ slider_style = css
91
+ slider_class = name
92
+ options = {type: 'text', id: slider_id, style: slider_style, class: slider_class, value: slider_selection}
93
+ options = options.merge('disabled': 'disabled') unless @enabled
94
+ @dom ||= html {
95
+ div(options)
96
+ }.to_s
97
+ end
98
+ end
99
+ end
100
+ end
@@ -1,3 +1,24 @@
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/swt/widget_proxy'
2
23
 
3
24
  module Glimmer
@@ -12,21 +33,23 @@ module Glimmer
12
33
  dom_element.spinner
13
34
  end
14
35
 
15
- def selection=(value)
36
+ def selection=(value, format_digits: true)
16
37
  old_value = @selection.to_f
17
38
  if @selection.nil?
18
39
  @selection = value.to_f / divider
19
40
  else
20
41
  @selection = value.to_f
21
42
  end
22
- # TODO do not apply digits if last change was done by keyboard not spinner
23
- # if @digits.to_i > 0
24
- # new_value = "%0.#{@digits.to_i}f" % @selection
25
- # dom_element.value = new_value if value.to_f != old_value.to_f
26
- # else
27
- dom_element.value = @selection if value.to_f != old_value.to_f
28
- # end
43
+ if value.to_i != old_value.to_i
44
+ if format_digits && @digits.to_i > 0
45
+ new_value = "%0.#{@digits.to_i}f" % @selection
46
+ dom_element.value = new_value
47
+ else
48
+ dom_element.value = @selection if @selection != 0
49
+ end
50
+ end
29
51
  end
52
+ alias set_selection selection=
30
53
 
31
54
  def selection
32
55
  @selection && @selection * divider
@@ -85,11 +108,28 @@ module Glimmer
85
108
  }
86
109
  }
87
110
  },
111
+ {
112
+ event: 'keyup',
113
+ event_handler: -> (event_listener) {
114
+ -> (event) {
115
+ @keyup = true # ensures spinstop event does not set selection if caused by key up entry
116
+ }
117
+ }
118
+ },
119
+ {
120
+ event: 'spin',
121
+ event_handler: -> (event_listener) {
122
+ -> (event) {
123
+ @keyup = false
124
+ }
125
+ }
126
+ },
88
127
  {
89
128
  event: 'spinstop',
90
129
  event_handler: -> (event_listener) {
91
130
  -> (event) {
92
- self.selection = event.target.value
131
+ self.set_selection(event.target.value, format_digits: !@keyup)
132
+ @keyup = false
93
133
  event_listener.call(event)
94
134
  }
95
135
  }
@@ -160,10 +200,8 @@ module Glimmer
160
200
  text_id = id
161
201
  text_style = css
162
202
  text_class = name
163
- # TODO support password field
164
203
  options = {type: 'text', id: text_id, style: text_style, class: text_class, value: text_text, style: 'min-width: 27px;'}
165
204
  options = options.merge('disabled': 'disabled') unless @enabled
166
- options = options.merge(type: 'password') if has_style?(:password)
167
205
  @dom ||= html {
168
206
  input(options)
169
207
  }.to_s
@@ -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
@@ -81,7 +81,6 @@ module Glimmer
81
81
  text_id = id
82
82
  text_style = css
83
83
  text_class = name
84
- # TODO support password field
85
84
  options = {type: 'text', id: text_id, style: text_style, class: text_class, value: text_text, style: 'min-width: 27px;'}
86
85
  options = options.merge('disabled': 'disabled') unless @enabled
87
86
  options = options.merge(type: 'password') if has_style?(:password)
@@ -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
@@ -851,6 +881,20 @@ module Glimmer
851
881
  # }
852
882
  # end,
853
883
  # },
884
+ ScaleProxy => {
885
+ :selection => lambda do |observer|
886
+ on_widget_selected { |selection_event|
887
+ observer.call(selection)
888
+ }
889
+ end
890
+ },
891
+ SliderProxy => {
892
+ :selection => lambda do |observer|
893
+ on_widget_selected { |selection_event|
894
+ observer.call(selection)
895
+ }
896
+ end
897
+ },
854
898
  SpinnerProxy => {
855
899
  :selection => lambda do |observer|
856
900
  on_widget_selected { |selection_event|
@@ -950,17 +994,16 @@ module Glimmer
950
994
  # observer.call(getSelection)
951
995
  # }
952
996
  # end
953
- # },
954
- # Java::OrgEclipseSwtWidgets::Spinner => {
955
- # :selection => lambda do |observer|
956
- # on_widget_selected { |selection_event|
957
- # observer.call(getSelection)
958
- # }
959
- # end
960
997
  # },
961
998
  }
962
999
  end
963
1000
 
1001
+ private
1002
+
1003
+ def css_cursor
1004
+ SWT_CURSOR_TO_CSS_CURSOR_MAP[@cursor]
1005
+ end
1006
+
964
1007
  end
965
1008
  end
966
1009
  end
@@ -990,7 +1033,9 @@ require 'glimmer/swt/table_item_proxy'
990
1033
  require 'glimmer/swt/table_proxy'
991
1034
  require 'glimmer/swt/text_proxy'
992
1035
  require 'glimmer/swt/radio_proxy'
1036
+ require 'glimmer/swt/scale_proxy'
993
1037
  require 'glimmer/swt/scrolled_composite_proxy'
1038
+ require 'glimmer/swt/slider_proxy'
994
1039
  require 'glimmer/swt/spinner_proxy'
995
1040
  require 'glimmer/swt/styled_text_proxy'
996
1041
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-opal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.0
4
+ version: 0.22.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-16 00:00:00.000000000 Z
11
+ date: 2021-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer
@@ -283,6 +283,7 @@ files:
283
283
  - lib/glimmer-dsl-opal/samples/elaborate/tic_tac_toe.rb
284
284
  - lib/glimmer-dsl-opal/samples/elaborate/tic_tac_toe/board.rb
285
285
  - lib/glimmer-dsl-opal/samples/elaborate/tic_tac_toe/cell.rb
286
+ - lib/glimmer-dsl-opal/samples/elaborate/user_profile.rb
286
287
  - lib/glimmer-dsl-opal/samples/elaborate/weather.rb
287
288
  - lib/glimmer-dsl-opal/samples/hello/hello_arrow.rb
288
289
  - lib/glimmer-dsl-opal/samples/hello/hello_browser.rb
@@ -294,6 +295,7 @@ files:
294
295
  - lib/glimmer-dsl-opal/samples/hello/hello_combo.rb
295
296
  - lib/glimmer-dsl-opal/samples/hello/hello_composite.rb
296
297
  - lib/glimmer-dsl-opal/samples/hello/hello_computed.rb
298
+ - lib/glimmer-dsl-opal/samples/hello/hello_cursor.rb
297
299
  - lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb
298
300
  - lib/glimmer-dsl-opal/samples/hello/hello_custom_widget.rb
299
301
  - lib/glimmer-dsl-opal/samples/hello/hello_date_time.rb
@@ -307,6 +309,8 @@ files:
307
309
  - lib/glimmer-dsl-opal/samples/hello/hello_pop_up_context_menu.rb
308
310
  - lib/glimmer-dsl-opal/samples/hello/hello_radio.rb
309
311
  - lib/glimmer-dsl-opal/samples/hello/hello_radio_group.rb
312
+ - lib/glimmer-dsl-opal/samples/hello/hello_scale.rb
313
+ - lib/glimmer-dsl-opal/samples/hello/hello_slider.rb
310
314
  - lib/glimmer-dsl-opal/samples/hello/hello_spinner.rb
311
315
  - lib/glimmer-dsl-opal/samples/hello/hello_tab.rb
312
316
  - lib/glimmer-dsl-opal/samples/hello/hello_table.rb
@@ -419,8 +423,10 @@ files:
419
423
  - lib/glimmer/swt/property_owner.rb
420
424
  - lib/glimmer/swt/radio_proxy.rb
421
425
  - lib/glimmer/swt/row_layout_proxy.rb
426
+ - lib/glimmer/swt/scale_proxy.rb
422
427
  - lib/glimmer/swt/scrolled_composite_proxy.rb
423
428
  - lib/glimmer/swt/shell_proxy.rb
429
+ - lib/glimmer/swt/slider_proxy.rb
424
430
  - lib/glimmer/swt/spinner_proxy.rb
425
431
  - lib/glimmer/swt/style_constantizable.rb
426
432
  - lib/glimmer/swt/styled_text_proxy.rb