glimmer-dsl-opal 0.22.0 → 0.25.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/README.md +177 -59
- data/VERSION +1 -1
- data/lib/glimmer-dsl-opal/samples/elaborate/user_profile.rb +78 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_combo.rb +2 -2
- data/lib/glimmer-dsl-opal/samples/hello/hello_computed.rb +14 -22
- data/lib/glimmer-dsl-opal/samples/hello/hello_label.rb +192 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_print.rb +58 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_progress_bar.rb +126 -0
- data/lib/glimmer/swt/c_tab_item_proxy.rb +1 -1
- data/lib/glimmer/swt/label_proxy.rb +19 -20
- data/lib/glimmer/swt/progress_bar_proxy.rb +86 -0
- data/lib/glimmer/swt/widget_proxy.rb +6 -0
- metadata +9 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3acd64cce93e2c522567f6b10967489a8edb74e19aad32d9b6aef070f8339715
|
4
|
+
data.tar.gz: 78adb831387641339c046839bf8ccd034354881a1a963c0eb7084c4065167c2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 340aa792a59e2577c818461ef4ebe88a01b06a8becf19e2f138c8895cdfa691872d227ea9c490f1bb48d14fd6edf3bb2b65aabe8f21bb0982e8fcf4bfdb2d5e1
|
7
|
+
data.tar.gz: c5509de40b089c73879d46aabb4c7440698eda864acd80509e1496b7bb1ca0558b47c399c96d28b295fa9ec088dffdaf7958861f23dcb9b4b24bbb58a798561d
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,25 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.25.0
|
4
|
+
|
5
|
+
- Support `progress_bar` widget without `:vertical` SWT style support
|
6
|
+
- Hello, Progress Bar! sample without `:vertical` SWT style
|
7
|
+
|
8
|
+
## 0.24.0
|
9
|
+
|
10
|
+
- `widget#print` method
|
11
|
+
- Hello, Print! sample
|
12
|
+
|
13
|
+
## 0.23.0
|
14
|
+
|
15
|
+
- Hello, Label! sample
|
16
|
+
- Support `label` `:separator` SWT style along with `:horizontal` or `:vertical`
|
17
|
+
- Support `label` `image` attribute
|
18
|
+
|
19
|
+
## 0.22.1
|
20
|
+
|
21
|
+
- User Profile elaborate sample
|
22
|
+
|
3
23
|
## 0.22.0
|
4
24
|
|
5
25
|
- Support widget `cursor` attribute
|
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.
|
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)
|
@@ -166,6 +166,7 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
|
|
166
166
|
- [Hello, Composite!](#hello-composite)
|
167
167
|
- [Hello, Computed!](#hello-computed)
|
168
168
|
- [Hello, Cursor!](#hello-cursor)
|
169
|
+
- [Hello, Label!](#hello-label)
|
169
170
|
- [Hello, Layout!](#hello-layout)
|
170
171
|
- [Hello, List Single Selection!](#hello-list-single-selection)
|
171
172
|
- [Hello, List Multi Selection!](#hello-list-multi-selection)
|
@@ -186,12 +187,15 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
|
|
186
187
|
- [Hello, Arrow!](#hello-arrow)
|
187
188
|
- [Hello, Message Box!](#hello-message-box)
|
188
189
|
- [Hello, Pop Up Context Menu!](#hello-pop-up-context-menu)
|
190
|
+
- [Hello, Print!](#hello-print)
|
191
|
+
- [Hello, Progress Bar!](#hello-progress-bar)
|
189
192
|
- [Hello, Menu Bar!](#hello-menu-bar)
|
190
193
|
- [Hello, Dialog!](#hello-dialog)
|
191
194
|
- [Elaborate Samples](#elaborate-samples)
|
192
195
|
- [Login](#login)
|
193
|
-
- [Tic Tac Toe](#tic-tac-toe)
|
194
196
|
- [Contact Manager](#contact-manager)
|
197
|
+
- [Tic Tac Toe](#tic-tac-toe)
|
198
|
+
- [User Profile](#user-profile)
|
195
199
|
- [Weather](#weather)
|
196
200
|
- [External Samples](#external-samples)
|
197
201
|
- [Glimmer Calculator](#glimmer-calculator)
|
@@ -260,9 +264,9 @@ Add the following to `Gemfile`:
|
|
260
264
|
```
|
261
265
|
gem 'opal', '1.0.4'
|
262
266
|
gem 'opal-rails', '1.1.2'
|
263
|
-
gem 'opal-async', '~> 1.
|
267
|
+
gem 'opal-async', '~> 1.3.0'
|
264
268
|
gem 'opal-jquery', '~> 0.4.4'
|
265
|
-
gem 'glimmer-dsl-opal', '~> 0.
|
269
|
+
gem 'glimmer-dsl-opal', '~> 0.24.0'
|
266
270
|
gem 'glimmer-dsl-xml', '~> 1.2.0', require: false
|
267
271
|
gem 'glimmer-dsl-css', '~> 1.2.0', require: false
|
268
272
|
|
@@ -470,9 +474,9 @@ class HelloCombo
|
|
470
474
|
|
471
475
|
include Glimmer::UI::CustomShell
|
472
476
|
|
473
|
-
before_body
|
477
|
+
before_body do
|
474
478
|
@person = Person.new
|
475
|
-
|
479
|
+
end
|
476
480
|
|
477
481
|
body {
|
478
482
|
shell {
|
@@ -576,13 +580,13 @@ class HelloComputed
|
|
576
580
|
|
577
581
|
include Glimmer::UI::CustomShell
|
578
582
|
|
579
|
-
before_body
|
583
|
+
before_body do
|
580
584
|
@contact = Contact.new(
|
581
585
|
first_name: 'Barry',
|
582
586
|
last_name: 'McKibbin',
|
583
587
|
year_of_birth: 1985
|
584
588
|
)
|
585
|
-
|
589
|
+
end
|
586
590
|
|
587
591
|
body {
|
588
592
|
shell {
|
@@ -598,51 +602,43 @@ class HelloComputed
|
|
598
602
|
|
599
603
|
label {text 'First &Name: '}
|
600
604
|
text {
|
605
|
+
fill_horizontally_layout_data
|
601
606
|
text <=> [@contact, :first_name]
|
602
|
-
layout_data {
|
603
|
-
horizontal_alignment :fill
|
604
|
-
grab_excess_horizontal_space true
|
605
|
-
}
|
606
607
|
}
|
607
608
|
|
608
609
|
label {text '&Last Name: '}
|
609
610
|
text {
|
611
|
+
fill_horizontally_layout_data
|
610
612
|
text <=> [@contact, :last_name]
|
611
|
-
layout_data {
|
612
|
-
horizontal_alignment :fill
|
613
|
-
grab_excess_horizontal_space true
|
614
|
-
}
|
615
613
|
}
|
616
614
|
|
617
615
|
label {text '&Year of Birth: '}
|
618
616
|
text {
|
617
|
+
fill_horizontally_layout_data
|
619
618
|
text <=> [@contact, :year_of_birth]
|
620
|
-
layout_data {
|
621
|
-
horizontal_alignment :fill
|
622
|
-
grab_excess_horizontal_space true
|
623
|
-
}
|
624
619
|
}
|
625
620
|
|
626
621
|
label {text 'Name: '}
|
627
622
|
label {
|
623
|
+
fill_horizontally_layout_data
|
628
624
|
text <= [@contact, :name, computed_by: [:first_name, :last_name]]
|
629
|
-
layout_data {
|
630
|
-
horizontal_alignment :fill
|
631
|
-
grab_excess_horizontal_space true
|
632
|
-
}
|
633
625
|
}
|
634
626
|
|
635
627
|
label {text 'Age: '}
|
636
628
|
label {
|
629
|
+
fill_horizontally_layout_data
|
637
630
|
text <= [@contact, :age, on_write: :to_i, computed_by: [:year_of_birth]]
|
638
|
-
layout_data {
|
639
|
-
horizontal_alignment :fill
|
640
|
-
grab_excess_horizontal_space true
|
641
|
-
}
|
642
631
|
}
|
643
632
|
}
|
644
633
|
}
|
645
634
|
}
|
635
|
+
|
636
|
+
def fill_horizontally_layout_data
|
637
|
+
layout_data {
|
638
|
+
horizontal_alignment :fill
|
639
|
+
grab_excess_horizontal_space true
|
640
|
+
}
|
641
|
+
end
|
646
642
|
end
|
647
643
|
|
648
644
|
HelloComputed.launch
|
@@ -690,6 +686,56 @@ You should see "Hello, Cursor!"
|
|
690
686
|
|
691
687
|
![Glimmer DSL for Opal Hello Cursor](images/glimmer-dsl-opal-hello-cursor.gif)
|
692
688
|
|
689
|
+
#### Hello, Label!
|
690
|
+
|
691
|
+
Add the following require statement to `app/assets/javascripts/application.rb`
|
692
|
+
|
693
|
+
|
694
|
+
```ruby
|
695
|
+
require 'glimmer-dsl-opal/samples/hello/hello_label'
|
696
|
+
```
|
697
|
+
|
698
|
+
Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
|
699
|
+
|
700
|
+
![Glimmer DSL for SWT Hello Label](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-label-left-aligned.png)
|
701
|
+
|
702
|
+
![Glimmer DSL for SWT Hello Label](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-label-center-aligned.png)
|
703
|
+
|
704
|
+
![Glimmer DSL for SWT Hello Label](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-label-right-aligned.png)
|
705
|
+
|
706
|
+
![Glimmer DSL for SWT Hello Label](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-label-images.png)
|
707
|
+
|
708
|
+
![Glimmer DSL for SWT Hello Label](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-label-background_images.png)
|
709
|
+
|
710
|
+
![Glimmer DSL for SWT Hello Label](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-label-horizontal-separator.png)
|
711
|
+
|
712
|
+
![Glimmer DSL for SWT Hello Label](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-label-vertical-separator.png)
|
713
|
+
|
714
|
+
Glimmer app on the web (using `glimmer-dsl-opal` gem):
|
715
|
+
|
716
|
+
Start the Rails server:
|
717
|
+
```
|
718
|
+
rails s
|
719
|
+
```
|
720
|
+
|
721
|
+
Visit `http://localhost:3000`
|
722
|
+
|
723
|
+
You should see "Hello, Label!"
|
724
|
+
|
725
|
+
![Glimmer DSL for Opal Hello Label](images/glimmer-dsl-opal-hello-label-left-aligned.png)
|
726
|
+
|
727
|
+
![Glimmer DSL for Opal Hello Label](images/glimmer-dsl-opal-hello-label-center-aligned.png)
|
728
|
+
|
729
|
+
![Glimmer DSL for Opal Hello Label](images/glimmer-dsl-opal-hello-label-right-aligned.png)
|
730
|
+
|
731
|
+
![Glimmer DSL for Opal Hello Label](images/glimmer-dsl-opal-hello-label-images.png)
|
732
|
+
|
733
|
+
![Glimmer DSL for Opal Hello Label](images/glimmer-dsl-opal-hello-label-background_images.png)
|
734
|
+
|
735
|
+
![Glimmer DSL for Opal Hello Label](images/glimmer-dsl-opal-hello-label-horizontal-separator.png)
|
736
|
+
|
737
|
+
![Glimmer DSL for Opal Hello Label](images/glimmer-dsl-opal-hello-label-vertical-separator.png)
|
738
|
+
|
693
739
|
#### Hello, Layout!
|
694
740
|
|
695
741
|
Add the following require statement to `app/assets/javascripts/application.rb`
|
@@ -1789,6 +1835,52 @@ You should see "Hello, Message Box!"
|
|
1789
1835
|
![Glimmer DSL for Opal Hello Message Box](images/glimmer-dsl-opal-hello-message-box.png)
|
1790
1836
|
![Glimmer DSL for Opal Hello Message Box Dialog](images/glimmer-dsl-opal-hello-message-box-dialog.png)
|
1791
1837
|
|
1838
|
+
#### Hello, Print!
|
1839
|
+
|
1840
|
+
Add the following require statement to `app/assets/javascripts/application.rb`
|
1841
|
+
|
1842
|
+
```ruby
|
1843
|
+
require 'glimmer-dsl-opal/samples/hello/hello_print'
|
1844
|
+
```
|
1845
|
+
|
1846
|
+
Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
|
1847
|
+
|
1848
|
+
![Glimmer DSL for SWT Hello Print](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-print.png)
|
1849
|
+
|
1850
|
+
Glimmer app on the web (using `glimmer-dsl-opal` gem):
|
1851
|
+
|
1852
|
+
Start the Rails server:
|
1853
|
+
```
|
1854
|
+
rails s
|
1855
|
+
```
|
1856
|
+
|
1857
|
+
Visit `http://localhost:3000`
|
1858
|
+
|
1859
|
+
You should see "Hello, Print!"
|
1860
|
+
|
1861
|
+
#### Hello, Progress Bar!
|
1862
|
+
|
1863
|
+
Add the following require statement to `app/assets/javascripts/application.rb`
|
1864
|
+
|
1865
|
+
```ruby
|
1866
|
+
require 'glimmer-dsl-opal/samples/hello/hello_progress_bar'
|
1867
|
+
```
|
1868
|
+
|
1869
|
+
Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
|
1870
|
+
|
1871
|
+
![Glimmer DSL for SWT Hello Progress Bar](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-progress-bar.gif)
|
1872
|
+
|
1873
|
+
Glimmer app on the web (using `glimmer-dsl-opal` gem):
|
1874
|
+
|
1875
|
+
Start the Rails server:
|
1876
|
+
```
|
1877
|
+
rails s
|
1878
|
+
```
|
1879
|
+
|
1880
|
+
Visit `http://localhost:3000`
|
1881
|
+
|
1882
|
+
You should see "Hello, Progress Bar!"
|
1883
|
+
|
1792
1884
|
#### Hello, Pop Up Context Menu!
|
1793
1885
|
|
1794
1886
|
Add the following require statement to `app/assets/javascripts/application.rb`
|
@@ -2427,36 +2519,6 @@ You should see "Login" dialog
|
|
2427
2519
|
![Glimmer DSL for Opal Login Filled In](images/glimmer-dsl-opal-login-filled-in.png)
|
2428
2520
|
![Glimmer DSL for Opal Login Logged In](images/glimmer-dsl-opal-login-logged-in.png)
|
2429
2521
|
|
2430
|
-
#### Tic Tac Toe
|
2431
|
-
|
2432
|
-
Add the following require statement to `app/assets/javascripts/application.rb`
|
2433
|
-
|
2434
|
-
```ruby
|
2435
|
-
require 'glimmer-dsl-opal/samples/elaborate/tic_tac_toe'
|
2436
|
-
```
|
2437
|
-
|
2438
|
-
```ruby
|
2439
|
-
Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
|
2440
|
-
|
2441
|
-
![Glimmer DSL for SWT Tic Tac Toe](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-tic-tac-toe.png)
|
2442
|
-
![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)
|
2443
|
-
![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)
|
2444
|
-
|
2445
|
-
Glimmer app on the web (using `glimmer-dsl-opal` gem):
|
2446
|
-
|
2447
|
-
Start the Rails server:
|
2448
|
-
```
|
2449
|
-
rails s
|
2450
|
-
```
|
2451
|
-
|
2452
|
-
Visit `http://localhost:3000`
|
2453
|
-
|
2454
|
-
You should see "Tic Tac Toe"
|
2455
|
-
|
2456
|
-
![Glimmer DSL for Opal Tic Tac Toe](images/glimmer-dsl-opal-tic-tac-toe.png)
|
2457
|
-
![Glimmer DSL for Opal Tic Tac Toe In Progress](images/glimmer-dsl-opal-tic-tac-toe-in-progress.png)
|
2458
|
-
![Glimmer DSL for Opal Tic Tac Toe Game Over](images/glimmer-dsl-opal-tic-tac-toe-game-over.png)
|
2459
|
-
|
2460
2522
|
#### Contact Manager
|
2461
2523
|
|
2462
2524
|
Add the following require statement to `app/assets/javascripts/application.rb`
|
@@ -2496,7 +2558,7 @@ rails s
|
|
2496
2558
|
|
2497
2559
|
Visit `http://localhost:3000`
|
2498
2560
|
|
2499
|
-
You should see "
|
2561
|
+
You should see "Contact Manager"
|
2500
2562
|
|
2501
2563
|
Glimmer DSL for Opal Contact Manager
|
2502
2564
|
|
@@ -2518,6 +2580,62 @@ Glimmer DSL for Opal Contact Manager Edit Done
|
|
2518
2580
|
|
2519
2581
|
![Glimmer DSL for Opal Contact Manager Edit Done](images/glimmer-dsl-opal-contact-manager-edit-done.png)
|
2520
2582
|
|
2583
|
+
#### Tic Tac Toe
|
2584
|
+
|
2585
|
+
Add the following require statement to `app/assets/javascripts/application.rb`
|
2586
|
+
|
2587
|
+
```ruby
|
2588
|
+
require 'glimmer-dsl-opal/samples/elaborate/tic_tac_toe'
|
2589
|
+
```
|
2590
|
+
|
2591
|
+
Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
|
2592
|
+
|
2593
|
+
![Glimmer DSL for SWT Tic Tac Toe](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-tic-tac-toe.png)
|
2594
|
+
![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)
|
2595
|
+
![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)
|
2596
|
+
|
2597
|
+
Glimmer app on the web (using `glimmer-dsl-opal` gem):
|
2598
|
+
|
2599
|
+
Start the Rails server:
|
2600
|
+
```
|
2601
|
+
rails s
|
2602
|
+
```
|
2603
|
+
|
2604
|
+
Visit `http://localhost:3000`
|
2605
|
+
|
2606
|
+
You should see "Tic Tac Toe"
|
2607
|
+
|
2608
|
+
![Glimmer DSL for Opal Tic Tac Toe](images/glimmer-dsl-opal-tic-tac-toe.png)
|
2609
|
+
![Glimmer DSL for Opal Tic Tac Toe In Progress](images/glimmer-dsl-opal-tic-tac-toe-in-progress.png)
|
2610
|
+
![Glimmer DSL for Opal Tic Tac Toe Game Over](images/glimmer-dsl-opal-tic-tac-toe-game-over.png)
|
2611
|
+
|
2612
|
+
#### User Profile
|
2613
|
+
|
2614
|
+
Code: [lib/glimmer-dsl-opal/samples/elaborate/user_profile](lib/glimmer-dsl-opal/samples/elaborate/user_profile.rb)
|
2615
|
+
|
2616
|
+
Add the following require statement to `app/assets/javascripts/application.rb`
|
2617
|
+
|
2618
|
+
```ruby
|
2619
|
+
require 'glimmer-dsl-opal/samples/elaborate/user_profile'
|
2620
|
+
```
|
2621
|
+
|
2622
|
+
Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
|
2623
|
+
|
2624
|
+
![User Profile](https://github.com/AMaleh/glimmer-dsl-swt/raw/master/images/glimmer-user-profile.png)
|
2625
|
+
|
2626
|
+
Glimmer app on the web (using `glimmer-dsl-opal` gem):
|
2627
|
+
|
2628
|
+
Start the Rails server:
|
2629
|
+
```
|
2630
|
+
rails s
|
2631
|
+
```
|
2632
|
+
|
2633
|
+
Visit `http://localhost:3000`
|
2634
|
+
|
2635
|
+
You should see "User Profile"
|
2636
|
+
|
2637
|
+
![Opal User Profile](/images/glimmer-dsl-opal-user-profile.png)
|
2638
|
+
|
2521
2639
|
#### Weather
|
2522
2640
|
|
2523
2641
|
Code: [lib/glimmer-dsl-opal/samples/elaborate/weather](lib/glimmer-dsl-opal/samples/elaborate/weather.rb)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.25.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
|
@@ -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,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
|
@@ -0,0 +1,126 @@
|
|
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 HelloProgressBar
|
23
|
+
include Glimmer::UI::CustomShell
|
24
|
+
|
25
|
+
class ProgressModel
|
26
|
+
attr_accessor :minimum, :maximum, :selection, :delay
|
27
|
+
end
|
28
|
+
|
29
|
+
before_body do
|
30
|
+
@progress_model = ProgressModel.new
|
31
|
+
@progress_model.minimum = 0
|
32
|
+
@progress_model.maximum = 100
|
33
|
+
@progress_model.selection = 0
|
34
|
+
@progress_model.delay = 0.01
|
35
|
+
end
|
36
|
+
|
37
|
+
body {
|
38
|
+
shell {
|
39
|
+
grid_layout(4, true)
|
40
|
+
|
41
|
+
text 'Hello, Progress Bar!'
|
42
|
+
|
43
|
+
progress_bar(:indeterminate) {
|
44
|
+
layout_data(:fill, :center, true, false) {
|
45
|
+
horizontal_span 4
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
label {
|
50
|
+
text 'Minimum'
|
51
|
+
}
|
52
|
+
|
53
|
+
label {
|
54
|
+
text 'Maximum'
|
55
|
+
}
|
56
|
+
|
57
|
+
label {
|
58
|
+
text 'Selection'
|
59
|
+
}
|
60
|
+
|
61
|
+
label {
|
62
|
+
text 'Delay in Seconds'
|
63
|
+
}
|
64
|
+
|
65
|
+
spinner {
|
66
|
+
selection <=> [@progress_model, :minimum]
|
67
|
+
}
|
68
|
+
|
69
|
+
spinner {
|
70
|
+
selection <=> [@progress_model, :maximum]
|
71
|
+
}
|
72
|
+
|
73
|
+
spinner {
|
74
|
+
selection <=> [@progress_model, :selection]
|
75
|
+
}
|
76
|
+
|
77
|
+
spinner {
|
78
|
+
digits 2
|
79
|
+
minimum 1
|
80
|
+
maximum 200
|
81
|
+
selection <=> [@progress_model, :delay, on_read: ->(v) {v.to_f*100.0}, on_write: ->(v) {v.to_f/100.0}]
|
82
|
+
}
|
83
|
+
|
84
|
+
progress_bar {
|
85
|
+
layout_data(:fill, :center, true, false) {
|
86
|
+
horizontal_span 4
|
87
|
+
}
|
88
|
+
minimum <= [@progress_model, :minimum]
|
89
|
+
maximum <= [@progress_model, :maximum]
|
90
|
+
selection <= [@progress_model, :selection]
|
91
|
+
}
|
92
|
+
|
93
|
+
# :vertical SWT style is unsupported for now
|
94
|
+
# progress_bar(:vertical) {
|
95
|
+
# layout_data(:fill, :center, true, false) {
|
96
|
+
# horizontal_span 4
|
97
|
+
# }
|
98
|
+
# minimum <= [@progress_model, :minimum]
|
99
|
+
# maximum <= [@progress_model, :maximum]
|
100
|
+
# selection <= [@progress_model, :selection]
|
101
|
+
# }
|
102
|
+
|
103
|
+
button {
|
104
|
+
layout_data(:fill, :center, true, false) {
|
105
|
+
horizontal_span 4
|
106
|
+
}
|
107
|
+
text "Start"
|
108
|
+
|
109
|
+
on_widget_selected do
|
110
|
+
# if a previous thread is running, then kill first
|
111
|
+
# (killing is not dangerous since it is only a thread about updating progress)
|
112
|
+
@current_thread&.kill
|
113
|
+
@current_thread = Thread.new do
|
114
|
+
@progress_model.selection = @progress_model.minimum
|
115
|
+
(@progress_model.minimum..@progress_model.maximum).to_a.each do |n|
|
116
|
+
@progress_model.selection = n
|
117
|
+
sleep(@progress_model.delay)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
}
|
122
|
+
}
|
123
|
+
}
|
124
|
+
end
|
125
|
+
|
126
|
+
HelloProgressBar.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[
|
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)
|
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
|
-
|
44
|
-
|
45
|
-
#
|
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:
|
91
|
+
label(id: label_id, class: label_class, style: label_style) {
|
93
92
|
html_text
|
94
93
|
}
|
95
94
|
}.to_s
|
@@ -0,0 +1,86 @@
|
|
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 ProgressBarProxy < WidgetProxy
|
27
|
+
STYLE = <<~CSS
|
28
|
+
.ui-progressbar.vertical {
|
29
|
+
/* Not Supported */
|
30
|
+
/* transform: rotate(-90deg); */
|
31
|
+
}
|
32
|
+
CSS
|
33
|
+
|
34
|
+
attr_reader :vertical, :indeterminate, :maximum, :selection
|
35
|
+
attr_accessor :state, :minimum #ignored, only there for API compatibility
|
36
|
+
alias vertical? vertical
|
37
|
+
alias indeterminate? indeterminate
|
38
|
+
|
39
|
+
def initialize(parent, args, block)
|
40
|
+
@vertical = args.detect { |arg| SWTProxy[arg] == SWTProxy[:vertical] }
|
41
|
+
@indeterminate = args.detect { |arg| SWTProxy[arg] == SWTProxy[:indeterminate] }
|
42
|
+
super(parent, args, block)
|
43
|
+
dom_element.progressbar
|
44
|
+
self.minimum = 0
|
45
|
+
self.selection = false if indeterminate?
|
46
|
+
end
|
47
|
+
|
48
|
+
def horizontal
|
49
|
+
!vertical
|
50
|
+
end
|
51
|
+
alias horizontal? horizontal
|
52
|
+
|
53
|
+
def minimum=(value)
|
54
|
+
@minimum = value
|
55
|
+
# re-update maximum and selection since they depend on minimum
|
56
|
+
self.maximum = @maximum if @maximum
|
57
|
+
self.selection = @selection if @selection
|
58
|
+
end
|
59
|
+
|
60
|
+
def maximum=(value)
|
61
|
+
@maximum = value
|
62
|
+
dom_element.progressbar('option', 'max', @maximum - @minimum)
|
63
|
+
end
|
64
|
+
|
65
|
+
def selection=(selection_value)
|
66
|
+
@selection = selection_value
|
67
|
+
value = @selection ? (@selection - @minimum) : @selection
|
68
|
+
dom_element.progressbar('option', 'value', value)
|
69
|
+
end
|
70
|
+
|
71
|
+
def element
|
72
|
+
'div'
|
73
|
+
end
|
74
|
+
|
75
|
+
def dom
|
76
|
+
progress_bar_id = id
|
77
|
+
progress_bar_class = name
|
78
|
+
progress_bar_class += ' vertical' if vertical?
|
79
|
+
progress_bar_class += ' indeterminate' if indeterminate?
|
80
|
+
@dom ||= html {
|
81
|
+
div(id: progress_bar_id, class: progress_bar_class)
|
82
|
+
}.to_s
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -241,6 +241,11 @@ module Glimmer
|
|
241
241
|
def dialog_ancestor
|
242
242
|
parents.detect {|p| p.is_a?(DialogProxy)}
|
243
243
|
end
|
244
|
+
|
245
|
+
def print
|
246
|
+
`window.print()`
|
247
|
+
true
|
248
|
+
end
|
244
249
|
|
245
250
|
def enabled=(value)
|
246
251
|
@enabled = value
|
@@ -1032,6 +1037,7 @@ require 'glimmer/swt/table_column_proxy'
|
|
1032
1037
|
require 'glimmer/swt/table_item_proxy'
|
1033
1038
|
require 'glimmer/swt/table_proxy'
|
1034
1039
|
require 'glimmer/swt/text_proxy'
|
1040
|
+
require 'glimmer/swt/progress_bar_proxy'
|
1035
1041
|
require 'glimmer/swt/radio_proxy'
|
1036
1042
|
require 'glimmer/swt/scale_proxy'
|
1037
1043
|
require 'glimmer/swt/scrolled_composite_proxy'
|
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.
|
4
|
+
version: 0.25.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-
|
11
|
+
date: 2021-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.
|
61
|
+
version: 1.3.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.
|
68
|
+
version: 1.3.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: to_collection
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -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
|
@@ -300,12 +301,15 @@ files:
|
|
300
301
|
- lib/glimmer-dsl-opal/samples/hello/hello_date_time.rb
|
301
302
|
- lib/glimmer-dsl-opal/samples/hello/hello_dialog.rb
|
302
303
|
- lib/glimmer-dsl-opal/samples/hello/hello_group.rb
|
304
|
+
- lib/glimmer-dsl-opal/samples/hello/hello_label.rb
|
303
305
|
- lib/glimmer-dsl-opal/samples/hello/hello_layout.rb
|
304
306
|
- lib/glimmer-dsl-opal/samples/hello/hello_list_multi_selection.rb
|
305
307
|
- lib/glimmer-dsl-opal/samples/hello/hello_list_single_selection.rb
|
306
308
|
- lib/glimmer-dsl-opal/samples/hello/hello_menu_bar.rb
|
307
309
|
- lib/glimmer-dsl-opal/samples/hello/hello_message_box.rb
|
308
310
|
- lib/glimmer-dsl-opal/samples/hello/hello_pop_up_context_menu.rb
|
311
|
+
- lib/glimmer-dsl-opal/samples/hello/hello_print.rb
|
312
|
+
- lib/glimmer-dsl-opal/samples/hello/hello_progress_bar.rb
|
309
313
|
- lib/glimmer-dsl-opal/samples/hello/hello_radio.rb
|
310
314
|
- lib/glimmer-dsl-opal/samples/hello/hello_radio_group.rb
|
311
315
|
- lib/glimmer-dsl-opal/samples/hello/hello_scale.rb
|
@@ -419,6 +423,7 @@ files:
|
|
419
423
|
- lib/glimmer/swt/menu_proxy.rb
|
420
424
|
- lib/glimmer/swt/message_box_proxy.rb
|
421
425
|
- lib/glimmer/swt/point.rb
|
426
|
+
- lib/glimmer/swt/progress_bar_proxy.rb
|
422
427
|
- lib/glimmer/swt/property_owner.rb
|
423
428
|
- lib/glimmer/swt/radio_proxy.rb
|
424
429
|
- lib/glimmer/swt/row_layout_proxy.rb
|