glimmer-dsl-swt 4.24.0.2 → 4.24.1.2

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: b4fbbf7e487d4ee6667d7b9b30833ce767ae9c14c0cfd90c893f40269a8d8c2e
4
- data.tar.gz: 49750266d23f5a59e4123aaa02b9864c6907366e6be70dcac69b0ef5c96aabc7
3
+ metadata.gz: 4958a72683334de9b8f0ca8a213eabce1dbf93031ea249dd760abea934d704d6
4
+ data.tar.gz: ec7566aee8c9a16a757fc639cb64a3a3b96ba83b7abb92d92a83bc64221631a8
5
5
  SHA512:
6
- metadata.gz: 36d166223378ffa459eb42d2154432be06c4efe7305ffeaa34683476fa08267bf6dd94c2ba5056a8b534fbdedbeda8aa5702a6f5bb6baec593461d9fb2f66547
7
- data.tar.gz: 55736839c473741195ac69ac63ed0e01efebb6d9c3867f77756172e8b636fa8f1c69c97a7fe46827112a72cd0c73b11cabfa2df11c65a1ee4886307b98d1faff
6
+ metadata.gz: 0fcf51949b0e6231e92b1d0603c530f69272ccd5a3a18631d3a386a140bffb5e41bca9eda858ff6f5481aeb60351e8fcef04f0ce30ec835cdd50898e149cadf8
7
+ data.tar.gz: 75a92e8793f5c7782dd9d18359a1693d80dc35de3ad7eea51268a316f382ed1c88bf5e451865975ffe881134ff041fc343697e1c4f933fb77e3fd6fac22ba70e
data/CHANGELOG.md CHANGED
@@ -1,8 +1,23 @@
1
1
  # Change Log
2
2
 
3
+ ## 4.24.1.2
4
+
5
+ - 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`
6
+ - Refactor Parking sample to clarify rotation details
7
+
8
+ ## 4.24.1.1
9
+
10
+ - Fix `jar-dependencies` gem version to v0.4.1 in scaffolded applications to avoid issue encountered in newly released v0.4.2
11
+
12
+ ## 4.24.1.0
13
+
14
+ - Upgrade to JRuby 9.3.6.0
15
+ - Speed up app scaffolding by dropping packaging from the scaffolding steps as there is no point in packaging an unfinished product
16
+ - Refactor/simplify Hello, Canvas Path!
17
+
3
18
  ## 4.24.0.2
4
19
 
5
- - Extend Hello, Canvas Data-Binding! to support quadratic bezier curves, cubic bezier curves, and Drag & Drop of endpoints / control points
20
+ - Update Hello, Canvas Data-Binding! to support quadratic bezier curves, cubic bezier curves, and Drag & Drop of endpoints / control points
6
21
  - Fix issue with data-binding `quad` & `cubic` path shape `point_array`
7
22
 
8
23
  ## 4.24.0.1
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.0.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.1.2
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)
@@ -19,7 +19,7 @@ Featured in JRuby Cookbook](http://shop.oreilly.com/product/9780596519650.do) an
19
19
 
20
20
  ![Eclipse SWT RCP NASA Mars Rover](/images/glimmer-eclipse-swt-rcp-nasa-mars-rover.png)
21
21
 
22
- [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.24.0.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.
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.
23
23
 
24
24
  **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
25
 
@@ -281,7 +281,7 @@ Audio is supported via the Java Sound library in a cross-platform approach and v
281
281
 
282
282
  ### Remaining Challenges
283
283
 
284
- JRuby startup time is longer than that of CRuby, but has gotten a lot faster with newer CPUs, especially the latest Mac ARM64 processors. Thankfully, [there are work-arounds](https://andymaleh.blogspot.com/2021/03/glimmer-dsl-for-swt-41900-halved.html) that could make apps start as fast as instantly when needed.
284
+ JRuby startup time is longer than that of CRuby, but has gotten a lot faster with newer CPUs, especially the latest Mac ARM64 processors (it is now about 2.5 seconds on Mac ARM64 processors like the M1 chip). Thankfully, [there are work-arounds](https://andymaleh.blogspot.com/2021/03/glimmer-dsl-for-swt-41900-halved.html) that could make apps start as fast as instantly when needed.
285
285
 
286
286
  Contributors who appreciate Glimmer's ultra-high productivity, maintainability, and extensibility might want to help report and resolve remaining challenges in its software architecture.
287
287
 
@@ -304,9 +304,9 @@ https://www.eclipse.org/swt/faq.php
304
304
 
305
305
  ## Pre-requisites
306
306
 
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)
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)
308
308
  - [RVM](http://rvm.io) on Mac & Linux (not needed on Windows)
309
- - JRuby 9.3.4.0 (supporting Ruby 2.6.x syntax) (get via [RVM](http://rvm.io) on Mac and Linux by running `rvm install jruby-9.3.4.0`; On Windows, find at [https://www.jruby.org/download](https://www.jruby.org/download))
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))
310
310
  - 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
311
  - Git (comes with Mac and Linux. Install on Windows: https://git-scm.com/download/win )
312
312
 
@@ -336,7 +336,7 @@ jgem install glimmer-dsl-swt
336
336
 
337
337
  Or this command if you want a specific version:
338
338
  ```
