glimmer-dsl-swt 4.20.5.1 → 4.20.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/README.md +5 -5
- data/VERSION +1 -1
- data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +107 -9
- data/docs/reference/GLIMMER_SAMPLES.md +9 -13
- data/glimmer-dsl-swt.gemspec +0 -0
- data/lib/glimmer/swt/custom/animation.rb +59 -28
- data/lib/glimmer/swt/custom/shape.rb +9 -0
- data/samples/elaborate/meta_sample.rb +2 -2
- data/samples/hello/hello_canvas_animation.rb +98 -37
- data/samples/hello/hello_canvas_animation_multi.rb +109 -0
- metadata +3 -3
- data/samples/hello/hello_canvas_animation_data_binding.rb +0 -66
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22394bc84cfc12938603e2566009365c2d23f9eee64f49b9da159f201438ca78
|
4
|
+
data.tar.gz: d00cd63f2663d46628e26a9dd974705e29d6d97e5c4b9d686194899662b34218
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab487ddda276df797b56bdc5ad201ec6a9f02abcda356d13f8bdaa7c70eb3a90252459cc83872e28e88bf0b14284eafcaf05ee1f1dfca1468b88730eb1364b74
|
7
|
+
data.tar.gz: 1a8bb076d8bfb3daa0678477039c3220c5e49e206e08e641d2c701a5ef72a1ac3820a4f19539077be5d6d7ee5e65332f9118e88214b9d1cc9e6960a6c84339a9
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,27 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
### 4.20.8.0
|
4
|
+
|
5
|
+
- Support data-binding Animation `duration_limit` property
|
6
|
+
- Improve support of Animation `duration_limit` property in recognizing when an animation is finished
|
7
|
+
- Added duration limit to Hello, Canvas Animation! sample
|
8
|
+
|
9
|
+
### 4.20.7.0
|
10
|
+
|
11
|
+
- Add Canvas Animation DSL #finished, #finished?, #finished= properties
|
12
|
+
- Update Hello, Canvas Animation! (formerly had Data Binding suffix)
|
13
|
+
- Update Hello, Canvas Animation Multi! (formerly did not have Multi suffix)
|
14
|
+
|
15
|
+
### 4.20.6.0
|
16
|
+
|
17
|
+
- Canvas Animation DSL: support parallel animations per canvas (running along canvas static shapes too)
|
18
|
+
|
19
|
+
### 4.20.5.2
|
20
|
+
|
21
|
+
- Identify trimmed Canvas Shape DSL attribute `fill_rule` styles without `fill_` prefix
|
22
|
+
- Identify trimmed Canvas Shape DSL attribute `line_cap` styles without `cap_` prefix
|
23
|
+
- Identify trimmed Canvas Shape DSL attribute `line_join` styles without `join_` prefix
|
24
|
+
|
3
25
|
### 4.20.5.1
|
4
26
|
|
5
27
|
- Fix issue with Namespace is required always showing up when buildling a custom widget gem or custom shape gem
|
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.20.
|
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.20.8.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)
|
@@ -15,7 +15,7 @@
|
|
15
15
|
[<img src="https://covers.oreillystatic.com/images/9780596519650/lrg.jpg" width=105 /><br />
|
16
16
|
Featured in JRuby Cookbook](http://shop.oreilly.com/product/9780596519650.do) and [Chalmers/Gothenburg University Software Engineering Master's Lecture Material](http://www.cse.chalmers.se/~bergert/slides/guest_lecture_DSLs.pdf)
|
17
17
|
|
18
|
-
[Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.20.
|
18
|
+
[Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.20.8.0 includes [SWT 4.20](https://download.eclipse.org/eclipse/downloads/drops4/R-4.20-202106111600/), which was released on June 11, 2021. Gem version numbers are in sync with the SWT library versions. The first two digits represent the SWT version number. The last two digits represent the minor and patch versions of Glimmer DSL for SWT. Note that SWT now supports AARCH64 on Mac and Linux, but it is not fully tested in Glimmer DSL for SWT yet, so deem its support experimental for the time being without guarantees for functionality until declared otherwise (report any issues you may encounter).
|
19
19
|
|
20
20
|
**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 (keep in mind that it is still a beta, so default back to `bind` whenever needed).
|
21
21
|
|
@@ -347,7 +347,7 @@ jgem install glimmer-dsl-swt
|
|
347
347
|
|
348
348
|
Or this command if you want a specific version:
|
349
349
|
```
|
350
|
-
jgem install glimmer-dsl-swt -v 4.20.
|
350
|
+
jgem install glimmer-dsl-swt -v 4.20.8.0
|
351
351
|
```
|
352
352
|
|
353
353
|
`jgem` is JRuby's version of `gem` command.
|
@@ -375,7 +375,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
|
|
375
375
|
|
376
376
|
Add the following to `Gemfile`:
|
377
377
|
```
|
378
|
-
gem 'glimmer-dsl-swt', '~> 4.20.
|
378
|
+
gem 'glimmer-dsl-swt', '~> 4.20.8.0'
|
379
379
|
```
|
380
380
|
|
381
381
|
And, then run:
|
@@ -396,7 +396,7 @@ glimmer
|
|
396
396
|
```
|
397
397
|
|
398
398
|
```
|
399
|
-
Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.20.
|
399
|
+
Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.20.8.0
|
400
400
|
|
401
401
|
Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
|
402
402
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.20.
|
1
|
+
4.20.8.0
|
@@ -18,6 +18,7 @@ This guide should help you get started with Glimmer DSL for SWT. For more advanc
|
|
18
18
|
- [sync_exec](#sync_exec)
|
19
19
|
- [timer_exec](#timer_exec)
|
20
20
|
- [Menus](#menus)
|
21
|
+
- [Tray Item](#tray-item)
|
21
22
|
- [ScrolledComposite](#scrolledcomposite)
|
22
23
|
- [Sash Form Widget](#sash-form-widget)
|
23
24
|
- [Browser Widget](#browser-widget)
|
@@ -872,6 +873,101 @@ shell {
|
|
872
873
|
}.open
|
873
874
|
```
|
874
875
|
|
876
|
+
#### Tray Item
|
877
|
+
|
878
|
+
![Hello Tray Item Icon](/images/glimmer-hello-tray-item.png)
|
879
|
+
|
880
|
+
The system tray allows showing icons for various apps that need to stay on for extended periods of time and provide quick access.
|
881
|
+
|
882
|
+
In Glimmer DSL for SWT, generating tray items is automated via the `tray_item` keyword, which can be nested under `shell` and then have a child `menu` underneath that pops up when the user clicks on its icon in the system tray.
|
883
|
+
|
884
|
+
Note how the shell was declared with the `:on_top` style (in addition to the default, which is `:shell_trim`) to ensure it opens above all apps when the "Show Application" menu item is selected.
|
885
|
+
|
886
|
+
Example code:
|
887
|
+
|
888
|
+
```ruby
|
889
|
+
shell(:shell_trim, :on_top) { # make it always appear on top of everything
|
890
|
+
row_layout(:vertical) {
|
891
|
+
center true
|
892
|
+
}
|
893
|
+
text 'Hello, Tray Item!'
|
894
|
+
|
895
|
+
on_shell_closed do |event|
|
896
|
+
# do not perform event that closes app when shell is closed
|
897
|
+
event.doit = false
|
898
|
+
# body_root is the root shell
|
899
|
+
body_root.hide
|
900
|
+
self.show_application = false # updates Show Application checkbox menu item indirectly
|
901
|
+
end
|
902
|
+
|
903
|
+
tray_item {
|
904
|
+
tool_tip_text 'Glimmer'
|
905
|
+
image @image # could use an image path instead
|
906
|
+
|
907
|
+
menu {
|
908
|
+
menu_item {
|
909
|
+
text 'About'
|
910
|
+
|
911
|
+
on_widget_selected do
|
912
|
+
message_box {
|
913
|
+
text 'Glimmer - About'
|
914
|
+
message 'This is a Glimmer DSL for SWT Tray Item'
|
915
|
+
}.open
|
916
|
+
end
|
917
|
+
}
|
918
|
+
menu_item(:separator)
|
919
|
+
menu_item(:check) {
|
920
|
+
text 'Show Application'
|
921
|
+
selection <=> [self, :show_application]
|
922
|
+
|
923
|
+
on_widget_selected do
|
924
|
+
# body_root is the root shell
|
925
|
+
if body_root.visible?
|
926
|
+
body_root.hide
|
927
|
+
else
|
928
|
+
body_root.show
|
929
|
+
end
|
930
|
+
end
|
931
|
+
}
|
932
|
+
menu_item(:separator)
|
933
|
+
menu_item {
|
934
|
+
text 'Exit'
|
935
|
+
|
936
|
+
on_widget_selected {
|
937
|
+
exit(0)
|
938
|
+
}
|
939
|
+
}
|
940
|
+
}
|
941
|
+
|
942
|
+
# supported tray item listeners (you can try to add actions to them when needed)
|
943
|
+
# on_swt_Show {
|
944
|
+
# }
|
945
|
+
#
|
946
|
+
# on_swt_Hide {
|
947
|
+
# }
|
948
|
+
#
|
949
|
+
# on_widget_selected {
|
950
|
+
# }
|
951
|
+
#
|
952
|
+
# on_menu_detected {
|
953
|
+
# }
|
954
|
+
}
|
955
|
+
|
956
|
+
label(:center) {
|
957
|
+
text 'This is the application'
|
958
|
+
font height: 30
|
959
|
+
}
|
960
|
+
label {
|
961
|
+
text 'Click on the tray item (circles icon) to open its menu'
|
962
|
+
}
|
963
|
+
label {
|
964
|
+
text 'Uncheck Show Application to hide the app and recheck it to show the app'
|
965
|
+
}
|
966
|
+
}
|
967
|
+
```
|
968
|
+
|
969
|
+
Learn more at [Hello, Tray Item!](/docs/reference/GLIMMER_SAMPLES.md#hello-tray-item)
|
970
|
+
|
875
971
|
#### ScrolledComposite
|
876
972
|
|
877
973
|
Glimmer provides smart defaults for the `scrolled_composite` widget by:
|
@@ -2147,13 +2243,13 @@ Learn more at the [Hello, Canvas Transform! Sample](GLIMMER_SAMPLES.md#hello-can
|
|
2147
2243
|
|
2148
2244
|
(note: this is a very new feature of Glimmer. It may change a bit while getting battle tested. As always, you could default to basic SWT usage if needed.)
|
2149
2245
|
|
2150
|
-
Glimmer
|
2246
|
+
Glimmer provides built-in support for animations via a declarative Animation DSL, another sub-DSL of the Glimmer GUI DSL.
|
2151
2247
|
|
2152
|
-
Animations take advantage of multi-threading, automatically running each animation in its own independent thread of execution while updating the GUI asynchronously.
|
2248
|
+
Animations take advantage of multi-threading, with Glimmer DSL for SWT automatically running each animation in its own independent thread of execution while updating the GUI asynchronously.
|
2153
2249
|
|
2154
|
-
Multiple simultaneous animations are supported
|
2250
|
+
Multiple simultaneous animations are supported per `canvas` (or widget) parent.
|
2155
2251
|
|
2156
|
-
`canvas` has the `:double_buffered` SWT style by default to ensure flicker-free rendering. If you need to disable it for whatever reason, just pass the `:none` SWT style instead (e.g. `canvas(:none)`)
|
2252
|
+
`canvas` has the `:double_buffered` SWT style by default on platforms other than the Mac to ensure flicker-free rendering (Mac does not need it). If you need to disable it for whatever reason, just pass the `:none` SWT style instead (e.g. `canvas(:none)`)
|
2157
2253
|
|
2158
2254
|
This example says it all (it moves a tiny red square across a blue background) (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
|
2159
2255
|
|
@@ -2186,11 +2282,13 @@ Screenshot:
|
|
2186
2282
|
Keywords:
|
2187
2283
|
- `animation` declares an animation under a canvas, which renders frames using a frame block indefinitely or finitely depending on (cycle_count/frame_count) properties
|
2188
2284
|
- `every` specifies delay in seconds between every two frame renders
|
2189
|
-
- `frame` a block that can contain Shape DSL syntax that is rendered dynamically with variables calculated on the fly
|
2190
|
-
- `cycle`
|
2191
|
-
- `cycle_count` an optional cycle count limit after which the animation stops
|
2192
|
-
- `frame_count` an optional frame count limit after which the animation stops
|
2193
|
-
- `
|
2285
|
+
- `frame {|index, cycle_var| }` a block that can contain Shape DSL syntax that is rendered dynamically with variables calculated on the fly
|
2286
|
+
- `cycle` an optional property that takes an array to cycle into a second variable for the `frame` block
|
2287
|
+
- `cycle_count` an optional cycle count limit after which the animation stops (finishes)
|
2288
|
+
- `frame_count` an optional frame count limit after which the animation stops (finishes)
|
2289
|
+
- `duration_limit` an optional duration limit in seconds after which the animation stops (finishes)
|
2290
|
+
- `started`/`started?` a boolean indicating if the animation is started right away or stopped waiting for manual startup via `#start` method
|
2291
|
+
- `finished`/`finished?` a boolean indicating if the animation finished (for finite animations only)
|
2194
2292
|
|
2195
2293
|
API of Animation Object (returned from `animation` keyword):
|
2196
2294
|
- `#start` starts an animation that is indefinite or has never been started before (i.e. having `started: false` option). Otherwise, resumes a stopped animation that has not been completed.
|
@@ -39,7 +39,7 @@
|
|
39
39
|
- [Hello, Code Text!](#hello-code-text)
|
40
40
|
- [Hello, Canvas!](#hello-canvas)
|
41
41
|
- [Hello, Canvas Animation!](#hello-canvas-animation)
|
42
|
-
- [Hello, Canvas Animation
|
42
|
+
- [Hello, Canvas Animation Multi!](#hello-canvas-animation-multi)
|
43
43
|
- [Hello, Canvas Transform!](#hello-canvas-transform)
|
44
44
|
- [Hello, Canvas Path!](#hello-canvas-path)
|
45
45
|
- [Hello, Canvas Data Binding!](#hello-canvas-data-binding)
|
@@ -743,31 +743,27 @@ Hello, Canvas! Data-Binding (changing a `text` shape `string` via data-binding c
|
|
743
743
|
|
744
744
|
#### Hello, Canvas Animation!
|
745
745
|
|
746
|
-
This sample demonstrates the use of the
|
746
|
+
This sample demonstrates the use of the [Canvas Animation DSL](#canvas-animation-dsl) with data-binding.
|
747
747
|
|
748
748
|
Code:
|
749
749
|
|
750
|
-
[samples/hello/
|
750
|
+
[samples/hello/hello_canvas_animation_data_binding.rb](/samples/hello/hello_canvas_animation_data_binding.rb)
|
751
751
|
|
752
752
|
Hello, Canvas Animation!
|
753
753
|
|
754
|
-
![Hello Canvas Animation](/images/glimmer-hello-canvas-animation.
|
755
|
-
|
756
|
-
Hello, Canvas Animation Another Frame!
|
754
|
+
![Hello Canvas Animation Data Binding](/images/glimmer-hello-canvas-animation.gif)
|
757
755
|
|
758
|
-
|
756
|
+
#### Hello, Canvas Animation Multi!
|
759
757
|
|
760
|
-
|
761
|
-
|
762
|
-
This sample demonstrates the use of the [Canvas Animation DSL](#canvas-animation-dsl) with data-binding.
|
758
|
+
This sample demonstrates parallel animations in the [Canvas Animation DSL](/docs/reference/GLIMMER_GUI_DSL_SYNTAX#canvas-animation-dsl).
|
763
759
|
|
764
760
|
Code:
|
765
761
|
|
766
|
-
[samples/hello/
|
762
|
+
[samples/hello/hello_canvas_animation_multi.rb](/samples/hello/hello_canvas_animation_multi.rb)
|
767
763
|
|
768
|
-
Hello, Canvas Animation
|
764
|
+
Hello, Canvas Animation Multi!
|
769
765
|
|
770
|
-
![Hello Canvas Animation
|
766
|
+
![Hello Canvas Animation Multi](/images/glimmer-hello-canvas-animation-multi.gif)
|
771
767
|
|
772
768
|
#### Hello, Canvas Transform!
|
773
769
|
|
data/glimmer-dsl-swt.gemspec
CHANGED
Binary file
|
@@ -20,6 +20,7 @@
|
|
20
20
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
22
|
require 'glimmer/swt/properties'
|
23
|
+
require 'glimmer/swt/custom/shape'
|
23
24
|
|
24
25
|
module Glimmer
|
25
26
|
module SWT
|
@@ -27,6 +28,7 @@ module Glimmer
|
|
27
28
|
# Represents an animation declaratively
|
28
29
|
class Animation
|
29
30
|
include Properties
|
31
|
+
include Glimmer::DataBinding::ObservableModel
|
30
32
|
|
31
33
|
class << self
|
32
34
|
def schedule_frame_animation(animation, &frame_animation_block)
|
@@ -76,18 +78,19 @@ module Glimmer
|
|
76
78
|
end
|
77
79
|
end
|
78
80
|
|
79
|
-
attr_reader :parent, :options
|
81
|
+
attr_reader :parent, :options
|
82
|
+
attr_accessor :frame_index, :cycle, :frame_block, :every, :cycle_count, :frame_count, :started, :duration_limit, :duration, :finished, :cycle_count_index
|
80
83
|
alias current_frame_index frame_index
|
81
|
-
attr_accessor :frame_block, :every, :cycle_count, :frame_count, :started, :duration_limit
|
82
84
|
alias started? started
|
85
|
+
alias finished? finished
|
83
86
|
# TODO consider supporting an async: false option
|
84
87
|
|
85
88
|
def initialize(parent)
|
86
89
|
@parent = parent
|
87
90
|
@parent.requires_shape_disposal = true
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
+
self.started = true
|
92
|
+
self.frame_index = 0
|
93
|
+
self.cycle_count_index = 0
|
91
94
|
@start_number = 0 # denotes the number of starts (increments on every start)
|
92
95
|
self.class.swt_display # ensures initializing variable to set from GUI thread
|
93
96
|
end
|
@@ -110,9 +113,11 @@ module Glimmer
|
|
110
113
|
def start
|
111
114
|
return if @start_number > 0 && started?
|
112
115
|
@start_number += 1
|
113
|
-
@started = true
|
114
116
|
@start_time = Time.now
|
117
|
+
@duration = 0
|
115
118
|
@original_start_time = @start_time if @duration.nil?
|
119
|
+
self.finished = false if finished?
|
120
|
+
self.started = true
|
116
121
|
# TODO track when finished in a variable for finite animations (whether by frame count, cycle count, or duration limit)
|
117
122
|
Thread.new do
|
118
123
|
start_number = @start_number
|
@@ -131,16 +136,16 @@ module Glimmer
|
|
131
136
|
|
132
137
|
def stop
|
133
138
|
return if stopped?
|
134
|
-
|
135
|
-
|
139
|
+
self.started = false
|
140
|
+
self.duration = (Time.now - @start_time) + @duration.to_f if duration_limited? && !@start_time.nil?
|
136
141
|
end
|
137
142
|
|
138
143
|
# Restarts an animation (whether indefinite or not and whether stopped or not)
|
139
144
|
def restart
|
140
|
-
@original_start_time = @start_time =
|
141
|
-
|
142
|
-
|
143
|
-
|
145
|
+
@original_start_time = @start_time = Time.now
|
146
|
+
self.duration = 0
|
147
|
+
self.frame_index = 0
|
148
|
+
self.cycle_count_index = 0
|
144
149
|
stop
|
145
150
|
start
|
146
151
|
end
|
@@ -182,6 +187,24 @@ module Glimmer
|
|
182
187
|
end
|
183
188
|
end
|
184
189
|
|
190
|
+
def cycle_count_index=(value)
|
191
|
+
@cycle_count_index = value
|
192
|
+
self.finished = true if cycle_limited? && @cycle_count_index == @cycle_count
|
193
|
+
@cycle_count_index
|
194
|
+
end
|
195
|
+
|
196
|
+
def frame_index=(value)
|
197
|
+
@frame_index = value
|
198
|
+
self.finished = true if frame_count_limited? && @frame_index == @frame_count
|
199
|
+
@frame_index
|
200
|
+
end
|
201
|
+
|
202
|
+
def duration=(value)
|
203
|
+
@duration = value
|
204
|
+
self.finished = true if surpassed_duration_limit?
|
205
|
+
@duration
|
206
|
+
end
|
207
|
+
|
185
208
|
def cycle_enabled?
|
186
209
|
@cycle.is_a?(Array)
|
187
210
|
end
|
@@ -191,15 +214,15 @@ module Glimmer
|
|
191
214
|
end
|
192
215
|
|
193
216
|
def duration_limited?
|
194
|
-
@duration_limit.is_a?(
|
217
|
+
@duration_limit.is_a?(Numeric) && @duration_limit > 0
|
195
218
|
end
|
196
219
|
|
197
220
|
def frame_count_limited?
|
198
|
-
@frame_count.is_a?(Integer)
|
221
|
+
@frame_count.is_a?(Integer) && @frame_count > 0
|
199
222
|
end
|
200
223
|
|
201
224
|
def surpassed_duration_limit?
|
202
|
-
duration_limited? && ((Time.now - @start_time) >
|
225
|
+
duration_limited? && ((Time.now - @start_time) > @duration_limit)
|
203
226
|
end
|
204
227
|
|
205
228
|
def within_duration_limit?
|
@@ -210,32 +233,40 @@ module Glimmer
|
|
210
233
|
|
211
234
|
# Returns true on success of painting a frame and false otherwise
|
212
235
|
def draw_frame(start_number)
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
236
|
+
if stopped? or
|
237
|
+
(start_number != @start_number) or
|
238
|
+
(frame_count_limited? && @frame_index == @frame_count) or
|
239
|
+
(cycle_limited? && @cycle_count_index == @cycle_count) or
|
240
|
+
surpassed_duration_limit?
|
241
|
+
self.duration = Time.now - @start_time
|
242
|
+
return false
|
243
|
+
end
|
218
244
|
block_args = [@frame_index]
|
219
245
|
block_args << @cycle[@frame_index % @cycle.length] if cycle_enabled?
|
220
246
|
current_frame_index = @frame_index
|
221
247
|
current_cycle_count_index = @cycle_count_index
|
222
248
|
self.class.schedule_frame_animation(self) do
|
249
|
+
self.duration = Time.now - @start_time # TODO should this be set here, after the if statement, in the else too, or outside both?
|
223
250
|
if started? && start_number == @start_number && within_duration_limit?
|
224
251
|
unless @parent.isDisposed
|
225
|
-
@
|
226
|
-
@parent.
|
252
|
+
@shapes.to_a.each(&:dispose)
|
253
|
+
parent_shapes_before = @parent.shapes.clone
|
254
|
+
@parent.content {
|
255
|
+
frame_block.call(*block_args)
|
256
|
+
}
|
257
|
+
@shapes = @parent.shapes - parent_shapes_before
|
258
|
+
self.duration = Time.now - @start_time # TODO consider if this is needed
|
227
259
|
end
|
228
260
|
else
|
229
261
|
if stopped? && @frame_index > current_frame_index
|
230
|
-
|
231
|
-
|
232
|
-
@cycle_count_index = current_cycle_count_index
|
262
|
+
self.frame_index = current_frame_index
|
263
|
+
self.cycle_count_index = current_cycle_count_index
|
233
264
|
end
|
234
265
|
end
|
235
266
|
end
|
236
|
-
|
237
|
-
|
238
|
-
sleep(every) if every.is_a?(Numeric)
|
267
|
+
self.frame_index += 1
|
268
|
+
self.cycle_count_index += 1 if cycle_limited? && (@frame_index % @cycle&.length&.to_i) == 0
|
269
|
+
sleep(every) if every.is_a?(Numeric) # TODO consider using timer_exec as a perhaps more reliable alternative
|
239
270
|
true
|
240
271
|
rescue => e
|
241
272
|
Glimmer::Config.logger.error {e}
|
@@ -295,6 +295,15 @@ module Glimmer
|
|
295
295
|
if method_name.to_s == 'setLineStyle'
|
296
296
|
args[0] = "line_#{args[0]}" if !args[0].to_s.downcase.start_with?('line_')
|
297
297
|
end
|
298
|
+
if method_name.to_s == 'setFillRule'
|
299
|
+
args[0] = "fill_#{args[0]}" if !args[0].to_s.downcase.start_with?('fill_')
|
300
|
+
end
|
301
|
+
if method_name.to_s == 'setLineCap'
|
302
|
+
args[0] = "cap_#{args[0]}" if !args[0].to_s.downcase.start_with?('cap_')
|
303
|
+
end
|
304
|
+
if method_name.to_s == 'setLineJoin'
|
305
|
+
args[0] = "join_#{args[0]}" if !args[0].to_s.downcase.start_with?('join_')
|
306
|
+
end
|
298
307
|
if the_java_method.parameter_types.first == Java::int.java_class
|
299
308
|
args[0] = SWTProxy.constant(args[0])
|
300
309
|
end
|
@@ -207,6 +207,8 @@ class MetaSampleApplication
|
|
207
207
|
image File.expand_path('../../icons/scaffold_app.png', __dir__)
|
208
208
|
|
209
209
|
sash_form {
|
210
|
+
weights 4, 14
|
211
|
+
|
210
212
|
composite {
|
211
213
|
grid_layout(1, false) {
|
212
214
|
margin_width 0
|
@@ -282,8 +284,6 @@ class MetaSampleApplication
|
|
282
284
|
left_margin 7
|
283
285
|
right_margin 7
|
284
286
|
}
|
285
|
-
|
286
|
-
weights 4, 11
|
287
287
|
}
|
288
288
|
}
|
289
289
|
}
|
@@ -20,49 +20,110 @@
|
|
20
20
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
22
|
require 'glimmer-dsl-swt'
|
23
|
+
require 'bigdecimal'
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
25
|
+
class HelloCanvasAnimation
|
26
|
+
include Glimmer::UI::CustomShell
|
27
|
+
|
28
|
+
# data-bindable attributes (names must vary from attribute names on animation)
|
29
|
+
attr_accessor :animation_every, :animation_frame_count, :animation_duration_limit, :animation_started, :animation_finished
|
30
|
+
|
31
|
+
before_body {
|
32
|
+
@animation_every = 0.050 # seconds
|
33
|
+
@animation_frame_count = 100
|
34
|
+
@animation_duration_limit = 0 # seconds
|
35
|
+
@animation_started = true
|
36
|
+
@animation_finished = false
|
37
|
+
}
|
38
|
+
|
39
|
+
body {
|
40
|
+
shell {
|
41
|
+
grid_layout(2, true)
|
42
|
+
text 'Hello, Canvas Animation!'
|
43
|
+
|
44
|
+
# row 1
|
45
|
+
button {
|
46
|
+
layout_data(:fill, :center, true, false)
|
47
|
+
text <= [self, :animation_started, on_read: ->(value) { value ? 'Stop' : 'Resume' }]
|
48
|
+
enabled <= [self, :animation_finished, on_read: :!]
|
36
49
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
50
|
+
on_widget_selected do
|
51
|
+
if @animation.started?
|
52
|
+
@animation.stop
|
53
|
+
else
|
54
|
+
@animation.start
|
55
|
+
end
|
56
|
+
end
|
57
|
+
}
|
58
|
+
button {
|
59
|
+
layout_data(:fill, :center, true, false)
|
60
|
+
text 'Restart'
|
61
|
+
|
62
|
+
on_widget_selected do
|
63
|
+
@animation.restart
|
64
|
+
end
|
43
65
|
}
|
44
|
-
}
|
45
|
-
}
|
46
|
-
|
47
|
-
canvas {
|
48
|
-
colors = [:yellow, :red]
|
49
|
-
animation {
|
50
|
-
every 0.25 # in seconds (one quarter)
|
51
|
-
cycle colors # cycles array of colors into the second variable of the frame block below
|
52
|
-
|
53
|
-
frame { |index, color| # frame block loops indefinitely (unless frame_count or cycle_count is set to an integer)
|
54
|
-
outside_color = colors[index % 2]
|
55
|
-
inside_color = colors[(index + 1) % 2]
|
56
|
-
|
57
|
-
background outside_color # sets canvas background color
|
58
66
|
|
59
|
-
|
60
|
-
|
67
|
+
# row 2
|
68
|
+
label {
|
69
|
+
text 'every'
|
70
|
+
}
|
71
|
+
label {
|
72
|
+
text 'frame count (0=unlimited)'
|
73
|
+
}
|
74
|
+
|
75
|
+
# row 3
|
76
|
+
spinner {
|
77
|
+
layout_data(:fill, :center, true, false)
|
78
|
+
digits 3
|
79
|
+
minimum 1
|
80
|
+
maximum 100
|
81
|
+
selection <=> [self, :animation_every, on_read: ->(v) {(BigDecimal(v.to_s)*1000).to_f}, on_write: ->(v) {(BigDecimal(v.to_s)/1000).to_f}]
|
82
|
+
}
|
83
|
+
spinner {
|
84
|
+
layout_data(:fill, :center, true, false)
|
85
|
+
minimum 0
|
86
|
+
maximum 100
|
87
|
+
selection <=> [self, :animation_frame_count]
|
88
|
+
}
|
89
|
+
|
90
|
+
# row 4
|
91
|
+
label {
|
92
|
+
text 'duration limit (0=unlimited)'
|
93
|
+
}
|
94
|
+
label # filler
|
95
|
+
|
96
|
+
# row 5
|
97
|
+
spinner {
|
98
|
+
layout_data(:fill, :center, true, false)
|
99
|
+
minimum 0
|
100
|
+
maximum 10
|
101
|
+
selection <=> [self, :animation_duration_limit]
|
102
|
+
}
|
103
|
+
|
104
|
+
canvas {
|
105
|
+
layout_data(:fill, :fill, true, true) {
|
106
|
+
horizontal_span 2
|
107
|
+
width_hint 320
|
108
|
+
height_hint 320
|
61
109
|
}
|
62
|
-
|
63
|
-
|
110
|
+
@animation = animation {
|
111
|
+
every <= [self, :animation_every]
|
112
|
+
frame_count <= [self, :animation_frame_count]
|
113
|
+
duration_limit <= [self, :animation_duration_limit]
|
114
|
+
started <=> [self, :animation_started]
|
115
|
+
finished <=> [self, :animation_finished]
|
116
|
+
|
117
|
+
frame { |index|
|
118
|
+
background rgb(index%100, index%100 + 100, index%55 + 200)
|
119
|
+
oval(index*3%300, index*3%300, 20, 20) {
|
120
|
+
background :yellow
|
121
|
+
}
|
122
|
+
}
|
64
123
|
}
|
65
124
|
}
|
66
125
|
}
|
67
126
|
}
|
68
|
-
|
127
|
+
end
|
128
|
+
|
129
|
+
HelloCanvasAnimation.launch
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# Copyright (c) 2007-2021 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
|
+
require 'glimmer-dsl-swt'
|
23
|
+
|
24
|
+
include Glimmer
|
25
|
+
|
26
|
+
shell {
|
27
|
+
text 'Hello, Canvas Animation Multi!'
|
28
|
+
minimum_size 1200, 420
|
29
|
+
|
30
|
+
canvas {
|
31
|
+
background :white
|
32
|
+
|
33
|
+
animation {
|
34
|
+
every 0.01 # in seconds (one hundredth)
|
35
|
+
|
36
|
+
frame { |index| # frame block loops indefinitely (unless frame_count is set to an integer)
|
37
|
+
oval(0, 0, 400, 400) { # x, y, width, height
|
38
|
+
foreground :black # sets oval background color
|
39
|
+
}
|
40
|
+
arc(0, 0, 400, 400, -1.4*index%360, 10) { # x, y, width, height, start angle, arc angle
|
41
|
+
background rgb(50, 200, 50) # sets arc background color
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
canvas {
|
48
|
+
background :white
|
49
|
+
|
50
|
+
colors = [:yellow, :red]
|
51
|
+
|
52
|
+
animation {
|
53
|
+
every 0.25 # in seconds (one quarter)
|
54
|
+
cycle colors # cycles array of colors into the second variable of the frame block below
|
55
|
+
|
56
|
+
frame { |index, color| # frame block loops indefinitely (unless frame_count or cycle_count is set to an integer)
|
57
|
+
outside_color = colors[index % 2]
|
58
|
+
inside_color = colors[(index + 1) % 2]
|
59
|
+
|
60
|
+
background outside_color # sets canvas background color
|
61
|
+
|
62
|
+
rectangle(0, 0, 200, 200) {
|
63
|
+
background inside_color # sets rectangle background color
|
64
|
+
}
|
65
|
+
rectangle(200, 200, 200, 200) {
|
66
|
+
background inside_color # sets rectangle background color
|
67
|
+
}
|
68
|
+
}
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
72
|
+
canvas {
|
73
|
+
background :white
|
74
|
+
|
75
|
+
colors = [:yellow, :red]
|
76
|
+
|
77
|
+
animation {
|
78
|
+
every 0.25 # in seconds (one quarter)
|
79
|
+
cycle colors # cycles array of colors into the second variable of the frame block below
|
80
|
+
|
81
|
+
frame { |index, color| # frame block loops indefinitely (unless frame_count or cycle_count is set to an integer)
|
82
|
+
outside_color = colors[index % 2]
|
83
|
+
inside_color = colors[(index + 1) % 2]
|
84
|
+
|
85
|
+
background outside_color # sets canvas background color
|
86
|
+
|
87
|
+
rectangle(0, 0, 200, 200) {
|
88
|
+
background inside_color # sets rectangle background color
|
89
|
+
}
|
90
|
+
rectangle(200, 200, 200, 200) {
|
91
|
+
background inside_color # sets rectangle background color
|
92
|
+
}
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
animation {
|
97
|
+
every 0.01 # in seconds (one hundredth)
|
98
|
+
|
99
|
+
frame { |index| # frame block loops indefinitely (unless frame_count is set to an integer)
|
100
|
+
oval(0, 0, 400, 400) { # x, y, width, height
|
101
|
+
foreground :black # sets oval background color
|
102
|
+
}
|
103
|
+
arc(0, 0, 400, 400, -1.4*index%360, 10) { # x, y, width, height, start angle, arc angle
|
104
|
+
background rgb(50, 200, 50) # sets arc background color
|
105
|
+
}
|
106
|
+
}
|
107
|
+
}
|
108
|
+
}
|
109
|
+
}.open
|
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.20.
|
4
|
+
version: 4.20.8.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: 2021-07-
|
11
|
+
date: 2021-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -574,7 +574,7 @@ files:
|
|
574
574
|
- samples/hello/hello_c_tab.rb
|
575
575
|
- samples/hello/hello_canvas.rb
|
576
576
|
- samples/hello/hello_canvas_animation.rb
|
577
|
-
- samples/hello/
|
577
|
+
- samples/hello/hello_canvas_animation_multi.rb
|
578
578
|
- samples/hello/hello_canvas_data_binding.rb
|
579
579
|
- samples/hello/hello_canvas_path.rb
|
580
580
|
- samples/hello/hello_canvas_transform.rb
|
@@ -1,66 +0,0 @@
|
|
1
|
-
# Copyright (c) 2007-2021 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
|
-
require 'glimmer-dsl-swt'
|
23
|
-
require 'bigdecimal'
|
24
|
-
|
25
|
-
class HelloAnimationDataBinding
|
26
|
-
include Glimmer::UI::CustomShell
|
27
|
-
|
28
|
-
attr_accessor :delay_time
|
29
|
-
|
30
|
-
before_body {
|
31
|
-
@delay_time = 0.050
|
32
|
-
}
|
33
|
-
|
34
|
-
body {
|
35
|
-
shell {
|
36
|
-
text 'Hello, Canvas Animation Data Binding!'
|
37
|
-
minimum_size 320, 320
|
38
|
-
|
39
|
-
canvas {
|
40
|
-
grid_layout
|
41
|
-
|
42
|
-
spinner {
|
43
|
-
layout_data(:center, :center, true, true) {
|
44
|
-
minimum_width 75
|
45
|
-
}
|
46
|
-
digits 3
|
47
|
-
minimum 1
|
48
|
-
maximum 100
|
49
|
-
selection <=> [self, :delay_time, on_read: ->(v) {(BigDecimal(v.to_s)*1000).to_f}, on_write: ->(v) {(BigDecimal(v.to_s)/1000).to_f}]
|
50
|
-
}
|
51
|
-
animation {
|
52
|
-
every <= [self, :delay_time]
|
53
|
-
|
54
|
-
frame { |index|
|
55
|
-
background rgb(index%100, index%100 + 100, index%55 + 200)
|
56
|
-
oval(index*3%300, index*3%300, 20, 20) {
|
57
|
-
background :yellow
|
58
|
-
}
|
59
|
-
}
|
60
|
-
}
|
61
|
-
}
|
62
|
-
}
|
63
|
-
}
|
64
|
-
end
|
65
|
-
|
66
|
-
HelloAnimationDataBinding.launch
|