glimmer-dsl-swt 4.20.6.0 → 4.20.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/VERSION +1 -1
- data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +3 -3
- data/docs/reference/GLIMMER_SAMPLES.md +9 -13
- data/glimmer-dsl-swt.gemspec +0 -0
- data/lib/glimmer/swt/custom/animation.rb +43 -23
- data/samples/elaborate/meta_sample.rb +2 -2
- data/samples/hello/hello_canvas_animation.rb +77 -78
- 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,11 @@
|
|
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
|
+
|
3
9
|
### 4.20.6.0
|
4
10
|
|
5
11
|
- Canvas Animation DSL: support parallel animations per canvas (running along canvas static shapes too)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.20.
|
1
|
+
4.20.7.0
|
@@ -2247,7 +2247,7 @@ Glimmer provides built-in support for animations via a declarative Animation DSL
|
|
2247
2247
|
|
2248
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.
|
2249
2249
|
|
2250
|
-
Multiple simultaneous animations are supported per `canvas` (or widget) parent
|
2250
|
+
Multiple simultaneous animations are supported per `canvas` (or widget) parent.
|
2251
2251
|
|
2252
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)`)
|
2253
2253
|
|
@@ -2282,8 +2282,8 @@ Screenshot:
|
|
2282
2282
|
Keywords:
|
2283
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
|
2284
2284
|
- `every` specifies delay in seconds between every two frame renders
|
2285
|
-
- `frame` a block that can contain Shape DSL syntax that is rendered dynamically with variables calculated on the fly
|
2286
|
-
- `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
|
2287
2287
|
- `cycle_count` an optional cycle count limit after which the animation stops
|
2288
2288
|
- `frame_count` an optional frame count limit after which the animation stops
|
2289
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
|
-

|
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
|
-

