glimmer-dsl-opal 0.17.0 → 0.20.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 +23 -1
- data/README.md +97 -4
- data/VERSION +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_c_combo.rb +67 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_c_tab.rb +172 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_spinner.rb +78 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_tab.rb +10 -8
- data/lib/glimmer-dsl-opal/samples/hello/images/denmark.png +0 -0
- data/lib/glimmer-dsl-opal/samples/hello/images/finland.png +0 -0
- data/lib/glimmer-dsl-opal/samples/hello/images/france.png +0 -0
- data/lib/glimmer-dsl-opal/samples/hello/images/germany.png +0 -0
- data/lib/glimmer-dsl-opal/samples/hello/images/italy.png +0 -0
- data/lib/glimmer-dsl-opal/samples/hello/images/mexico.png +0 -0
- data/lib/glimmer-dsl-opal/samples/hello/images/netherlands.png +0 -0
- data/lib/glimmer-dsl-opal/samples/hello/images/norway.png +0 -0
- data/lib/glimmer-dsl-opal/samples/hello/images/usa.png +0 -0
- data/lib/glimmer/swt/c_combo_proxy.rb +51 -0
- data/lib/glimmer/swt/c_tab_folder_proxy.rb +43 -0
- data/lib/glimmer/swt/c_tab_item_proxy.rb +96 -0
- data/lib/glimmer/swt/combo_proxy.rb +3 -0
- data/lib/glimmer/swt/shell_proxy.rb +4 -0
- data/lib/glimmer/swt/spinner_proxy.rb +173 -0
- data/lib/glimmer/swt/tab_folder_proxy.rb +12 -10
- data/lib/glimmer/swt/tab_item_proxy.rb +52 -4
- data/lib/glimmer/swt/widget_proxy.rb +14 -2
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 531f953f5ec4fe36dfa9a7bc8e7a98e5155c8dced489215e74b6679543feff1b
|
4
|
+
data.tar.gz: 3e429ff4bac544027a49e458c75b670adf0d3f6110da692f151da6153511e889
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2822a5d9881c20c06c31b4a1115cf08a1cc5e79db5da15ca2cf8491a9f1c9e7114ccb8380e94af27b55f14e7e533a2247890cd11ea06bd2d8a82b7038c9e628d
|
7
|
+
data.tar.gz: ea93b2b373f4aea2c742c09d1e05752899c91ba62d12b5e5cde96492631984cf49e70fcbc8d744ea516ac2bbd42fc00bd58d84b0cc8f297cb04d0d6a45d34210
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,27 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.20.0
|
4
|
+
|
5
|
+
- Support `spinner` widget (leaving out automatic insertion of decimal point when digits are specified)
|
6
|
+
- Hello, Spinner! sample
|
7
|
+
|
8
|
+
## 0.19.1
|
9
|
+
|
10
|
+
- Fix widget `font` property support for both `:bold` and `:italic` styles at the same time
|
11
|
+
|
12
|
+
## 0.19.0
|
13
|
+
|
14
|
+
- Change `tab_item` default background/foreground color to better match Glimmer DSL for SWT
|
15
|
+
- Support `tab_item` `tool_tip_text` attribute
|
16
|
+
- Support `tab_item` `image` attribute
|
17
|
+
- Implement `c_tab_folder` & `c_tab_item` (without the dropdown for hidden tabs that is in Glimmer DSL for SWT)
|
18
|
+
- Hello, C Tab! sample
|
19
|
+
|
20
|
+
## 0.18.0
|
21
|
+
|
22
|
+
- Implement `c_combo`
|
23
|
+
- Hello, C Combo! sample
|
24
|
+
|
3
25
|
## 0.17.0
|
4
26
|
|
5
27
|
- Support `menu` `visible` attribute to enable programmatic display of menu
|
@@ -22,7 +44,7 @@
|
|
22
44
|
|
23
45
|
## 0.16.0
|
24
46
|
|
25
|
-
- Support label widget background_image attribute
|
47
|
+
- Support `label` widget `background_image` attribute
|
26
48
|
- Have File.expand_path support expanding paths even if they did not base off of __dir__ or __FILE__
|
27
49
|
- Custom specification of gems having image paths via server-side configuration in Glimmer::Config.gems_having_image_paths
|
28
50
|
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for Opal
|
1
|
+
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for Opal [Alpha] (Pure Ruby Web GUI)
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/glimmer-dsl-opal.svg)](http://badge.fury.io/rb/glimmer-dsl-opal)
|
3
3
|
[![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
4
4
|
|
@@ -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.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))
|
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)
|
@@ -153,7 +153,7 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
|
|
153
153
|
|
154
154
|
## Table of Contents
|
155
155
|
|
156
|
-
- [Glimmer DSL for Opal
|
156
|
+
- [Glimmer DSL for Opal [Alpha] (Pure Ruby Web GUI)](#-glimmer-dsl-for-opal-alpha-pure-ruby-web-gui)
|
157
157
|
- [Principles](#principles)
|
158
158
|
- [Background](#background)
|
159
159
|
- [Pre-requisites](#pre-requisites)
|
@@ -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, Layout!](#hello-layout)
|
168
169
|
- [Hello, List Single Selection!](#hello-list-single-selection)
|
169
170
|
- [Hello, List Multi Selection!](#hello-list-multi-selection)
|
170
171
|
- [Hello, Browser!](#hello-browser)
|
@@ -174,11 +175,14 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
|
|
174
175
|
- [Hello, Radio!](#hello-radio)
|
175
176
|
- [Hello, Radio Group!](#hello-radio-group)
|
176
177
|
- [Hello, Group!](#hello-group)
|
178
|
+
- [Hello, C Combo!](#hello-c-combo)
|
179
|
+
- [Hello, C Tab!](#hello-c-tab)
|
177
180
|
- [Hello, Checkbox!](#hello-checkbox)
|
178
181
|
- [Hello, Checkbox Group!](#hello-checkbox-group)
|
179
182
|
- [Hello, Date Time!](#hello-date-time)
|
180
183
|
- [Hello, Table!](#hello-table)
|
181
184
|
- [Hello, Button!](#hello-button)
|
185
|
+
- [Hello, Arrow!](#hello-arrow)
|
182
186
|
- [Hello, Message Box!](#hello-message-box)
|
183
187
|
- [Hello, Pop Up Context Menu!](#hello-pop-up-context-menu)
|
184
188
|
- [Hello, Menu Bar!](#hello-menu-bar)
|
@@ -257,7 +261,7 @@ gem 'opal', '1.0.4'
|
|
257
261
|
gem 'opal-rails', '1.1.2'
|
258
262
|
gem 'opal-async', '~> 1.2.0'
|
259
263
|
gem 'opal-jquery', '~> 0.4.4'
|
260
|
-
gem 'glimmer-dsl-opal', '~> 0.
|
264
|
+
gem 'glimmer-dsl-opal', '~> 0.20.0'
|
261
265
|
gem 'glimmer-dsl-xml', '~> 1.2.0', require: false
|
262
266
|
gem 'glimmer-dsl-css', '~> 1.2.0', require: false
|
263
267
|
|
@@ -345,6 +349,8 @@ Widgets:
|
|
345
349
|
- `shell`: featured in [Hello, Checkbox!](#hello-checkbox) / [Hello, Button!](#hello-button) / [Hello, Table!](#hello-table) / [Hello, Tab!](#hello-tab) / [Hello, Radio Group!](#hello-radio-group) / [Hello, Radio!](#hello-radio) / [Hello, List Single Selection!](#hello-list-single-selection) / [Hello, List Multi Selection!](#hello-list-multi-selection) / [Hello, Group!](#hello-group) / [Hello, Date Time!](#hello-date-time) / [Hello, Custom Shell!](#hello-custom-shell) / [Hello, Computed!](#hello-computed) / [Hello, Combo!](#hello-combo) / [Hello, Checkbox Group!](#hello-checkbox-group) / [Contact Manager](#contact-manager) / [Tic Tac Toe](#tic-tac-toe) / [Login](#login)
|
346
350
|
- `tab_folder`: featured in [Hello, Tab!](#hello-tab)
|
347
351
|
- `tab_item`: featured in [Hello, Tab!](#hello-tab)
|
352
|
+
- `c_tab_folder`: featured in [Hello, C Tab!](#hello-c-tab)
|
353
|
+
- `c_tab_item`: featured in [Hello, C Tab!](#hello-c-tab)
|
348
354
|
- `table`: featured in [Hello, Custom Shell!](#hello-custom-shell) / [Hello, Table!](#hello-table) / [Contact Manager](#contact-manager)
|
349
355
|
- `table_column`: featured in [Hello, Table!](#hello-table) / [Hello, Custom Shell!](#hello-custom-shell) / [Contact Manager](#contact-manager)
|
350
356
|
- `text`: featured in [Hello, Computed!](#hello-computed) / [Login](#login) / [Contact Manager](#contact-manager)
|
@@ -793,6 +799,31 @@ You should see "Hello, Arrow!"
|
|
793
799
|
|
794
800
|
![Glimmer DSL for Opal Hello Arrow](images/glimmer-dsl-opal-hello-arrow-item-selected.png)
|
795
801
|
|
802
|
+
#### Hello, Spinner!
|
803
|
+
|
804
|
+
Add the following require statement to `app/assets/javascripts/application.rb`
|
805
|
+
|
806
|
+
```ruby
|
807
|
+
require 'glimmer-dsl-opal/samples/hello/hello_spinner'
|
808
|
+
```
|
809
|
+
|
810
|
+
Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
|
811
|
+
|
812
|
+
![Glimmer DSL for SWT Hello Spinner](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-spinner.png)
|
813
|
+
|
814
|
+
Glimmer app on the web (using `glimmer-dsl-opal` gem):
|
815
|
+
|
816
|
+
Start the Rails server:
|
817
|
+
```
|
818
|
+
rails s
|
819
|
+
```
|
820
|
+
|
821
|
+
Visit `http://localhost:3000`
|
822
|
+
|
823
|
+
You should see "Hello, Spinner!"
|
824
|
+
|
825
|
+
![Glimmer DSL for Opal Hello Spinner](images/glimmer-dsl-opal-hello-spinner.png)
|
826
|
+
|
796
827
|
#### Hello, Browser!
|
797
828
|
|
798
829
|
Add the following require statement to `app/assets/javascripts/application.rb`
|
@@ -1290,6 +1321,68 @@ You should see "Hello, Group!"
|
|
1290
1321
|
|
1291
1322
|
![Glimmer DSL for Opal Hello Group](images/glimmer-dsl-opal-hello-group.png)
|
1292
1323
|
|
1324
|
+
#### Hello, C Combo!
|
1325
|
+
|
1326
|
+
This is the low level way of using `c_combo`
|
1327
|
+
|
1328
|
+
Add the following require statement to `app/assets/javascripts/application.rb`
|
1329
|
+
|
1330
|
+
```ruby
|
1331
|
+
require 'glimmer-dsl-opal/samples/hello/hello_c_combo'
|
1332
|
+
```
|
1333
|
+
|
1334
|
+
Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
|
1335
|
+
|
1336
|
+
![Glimmer DSL for SWT Hello C Combo](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-c-combo.png)
|
1337
|
+
|
1338
|
+
![Glimmer DSL for SWT Hello C Combo Expanded](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-c-combo-expanded.png)
|
1339
|
+
|
1340
|
+
Glimmer app on the web (using `glimmer-dsl-opal` gem):
|
1341
|
+
|
1342
|
+
Start the Rails server:
|
1343
|
+
```
|
1344
|
+
rails s
|
1345
|
+
```
|
1346
|
+
|
1347
|
+
Visit `http://localhost:3000`
|
1348
|
+
|
1349
|
+
You should see "Hello, C Combo!"
|
1350
|
+
|
1351
|
+
![Glimmer DSL for Opal Hello C Combo](images/glimmer-dsl-opal-hello-c-combo.png)
|
1352
|
+
|
1353
|
+
![Glimmer DSL for Opal Hello C Combo Expanded](images/glimmer-dsl-opal-hello-c-combo-expanded.png)
|
1354
|
+
|
1355
|
+
#### Hello, C Tab!
|
1356
|
+
|
1357
|
+
This is the low level way of using `c_tab_folder`/`c_tab_item`
|
1358
|
+
|
1359
|
+
Add the following require statement to `app/assets/javascripts/application.rb`
|
1360
|
+
|
1361
|
+
```ruby
|
1362
|
+
require 'glimmer-dsl-opal/samples/hello/hello_c_tab'
|
1363
|
+
```
|
1364
|
+
|
1365
|
+
Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
|
1366
|
+
|
1367
|
+
![Glimmer DSL for SWT Hello C Tab](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-c-tab.png)
|
1368
|
+
|
1369
|
+
![Glimmer DSL for SWT Hello C Tab Other Tab](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-c-tab-other-tab.png)
|
1370
|
+
|
1371
|
+
Glimmer app on the web (using `glimmer-dsl-opal` gem):
|
1372
|
+
|
1373
|
+
Start the Rails server:
|
1374
|
+
```
|
1375
|
+
rails s
|
1376
|
+
```
|
1377
|
+
|
1378
|
+
Visit `http://localhost:3000`
|
1379
|
+
|
1380
|
+
You should see "Hello, C Tab!"
|
1381
|
+
|
1382
|
+
![Glimmer DSL for Opal Hello C Tab](images/glimmer-dsl-opal-hello-c-tab.png)
|
1383
|
+
|
1384
|
+
![Glimmer DSL for Opal Hello C Tab Other Tab](images/glimmer-dsl-opal-hello-c-tab-other-tab.png)
|
1385
|
+
|
1293
1386
|
#### Hello, Checkbox!
|
1294
1387
|
|
1295
1388
|
This is the low level way of using `checkbox`
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.20.0
|
@@ -0,0 +1,67 @@
|
|
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
|
+
# This is a sample for the c_combo widget, a more customizable version of combo
|
23
|
+
class HelloCCombo
|
24
|
+
class Person
|
25
|
+
attr_accessor :country, :country_options
|
26
|
+
|
27
|
+
def initialize
|
28
|
+
self.country_options = ['', 'Canada', 'US', 'Mexico']
|
29
|
+
reset_country!
|
30
|
+
end
|
31
|
+
|
32
|
+
def reset_country!
|
33
|
+
self.country = 'Canada'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
include Glimmer::UI::CustomShell
|
38
|
+
|
39
|
+
before_body do
|
40
|
+
@person = Person.new
|
41
|
+
end
|
42
|
+
|
43
|
+
body {
|
44
|
+
shell {
|
45
|
+
row_layout(:vertical) {
|
46
|
+
fill true
|
47
|
+
}
|
48
|
+
|
49
|
+
text 'Hello, C Combo!'
|
50
|
+
|
51
|
+
c_combo(:read_only) {
|
52
|
+
selection <=> [@person, :country] # also binds to country_options by convention
|
53
|
+
font height: 45 # unlike `combo`, `c_combo` changes height when setting the font height
|
54
|
+
}
|
55
|
+
|
56
|
+
button {
|
57
|
+
text 'Reset Selection'
|
58
|
+
|
59
|
+
on_widget_selected do
|
60
|
+
@person.reset_country!
|
61
|
+
end
|
62
|
+
}
|
63
|
+
}
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
HelloCCombo.launch
|
@@ -0,0 +1,172 @@
|
|
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
|
+
# Country flag images were made by [Freepik](https://www.flaticon.com/authors/freepik) from [www.flaticon.com](http://www.flaticon.com)
|
23
|
+
|
24
|
+
# This is a sample for the Custom Tab widgets (c_tab_folder & c_tab_item), which are more customizable versions of tab_folder and tab_item.
|
25
|
+
class HelloCTab
|
26
|
+
include Glimmer::UI::CustomShell
|
27
|
+
|
28
|
+
body {
|
29
|
+
shell {
|
30
|
+
row_layout
|
31
|
+
text 'Hello, C Tab!'
|
32
|
+
minimum_size 200, 200
|
33
|
+
|
34
|
+
c_tab_folder { # accepts styles: :close
|
35
|
+
layout_data {
|
36
|
+
width 1024
|
37
|
+
height 200
|
38
|
+
}
|
39
|
+
c_tab_item(:close) {
|
40
|
+
text 'English'
|
41
|
+
tool_tip_text 'English Greeting'
|
42
|
+
foreground :blue
|
43
|
+
selection_foreground :dark_blue
|
44
|
+
font name: 'Times New Roman', height: 30, style: [:bold, :italic]
|
45
|
+
image File.expand_path('images/usa.png', __dir__)
|
46
|
+
|
47
|
+
label {
|
48
|
+
text 'Hello, World!'
|
49
|
+
font name: 'Times New Roman', height: 90, style: [:bold, :italic]
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
c_tab_item(:close) {
|
54
|
+
text 'French'
|
55
|
+
tool_tip_text 'French Greeting'
|
56
|
+
foreground :blue
|
57
|
+
selection_foreground :dark_blue
|
58
|
+
font name: 'Times New Roman', height: 30, style: [:bold, :italic]
|
59
|
+
image File.expand_path('images/france.png', __dir__)
|
60
|
+
|
61
|
+
label {
|
62
|
+
text 'Bonjour, Univers!'
|
63
|
+
font name: 'Times New Roman', height: 90, style: [:bold, :italic]
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
c_tab_item(:close) {
|
68
|
+
text 'Spanish'
|
69
|
+
tool_tip_text 'Spanish Greeting'
|
70
|
+
foreground :blue
|
71
|
+
selection_foreground :dark_blue
|
72
|
+
font name: 'Times New Roman', height: 30, style: [:bold, :italic]
|
73
|
+
image File.expand_path('images/mexico.png', __dir__)
|
74
|
+
|
75
|
+
label {
|
76
|
+
text 'Hola, Mundo!'
|
77
|
+
font name: 'Times New Roman', height: 90, style: [:bold, :italic]
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
c_tab_item(:close) {
|
82
|
+
text 'German'
|
83
|
+
tool_tip_text 'German Greeting'
|
84
|
+
foreground :blue
|
85
|
+
selection_foreground :dark_blue
|
86
|
+
font name: 'Times New Roman', height: 30, style: [:bold, :italic]
|
87
|
+
image File.expand_path('images/germany.png', __dir__)
|
88
|
+
|
89
|
+
label {
|
90
|
+
text 'Hallo, Welt!'
|
91
|
+
font name: 'Times New Roman', height: 90, style: [:bold, :italic]
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
95
|
+
c_tab_item(:close) {
|
96
|
+
text 'Italian'
|
97
|
+
tool_tip_text 'Italian Greeting'
|
98
|
+
foreground :blue
|
99
|
+
selection_foreground :dark_blue
|
100
|
+
font name: 'Times New Roman', height: 30, style: [:bold, :italic]
|
101
|
+
image File.expand_path('images/italy.png', __dir__)
|
102
|
+
|
103
|
+
label {
|
104
|
+
text 'Ciao, Mondo!'
|
105
|
+
font name: 'Times New Roman', height: 90, style: [:bold, :italic]
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
c_tab_item(:close) {
|
110
|
+
text 'Dutch'
|
111
|
+
tool_tip_text 'Dutch Greeting'
|
112
|
+
foreground :blue
|
113
|
+
selection_foreground :dark_blue
|
114
|
+
font name: 'Times New Roman', height: 30, style: [:bold, :italic]
|
115
|
+
image File.expand_path('images/netherlands.png', __dir__)
|
116
|
+
|
117
|
+
label {
|
118
|
+
text 'Hallo, Wereld!'
|
119
|
+
font name: 'Times New Roman', height: 90, style: [:bold, :italic]
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
c_tab_item(:close) {
|
124
|
+
text 'Danish'
|
125
|
+
tool_tip_text 'Danish Greeting'
|
126
|
+
foreground :blue
|
127
|
+
selection_foreground :dark_blue
|
128
|
+
font name: 'Times New Roman', height: 30, style: [:bold, :italic]
|
129
|
+
image File.expand_path('images/denmark.png', __dir__)
|
130
|
+
|
131
|
+
label {
|
132
|
+
text 'Hej, Verden!'
|
133
|
+
font name: 'Times New Roman', height: 90, style: [:bold, :italic]
|
134
|
+
}
|
135
|
+
}
|
136
|
+
|
137
|
+
c_tab_item(:close) {
|
138
|
+
text 'Finnish'
|
139
|
+
tool_tip_text 'Finnish Greeting'
|
140
|
+
foreground :blue
|
141
|
+
selection_foreground :dark_blue
|
142
|
+
font name: 'Times New Roman', height: 30, style: [:bold, :italic]
|
143
|
+
image File.expand_path('images/finland.png', __dir__)
|
144
|
+
|
145
|
+
label {
|
146
|
+
text 'Hei, Maailma!'
|
147
|
+
font name: 'Times New Roman', height: 90, style: [:bold, :italic]
|
148
|
+
}
|
149
|
+
}
|
150
|
+
|
151
|
+
c_tab_item(:close) {
|
152
|
+
text 'Norwegian'
|
153
|
+
tool_tip_text 'Norwegian Greeting'
|
154
|
+
foreground :blue
|
155
|
+
selection_foreground :dark_blue
|
156
|
+
font name: 'Times New Roman', height: 30, style: [:bold, :italic]
|
157
|
+
image File.expand_path('images/norway.png', __dir__)
|
158
|
+
|
159
|
+
label {
|
160
|
+
text 'Hei, Verden!'
|
161
|
+
font name: 'Times New Roman', height: 90, style: [:bold, :italic]
|
162
|
+
}
|
163
|
+
}
|
164
|
+
|
165
|
+
}
|
166
|
+
|
167
|
+
}
|
168
|
+
|
169
|
+
}
|
170
|
+
end
|
171
|
+
|
172
|
+
HelloCTab.launch
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# Copyright (c) 2007-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 HelloSpinner
|
23
|
+
class Person
|
24
|
+
attr_accessor :donation
|
25
|
+
end
|
26
|
+
|
27
|
+
include Glimmer::UI::CustomShell
|
28
|
+
|
29
|
+
before_body do
|
30
|
+
@person = Person.new
|
31
|
+
@person.donation = 500 # in cents
|
32
|
+
end
|
33
|
+
|
34
|
+
body {
|
35
|
+
shell {
|
36
|
+
grid_layout
|
37
|
+
|
38
|
+
text 'Hello, Spinner!'
|
39
|
+
|
40
|
+
label {
|
41
|
+
text 'Please select the amount you would like to donate to the poor:'
|
42
|
+
}
|
43
|
+
|
44
|
+
composite {
|
45
|
+
grid_layout 3, false
|
46
|
+
|
47
|
+
label {
|
48
|
+
layout_data {
|
49
|
+
width_hint 240
|
50
|
+
}
|
51
|
+
text 'Amount:'
|
52
|
+
font style: :bold
|
53
|
+
}
|
54
|
+
|
55
|
+
label {
|
56
|
+
text '$'
|
57
|
+
}
|
58
|
+
|
59
|
+
spinner {
|
60
|
+
digits 2 # digits after the decimal point
|
61
|
+
minimum 100 # minimum value (including digits after the decimal point)
|
62
|
+
maximum 15000 # maximum value (including digits after the decimal point)
|
63
|
+
increment 500 # increment on up and down (including digits after the decimal point)
|
64
|
+
page_increment 5000 # page increment on page up and page down (including digits after the decimal point)
|
65
|
+
selection <=> [@person, :donation] # selection must be set last if other properties are configured to ensure value is within bounds
|
66
|
+
}
|
67
|
+
|
68
|
+
label {
|
69
|
+
layout_data(:fill, :center, true, false)
|
70
|
+
text <=> [@person, :donation, on_read: ->(value) { "Thank you for your donation of $#{"%.2f" % (value.to_f / 100.0)}"}]
|
71
|
+
}
|
72
|
+
|
73
|
+
}
|
74
|
+
}
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
78
|
+
HelloSpinner.launch
|
@@ -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
|
@@ -20,15 +20,16 @@
|
|
20
20
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
22
|
class HelloTab
|
23
|
-
include Glimmer
|
23
|
+
include Glimmer::UI::CustomShell
|
24
24
|
|
25
|
-
|
25
|
+
body {
|
26
26
|
shell {
|
27
27
|
text 'Hello, Tab!'
|
28
28
|
|
29
29
|
tab_folder {
|
30
30
|
tab_item {
|
31
31
|
text 'English'
|
32
|
+
tool_tip_text 'English Greeting'
|
32
33
|
|
33
34
|
label {
|
34
35
|
text 'Hello, World!'
|
@@ -37,14 +38,15 @@ class HelloTab
|
|
37
38
|
|
38
39
|
tab_item {
|
39
40
|
text 'French'
|
41
|
+
tool_tip_text 'French Greeting'
|
40
42
|
|
41
43
|
label {
|
42
44
|
text 'Bonjour, Univers!'
|
43
45
|
}
|
44
46
|
}
|
45
47
|
}
|
46
|
-
}
|
47
|
-
|
48
|
+
}
|
49
|
+
}
|
48
50
|
end
|
49
51
|
|
50
|
-
HelloTab.
|
52
|
+
HelloTab.launch
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,51 @@
|
|
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
|
+
require 'glimmer/swt/combo_proxy'
|
24
|
+
|
25
|
+
module Glimmer
|
26
|
+
module SWT
|
27
|
+
class CComboProxy < ComboProxy
|
28
|
+
def post_add_content
|
29
|
+
`$(#{path}).selectmenu()`
|
30
|
+
c_combo_dom_element.css('width', 'initial')
|
31
|
+
end
|
32
|
+
|
33
|
+
def font=(value)
|
34
|
+
@font = value.is_a?(FontProxy) ? value : FontProxy.new(self, value)
|
35
|
+
c_combo_dom_element.css('font-family', @font.name) unless @font.nil?
|
36
|
+
c_combo_dom_element.css('font-style', 'italic') if @font&.style == :italic
|
37
|
+
c_combo_dom_element.css('font-weight', 'bold') if @font&.style == :bold
|
38
|
+
c_combo_dom_element.css('font-size', "#{@font.height}px") unless @font.nil?
|
39
|
+
end
|
40
|
+
|
41
|
+
def c_combo_path
|
42
|
+
"##{id}-button"
|
43
|
+
end
|
44
|
+
|
45
|
+
def c_combo_dom_element
|
46
|
+
Document.find(c_combo_path)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,43 @@
|
|
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
|
+
require 'glimmer/swt/tab_folder_proxy'
|
24
|
+
|
25
|
+
module Glimmer
|
26
|
+
module SWT
|
27
|
+
class CTabFolderProxy < TabFolderProxy
|
28
|
+
attr_reader :closeable_children
|
29
|
+
|
30
|
+
def initialize(parent, args, block)
|
31
|
+
@closeable_children = args.detect { |arg| SWTProxy[:close] == SWTProxy[arg] }
|
32
|
+
super(parent, args, block)
|
33
|
+
end
|
34
|
+
|
35
|
+
def post_initialize_child(child)
|
36
|
+
child.closeable = true if @closeable_children
|
37
|
+
super(child)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,96 @@
|
|
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/tab_item_proxy'
|
23
|
+
|
24
|
+
module Glimmer
|
25
|
+
module SWT
|
26
|
+
class CTabItemProxy < TabItemProxy
|
27
|
+
attr_reader :selection_foreground
|
28
|
+
attr_accessor :closeable
|
29
|
+
|
30
|
+
def initialize(parent, args, block)
|
31
|
+
@closeable = args.detect { |arg| SWTProxy[:close] == SWTProxy[arg] }
|
32
|
+
super(parent, args, block)
|
33
|
+
# TODO attach listener if :close style is set
|
34
|
+
close_dom_element.on('click') { dispose }
|
35
|
+
end
|
36
|
+
|
37
|
+
def foreground=(value)
|
38
|
+
value = ColorProxy.new(value) if value.is_a?(String)
|
39
|
+
@foreground = value
|
40
|
+
tab_dom_element.css('color', foreground.to_css) unless foreground.nil?
|
41
|
+
end
|
42
|
+
|
43
|
+
def selection_foreground=(value)
|
44
|
+
value = ColorProxy.new(value) if value.is_a?(String)
|
45
|
+
@selection_foreground = value
|
46
|
+
if @selection_foreground && tab_dom_element.has_class?('selected')
|
47
|
+
@old_foreground = tab_dom_element.css('color')
|
48
|
+
tab_dom_element.css('color', @selection_foreground.to_css)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def font=(value)
|
53
|
+
@font = value.is_a?(FontProxy) ? value : FontProxy.new(self, value)
|
54
|
+
tab_dom_element.css('font-family', @font.name) unless @font.nil?
|
55
|
+
tab_dom_element.css('font-style', 'italic') if @font&.style == :italic || [@font&.style].flatten.compact.include?(:italic)
|
56
|
+
tab_dom_element.css('font-weight', 'bold') if @font&.style == :bold || [@font&.style].flatten.compact.include?(:bold)
|
57
|
+
tab_dom_element.css('font-size', "#{@font.height}px") unless @font.nil?
|
58
|
+
end
|
59
|
+
|
60
|
+
def show
|
61
|
+
super
|
62
|
+
if @selection_foreground
|
63
|
+
@old_foreground = tab_dom_element.css('color')
|
64
|
+
tab_dom_element.css('color', @selection_foreground.to_css)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def hide
|
69
|
+
super
|
70
|
+
if @old_foreground
|
71
|
+
tab_dom_element.css('color', @old_foreground)
|
72
|
+
@old_foreground = nil
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def close_path
|
77
|
+
"#{tab_path} span.ui-icon-close"
|
78
|
+
end
|
79
|
+
|
80
|
+
def close_dom_element
|
81
|
+
Document.find(close_path)
|
82
|
+
end
|
83
|
+
|
84
|
+
def tab_dom
|
85
|
+
@tab_dom ||= html {
|
86
|
+
a(href: '#', id: tab_id, class: "tab") {
|
87
|
+
img {}
|
88
|
+
span { @text }
|
89
|
+
span(class: 'ui-icon ui-icon-close', role: 'presentation') { 'Remove Tab' } if @closeable
|
90
|
+
}
|
91
|
+
}.to_s
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,173 @@
|
|
1
|
+
require 'glimmer/swt/widget_proxy'
|
2
|
+
|
3
|
+
module Glimmer
|
4
|
+
module SWT
|
5
|
+
class SpinnerProxy < WidgetProxy
|
6
|
+
attr_reader :minimum, :maximum, :increment, :page_increment, :digits
|
7
|
+
|
8
|
+
def initialize(parent, args, block)
|
9
|
+
super(parent, args, block)
|
10
|
+
@increment = 1
|
11
|
+
@digits = 0
|
12
|
+
dom_element.spinner
|
13
|
+
end
|
14
|
+
|
15
|
+
def selection=(value)
|
16
|
+
old_value = @selection.to_f
|
17
|
+
if @selection.nil?
|
18
|
+
@selection = value.to_f / divider
|
19
|
+
else
|
20
|
+
@selection = value.to_f
|
21
|
+
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
|
29
|
+
end
|
30
|
+
|
31
|
+
def selection
|
32
|
+
@selection && @selection * divider
|
33
|
+
end
|
34
|
+
|
35
|
+
def text=(value)
|
36
|
+
self.selection = value.to_f
|
37
|
+
end
|
38
|
+
|
39
|
+
def text
|
40
|
+
self.selection.to_s
|
41
|
+
end
|
42
|
+
|
43
|
+
def minimum=(value)
|
44
|
+
@minimum = value.to_f / divider
|
45
|
+
dom_element.spinner('option', 'min', @minimum)
|
46
|
+
end
|
47
|
+
|
48
|
+
def maximum=(value)
|
49
|
+
@maximum = value.to_f / divider
|
50
|
+
dom_element.spinner('option', 'max', @maximum)
|
51
|
+
end
|
52
|
+
|
53
|
+
def increment=(value)
|
54
|
+
@increment = value.to_f / divider
|
55
|
+
dom_element.spinner('option', 'step', @increment)
|
56
|
+
end
|
57
|
+
|
58
|
+
def page_increment=(value)
|
59
|
+
@page_increment = value.to_f / (@increment * divider)
|
60
|
+
dom_element.spinner('option', 'page', @page_increment)
|
61
|
+
end
|
62
|
+
|
63
|
+
def divider
|
64
|
+
('1' + '0'*@digits.to_i).to_f
|
65
|
+
end
|
66
|
+
|
67
|
+
def digits=(value)
|
68
|
+
@digits = value
|
69
|
+
dom_element.spinner('option', 'numberFormat', "n") if @digits.to_i > 0
|
70
|
+
end
|
71
|
+
|
72
|
+
def element
|
73
|
+
'input'
|
74
|
+
end
|
75
|
+
|
76
|
+
def observation_request_to_event_mapping
|
77
|
+
{
|
78
|
+
'on_widget_selected' => [
|
79
|
+
{
|
80
|
+
event: 'change',
|
81
|
+
event_handler: -> (event_listener) {
|
82
|
+
-> (event) {
|
83
|
+
self.selection = event.target.value
|
84
|
+
event_listener.call(event)
|
85
|
+
}
|
86
|
+
}
|
87
|
+
},
|
88
|
+
{
|
89
|
+
event: 'spinstop',
|
90
|
+
event_handler: -> (event_listener) {
|
91
|
+
-> (event) {
|
92
|
+
self.selection = event.target.value
|
93
|
+
event_listener.call(event)
|
94
|
+
}
|
95
|
+
}
|
96
|
+
},
|
97
|
+
],
|
98
|
+
'on_modify_text' => {
|
99
|
+
event: 'keyup',
|
100
|
+
event_handler: -> (event_listener) {
|
101
|
+
-> (event) {
|
102
|
+
# TODO consider unifying this event handler with on_key_pressed by relying on its result instead of hooking another keyup event
|
103
|
+
if @last_key_pressed_event.nil? || @last_key_pressed_event.doit
|
104
|
+
self.text = event.target.value
|
105
|
+
event_listener.call(event)
|
106
|
+
else
|
107
|
+
# TODO Fix doit false, it's not stopping input
|
108
|
+
event.prevent
|
109
|
+
event.prevent_default
|
110
|
+
event.stop_propagation
|
111
|
+
event.stop_immediate_propagation
|
112
|
+
end
|
113
|
+
}
|
114
|
+
}
|
115
|
+
},
|
116
|
+
'on_key_pressed' => {
|
117
|
+
event: 'keydown',
|
118
|
+
event_handler: -> (event_listener) {
|
119
|
+
-> (event) {
|
120
|
+
@last_key_pressed_event = event
|
121
|
+
self.text = event.target.value
|
122
|
+
# TODO generalize this solution to all widgets that support key presses
|
123
|
+
# TODO support event.location once DOM3 is supported by opal-jquery
|
124
|
+
event.define_singleton_method(:keyCode) {event.which}
|
125
|
+
event.define_singleton_method(:key_code, &event.method(:keyCode))
|
126
|
+
event.define_singleton_method(:character) {event.which.chr}
|
127
|
+
event.define_singleton_method(:stateMask) do
|
128
|
+
state_mask = 0
|
129
|
+
state_mask |= SWTProxy[:alt] if event.alt_key
|
130
|
+
state_mask |= SWTProxy[:ctrl] if event.ctrl_key
|
131
|
+
state_mask |= SWTProxy[:shift] if event.shift_key
|
132
|
+
state_mask |= SWTProxy[:command] if event.meta_key
|
133
|
+
state_mask
|
134
|
+
end
|
135
|
+
event.define_singleton_method(:state_mask, &event.method(:stateMask))
|
136
|
+
doit = true
|
137
|
+
event.define_singleton_method(:doit=) do |value|
|
138
|
+
doit = value
|
139
|
+
end
|
140
|
+
event.define_singleton_method(:doit) { doit }
|
141
|
+
event_listener.call(event)
|
142
|
+
|
143
|
+
# TODO Fix doit false, it's not stopping input
|
144
|
+
unless doit
|
145
|
+
event.prevent
|
146
|
+
event.prevent_default
|
147
|
+
event.stop_propagation
|
148
|
+
event.stop_immediate_propagation
|
149
|
+
end
|
150
|
+
|
151
|
+
doit
|
152
|
+
}
|
153
|
+
}
|
154
|
+
},
|
155
|
+
}
|
156
|
+
end
|
157
|
+
|
158
|
+
def dom
|
159
|
+
text_text = @text
|
160
|
+
text_id = id
|
161
|
+
text_style = css
|
162
|
+
text_class = name
|
163
|
+
# TODO support password field
|
164
|
+
options = {type: 'text', id: text_id, style: text_style, class: text_class, value: text_text, style: 'min-width: 27px;'}
|
165
|
+
options = options.merge('disabled': 'disabled') unless @enabled
|
166
|
+
options = options.merge(type: 'password') if has_style?(:password)
|
167
|
+
@dom ||= html {
|
168
|
+
input(options)
|
169
|
+
}.to_s
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
@@ -26,8 +26,8 @@ module Glimmer
|
|
26
26
|
class TabFolderProxy < WidgetProxy
|
27
27
|
STYLE = <<~CSS
|
28
28
|
.tabs .tab.selected {
|
29
|
-
background:
|
30
|
-
color:
|
29
|
+
background: white;
|
30
|
+
color: black;
|
31
31
|
}
|
32
32
|
.tabs .tab {
|
33
33
|
background-color: inherit;
|
@@ -38,6 +38,14 @@ module Glimmer
|
|
38
38
|
padding: 14px 16px;
|
39
39
|
transition: 0.3s;
|
40
40
|
font-size: 17px;
|
41
|
+
text-decoration: none;
|
42
|
+
}
|
43
|
+
.tabs .tab:hover {
|
44
|
+
color: black
|
45
|
+
}
|
46
|
+
.tabs .tab > * {
|
47
|
+
display: inline-block;
|
48
|
+
vertical-align: middle;
|
41
49
|
}
|
42
50
|
.tabs {
|
43
51
|
overflow: hidden;
|
@@ -46,16 +54,10 @@ module Glimmer
|
|
46
54
|
}
|
47
55
|
CSS
|
48
56
|
|
49
|
-
attr_reader :tabs
|
50
|
-
|
51
|
-
def initialize(parent, args, block)
|
52
|
-
super(parent, args, block)
|
53
|
-
@tabs = []
|
54
|
-
end
|
55
|
-
|
56
57
|
def post_initialize_child(child)
|
57
58
|
unless @children.include?(child)
|
58
59
|
@children << child
|
60
|
+
child.closeable = true if @closeable_children
|
59
61
|
tabs_dom_element.append(child.tab_dom)
|
60
62
|
child.render
|
61
63
|
end
|
@@ -85,7 +87,7 @@ module Glimmer
|
|
85
87
|
tab_folder_id = id
|
86
88
|
tab_folder_id_style = css
|
87
89
|
@dom ||= html {
|
88
|
-
div(id: tab_folder_id, style: tab_folder_id_style, class:
|
90
|
+
div(id: tab_folder_id, style: tab_folder_id_style, class: name) {
|
89
91
|
div(id: tabs_id, class: 'tabs')
|
90
92
|
}
|
91
93
|
}.to_s
|
@@ -1,10 +1,31 @@
|
|
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/composite_proxy'
|
2
23
|
|
3
24
|
module Glimmer
|
4
25
|
module SWT
|
5
26
|
class TabItemProxy < CompositeProxy
|
6
27
|
include Glimmer
|
7
|
-
attr_reader :text, :content_visible
|
28
|
+
attr_reader :text, :content_visible, :tool_tip_text, :image
|
8
29
|
|
9
30
|
def initialize(parent, args, block)
|
10
31
|
super(parent, args, block)
|
@@ -30,7 +51,33 @@ module Glimmer
|
|
30
51
|
|
31
52
|
def text=(value)
|
32
53
|
@text = value
|
33
|
-
tab_dom_element.html(@text)
|
54
|
+
tab_dom_element.find('span').html(@text)
|
55
|
+
end
|
56
|
+
|
57
|
+
def image=(value)
|
58
|
+
@image = value
|
59
|
+
if @image.is_a?(String)
|
60
|
+
tab_dom_element.find('img').attr('src', @image)
|
61
|
+
tab_dom_element.find('img').css('padding-right', '5px')
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def tool_tip_text=(value)
|
66
|
+
@tool_tip_text = value
|
67
|
+
tab_dom_element.attr('title', @tool_tip_text) if !@tool_tip_text.to_s.empty?
|
68
|
+
end
|
69
|
+
|
70
|
+
def dispose
|
71
|
+
tab_index = parent.children.to_a.index(self)
|
72
|
+
tab_dom_element.remove
|
73
|
+
super
|
74
|
+
if @content_visible
|
75
|
+
@content_visible = false
|
76
|
+
parent.hide_all_tab_content
|
77
|
+
tab_to_show = parent.children.to_a[tab_index]
|
78
|
+
tab_to_show ||= parent.children.to_a[tab_index - 1]
|
79
|
+
tab_to_show&.show
|
80
|
+
end
|
34
81
|
end
|
35
82
|
|
36
83
|
def selector
|
@@ -64,8 +111,9 @@ module Glimmer
|
|
64
111
|
# This contains the clickable tab area with tab names
|
65
112
|
def tab_dom
|
66
113
|
@tab_dom ||= html {
|
67
|
-
|
68
|
-
|
114
|
+
a(href: '#', id: tab_id, class: "tab") {
|
115
|
+
img {}
|
116
|
+
span { @text }
|
69
117
|
}
|
70
118
|
}.to_s
|
71
119
|
end
|
@@ -112,6 +112,7 @@ module Glimmer
|
|
112
112
|
@parent = parent
|
113
113
|
@args = args
|
114
114
|
@block = block
|
115
|
+
# TODO consider changing children to an array (why is it a Set if order matters?)
|
115
116
|
@children = Set.new # TODO consider moving to composite
|
116
117
|
@enabled = true
|
117
118
|
@data = {}
|
@@ -236,8 +237,8 @@ module Glimmer
|
|
236
237
|
def font=(value)
|
237
238
|
@font = value.is_a?(FontProxy) ? value : FontProxy.new(self, value)
|
238
239
|
dom_element.css('font-family', @font.name) unless @font.nil?
|
239
|
-
dom_element.css('font-style', 'italic') if @font&.style == :italic
|
240
|
-
dom_element.css('font-weight', 'bold') if @font&.style == :bold
|
240
|
+
dom_element.css('font-style', 'italic') if @font&.style == :italic || [@font&.style].flatten.compact.include?(:italic)
|
241
|
+
dom_element.css('font-weight', 'bold') if @font&.style == :bold || [@font&.style].flatten.compact.include?(:bold)
|
241
242
|
dom_element.css('font-size', "#{@font.height}px") unless @font.nil?
|
242
243
|
end
|
243
244
|
|
@@ -850,6 +851,13 @@ module Glimmer
|
|
850
851
|
# }
|
851
852
|
# end,
|
852
853
|
# },
|
854
|
+
SpinnerProxy => {
|
855
|
+
:selection => lambda do |observer|
|
856
|
+
on_widget_selected { |selection_event|
|
857
|
+
observer.call(selection)
|
858
|
+
}
|
859
|
+
end
|
860
|
+
},
|
853
861
|
TextProxy => {
|
854
862
|
:text => lambda do |observer|
|
855
863
|
on_modify_text { |modify_event|
|
@@ -962,6 +970,7 @@ require 'glimmer/swt/browser_proxy'
|
|
962
970
|
require 'glimmer/swt/button_proxy'
|
963
971
|
require 'glimmer/swt/arrow_proxy'
|
964
972
|
require 'glimmer/swt/combo_proxy'
|
973
|
+
require 'glimmer/swt/c_combo_proxy'
|
965
974
|
require 'glimmer/swt/checkbox_proxy'
|
966
975
|
require 'glimmer/swt/composite_proxy'
|
967
976
|
require 'glimmer/swt/dialog_proxy'
|
@@ -974,12 +983,15 @@ require 'glimmer/swt/menu_proxy'
|
|
974
983
|
require 'glimmer/swt/radio_proxy'
|
975
984
|
require 'glimmer/swt/tab_folder_proxy'
|
976
985
|
require 'glimmer/swt/tab_item_proxy'
|
986
|
+
require 'glimmer/swt/c_tab_folder_proxy'
|
987
|
+
require 'glimmer/swt/c_tab_item_proxy'
|
977
988
|
require 'glimmer/swt/table_column_proxy'
|
978
989
|
require 'glimmer/swt/table_item_proxy'
|
979
990
|
require 'glimmer/swt/table_proxy'
|
980
991
|
require 'glimmer/swt/text_proxy'
|
981
992
|
require 'glimmer/swt/radio_proxy'
|
982
993
|
require 'glimmer/swt/scrolled_composite_proxy'
|
994
|
+
require 'glimmer/swt/spinner_proxy'
|
983
995
|
require 'glimmer/swt/styled_text_proxy'
|
984
996
|
|
985
997
|
require 'glimmer/dsl/opal/widget_expression'
|
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.20.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-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -287,6 +287,8 @@ files:
|
|
287
287
|
- lib/glimmer-dsl-opal/samples/hello/hello_arrow.rb
|
288
288
|
- lib/glimmer-dsl-opal/samples/hello/hello_browser.rb
|
289
289
|
- lib/glimmer-dsl-opal/samples/hello/hello_button.rb
|
290
|
+
- lib/glimmer-dsl-opal/samples/hello/hello_c_combo.rb
|
291
|
+
- lib/glimmer-dsl-opal/samples/hello/hello_c_tab.rb
|
290
292
|
- lib/glimmer-dsl-opal/samples/hello/hello_checkbox.rb
|
291
293
|
- lib/glimmer-dsl-opal/samples/hello/hello_checkbox_group.rb
|
292
294
|
- lib/glimmer-dsl-opal/samples/hello/hello_combo.rb
|
@@ -305,10 +307,20 @@ files:
|
|
305
307
|
- lib/glimmer-dsl-opal/samples/hello/hello_pop_up_context_menu.rb
|
306
308
|
- lib/glimmer-dsl-opal/samples/hello/hello_radio.rb
|
307
309
|
- lib/glimmer-dsl-opal/samples/hello/hello_radio_group.rb
|
310
|
+
- lib/glimmer-dsl-opal/samples/hello/hello_spinner.rb
|
308
311
|
- lib/glimmer-dsl-opal/samples/hello/hello_tab.rb
|
309
312
|
- lib/glimmer-dsl-opal/samples/hello/hello_table.rb
|
310
313
|
- lib/glimmer-dsl-opal/samples/hello/hello_table/baseball_park.png
|
311
314
|
- lib/glimmer-dsl-opal/samples/hello/hello_world.rb
|
315
|
+
- lib/glimmer-dsl-opal/samples/hello/images/denmark.png
|
316
|
+
- lib/glimmer-dsl-opal/samples/hello/images/finland.png
|
317
|
+
- lib/glimmer-dsl-opal/samples/hello/images/france.png
|
318
|
+
- lib/glimmer-dsl-opal/samples/hello/images/germany.png
|
319
|
+
- lib/glimmer-dsl-opal/samples/hello/images/italy.png
|
320
|
+
- lib/glimmer-dsl-opal/samples/hello/images/mexico.png
|
321
|
+
- lib/glimmer-dsl-opal/samples/hello/images/netherlands.png
|
322
|
+
- lib/glimmer-dsl-opal/samples/hello/images/norway.png
|
323
|
+
- lib/glimmer-dsl-opal/samples/hello/images/usa.png
|
312
324
|
- lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/GPL-LICENSE.txt
|
313
325
|
- lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/MIT-LICENSE.txt
|
314
326
|
- lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/jquery.ui.timepicker.css
|
@@ -374,6 +386,9 @@ files:
|
|
374
386
|
- lib/glimmer/swt/arrow_proxy.rb
|
375
387
|
- lib/glimmer/swt/browser_proxy.rb
|
376
388
|
- lib/glimmer/swt/button_proxy.rb
|
389
|
+
- lib/glimmer/swt/c_combo_proxy.rb
|
390
|
+
- lib/glimmer/swt/c_tab_folder_proxy.rb
|
391
|
+
- lib/glimmer/swt/c_tab_item_proxy.rb
|
377
392
|
- lib/glimmer/swt/checkbox_proxy.rb
|
378
393
|
- lib/glimmer/swt/color_proxy.rb
|
379
394
|
- lib/glimmer/swt/combo_proxy.rb
|
@@ -406,6 +421,7 @@ files:
|
|
406
421
|
- lib/glimmer/swt/row_layout_proxy.rb
|
407
422
|
- lib/glimmer/swt/scrolled_composite_proxy.rb
|
408
423
|
- lib/glimmer/swt/shell_proxy.rb
|
424
|
+
- lib/glimmer/swt/spinner_proxy.rb
|
409
425
|
- lib/glimmer/swt/style_constantizable.rb
|
410
426
|
- lib/glimmer/swt/styled_text_proxy.rb
|
411
427
|
- lib/glimmer/swt/swt_proxy.rb
|