glimmer-dsl-swt 4.20.5.0 → 4.20.7.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 +20 -0
- data/README.md +5 -5
- data/VERSION +1 -1
- data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +102 -6
- data/docs/reference/GLIMMER_SAMPLES.md +9 -13
- data/glimmer-dsl-swt.gemspec +0 -0
- data/lib/glimmer/rake_task/scaffold.rb +2 -2
- data/lib/glimmer/swt/custom/animation.rb +50 -25
- data/lib/glimmer/swt/custom/shape.rb +9 -0
- data/samples/elaborate/meta_sample.rb +2 -2
- data/samples/hello/hello_canvas_animation.rb +78 -38
- 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: 9a17e44008cc8425de7d3789c82e9bbaa11e0406e3f38ec71cee7f9427f07686
|
4
|
+
data.tar.gz: abfaa95510ebb353849d8659f55f5336aa1fd9b2653e4baf44fa156ba4524174
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c9c41491e55320002c349ae791073ec386237d63d07dc8737bbc8ecee37e29fbebef3ed8b4b333577ac8627e128fc54ff7da96720ca7db1fbad7ae4f49d7a96
|
7
|
+
data.tar.gz: 8a327ae96049e238fc36b40531e7bc9ae0d12303adae5183a4428de8cd3d39f49ef7ede3162b1b44a57102769f469200c556e394154eb65aba148679976ee12f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,25 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
### 4.20.7.0
|
4
|
+
|
5
|
+
- Add Canvas Animation DSL #finished, #finished?, #finished= properties
|
6
|
+
- Update Hello, Canvas Animation! (formerly had Data Binding suffix)
|
7
|
+
- Update Hello, Canvas Animation Multi! (formerly did not have Multi suffix)
|
8
|
+
|
9
|
+
### 4.20.6.0
|
10
|
+
|
11
|
+
- Canvas Animation DSL: support parallel animations per canvas (running along canvas static shapes too)
|
12
|
+
|
13
|
+
### 4.20.5.2
|
14
|
+
|
15
|
+
- Identify trimmed Canvas Shape DSL attribute `fill_rule` styles without `fill_` prefix
|
16
|
+
- Identify trimmed Canvas Shape DSL attribute `line_cap` styles without `cap_` prefix
|
17
|
+
- Identify trimmed Canvas Shape DSL attribute `line_join` styles without `join_` prefix
|
18
|
+
|
19
|
+
### 4.20.5.1
|
20
|
+
|
21
|
+
- Fix issue with Namespace is required always showing up when buildling a custom widget gem or custom shape gem
|
22
|
+
|
3
23
|
### 4.20.5.0
|
4
24
|
|
5
25
|
- Relax glimmer-dsl-swt version number when scaffolding custom shape/widget/shell gems. Keep it strict for app development.
|
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.6.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.6.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.6.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.6.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.6.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.7.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,8 +2282,8 @@ 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`
|
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
|
2191
2287
|
- `cycle_count` an optional cycle count limit after which the animation stops
|
2192
2288
|
- `frame_count` an optional frame count limit after which the animation stops
|
2193
2289
|
- `started` a boolean indicating if the animation is started right away or stopped waiting for manual startup via `#start` method
|
@@ -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
|
@@ -312,13 +312,13 @@ module Glimmer
|
|
312
312
|
end
|
313
313
|
|
314
314
|
def custom_widget_gem(custom_widget_name, namespace)
|
315
|
-
return puts('Namespace is required! Usage: glimmer scaffold:custom_widget_gem[custom_widget_name,namespace]') unless `git config --get github.user`.to_s.strip == 'AndyObtiva'
|
316
315
|
gem_name = "glimmer-cw-#{compact_name(custom_widget_name)}"
|
317
316
|
gem_summary = "#{human_name(custom_widget_name)} - Glimmer Custom Widget"
|
318
317
|
if namespace
|
319
318
|
gem_name += "-#{compact_name(namespace)}"
|
320
319
|
gem_summary += " (#{human_name(namespace)})"
|
321
320
|
else
|
321
|
+
return puts('Namespace is required! Usage: glimmer scaffold:custom_widget_gem[custom_widget_name,namespace]') unless `git config --get github.user`.to_s.strip == 'AndyObtiva'
|
322
322
|
namespace = 'glimmer'
|
323
323
|
end
|
324
324
|
|
@@ -350,13 +350,13 @@ module Glimmer
|
|
350
350
|
end
|
351
351
|
|
352
352
|
def custom_shape_gem(custom_shape_name, namespace)
|
353
|
-
return puts('Namespace is required! Usage: glimmer scaffold:custom_shape_gem[custom_shape_name,namespace]') unless `git config --get github.user`.to_s.strip == 'AndyObtiva'
|
354
353
|
gem_name = "glimmer-cp-#{compact_name(custom_shape_name)}"
|
355
354
|
gem_summary = "#{human_name(custom_shape_name)} - Glimmer Custom Shape"
|
356
355
|
if namespace
|
357
356
|
gem_name += "-#{compact_name(namespace)}"
|
358
357
|
gem_summary += " (#{human_name(namespace)})"
|
359
358
|
else
|
359
|
+
return puts('Namespace is required! Usage: glimmer scaffold:custom_shape_gem[custom_shape_name,namespace]') unless `git config --get github.user`.to_s.strip == 'AndyObtiva'
|
360
360
|
namespace = 'glimmer'
|
361
361
|
end
|
362
362
|
|
@@ -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,10 @@ 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
|
115
117
|
@original_start_time = @start_time if @duration.nil?
|
118
|
+
self.finished = false if finished?
|
119
|
+
self.started = true
|
116
120
|
# TODO track when finished in a variable for finite animations (whether by frame count, cycle count, or duration limit)
|
117
121
|
Thread.new do
|
118
122
|
start_number = @start_number
|
@@ -131,16 +135,16 @@ module Glimmer
|
|
131
135
|
|
132
136
|
def stop
|
133
137
|
return if stopped?
|
134
|
-
|
135
|
-
|
138
|
+
self.started = false
|
139
|
+
self.duration = (Time.now - @start_time) + @duration.to_f if duration_limited? && !@start_time.nil?
|
136
140
|
end
|
137
141
|
|
138
142
|
# Restarts an animation (whether indefinite or not and whether stopped or not)
|
139
143
|
def restart
|
140
144
|
@original_start_time = @start_time = nil
|
141
|
-
|
142
|
-
|
143
|
-
|
145
|
+
self.duration = nil
|
146
|
+
self.frame_index = 0
|
147
|
+
self.cycle_count_index = 0
|
144
148
|
stop
|
145
149
|
start
|
146
150
|
end
|
@@ -182,6 +186,21 @@ module Glimmer
|
|
182
186
|
end
|
183
187
|
end
|
184
188
|
|
189
|
+
def cycle_count_index=(value)
|
190
|
+
@cycle_count_index = value
|
191
|
+
self.finished = true if cycle_limited? && @cycle_count_index == @cycle_count
|
192
|
+
end
|
193
|
+
|
194
|
+
def frame_index=(value)
|
195
|
+
@frame_index = value
|
196
|
+
self.finished = true if frame_count_limited? && @frame_index == @frame_count
|
197
|
+
end
|
198
|
+
|
199
|
+
def duration=(value)
|
200
|
+
@duration = value
|
201
|
+
self.finished = true if surpassed_duration_limit?
|
202
|
+
end
|
203
|
+
|
185
204
|
def cycle_enabled?
|
186
205
|
@cycle.is_a?(Array)
|
187
206
|
end
|
@@ -195,7 +214,7 @@ module Glimmer
|
|
195
214
|
end
|
196
215
|
|
197
216
|
def frame_count_limited?
|
198
|
-
@frame_count.is_a?(Integer)
|
217
|
+
@frame_count.is_a?(Integer) && @frame_count > 0
|
199
218
|
end
|
200
219
|
|
201
220
|
def surpassed_duration_limit?
|
@@ -210,11 +229,13 @@ module Glimmer
|
|
210
229
|
|
211
230
|
# Returns true on success of painting a frame and false otherwise
|
212
231
|
def draw_frame(start_number)
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
232
|
+
if stopped? or
|
233
|
+
(start_number != @start_number) or
|
234
|
+
(frame_count_limited? && @frame_index == @frame_count) or
|
235
|
+
(cycle_limited? && @cycle_count_index == @cycle_count) or
|
236
|
+
surpassed_duration_limit?
|
237
|
+
return false
|
238
|
+
end
|
218
239
|
block_args = [@frame_index]
|
219
240
|
block_args << @cycle[@frame_index % @cycle.length] if cycle_enabled?
|
220
241
|
current_frame_index = @frame_index
|
@@ -222,20 +243,24 @@ module Glimmer
|
|
222
243
|
self.class.schedule_frame_animation(self) do
|
223
244
|
if started? && start_number == @start_number && within_duration_limit?
|
224
245
|
unless @parent.isDisposed
|
225
|
-
@
|
226
|
-
@parent.
|
246
|
+
@shapes.to_a.each(&:dispose)
|
247
|
+
parent_shapes_before = @parent.shapes.clone
|
248
|
+
@parent.content {
|
249
|
+
frame_block.call(*block_args)
|
250
|
+
}
|
251
|
+
@shapes = @parent.shapes - parent_shapes_before
|
227
252
|
end
|
228
253
|
else
|
254
|
+
self.finished = true if surpassed_duration_limit?
|
229
255
|
if stopped? && @frame_index > current_frame_index
|
230
|
-
|
231
|
-
|
232
|
-
@cycle_count_index = current_cycle_count_index
|
256
|
+
self.frame_index = current_frame_index
|
257
|
+
self.cycle_count_index = current_cycle_count_index
|
233
258
|
end
|
234
259
|
end
|
235
260
|
end
|
236
|
-
|
237
|
-
|
238
|
-
sleep(every) if every.is_a?(Numeric)
|
261
|
+
self.frame_index += 1
|
262
|
+
self.cycle_count_index += 1 if cycle_limited? && (@frame_index % @cycle&.length&.to_i) == 0
|
263
|
+
sleep(every) if every.is_a?(Numeric) # TODO consider using timer_exec as a more reliable alternative
|
239
264
|
true
|
240
265
|
rescue => e
|
241
266
|
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,89 @@
|
|
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_started, :animation_finished
|
30
|
+
|
31
|
+
before_body {
|
32
|
+
@animation_every = 0.050
|
33
|
+
@animation_frame_count = 100
|
34
|
+
@animation_started = true
|
35
|
+
@animation_finished = false
|
36
|
+
}
|
37
|
+
|
38
|
+
body {
|
39
|
+
shell {
|
40
|
+
grid_layout(2, true)
|
41
|
+
text 'Hello, Canvas Animation!'
|
42
|
+
|
43
|
+
button {
|
44
|
+
layout_data(:fill, :center, true, false)
|
45
|
+
text <= [self, :animation_started, on_read: ->(value) { value ? 'Stop' : 'Resume' }]
|
46
|
+
enabled <= [self, :animation_finished, on_read: :!]
|
36
47
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
48
|
+
on_widget_selected do
|
49
|
+
if @animation.started?
|
50
|
+
@animation.stop
|
51
|
+
else
|
52
|
+
@animation.start
|
53
|
+
end
|
54
|
+
end
|
43
55
|
}
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
56
|
+
button {
|
57
|
+
layout_data(:fill, :center, true, false)
|
58
|
+
text 'Restart'
|
59
|
+
|
60
|
+
on_widget_selected do
|
61
|
+
@animation.restart
|
62
|
+
end
|
63
|
+
}
|
64
|
+
label {
|
65
|
+
text 'every (milliseconds)'
|
66
|
+
}
|
67
|
+
label {
|
68
|
+
text 'frame count (0 is unlimited)'
|
69
|
+
}
|
70
|
+
spinner {
|
71
|
+
layout_data(:fill, :center, true, false)
|
72
|
+
digits 3
|
73
|
+
minimum 1
|
74
|
+
maximum 100
|
75
|
+
selection <=> [self, :animation_every, on_read: ->(v) {(BigDecimal(v.to_s)*1000).to_f}, on_write: ->(v) {(BigDecimal(v.to_s)/1000).to_f}]
|
76
|
+
}
|
77
|
+
spinner {
|
78
|
+
layout_data(:fill, :center, true, false)
|
79
|
+
minimum 0
|
80
|
+
maximum 100
|
81
|
+
selection <=> [self, :animation_frame_count]
|
82
|
+
}
|
83
|
+
|
84
|
+
canvas {
|
85
|
+
layout_data(:fill, :fill, true, true) {
|
86
|
+
horizontal_span 2
|
87
|
+
width_hint 320
|
88
|
+
height_hint 320
|
61
89
|
}
|
62
|
-
|
63
|
-
|
90
|
+
@animation = animation {
|
91
|
+
every <= [self, :animation_every]
|
92
|
+
frame_count <= [self, :animation_frame_count]
|
93
|
+
started <=> [self, :animation_started]
|
94
|
+
finished <=> [self, :animation_finished]
|
95
|
+
|
96
|
+
frame { |index|
|
97
|
+
background rgb(index%100, index%100 + 100, index%55 + 200)
|
98
|
+
oval(index*3%300, index*3%300, 20, 20) {
|
99
|
+
background :yellow
|
100
|
+
}
|
101
|
+
}
|
64
102
|
}
|
65
103
|
}
|
66
104
|
}
|
67
105
|
}
|
68
|
-
|
106
|
+
end
|
107
|
+
|
108
|
+
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.7.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-18 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
|