glimmer-dsl-swt 4.17.2.2 → 4.17.2.3

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: d7523b15b5a850c249c3aff9ad499861ee10ecd051de1084221fbbe456237330
4
- data.tar.gz: 5ac2fcb76137fe377268c8f38fd09f37fe94193351629213a30d1cc8b4b4707b
3
+ metadata.gz: 72abd42bfd0a4074ba03517643ae4f560cc892d1d592cefd9d96b7a4990195de
4
+ data.tar.gz: 6479abb04a31e9bd5670a4de48c9c98a46f7b05783f4491082c4e0c127f5aa1c
5
5
  SHA512:
6
- metadata.gz: ebf5035466675f7cb5b3151950c7d244a6deda09c0e0a0a7b516ca6a67a673f371377f706ec8377db62c0e1eb5a983789ac1e4e3627a660ba88322596af72388
7
- data.tar.gz: 14a95141c001e279b305cee7ed90295bc620e1bb08fa897f5e72b90dc283d50abc242b7c71896d65c6c981de6785ab69f2d94c927c5fdc5320e793541f97d1fb
6
+ metadata.gz: 46ecd1fbe2700184f8b3ea5f447cd7d3e2209a777080d40a787821edee1d65d7525e28befd96bd4ec5dbd48f646371810470eeef8777388d60bd6fce823da525
7
+ data.tar.gz: 74ecccfa3cbb21712178fa695ddbd2eed4cb3cbb400aae3b3bf5b5dc5358ccba3ae2ff056d1992d7adfc0dcd173dcf77cf52a6f6e4ecabe961f5ece49c6b69d9
@@ -1,5 +1,14 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.17.2.3
4
+
5
+ - Maintain image file path upon scaling an ImageProxy
6
+ - Add a glimmer rake task that wraps the juwelier rake gemspec:generate task
7
+ - Accept `ImageProxy` as arg for `image` and `background_image` property methods
8
+ - (EXPERIMENTAL) Animate gif images when set as a `background_image` on a `composite`
9
+ - Fix issue with table redraw after data-binding changes leaving old removed table items visible (even if user cannot interact with anymore)
10
+ - Fix issue with running package rake task from `glimmer` command TUI
11
+
3
12
  ### 4.17.2.2
4
13
 
5
14
  - Small updates/refactorings in samples
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.17.2.2
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.17.2.3
2
2
  ## JRuby Desktop Development GUI Library
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)
@@ -428,7 +428,7 @@ jgem install glimmer-dsl-swt
428
428
 
429
429
  Or this command if you want a specific version:
430
430
  ```
431
- jgem install glimmer-dsl-swt -v 4.17.2.2
431
+ jgem install glimmer-dsl-swt -v 4.17.2.3
432
432
  ```
433
433
 
434
434
  Note: 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.
@@ -505,7 +505,7 @@ bin/glimmer sample:run[hello_world]
505
505
  Below are the full usage instructions that come up when running `glimmer` without args.
506
506
 
507
507
  ```
508
- Glimmer (Ruby Desktop Development GUI Library) - JRuby Gem: glimmer-dsl-swt v4.17.2.2
508
+ Glimmer (Ruby Desktop Development GUI Library) - JRuby Gem: glimmer-dsl-swt v4.17.2.3
509
509
 
510
510
  Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
511
511
 
@@ -534,6 +534,7 @@ Select a Glimmer task to run: (Press ↑/↓ arrow to move, Enter to select and
534
534
  glimmer package[type] # Package app for distribution (generating config, jar, and native files) (type is optional)
535
535
  glimmer package:clean # Clean by removing "dist" and "packages" directories
536
536
  glimmer package:config # Generate JAR config file
537
+ glimmer package:gemspec # Generate gemspec
537
538
  glimmer package:jar # Generate JAR file
538
539
  glimmer package:lock_jars # Lock JARs
539
540
  glimmer package:native[type] # Generate Native files
@@ -620,7 +621,7 @@ This will run the hello_tab sample and output its code:
620
621
  ```
