glimmer-dsl-swt 4.20.4.3 → 4.20.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 13212fd4b8a440d635d5172b493b979d12a1ec1da94e7ea50c5c55521e4ae80c
4
- data.tar.gz: d7c3004d04d20b0c14e8f6f72ac4be6368844e0ecb892962c021414291e3a0d8
3
+ metadata.gz: 4d7ca988f6d990ae7520a2b6319c538a793f7499a23713e97ce02f32e3db2bec
4
+ data.tar.gz: a50dfa303380c6415d6a286f351a55931a4b1e09d73d7cc3e4602b52a00c179d
5
5
  SHA512:
6
- metadata.gz: 6420272e89fe681bd64d68b4db5dc25ac19a52efd20e00e3a72b840ead51dcb3755396bd1b9e72a6e36b96719348c609c275e2827805809e7ecefdc00727d327
7
- data.tar.gz: 40b0acce99bf96c49f5499034271faf126c40b5e8870ff62c9b22bf8f6501448cd7256cf583c30d2928e06572ee02862cae1445feac71427b29ef7d829a09f6c
6
+ metadata.gz: a8739fded7624fc8a007850dfa84fabeba144ffd3830fb83284e6abd733be75d8500da1be339d4827f30e14d702a4472f271198d90101d30573696f6a6dfdb14
7
+ data.tar.gz: c95d53ca9b574ec413b1630c2b415deb2fa3e65a091bc3d5d40b391b3c6083db5e74158c3f9d3572523682c4a02e75afee465ffef2e83f96cbc3bbc7e671698a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.20.6.0
4
+
5
+ - Canvas Animation DSL: support parallel animations per canvas (running along canvas static shapes too)
6
+
7
+ ### 4.20.5.2
8
+
9
+ - Identify trimmed Canvas Shape DSL attribute `fill_rule` styles without `fill_` prefix
10
+ - Identify trimmed Canvas Shape DSL attribute `line_cap` styles without `cap_` prefix
11
+ - Identify trimmed Canvas Shape DSL attribute `line_join` styles without `join_` prefix
12
+
13
+ ### 4.20.5.1
14
+
15
+ - Fix issue with Namespace is required always showing up when buildling a custom widget gem or custom shape gem
16
+
17
+ ### 4.20.5.0
18
+
19
+ - Relax glimmer-dsl-swt version number when scaffolding custom shape/widget/shell gems. Keep it strict for app development.
20
+ - 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).
21
+ - Hello, Tray Item! Sample
22
+
3
23
  ### 4.20.4.2
4
24
 
