glimmer-dsl-opal 0.21.0 → 0.24.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: f974d9526112e11c32284c5fbcd30e08226aafa3f799c08ccd67deabddf9f0ac
4
+ data.tar.gz: e77d826d4afb7a359a24f2a87dc49672e7d17e4da265feef11c278403370d468
5
5
  SHA512:
6
- metadata.gz: 0f84635205c0f8a86575fee0c1b72760052bb3722467196d067f469111f923d4195264ab4563bf3b5e37155d51e061d7d1f35f2b43acd77ca4d922ceabba4255
7
- data.tar.gz: 6f6f984e402e801fe336448ab7997ac2dacb40d1fe2a05c35ae4a937394325b48de250c98e4cf6fde8313b3f6d73d88eab180520b889bdd9f146828565baf1af
6
+ metadata.gz: 9295b9a8da3867580a975a43cc61708d635de4f03d30fae6d07913d9147783c2372fe1fe9f673d0f8bfe20988684579b0aaeaa6fbebcec189c4111bba3b62935
7
+ data.tar.gz: 5ea143577dc7c59c8c8b5d423f0a17580c71bcbefb29cd200c770e8078ca78cca75f29de4354801b38a2a440365285832f96a48ec50290afbe941b865aa73f14
data/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.24.0
4
+
5
+ - `widget#print` method
6
+ - Hello, Print! sample
7
+
8
+ ## 0.23.0
9
+
10
+ - Hello, Label! sample
11
+ - Support `label` `:separator` SWT style along with `:horizontal` or `:vertical`
12
+ - Support `label` `image` attribute
13
+
14
+ ## 0.22.1
15
+
16
+ - User Profile elaborate sample
17
+
18
+ ## 0.22.0
19
+
20
+ - Support widget `cursor` attribute
21
+ - Hello, Cursor! sample
22
+
3
23
  ## 0.21.0
4
24
 
5
25
  - 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.24.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,8 @@ 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)