621
622
  $ glimmer sample:run[hello_tab]
622
623
 
623
- # /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.2/samples/hello/hello_tab.rb
624
+ # /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.3/samples/hello/hello_tab.rb
624
625
 
625
626
  class HelloTab
626
627
  include Glimmer
@@ -665,7 +666,7 @@ Example:
665
666
  ```
666
667
  $ glimmer sample:code[tic_tac_toe]
667
668
 
668
- # /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.2/samples/elaborate/tic_tac_toe.rb
669
+ # /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.3/samples/elaborate/tic_tac_toe.rb
669
670
 
670
671
  require_relative "tic_tac_toe/board"
671
672
 
@@ -726,7 +727,7 @@ TicTacToe.new.open
726
727
  # # #
727
728
 
728
729
 
729
- # /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.2/samples/elaborate/tic_tac_toe/cell.rb
730
+ # /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.3/samples/elaborate/tic_tac_toe/cell.rb
730
731
 
731
732
  class TicTacToe
732
733
  class Cell
@@ -759,7 +760,7 @@ end
759
760
  # # #
760
761
 
761
762
 
762
- # /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.2/samples/elaborate/tic_tac_toe/board.rb
763
+ # /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.3/samples/elaborate/tic_tac_toe/board.rb
763
764
 
764
765
  require_relative 'cell'
765
766
 
@@ -1040,7 +1041,7 @@ Only official Glimmer gems created by the Glimmer project committers will have n
1040
1041
 
1041
1042
  Since custom shell gems are both an app and a gem, they provide two ways to run:
1042
1043
  - Run the `glimmer` command and pass it the generated script under the `bin` directory that matches the gem name (e.g. run `glimmer bin/glimmer-cs-calculator`)
1043
- - Run the executable binary file that ships with the gem directly (without `glimmer`). It intentionally has a shorter name for convenience since it is meant to be used on the command line (not in a package), so you can leave out the `glimmer-cs-` prefix (e.g. run `bin/calculator` directly)
1044
+ - Run the executable shell script that ships with the gem directly (does not need the `glimmer` command). It intentionally has a shorter name for convenience since it is meant to be used on the command line (not in a package), so you can leave out the `glimmer-cs-` prefix (e.g. run `bin/calculator` directly). This is also used as the main way of running custom shell gems on Linux.
1044
1045
 
1045
1046
  Examples:
1046
1047
 
@@ -1191,7 +1192,7 @@ Output:
1191
1192
 
1192
1193
  Css glimmer-dsl-css 1.1.0 AndyMaleh Glimmer DSL for CSS
1193
1194
  Opal glimmer-dsl-opal 0.3.0 AndyMaleh Glimmer DSL for Opal
1194
- Swt glimmer-dsl-swt 4.17.2.2 AndyMaleh Glimmer DSL for SWT
1195
+ Swt glimmer-dsl-swt 4.17.2.3 AndyMaleh Glimmer DSL for SWT
1195
1196
  Tk glimmer-dsl-tk 0.0.5 AndyMaleh Glimmer DSL for Tk
1196
1197
  Xml glimmer-dsl-xml 1.1.0 AndyMaleh Glimmer DSL for XML
1197
1198
  ```
