glimmer-dsl-swt 4.24.1.2 → 4.24.2.1

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: 4958a72683334de9b8f0ca8a213eabce1dbf93031ea249dd760abea934d704d6
4
- data.tar.gz: ec7566aee8c9a16a757fc639cb64a3a3b96ba83b7abb92d92a83bc64221631a8
3
+ metadata.gz: dcabd7cc1b4ab9c8c077fa97bb60d66f2da290707a49aed7d8cb49375fcee4d7
4
+ data.tar.gz: 5634d30ee03e7b20a7a4475c396b98e3bf0fdb1c063a4c42f0216a3ae4a119d6
5
5
  SHA512:
6
- metadata.gz: 0fcf51949b0e6231e92b1d0603c530f69272ccd5a3a18631d3a386a140bffb5e41bca9eda858ff6f5481aeb60351e8fcef04f0ce30ec835cdd50898e149cadf8
7
- data.tar.gz: 75a92e8793f5c7782dd9d18359a1693d80dc35de3ad7eea51268a316f382ed1c88bf5e451865975ffe881134ff041fc343697e1c4f933fb77e3fd6fac22ba70e
6
+ metadata.gz: a1bef78b2591d3ef7e6b0217062769d4f0e9999a42458d69aab2e2d23afa05aafde87c236586f808b51a8ab66cc7e7b6cb48b092159e2dac0da73501cfb63fcd
7
+ data.tar.gz: bb449c8d49d5b8acdd2b71cecdbc37f44dbb33c09ab358fc90c1922c0de6cc38f788d5dbd72a5071d419c372c1db8bf7ca985dd0e798d2a9db0e90f241cda5b2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Change Log
2
2
 
3
+ ## 4.24.2.1
4
+
5
+ - Fix mistake of changing all themes to dark themes in Hello, Code Text! (not it works just like before)
6
+
7
+ ## 4.24.2.0
8
+
9
+ - 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
10
+ - 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.
11
+ - Update Hello, Code Text! and Glimmer Meta-Sample to support Dark Mode
12
+ - Refactor Hello, Custom Widget! with on_widget_disposed thread cleanup code
13
+ - Refactor Hello, Custom Shell! to support keyboard display of emails by hitting ENTER/SPACE after selecting a table row
14
+
15
+ ## 4.24.1.3
16
+
17
+ - 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)
18
+
3
19
  ## 4.24.1.2
4
20
 
5
21
  - 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`
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.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.24.2.1
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.2 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.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.
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 required on Mac/Linux / JDK 16 is required on Windows (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 is required on Mac/Linux / JRuby 9.3.4.0 is required on Windows (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.2
341
+ jgem install glimmer-dsl-swt -v 4.24.2.1
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.2'
369
+ gem 'glimmer-dsl-swt', '~> 4.24.2.1'
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.2
392
+ Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.24.2.1
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.2
1
+ 4.24.2.1
@@ -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
@@ -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']
@@ -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', 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
 
100
+ # Note: code_text theme is currently ignored in dark mode
99
101
  code_text(:multi, :h_scroll, :v_scroll, language: 'javascript', theme: 'pastie', 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,6 +120,7 @@ class HelloCodeText
118
120
 
119
121
  text 'HTML (github theme)'
120
122
 
123
+ # Note: code_text theme is currently ignored in dark mode
121
124
  code_text(language: 'html', theme: 'github') { # default is lines: false
122
125
  text <=> [self, :html_code]
123
126
  }
@@ -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.2
4
+ version: 4.24.2.1
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