glimmer-dsl-swt 4.18.5.4 → 4.18.6.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -56,9 +56,9 @@ class HelloCanvas
56
56
  rectangle([:default, -70], :default, :default, [:default, 1]) {
57
57
  foreground :cyan
58
58
  text {
59
- x :default, 1
60
- # y is assumed to be the default (centered within parent)
61
59
  string bind(self, :artist)
60
+ x :default, 1 # add 1 pixel to default x (shape centered within parent horizontally)
61
+ y :default, 1 # add 1 pixel to default y (shape centered within parent vertically)
62
62
  background :yellow
63
63
  foreground :dark_magenta
64
64
  font name: 'Courier', height: 30
@@ -0,0 +1,214 @@
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
+ class HelloCanvasDataBinding
25
+ include Glimmer::GUI::CustomWindow
26
+
27
+ CANVAS_WIDTH = 300
28
+ CANVAS_HEIGHT = 300
29
+
30
+ attr_accessor :x1_value, :y1_value, :x2_value, :y2_value, :foreground_red, :foreground_green, :foreground_blue, :line_width_value, :line_style_value
31
+
32
+ def foreground_value
33
+ rgb(foreground_red, foreground_green, foreground_blue)
34
+ end
35
+
36
+ def line_style_value_options
37
+ [:solid, :dash, :dot, :dashdot, :dashdotdot]
38
+ end
39
+
40
+ before_body {
41
+ self.x1_value = 0
42
+ self.y1_value = 0
43
+ self.x2_value = CANVAS_WIDTH
44
+ self.y2_value = CANVAS_HEIGHT
45
+ self.foreground_red = 28
46
+ self.foreground_green = 128
47
+ self.foreground_blue = 228
48
+ self.line_width_value = 3
49
+ self.line_style_value = :dot
50
+ }
51
+
52
+ body {
53
+ shell {
54
+ text 'Hello, Canvas Data-Binding!'
55
+
56
+ tab_folder {
57
+ tab_item {
58
+ grid_layout(6, true) {
59
+ margin_width 0
60
+ margin_height 0
61
+ horizontal_spacing 0
62
+ vertical_spacing 0
63
+ }
64
+ text 'line'
65
+
66
+ label {
67
+ layout_data(:fill, :center, false, false) {
68
+ horizontal_span 3
69
+ }
70
+ text 'x1'
71
+ }
72
+ label {
73
+ layout_data(:fill, :center, false, false) {
74
+ horizontal_span 3
75
+ }
76
+ text 'y1'
77
+ }
78
+ spinner {
79
+ layout_data(:fill, :center, false, false) {
80
+ horizontal_span 3
81
+ }
82
+ maximum CANVAS_WIDTH
83
+ increment 3
84
+ selection bind(self, :x1_value)
85
+ }
86
+ spinner {
87
+ layout_data(:fill, :center, false, false) {
88
+ horizontal_span 3
89
+ }
90
+ maximum CANVAS_HEIGHT
91
+ increment 3
92
+ selection bind(self, :y1_value)
93
+ }
94
+ label {
95
+ layout_data(:fill, :center, false, false) {
96
+ horizontal_span 3
97
+ }
98
+ text 'x2'
99
+ }
100
+ label {
101
+ layout_data(:fill, :center, false, false) {
102
+ horizontal_span 3
103
+ }
104
+ text 'y2'
105
+ }
106
+ spinner {
107
+ layout_data(:fill, :center, false, false) {
108
+ horizontal_span 3
109
+ }
110
+ maximum CANVAS_WIDTH
111
+ increment 3
112
+ selection bind(self, :x2_value)
113
+ }
114
+ spinner {
115
+ layout_data(:fill, :center, false, false) {
116
+ horizontal_span 3
117
+ }
118
+ maximum CANVAS_HEIGHT
119
+ increment 3
120
+ selection bind(self, :y2_value)
121
+ }
122
+ label {
123
+ layout_data(:fill, :center, false, false) {
124
+ horizontal_span 2
125
+ }
126
+ text 'foreground red'
127
+ }
128
+ label {
129
+ layout_data(:fill, :center, false, false) {
130
+ horizontal_span 2
131
+ }
132
+ text 'foreground green'
133
+ }
134
+ label {
135
+ layout_data(:fill, :center, false, false) {
136
+ horizontal_span 2
137
+ }
138
+ text 'foreground blue'
139
+ }
140
+ spinner {
141
+ layout_data(:fill, :center, false, false) {
142
+ horizontal_span 2
143
+ }
144
+ maximum 255
145
+ increment 10
146
+ selection bind(self, :foreground_red)
147
+ }
148
+ spinner {
149
+ layout_data(:fill, :center, false, false) {
150
+ horizontal_span 2
151
+ }
152
+ maximum 255
153
+ increment 10
154
+ selection bind(self, :foreground_green)
155
+ }
156
+ spinner {
157
+ layout_data(:fill, :center, false, false) {
158
+ horizontal_span 2
159
+ }
160
+ maximum 255
161
+ increment 10
162
+ selection bind(self, :foreground_blue)
163
+ }
164
+ label {
165
+ layout_data(:fill, :center, false, false) {
166
+ horizontal_span 3
167
+ }
168
+ text 'line width'
169
+ }
170
+ label {
171
+ layout_data(:fill, :center, false, false) {
172
+ horizontal_span 3
173
+ }
174
+ text 'line style'
175
+ }
176
+ spinner {
177
+ layout_data(:fill, :center, false, false) {
178
+ horizontal_span 3
179
+ }
180
+ maximum 255
181
+ selection bind(self, :line_width_value)
182
+ }
183
+ combo(:read_only) {
184
+ layout_data(:fill, :center, false, false) {
185
+ horizontal_span 3
186
+ }
187
+ selection bind(self, :line_style_value)
188
+ }
189
+ canvas {
190
+ layout_data(:center, :center, false, false) {
191
+ horizontal_span 6
192
+ width_hint CANVAS_WIDTH
193
+ height_hint CANVAS_WIDTH
194
+ }
195
+ background :white
196
+
197
+ line {
198
+ x1 bind(self, :x1_value)
199
+ y1 bind(self, :y1_value)
200
+ x2 bind(self, :x2_value)
201
+ y2 bind(self, :y2_value)
202
+ foreground bind(self, :foreground_value, computed_by: [:foreground_red, :foreground_green, :foreground_blue])
203
+ line_width bind(self, :line_width_value)
204
+ line_style bind(self, :line_style_value)
205
+ }
206
+ }
207
+ }
208
+ }
209
+ }
210
+ }
211
+
212
+ end
213
+
214
+ HelloCanvasDataBinding.launch
@@ -0,0 +1,120 @@
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
+ 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 {
41
+ @regenerate = true
42
+ @button.enabled = false
43
+ }
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
+ }
64
+
65
+ text('cubic', 15, 400) {
66
+ foreground :blue
67
+ }
68
+ @path3 = path {
69
+ antialias :on
70
+ foreground :blue
71
+ }
72
+ }
73
+
74
+ on_swt_show {
75
+ @regenerate = true
76
+ @thread = Thread.new {
77
+ loop {
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
108
+ end
109
+ sleep(0.1)
110
+ }
111
+
112
+ }
113
+
114
+ }
115
+
116
+ on_widget_disposed {
117
+ @thread.kill # safe to kill since data is in memory only
118
+ }
119
+
120
+ }.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.18.5.4
4
+ version: 4.18.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-26 00:00:00.000000000 Z
11
+ date: 2021-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -434,13 +434,17 @@ files:
434
434
  - lib/glimmer/swt/custom/radio_group.rb
435
435
  - lib/glimmer/swt/custom/shape.rb
436
436
  - lib/glimmer/swt/custom/shape/arc.rb
437
+ - lib/glimmer/swt/custom/shape/cubic.rb
437
438
  - lib/glimmer/swt/custom/shape/focus.rb
438
439
  - lib/glimmer/swt/custom/shape/image.rb
439
440
  - lib/glimmer/swt/custom/shape/line.rb
440
441
  - lib/glimmer/swt/custom/shape/oval.rb
442
+ - lib/glimmer/swt/custom/shape/path.rb
443
+ - lib/glimmer/swt/custom/shape/path_segment.rb
441
444
  - lib/glimmer/swt/custom/shape/point.rb
442
445
  - lib/glimmer/swt/custom/shape/polygon.rb
443
446
  - lib/glimmer/swt/custom/shape/polyline.rb
447
+ - lib/glimmer/swt/custom/shape/quad.rb
444
448
  - lib/glimmer/swt/custom/shape/rectangle.rb
445
449
  - lib/glimmer/swt/custom/shape/text.rb
446
450
  - lib/glimmer/swt/date_time_proxy.rb
@@ -463,6 +467,7 @@ files:
463
467
  - lib/glimmer/swt/style_constantizable.rb
464
468
  - lib/glimmer/swt/styled_text_proxy.rb
465
469
  - lib/glimmer/swt/swt_proxy.rb
470
+ - lib/glimmer/swt/tab_folder_proxy.rb
466
471
  - lib/glimmer/swt/tab_item_proxy.rb
467
472
  - lib/glimmer/swt/table_column_proxy.rb
468
473
  - lib/glimmer/swt/table_proxy.rb
@@ -481,6 +486,7 @@ files:
481
486
  - samples/elaborate/login.rb
482
487
  - samples/elaborate/mandelbrot_fractal.rb
483
488
  - samples/elaborate/meta_sample.rb
489
+ - samples/elaborate/stock_ticker.rb
484
490
  - samples/elaborate/tetris.rb
485
491
  - samples/elaborate/tetris/model/block.rb
486
492
  - samples/elaborate/tetris/model/game.rb
@@ -499,6 +505,8 @@ files:
499
505
  - samples/hello/hello_button.rb
500
506
  - samples/hello/hello_canvas.rb
501
507
  - samples/hello/hello_canvas_animation.rb
508
+ - samples/hello/hello_canvas_data_binding.rb
509
+ - samples/hello/hello_canvas_path.rb
502
510
  - samples/hello/hello_canvas_transform.rb
503
511
  - samples/hello/hello_checkbox.rb
504
512
  - samples/hello/hello_checkbox_group.rb