glimmer-dsl-swt 4.20.4.0 → 4.20.5.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 +19 -0
- data/README.md +5 -5
- data/VERSION +1 -1
- data/docs/reference/GLIMMER_SAMPLES.md +44 -0
- data/glimmer-dsl-swt.gemspec +0 -0
- data/lib/glimmer/data_binding/table_items_binding.rb +1 -0
- data/{samples/hello/hello_computed/contact.rb → lib/glimmer/dsl/swt/tray_expression.rb} +21 -20
- data/lib/glimmer/dsl/swt/tray_item_expression.rb +48 -0
- data/lib/glimmer/rake_task/scaffold.rb +18 -8
- data/lib/glimmer/swt/menu_proxy.rb +15 -1
- data/lib/glimmer/swt/tray_item_proxy.rb +44 -0
- data/lib/glimmer/swt/tray_proxy.rb +64 -0
- data/samples/elaborate/timer.rb +1 -1
- data/samples/elaborate/weather.rb +8 -4
- data/samples/hello/hello_c_tab.rb +9 -9
- data/samples/hello/hello_computed.rb +20 -2
- data/samples/hello/hello_custom_shell.rb +16 -10
- data/samples/hello/hello_label.rb +194 -0
- data/samples/hello/hello_tray_item.rb +135 -0
- data/samples/hello/{hello_c_tab → images}/denmark.png +0 -0
- data/samples/hello/{hello_c_tab → images}/finland.png +0 -0
- data/samples/hello/{hello_c_tab → images}/france.png +0 -0
- data/samples/hello/{hello_c_tab → images}/germany.png +0 -0
- data/samples/hello/{hello_c_tab → images}/italy.png +0 -0
- data/samples/hello/{hello_c_tab → images}/mexico.png +0 -0
- data/samples/hello/{hello_c_tab → images}/netherlands.png +0 -0
- data/samples/hello/{hello_c_tab → images}/norway.png +0 -0
- data/samples/hello/{hello_c_tab → images}/usa.png +0 -0
- metadata +17 -13
- data/samples/elaborate/timer/alarm1.wav +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b5a5a713224bb17bff5a0f19e1333a232c71871212e99be452753fe6821e407
|
4
|
+
data.tar.gz: 65c144171a3083704797b01c29b036463b27692461aeb0a11a7698ad24c400a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44d93271f4c7504605a23a665cc921bd8c364962f6e992f137c058b0361099593407eee8003ce1aa08cd58e1f36d8302ab3243d34dead3e8718971c25150cca9
|
7
|
+
data.tar.gz: e7921eb7002882585225e4580b02d81f17a471982905263abdaad87482e640edcc686a5ae9be9241dd2b0f9d9f37f0a29cbfc6c7d43e1e1d770c39d60ce7be35
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,24 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
### 4.20.5.0
|
4
|
+
|
5
|
+
- Relax glimmer-dsl-swt version number when scaffolding custom shape/widget/shell gems. Keep it strict for app development.
|
6
|
+
- Explicit support for `tray_item` keyword as nested under `shell`, having `menu` nested under `tray_item`, automating everything relating to using SWT TrayItem (no need to work with the Display System Tray or Menu objects manually).
|
7
|
+
- Hello, Tray Item! Sample
|
8
|
+
|
9
|
+
### 4.20.4.2
|
10
|
+
|
11
|
+
- Hello, Label!
|
12
|
+
|
13
|
+
### 4.20.4.1
|
14
|
+
|
15
|
+
- Ensure a `table` with `:editable` style loses it if `items <= ...` one-way data-binding (having read_only: true option) was setup.
|
16
|
+
- Tweak/refactor/improve samples
|
17
|
+
|
18
|
+
### 4.20.4.0
|
19
|
+
|
20
|
+
- Extracted Shine data-binding syntax and `BindExpression` to Glimmer 2
|
21
|
+
|
3
22
|
### 4.20.3.0
|
4
23
|
|
5
24
|
- Shine data-binding support for `custom widgets`, `custom shells`, and `custom shapes`
|
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 SWT 4.20.
|
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 SWT 4.20.5.0
|
2
2
|
## JRuby Desktop Development GUI Framework
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/glimmer-dsl-swt.svg)](http://badge.fury.io/rb/glimmer-dsl-swt)
|
4
4
|
[![Travis CI](https://travis-ci.com/AndyObtiva/glimmer-dsl-swt.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer-dsl-swt)
|
@@ -15,7 +15,7 @@
|
|
15
15
|
[<img src="https://covers.oreillystatic.com/images/9780596519650/lrg.jpg" width=105 /><br />
|
16
16
|
Featured in JRuby Cookbook](http://shop.oreilly.com/product/9780596519650.do) and [Chalmers/Gothenburg University Software Engineering Master's Lecture Material](http://www.cse.chalmers.se/~bergert/slides/guest_lecture_DSLs.pdf)
|
17
17
|
|
18
|
-
[Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.20.
|
18
|
+
[Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.20.5.0 includes [SWT 4.20](https://download.eclipse.org/eclipse/downloads/drops4/R-4.20-202106111600/), which was released on June 11, 2021. Gem version numbers are in sync with the SWT library versions. The first two digits represent the SWT version number. The last two digits represent the minor and patch versions of Glimmer DSL for SWT. Note that SWT now supports AARCH64 on Mac and Linux, but it is not fully tested in Glimmer DSL for SWT yet, so deem its support experimental for the time being without guarantees for functionality until declared otherwise (report any issues you may encounter).
|
19
19
|
|
20
20
|
**Starting in version 4.20.0.0, [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) comes with the new [***Shine***](/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#shine) syntax** for highly intuitive and visually expressive View/Model Attribute Mapping, relying on `<=>` for bidirectional (two-way) data-binding and `<=` for unidirectional (one-way) data-binding, providing an alternative to the `bind` keyword (keep in mind that it is still a beta, so default back to `bind` whenever needed).
|
21
21
|
|
@@ -347,7 +347,7 @@ jgem install glimmer-dsl-swt
|
|
347
347
|
|
348
348
|
Or this command if you want a specific version:
|
349
349
|
```
|
350
|
-
jgem install glimmer-dsl-swt -v 4.20.
|
350
|
+
jgem install glimmer-dsl-swt -v 4.20.5.0
|
351
351
|
```
|
352
352
|
|
353
353
|
`jgem` is JRuby's version of `gem` command.
|
@@ -375,7 +375,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
|
|
375
375
|
|
376
376
|
Add the following to `Gemfile`:
|
377
377
|
```
|
378
|
-
gem 'glimmer-dsl-swt', '~> 4.20.
|
378
|
+
gem 'glimmer-dsl-swt', '~> 4.20.5.0'
|
379
379
|
```
|
380
380
|
|
381
381
|
And, then run:
|
@@ -396,7 +396,7 @@ glimmer
|
|
396
396
|
```
|
397
397
|
|
398
398
|
```
|
399
|
-
Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.20.
|
399
|
+
Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.20.5.0
|
400
400
|
|
401
401
|
Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
|
402
402
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.20.
|
1
|
+
4.20.5.0
|
@@ -2,6 +2,7 @@
|
|
2
2
|
- [Hello Samples](#hello-samples)
|
3
3
|
- [Hello, World!](#hello-world)
|
4
4
|
- [Hello, Button!](#hello-button)
|
5
|
+
- [Hello, Label!](#hello-label)
|
5
6
|
- [Hello, Text!](#hello-text)
|
6
7
|
- [Hello, Composite!](#hello-composite)
|
7
8
|
- [Hello, Layout!](#hello-layout)
|
@@ -51,6 +52,7 @@
|
|
51
52
|
- [Hello, Custom Shape!](#hello-custom-shape)
|
52
53
|
- [Hello, Tool Bar!](#hello-tool-bar)
|
53
54
|
- [Hello, Cool Bar!](#hello-cool-bar)
|
55
|
+
- [Hello, Tray Item!](#hello-tray-item)
|
54
56
|
- [Elaborate Samples](#elaborate-samples)
|
55
57
|
- [User Profile](#user-profile)
|
56
58
|
- [Login](#login)
|
@@ -117,6 +119,28 @@ Hello, Button! Incremented 7 times!
|
|
117
119
|
|
118
120
|
![Hello Button Incremented](/images/glimmer-hello-button-incremented.png)
|
119
121
|
|
122
|
+
#### Hello, Label!
|
123
|
+
|
124
|
+
This sample demonstrates the use of the `label` widget in Glimmer.
|
125
|
+
|
126
|
+
Code:
|
127
|
+
|
128
|
+
[samples/hello/hello_label.rb](/samples/hello/hello_label.rb)
|
129
|
+
|
130
|
+
![Hello Label Left Aligned](/images/glimmer-hello-label-left-aligned.png)
|
131
|
+
|
132
|
+
![Hello Label Center Aligned](/images/glimmer-hello-label-center-aligned.png)
|
133
|
+
|
134
|
+
![Hello Label Right Aligned](/images/glimmer-hello-label-right-aligned.png)
|
135
|
+
|
136
|
+
![Hello Label Images](/images/glimmer-hello-label-images.png)
|
137
|
+
|
138
|
+
![Hello Label Background Images](/images/glimmer-hello-label-background_images.png)
|
139
|
+
|
140
|
+
![Hello Label Horizontal Separator](/images/glimmer-hello-label-horizontal-separator.png)
|
141
|
+
|
142
|
+
![Hello Label Vertical Separator](/images/glimmer-hello-label-vertical-separator.png)
|
143
|
+
|
120
144
|
#### Hello, Text!
|
121
145
|
|
122
146
|
This sample demonstrates the use of the `text` widget in Glimmer, including data-binding (e.g. via the `<=>` operator) and event handling.
|
@@ -919,6 +943,26 @@ Hello, Cool Bar!
|
|
919
943
|
|
920
944
|
![Hello Cool Bar Reorg3](/images/glimmer-hello-cool-bar-reorg3.png)
|
921
945
|
|
946
|
+
#### Hello, Tray Item!
|
947
|
+
|
948
|
+
This sample demonstrates the use of `tray_item`, which enables hiding an app (sending to background) and showing again on top of all other apps. It can also show an About Message Box and exit completely if needed.
|
949
|
+
|
950
|
+
Code:
|
951
|
+
|
952
|
+
[samples/hello/hello_tray_item.rb](/samples/hello/hello_tray_item.rb)
|
953
|
+
|
954
|
+
Hello, Tray Item Icon!
|
955
|
+
|
956
|
+
![Hello Tray Item Icon](/images/glimmer-hello-tray-item.png)
|
957
|
+
|
958
|
+
Hello, Tray Item Icon App!
|
959
|
+
|
960
|
+
![Hello Tray Item App](/images/glimmer-hello-tray-item-app.png)
|
961
|
+
|
962
|
+
Hello, Tray Item Icon About Message Box!
|
963
|
+
|
964
|
+
![Hello Tray Item Åbout](/images/glimmer-hello-tray-item-about.png)
|
965
|
+
|
922
966
|
### Elaborate Samples
|
923
967
|
|
924
968
|
For more elaborate samples, check the following:
|
data/glimmer-dsl-swt.gemspec
CHANGED
Binary file
|
@@ -39,6 +39,7 @@ module Glimmer
|
|
39
39
|
@model_binding = model_binding
|
40
40
|
@read_only_sort = @model_binding.binding_options[:read_only_sort]
|
41
41
|
@column_properties = @model_binding.binding_options[:column_properties] || @model_binding.binding_options[:column_attributes] || column_properties
|
42
|
+
@table.editable = false if @model_binding.binding_options[:read_only]
|
42
43
|
if @table.respond_to?(:column_properties=)
|
43
44
|
@table.column_properties = @column_properties
|
44
45
|
else # assume custom widget
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2007-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
|
@@ -19,24 +19,25 @@
|
|
19
19
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
20
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
22
|
+
require 'glimmer/dsl/static_expression'
|
23
|
+
require 'glimmer/dsl/parent_expression'
|
24
|
+
require 'glimmer/swt/display_proxy'
|
25
|
+
require 'glimmer/swt/tray_proxy'
|
26
|
+
|
27
|
+
module Glimmer
|
28
|
+
module DSL
|
29
|
+
module SWT
|
30
|
+
class TrayExpression < StaticExpression
|
31
|
+
include ParentExpression
|
32
|
+
|
33
|
+
def can_interpret?(parent, keyword, *args, &block)
|
34
|
+
super && parent.is_a?(Glimmer::SWT::DisplayProxy) && args.empty?
|
35
|
+
end
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
def interpret(parent, keyword, *args, &block)
|
38
|
+
Glimmer::SWT::TrayProxy.instance
|
39
|
+
end
|
40
|
+
end
|
40
41
|
end
|
41
42
|
end
|
42
43
|
end
|
@@ -0,0 +1,48 @@
|
|
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
|
+
require 'glimmer/dsl/static_expression'
|
23
|
+
require 'glimmer/dsl/parent_expression'
|
24
|
+
require 'glimmer/swt/display_proxy'
|
25
|
+
require 'glimmer/swt/tray_proxy'
|
26
|
+
require 'glimmer/swt/tray_item_proxy'
|
27
|
+
|
28
|
+
module Glimmer
|
29
|
+
module DSL
|
30
|
+
module SWT
|
31
|
+
class TrayItemExpression < StaticExpression
|
32
|
+
include ParentExpression
|
33
|
+
|
34
|
+
include_package 'org.eclipse.swt.widgets'
|
35
|
+
|
36
|
+
def can_interpret?(parent, keyword, *args, &block)
|
37
|
+
super and
|
38
|
+
parent.swt_widget.is_a?(Shell) and
|
39
|
+
args.empty?
|
40
|
+
end
|
41
|
+
|
42
|
+
def interpret(parent, keyword, *args, &block)
|
43
|
+
Glimmer::SWT::TrayItemProxy.new(parent, *args)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -106,15 +106,23 @@ module Glimmer
|
|
106
106
|
/vendor/jars/
|
107
107
|
MULTI_LINE_STRING
|
108
108
|
|
109
|
-
|
109
|
+
GEMFILE_PREFIX = <<~MULTI_LINE_STRING
|
110
110
|
# frozen_string_literal: true
|
111
111
|
|
112
112
|
source 'https://rubygems.org'
|
113
113
|
|
114
114
|
git_source(:github) {|repo_name| "https://github.com/\#{repo_name}" }
|
115
|
-
|
115
|
+
MULTI_LINE_STRING
|
116
|
+
GEMFILE_APP_MIDFIX = <<~MULTI_LINE_STRING
|
117
|
+
|
116
118
|
gem 'glimmer-dsl-swt', '~> #{VERSION}'
|
117
|
-
|
119
|
+
MULTI_LINE_STRING
|
120
|
+
GEMFILE_GEM_MIDFIX = <<~MULTI_LINE_STRING
|
121
|
+
|
122
|
+
gem 'glimmer-dsl-swt', '~> #{VERSION.split('.')[0...2].join('.')}'
|
123
|
+
MULTI_LINE_STRING
|
124
|
+
GEMFILE_SUFFIX = <<~MULTI_LINE_STRING
|
125
|
+
|
118
126
|
group :development do
|
119
127
|
gem 'rspec', '~> 3.5.0'
|
120
128
|
gem 'juwelier', '2.4.9'
|
@@ -122,6 +130,8 @@ module Glimmer
|
|
122
130
|
gem 'simplecov', '>= 0'
|
123
131
|
end
|
124
132
|
MULTI_LINE_STRING
|
133
|
+
APP_GEMFILE = GEMFILE_PREFIX + GEMFILE_APP_MIDFIX + GEMFILE_SUFFIX
|
134
|
+
GEM_GEMFILE = GEMFILE_PREFIX + GEMFILE_GEM_MIDFIX + GEMFILE_SUFFIX
|
125
135
|
|
126
136
|
def app(app_name)
|
127
137
|
common_app(app_name)
|
@@ -250,7 +260,7 @@ module Glimmer
|
|
250
260
|
write '.ruby-version', RUBY_VERSION
|
251
261
|
write '.ruby-gemset', gem_name
|
252
262
|
write 'VERSION', '1.0.0'
|
253
|
-
write 'Gemfile',
|
263
|
+
write 'Gemfile', GEM_GEMFILE
|
254
264
|
write 'Rakefile', gem_rakefile(custom_shell_name, namespace, gem_name)
|
255
265
|
append "lib/#{gem_name}.rb", gem_main_file(custom_shell_name, namespace)
|
256
266
|
custom_shell(custom_shell_name, namespace, :gem)
|
@@ -321,7 +331,7 @@ module Glimmer
|
|
321
331
|
write '.ruby-version', RUBY_VERSION
|
322
332
|
write '.ruby-gemset', gem_name
|
323
333
|
write 'VERSION', '1.0.0'
|
324
|
-
write 'Gemfile',
|
334
|
+
write 'Gemfile', GEM_GEMFILE
|
325
335
|
write 'Rakefile', gem_rakefile
|
326
336
|
append "lib/#{gem_name}.rb", gem_main_file(custom_widget_name, namespace)
|
327
337
|
custom_widget(custom_widget_name, namespace)
|
@@ -359,7 +369,7 @@ module Glimmer
|
|
359
369
|
write '.ruby-version', RUBY_VERSION
|
360
370
|
write '.ruby-gemset', gem_name
|
361
371
|
write 'VERSION', '1.0.0'
|
362
|
-
write 'Gemfile',
|
372
|
+
write 'Gemfile', GEM_GEMFILE
|
363
373
|
write 'Rakefile', gem_rakefile
|
364
374
|
append "lib/#{gem_name}.rb", gem_main_file(custom_shape_name, namespace)
|
365
375
|
custom_shape(custom_shape_name, namespace)
|
@@ -418,7 +428,7 @@ module Glimmer
|
|
418
428
|
|
419
429
|
def gemfile(shell_type)
|
420
430
|
if shell_type == :desktopify
|
421
|
-
lines =
|
431
|
+
lines = APP_GEMFILE.split("\n")
|
422
432
|
require_glimmer_dsl_swt_index = lines.index(lines.detect {|l| l.include?("gem 'glimmer-dsl-swt'") })
|
423
433
|
lines[(require_glimmer_dsl_swt_index + 1)..(require_glimmer_dsl_swt_index + 1)] = [
|
424
434
|
"",
|
@@ -428,7 +438,7 @@ module Glimmer
|
|
428
438
|
]
|
429
439
|
lines.join("\n")
|
430
440
|
else
|
431
|
-
|
441
|
+
APP_GEMFILE
|
432
442
|
end
|
433
443
|
end
|
434
444
|
|
@@ -63,6 +63,9 @@ module Glimmer
|
|
63
63
|
@swt_menu_item.setMenu(swt_widget)
|
64
64
|
elsif parent.swt_widget.is_a?(Shell)
|
65
65
|
@swt_widget = swt_widget_class.new(parent.swt_widget, style('menu', styles))
|
66
|
+
elsif parent.swt_widget.is_a?(TrayItem)
|
67
|
+
@swt_widget = swt_widget_class.new(parent.shell_proxy.swt_widget, style('menu', styles))
|
68
|
+
parent.menu_proxy = self
|
66
69
|
else
|
67
70
|
@swt_widget = swt_widget_class.new(parent.swt_widget)
|
68
71
|
end
|
@@ -70,7 +73,18 @@ module Glimmer
|
|
70
73
|
if styles.include?(:bar)
|
71
74
|
DisplayProxy.instance.auto_exec { parent.swt_widget.setMenuBar(swt_widget) }
|
72
75
|
elsif styles.include?(:pop_up)
|
73
|
-
|
76
|
+
if parent.swt_widget.is_a?(TrayItem)
|
77
|
+
parent.on_widget_selected {
|
78
|
+
self.visible = true
|
79
|
+
}
|
80
|
+
parent.on_menu_detected {
|
81
|
+
self.visible = true
|
82
|
+
}
|
83
|
+
else
|
84
|
+
DisplayProxy.instance.auto_exec {
|
85
|
+
parent.swt_widget.setMenu(swt_widget) unless parent.swt_widget.is_a?(TrayItem)
|
86
|
+
}
|
87
|
+
end
|
74
88
|
end
|
75
89
|
end
|
76
90
|
|
@@ -0,0 +1,44 @@
|
|
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
|
+
require 'glimmer/swt/swt_proxy'
|
23
|
+
require 'glimmer/swt/widget_proxy'
|
24
|
+
require 'glimmer/swt/tray_proxy'
|
25
|
+
|
26
|
+
module Glimmer
|
27
|
+
module SWT
|
28
|
+
# Proxy for org.eclipse.swt.widgets.TrayItem
|
29
|
+
#
|
30
|
+
# Invoking `#swt_widget` returns the SWT TrayItem object wrapped by this proxy
|
31
|
+
#
|
32
|
+
# Follows the Proxy Design Pattern and Flyweight Design Pattern (caching memoization)
|
33
|
+
class TrayItemProxy < Glimmer::SWT::WidgetProxy
|
34
|
+
attr_reader :tray_proxy, :shell_proxy
|
35
|
+
attr_accessor :menu_proxy
|
36
|
+
|
37
|
+
def initialize(shell_proxy, *args)
|
38
|
+
@shell_proxy = shell_proxy
|
39
|
+
@tray_proxy = Glimmer::SWT::TrayProxy.instance
|
40
|
+
super('tray_item', @tray_proxy, args)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,64 @@
|
|
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
|
+
require 'glimmer/swt/display_proxy'
|
23
|
+
|
24
|
+
module Glimmer
|
25
|
+
module SWT
|
26
|
+
# Proxy for org.eclipse.swt.widgets.Tray
|
27
|
+
#
|
28
|
+
# Invoking `#swt_widget` returns the SWT Tray object wrapped by this proxy
|
29
|
+
#
|
30
|
+
# Follows the Proxy Design Pattern and Flyweight Design Pattern (caching memoization)
|
31
|
+
class TrayProxy
|
32
|
+
class << self
|
33
|
+
def instance
|
34
|
+
@instance ||= new(Glimmer::SWT::DisplayProxy.instance)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
attr_reader :swt_widget
|
39
|
+
|
40
|
+
def initialize(display_proxy)
|
41
|
+
@swt_widget = display_proxy.getSystemTray
|
42
|
+
end
|
43
|
+
|
44
|
+
def method_missing(method, *args, &block)
|
45
|
+
@swt_widget.send(method, *args, &block)
|
46
|
+
end
|
47
|
+
|
48
|
+
def respond_to?(method, *args, &block)
|
49
|
+
super || @swt_widget.respond_to?(method, *args, &block)
|
50
|
+
end
|
51
|
+
|
52
|
+
def post_initialize_child(child)
|
53
|
+
# No Op
|
54
|
+
end
|
55
|
+
|
56
|
+
# Subclasses may override to perform post add_content work.
|
57
|
+
# Make sure its logic detects if it ran before since it could run multiple times
|
58
|
+
# when adding content multiple times post creation.
|
59
|
+
def post_add_content
|
60
|
+
# No Op
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/samples/elaborate/timer.rb
CHANGED
@@ -6,7 +6,7 @@ class Timer
|
|
6
6
|
|
7
7
|
import 'javax.sound.sampled'
|
8
8
|
|
9
|
-
FILE_SOUND_ALARM = File.expand_path(File.join('timer', 'alarm1.wav'), __dir__)
|
9
|
+
FILE_SOUND_ALARM = File.expand_path(File.join('timer', 'sounds', 'alarm1.wav'), __dir__)
|
10
10
|
COMMAND_KEY = OS.mac? ? :command : :ctrl
|
11
11
|
|
12
12
|
## Add options like the following to configure CustomShell by outside consumers
|
@@ -29,6 +29,7 @@ class Weather
|
|
29
29
|
|
30
30
|
DEFAULT_FONT_HEIGHT = 30
|
31
31
|
DEFAULT_FOREGROUND = :white
|
32
|
+
DEFAULT_BACKGROUND = rgb(135, 176, 235)
|
32
33
|
|
33
34
|
attr_accessor :city, :temp, :temp_min, :temp_max, :feels_like, :humidity
|
34
35
|
|
@@ -54,7 +55,7 @@ class Weather
|
|
54
55
|
|
55
56
|
text 'Glimmer Weather'
|
56
57
|
minimum_size 400, 300
|
57
|
-
background
|
58
|
+
background DEFAULT_BACKGROUND
|
58
59
|
|
59
60
|
text {
|
60
61
|
layout_data(:center, :center, true, true)
|
@@ -78,7 +79,7 @@ class Weather
|
|
78
79
|
grid_layout 2, false
|
79
80
|
|
80
81
|
text temp_unit
|
81
|
-
background
|
82
|
+
background DEFAULT_BACKGROUND
|
82
83
|
|
83
84
|
rectangle(0, 0, [:default, -2], [:default, -2], 15, 15) {
|
84
85
|
foreground DEFAULT_FOREGROUND
|
@@ -128,8 +129,8 @@ class Weather
|
|
128
129
|
@weather_mutex.synchronize do
|
129
130
|
self.weather_data = JSON.parse(Net::HTTP.get('api.openweathermap.org', "/data/2.5/weather?q=#{city}&appid=1d16d70a9aec3570b5cbd27e6b421330"))
|
130
131
|
end
|
131
|
-
rescue
|
132
|
-
|
132
|
+
rescue => e
|
133
|
+
Glimmer::Config.logger.error "Unable to fetch weather due to error: #{e.full_message}"
|
133
134
|
end
|
134
135
|
|
135
136
|
def weather_data=(data)
|
@@ -148,14 +149,17 @@ class Weather
|
|
148
149
|
end
|
149
150
|
|
150
151
|
def kelvin_to_celsius(kelvin)
|
152
|
+
return nil if kelvin.nil?
|
151
153
|
kelvin - 273.15
|
152
154
|
end
|
153
155
|
|
154
156
|
def celsius_to_fahrenheit(celsius)
|
157
|
+
return nil if celsius.nil?
|
155
158
|
(celsius * 9 / 5 ) + 32
|
156
159
|
end
|
157
160
|
|
158
161
|
def kelvin_to_fahrenheit(kelvin)
|
162
|
+
return nil if kelvin.nil?
|
159
163
|
celsius_to_fahrenheit(kelvin_to_celsius(kelvin))
|
160
164
|
end
|
161
165
|
|
@@ -44,7 +44,7 @@ class HelloCTab
|
|
44
44
|
foreground :blue
|
45
45
|
selection_foreground :dark_blue
|
46
46
|
font name: 'Times New Roman', height: 30, style: [:bold, :italic]
|
47
|
-
image File.expand_path('
|
47
|
+
image File.expand_path('images/usa.png', __dir__)
|
48
48
|
|
49
49
|
label {
|
50
50
|
text 'Hello, World!'
|
@@ -58,7 +58,7 @@ class HelloCTab
|
|
58
58
|
foreground :blue
|
59
59
|
selection_foreground :dark_blue
|
60
60
|
font name: 'Times New Roman', height: 30, style: [:bold, :italic]
|
61
|
-
image File.expand_path('
|
61
|
+
image File.expand_path('images/france.png', __dir__)
|
62
62
|
|
63
63
|
label {
|
64
64
|
text 'Bonjour, Univers!'
|
@@ -72,7 +72,7 @@ class HelloCTab
|
|
72
72
|
foreground :blue
|
73
73
|
selection_foreground :dark_blue
|
74
74
|
font name: 'Times New Roman', height: 30, style: [:bold, :italic]
|
75
|
-
image File.expand_path('
|
75
|
+
image File.expand_path('images/mexico.png', __dir__)
|
76
76
|
|
77
77
|
label {
|
78
78
|
text 'Hola, Mundo!'
|
@@ -86,7 +86,7 @@ class HelloCTab
|
|
86
86
|
foreground :blue
|
87
87
|
selection_foreground :dark_blue
|
88
88
|
font name: 'Times New Roman', height: 30, style: [:bold, :italic]
|
89
|
-
image File.expand_path('
|
89
|
+
image File.expand_path('images/germany.png', __dir__)
|
90
90
|
|
91
91
|
label {
|
92
92
|
text 'Hallo, Welt!'
|
@@ -100,7 +100,7 @@ class HelloCTab
|
|
100
100
|
foreground :blue
|
101
101
|
selection_foreground :dark_blue
|
102
102
|
font name: 'Times New Roman', height: 30, style: [:bold, :italic]
|
103
|
-
image File.expand_path('
|
103
|
+
image File.expand_path('images/italy.png', __dir__)
|
104
104
|
|
105
105
|
label {
|
106
106
|
text 'Ciao, Mondo!'
|
@@ -114,7 +114,7 @@ class HelloCTab
|
|
114
114
|
foreground :blue
|
115
115
|
selection_foreground :dark_blue
|
116
116
|
font name: 'Times New Roman', height: 30, style: [:bold, :italic]
|
117
|
-
image File.expand_path('
|
117
|
+
image File.expand_path('images/netherlands.png', __dir__)
|
118
118
|
|
119
119
|
label {
|
120
120
|
text 'Hallo, Wereld!'
|
@@ -128,7 +128,7 @@ class HelloCTab
|
|
128
128
|
foreground :blue
|
129
129
|
selection_foreground :dark_blue
|
130
130
|
font name: 'Times New Roman', height: 30, style: [:bold, :italic]
|
131
|
-
image File.expand_path('
|
131
|
+
image File.expand_path('images/denmark.png', __dir__)
|
132
132
|
|
133
133
|
label {
|
134
134
|
text 'Hej, Verden!'
|
@@ -142,7 +142,7 @@ class HelloCTab
|
|
142
142
|
foreground :blue
|
143
143
|
selection_foreground :dark_blue
|
144
144
|
font name: 'Times New Roman', height: 30, style: [:bold, :italic]
|
145
|
-
image File.expand_path('
|
145
|
+
image File.expand_path('images/finland.png', __dir__)
|
146
146
|
|
147
147
|
label {
|
148
148
|
text 'Hei, Maailma!'
|
@@ -156,7 +156,7 @@ class HelloCTab
|
|
156
156
|
foreground :blue
|
157
157
|
selection_foreground :dark_blue
|
158
158
|
font name: 'Times New Roman', height: 30, style: [:bold, :italic]
|
159
|
-
image File.expand_path('
|
159
|
+
image File.expand_path('images/norway.png', __dir__)
|
160
160
|
|
161
161
|
label {
|
162
162
|
text 'Hei, Verden!'
|
@@ -21,9 +21,27 @@
|
|
21
21
|
|
22
22
|
require 'glimmer-dsl-swt'
|
23
23
|
|
24
|
-
require_relative 'hello_computed/contact'
|
25
|
-
|
26
24
|
class HelloComputed
|
25
|
+
class Contact
|
26
|
+
attr_accessor :first_name, :last_name, :year_of_birth
|
27
|
+
|
28
|
+
def initialize(attribute_map)
|
29
|
+
@first_name = attribute_map[:first_name]
|
30
|
+
@last_name = attribute_map[:last_name]
|
31
|
+
@year_of_birth = attribute_map[:year_of_birth]
|
32
|
+
end
|
33
|
+
|
34
|
+
def name
|
35
|
+
"#{last_name}, #{first_name}"
|
36
|
+
end
|
37
|
+
|
38
|
+
def age
|
39
|
+
Time.now.year - year_of_birth.to_i
|
40
|
+
rescue
|
41
|
+
0
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
27
45
|
include Glimmer::UI::CustomShell
|
28
46
|
|
29
47
|
before_body {
|
@@ -88,12 +88,10 @@ class EmailShell
|
|
88
88
|
end
|
89
89
|
|
90
90
|
class HelloCustomShell
|
91
|
-
include Glimmer::UI::CustomShell
|
92
|
-
|
93
91
|
Email = Struct.new(:date, :subject, :from, :message, keyword_init: true)
|
94
92
|
EmailSystem = Struct.new(:emails, keyword_init: true)
|
95
93
|
|
96
|
-
|
94
|
+
def initialize
|
97
95
|
@email_system = EmailSystem.new(
|
98
96
|
emails: [
|
99
97
|
Email.new(date: DateTime.new(2029, 10, 22, 11, 3, 0).strftime('%F %I:%M %p'), subject: '3rd Week Report', from: '"Dianne Tux" <dianne.tux@example.com>', message: "Hello,\n\nI was wondering if you'd like to go over the weekly report sometime this afternoon.\n\nDianne"),
|
@@ -104,10 +102,10 @@ class HelloCustomShell
|
|
104
102
|
Email.new(date: DateTime.new(2029, 10, 2, 10, 34, 0).strftime('%F %I:%M %p'), subject: 'Glimmer Upgrade v98.0', from: '"Robert McGabbins" <robert.mcgabbins@example.com>', message: "Team,\n\nWe are upgrading to Glimmer version 98.0.\n\nEveryone pull the latest code!\n\nRegards,\n\nRobert McGabbins"),
|
105
103
|
]
|
106
104
|
)
|
107
|
-
|
105
|
+
end
|
108
106
|
|
109
|
-
|
110
|
-
shell {
|
107
|
+
def launch
|
108
|
+
shell { |shell_proxy|
|
111
109
|
grid_layout
|
112
110
|
|
113
111
|
text 'Hello, Custom Shell!'
|
@@ -142,11 +140,19 @@ class HelloCustomShell
|
|
142
140
|
|
143
141
|
on_mouse_up { |event|
|
144
142
|
email = event.table_item.get_data
|
145
|
-
|
143
|
+
|
144
|
+
# open a custom email shell
|
145
|
+
email_shell(
|
146
|
+
parent_shell: shell_proxy,
|
147
|
+
date: email.date,
|
148
|
+
subject: email.subject,
|
149
|
+
from: email.from,
|
150
|
+
message: email.message
|
151
|
+
).open
|
146
152
|
}
|
147
153
|
}
|
148
|
-
}
|
149
|
-
|
154
|
+
}.open
|
155
|
+
end
|
150
156
|
end
|
151
157
|
|
152
|
-
HelloCustomShell.launch
|
158
|
+
HelloCustomShell.new.launch
|
@@ -0,0 +1,194 @@
|
|
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
|
+
require 'glimmer-dsl-swt'
|
23
|
+
|
24
|
+
class HelloLabel
|
25
|
+
include Glimmer::UI::CustomShell
|
26
|
+
|
27
|
+
body {
|
28
|
+
shell {
|
29
|
+
text 'Hello, Label!'
|
30
|
+
|
31
|
+
tab_folder {
|
32
|
+
tab_item {
|
33
|
+
text 'left-aligned'
|
34
|
+
|
35
|
+
grid_layout 2, true
|
36
|
+
|
37
|
+
1.upto(3) do |n|
|
38
|
+
label(:left) { # :left is default in English, so it is unnecessary
|
39
|
+
layout_data :fill, :center, true, false
|
40
|
+
text "Field #{n}"
|
41
|
+
}
|
42
|
+
text {
|
43
|
+
layout_data :fill, :center, true, false
|
44
|
+
text "Enter Field #{n}"
|
45
|
+
}
|
46
|
+
end
|
47
|
+
}
|
48
|
+
|
49
|
+
tab_item {
|
50
|
+
text 'center-aligned'
|
51
|
+
|
52
|
+
grid_layout 2, true
|
53
|
+
|
54
|
+
1.upto(3) do |n|
|
55
|
+
label(:center) {
|
56
|
+
layout_data :fill, :center, true, false
|
57
|
+
text "Field #{n}"
|
58
|
+
}
|
59
|
+
text {
|
60
|
+
layout_data :fill, :center, true, false
|
61
|
+
text "Enter Field #{n}"
|
62
|
+
}
|
63
|
+
end
|
64
|
+
}
|
65
|
+
|
66
|
+
tab_item {
|
67
|
+
text 'right-aligned'
|
68
|
+
|
69
|
+
grid_layout 2, true
|
70
|
+
|
71
|
+
1.upto(3) do |n|
|
72
|
+
label(:right) {
|
73
|
+
layout_data :fill, :center, true, false
|
74
|
+
text "Field #{n}"
|
75
|
+
}
|
76
|
+
text {
|
77
|
+
layout_data :fill, :center, true, false
|
78
|
+
text "Enter Field #{n}"
|
79
|
+
}
|
80
|
+
end
|
81
|
+
}
|
82
|
+
|
83
|
+
tab_item {
|
84
|
+
text 'images'
|
85
|
+
|
86
|
+
grid_layout 2, true
|
87
|
+
|
88
|
+
['denmark', 'finland', 'norway'].each do |image_name|
|
89
|
+
label {
|
90
|
+
layout_data :fill, :center, true, false
|
91
|
+
image File.expand_path("images/#{image_name}.png", __dir__)
|
92
|
+
}
|
93
|
+
text {
|
94
|
+
layout_data :fill, :center, true, false
|
95
|
+
text "Enter Field #{image_name.capitalize}"
|
96
|
+
}
|
97
|
+
end
|
98
|
+
}
|
99
|
+
|
100
|
+
tab_item {
|
101
|
+
text 'background images'
|
102
|
+
|
103
|
+
grid_layout 2, true
|
104
|
+
|
105
|
+
['italy', 'france', 'mexico'].each do |image_name|
|
106
|
+
label {
|
107
|
+
layout_data :center, :center, true, false
|
108
|
+
background_image File.expand_path("images/#{image_name}.png", __dir__)
|
109
|
+
text image_name.capitalize
|
110
|
+
font height: 26, style: :bold
|
111
|
+
}
|
112
|
+
text {
|
113
|
+
layout_data :fill, :center, true, false
|
114
|
+
text "Enter Field #{image_name.capitalize}"
|
115
|
+
}
|
116
|
+
end
|
117
|
+
}
|
118
|
+
|
119
|
+
tab_item {
|
120
|
+
text 'horizontal separator'
|
121
|
+
|
122
|
+
grid_layout 2, true
|
123
|
+
|
124
|
+
label {
|
125
|
+
layout_data :fill, :center, true, false
|
126
|
+
text "Field 1"
|
127
|
+
}
|
128
|
+
text {
|
129
|
+
layout_data :fill, :center, true, false
|
130
|
+
text "Enter Field 1"
|
131
|
+
}
|
132
|
+
|
133
|
+
label(:separator, :horizontal) {
|
134
|
+
layout_data(:fill, :center, true, false) {
|
135
|
+
horizontal_span 2
|
136
|
+
}
|
137
|
+
}
|
138
|
+
|
139
|
+
label {
|
140
|
+
layout_data :fill, :center, true, false
|
141
|
+
text "Field 2"
|
142
|
+
}
|
143
|
+
text {
|
144
|
+
layout_data :fill, :center, true, false
|
145
|
+
text "Enter Field 2"
|
146
|
+
}
|
147
|
+
}
|
148
|
+
|
149
|
+
tab_item {
|
150
|
+
text 'vertical separator'
|
151
|
+
|
152
|
+
grid_layout 3, true
|
153
|
+
|
154
|
+
label {
|
155
|
+
layout_data :fill, :center, true, false
|
156
|
+
text "Field 1"
|
157
|
+
}
|
158
|
+
label(:separator, :vertical) {
|
159
|
+
layout_data(:center, :center, false, false) {
|
160
|
+
vertical_span 3
|
161
|
+
}
|
162
|
+
}
|
163
|
+
text {
|
164
|
+
layout_data :fill, :center, true, false
|
165
|
+
text "Enter Field 1"
|
166
|
+
}
|
167
|
+
|
168
|
+
label {
|
169
|
+
layout_data :fill, :center, true, false
|
170
|
+
text "Field 2"
|
171
|
+
}
|
172
|
+
text {
|
173
|
+
layout_data :fill, :center, true, false
|
174
|
+
text "Enter Field 2"
|
175
|
+
}
|
176
|
+
|
177
|
+
label {
|
178
|
+
layout_data :fill, :center, true, false
|
179
|
+
text "Field 3"
|
180
|
+
}
|
181
|
+
text {
|
182
|
+
layout_data :fill, :center, true, false
|
183
|
+
text "Enter Field 3"
|
184
|
+
}
|
185
|
+
}
|
186
|
+
|
187
|
+
}
|
188
|
+
|
189
|
+
}
|
190
|
+
|
191
|
+
}
|
192
|
+
end
|
193
|
+
|
194
|
+
HelloLabel.launch
|
@@ -0,0 +1,135 @@
|
|
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
|
+
require 'glimmer-dsl-swt'
|
23
|
+
|
24
|
+
class HelloTrayItem
|
25
|
+
include Glimmer::UI::CustomShell
|
26
|
+
|
27
|
+
# boolean that indicates if application is visible
|
28
|
+
attr_accessor :show_application
|
29
|
+
|
30
|
+
before_body {
|
31
|
+
# application starts visible
|
32
|
+
@show_application = true
|
33
|
+
# pre-render an icon image using the Canvas Shape DSL
|
34
|
+
@image = image(16, 16) {
|
35
|
+
rectangle(0, 0, 16, 16) {
|
36
|
+
background :black
|
37
|
+
}
|
38
|
+
oval(1, 1, [:default, - 2], [:default, - 2]) {
|
39
|
+
foreground :white
|
40
|
+
}
|
41
|
+
oval(3, 3, [:default, - 6], [:default, - 6]) {
|
42
|
+
foreground :white
|
43
|
+
}
|
44
|
+
oval(5, 5, [:default, - 10], [:default, - 10]) {
|
45
|
+
foreground :white
|
46
|
+
}
|
47
|
+
oval(7, 7, [:default, - 14], [:default, - 14]) {
|
48
|
+
foreground :white
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
body {
|
54
|
+
shell(:shell_trim, :on_top) { # make it always appear on top of everything
|
55
|
+
row_layout(:vertical) {
|
56
|
+
center true
|
57
|
+
}
|
58
|
+
text 'Hello, Tray Item!'
|
59
|
+
|
60
|
+
on_shell_closed do |event|
|
61
|
+
# do not perform event that closes app when shell is closed
|
62
|
+
event.doit = false
|
63
|
+
# body_root is the root shell
|
64
|
+
body_root.hide
|
65
|
+
self.show_application = false # updates Show Application checkbox menu item indirectly
|
66
|
+
end
|
67
|
+
|
68
|
+
tray_item {
|
69
|
+
tool_tip_text 'Glimmer'
|
70
|
+
image @image # could use an image path instead
|
71
|
+
|
72
|
+
menu {
|
73
|
+
menu_item {
|
74
|
+
text 'About'
|
75
|
+
|
76
|
+
on_widget_selected do
|
77
|
+
message_box {
|
78
|
+
text 'Glimmer - About'
|
79
|
+
message 'This is a Glimmer DSL for SWT Tray Item'
|
80
|
+
}.open
|
81
|
+
end
|
82
|
+
}
|
83
|
+
menu_item(:separator)
|
84
|
+
menu_item(:check) {
|
85
|
+
text 'Show Application'
|
86
|
+
selection <=> [self, :show_application]
|
87
|
+
|
88
|
+
on_widget_selected do
|
89
|
+
# body_root is the root shell
|
90
|
+
if body_root.visible?
|
91
|
+
body_root.hide
|
92
|
+
else
|
93
|
+
body_root.show
|
94
|
+
end
|
95
|
+
end
|
96
|
+
}
|
97
|
+
menu_item(:separator)
|
98
|
+
menu_item {
|
99
|
+
text 'Exit'
|
100
|
+
|
101
|
+
on_widget_selected {
|
102
|
+
exit(0)
|
103
|
+
}
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
107
|
+
# supported tray item listeners (you can try to add actions to them when needed)
|
108
|
+
# on_swt_Show {
|
109
|
+
# }
|
110
|
+
#
|
111
|
+
# on_swt_Hide {
|
112
|
+
# }
|
113
|
+
#
|
114
|
+
# on_widget_selected {
|
115
|
+
# }
|
116
|
+
#
|
117
|
+
# on_menu_detected {
|
118
|
+
# }
|
119
|
+
}
|
120
|
+
|
121
|
+
label(:center) {
|
122
|
+
text 'This is the application'
|
123
|
+
font height: 30
|
124
|
+
}
|
125
|
+
label {
|
126
|
+
text 'Click on the tray item (circles icon) to open its menu'
|
127
|
+
}
|
128
|
+
label {
|
129
|
+
text 'Uncheck Show Application to hide the app and recheck it to show the app'
|
130
|
+
}
|
131
|
+
}
|
132
|
+
}
|
133
|
+
end
|
134
|
+
|
135
|
+
HelloTrayItem.launch
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-swt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.20.
|
4
|
+
version: 4.20.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -457,6 +457,8 @@ files:
|
|
457
457
|
- lib/glimmer/dsl/swt/table_items_data_binding_expression.rb
|
458
458
|
- lib/glimmer/dsl/swt/timer_exec_expression.rb
|
459
459
|
- lib/glimmer/dsl/swt/transform_expression.rb
|
460
|
+
- lib/glimmer/dsl/swt/tray_expression.rb
|
461
|
+
- lib/glimmer/dsl/swt/tray_item_expression.rb
|
460
462
|
- lib/glimmer/dsl/swt/tree_items_data_binding_expression.rb
|
461
463
|
- lib/glimmer/dsl/swt/tree_properties_expression.rb
|
462
464
|
- lib/glimmer/dsl/swt/widget_expression.rb
|
@@ -516,6 +518,8 @@ files:
|
|
516
518
|
- lib/glimmer/swt/table_proxy.rb
|
517
519
|
- lib/glimmer/swt/tool_bar_proxy.rb
|
518
520
|
- lib/glimmer/swt/transform_proxy.rb
|
521
|
+
- lib/glimmer/swt/tray_item_proxy.rb
|
522
|
+
- lib/glimmer/swt/tray_proxy.rb
|
519
523
|
- lib/glimmer/swt/tree_proxy.rb
|
520
524
|
- lib/glimmer/swt/widget_listener_proxy.rb
|
521
525
|
- lib/glimmer/swt/widget_proxy.rb
|
@@ -561,7 +565,6 @@ files:
|
|
561
565
|
- samples/elaborate/tic_tac_toe/board.rb
|
562
566
|
- samples/elaborate/tic_tac_toe/cell.rb
|
563
567
|
- samples/elaborate/timer.rb
|
564
|
-
- samples/elaborate/timer/alarm1.wav
|
565
568
|
- samples/elaborate/timer/sounds/alarm1.wav
|
566
569
|
- samples/elaborate/user_profile.rb
|
567
570
|
- samples/elaborate/weather.rb
|
@@ -569,15 +572,6 @@ files:
|
|
569
572
|
- samples/hello/hello_button.rb
|
570
573
|
- samples/hello/hello_c_combo.rb
|
571
574
|
- samples/hello/hello_c_tab.rb
|
572
|
-
- samples/hello/hello_c_tab/denmark.png
|
573
|
-
- samples/hello/hello_c_tab/finland.png
|
574
|
-
- samples/hello/hello_c_tab/france.png
|
575
|
-
- samples/hello/hello_c_tab/germany.png
|
576
|
-
- samples/hello/hello_c_tab/italy.png
|
577
|
-
- samples/hello/hello_c_tab/mexico.png
|
578
|
-
- samples/hello/hello_c_tab/netherlands.png
|
579
|
-
- samples/hello/hello_c_tab/norway.png
|
580
|
-
- samples/hello/hello_c_tab/usa.png
|
581
575
|
- samples/hello/hello_canvas.rb
|
582
576
|
- samples/hello/hello_canvas_animation.rb
|
583
577
|
- samples/hello/hello_canvas_animation_data_binding.rb
|
@@ -591,7 +585,6 @@ files:
|
|
591
585
|
- samples/hello/hello_combo.rb
|
592
586
|
- samples/hello/hello_composite.rb
|
593
587
|
- samples/hello/hello_computed.rb
|
594
|
-
- samples/hello/hello_computed/contact.rb
|
595
588
|
- samples/hello/hello_cool_bar.rb
|
596
589
|
- samples/hello/hello_cursor.rb
|
597
590
|
- samples/hello/hello_custom_shape.rb
|
@@ -605,6 +598,7 @@ files:
|
|
605
598
|
- samples/hello/hello_file_dialog.rb
|
606
599
|
- samples/hello/hello_font_dialog.rb
|
607
600
|
- samples/hello/hello_group.rb
|
601
|
+
- samples/hello/hello_label.rb
|
608
602
|
- samples/hello/hello_layout.rb
|
609
603
|
- samples/hello/hello_link.rb
|
610
604
|
- samples/hello/hello_list_multi_selection.rb
|
@@ -625,8 +619,18 @@ files:
|
|
625
619
|
- samples/hello/hello_table/baseball_park.png
|
626
620
|
- samples/hello/hello_text.rb
|
627
621
|
- samples/hello/hello_tool_bar.rb
|
622
|
+
- samples/hello/hello_tray_item.rb
|
628
623
|
- samples/hello/hello_tree.rb
|
629
624
|
- samples/hello/hello_world.rb
|
625
|
+
- samples/hello/images/denmark.png
|
626
|
+
- samples/hello/images/finland.png
|
627
|
+
- samples/hello/images/france.png
|
628
|
+
- samples/hello/images/germany.png
|
629
|
+
- samples/hello/images/italy.png
|
630
|
+
- samples/hello/images/mexico.png
|
631
|
+
- samples/hello/images/netherlands.png
|
632
|
+
- samples/hello/images/norway.png
|
633
|
+
- samples/hello/images/usa.png
|
630
634
|
- sounds/metronome-down.wav
|
631
635
|
- sounds/metronome-up.wav
|
632
636
|
- vendor/swt/linux/swt.jar
|
Binary file
|