@@ -1207,10 +1208,28 @@ On Linux, the Glimmer [Custom Shell Gem](#custom-shell-gem) approach provides a
1207
1208
  ### Raw JRuby Command
1208
1209
 
1209
1210
  If there is a need to run Glimmer directly via the `jruby` command, you
1210
- may run the following:
1211
+ may run the following on Windows/Linux:
1211
1212
 
1212
1213
  ```
1213
- jruby -J-classpath "path_to/swt.jar" -r glimmer -S application.rb
1214
+ jruby -r glimmer-dsl-swt -S application.rb
1215
+ ```
1216
+
1217
+ Or, the following on Mac:
1218
+
1219
+ ```
1220
+ jruby -J-XstartOnFirstThread -r glimmer-dsl-swt -S application.rb
1221
+ ```
1222
+
1223
+ If you want to use a specific custom version of SWT, run the following on Windows/Linux:
1224
+
1225
+ ```
1226
+ jruby -J-classpath "path_to/swt.jar" -r glimmer-dsl-swt -S application.rb
1227
+ ```
1228
+
1229
+ Or, the following on Mac:
1230
+
1231
+ ```
1232
+ jruby -J-XstartOnFirstThread -J-classpath "path_to/swt.jar" -r glimmer-dsl-swt -S application.rb
1214
1233
  ```
1215
1234
 
1216
1235
  The `-J-classpath` option specifies the `swt.jar` file path, which can be a
@@ -1228,7 +1247,7 @@ However, if there is a reason to use the raw `jruby` command directly instead of
1228
1247
 
1229
1248
  Example:
1230
1249
  ```
1231
- jruby -J-XstartOnFirstThread -J-classpath "path_to/swt.jar" -r glimmer -S application.rb
1250
+ jruby -J-XstartOnFirstThread -J-classpath "path_to/swt.jar" -r glimmer-dsl-swt -S application.rb
1232
1251
  ```
1233
1252
 
1234
1253
  ## Girb (Glimmer irb) Command
@@ -1312,19 +1331,21 @@ Glimmer DSL syntax consists mainly of:
1312
1331
 
1313
1332
  ### DSL Auto-Expansion
1314
1333
 
1315
- Glimmer supports a new and radical Ruby DSL concept called DSL Auto-Expansion. It is explained by first mentioning the two types of Glimmer GUI DSL keywords: static and dynamic.
1334
+ Glimmer supports a new and radical Ruby DSL concept called DSL Auto-Expansion. To explain, let's first mention the two types of Glimmer GUI DSL keywords: static and dynamic.
1316
1335
 
1317
1336
  Static keywords are pre-identified keywords in the Glimmer DSL, such as `shell`, `display`, `message_box`, `async_exec`, `sync_exec`, and `bind`.
1318
1337
 
1319
- Dynamic keywords are dynamically figured out from currently imported (aka required/loaded) SWT widgets, custom widgets, and widget properties. Examples are: `label`, `combo`, and `list` for widgets and `enabled`, `text`, and `selection` for properties.
1338
+ Dynamic keywords are dynamically figured out from currently imported (aka required/loaded) SWT widgets and custom widgets. Examples are: `label`, `combo`, and `list` for SWT widgets and `c_date_time`, `video`, and `gantt_chart` for custom widgets.
1339
+
1340
+ The only reason to distinguish between the two is to realize that importing new Glimmer [custom widgets](#custom-widgets) and Java SWT custom widget libraries automatically expands Glimmer's DSL vocabulary with new dynamic keywords.
1320
1341
 
1321
- The only reason to distinguish between the two types of Glimmer DSL keywords is to realize that importing new Glimmer [custom widgets](#custom-widgets) and Java SWT custom widget libraries automatically expands Glimmer's DSL vocabulary via new dynamic keywords.
1342
+ For example, if a project adds this custom Java SWT library from the [Nebula Project](https://www.eclipse.org/nebula/):
1322
1343
 
1323
- For example, if a project adds this custom Java SWT library:
1344
+ https://www.eclipse.org/nebula/widgets/gallery/gallery.php
1324
1345
 
1325
- https://www.eclipse.org/nebula/widgets/cdatetime/cdatetime.php?page=operation
1346
+ Glimmer will automatically support using the keyword `gallery`
1326
1347
 
1327
- Glimmer will automatically support using the keyword `c_date_time`
1348
+ This is what DSL Auto-Expansion is.
1328
1349
 
1329
1350
  You will learn more about widgets next.
1330
1351
 
@@ -1439,6 +1460,10 @@ shell {
1439
1460
 
1440
1461
  If you are new to Glimmer, you have learned enough to start running some [samples](#samples). Go ahead and run all Glimmer [samples](#samples), and come back to read the rest in any order you like since this material is more organized like a reference.
1441
1462
 
1463
+ If you are advanced and need more widgets, check out the [Nebula Project](https://www.eclipse.org/nebula/) for an extensive list of high quality custom widgets:
1464
+
1465
+ https://www.eclipse.org/nebula/
1466
+
1442
1467
  #### Display
1443
1468
 
1444
1469
  SWT Display is a singleton in Glimmer. It is used in SWT to represent your display device, allowing you to manage GUI globally
@@ -2636,6 +2661,8 @@ end
2636
2661
 
2637
2662
  Custom widgets are brand new Glimmer DSL keywords that represent aggregates of existing widgets (e.g. `address_form`), customized existing widgets (e.g. `greeting_label`), or brand new widgets (e.g. `oscilloscope`)
2638
2663
 
2664
+ You can find out about [published Glimmer Custom Widgets](https://github.com/AndyObtiva/glimmer-dsl-swt#gem-listing) by running the `glimmer list:gems:customwidget` command
2665
+
2639
2666
  Glimmer supports two ways of creating custom widgets with minimal code:
2640
2667
  1. Method-based Custom Widgets (for single-view-internal reuse): Extract a method containing Glimmer DSL widget syntax. Useful for quickly eliminating redundant code within a single view.
2641
2668
  2. Class-based Custom Widgets (for multiple-view-external reuse): Create a class that includes the `Glimmer::UI::CustomWidget` module and Glimmer DSL widget syntax in a `body {}` block. This will automatically extend Glimmer's DSL syntax with an underscored lowercase keyword matching the class name by convention. Useful in making a custom widget available in many views.
@@ -2842,6 +2869,8 @@ Custom shells are a kind of custom widgets that have shells only as the body roo
2842
2869
 
2843
2870
  They may also be chained in a wizard fashion.
2844
2871
 
2872
+ You can find out about [published Glimmer Custom Shells](https://github.com/AndyObtiva/glimmer-dsl-swt#gem-listing) by running the `glimmer list:gems:customshell` command
2873
+
2845
2874
  Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
2846
2875
 
2847
2876
  ```ruby
@@ -3461,6 +3490,10 @@ Here is an SWT Custom Widget guide:
3461
3490
 
3462
3491
  https://www.eclipse.org/articles/Article-Writing%20Your%20Own%20Widget/Writing%20Your%20Own%20Widget.htm
3463
3492
 
3493
+ Here is the Nebula Project (custom widget library) homepage:
3494
+
3495
+ https://www.eclipse.org/nebula/
3496
+
3464
3497
  ## Samples
3465
3498
 
3466
3499
  Check the [samples](samples) directory in [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) for examples on how to write Glimmer applications. To run a sample, make sure to install the `glimmer` gem first and then use the `glimmer` command to run it (alternatively, you may clone the repo, follow [CONTRIBUTING.md](CONTRIBUTING.md) instructions, and run samples locally with development glimmer command: `bin/glimmer`).
@@ -3860,7 +3893,7 @@ require 'glimmer/rake_task'
3860
3893
 
3861
3894
  The Glimmer packaging process done in the `glimmer package` command consists of the following steps:
3862
3895
  1. Generate gemspec via [Juwelier](https://rubygems.org/gems/juwelier) (`rake gemspec:generate`): Having a gemspec is required by the [`jar-dependencies`](https://github.com/mkristian/jar-dependencies) JRuby gem, used by JRuby libraries to declare JAR dependencies.
3863
- 1. Lock JAR versions (`glimmer package:lock_jars`): This locks versions of JAR dependencies leveraged by the `jar-dependencies` JRuby gem, downloading them into the `./vendor` directory so they would get inside the top-level Glimmer app/gem JAR file.
3896
+ 1. Lock JAR versions (`glimmer package:4.17.2.3`): This locks versions of JAR dependencies leveraged by the `jar-dependencies` JRuby gem, downloading them into the `./vendor` directory so they would get inside the top-level Glimmer app/gem JAR file.
3864
3897
  1. Generate [Warbler](https://github.com/jruby/warbler) config (`glimmer package:config`): Generates initial Warbler config file (under `./config/warble.rb`) to use for generating JAR file.
3865
3898
  1. Generate JAR file using [Warbler](https://github.com/jruby/warbler) (`glimmer package:jar`): Enables bundling a Glimmer app into a JAR file under the `./dist` directory
3866
3899
  1. Generate native executable using [javapackager](https://docs.oracle.com/javase/8/docs/technotes/tools/unix/javapackager.html) (`glimmer package:native`): Enables packaging a JAR file as a DMG/PKG/APP file on Mac, MSI/EXE/APP on Windows, and DEB/RPM/APP on Linux (Glimmer does not officially support Linux with the `glimmer package` command yet, but it generates the JAR file successfully, and you could use `javapackager` manually afterwards if needed).
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.17.2.2
1
+ 4.17.2.3
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: glimmer-dsl-swt 4.17.2.2 ruby lib
5
+ # stub: glimmer-dsl-swt 4.17.2.3 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "glimmer-dsl-swt".freeze
9
- s.version = "4.17.2.2"
9
+ s.version = "4.17.2.3"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["AndyMaleh".freeze]
14
- s.date = "2020-10-14"
14
+ s.date = "2020-10-16"
15
15
  s.description = "Glimmer DSL for SWT (JRuby Desktop Development GUI Library)".freeze
16
16
  s.email = "andy.am@gmail.com".freeze
17
17
  s.executables = ["glimmer".freeze, "girb".freeze]
@@ -144,6 +144,7 @@ Glimmer::Config.excluded_keyword_checkers << lambda do |method_symbol, *args|
144
144
  result ||= method == 'dispose' && is_a?(Glimmer::UI::CustomWidget) && respond_to?(method)
145
145
  result ||= ['drag_source_proxy', 'drop_target_proxy'].include?(method) && is_a?(Glimmer::UI::CustomWidget)
146
146
  result ||= method == 'post_initialize_child'
147
+ result ||= method == 'handle'
147
148
  result ||= method.end_with?('=')
148
149
  result ||= ['finish_edit!', 'search', 'all_tree_items', 'depth_first_search'].include?(method) && is_a?(Glimmer::UI::CustomWidget) && body_root.respond_to?(method)
149
150
  end
@@ -80,6 +80,7 @@ module Glimmer
80
80
  selected_table_items = [parent.swt_widget.getItems.first].to_java(TableItem) if selected_table_items.empty? && !parent.swt_widget.getItems.empty?
81
81
  parent.swt_widget.setSelection(selected_table_items) unless selected_table_items.empty?
82
82
  parent.sort
83
+ parent.swt_widget.redraw if parent&.swt_widget&.respond_to?(:redraw)
83
84
  end
84
85
  end
85
86
  end
@@ -76,6 +76,11 @@ namespace :glimmer do
76
76
  Glimmer::RakeTask::Package.clean
77
77
  end
78
78
 
79
+ desc 'Generate gemspec'
80
+ task :gemspec do
81
+ Glimmer::RakeTask::Package.gemspec
82
+ end
83
+
79
84
  desc 'Generate JAR config file'
80
85
  task :config do
81
86
  Glimmer::RakeTask::Package.config
@@ -100,7 +105,7 @@ namespace :glimmer do
100
105
 
101
106
  desc 'Package app for distribution (generating config, jar, and native files) (type is optional)'
102
107
  task :package, [:type] do |t, args|
103
- Rake::Task['gemspec:generate'].execute
108
+ Rake::Task['glimmer:package:gemspec'].execute
104
109
  Rake::Task['glimmer:package:lock_jars'].execute
105
110
  Rake::Task['glimmer:package:config'].execute
106
111
  Rake::Task['glimmer:package:jar'].execute
@@ -35,6 +35,18 @@ module Glimmer
35
35
  FileUtils.rm_rf('packages')
36
36
  end
37
37
 
38
+ def gemspec
39
+ system 'rake gemspec:generate'
40
+ end
41
+
42
+ def lock_jars
43
+ puts 'Locking gem jar-dependencies by downloading & storing in vendor/jars...'
44
+ FileUtils.mkdir_p('vendor/jars')
45
+ command = "lock_jars --vendor-dir vendor/jars"
46
+ puts command
47
+ system command
48
+ end
49
+
38
50
  def config
39
51
  project_name = File.basename(File.expand_path('.'))
40
52
  if !File.exists?('config/warble.rb')
@@ -72,14 +84,6 @@ module Glimmer
72
84
  system('warble')
73
85
  end
74
86
 
75
- def lock_jars
76
- puts 'Locking gem jar-dependencies by downloading & storing in vendor/jars...'
77
- FileUtils.mkdir_p('vendor/jars')
78
- command = "lock_jars --vendor-dir vendor/jars"
79
- puts command
80
- system command
81
- end
82
-
83
87
  def native(native_type=nil, native_extra_args)
84
88
  puts "Generating native executable with javapackager/jpackage..."
85
89
  require 'facets/string/titlecase'
@@ -39,27 +39,38 @@ module Glimmer
39
39
  def initialize(*args)
40
40
  @args = args
41
41
  @file_path = @args.first if @args.first.is_a?(String) && @args.size == 1
42
- if @file_path
43
- if @file_path.start_with?('uri:classloader')
44
- @jar_file_path = @file_path
45
- @file_path = @jar_file_path.sub(/^uri\:classloader\:/, '').sub('//', '/') # the latter sub is needed for Mac
46
- object = java.lang.Object.new
47
- file_input_stream = object.java_class.resource_as_stream(file_path)
48
- buffered_file_input_stream = java.io.BufferedInputStream.new(file_input_stream)
49
- end
50
- @image_data = ImageData.new(buffered_file_input_stream || @file_path)
42
+ options = @args.delete_at(-1) if @args.last.is_a?(Hash)
43
+ if options&.keys&.include?(:swt_image)
44
+ @swt_image = options[:swt_image]
45
+ @image_data = @swt_image.image_data
46
+ elsif @file_path
47
+ @image_data = ImageData.new(input_stream || @file_path)
51
48
  @swt_image = Image.new(DisplayProxy.instance.swt_display, @image_data)
52
49
  else
53
50
  @swt_image = Image.new(*@args)
54
51
  @image_data = @swt_image.image_data
55
52
  end
56
53
  end
54
+
55
+ def input_stream
56
+ if @file_path.start_with?('uri:classloader')
57
+ @jar_file_path = @file_path
58
+ file_path = @jar_file_path.sub(/^uri\:classloader\:/, '').sub('//', '/') # the latter sub is needed for Mac
59
+ object = java.lang.Object.new
60
+ file_input_stream = object.java_class.resource_as_stream(file_path)
61
+ else
62
+ file_input_stream = java.io.FileInputStream.new(@file_path)
63
+ end
64
+ java.io.BufferedInputStream.new(file_input_stream) if file_input_stream
65
+ end
57
66
 
58
67
  def scale_to(width, height)
59
68
  scaled_image_data = image_data.scaledTo(width, height)
60
69
  device = swt_image.device
61
70
  swt_image.dispose
62
71
  @swt_image = Image.new(device, scaled_image_data)
72
+ @image_data = @swt_image.image_data
73
+ self
63
74
  end
64
75
 
65
76
  def method_missing(method, *args, &block)
@@ -23,6 +23,7 @@ require 'glimmer/swt/widget_listener_proxy'
23
23
  require 'glimmer/swt/color_proxy'
24
24
  require 'glimmer/swt/font_proxy'
25
25
  require 'glimmer/swt/swt_proxy'
26
+ require 'glimmer/swt/display_proxy'
26
27
  require 'glimmer/swt/dnd_proxy'
27
28
  require 'glimmer/swt/image_proxy'
28
29
 
@@ -204,7 +205,7 @@ module Glimmer
204
205
  widget_custom_attribute = widget_custom_attribute_mapping[attribute_name.to_s]
205
206
  if widget_custom_attribute
206
207
  widget_custom_attribute[:setter][:invoker].call(@swt_widget, args)
207
- elsif @swt_widget.respond_to?(attribute_setter(attribute_name), args)
208
+ elsif @swt_widget.respond_to?(attribute_setter(attribute_name))
208
209
  apply_property_type_converters(attribute_name, args)
209
210
  @swt_widget.send(attribute_setter(attribute_name), *args) unless @swt_widget.send(attribute_getter(attribute_name)) == args.first
210
211
  else
@@ -683,21 +684,54 @@ module Glimmer
683
684
  },
684
685
  :background => color_converter,
685
686
  :background_image => lambda do |value|
686
- image_proxy = nil
687
- if value.is_a?(String)
688
- image_proxy = ImageProxy.new(value)
687
+ # TODO push this code to ImageProxy
688
+ image_proxy = if value.is_a?(String)
689
+ ImageProxy.new(value)
689
690
  elsif value.is_a?(Array)
690
- image_proxy = ImageProxy.new(*value)
691
- end
692
- if image_proxy
693
- on_swt_Resize do |resize_event|
694
- image_proxy.scale_to(@swt_widget.getSize.x, @swt_widget.getSize.y)
695
- @swt_widget.setBackgroundImage(image_proxy.swt_image)
696
- end
697
- image_proxy.swt_image
691
+ ImageProxy.new(*value)
692
+ elsif value.is_a?(Image)
693
+ ImageProxy.new(swt_image: value)
698
694
  else
699
695
  value
700
696
  end
697
+
698
+ if image_proxy&.file_path&.end_with?('.gif')
699
+ image = image_proxy.swt_image
700
+ width = image.get_bounds.width.to_i
701
+ height = image.get_bounds.height.to_i
702
+ image_number = 0
703
+ loader = ImageLoader.new
704
+ loader.load(image_proxy.input_stream)
705
+ image.dispose
706
+ image = org.eclipse.swt.graphics.Image.new(DisplayProxy.instance.swt_display,loader.data[0].scaledTo(width, height))
707
+ gc = org.eclipse.swt.graphics.GC.new(image)
708
+ on_paint_control { |event|
709
+ image_number = (image_number == loader.data.length - 1) ? 0 : image_number + 1
710
+ next_frame_data = loader.data[image_number]
711
+ image = org.eclipse.swt.graphics.Image.new(DisplayProxy.instance.swt_display, next_frame_data.scaledTo(width, height))
712
+ event.gc.drawImage(image, 0, 0, width, height, 0, 0, width, height)
713
+ image.dispose
714
+ }
715
+ Thread.new {
716
+ last_image_number = -1
717
+ while last_image_number != image_number
718
+ last_image_number = image_number
719
+ sync_exec {
720
+ redraw
721
+ }
722
+ delayTime = loader.data[image_number].delayTime.to_f / 100.0
723
+ sleep(delayTime)
724
+ end
725
+ };
726
+ image_proxy = nil
727
+ else
728
+ on_swt_Resize do |resize_event|
729
+ image_proxy.scale_to(@swt_widget.getSize.x, @swt_widget.getSize.y)
730
+ @swt_widget.setBackgroundImage(image_proxy.swt_image)
731
+ end
732
+ end
733
+
734
+ image_proxy&.swt_image
701
735
  end,
702
736
  :cursor => lambda do |value|
703
737
  cursor_proxy = nil
@@ -718,13 +752,16 @@ module Glimmer
718
752
  end
719
753
  end,
720
754
  :image => lambda do |value|
721
- if value.is_a?(String)
755
+ image_proxy = if value.is_a?(String)
722
756
  ImageProxy.new(value).swt_image
723
757
  elsif value.is_a?(Array)
724
758
  ImageProxy.new(*value).swt_image
759
+ elsif value.is_a?(Image)
760
+ ImageProxy.new(swt_image: value)
725
761
  else
726
762
  value
727
763
  end
764
+ image_proxy.swt_image
728
765
  end,
729
766
  :images => lambda do |array|
730
767
  array.to_a.map do |value|
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.17.2.2
4
+ version: 4.17.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-14 00:00:00.000000000 Z
11
+ date: 2020-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement