glimmer-dsl-swt 4.24.1.1 → 4.24.2.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: fb2e6b29d0e22472197125558b15c5907bb8cd0f14435a5394e50e988d246e60
4
- data.tar.gz: fb077b4b726a322ba57a3bc18e5feb8356d25eac9f8919cd3fccabd8cb3220a6
3
+ metadata.gz: e022ad5b5e0334818e996c918fbf384bee80a9e5a628503da14f857842ab7da0
4
+ data.tar.gz: 86d06e30bbe172f7de677ecbfa9338b5874a9a92ab3d73f67f05dca975fb1500
5
5
  SHA512:
6
- metadata.gz: be47b7d1ed562c8a086f6d4f58df9f669597fe0726f7befc15632ee21ba326514978a6622b6daeb3c35da6fdaaf104a55c316ee1b8fd22841697999eddedb193
7
- data.tar.gz: bd6f034024917f91b7b15b54010c37c17b9b10a85d82ae9b41ad7f5605935217ca381a98f15f4f96f874684a3fb1f6b62e6bb19fb7a354af4c98d30a746daa47
6
+ metadata.gz: bdc32f76c5467e573db93f650bd8b4eef2dd074c952926f6c92bfaa6798f240be09ae21262e3e062f916f1a86cf1cedd8e7c2f3de4d107a55bcbc950a638b9ae
7
+ data.tar.gz: '097eb1e61863157609a431e16345ffc73b0d06b7db44311e56ef1ba53d5d1619782f8ee0bc6e34d441d3cbbcb909237801d68b42446d6ca7d1d8ec731f856b80'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Change Log
2
2
 
3
+ ## 4.24.2.0
4
+
5
+ - Update `code_text` to support Dark Mode with `glimmer_dark` theme, which is applied by default when app is run with OS in dark mode
6
+ - Fix issue with `code_text` showing gibberish on Linux when Courier & Consolas fonts are not available. It will attempt to use the first Monospace font it finds now or otherwise stick to the default font.
7
+ - Update Hello, Code Text! and Glimmer Meta-Sample to support Dark Mode
8
+ - Refactor Hello, Custom Widget! with on_widget_disposed thread cleanup code
9
+ - Refactor Hello, Custom Shell! to support keyboard display of emails by hitting ENTER/SPACE after selecting a table row
10
+
11
+ ## 4.24.1.3
12
+
13
+ - Fix Windows freezing issue with warbler during packaging with the `glimmer package` command (caused by bundler included in JRuby on JDK18, fixed by installing latest bundler)
14
+
15
+ ## 4.24.1.2
16
+
17
+ - Fix issue where you cannot call `tab_item_proxy.text` or `tab_item_proxy.text = 'new text'` because its `swt_widget` is the contained `composite`
18
+ - Refactor Parking sample to clarify rotation details
19
+
3
20
  ## 4.24.1.1
4
21
 
5
22
  - Fix `jar-dependencies` gem version to v0.4.1 in scaffolded applications to avoid issue encountered in newly released v0.4.2
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.24.1.1
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.24.2.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)
@@ -10,6 +10,8 @@
10
10
 