|
771
767
|
|
772
768
|
#### Hello, Canvas Transform!
|
773
769
|
|
data/glimmer-dsl-swt.gemspec
CHANGED
Binary file
|
@@ -28,6 +28,7 @@ module Glimmer
|
|
28
28
|
# Represents an animation declaratively
|
29
29
|
class Animation
|
30
30
|
include Properties
|
31
|
+
include Glimmer::DataBinding::ObservableModel
|
31
32
|
|
32
33
|
class << self
|
33
34
|
def schedule_frame_animation(animation, &frame_animation_block)
|
@@ -77,18 +78,19 @@ module Glimmer
|
|
77
78
|
end
|
78
79
|
end
|
79
80
|
|
80
|
-
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
|
81
83
|
alias current_frame_index frame_index
|
82
|
-
attr_accessor :frame_block, :every, :cycle_count, :frame_count, :started, :duration_limit
|
83
84
|
alias started? started
|
85
|
+
alias finished? finished
|
84
86
|
# TODO consider supporting an async: false option
|
85
87
|
|
86
88
|
def initialize(parent)
|
87
89
|
@parent = parent
|
88
90
|
@parent.requires_shape_disposal = true
|
89
|
-
|
90
|
-
|
91
|
-
|
91
|
+
self.started = true
|
92
|
+
self.frame_index = 0
|
93
|
+
self.cycle_count_index = 0
|
92
94
|
@start_number = 0 # denotes the number of starts (increments on every start)
|
93
95
|
self.class.swt_display # ensures initializing variable to set from GUI thread
|
94
96
|
end
|
@@ -111,9 +113,10 @@ module Glimmer
|
|
111
113
|
def start
|
112
114
|
return if @start_number > 0 && started?
|
113
115
|
@start_number += 1
|
114
|
-
@started = true
|
115
116
|
@start_time = Time.now
|
116
117
|
@original_start_time = @start_time if @duration.nil?
|
118
|
+
self.finished = false if finished?
|
119
|
+
self.started = true
|
117
120
|
# TODO track when finished in a variable for finite animations (whether by frame count, cycle count, or duration limit)
|
118
121
|
Thread.new do
|
119
122
|
start_number = @start_number
|
@@ -132,16 +135,16 @@ module Glimmer
|
|
132
135
|
|
133
136
|
def stop
|
134
137
|
return if stopped?
|
135
|
-
|
136
|
-
|
138
|
+
self.started = false
|
139
|
+
self.duration = (Time.now - @start_time) + @duration.to_f if duration_limited? && !@start_time.nil?
|
137
140
|
end
|
138
141
|
|
139
142
|
# Restarts an animation (whether indefinite or not and whether stopped or not)
|
140
143
|
def restart
|
141
144
|
@original_start_time = @start_time = nil
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
+
self.duration = nil
|
146
|
+
self.frame_index = 0
|
147
|
+
self.cycle_count_index = 0
|
145
148
|
stop
|
146
149
|
start
|
147
150
|
end
|
@@ -183,6 +186,21 @@ module Glimmer
|
|
183
186
|
end
|
184
187
|
end
|
185
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
|
+
|
186
204
|
def cycle_enabled?
|
187
205
|
@cycle.is_a?(Array)
|
188
206
|
end
|
@@ -196,7 +214,7 @@ module Glimmer
|
|
196
214
|
end
|
197
215
|
|
198
216
|
def frame_count_limited?
|
199
|
-
@frame_count.is_a?(Integer)
|
217
|
+
@frame_count.is_a?(Integer) && @frame_count > 0
|
200
218
|
end
|
201
219
|
|
202
220
|
def surpassed_duration_limit?
|
@@ -211,11 +229,13 @@ module Glimmer
|
|
211
229
|
|
212
230
|
# Returns true on success of painting a frame and false otherwise
|
213
231
|
def draw_frame(start_number)
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
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
|
219
239
|
block_args = [@frame_index]
|
220
240
|
block_args << @cycle[@frame_index % @cycle.length] if cycle_enabled?
|
221
241
|
current_frame_index = @frame_index
|
@@ -231,16 +251,16 @@ module Glimmer
|
|
231
251
|
@shapes = @parent.shapes - parent_shapes_before
|
232
252
|
end
|
233
253
|
else
|
254
|
+
self.finished = true if surpassed_duration_limit?
|
234
255
|
if stopped? && @frame_index > current_frame_index
|
235
|
-
|
236
|
-
|
237
|
-
@cycle_count_index = current_cycle_count_index
|
256
|
+
self.frame_index = current_frame_index
|
257
|
+
self.cycle_count_index = current_cycle_count_index
|
238
258
|
end
|
239
259
|
end
|
240
260
|
end
|
241
|
-
|
242
|
-
|
243
|
-
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
|
244
264
|
true
|
245
265
|
rescue => e
|
246
266
|
Glimmer::Config.logger.error {e}
|
@@ -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,90 +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
|
-
|
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
|
-
}
|
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
|
45
36
|
}
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
}
|
65
|
-
rectangle(200, 200, 200, 200) {
|
66
|
-
background inside_color # sets rectangle background color
|
67
|
-
}
|
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: :!]
|
47
|
+
|
48
|
+
on_widget_selected do
|
49
|
+
if @animation.started?
|
50
|
+
@animation.stop
|
51
|
+
else
|
52
|
+
@animation.start
|
53
|
+
end
|
54
|
+
end
|
68
55
|
}
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
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
|
-
}
|
56
|
+
button {
|
57
|
+
layout_data(:fill, :center, true, false)
|
58
|
+
text 'Restart'
|
59
|
+
|
60
|
+
on_widget_selected do
|
61
|
+
@animation.restart
|
62
|
+
end
|
93
63
|
}
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
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
|
102
89
|
}
|
103
|
-
|
104
|
-
|
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
|
+
}
|
105
102
|
}
|
106
103
|
}
|
107
104
|
}
|
108
105
|
}
|
109
|
-
|
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
|