169
+ - [Hello, Label!](#hello-label)
168
170
  - [Hello, Layout!](#hello-layout)
169
171
  - [Hello, List Single Selection!](#hello-list-single-selection)
170
172
  - [Hello, List Multi Selection!](#hello-list-multi-selection)
@@ -189,8 +191,9 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
189
191
  - [Hello, Dialog!](#hello-dialog)
190
192
  - [Elaborate Samples](#elaborate-samples)
191
193
  - [Login](#login)
192
- - [Tic Tac Toe](#tic-tac-toe)
193
194
  - [Contact Manager](#contact-manager)
195
+ - [Tic Tac Toe](#tic-tac-toe)
196
+ - [User Profile](#user-profile)
194
197
  - [Weather](#weather)
195
198
  - [External Samples](#external-samples)
196
199
  - [Glimmer Calculator](#glimmer-calculator)
@@ -261,7 +264,7 @@ gem 'opal', '1.0.4'
261
264
  gem 'opal-rails', '1.1.2'
262
265
  gem 'opal-async', '~> 1.2.0'
263
266
  gem 'opal-jquery', '~> 0.4.4'
264
- gem 'glimmer-dsl-opal', '~> 0.21.0'
267
+ gem 'glimmer-dsl-opal', '~> 0.24.0'
265
268
  gem 'glimmer-dsl-xml', '~> 1.2.0', require: false
266
269
  gem 'glimmer-dsl-css', '~> 1.2.0', require: false
267
270
 
@@ -469,9 +472,9 @@ class HelloCombo
469
472
 
470
473
  include Glimmer::UI::CustomShell
471
474
 
472
- before_body {
475
+ before_body do
473
476
  @person = Person.new
474
- }
477
+ end
475
478
 
476
479
  body {
477
480
  shell {
@@ -575,13 +578,13 @@ class HelloComputed
575
578
 
576
579
  include Glimmer::UI::CustomShell
577
580
 
578
- before_body {
581
+ before_body do
579
582
  @contact = Contact.new(
580
583
  first_name: 'Barry',
581
584
  last_name: 'McKibbin',
582
585
  year_of_birth: 1985
583
586
  )
584
- }
587
+ end
585
588
 
586
589
  body {
587
590
  shell {
@@ -597,51 +600,43 @@ class HelloComputed
597
600
 
598
601
  label {text 'First &Name: '}
599
602
  text {
603
+ fill_horizontally_layout_data
600
604
  text <=> [@contact, :first_name]
601
- layout_data {
602
- horizontal_alignment :fill
603
- grab_excess_horizontal_space true
604
- }
605
605
  }
606
606
 
607
607
  label {text '&Last Name: '}
608
608
  text {
609
+ fill_horizontally_layout_data
609
610
  text <=> [@contact, :last_name]
610
- layout_data {
611
- horizontal_alignment :fill
612
- grab_excess_horizontal_space true
613
- }
614
611
  }
615
612
 
616
613
  label {text '&Year of Birth: '}
617
614
  text {
615
+ fill_horizontally_layout_data
618
616
  text <=> [@contact, :year_of_birth]
619
- layout_data {
620
- horizontal_alignment :fill
621
- grab_excess_horizontal_space true
622
- }
623
617
  }
624
618
 
625
619
  label {text 'Name: '}
626
620
  label {
621
+ fill_horizontally_layout_data
627
622
  text <= [@contact, :name, computed_by: [:first_name, :last_name]]
628
- layout_data {
629
- horizontal_alignment :fill
630
- grab_excess_horizontal_space true
631
- }
632
623
  }
633
624
 
634
625
  label {text 'Age: '}
635
626
  label {
627
+ fill_horizontally_layout_data
636
628
  text <= [@contact, :age, on_write: :to_i, computed_by: [:year_of_birth]]
637
- layout_data {
638
- horizontal_alignment :fill
639
- grab_excess_horizontal_space true
640
- }
641
629
  }
642
630
  }
643
631
  }
644
632
  }
633
+
634
+ def fill_horizontally_layout_data
635
+ layout_data {
636
+ horizontal_alignment :fill
637
+ grab_excess_horizontal_space true
638
+ }
639
+ end
645
640
  end
646
641
 
647
642
  HelloComputed.launch
@@ -663,6 +658,82 @@ You should see "Hello, Computed!"
663
658
 
664
659
  ![Glimmer DSL for Opal Hello Computed](images/glimmer-dsl-opal-hello-computed.png)
665
660
 
661
+ #### Hello, Cursor!
662
+
663
+ Add the following require statement to `app/assets/javascripts/application.rb`
664
+
665
+
666
+ ```ruby
667
+ require 'glimmer-dsl-opal/samples/hello/hello_cursor'
668
+ ```
669
+
670
+ Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
671
+
672
+ ![Glimmer DSL for SWT Hello Cursor](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-cursor.gif)
673
+
674
+ Glimmer app on the web (using `glimmer-dsl-opal` gem):
675
+
676
+ Start the Rails server:
677
+ ```
678
+ rails s
679
+ ```
680
+
681
+ Visit `http://localhost:3000`
682
+
683
+ You should see "Hello, Cursor!"
684
+
685
+ ![Glimmer DSL for Opal Hello Cursor](images/glimmer-dsl-opal-hello-cursor.gif)
686
+
687
+ #### Hello, Label!
688
+
689
+ Add the following require statement to `app/assets/javascripts/application.rb`
690
+
691
+
692
+ ```ruby
693
+ require 'glimmer-dsl-opal/samples/hello/hello_label'
694
+ ```
695
+
696
+ Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
697
+
698
+ ![Glimmer DSL for SWT Hello Label](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-label-left-aligned.png)
699
+
700
+ ![Glimmer DSL for SWT Hello Label](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-label-center-aligned.png)
701
+
702
+ ![Glimmer DSL for SWT Hello Label](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-label-right-aligned.png)
703
+
704
+ ![Glimmer DSL for SWT Hello Label](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-label-images.png)
705
+
706
+ ![Glimmer DSL for SWT Hello Label](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-label-background_images.png)
707
+
708
+ ![Glimmer DSL for SWT Hello Label](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-label-horizontal-separator.png)
709
+
710
+ ![Glimmer DSL for SWT Hello Label](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-label-vertical-separator.png)
711
+
712
+ Glimmer app on the web (using `glimmer-dsl-opal` gem):
713
+
714
+ Start the Rails server:
715
+ ```
716
+ rails s
717
+ ```
718
+
719
+ Visit `http://localhost:3000`
720
+
721
+ You should see "Hello, Label!"
722
+
723
+ ![Glimmer DSL for Opal Hello Label](images/glimmer-dsl-opal-hello-label-left-aligned.png)
724
+
725
+ ![Glimmer DSL for Opal Hello Label](images/glimmer-dsl-opal-hello-label-center-aligned.png)
726
+
727
+ ![Glimmer DSL for Opal Hello Label](images/glimmer-dsl-opal-hello-label-right-aligned.png)
728
+
729
+ ![Glimmer DSL for Opal Hello Label](images/glimmer-dsl-opal-hello-label-images.png)
730
+
731
+ ![Glimmer DSL for Opal Hello Label](images/glimmer-dsl-opal-hello-label-background_images.png)
732
+
733
+ ![Glimmer DSL for Opal Hello Label](images/glimmer-dsl-opal-hello-label-horizontal-separator.png)
734
+
735
+ ![Glimmer DSL for Opal Hello Label](images/glimmer-dsl-opal-hello-label-vertical-separator.png)
736
+
666
737
  #### Hello, Layout!
667
738
 
668
739
  Add the following require statement to `app/assets/javascripts/application.rb`
@@ -2400,36 +2471,6 @@ You should see "Login" dialog
2400
2471
  ![Glimmer DSL for Opal Login Filled In](images/glimmer-dsl-opal-login-filled-in.png)
2401
2472
  ![Glimmer DSL for Opal Login Logged In](images/glimmer-dsl-opal-login-logged-in.png)
2402
2473
 
2403
- #### Tic Tac Toe
2404
-
2405
- Add the following require statement to `app/assets/javascripts/application.rb`
2406
-
2407
- ```ruby
2408
- require 'glimmer-dsl-opal/samples/elaborate/tic_tac_toe'
2409
- ```
2410
-
2411
- ```ruby
2412
- Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
2413
-
2414
- ![Glimmer DSL for SWT Tic Tac Toe](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-tic-tac-toe.png)
2415
- ![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)
2416
- ![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)
2417
-
2418
- Glimmer app on the web (using `glimmer-dsl-opal` gem):
2419
-
2420
- Start the Rails server:
2421
- ```
2422
- rails s
2423
- ```
2424
-
2425
- Visit `http://localhost:3000`
2426
-
2427
- You should see "Tic Tac Toe"
2428
-
2429
- ![Glimmer DSL for Opal Tic Tac Toe](images/glimmer-dsl-opal-tic-tac-toe.png)
2430
- ![Glimmer DSL for Opal Tic Tac Toe In Progress](images/glimmer-dsl-opal-tic-tac-toe-in-progress.png)
2431
- ![Glimmer DSL for Opal Tic Tac Toe Game Over](images/glimmer-dsl-opal-tic-tac-toe-game-over.png)
2432
-
2433
2474
  #### Contact Manager
2434
2475
 
2435
2476
  Add the following require statement to `app/assets/javascripts/application.rb`
@@ -2469,7 +2510,7 @@ rails s
2469
2510
 
2470
2511
  Visit `http://localhost:3000`
2471
2512
 
2472
- You should see "Tic Tac Toe"
2513
+ You should see "Contact Manager"
2473
2514
 
2474
2515
  Glimmer DSL for Opal Contact Manager
2475
2516
 
@@ -2491,6 +2532,62 @@ Glimmer DSL for Opal Contact Manager Edit Done
2491
2532
 
2492
2533
  ![Glimmer DSL for Opal Contact Manager Edit Done](images/glimmer-dsl-opal-contact-manager-edit-done.png)
2493
2534
 
2535
+ #### Tic Tac Toe
2536
+
2537
+ Add the following require statement to `app/assets/javascripts/application.rb`
2538
+
2539
+ ```ruby
2540
+ require 'glimmer-dsl-opal/samples/elaborate/tic_tac_toe'
2541
+ ```
2542
+
2543
+ Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
2544
+
2545
+ ![Glimmer DSL for SWT Tic Tac Toe](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-tic-tac-toe.png)
2546
+ ![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)
2547
+ ![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)
2548
+
2549
+ Glimmer app on the web (using `glimmer-dsl-opal` gem):
2550
+
2551
+ Start the Rails server:
2552
+ ```
2553
+ rails s
2554
+ ```
2555
+
2556
+ Visit `http://localhost:3000`
2557
+
2558
+ You should see "Tic Tac Toe"
2559
+
2560
+ ![Glimmer DSL for Opal Tic Tac Toe](images/glimmer-dsl-opal-tic-tac-toe.png)
2561
+ ![Glimmer DSL for Opal Tic Tac Toe In Progress](images/glimmer-dsl-opal-tic-tac-toe-in-progress.png)
2562
+ ![Glimmer DSL for Opal Tic Tac Toe Game Over](images/glimmer-dsl-opal-tic-tac-toe-game-over.png)
2563
+
2564
+ #### User Profile
2565
+
2566
+ Code: [lib/glimmer-dsl-opal/samples/elaborate/user_profile](lib/glimmer-dsl-opal/samples/elaborate/user_profile.rb)
2567
+
2568
+ Add the following require statement to `app/assets/javascripts/application.rb`
2569
+
2570
+ ```ruby
2571
+ require 'glimmer-dsl-opal/samples/elaborate/user_profile'
2572
+ ```
2573
+
2574
+ Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
2575
+
2576
+ ![User Profile](https://github.com/AMaleh/glimmer-dsl-swt/raw/master/images/glimmer-user-profile.png)
2577
+
2578
+ Glimmer app on the web (using `glimmer-dsl-opal` gem):
2579
+
2580
+ Start the Rails server:
2581
+ ```
2582
+ rails s
2583
+ ```
2584
+
2585
+ Visit `http://localhost:3000`
2586
+
2587
+ You should see "User Profile"
2588
+
2589
+ ![Opal User Profile](/images/glimmer-dsl-opal-user-profile.png)
2590
+
2494
2591
  #### Weather
2495
2592
 
2496
2593
  Code: [lib/glimmer-dsl-opal/samples/elaborate/weather](lib/glimmer-dsl-opal/samples/elaborate/weather.rb)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.21.0
1
+ 0.24.0
@@ -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
@@ -35,9 +35,9 @@ class HelloCombo
35
35
 
36
36
  include Glimmer::UI::CustomShell
37
37
 
38
- before_body {
38
+ before_body do
39
39
  @person = Person.new
40
- }
40
+ end
41
41
 
42
42
  body {
43
43
  shell {
@@ -42,13 +42,13 @@ class HelloComputed
42
42
 
43
43
  include Glimmer::UI::CustomShell
44
44
 
45
- before_body {
45
+ before_body do
46
46
  @contact = Contact.new(
47
47
  first_name: 'Barry',
48
48
  last_name: 'McKibbin',
49
49
  year_of_birth: 1985
50
50
  )
51
- }
51
+ end
52
52
 
53
53
  body {
54
54
  shell {
@@ -64,51 +64,43 @@ class HelloComputed
64
64
 
65
65
  label {text 'First &Name: '}
66
66
  text {
67
+ fill_horizontally_layout_data
67
68
  text <=> [@contact, :first_name]
68
- layout_data {
69
- horizontal_alignment :fill
70
- grab_excess_horizontal_space true
71
- }
72
69
  }
73
70
 
74
71
  label {text '&Last Name: '}
75
72
  text {
73
+ fill_horizontally_layout_data
76
74
  text <=> [@contact, :last_name]
77
- layout_data {
78
- horizontal_alignment :fill
79
- grab_excess_horizontal_space true
80
- }
81
75
  }
82
76
 
83
77
  label {text '&Year of Birth: '}
84
78
  text {
79
+ fill_horizontally_layout_data
85
80
  text <=> [@contact, :year_of_birth]
86
- layout_data {
87
- horizontal_alignment :fill
88
- grab_excess_horizontal_space true
89
- }
90
81
  }
91
82
 
92
83
  label {text 'Name: '}
93
84
  label {
85
+ fill_horizontally_layout_data
94
86
  text <= [@contact, :name, computed_by: [:first_name, :last_name]]
95
- layout_data {
96
- horizontal_alignment :fill
97
- grab_excess_horizontal_space true
98
- }
99
87
  }
100
88
 
101
89
  label {text 'Age: '}
102
90
  label {
91
+ fill_horizontally_layout_data
103
92
  text <= [@contact, :age, on_write: :to_i, computed_by: [:year_of_birth]]
104
- layout_data {
105
- horizontal_alignment :fill
106
- grab_excess_horizontal_space true
107
- }
108
93
  }
109
94
  }
110
95
  }
111
96
  }
97
+
98
+ def fill_horizontally_layout_data
99
+ layout_data {
100
+ horizontal_alignment :fill
101
+ grab_excess_horizontal_space true
102
+ }
103
+ end
112
104
  end
113
105
 
114
106
  HelloComputed.launch
@@ -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,192 @@
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 HelloLabel
23
+ include Glimmer::UI::CustomShell
24
+
25
+ body {
26
+ shell {
27
+ text 'Hello, Label!'
28
+
29
+ tab_folder {
30
+ tab_item {
31
+ text 'left-aligned'
32
+
33
+ grid_layout 2, true
34
+
35
+ 1.upto(3) do |n|
36
+ label(:left) { # :left is default in English, so it is unnecessary
37
+ layout_data :fill, :center, true, false
38
+ text "Field #{n}"
39
+ }
40
+ text {
41
+ layout_data :fill, :center, true, false
42
+ text "Enter Field #{n}"
43
+ }
44
+ end
45
+ }
46
+
47
+ tab_item {
48
+ text 'center-aligned'
49
+
50
+ grid_layout 2, true
51
+
52
+ 1.upto(3) do |n|
53
+ label(:center) {
54
+ layout_data :fill, :center, true, false
55
+ text "Field #{n}"
56
+ }
57
+ text {
58
+ layout_data :fill, :center, true, false
59
+ text "Enter Field #{n}"
60
+ }
61
+ end
62
+ }
63
+
64
+ tab_item {
65
+ text 'right-aligned'
66
+
67
+ grid_layout 2, true
68
+
69
+ 1.upto(3) do |n|
70
+ label(:right) {
71
+ layout_data :fill, :center, true, false
72
+ text "Field #{n}"
73
+ }
74
+ text {
75
+ layout_data :fill, :center, true, false
76
+ text "Enter Field #{n}"
77
+ }
78
+ end
79
+ }
80
+
81
+ tab_item {
82
+ text 'images'
83
+
84
+ grid_layout 2, true
85
+
86
+ ['denmark', 'finland', 'norway'].each do |image_name|
87
+ label {
88
+ layout_data :center, :center, true, false
89
+ image File.expand_path("images/#{image_name}.png", __dir__)
90
+ }
91
+ text {
92
+ layout_data :fill, :center, true, false
93
+ text "Enter Field #{image_name.capitalize}"
94
+ }
95
+ end
96
+ }
97
+
98
+ tab_item {
99
+ text 'background images'
100
+
101
+ grid_layout 2, true
102
+
103
+ ['italy', 'france', 'mexico'].each do |image_name|
104
+ label {
105
+ layout_data :center, :center, true, false
106
+ background_image File.expand_path("images/#{image_name}.png", __dir__)
107
+ text image_name.capitalize
108
+ font height: 26, style: :bold
109
+ }
110
+ text {
111
+ layout_data :fill, :center, true, false
112
+ text "Enter Field #{image_name.capitalize}"
113
+ }
114
+ end
115
+ }
116
+
117
+ tab_item {
118
+ text 'horizontal separator'
119
+
120
+ grid_layout 2, true
121
+
122
+ label {
123
+ layout_data :fill, :center, true, false
124
+ text "Field 1"
125
+ }
126
+ text {
127
+ layout_data :fill, :center, true, false
128
+ text "Enter Field 1"
129
+ }
130
+
131
+ label(:separator, :horizontal) {
132
+ layout_data(:fill, :center, true, false) {
133
+ horizontal_span 2
134
+ }
135
+ }
136
+
137
+ label {
138
+ layout_data :fill, :center, true, false
139
+ text "Field 2"
140
+ }
141
+ text {
142
+ layout_data :fill, :center, true, false
143
+ text "Enter Field 2"
144
+ }
145
+ }
146
+
147
+ tab_item {
148
+ text 'vertical separator'
149
+
150
+ grid_layout 3, true
151
+
152
+ label {
153
+ layout_data :fill, :center, true, false
154
+ text "Field 1"
155
+ }
156
+ label(:separator, :vertical) {
157
+ layout_data(:center, :center, false, false) {
158
+ vertical_span 3
159
+ }
160
+ }
161
+ text {
162
+ layout_data :fill, :center, true, false
163
+ text "Enter Field 1"
164
+ }
165
+
166
+ label {
167
+ layout_data :fill, :center, true, false
168
+ text "Field 2"
169
+ }
170
+ text {
171
+ layout_data :fill, :center, true, false
172
+ text "Enter Field 2"
173
+ }
174
+
175
+ label {
176
+ layout_data :fill, :center, true, false
177
+ text "Field 3"
178
+ }
179
+ text {
180
+ layout_data :fill, :center, true, false
181
+ text "Enter Field 3"
182
+ }
183
+ }
184
+
185
+ }
186
+
187
+ }
188
+
189
+ }
190
+ end
191
+
192
+ HelloLabel.launch
@@ -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 HelloPrint
23
+ include Glimmer::UI::CustomShell
24
+
25
+ body {
26
+ shell {
27
+ text 'Hello, Print!'
28
+ @composite = composite {
29
+ row_layout(:vertical) {
30
+ fill true
31
+ center true
32
+ }
33
+
34
+ label(:center) {
35
+ text "Whatever you see inside the app composite\nwill get printed when clicking the Print button."
36
+ font height: 16
37
+ }
38
+
39
+ button {
40
+ text 'Print'
41
+
42
+ on_widget_selected do
43
+ # Unlike the SWT version, Opal's print always prints the entire window no matter what widget
44
+ # the print method is invoked from
45
+ unless @composite.print
46
+ message_box {
47
+ text 'Unable To Print'
48
+ message 'Sorry! Printing is not supported on this platform!'
49
+ }.open
50
+ end
51
+ end
52
+ }
53
+ }
54
+ }
55
+ }
56
+ end
57
+
58
+ HelloPrint.launch
@@ -28,7 +28,7 @@ module Glimmer
28
28
  attr_accessor :closeable
29
29
 
30
30
  def initialize(parent, args, block)
31
- @closeable = args.detect { |arg| SWTProxy[:close] == SWTProxy[arg] }
31
+ @closeable = args.detect { |arg| SWTProxy[arg] == SWTProxy[:close] }
32
32
  super(parent, args, block)
33
33
  # TODO attach listener if :close style is set
34
34
  close_dom_element.on('click') { dispose }
@@ -25,43 +25,39 @@ require 'glimmer/swt/widget_proxy'
25
25
  module Glimmer
26
26
  module SWT
27
27
  class LabelProxy < WidgetProxy
28
- attr_reader :text, :background_image, :image
28
+ attr_reader :text, :background_image, :image, :separator, :vertical
29
+ alias separator? separator
30
+ alias vertical? vertical
29
31
 
30
32
  def initialize(parent, args, block)
33
+ @separator = args.detect { |arg| SWTProxy[arg] == SWTProxy[:separator] }
34
+ @vertical = args.detect { |arg| SWTProxy[arg] == SWTProxy[:vertical] }
31
35
  super(parent, args, block)
32
36
  end
37
+
38
+ def horizontal
39
+ !vertical
40
+ end
41
+ alias horizontal? horizontal
33
42
 
34
43
  def text=(value)
35
44
  @text = value
36
- dom_element.html(html_text) # TODO deal with issue of handling lines and escaping at the same time
45
+ dom_element.html(html_text) unless @image
37
46
  end
38
47
 
39
48
  def html_text
40
49
  text && CGI.escape_html(text).gsub("\n", '<br />')
41
50
  end
42
51
 
43
- # def background_image=(*image_options)
44
- # TODO consider if there is a difference between background_image and image in label and to have one reuse the other
45
- # TODO finish implementation
46
- # @background_image = Glimmer::SWT::ImageProxy.create(*image_options)
47
- # dom_element.css('background-image', @background_image.image_data.dom_element.src)
48
- # end
49
-
50
- def image=(*image_options)
51
- # TODO finish implementation
52
- # @image = Glimmer::SWT::ImageProxy.create(*image_options)
53
- # dom_element.css('background-image', @image.image_data.dom_element.src)
54
- end
55
-
56
- # background image
57
- def background_image
58
- @background_image
52
+ def image=(value)
53
+ @image = value
54
+ dom_element.html("<img src='#{@image}' />")
59
55
  end
60
56
 
61
57
  # background image is stretched by default
62
58
  def background_image=(value)
63
59
  @background_image = value
64
- dom_element.css('background-image', "url(#{background_image})")
60
+ dom_element.css('background-image', "url(#{@background_image})")
65
61
  dom_element.css('background-repeat', 'no-repeat')
66
62
  dom_element.css('background-size', 'cover')
67
63
  end
@@ -88,8 +84,11 @@ module Glimmer
88
84
  def dom
89
85
  label_id = id
90
86
  label_class = name
87
+ label_style = "text-align: #{alignment}; "
88
+ label_style += "border-top: 1px solid rgb(207, 207, 207); " if separator? && horizontal?
89
+ label_style += "border-right: 1px solid rgb(207, 207, 207); height: 100%; " if separator? && vertical?
91
90
  @dom ||= html {
92
- label(id: label_id, class: label_class, style: "text-align: #{alignment};") {
91
+ label(id: label_id, class: label_class, style: label_style) {
93
92
  html_text
94
93
  }
95
94
  }.to_s
@@ -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?
@@ -216,6 +241,11 @@ module Glimmer
216
241
  def dialog_ancestor
217
242
  parents.detect {|p| p.is_a?(DialogProxy)}
218
243
  end
244
+
245
+ def print
246
+ `window.print()`
247
+ true
248
+ end
219
249
 
220
250
  def enabled=(value)
221
251
  @enabled = value
@@ -242,6 +272,11 @@ module Glimmer
242
272
  dom_element.css('font-size', "#{@font.height}px") unless @font.nil?
243
273
  end
244
274
 
275
+ def cursor=(value)
276
+ @cursor = value
277
+ dom_element.css('cursor', css_cursor)
278
+ end
279
+
245
280
  def focus=(value)
246
281
  @focus = value
247
282
  dom_element.focus # TODO consider if a delay or async_exec is needed here
@@ -968,6 +1003,12 @@ module Glimmer
968
1003
  }
969
1004
  end
970
1005
 
1006
+ private
1007
+
1008
+ def css_cursor
1009
+ SWT_CURSOR_TO_CSS_CURSOR_MAP[@cursor]
1010
+ end
1011
+
971
1012
  end
972
1013
  end
973
1014
  end
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.21.0
4
+ version: 0.24.0
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-17 00:00:00.000000000 Z
11
+ date: 2021-08-18 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,17 +295,20 @@ 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
300
302
  - lib/glimmer-dsl-opal/samples/hello/hello_dialog.rb
301
303
  - lib/glimmer-dsl-opal/samples/hello/hello_group.rb
304
+ - lib/glimmer-dsl-opal/samples/hello/hello_label.rb
302
305
  - lib/glimmer-dsl-opal/samples/hello/hello_layout.rb
303
306
  - lib/glimmer-dsl-opal/samples/hello/hello_list_multi_selection.rb
304
307
  - lib/glimmer-dsl-opal/samples/hello/hello_list_single_selection.rb
305
308
  - lib/glimmer-dsl-opal/samples/hello/hello_menu_bar.rb
306
309
  - lib/glimmer-dsl-opal/samples/hello/hello_message_box.rb
307
310
  - lib/glimmer-dsl-opal/samples/hello/hello_pop_up_context_menu.rb
311
+ - lib/glimmer-dsl-opal/samples/hello/hello_print.rb
308
312
  - lib/glimmer-dsl-opal/samples/hello/hello_radio.rb
309
313
  - lib/glimmer-dsl-opal/samples/hello/hello_radio_group.rb
310
314
  - lib/glimmer-dsl-opal/samples/hello/hello_scale.rb