glimmer-dsl-swt 4.22.0.0 → 4.22.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +191 -169
  3. data/README.md +5 -5
  4. data/VERSION +1 -1
  5. data/docs/reference/GLIMMER_COMMAND.md +2 -2
  6. data/docs/reference/GLIMMER_CONFIGURATION.md +14 -3
  7. data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +98 -20
  8. data/docs/reference/GLIMMER_SAMPLES.md +13 -0
  9. data/glimmer-dsl-swt.gemspec +0 -0
  10. data/lib/ext/glimmer/config.rb +41 -24
  11. data/lib/glimmer/data_binding/observable_widget.rb +6 -6
  12. data/lib/glimmer/data_binding/widget_binding.rb +2 -1
  13. data/lib/glimmer/dsl/swt/observe_expression.rb +2 -1
  14. data/lib/glimmer/dsl/swt/transform_expression.rb +1 -1
  15. data/lib/glimmer/launcher.rb +15 -14
  16. data/lib/glimmer/rake_task/scaffold.rb +2 -14
  17. data/lib/glimmer/swt/color_proxy.rb +5 -5
  18. data/lib/glimmer/swt/custom/drawable.rb +4 -0
  19. data/lib/glimmer/swt/custom/shape/line.rb +0 -1
  20. data/lib/glimmer/swt/custom/shape/path.rb +2 -2
  21. data/lib/glimmer/swt/custom/shape/path_segment.rb +2 -2
  22. data/lib/glimmer/swt/custom/shape/point.rb +8 -1
  23. data/lib/glimmer/swt/custom/shape.rb +170 -69
  24. data/lib/glimmer/swt/display_proxy.rb +15 -10
  25. data/lib/glimmer/swt/image_proxy.rb +5 -5
  26. data/lib/glimmer/swt/message_box_proxy.rb +5 -5
  27. data/lib/glimmer/swt/shape_listener_proxy.rb +55 -0
  28. data/lib/glimmer/swt/transform_proxy.rb +3 -3
  29. data/lib/glimmer/swt/tray_proxy.rb +4 -4
  30. data/lib/glimmer/swt/widget_proxy.rb +5 -7
  31. data/lib/glimmer/ui/custom_shape.rb +34 -10
  32. data/lib/glimmer/ui/custom_widget.rb +3 -8
  33. data/lib/glimmer-dsl-swt.rb +6 -2
  34. data/samples/elaborate/klondike_solitaire/model/column_pile.rb +0 -1
  35. data/samples/elaborate/klondike_solitaire/view/column_pile.rb +3 -16
  36. data/samples/elaborate/klondike_solitaire/view/dealing_pile.rb +1 -1
  37. data/samples/elaborate/klondike_solitaire/view/dealt_pile.rb +12 -5
  38. data/samples/elaborate/klondike_solitaire/view/empty_playing_card.rb +2 -1
  39. data/samples/elaborate/klondike_solitaire/view/foundation_pile.rb +2 -2
  40. data/samples/elaborate/klondike_solitaire/view/hidden_playing_card.rb +2 -2
  41. data/samples/elaborate/klondike_solitaire/view/klondike_solitaire_menu_bar.rb +60 -0
  42. data/samples/elaborate/klondike_solitaire/view/playing_card.rb +3 -2
  43. data/samples/elaborate/klondike_solitaire.rb +13 -55
  44. data/samples/elaborate/mandelbrot_fractal.rb +3 -1
  45. data/samples/elaborate/quarto/model/game.rb +124 -0
  46. data/samples/elaborate/quarto/model/piece/cube.rb +31 -0
  47. data/samples/elaborate/quarto/model/piece/cylinder.rb +31 -0
  48. data/samples/elaborate/quarto/model/piece.rb +70 -0
  49. data/samples/elaborate/quarto/view/available_pieces_area.rb +72 -0
  50. data/samples/elaborate/quarto/view/board.rb +65 -0
  51. data/samples/elaborate/quarto/view/cell.rb +85 -0
  52. data/samples/elaborate/quarto/view/cube.rb +73 -0
  53. data/samples/elaborate/quarto/view/cylinder.rb +72 -0
  54. data/samples/elaborate/quarto/view/message_box_panel.rb +114 -0
  55. data/samples/elaborate/quarto/view/piece.rb +56 -0
  56. data/samples/elaborate/quarto/view/selected_piece_area.rb +69 -0
  57. data/samples/elaborate/quarto.rb +190 -0
  58. data/samples/hello/hello_custom_widget.rb +23 -5
  59. metadata +17 -23
  60. data/bin/glimmer_runner.rb +0 -4
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.22.0.0
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.22.1.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)
@@ -17,7 +17,7 @@ Featured in JRuby Cookbook](http://shop.oreilly.com/product/9780596519650.do) an
17
17
 
18
18
  ![Eclipse SWT RCP NASA Mars Rover](/images/glimmer-eclipse-swt-rcp-nasa-mars-rover.png)
19
19
 
20
- [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.22.0.0 includes [SWT 4.22](https://download.eclipse.org/eclipse/downloads/drops4/R-4.22-202111241800/), which was released on November 24, 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 (please report any issues you may encounter).
20
+ [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.22.1.0 includes [SWT 4.22](https://download.eclipse.org/eclipse/downloads/drops4/R-4.22-202111241800/), which was released on November 24, 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 (please report any issues you may encounter).
21
21
 
22
22
  **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.
23
23
 
@@ -325,7 +325,7 @@ jgem install glimmer-dsl-swt
325
325
 
326
326
  Or this command if you want a specific version:
327
327
  ```
328
- jgem install glimmer-dsl-swt -v 4.22.0.0
328
+ jgem install glimmer-dsl-swt -v 4.22.1.0
329
329
  ```
330
330
 
331
331
  `jgem` is JRuby's version of `gem` command.
@@ -353,7 +353,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
353
353
 
354
354
  Add the following to `Gemfile`:
355
355
  ```
356
- gem 'glimmer-dsl-swt', '~> 4.22.0.0'
356
+ gem 'glimmer-dsl-swt', '~> 4.22.1.0'
357
357
  ```
358
358
 
359
359
  And, then run:
@@ -376,7 +376,7 @@ glimmer
376
376
  ```
377
377
 
378
378
  ```
379
- Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.22.0.0
379
+ Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.22.1.0
380
380
 
381
381
  Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
382
382
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.22.0.0
1
+ 4.22.1.0
@@ -227,13 +227,13 @@ glimmer bin/greeter
227
227
 
228
228
  #### Desktopify
229
229
 
230
- Desktopify basically turns a website into a desktop application by wrapping the website within a [Browser Widget](#browser-widget).
230
+ Desktopify basically turns a website into a desktop application by wrapping the website within a [Browser Widget](/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#browser-widget).
231
231
 
232
232
  The desktopify app is similar to the standard scaffolded app. It can be extended and the [browser may even be instrumented](https://help.eclipse.org/2020-09/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/browser/Browser.html).
233
233
 
234
234
  The app even remembers your cookies if you log into the website, close the app, and reopen again.
235
235
 
236
- Note that on Linux, the default SWT browser, which runs on webkit, does not support HTML5 Video out of the box. If you need video support, open `Gemfile` after scaffolding and enable the line that has the `glimmer-cw-browser-chromium` gem then replace the `browser` in "app/views/snowboard_utah/app_view.rb" with `browser(:chromium)`
236
+ Note that on Linux, the default SWT browser, which runs on webkit, does not support HTML5 Video out of the box. If you need video support on Linux, you may try the [JxBrowser](https://www.teamdev.com/jxbrowser) SWT widget instead, which embeds Chromium instead.
237
237
 
238
238
  Before you start, make sure you are in a JRuby environment with Glimmer gem installed as per "Direct Install" pre-requisites.
239
239
 
@@ -13,7 +13,7 @@ Example:
13
13
  ```ruby
14
14
  Glimmer::Config.logger.level = :debug
15
15
  ```
16
- This results in more verbose debug loggging to `STDOUT`, which is very helpful in troubleshooting Glimmer DSL syntax when needed.
16
+ This results in more verbose debug logging to `STDOUT`, which is very helpful in troubleshooting Glimmer DSL syntax when needed.
17
17
 
18
18
  Example log:
19
19
  ```
@@ -37,9 +37,20 @@ To reset `logger` to the default instance, you may call `Glimmer::Config.reset_l
37
37
 
38
38
  All logging is done lazily via blocks (e.g. `logger.debug {message}`) to avoid affecting app performance with logging when below the configured logging level threshold.
39
39
 
40
- [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) enhances Glimmer default logging support via the Ruby [`logging`](https://github.com/TwP/logging) gem, enabling buffered asynchronous logging in a separate thread, thus completely unhindering normal desktop app performance.
40
+ Optionally, [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) enhances Glimmer default logging support via the Ruby [`logging`](https://github.com/TwP/logging) gem, enabling buffered asynchronous logging in a separate thread, thus completely unhindering normal desktop app performance.
41
41
 
42
- Other config options related to the [`logging`](https://github.com/TwP/logging) gem are mentioned below.
42
+ You can alternatively use the [logging](https://github.com/TwP/logging) gem for asynchronous logging (note that it adds about 0.5 - 1.0 second to startup time) by adding the gem:
43
+ ```ruby
44
+ gem 'logging', '>= 2.3.0', '< 3.0.0'
45
+ ```
46
+
47
+ And, updating the logger type:
48
+ ```ruby
49
+ require 'logging'
50
+ Glimmer::Config.logger_type = :logging
51
+ ```
52
+
53
+ Other config options related to the [logging](https://github.com/TwP/logging) gem are mentioned below.
43
54
 
44
55
  #### logging_devices
45
56
 
@@ -69,6 +69,7 @@ This guide should help you get started with Glimmer DSL for SWT. For more advanc
69
69
  - [Class-Based Custom Widget Example](#class-based-custom-widget-example)
70
70
  - [Custom Widget Lifecycle Hooks](#custom-widget-lifecycle-hooks)
71
71
  - [Lifecycle Hooks Example](#lifecycle-hooks-example)
72
+ - [Custom Widget Listeners](#custom-widget-listeners)
72
73
  - [Custom Widget API](#custom-widget-api)
73
74
  - [Content/Options Example](#contentoptions-example)
74
75
  - [Custom Widget Gotchas](#custom-widget-gotchas)
@@ -1107,6 +1108,8 @@ shell {
1107
1108
  }.open
1108
1109
  ```
1109
1110
 
1111
+ This relies on Glimmer's [Multi-DSL Support](#multi-dsl-support) for building the HTML text using [Glimmer XML DSL](https://github.com/AndyObtiva/glimmer-dsl-xml).
1112
+
1110
1113
  Learn more at the [SWT Browser widget](https://help.eclipse.org/2020-12/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/browser/Browser.html) API.
1111
1114
 
1112
1115
  ### Widget Styles
@@ -3119,7 +3122,7 @@ Approach #1 is a casual Ruby-based approach. Approach #2 is the official Glimmer
3119
3122
 
3120
3123
  A developer might start with approach #1 to eliminate duplication in a view and later upgrade it to approach #2 when needing to export a custom widget to make it available in many views.
3121
3124
 
3122
- Class-based Custom Widgets a number of benefits over method-based custom widgets, such as built-in support for passing SWT style, nested block of extra widgets and properties, and `before_body`/`after_body` hooks.
3125
+ Class-based Custom Widgets offer a number of benefits over method-based custom widgets, such as built-in support for passing SWT style, nested block of extra widgets and properties, and `before_body`/`after_body` hooks.
3123
3126
 
3124
3127
  #### Simple Example
3125
3128
 
@@ -3217,6 +3220,100 @@ Notice how `Red::Composite` became `red__composite` with double-underscore, whic
3217
3220
 
3218
3221
  Keep in mind that namespaces are not needed to be specified if the Custom Widget class has a unique name, not clashing with a basic SWT widget or another custom widget name.
3219
3222
 
3223
+ #### Custom Widget Listeners
3224
+
3225
+ If you need to declare a custom listener on a custom widget, you must override these methods:
3226
+ - `can_handle_observation_request?(event, &block)`: returns if an event is supported or delegates to super otherwise (to ensure continued support for built-in events)
3227
+ - `handle_observation_request(event, &block)`: handles event by storing the block in a list of block handlers to invoke at the right time in the custom widget code
3228
+
3229
+ Example (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
3230
+
3231
+ ```ruby
3232
+ require 'glimmer-dsl-swt'
3233
+
3234
+ # This class declares a `greeting_label` custom widget (by convention)
3235
+ class GreetingLabel
3236
+ include Glimmer::UI::CustomWidget
3237
+
3238
+ # multiple options without default values
3239
+ options :name, :colors
3240
+
3241
+ # single option with default value
3242
+ option :greeting, default: 'Hello'
3243
+
3244
+ # internal attribute (not a custom widget option)
3245
+ attr_accessor :label_color
3246
+
3247
+ def can_handle_observation_request?(event, &block)
3248
+ event.to_s == 'on_color_changed' || super
3249
+ end
3250
+
3251
+ def handle_observation_request(event, &block)
3252
+ if event.to_s == 'on_color_changed'
3253
+ @color_changed_handlers ||= []
3254
+ @color_changed_handlers << block
3255
+ else
3256
+ super
3257
+ end
3258
+ end
3259
+
3260
+ before_body do
3261
+ @font = {height: 24, style: :bold}
3262
+ @label_color = :black
3263
+ end
3264
+
3265
+ after_body do
3266
+ return if colors.nil?
3267
+
3268
+ Thread.new {
3269
+ colors.cycle { |color|
3270
+ self.label_color = color
3271
+ @color_changed_handlers&.each {|handler| handler.call(color)}
3272
+ sleep(1)
3273
+ }
3274
+ }
3275
+ end
3276
+
3277
+ body {
3278
+ # pass received swt_style through to label to customize (e.g. :center to center text)
3279
+ label(swt_style) {
3280
+ text "#{greeting}, #{name}!"
3281
+ font @font
3282
+ foreground <=> [self, :label_color]
3283
+ }
3284
+ }
3285
+
3286
+ end
3287
+
3288
+ # including Glimmer enables the Glimmer DSL syntax, including auto-discovery of the `greeting_label` custom widget
3289
+ include Glimmer
3290
+
3291
+ shell {
3292
+ fill_layout :vertical
3293
+
3294
+ minimum_size 215, 215
3295
+ text 'Hello, Custom Widget!'
3296
+
3297
+ # custom widget options are passed in a hash
3298
+ greeting_label(name: 'Sean')
3299
+
3300
+ # pass :center SWT style followed by custom widget options hash
3301
+ greeting_label(:center, name: 'Laura', greeting: 'Aloha') #
3302
+
3303
+ greeting_label(:right, name: 'Rick') {
3304
+ # you can nest attributes under custom widgets just like any standard widget
3305
+ foreground :red
3306
+ }
3307
+
3308
+ # the colors option cycles between colors for the label foreground every second
3309
+ greeting_label(:center, name: 'Mary', greeting: 'Aloha', colors: [:red, :dark_green, :blue]) {
3310
+ on_color_changed do |color|
3311
+ puts "Label color changed: #{color}"
3312
+ end
3313
+ }
3314
+ }.open
3315
+ ```
3316
+
3220
3317
  #### Custom Widget API
3221
3318
 
3222
3319
  Custom Widgets have the following attributes available to call from inside the `#body` method:
@@ -4041,25 +4138,6 @@ You may run `glimmer` with the `--profile.graph` instead for a more detailed out
4041
4138
 
4042
4139
  Learn more at the [JRuby Performance Profile WIKI page](https://github.com/jruby/jruby/wiki/Profiling-JRuby).
4043
4140
 
4044
- ##### SWT Browser Style Options
4045
-
4046
- The `browser` widget can use a particular desktop browser by setting the SWT Style to:
4047
- - `:webkit`: use the Webkit browser engine
4048
- - `:chromium`: use the Chromium browser engine
4049
-
4050
- Example using the Chromium browser (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
4051
-
4052
- ```ruby
4053
- shell {
4054
- minimum_size 1024, 860
4055
- browser(:chromium) {
4056
- url 'http://brightonresort.com/about'
4057
- }
4058
- }.open
4059
- ```
4060
-
4061
- This relies on Glimmer's [Multi-DSL Support](#multi-dsl-support) for building the HTML text using [Glimmer XML DSL](https://github.com/AndyObtiva/glimmer-dsl-xml).
4062
-
4063
4141
  ## License
4064
4142
 
4065
4143
  [MIT](LICENSE.txt)
@@ -78,6 +78,7 @@
78
78
  - [Stock Ticker](#stock-ticker)
79
79
  - [Metronome](#metronome)
80
80
  - [Weather](#weather)
81
+ - [Quarto](#quarto)
81
82
  - [External Samples](#external-samples)
82
83
  - [Glimmer Calculator](#glimmer-calculator)
83
84
  - [Gladiator](#gladiator)
@@ -1369,6 +1370,18 @@ Atlanta - Fahrenheit
1369
1370
 
1370
1371
  ![Atlanta F](/images/glimmer-weather-atlanta-fahrenheit.png)
1371
1372
 
1373
+ #### Quarto
1374
+
1375
+ This sample is a classic game called [Quarto](https://en.gigamic.com/game/quarto-classic), which demonstrates Canvas Drag and Drop and Custom Shapes (`cylinder`, `cube`, and `message_box_panel`) in an MVC application.
1376
+
1377
+ Code:
1378
+
1379
+ [samples/elaborate/quarto.rb](/samples/elaborate/quarto.rb)
1380
+
1381
+ Quarto
1382
+
1383
+ ![Quarto](/images/glimmer-quarto.png)
1384
+
1372
1385
  ### External Samples
1373
1386
 
1374
1387
  #### Glimmer Calculator
Binary file
@@ -59,6 +59,20 @@ module Glimmer
59
59
  end
60
60
  alias auto_sync_exec? auto_sync_exec
61
61
 
62
+ # allowed logger types are :logger (default) and :logging (logging gem supporting async logging)
63
+ # updating logger type value resets logger
64
+ def logger_type=(logger_type_class)
65
+ @@logger_type = logger_type_class
66
+ reset_logger!
67
+ end
68
+
69
+ def logger_type
70
+ unless defined? @@logger_type
71
+ @@logger_type = :logger
72
+ end
73
+ @@logger_type
74
+ end
75
+
62
76
  # Returns Logging Devices. Default is [:stdout, :syslog]
63
77
  def logging_devices
64
78
  unless defined? @@logging_devices
@@ -112,39 +126,42 @@ module Glimmer
112
126
  reset_logger!
113
127
  end
114
128
 
129
+ alias reset_logger_without_glimmer_dsl_swt! reset_logger!
115
130
  def reset_logger!
116
- @first_time = !defined?(@@logger)
117
- old_level = logger.level unless @first_time
118
- self.logger = Logging.logger['glimmer'].tap do |logger|
119
- logger.level = old_level || :error
120
- appenders = []
121
- appenders << Logging.appenders.stdout(logging_appender_options) if logging_devices.include?(:stdout)
122
- appenders << Logging.appenders.stderr(logging_appender_options) if logging_devices.include?(:stderr)
123
- if logging_devices.include?(:file)
124
- require 'fileutils'
125
- FileUtils.mkdir_p('log')
126
- appenders << Logging.appenders.rolling_file('log/glimmer.log', logging_appender_options.merge(logging_device_file_options)) if logging_devices.include?(:file)
131
+ if logger_type == :logger
132
+ reset_logger_without_glimmer_dsl_swt!
133
+ else
134
+ require 'logging'
135
+ @first_time = !defined?(@@logger)
136
+ old_level = logger.level unless @first_time
137
+ self.logger = Logging.logger['glimmer'].tap do |logger|
138
+ logger.level = old_level || :error
139
+ appenders = []
140
+ appenders << Logging.appenders.stdout(logging_appender_options) if logging_devices.include?(:stdout)
141
+ appenders << Logging.appenders.stderr(logging_appender_options) if logging_devices.include?(:stderr)
142
+ if logging_devices.include?(:file)
143
+ require 'fileutils'
144
+ FileUtils.mkdir_p('log')
145
+ appenders << Logging.appenders.rolling_file('log/glimmer.log', logging_appender_options.merge(logging_device_file_options)) if logging_devices.include?(:file)
146
+ end
147
+ if Object.const_defined?(:Syslog) && logging_devices.include?(:syslog)
148
+ Syslog.close if Syslog.opened?
149
+ appenders << Logging.appenders.syslog('glimmer', logging_appender_options)
150
+ end
151
+ logger.appenders = appenders
127
152
  end
128
- if Object.const_defined?(:Syslog) && logging_devices.include?(:syslog)
129
- Syslog.close if Syslog.opened?
130
- appenders << Logging.appenders.syslog('glimmer', logging_appender_options)
131
- end
132
- logger.appenders = appenders
133
153
  end
134
-
135
154
  end
136
-
137
155
  end
138
-
139
156
  end
140
-
141
157
  end
142
158
 
143
- Glimmer::Config.reset_logger! unless ENV['GLIMMER_LOGGER_ENABLED'].to_s.downcase == 'false'
144
159
  if ENV['GLIMMER_LOGGER_LEVEL']
145
- # if glimmer log level is being overridden for debugging purposes, then disable async logging making logging immediate
146
- Glimmer::Config.logging_appender_options = Glimmer::Config.logging_appender_options.merge(async: false, auto_flushing: 1, immediate_at: [:unknown, :debug, :info, :error, :fatal])
147
- Glimmer::Config.logging_devices = [:stdout]
160
+ if Glimmer::Config.logger_type == :logging
161
+ # if glimmer log level is being overridden for debugging purposes, then disable async logging making logging immediate
162
+ Glimmer::Config.logging_appender_options = Glimmer::Config.logging_appender_options.merge(async: false, auto_flushing: 1, immediate_at: [:unknown, :debug, :info, :error, :fatal])
163
+ Glimmer::Config.logging_devices = [:stdout]
164
+ end
148
165
  begin
149
166
  puts "Adjusting Glimmer logging level to #{ENV['GLIMMER_LOGGER_LEVEL']}"
150
167
  Glimmer::Config.logger.level = ENV['GLIMMER_LOGGER_LEVEL'].strip
@@ -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
@@ -25,9 +25,9 @@ module Glimmer
25
25
  # TODO see if it is worth it to eliminate duplication of method_missing
26
26
  # from WidgetProxy using a module
27
27
 
28
- def method_missing(method, *args, &block)
29
- method_name = method.to_s
30
- if can_handle_observation_request?(method_name)
28
+ def method_missing(method_name, *args, &block)
29
+ method_name = method_name.to_s
30
+ if block && can_handle_observation_request?(method_name)
31
31
  handle_observation_request(method_name, &block)
32
32
  else
33
33
  super
@@ -38,11 +38,12 @@ module Glimmer
38
38
  @sync_exec = sync_exec
39
39
  @async_exec = async_exec
40
40
  SWT::DisplayProxy.instance.auto_exec(override_sync_exec: @sync_exec, override_async_exec: @async_exec) do
41
- if @widget.respond_to?(:on_widget_disposed)
41
+ if @widget.is_a?(Glimmer::SWT::WidgetProxy) && @widget.respond_to?(:on_widget_disposed)
42
42
  @widget.on_widget_disposed do |dispose_event|
43
43
  deregister_all_observables unless @widget.shell_proxy.last_shell_closing?
44
44
  end
45
45
  end
46
+ # TODO look into hooking on_shape_disposed without slowing down shapes in samples like Tetris
46
47
  end
47
48
  end
48
49
 
@@ -23,6 +23,7 @@ require 'glimmer/dsl/static_expression'
23
23
  require 'glimmer/dsl/top_level_expression'
24
24
  require 'glimmer/dsl/observe_expression'
25
25
  require 'glimmer/ui/custom_widget'
26
+ require 'glimmer/swt/display_proxy'
26
27
 
27
28
  module Glimmer
28
29
  module DSL
@@ -33,7 +34,7 @@ module Glimmer
33
34
 
34
35
  def interpret(parent, keyword, *args, &block)
35
36
  observer_registration = super
36
- Glimmer::UI::CustomWidget.current_custom_widgets.last&.observer_registrations&.push(observer_registration)
37
+ Glimmer::SWT::DisplayProxy.current_custom_widgets_and_shapes.last&.observer_registrations&.push(observer_registration)
37
38
  observer_registration
38
39
  end
39
40
  end
@@ -34,7 +34,7 @@ module Glimmer
34
34
 
35
35
  def can_interpret?(parent, keyword, *args, &block)
36
36
  super and
37
- (parent.nil? or parent.is_a?(Glimmer::SWT::Custom::Shape))
37
+ (parent.nil? or parent.is_a?(Glimmer::SWT::Custom::Shape) or parent.is_a?(Glimmer::UI::CustomShape))
38
38
  end
39
39
 
40
40
  def interpret(parent, keyword, *args, &block)
@@ -89,8 +89,7 @@ module Glimmer
89
89
  def glimmer_lib
90
90
  unless @glimmer_lib
91
91
  @glimmer_lib = GLIMMER_LIB_GEM
92
- glimmer_gem_listing = `jgem list #{GLIMMER_LIB_GEM}`.split("\n").map {|l| l.split.first}
93
- if !glimmer_gem_listing.include?(GLIMMER_LIB_GEM) && File.exists?(GLIMMER_LIB_LOCAL)
92
+ if File.exists?(GLIMMER_LIB_LOCAL)
94
93
  @glimmer_lib = GLIMMER_LIB_LOCAL
95
94
  puts "[DEVELOPMENT MODE] (detected #{@glimmer_lib})"
96
95
  end
@@ -121,18 +120,21 @@ module Glimmer
121
120
  ENV[k] = v
122
121
  end
123
122
  the_glimmer_lib = glimmer_lib
124
- if the_glimmer_lib == GLIMMER_LIB_LOCAL
125
- require 'puts_debuggerer'
123
+ require 'puts_debuggerer' if the_glimmer_lib == GLIMMER_LIB_LOCAL
124
+ is_rake_task = !application.end_with?('.rb')
125
+ rake_tasks = []
126
+ if is_rake_task
127
+ load File.expand_path('./Rakefile') if File.exist?(File.expand_path('./Rakefile')) && caller.join("\n").include?('/bin/glimmer:')
128
+ require_relative 'rake_task'
129
+ rake_tasks = Rake.application.tasks.map(&:to_s).map {|t| t.sub('glimmer:', '')}
130
+
131
+ # handle a bash quirk with calling package[msi] while there is a "packages" directory locally (it passes package[msi] as packages)
132
+ application = 'package[msi]' if application == 'packages'
133
+
134
+ potential_rake_task_parts = application.match(REGEX_RAKE_TASK_WITH_ARGS)
135
+ application = potential_rake_task_parts[1]
136
+ rake_task_args = potential_rake_task_parts[2].split(',')
126
137
  end
127
- require_relative 'rake_task'
128
- rake_tasks = Rake.application.tasks.map(&:to_s).map {|t| t.sub('glimmer:', '')}
129
-
130
- # handle a bash quirk with calling package[msi] while there is a "packages" directory locally (it passes package[msi] as packages)
131
- application = 'package[msi]' if application == 'packages'
132
-
133
- potential_rake_task_parts = application.match(REGEX_RAKE_TASK_WITH_ARGS)
134
- application = potential_rake_task_parts[1]
135
- rake_task_args = potential_rake_task_parts[2].split(',')
136
138
  if rake_tasks.include?(application)
137
139
  load_env_vars(glimmer_option_env_vars(glimmer_options))
138
140
  rake_task = "glimmer:#{application}"
@@ -171,7 +173,6 @@ module Glimmer
171
173
  private
172
174
 
173
175
  def launch_application
174
- load File.expand_path('./Rakefile') if File.exist?(File.expand_path('./Rakefile')) && caller.join("\n").include?('/bin/glimmer_runner.rb:')
175
176
  self.class.launch(
176
177
  @application_path,
177
178
  jruby_options: @jruby_options,
@@ -429,19 +429,7 @@ module Glimmer
429
429
  end
430
430
 
431
431
  def gemfile(shell_type)
432
- if shell_type == :desktopify
433
- lines = APP_GEMFILE.split("\n")
434
- require_glimmer_dsl_swt_index = lines.index(lines.detect {|l| l.include?("gem 'glimmer-dsl-swt'") })
435
- lines[(require_glimmer_dsl_swt_index + 1)..(require_glimmer_dsl_swt_index + 1)] = [
436
- "",
437
- "# Enable Chromium Browser Glimmer Custom Widget gem if needed (e.g. Linux needs it to support HTML5 Video), and use `browser(:chromium)` in GUI.",
438
- "# gem 'glimmer-cw-browser-chromium', '>= 0'",
439
- "",
440
- ]
441
- lines.join("\n")
442
- else
443
- APP_GEMFILE
444
- end
432
+ APP_GEMFILE
445
433
  end
446
434
 
447
435
  def app_main_file(app_name)
@@ -643,7 +631,7 @@ module Glimmer
643
631
  minimum_size #{shell_type == :desktopify ? '768, 432' : '420, 240'}
644
632
  image File.join(APP_ROOT, 'icons', 'windows', "#{human_name(shell_type == :gem ? custom_shell_name : current_dir_name)}.ico") if OS.windows?
645
633
  image File.join(APP_ROOT, 'icons', 'linux', "#{human_name(shell_type == :gem ? custom_shell_name : current_dir_name)}.png") unless OS.windows?
646
- text "#{human_name(namespace)} - #{human_name(custom_shell_name)}"
634
+ text "#{human_name(namespace)}#{' - ' + human_name(custom_shell_name) if shell_type != :desktopify}"
647
635
 
648
636
  MULTI_LINE_STRING
649
637
 
@@ -83,15 +83,15 @@ module Glimmer
83
83
  @swt_color
84
84
  end
85
85
 
86
- def method_missing(method, *args, &block)
87
- swt_color.send(method, *args, &block)
86
+ def method_missing(method_name, *args, &block)
87
+ swt_color.send(method_name, *args, &block)
88
88
  rescue => e
89
- Glimmer::Config.logger.debug {"Neither ColorProxy nor #{swt_color.class.name} can handle the method ##{method}"}
89
+ Glimmer::Config.logger.debug {"Neither ColorProxy nor #{swt_color.class.name} can handle the method ##{method_name}"}
90
90
  super
91
91
  end
92
92
 
93
- def respond_to?(method, *args, &block)
94
- super || swt_color.respond_to?(method, *args, &block)
93
+ def respond_to?(method_name, *args, &block)
94
+ super || swt_color.respond_to?(method_name, *args, &block)
95
95
  end
96
96
 
97
97
  private
@@ -44,6 +44,10 @@ module Glimmer
44
44
  @image_buffered_shapes ||= []
45
45
  end
46
46
 
47
+ def drop_shapes
48
+ @drop_shapes ||= []
49
+ end
50
+
47
51
  # TODO add a method like shapes that specifies drawable_properties to be able to adjust properties like transform in between shapes
48
52
 
49
53
  def shape_at_location(x, y)
@@ -1,5 +1,4 @@
1
1
  # Copyright (c) 2007-2021 Andy Maleh
2
- # Copyright (c) 2007-2021 Andy Maleh
3
2
  #
4
3
  # Permission is hereby granted, free of charge, to any person obtaining
5
4
  # a copy of this software and associated documentation files (the
@@ -101,10 +101,10 @@ module Glimmer
101
101
  end
102
102
  end
103
103
 
104
- def dispose(redraw: true)
104
+ def dispose(dispose_images: true, dispose_patterns: true, redraw: true)
105
105
  Glimmer::SWT::DisplayProxy.instance.auto_exec do
106
106
  clear if self.class == Path
107
- super(redraw: redraw) if (parent.is_a?(Shape) && (!parent.is_a?(PathSegment) || !parent.part_of_path?)) || parent.is_a?(Drawable)
107
+ super(dispose_images: dispose_images, dispose_patterns: dispose_patterns, redraw: redraw) if (parent.is_a?(Shape) && (!parent.is_a?(PathSegment) || !parent.part_of_path?)) || parent.is_a?(Drawable)
108
108
  end
109
109
  end
110
110
 
@@ -75,7 +75,7 @@ module Glimmer
75
75
  true
76
76
  end
77
77
 
78
- def dispose(redraw: true)
78
+ def dispose(dispose_images: true, dispose_patterns: true, redraw: true)
79
79
  Glimmer::SWT::DisplayProxy.instance.auto_exec do
80
80
  # including classes could override to dispose of resources first
81
81
  # afterwards, parent removes from its path segments with post_dispose_content
@@ -83,7 +83,7 @@ module Glimmer
83
83
  if part_of_path?
84
84
  drawable.redraw if redraw && !drawable.is_a?(ImageProxy)
85
85
  else
86
- super(redraw: redraw)
86
+ super(dispose_images: dispose_images, dispose_patterns: dispose_patterns, redraw: redraw)
87
87
  end
88
88
  end
89
89
  end
@@ -53,7 +53,14 @@ module Glimmer
53
53
  # give it some fuzz (helps makes mouse clicking easier)
54
54
  x.to_i.between?(self.absolute_x.to_i - 2, self.absolute_x.to_i + 2) && y.to_i.between?(self.absolute_y.to_i - 2, self.absolute_y.to_i + 2)
55
55
  end
56
- alias contain? include?
56
+
57
+ def contain?(x, y)
58
+ include?(x, y)
59
+ end
60
+
61
+ def bounds_contain?(x, y)
62
+ include?(x, y)
63
+ end
57
64
 
58
65
  def path_segment_method_name
59
66
  'addRectangle'