5
25
  - Hello, Label!
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.4.3
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.6.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.4.3 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).
18
+ [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.20.6.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.4.3
350
+ jgem install glimmer-dsl-swt -v 4.20.6.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.4.3'
378
+ gem 'glimmer-dsl-swt', '~> 4.20.6.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.4.3
399
+ Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.20.6.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.4.3
1
+ 4.20.6.0
@@ -18,6 +18,7 @@ This guide should help you get started with Glimmer DSL for SWT. For more advanc
18
18
  - [sync_exec](#sync_exec)
19
19
  - [timer_exec](#timer_exec)
20
20
  - [Menus](#menus)
21
+ - [Tray Item](#tray-item)
21
22
  - [ScrolledComposite](#scrolledcomposite)
22
23
  - [Sash Form Widget](#sash-form-widget)
23
24
  - [Browser Widget](#browser-widget)
@@ -872,6 +873,101 @@ shell {
872
873
  }.open
873
874
  ```
874
875
 
876
+ #### Tray Item
877
+
878
+ ![Hello Tray Item Icon](/images/glimmer-hello-tray-item.png)
879
+
880
+ The system tray allows showing icons for various apps that need to stay on for extended periods of time and provide quick access.
881
+
882
+ In Glimmer DSL for SWT, generating tray items is automated via the `tray_item` keyword, which can be nested under `shell` and then have a child `menu` underneath that pops up when the user clicks on its icon in the system tray.
883
+
884
+ Note how the shell was declared with the `:on_top` style (in addition to the default, which is `:shell_trim`) to ensure it opens above all apps when the "Show Application" menu item is selected.
885
+
886
+ Example code:
887
+
888
+ ```ruby
889
+ shell(:shell_trim, :on_top) { # make it always appear on top of everything
890
+ row_layout(:vertical) {
891
+ center true
892
+ }
893
+ text 'Hello, Tray Item!'
894
+
895
+ on_shell_closed do |event|
896
+ # do not perform event that closes app when shell is closed
897
+ event.doit = false
898
+ # body_root is the root shell
899
+ body_root.hide
900
+ self.show_application = false # updates Show Application checkbox menu item indirectly
901
+ end
902
+
903
+ tray_item {
904
+ tool_tip_text 'Glimmer'
905
+ image @image # could use an image path instead
906
+
907
+ menu {
908
+ menu_item {
909
+ text 'About'
910
+
911
+ on_widget_selected do
912
+ message_box {
913
+ text 'Glimmer - About'
914
+ message 'This is a Glimmer DSL for SWT Tray Item'
915
+ }.open
916
+ end
917
+ }
918
+ menu_item(:separator)
919
+ menu_item(:check) {
920
+ text 'Show Application'
921
+ selection <=> [self, :show_application]
922
+
923
+ on_widget_selected do
924
+ # body_root is the root shell
925
+ if body_root.visible?
926
+ body_root.hide
927
+ else
928
+ body_root.show
929
+ end
930
+ end
931
+ }
932
+ menu_item(:separator)
933
+ menu_item {
934
+ text 'Exit'
935
+
936
+ on_widget_selected {
937
+ exit(0)
938
+ }
939
+ }
940
+ }
941
+
942
+ # supported tray item listeners (you can try to add actions to them when needed)
943
+ # on_swt_Show {
944
+ # }
945
+ #
946
+ # on_swt_Hide {
947
+ # }
948
+ #
949
+ # on_widget_selected {
950
+ # }
951
+ #
952
+ # on_menu_detected {
953
+ # }
954
+ }
955
+
956
+ label(:center) {
957
+ text 'This is the application'
958
+ font height: 30
959
+ }
960
+ label {
961
+ text 'Click on the tray item (circles icon) to open its menu'
962
+ }
963
+ label {
964
+ text 'Uncheck Show Application to hide the app and recheck it to show the app'
965
+ }
966
+ }
967
+ ```
968
+
969
+ Learn more at [Hello, Tray Item!](/docs/reference/GLIMMER_SAMPLES.md#hello-tray-item)
970
+
875
971
  #### ScrolledComposite
876
972
 
877
973
  Glimmer provides smart defaults for the `scrolled_composite` widget by:
@@ -2147,13 +2243,13 @@ Learn more at the [Hello, Canvas Transform! Sample](GLIMMER_SAMPLES.md#hello-can
2147
2243
 
2148
2244
  (note: this is a very new feature of Glimmer. It may change a bit while getting battle tested. As always, you could default to basic SWT usage if needed.)
2149
2245
 
2150
- Glimmer additionally provides built-in support for animations via a declarative Animation DSL, another sub-DSL of the Glimmer GUI DSL.
2246
+ Glimmer provides built-in support for animations via a declarative Animation DSL, another sub-DSL of the Glimmer GUI DSL.
2151
2247
 
2152
- Animations take advantage of multi-threading, automatically running each animation in its own independent thread of execution while updating the GUI asynchronously.
2248
+ Animations take advantage of multi-threading, with Glimmer DSL for SWT automatically running each animation in its own independent thread of execution while updating the GUI asynchronously.
2153
2249
 
2154
- Multiple simultaneous animations are supported by declaring an animation per `canvas` (or widget) parent.
2250
+ Multiple simultaneous animations are supported per `canvas` (or widget) parent (they do not compete or starve each other).
2155
2251
 
2156
- `canvas` has the `:double_buffered` SWT style by default to ensure flicker-free rendering. If you need to disable it for whatever reason, just pass the `:none` SWT style instead (e.g. `canvas(:none)`)
2252
+ `canvas` has the `:double_buffered` SWT style by default on platforms other than the Mac to ensure flicker-free rendering (Mac does not need it). If you need to disable it for whatever reason, just pass the `:none` SWT style instead (e.g. `canvas(:none)`)
2157
2253
 
2158
2254
  This example says it all (it moves a tiny red square across a blue background) (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
2159
2255
 
@@ -52,6 +52,7 @@
52
52
  - [Hello, Custom Shape!](#hello-custom-shape)
53
53
  - [Hello, Tool Bar!](#hello-tool-bar)
54
54
  - [Hello, Cool Bar!](#hello-cool-bar)
55
+ - [Hello, Tray Item!](#hello-tray-item)
55
56
  - [Elaborate Samples](#elaborate-samples)
56
57
  - [User Profile](#user-profile)
57
58
  - [Login](#login)
@@ -942,6 +943,26 @@ Hello, Cool Bar!
942
943
 
943
944
  ![Hello Cool Bar Reorg3](/images/glimmer-hello-cool-bar-reorg3.png)
944
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
+
945
966
  ### Elaborate Samples
946
967
 
947
968
  For more elaborate samples, check the following:
Binary file
@@ -0,0 +1,43 @@
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
+
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
36
+
37
+ def interpret(parent, keyword, *args, &block)
38
+ Glimmer::SWT::TrayProxy.instance
39
+ end
40
+ end
41
+ end
42
+ end
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
- GEMFILE = <<~MULTI_LINE_STRING
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', 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)
@@ -302,13 +312,13 @@ module Glimmer
302
312
  end
303
313
 
304
314
  def custom_widget_gem(custom_widget_name, namespace)
305
- return puts('Namespace is required! Usage: glimmer scaffold:custom_widget_gem[custom_widget_name,namespace]') unless `git config --get github.user`.to_s.strip == 'AndyObtiva'
306
315
  gem_name = "glimmer-cw-#{compact_name(custom_widget_name)}"
307
316
  gem_summary = "#{human_name(custom_widget_name)} - Glimmer Custom Widget"
308
317
  if namespace
309
318
  gem_name += "-#{compact_name(namespace)}"
310
319
  gem_summary += " (#{human_name(namespace)})"
311
320
  else
321
+ return puts('Namespace is required! Usage: glimmer scaffold:custom_widget_gem[custom_widget_name,namespace]') unless `git config --get github.user`.to_s.strip == 'AndyObtiva'
312
322
  namespace = 'glimmer'
313
323
  end
314
324
 
@@ -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', 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)
@@ -340,13 +350,13 @@ module Glimmer
340
350
  end
341
351
 
342
352
  def custom_shape_gem(custom_shape_name, namespace)
343
- return puts('Namespace is required! Usage: glimmer scaffold:custom_shape_gem[custom_shape_name,namespace]') unless `git config --get github.user`.to_s.strip == 'AndyObtiva'
344
353
  gem_name = "glimmer-cp-#{compact_name(custom_shape_name)}"
345
354
  gem_summary = "#{human_name(custom_shape_name)} - Glimmer Custom Shape"
346
355
  if namespace
347
356
  gem_name += "-#{compact_name(namespace)}"
348
357
  gem_summary += " (#{human_name(namespace)})"
349
358
  else
359
+ return puts('Namespace is required! Usage: glimmer scaffold:custom_shape_gem[custom_shape_name,namespace]') unless `git config --get github.user`.to_s.strip == 'AndyObtiva'
350
360
  namespace = 'glimmer'
351
361
  end
352
362
 
@@ -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', 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 = GEMFILE.split("\n")
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
- GEMFILE
441
+ APP_GEMFILE
432
442
  end
433
443
  end
434
444
 
@@ -20,6 +20,7 @@
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  require 'glimmer/swt/properties'
23
+ require 'glimmer/swt/custom/shape'
23
24
 
24
25
  module Glimmer
25
26
  module SWT
@@ -222,8 +223,12 @@ module Glimmer
222
223
  self.class.schedule_frame_animation(self) do
223
224
  if started? && start_number == @start_number && within_duration_limit?
224
225
  unless @parent.isDisposed
225
- @parent.clear_shapes # TODO adjust this to clear only the shapes of this animation (not all shapes) to allow simultaneous animations to occur on the same parent
226
- @parent.content { frame_block.call(*block_args) }
226
+ @shapes.to_a.each(&:dispose)
227
+ parent_shapes_before = @parent.shapes.clone
228
+ @parent.content {
229
+ frame_block.call(*block_args)
230
+ }
231
+ @shapes = @parent.shapes - parent_shapes_before
227
232
  end
228
233
  else
229
234
  if stopped? && @frame_index > current_frame_index
@@ -295,6 +295,15 @@ module Glimmer
295
295
  if method_name.to_s == 'setLineStyle'
296
296
  args[0] = "line_#{args[0]}" if !args[0].to_s.downcase.start_with?('line_')
297
297
  end
298
+ if method_name.to_s == 'setFillRule'
299
+ args[0] = "fill_#{args[0]}" if !args[0].to_s.downcase.start_with?('fill_')
300
+ end
301
+ if method_name.to_s == 'setLineCap'
302
+ args[0] = "cap_#{args[0]}" if !args[0].to_s.downcase.start_with?('cap_')
303
+ end
304
+ if method_name.to_s == 'setLineJoin'
305
+ args[0] = "join_#{args[0]}" if !args[0].to_s.downcase.start_with?('join_')
306
+ end
298
307
  if the_java_method.parameter_types.first == Java::int.java_class
299
308
  args[0] = SWTProxy.constant(args[0])
300
309
  end
@@ -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
- DisplayProxy.instance.auto_exec { parent.swt_widget.setMenu(swt_widget) }
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
@@ -25,27 +25,30 @@ include Glimmer
25
25
 
26
26
  shell {
27
27
  text 'Hello, Canvas Animation!'
28
- minimum_size 800, 420
28
+ minimum_size 1200, 420
29
29
 
30
30
  canvas {
31
+ background :white
32
+
31
33
  animation {
32
34
  every 0.01 # in seconds (one hundredth)
33
35
 
34
36
  frame { |index| # frame block loops indefinitely (unless frame_count is set to an integer)
35
- background rgb(index%255, 100, 200) # sets canvas background color
36
-
37
37
  oval(0, 0, 400, 400) { # x, y, width, height
38
38
  foreground :black # sets oval background color
39
39
  }
40
40
  arc(0, 0, 400, 400, -1.4*index%360, 10) { # x, y, width, height, start angle, arc angle
41
- background rgb(200, 200, 50) # sets arc background color
41
+ background rgb(50, 200, 50) # sets arc background color
42
42
  }
43
43
  }
44
44
  }
45
45
  }
46
46
 
47
47
  canvas {
48
+ background :white
49
+
48
50
  colors = [:yellow, :red]
51
+
49
52
  animation {
50
53
  every 0.25 # in seconds (one quarter)
51
54
  cycle colors # cycles array of colors into the second variable of the frame block below
@@ -65,4 +68,42 @@ shell {
65
68
  }
66
69
  }
67
70
  }
71
+
72
+ canvas {
73
+ background :white
74
+
75
+ colors = [:yellow, :red]
76
+
77
+ animation {
78
+ every 0.25 # in seconds (one quarter)
79
+ cycle colors # cycles array of colors into the second variable of the frame block below
80
+
81
+ frame { |index, color| # frame block loops indefinitely (unless frame_count or cycle_count is set to an integer)
82
+ outside_color = colors[index % 2]
83
+ inside_color = colors[(index + 1) % 2]
84
+
85
+ background outside_color # sets canvas background color
86
+
87
+ rectangle(0, 0, 200, 200) {
88
+ background inside_color # sets rectangle background color
89
+ }
90
+ rectangle(200, 200, 200, 200) {
91
+ background inside_color # sets rectangle background color
92
+ }
93
+ }
94
+ }
95
+
96
+ animation {
97
+ every 0.01 # in seconds (one hundredth)
98
+
99
+ frame { |index| # frame block loops indefinitely (unless frame_count is set to an integer)
100
+ oval(0, 0, 400, 400) { # x, y, width, height
101
+ foreground :black # sets oval background color
102
+ }
103
+ arc(0, 0, 400, 400, -1.4*index%360, 10) { # x, y, width, height, start angle, arc angle
104
+ background rgb(50, 200, 50) # sets arc background color
105
+ }
106
+ }
107
+ }
108
+ }
68
109
  }.open
@@ -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
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.3
4
+ version: 4.20.6.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-15 00:00:00.000000000 Z
11
+ date: 2021-07-17 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
@@ -615,6 +619,7 @@ files:
615
619
  - samples/hello/hello_table/baseball_park.png
616
620
  - samples/hello/hello_text.rb
617
621
  - samples/hello/hello_tool_bar.rb
622
+ - samples/hello/hello_tray_item.rb
618
623
  - samples/hello/hello_tree.rb
619
624
  - samples/hello/hello_world.rb
620
625
  - samples/hello/images/denmark.png