11
11
  [GLIMMER VIDEO TUTORIAL CHANNEL](https://www.youtube.com/channel/UC5hzDE23HZXsZLAxYk2UJEw)
12
12
 
13
+ ![Glimmer DSL for SWT Demo of Hello, World!](/images/glimmer-dsl-swt-demo-hello-world.gif)
14
+
13
15
  [Glimmer](https://github.com/AndyObtiva/glimmer) DSL for [SWT](https://www.eclipse.org/swt/) is a native GUI (Graphical User Interface) cross-platform desktop development library written in [JRuby](https://www.jruby.org/), an OS-threaded faster [JVM](https://www.java.com/en/download/help/whatis_java.html) version of [Ruby](https://www.ruby-lang.org/en/). [Glimmer](https://github.com/AndyObtiva/glimmer)'s main innovation is a declarative [Ruby DSL](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#glimmer-dsl-syntax) (Domain Specific Language) that enables productive and efficient authoring of desktop application user-interfaces by relying on the robust [Eclipse SWT library](https://www.eclipse.org/swt/). [Glimmer](https://rubygems.org/gems/glimmer) additionally innovates by having built-in [data-binding](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#data-binding) support, which greatly facilitates synchronizing the GUI with domain models, thus achieving true decoupling of object oriented components and enabling developers to solve business problems (test-first) without worrying about GUI concerns, or alternatively drive development GUI-first, and then write clean business models afterwards. Not only does Glimmer provide a large set of GUI [widgets](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#widgets), but it also supports drawing Canvas Graphics like [Shapes](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#canvas-shape-dsl) and [Animations](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#canvas-animation-dsl). To get started quickly, [Glimmer](https://rubygems.org/gems/glimmer) offers [scaffolding](docs/reference/GLIMMER_COMMAND.md#scaffolding) options for [Apps](#in-production), [Gems](docs/reference/GLIMMER_COMMAND.md#custom-shell-gem), and [Custom Widgets](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#custom-widgets). [Glimmer](https://rubygems.org/gems/glimmer) also includes native-executable [packaging](docs/reference/GLIMMER_PACKAGING_AND_DISTRIBUTION.md) support, sorely lacking in other libraries, thus enabling the delivery of desktop apps written in [Ruby](https://www.ruby-lang.org/en/) as truly native DMG/PKG/APP files on the [Mac](https://www.apple.com/ca/macos), MSI/EXE files on [Windows](https://www.microsoft.com/en-ca/windows), and DEB/RPM files on [Linux](https://www.linux.org/). [Glimmer](https://github.com/AndyObtiva/glimmer) was the [first Ruby gem](https://rubygems.org/gems/glimmer) to bring [SWT](https://www.eclipse.org/swt/) (Standard Widget Toolkit) to [Ruby](https://www.ruby-lang.org/en/), thanks to creator [Andy Maleh](https://andymaleh.blogspot.com/), EclipseCon/EclipseWorld/RubyConf speaker.
14
16
 
15
17
  [<img src="https://covers.oreillystatic.com/images/9780596519650/lrg.jpg" width=105 /><br />
@@ -19,7 +21,7 @@ Featured in JRuby Cookbook](http://shop.oreilly.com/product/9780596519650.do) an
19
21
 
20
22
  ![Eclipse SWT RCP NASA Mars Rover](/images/glimmer-eclipse-swt-rcp-nasa-mars-rover.png)
21
23
 
22
- [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.24.1.1 includes [SWT 4.24](https://download.eclipse.org/eclipse/downloads/drops4/R-4.24-202206070700/), which was released on June 7, 2022. 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.
24
+ [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.24.2.0 includes [SWT 4.24](https://download.eclipse.org/eclipse/downloads/drops4/R-4.24-202206070700/), which was released on June 7, 2022. 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.
23
25
 
24
26
  **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. That was [originally conceived back in 2007](https://andymaleh.blogspot.com/2007/12/data-shining-in-glimmer.html).
25
27
 
@@ -304,9 +306,9 @@ https://www.eclipse.org/swt/faq.php
304
306
 
305
307
  ## Pre-requisites
306
308
 
307
- - JDK 18 is recommended / Minimum is JDK 16 on x64 platforms and Linux AARCH64, and JDK 17 on Mac ARM64 (find at https://www.oracle.com/java/technologies/downloads / Ensure `PATH` env var includes Java bin directory for `jpackage` command to work when packaging Glimmer applications / Preferably setup `JAVA_HOME` env var too to point to JDK home directory before installing JRuby)
309
+ - JDK 18 is required / JDK 16 is the minimum except on Mac ARM64 where JDK 17 is the minimum (find at https://www.oracle.com/java/technologies/downloads / Ensure `PATH` env var includes Java bin directory for `jpackage` command to work when packaging Glimmer applications / Preferably setup `JAVA_HOME` env var too to point to JDK home directory before installing JRuby)
308
310
  - [RVM](http://rvm.io) on Mac & Linux (not needed on Windows)
309
- - JRuby 9.3.6.0 (supporting Ruby 2.6.x syntax) (get via [RVM](http://rvm.io) on Mac and Linux by running `rvm install jruby-9.3.6.0`; On Windows, find at [https://www.jruby.org/download](https://www.jruby.org/download))
311
+ - JRuby 9.3.6.0 is required (supporting Ruby 2.6.x syntax) (get via [RVM](http://rvm.io) on Mac and Linux by running `rvm install jruby-9.3.6.0`; On Windows, find at [https://www.jruby.org/download](https://www.jruby.org/download))
310
312
  - SWT 4.24 (already included in the [glimmer-dsl-swt](https://rubygems.org/gems/glimmer-dsl-swt) gem). Note that SWT supports ARM64/AARCH64 on Mac and Linux since version 4.20
311
313
  - Git (comes with Mac and Linux. Install on Windows: https://git-scm.com/download/win )
312
314
 
@@ -336,7 +338,7 @@ jgem install glimmer-dsl-swt
336
338
 
337
339
  Or this command if you want a specific version:
338
340
  ```
339
- jgem install glimmer-dsl-swt -v 4.24.1.1
341
+ jgem install glimmer-dsl-swt -v 4.24.2.0
340
342
  ```
341
343
 
342
344
  `jgem` is JRuby's version of `gem` command.
@@ -364,7 +366,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
364
366
 
365
367
  Add the following to `Gemfile`:
366
368
  ```
367
- gem 'glimmer-dsl-swt', '~> 4.24.1.1'
369
+ gem 'glimmer-dsl-swt', '~> 4.24.2.0'
368
370
  ```
369
371
 
370
372
  And, then run:
@@ -387,7 +389,7 @@ glimmer
387
389
  ```
388
390
 
389
391
  ```
390
- Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.24.1.1
392
+ Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.24.2.0
391
393
 
392
394
  Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
393
395
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.24.1.1
1
+ 4.24.2.0
@@ -162,7 +162,7 @@ Glimmer DSL syntax consists mainly of:
162
162
 
163
163
  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.
164
164
 
165
- Static keywords are pre-identified keywords in the Glimmer DSL, such as `shell`, `display`, `message_box`, `async_exec`, `sync_exec`, and `bind`.
165
+ Static keywords are pre-identified keywords in the Glimmer DSL, such as `shell` (alias: `window`), `display`, `message_box`, `async_exec`, `sync_exec`, and `bind`.
166
166
 
167
167
  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.
168
168
 
@@ -191,7 +191,7 @@ This screenshot taken from the link above should give a glimpse of how SWT widge
191
191
  In Glimmer DSL, widgets are declared with lowercase underscored names mirroring their SWT names minus the package name.
192
192
 
193
193
  For example, here are some Glimmer widgets and their SWT counterparts:
194
- - `shell` instantiates `org.eclipse.swt.widgets.Shell`
194
+ - `shell` (alias: `window`) instantiates `org.eclipse.swt.widgets.Shell`, which represents a window
195
195
  - `text` instantiates `org.eclipse.swt.widgets.Text`
196
196
  - `button` instantiates `org.eclipse.swt.widgets.Button`
197
197
  - `label` instantiates `org.eclipse.swt.widgets.Label`
@@ -220,7 +220,7 @@ shell {
220
220
  }.open
221
221
  ```
222
222
 
223
- Note that `shell` instantiates the outer shell **widget**, in other words, the window that houses all of the desktop graphical user interface.
223
+ Note that `shell` (alias: `window`) instantiates the outer shell **widget**, in other words, the window that houses all of the desktop graphical user interface.
224
224
 
225
225
  `shell` is then followed by a ***block*** that contains
226
226
 
@@ -248,7 +248,7 @@ shell {|shell_proxy|
248
248
  }
249
249
  ```
250
250
 
251
- Remember that The `shell` widget is always the outermost widget containing all others in a Glimmer desktop windowed application.
251
+ Remember that The `shell` (alias: `window`) widget is always the outermost widget containing all others in a Glimmer desktop windowed application.
252
252
 
253
253
  After it is declared, a `shell` must be opened with the `#open` method, which can be called on the block directly as in the example above, or by capturing `shell` in a `@shell` variable (shown in example below), and calling `#open` on it independently (recommended in actual apps)
254
254
 
@@ -1114,7 +1114,7 @@ shell {
1114
1114
 
1115
1115
  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).
1116
1116
 
1117
- Learn more at:
1117
+ Learn more at:
1118
1118
  - [SWT Browser API](https://help.eclipse.org/2020-12/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/browser/Browser.html)
1119
1119
  - [SWT Browser FAQ](https://www.eclipse.org/swt/faq.php#whatisbrowser).
1120
1120
 
@@ -4809,6 +4809,12 @@ You may see another example at the [Hello, Radio Group!](/docs/reference/GLIMMER
4809
4809
 
4810
4810
  `code_text` is a Glimmer built-in custom widget that displays syntax highlighted Ruby code in a customized SWT [StyledText](https://help.eclipse.org/2020-09/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/custom/StyledText.html) widget.
4811
4811
 
4812
+ It attempts to use a monospace font if available, seeking fonts in the following order:
4813
+ 1. Consolas
4814
+ 2. Courier
4815
+ 3. Any font that contains the word "Mono"
4816
+ 4. Default system font (if no other font is found)
4817
+
4812
4818
  It is used in the [Glimmer Meta-Sample (The Sample of Samples)](#samples):
4813
4819
 
4814
4820
  ![Glimmer Meta-Sample](/images/glimmer-meta-sample.png)
@@ -4842,6 +4848,7 @@ Keep in mind that if the text grows and required a wider line numbers area, it g
4842
4848
 
4843
4849
  Changes syntax color highlighting theme. Can be one of the following:
4844
4850
  - glimmer
4851
+ - glimmer_dark (always applied when OS is in dark mode)
4845
4852
  - github
4846
4853
  - pastie
4847
4854
 
Binary file
@@ -0,0 +1,53 @@
1
+ # Copyright (c) 2007-2022 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
+ module Rouge
23
+ module Themes
24
+ # A port of the pastie style from Pygments.
25
+ # See https://bitbucket.org/birkenfeld/pygments-main/src/default/pygments/styles/pastie.py
26
+ class GlimmerDark < Github
27
+ name 'glimmer_dark'
28
+ style Comment::Single, fg: [149, 140, 130], italic: true # Also, Comments
29
+ style Keyword::Pseudo, fg: [188, 255, 255]
30
+ style Keyword::Declaration, fg: [188, 255, 255]
31
+ style Keyword, fg: [153, 38, 16], bold: true
32
+ style Literal::String::Single, fg: [149, 140, 130] # Also, Comments
33
+ style Literal::String::Double, fg: [255, 163, 58]
34
+ style Literal::String::Escape, fg: [6, 217, 141]
35
+ style Literal::Number::Integer, fg: [153, 38, 16], bold: true
36
+ style Literal::String::Interpol, fg: [153, 38, 16], bold: true
37
+ style Literal::String::Symbol, fg: [255, 127, 255]
38
+ style Literal::String, fg: [163, 215, 252]
39
+ style Name::Builtin, fg: [40, 197, 182]
40
+ style Name::Class, fg: [252, 208, 157]
41
+ style Name::Namespace, fg: [252, 208, 157]
42
+ style Name::Constant, fg: [255, 163, 58]
43
+ style Name::Function, fg: [153, 38, 16], bold: true
44
+ style Name::Variable::Instance, fg: [28, 157, 246]
45
+ style Name::Tag, fg: [247, 250, 136]
46
+ style Name::Attribute, fg: [255, 127, 127]
47
+ style Name, fg: [144, 189, 62] #inverse of purple
48
+ style Operator, fg: [6, 217, 141]
49
+ style Punctuation, fg: [102, 217, 239]
50
+ style Text, fg: [180, 180, 180]
51
+ end
52
+ end
53
+ end
@@ -147,6 +147,7 @@ module Glimmer
147
147
  gem_name = file_name(app_name)
148
148
  gem_summary = human_name(app_name)
149
149
  return puts("The directory '#{gem_name}' already exists. Please either remove or pick a different name.") if Dir.exist?(gem_name)
150
+ system "jruby -S gem install bundler --no-document" if OS.windows? # resolves freezing issue with warbler and bundler 2.2.29 included in JRuby
150
151
  system "jruby -S gem install juwelier -v2.4.9 --no-document" unless juwelier_exists?
151
152
  system "jruby -S juwelier --markdown --rspec --summary '#{gem_summary}' --description '#{gem_summary}' #{gem_name}"
152
153
  return puts('Your Git user.name and/or github.user are missing! Please add in for Juwelier to help Glimmer with Scaffolding.') if `git config --get github.user`.strip.empty? && `git config --get user.name`.strip.empty?
@@ -250,6 +251,7 @@ module Glimmer
250
251
  namespace = 'glimmer'
251
252
  end
252
253
  return puts("The directory '#{gem_name}' already exists. Please either remove or pick a different name.") if Dir.exist?(gem_name)
254
+ system "jruby -S gem install bundler --no-document" if OS.windows? # resolves freezing issue with warbler and bundler 2.2.29 included in JRuby
253
255
  system "jruby -S gem install juwelier -v2.4.9 --no-document" unless juwelier_exists?
254
256
  system "jruby -S juwelier --markdown --rspec --summary '#{gem_summary}' --description '#{gem_summary}' #{gem_name}"
255
257
  return puts('Your Git user.name and/or github.user are missing! Please add in for Juwelier to help Glimmer with Scaffolding.') if `git config --get github.user`.strip.empty? && `git config --get user.name`.strip.empty?
@@ -317,6 +319,7 @@ module Glimmer
317
319
  end
318
320
 
319
321
  return puts("The directory '#{gem_name}' already exists. Please either remove or pick a different name.") if Dir.exist?(gem_name)
322
+ system "jruby -S gem install bundler --no-document" if OS.windows? # resolves freezing issue with warbler and bundler 2.2.29 included in JRuby
320
323
  system "jruby -S gem install juwelier -v2.4.9 --no-document" unless juwelier_exists?
321
324
  system "jruby -S juwelier --markdown --rspec --summary '#{gem_summary}' --description '#{gem_summary}' #{gem_name}"
322
325
  return puts('Your Git user.name and/or github.user are missing! Please add in for Juwelier to help Glimmer with Scaffolding.') if `git config --get github.user`.strip.empty? && `git config --get user.name`.strip.empty?
@@ -355,6 +358,7 @@ module Glimmer
355
358
  end
356
359
 
357
360
  return puts("The directory '#{gem_name}' already exists. Please either remove or pick a different name.") if Dir.exist?(gem_name)
361
+ system "jruby -S gem install bundler --no-document" if OS.windows? # resolves freezing issue with warbler and bundler 2.2.29 included in JRuby
358
362
  system "jruby -S gem install juwelier -v2.4.9 --no-document" unless juwelier_exists?
359
363
  system "jruby -S juwelier --markdown --rspec --summary '#{gem_summary}' --description '#{gem_summary}' #{gem_name}"
360
364
  return puts('Your Git user.name and/or github.user are missing! Please add in for Juwelier to help Glimmer with Scaffolding.') if `git config --get github.user`.strip.empty? && `git config --get user.name`.strip.empty?
@@ -124,8 +124,12 @@ module Glimmer
124
124
  before_body do
125
125
  require 'rouge'
126
126
  require 'ext/rouge/themes/glimmer'
127
+ require 'ext/rouge/themes/glimmer_dark'
128
+ @dark_mode = Java::OrgEclipseSwtWidgets::Display.system_dark_theme?
129
+ self.theme = 'glimmer_dark' if @dark_mode
130
+ @dark_theme = theme.include?('dark')
127
131
  @swt_style = swt_style == 0 ? [:border, :multi, :v_scroll, :h_scroll] : swt_style
128
- @font_name = display.get_font_list(nil, true).map(&:name).include?('Consolas') ? 'Consolas' : 'Courier'
132
+ select_best_font
129
133
  if lines == true
130
134
  @lines_width = 4
131
135
  elsif lines.is_a?(Hash)
@@ -151,9 +155,9 @@ module Glimmer
151
155
  after_read: lambda { @line_numbers_styled_text_proxy&.top_pixel = styled_text_proxy_top_pixel unless styled_text_proxy_top_pixel.nil? }
152
156
  ]
153
157
  top_pixel <= [self, :styled_text_proxy_top_pixel]
154
- font name: @font_name, height: OS.mac? ? 15 : 12
158
+ font @font_options
155
159
  background color(:widget_background)
156
- foreground :dark_blue
160
+ foreground @dark_mode ? rgb(255, 255, 127) : :dark_blue
157
161
  top_margin 5
158
162
  right_margin 5
159
163
  bottom_margin 5
@@ -186,7 +190,8 @@ module Glimmer
186
190
 
187
191
  text <=> [self, :styled_text_proxy_text] if lines
188
192
  top_pixel <=> [self, :styled_text_proxy_top_pixel] if lines
189
- font name: @font_name, height: OS.mac? ? 15 : 12
193
+ font @font_options
194
+ background :black if @dark_mode
190
195
  foreground rgb(75, 75, 75)
191
196
  left_margin 5
192
197
  top_margin 5
@@ -239,8 +244,8 @@ module Glimmer
239
244
  start_index = token_hash[:token_index]
240
245
  size = token_hash[:token_text].size
241
246
  style_data = Rouge::Theme.find(theme).new.style_for(token_hash[:token_type])
242
- foreground_color = hex_color_to_swt_color(style_data[:fg], [:black])
243
- background_color = hex_color_to_swt_color(style_data[:bg], [:white])
247
+ foreground_color = hex_color_to_swt_color(style_data[:fg], [@dark_mode ? :white : :black])
248
+ background_color = hex_color_to_swt_color(style_data[:bg], [@dark_mode ? :black : :white])
244
249
  font_styles = []
245
250
  font_styles << :bold if style_data[:bold]
246
251
  font_styles << :italic if style_data[:italic]
@@ -310,6 +315,21 @@ module Glimmer
310
315
  @lines_width = lines_text_size if lines_text_size > @lines_width
311
316
  line_count.times.map {|n| (' ' * (lines_text_size - (n+1).to_s.size)) + (n+1).to_s }.join("\n") + "\n"
312
317
  end
318
+
319
+ def select_best_font
320
+ select_best_font_name
321
+ @font_options = {height: OS.mac? ? 15 : 12}
322
+ @font_options.merge!(name: @font_name) if @font_name
323
+ @font_options
324
+ end
325
+
326
+ def select_best_font_name
327
+ all_font_names = display.get_font_list(nil, true).map(&:name)
328
+ @font_name ||= 'Consolas' if all_font_names.include?('Consolas')
329
+ @font_name ||= 'Courier' if all_font_names.include?('Courier')
330
+ @font_name ||= all_font_names.find {|font_name| font_name.downcase.include?('mono')}
331
+ @font_name
332
+ end
313
333
  end
314
334
  end
315
335
  end
@@ -78,6 +78,23 @@ module Glimmer
78
78
  end
79
79
  end
80
80
 
81
+ ATTRIBUTES.each do |attribute|
82
+ define_method(attribute) do
83
+ auto_exec do
84
+ widget_proxy.send(attribute)
85
+ end
86
+ end
87
+
88
+ define_method("#{attribute}=") do |value|
89
+ value.tap do
90
+ auto_exec do
91
+ widget_proxy.send("#{attribute}=", value)
92
+ shell_proxy.pack_same_size
93
+ end
94
+ end
95
+ end
96
+ end
97
+
81
98
  def dispose
82
99
  auto_exec do
83
100
  swt_tab_item.setControl(nil)
@@ -25,3 +25,6 @@ Game Of Life: pDE79YRjOjs
25
25
  Hello, Canvas Data Binding!: PQ_Y8e5VeDo
26
26
  Hello, Canvas Path!: ThmNcXTldY8
27
27
  Hello, Canvas Transform!: ePIAF5EMsE0
28
+ Parking: kw-6icVgDR4
29
+ Hello, Custom Widget!: aJHLo5yLDZc
30
+ Hello, Custom Shell!: c8Eb8GWM_XQ
@@ -340,7 +340,7 @@ class MetaSampleApplication
340
340
  }
341
341
  }
342
342
  line_numbers {
343
- background :white
343
+ background Display.system_dark_theme? ? :black : :white
344
344
  }
345
345
  text <=> [SampleDirectory, 'selected_sample.code']
346
346
  editable <= [SampleDirectory, 'selected_sample.editable']
@@ -26,10 +26,10 @@ require_relative 'parking/model/parking_presenter'
26
26
  class Parking
27
27
  include Glimmer::UI::CustomShell
28
28
 
29
+ CANVAS_LENGTH = 600
29
30
  FLOOR_COUNT = 4
30
31
 
31
32
  before_body do
32
- @parking_spots = Model::ParkingSpot::LETTERS.clone
33
33
  @parking_presenter = Model::ParkingPresenter.new(FLOOR_COUNT)
34
34
  end
35
35
 
@@ -56,7 +56,6 @@ class Parking
56
56
  selection <=> [@parking_presenter, :selected_floor]
57
57
 
58
58
  on_widget_selected do
59
- @parking_spots = Model::ParkingSpot::LETTERS.clone
60
59
  @canvas.dispose_shapes
61
60
  @canvas.content {
62
61
  parking_floor
@@ -65,8 +64,8 @@ class Parking
65
64
  }
66
65
  @canvas = canvas {
67
66
  layout_data {
68
- width 600
69
- height 600
67
+ width CANVAS_LENGTH
68
+ height CANVAS_LENGTH
70
69
  }
71
70
 
72
71
  background :dark_gray
@@ -77,42 +76,33 @@ class Parking
77
76
  }
78
77
 
79
78
  def parking_floor
80
- parking_quad(67.5, 0, 125)
81
- parking_quad(67.5, 0, 125) { |shp|
82
- shp.rotate(90)
83
- }
84
- parking_quad(67.5, 0, 125) { |shp|
85
- shp.rotate(180)
86
- }
87
- parking_quad(67.5, 0, 125) { |shp|
88
- shp.rotate(270)
89
- }
79
+ parking_quad(67.5, 0, 125, 0)
80
+ parking_quad(67.5, 0, 125, 90)
81
+ parking_quad(67.5, 0, 125, 180)
82
+ parking_quad(67.5, 0, 125, 270)
90
83
  end
91
84
 
92
- def parking_quad(location_x, location_y, length, &block)
85
+ def parking_quad(location_x, location_y, length, angle)
93
86
  distance = (1.0/3)*length
94
- parking_spot(location_x, location_y, length, &block)
95
- parking_spot(location_x + distance, location_y, length, &block)
96
- parking_spot(location_x + 2*distance, location_y, length, &block)
97
- parking_spot(location_x + 3*distance, location_y, length, &block)
87
+ parking_spot(location_x, location_y, length, angle)
88
+ parking_spot(location_x + distance, location_y, length, angle)
89
+ parking_spot(location_x + 2*distance, location_y, length, angle)
90
+ parking_spot(location_x + 3*distance, location_y, length, angle)
98
91
  end
99
92
 
100
- def parking_spot(location_x, location_y, length, &block)
101
- parking_spot_letter = @parking_spots.shift
93
+ def parking_spot(location_x, location_y, length, angle)
94
+ parking_spot_letter = next_parking_spot_letter
102
95
  height = length
103
96
  width = (2.0/3)*length
104
- shape(location_x, location_y) { |the_shape|
97
+
98
+ shape(location_x, location_y) {
105
99
  line_width (1.0/15)*length
106
100
  foreground :white
107
101
 
108
- block&.call(the_shape)
109
-
110
102
  rectangle(location_x, location_y, width, height) {
111
- background <= [
112
- @parking_presenter.floors[@parking_presenter.selected_floor - 1].parking_spots[parking_spot_letter],
113
- :booked,
114
- on_read: ->(b) {b ? :red : :dark_gray}
115
- ]
103
+ background <= [parking_spot_for(parking_spot_letter), :booked,
104
+ on_read: ->(value) {value ? :red : :dark_gray}
105
+ ]
116
106
 
117
107
  text {
118
108
  x :default
@@ -123,7 +113,8 @@ class Parking
123
113
 
124
114
  on_mouse_up do
125
115
  begin
126
- @parking_presenter.floors[@parking_presenter.selected_floor - 1].book!(parking_spot_letter)
116
+ selected_parking_floor.book!(parking_spot_letter)
117
+
127
118
  message_box {
128
119
  text 'Parking Booked!'
129
120
  message "Floor #{@parking_presenter.selected_floor} Parking Spot #{parking_spot_letter} Is Booked!"
@@ -138,8 +129,29 @@ class Parking
138
129
  line(location_x, location_y, location_x + width, location_y)
139
130
  line(location_x + width, location_y, location_x + width, location_y + height)
140
131
 
132
+ # Rotate around the canvas center point
133
+ transform {
134
+ translation CANVAS_LENGTH/2.0, CANVAS_LENGTH/2.0
135
+ rotation angle
136
+ translation -CANVAS_LENGTH/2.0, -CANVAS_LENGTH/2.0
137
+ }
141
138
  }
142
139
  end
140
+
141
+ def parking_spot_for(parking_spot_letter)
142
+ selected_parking_floor.parking_spots[parking_spot_letter]
143
+ end
144
+
145
+ def selected_parking_floor
146
+ @parking_presenter.floors[@parking_presenter.selected_floor - 1]
147
+ end
148
+
149
+ private
150
+
151
+ def next_parking_spot_letter
152
+ @parking_spot_letters = Model::ParkingSpot::LETTERS.clone if @parking_spot_letters.nil? || @parking_spot_letters.empty?
153
+ @parking_spot_letters.shift
154
+ end
143
155
  end
144
156
 
145
157
  Parking.launch
@@ -86,7 +86,8 @@ class HelloCodeText
86
86
 
87
87
  text 'Ruby (glimmer theme)'
88
88
 
89
- code_text(language: 'ruby', theme: 'glimmer', lines: true) {
89
+ # Note: code_text theme is currently ignored in dark mode
90
+ code_text(language: 'ruby', theme: 'glimmer_dark', lines: true) { # theme is currently ignored in dark mode
90
91
  text <=> [self, :ruby_code]
91
92
  }
92
93
  }
@@ -96,17 +97,18 @@ class HelloCodeText
96
97
 
97
98
  text 'JavaScript (pastie theme)'
98
99
 
99
- code_text(:multi, :h_scroll, :v_scroll, language: 'javascript', theme: 'pastie', lines: {width: 2}) {
100
+ # Note: code_text theme is currently ignored in dark mode
101
+ code_text(:multi, :h_scroll, :v_scroll, language: 'javascript', theme: 'glimmer_dark', lines: {width: 2}) {
100
102
  root {
101
103
  grid_layout(2, false) {
102
104
  margin_width 2
103
105
  }
104
106
 
105
- background :white
107
+ background Display.system_dark_theme? ? :black : :white
106
108
  }
107
109
 
108
110
  line_numbers {
109
- background :white
111
+ background Display.system_dark_theme? ? :black : :white
110
112
  }
111
113
 
112
114
  text <=> [self, :js_code]
@@ -118,7 +120,8 @@ class HelloCodeText
118
120
 
119
121
  text 'HTML (github theme)'
120
122
 
121
- code_text(language: 'html', theme: 'github') { # default is lines: false
123
+ # Note: code_text theme is currently ignored in dark mode
124
+ code_text(language: 'html', theme: 'glimmer_dark') { # default is lines: false
122
125
  text <=> [self, :html_code]
123
126
  }
124
127
  }
@@ -26,7 +26,8 @@ require 'date'
26
26
  # Used to view an email message
27
27
  class EmailShell
28
28
  # including Glimmer::UI::CustomShell enables declaring as an `email_shell` custom widget Glimmer GUI DSL keyword
29
- include Glimmer::UI::CustomShell
29
+ # Glimmer::UI::CustomShell is a specialized Glimmer::UI::CustomWidget that has `shell` as its `body_root`
30
+ include Glimmer::UI::CustomShell # aliases: Glimmer::UI::CustomWindow & Glimmer::UI::Application
30
31
 
31
32
  # multiple options without default values
32
33
  options :parent_shell, :date, :subject, :from, :message
@@ -88,26 +89,56 @@ class EmailShell
88
89
  end
89
90
 
90
91
  class HelloCustomShell
91
- include Glimmer
92
+ include Glimmer::UI::Application # aliases: Glimmer::UI::CustomShell & Glimmer::UI::CustomWindow
92
93
 
93
94
  Email = Struct.new(:date, :subject, :from, :message, keyword_init: true)
94
- EmailSystem = Struct.new(:emails, keyword_init: true)
95
+ EmailSystem = Struct.new(:emails, :selected_email, keyword_init: true)
95
96
 
96
- def initialize
97
+ before_body do
97
98
  @email_system = EmailSystem.new(
98
99
  emails: [
99
- Email.new(date: DateTime.new(2029, 10, 22, 11, 3, 0).strftime('%F %I:%M %p'), subject: '3rd Week Report', from: '"Dianne Tux" <dianne.tux@example.com>', message: "Hello,\n\nI was wondering if you'd like to go over the weekly report sometime this afternoon.\n\nDianne"),
100
- Email.new(date: DateTime.new(2029, 10, 21, 8, 1, 0).strftime('%F %I:%M %p'), subject: 'Glimmer Upgrade v100.0', from: '"Robert McGabbins" <robert.mcgabbins@example.com>', message: "Team,\n\nWe are upgrading to Glimmer version 100.0.\n\nEveryone pull the latest code!\n\nRegards,\n\nRobert McGabbins"),
101
- Email.new(date: DateTime.new(2029, 10, 19, 16, 58, 0).strftime('%F %I:%M %p'), subject: 'Christmas Party', from: '"Lisa Ferreira" <lisa.ferreira@example.com>', message: "Merry Christmas,\n\nAll office Christmas Party arrangements have been set\n\nMake sure to bring a Secret Santa gift\n\nBest regards,\n\nLisa Ferreira"),
102
- Email.new(date: DateTime.new(2029, 10, 16, 9, 43, 0).strftime('%F %I:%M %p'), subject: 'Glimmer Upgrade v99.0', from: '"Robert McGabbins" <robert.mcgabbins@example.com>', message: "Team,\n\nWe are upgrading to Glimmer version 99.0.\n\nEveryone pull the latest code!\n\nRegards,\n\nRobert McGabbins"),
103
- Email.new(date: DateTime.new(2029, 10, 15, 11, 2, 0).strftime('%F %I:%M %p'), subject: '2nd Week Report', from: '"Dianne Tux" <dianne.tux@example.com>', message: "Hello,\n\nI was wondering if you'd like to go over the weekly report sometime this afternoon.\n\nDianne"),
104
- Email.new(date: DateTime.new(2029, 10, 2, 10, 34, 0).strftime('%F %I:%M %p'), subject: 'Glimmer Upgrade v98.0', from: '"Robert McGabbins" <robert.mcgabbins@example.com>', message: "Team,\n\nWe are upgrading to Glimmer version 98.0.\n\nEveryone pull the latest code!\n\nRegards,\n\nRobert McGabbins"),
100
+ Email.new(
101
+ date: DateTime.new(2029, 10, 22, 11, 3, 0).strftime('%F %I:%M %p'),
102
+ subject: '3rd Week Report',
103
+ from: '"Dianne Tux" <dianne.tux@example.com>',
104
+ message: "Hello,\n\nI was wondering if you'd like to go over the weekly report sometime this afternoon.\n\nDianne"
105
+ ),
106
+ Email.new(
107
+ date: DateTime.new(2029, 10, 21, 8, 1, 0).strftime('%F %I:%M %p'),
108
+ subject: 'Glimmer Upgrade v100.0',
109
+ from: '"Robert McGabbins" <robert.mcgabbins@example.com>',
110
+ message: "Team,\n\nWe are upgrading to Glimmer version 100.0.\n\nEveryone pull the latest code!\n\nRegards,\n\nRobert McGabbins"
111
+ ),
112
+ Email.new(
113
+ date: DateTime.new(2029, 10, 19, 16, 58, 0).strftime('%F %I:%M %p'),
114
+ subject: 'Christmas Party',
115
+ from: '"Lisa Ferreira" <lisa.ferreira@example.com>',
116
+ message: "Merry Christmas,\n\nAll office Christmas Party arrangements have been set\n\nMake sure to bring a Secret Santa gift\n\nBest regards,\n\nLisa Ferreira"
117
+ ),
118
+ Email.new(
119
+ date: DateTime.new(2029, 10, 16, 9, 43, 0).strftime('%F %I:%M %p'),
120
+ subject: 'Glimmer Upgrade v99.0',
121
+ from: '"Robert McGabbins" <robert.mcgabbins@example.com>',
122
+ message: "Team,\n\nWe are upgrading to Glimmer version 99.0.\n\nEveryone pull the latest code!\n\nRegards,\n\nRobert McGabbins"
123
+ ),
124
+ Email.new(
125
+ date: DateTime.new(2029, 10, 15, 11, 2, 0).strftime('%F %I:%M %p'),
126
+ subject: '2nd Week Report',
127
+ from: '"Dianne Tux" <dianne.tux@example.com>',
128
+ message: "Hello,\n\nI was wondering if you'd like to go over the weekly report sometime this afternoon.\n\nDianne"
129
+ ),
130
+ Email.new(
131
+ date: DateTime.new(2029, 10, 2, 10, 34, 0).strftime('%F %I:%M %p'),
132
+ subject: 'Glimmer Upgrade v98.0',
133
+ from: '"Robert McGabbins" <robert.mcgabbins@example.com>',
134
+ message: "Team,\n\nWe are upgrading to Glimmer version 98.0.\n\nEveryone pull the latest code!\n\nRegards,\n\nRobert McGabbins"
135
+ ),
105
136
  ]
106
137
  )
107
138
  end
108
139
 
109
- def launch
110
- shell { |shell_proxy|
140
+ body {
141
+ shell {
111
142
  grid_layout
112
143
 
113
144
  text 'Hello, Custom Shell!'
@@ -139,22 +170,33 @@ class HelloCustomShell
139
170
  }
140
171
 
141
172
  items <=> [@email_system, :emails, column_properties: [:date, :subject, :from]]
173
+ selection <=> [@email_system, :selected_email]
142
174
 
143
175
  on_mouse_up do |event|
144
- email = event.table_item.get_data
145
-
146
- # open a custom email shell
147
- email_shell(
148
- parent_shell: shell_proxy,
149
- date: email.date,
150
- subject: email.subject,
151
- from: email.from,
152
- message: email.message
153
- ).open
176
+ open_email(@email_system.selected_email)
177
+ end
178
+
179
+ on_key_pressed do |event|
180
+ if [swt(:cr), swt(:space)].include?(event.keyCode)
181
+ open_email(@email_system.selected_email)
182
+ end
154
183
  end
155
184
  }
156
- }.open
185
+ }
186
+ }
187
+
188
+ def open_email(email)
189
+ return if email.nil?
190
+
191
+ # open a custom email shell
192
+ email_shell(
193
+ parent_shell: body_root,
194
+ date: email.date,
195
+ subject: email.subject,
196
+ from: email.from,
197
+ message: email.message
198
+ ).open
157
199
  end
158
200
  end
159
201
 
160
- HelloCustomShell.new.launch
202
+ HelloCustomShell.launch
@@ -55,13 +55,13 @@ class GreetingLabel
55
55
  after_body do
56
56
  return if colors.nil?
57
57
 
58
- Thread.new {
59
- colors.cycle { |color|
58
+ @thread = Thread.new do
59
+ colors.cycle do |color|
60
60
  self.label_color = color
61
61
  @color_changed_handlers&.each {|handler| handler.call(color)}
62
62
  sleep(1)
63
- }
64
- }
63
+ end
64
+ end
65
65
  end
66
66
 
67
67
  body {
@@ -70,6 +70,10 @@ class GreetingLabel
70
70
  text "#{greeting}, #{name}!"
71
71
  font @font
72
72
  foreground <=> [self, :label_color]
73
+
74
+ on_widget_disposed do
75
+ @thread&.kill # safe since it does not involve data
76
+ end
73
77
  }
74
78
  }
75
79
 
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.24.1.1
4
+ version: 4.24.2.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: 2022-08-05 00:00:00.000000000 Z
11
+ date: 2022-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -399,6 +399,7 @@ files:
399
399
  - lib/ext/glimmer.rb
400
400
  - lib/ext/glimmer/config.rb
401
401
  - lib/ext/rouge/themes/glimmer.rb
402
+ - lib/ext/rouge/themes/glimmer_dark.rb
402
403
  - lib/glimmer-dsl-swt.rb
403
404
  - lib/glimmer/Rakefile
404
405
  - lib/glimmer/data_binding/list_selection_binding.rb