339
- jgem install glimmer-dsl-swt -v 4.24.0.2
339
+ jgem install glimmer-dsl-swt -v 4.24.1.2
340
340
  ```
341
341
 
342
342
  `jgem` is JRuby's version of `gem` command.
@@ -364,7 +364,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
364
364
 
365
365
  Add the following to `Gemfile`:
366
366
  ```
367
- gem 'glimmer-dsl-swt', '~> 4.24.0.2'
367
+ gem 'glimmer-dsl-swt', '~> 4.24.1.2'
368
368
  ```
369
369
 
370
370
  And, then run:
@@ -387,7 +387,7 @@ glimmer
387
387
  ```
388
388
 
389
389
  ```
390
- Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.24.0.2
390
+ Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.24.1.2
391
391
 
392
392
  Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
393
393
 
data/RUBY_VERSION CHANGED
@@ -1 +1 @@
1
- jruby-9.3.4.0
1
+ jruby-9.3.6.0
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.24.0.2
1
+ 4.24.1.2
@@ -1077,7 +1077,7 @@ You may check out a more full-fledged example in [Hello, Sash Form!](/docs/refer
1077
1077
 
1078
1078
  ![Hello Browser](/images/glimmer-hello-browser.png)
1079
1079
 
1080
- Glimmer supports the [SWT Browser widget](https://help.eclipse.org/2020-12/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/browser/Browser.html), which can load URLs or render HTML. It can even be instrumented with JavaScript when needed (though highly discouraged since it defeats the purpose of using Ruby except in very rare cases like leveraging a pre-existing web codebase in a desktop app).
1080
+ Glimmer DSL for SWT includes a basic [SWT Browser widget](https://help.eclipse.org/2020-12/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/browser/Browser.html), which can load URLs or render HTML. It supports WebKit, IE, and Edge browsers out of the box. Its JavaScript engine can even be instrumented with Ruby code if needed.
1081
1081
 
1082
1082
  Example loading a URL (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
1083
1083
 
@@ -1114,7 +1114,11 @@ 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 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.
1117
+ Learn more at:
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
+ - [SWT Browser FAQ](https://www.eclipse.org/swt/faq.php#whatisbrowser).
1120
+
1121
+ The built-in basic SWT `browser` widget might not satisfy all your needs. If so, consider the advanced 3rd-party browser widget [JxBrowser](https://www.teamdev.com/jxbrowser), which utilizes Google Chromium.
1118
1122
 
1119
1123
  ### Widget Styles
1120
1124
 
@@ -3562,7 +3566,7 @@ As they say, there are many ways to skin a cat! This is in line with the Ruby wa
3562
3566
 
3563
3567
  ### Canvas Path DSL
3564
3568
 
3565
- Unlike common imperative GUI graphing toolkits, Glimmer enables declarative rendering of paths with the new Canvas Path DSL (Early Alpha) via the new `path { }` keyword and by nesting one of the following path segment keywords underneath:
3569
+ Unlike common imperative GUI graphing toolkits, Glimmer enables declarative rendering of paths with the Canvas Path DSL via the new `path { }` keyword and by nesting one of the following path segment keywords underneath:
3566
3570
  - `point(x1, y1)`: renders a Point (Dot) as part of a path.
3567
3571
  - `line(x1, y1, x2=nil, y2=nil)`: renders a Line as part of a path. If you drop x2, y2, it joins to the previous point automatically. You may repeat for a series of lines forming a curve.
3568
3572
  - `quad(x1, y1, x2, y2, x3=nil, y3=nil)`: renders a Quadratic Bezier Curve. If you drop x3 and y3, it joins to the previous point automatically.
@@ -100,7 +100,7 @@ This brings up the [Glimmer Meta-Sample (The Sample of Samples)](/samples/elabor
100
100
 
101
101
  ![Glimmer Meta-Sample](/images/glimmer-meta-sample.png)
102
102
 
103
- You may edit the code of any sample before launching it by clicking on the "Launch" button. This helps you learn by experimenting with Glimmer GUI DSL syntax. To go back to original code, simply hit the "Reset" button.
103
+ You may edit the code of any sample before launching it by clicking on the "Launch" button. This helps you learn by experimenting with Glimmer GUI DSL syntax. To go back to original code, simply hit the "Reset" button. Also, for some samples, you can click the "Tutorial" button, and a YouTube video is played to guide you through learning the sample. The YouTube videos are played from the [Glimmer YouTube Channel](https://www.youtube.com/channel/UC5hzDE23HZXsZLAxYk2UJEw).
104
104
 
105
105
  Note that if you fail to run any sample through the Glimmer Meta-Sample for whatever reason, you could always run directly by cloning the project, running `bundle`, and then this command (drop the "bin" if you install the glimmer-dsl-swt gem instead):
106
106
 
Binary file
@@ -125,6 +125,7 @@ module Glimmer
125
125
  GEMFILE_SUFFIX = <<~MULTI_LINE_STRING
126
126
 
127
127
  group :development do
128
+ gem 'jar-dependencies', '0.4.1'
128
129
  gem 'rspec', '~> 3.5.0'
129
130
  gem 'juwelier', '2.4.9'
130
131
  gem 'warbler', '2.0.5'
@@ -195,16 +196,12 @@ module Glimmer
195
196
  system "bash -c '#{RVM_FUNCTION}\n cd .\n bundle\n rspec --init\n'"
196
197
  end
197
198
  write 'spec/spec_helper.rb', spec_helper_file
198
- if OS.windows?
199
- system "glimmer package" # TODO handle Windows with batch file
200
- system "\"packages/bundles/#{human_name(app_name)}/#{human_name(app_name)}.exe\""
199
+ if OS.mac?
200
+ system "bash -c '#{RVM_FUNCTION}\n cd .\n JRUBY_OPTS=\"$JRUBY_OPTS -J-XstartOnFirstThread\" glimmer run\n'"
201
+ elsif OS.linux?
202
+ system "bash -c '#{RVM_FUNCTION}\n cd .\n glimmer run\n'"
201
203
  else
202
- system "bash -c '#{RVM_FUNCTION}\n cd .\n glimmer package\n'"
203
- if OS.mac?
204
- system "bash -c '#{RVM_FUNCTION}\n cd .\n JRUBY_OPTS=\"$JRUBY_OPTS -J-XstartOnFirstThread\" glimmer run\n'"
205
- else
206
- system "bash -c '#{RVM_FUNCTION}\n cd .\n glimmer run\n'"
207
- end
204
+ system "glimmer run"
208
205
  end
209
206
  end
210
207
 
@@ -294,16 +291,12 @@ module Glimmer
294
291
  cp File.expand_path('../../../../icons/scaffold_app.png', __FILE__), icon_file
295
292
  puts "Created #{current_dir_name}/#{icon_file}"
296
293
 
297
- if OS.windows?
298
- system "glimmer package" # TODO handle windows properly with batch file
299
- system "\"packages/bundles/#{human_name(custom_shell_name)}/#{human_name(custom_shell_name)}.exe\""
294
+ if OS.mac?
295
+ system "bash -c '#{RVM_FUNCTION}\n cd .\n JRUBY_OPTS=\"$JRUBY_OPTS -J-XstartOnFirstThread\" glimmer run\n'"
296
+ elsif OS.linux?
297
+ system "bash -c '#{RVM_FUNCTION}\n cd .\n glimmer run\n'"
300
298
  else
301
- system "bash -c '#{RVM_FUNCTION}\n cd .\n glimmer package\n'"
302
- if OS.mac?
303
- system "bash -c '#{RVM_FUNCTION}\n cd .\n JRUBY_OPTS=\"$JRUBY_OPTS -J-XstartOnFirstThread\" glimmer run\n'"
304
- else
305
- system "bash -c '#{RVM_FUNCTION}\n cd .\n glimmer run\n'"
306
- end
299
+ system "glimmer run"
307
300
  end
308
301
  puts "Finished creating #{gem_name} Ruby gem."
309
302
  puts 'Edit Rakefile to configure gem details.'
@@ -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)
@@ -22,3 +22,6 @@ Hello, Tray Item!: VYXgIr5zxMM
22
22
  Hello, Drag And Drop!: zJSG5ysow0M
23
23
  Hello, Canvas Drag And Drop!: e7taTbRrDAM
24
24
  Game Of Life: pDE79YRjOjs
25
+ Hello, Canvas Data Binding!: PQ_Y8e5VeDo
26
+ Hello, Canvas Path!: ThmNcXTldY8
27
+ Hello, Canvas Transform!: ePIAF5EMsE0
@@ -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
@@ -20,101 +20,106 @@
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  require 'glimmer-dsl-swt'
23
-
24
- include Glimmer
25
-
26
- shell {
27
- grid_layout {
28
- margin_width 0
29
- margin_height 0
30
- margin_top 5
31
- }
32
- text 'Hello, Canvas Path!'
33
- minimum_size 800, 700
34
-
35
- @button = button {
36
- layout_data :center, :center, true, false
37
- text 'Regenerate'
38
- enabled false
39
-
40
- on_widget_selected do
41
- @regenerate = true
42
- @button.enabled = false
43
- end
44
- }
45
- canvas {
46
- layout_data :fill, :fill, true, true
47
- background :white
48
-
49
- text('line', 15, 200) {
50
- foreground :red
51
- }
52
- @path1 = path {
53
- antialias :on
54
- foreground :red
55
- }
56
-
57
- text('quad', 15, 300) {
58
- foreground :dark_green
59
- }
60
- @path2 = path {
61
- antialias :on
62
- foreground :dark_green
63
- }
23
+
24
+ class HelloCanvasPath
25
+ include Glimmer::UI::Application
64
26
 
65
- text('cubic', 15, 400) {
66
- foreground :blue
67
- }
68
- @path3 = path {
69
- antialias :on
70
- foreground :blue
27
+ after_body do
28
+ regenerate
29
+ end
30
+
31
+ body {
32
+ shell {
33
+ grid_layout {
34
+ margin_width 0
35
+ margin_height 0
36
+ margin_top 5
37
+ }
38
+
39
+ text 'Hello, Canvas Path!'
40
+ minimum_size 800, 700
41
+
42
+ @button = button {
43
+ layout_data :center, :center, true, false
44
+
45
+ text 'Regenerate'
46
+ enabled false
47
+
48
+ on_widget_selected do
49
+ regenerate
50
+ end
51
+ }
52
+
53
+ canvas {
54
+ layout_data :fill, :fill, true, true
55
+
56
+ background :white
57
+
58
+ text('line', 15, 200) {
59
+ foreground :red
60
+ }
61
+ @path1 = path {
62
+ antialias :on
63
+ foreground :red
64
+ }
65
+
66
+ text('quad', 15, 300) {
67
+ foreground :dark_green
68
+ }
69
+ @path2 = path {
70
+ antialias :on
71
+ foreground :dark_green
72
+ }
73
+
74
+ text('cubic', 15, 400) {
75
+ foreground :blue
76
+ }
77
+ @path3 = path {
78
+ antialias :on
79
+ foreground :blue
80
+ }
81
+ }
82
+
83
+ on_widget_disposed do
84
+ # safe to kill thread as data is in memory only, so no risk of data loss
85
+ @thread.kill
86
+ end
71
87
  }
72
88
  }
73
89
 
74
- on_swt_show do
75
- @regenerate = true
90
+ def regenerate
76
91
  @thread = Thread.new do
77
- loop do
78
- if @regenerate
79
- @regenerate = false
80
- @path1.clear
81
- @path2.clear
82
- @path3.clear
83
- y1 = y2 = y3 = 300
84
- 700.times.each do |x|
85
- x += 55
86
- x1 = x - 2
87
- x2 = x - 1
88
- x3 = x
89
- y1 = y3
90
- y2 = y1
91
- y3 = [[y3 + (rand*24 - 12), 0].max, 700].min
92
- @path1.content {
93
- line(x1, y1 - 100)
94
- }
95
- if x % 2 == 0
96
- @path2.content {
97
- quad(x1, y1, x2, y2)
98
- }
99
- end
100
- if x % 3 == 0
101
- @path3.content {
102
- cubic(x1, y1 + 100, x2, y2 + 100, x3, y3 + 100)
103
- }
104
- end
105
- sleep(0.01)
106
- end
107
- @button.enabled = true
92
+ @button.enabled = false
93
+ @path1.clear
94
+ @path2.clear
95
+ @path3.clear
96
+ y1 = y2 = y3 = 300
97
+ 700.times.each do |x|
98
+ x += 55
99
+ x1 = x - 2
100
+ x2 = x - 1
101
+ x3 = x
102
+ y1 = y3
103
+ y2 = y1
104
+ y3 = [[y3 + (rand*24 - 12), 0].max, 700].min
105
+ @path1.content {
106
+ line(x1, y1 - 100)
107
+ }
108
+ if x % 2 == 0
109
+ @path2.content {
110
+ quad(x1, y1, x2, y2)
111
+ }
108
112
  end
109
- sleep(0.1)
113
+ if x % 3 == 0
114
+ @path3.content {
115
+ cubic(x1, y1 + 100, x2, y2 + 100, x3, y3 + 100)
116
+ }
117
+ end
118
+ sleep(0.01)
110
119
  end
111
-
120
+ @button.enabled = true
112
121
  end
113
-
114
122
  end
115
-
116
- on_widget_disposed do
117
- @thread.kill # safe to kill since data is in memory only
118
- end
119
-
120
- }.open
123
+ end
124
+
125
+ HelloCanvasPath.launch
@@ -19,12 +19,14 @@ shell {
19
19
  # also supports inversion, identity, shear, and multiplication {transform properties}
20
20
  }
21
21
  }
22
+
22
23
  image(glimmer_logo, 0, 0) {
23
24
  transform {
24
25
  translation 110, 220
25
26
  scale 0.21, 0.21
26
27
  }
27
28
  }
29
+
28
30
  image(glimmer_logo, 0, 0) {
29
31
  transform {
30
32
  translation 220, 220
@@ -32,6 +34,7 @@ shell {
32
34
  scale 0.21, 0.21
33
35
  }
34
36
  }
37
+
35
38
  image(glimmer_logo, 0, 0) {
36
39
  transform {
37
40
  translation 220, 110
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.0.2
4
+ version: 4.24.1.2
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-07-15 00:00:00.000000000 Z
11
+ date: 2022-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement