glimmer-dsl-libui 0.2.15 → 0.2.19
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 +597 -92
- data/VERSION +1 -1
- data/bin/girb +0 -0
- data/examples/area_gallery.rb +11 -18
- data/examples/area_gallery2.rb +31 -7
- data/examples/area_gallery3.rb +14 -21
- data/examples/area_gallery4.rb +34 -10
- data/examples/basic_transform.rb +8 -2
- data/examples/color_button.rb +1 -1
- data/examples/histogram.rb +6 -13
- data/examples/meta_example.rb +3 -1
- data/examples/tetris/model/block.rb +48 -0
- data/examples/tetris/model/game.rb +306 -0
- data/examples/tetris/model/past_game.rb +39 -0
- data/examples/tetris/model/tetromino.rb +329 -0
- data/examples/tetris.rb +262 -0
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/dsl/libui/shape_expression.rb +1 -0
- data/lib/glimmer/libui/control_proxy/area_proxy.rb +25 -0
- data/lib/glimmer/libui/control_proxy/path_proxy.rb +19 -7
- data/lib/glimmer/libui/shape/figure.rb +4 -2
- data/lib/glimmer/libui/shape/polybezier.rb +45 -0
- data/lib/glimmer/libui/shape/polygon.rb +46 -0
- data/lib/glimmer/libui/shape/polyline.rb +45 -0
- data/lib/glimmer/libui/shape.rb +9 -3
- metadata +10 -2
@@ -68,12 +68,16 @@ module Glimmer
|
|
68
68
|
if args.empty?
|
69
69
|
@fill ||= {}
|
70
70
|
else
|
71
|
-
|
72
|
-
@
|
71
|
+
new_color = Glimmer::LibUI.interpret_color(args)
|
72
|
+
if new_color != @fill
|
73
|
+
@fill_observer&.unobserve(@fill) if @fill
|
74
|
+
@fill = new_color
|
75
|
+
request_auto_redraw
|
76
|
+
end
|
73
77
|
end
|
74
78
|
@fill.tap do
|
75
79
|
@fill_observer ||= Glimmer::DataBinding::Observer.proc do
|
76
|
-
|
80
|
+
request_auto_redraw
|
77
81
|
end
|
78
82
|
@fill_observer.observe(@fill)
|
79
83
|
end
|
@@ -92,12 +96,16 @@ module Glimmer
|
|
92
96
|
if args.empty?
|
93
97
|
@stroke ||= {}
|
94
98
|
else
|
95
|
-
|
96
|
-
@
|
99
|
+
new_color = Glimmer::LibUI.interpret_color(args)
|
100
|
+
if new_color != @stroke
|
101
|
+
@stroke_observer&.unobserve(@stroke) if @stroke
|
102
|
+
@stroke = Glimmer::LibUI.interpret_color(args)
|
103
|
+
request_auto_redraw
|
104
|
+
end
|
97
105
|
end
|
98
106
|
@stroke.tap do
|
99
107
|
@stroke_observer ||= Glimmer::DataBinding::Observer.proc do
|
100
|
-
|
108
|
+
request_auto_redraw
|
101
109
|
end
|
102
110
|
@stroke_observer.observe(@stroke)
|
103
111
|
end
|
@@ -137,7 +145,11 @@ module Glimmer
|
|
137
145
|
end
|
138
146
|
|
139
147
|
def redraw
|
140
|
-
@parent_proxy&.
|
148
|
+
@parent_proxy&.redraw
|
149
|
+
end
|
150
|
+
|
151
|
+
def request_auto_redraw
|
152
|
+
@parent_proxy&.request_auto_redraw
|
141
153
|
end
|
142
154
|
|
143
155
|
private
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# Copyright (c) 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/libui/shape'
|
23
|
+
|
24
|
+
module Glimmer
|
25
|
+
module LibUI
|
26
|
+
class Shape
|
27
|
+
class Polybezier < Shape
|
28
|
+
parameters :point_array
|
29
|
+
parameter_defaults []
|
30
|
+
|
31
|
+
def draw(area_draw_params)
|
32
|
+
alternating_x_y_array = point_array.to_a.compact.flatten
|
33
|
+
unless alternating_x_y_array.empty?
|
34
|
+
::LibUI.draw_path_new_figure(path_proxy.libui, alternating_x_y_array[0], alternating_x_y_array[1])
|
35
|
+
((alternating_x_y_array.size - 2) / 6).times do |n|
|
36
|
+
point_alternating_x_y_index = n * 6
|
37
|
+
::LibUI.draw_path_bezier_to(path_proxy.libui, alternating_x_y_array[point_alternating_x_y_index + 2], alternating_x_y_array[point_alternating_x_y_index + 3], alternating_x_y_array[point_alternating_x_y_index + 4], alternating_x_y_array[point_alternating_x_y_index + 5], alternating_x_y_array[point_alternating_x_y_index + 6], alternating_x_y_array[point_alternating_x_y_index + 7])
|
38
|
+
end
|
39
|
+
end
|
40
|
+
super
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# Copyright (c) 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/libui/shape'
|
23
|
+
|
24
|
+
module Glimmer
|
25
|
+
module LibUI
|
26
|
+
class Shape
|
27
|
+
class Polygon < Shape
|
28
|
+
parameters :point_array
|
29
|
+
parameter_defaults []
|
30
|
+
|
31
|
+
def draw(area_draw_params)
|
32
|
+
alternating_x_y_array = point_array.to_a.compact.flatten
|
33
|
+
unless alternating_x_y_array.empty?
|
34
|
+
::LibUI.draw_path_new_figure(path_proxy.libui, alternating_x_y_array[0], alternating_x_y_array[1])
|
35
|
+
((alternating_x_y_array.size - 2) / 2).times do |n|
|
36
|
+
point_alternating_x_y_index = n * 2
|
37
|
+
::LibUI.draw_path_line_to(path_proxy.libui, alternating_x_y_array[point_alternating_x_y_index + 2], alternating_x_y_array[point_alternating_x_y_index + 3])
|
38
|
+
end
|
39
|
+
::LibUI.draw_path_close_figure(path_proxy.libui)
|
40
|
+
end
|
41
|
+
super
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# Copyright (c) 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/libui/shape'
|
23
|
+
|
24
|
+
module Glimmer
|
25
|
+
module LibUI
|
26
|
+
class Shape
|
27
|
+
class Polyline < Shape
|
28
|
+
parameters :point_array
|
29
|
+
parameter_defaults []
|
30
|
+
|
31
|
+
def draw(area_draw_params)
|
32
|
+
alternating_x_y_array = point_array.to_a.compact.flatten
|
33
|
+
unless alternating_x_y_array.empty?
|
34
|
+
::LibUI.draw_path_new_figure(path_proxy.libui, alternating_x_y_array[0], alternating_x_y_array[1])
|
35
|
+
((alternating_x_y_array.size - 2) / 2).times do |n|
|
36
|
+
point_alternating_x_y_index = n * 2
|
37
|
+
::LibUI.draw_path_line_to(path_proxy.libui, alternating_x_y_array[point_alternating_x_y_index + 2], alternating_x_y_array[point_alternating_x_y_index + 3])
|
38
|
+
end
|
39
|
+
end
|
40
|
+
super
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/glimmer/libui/shape.rb
CHANGED
@@ -87,7 +87,11 @@ module Glimmer
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def redraw
|
90
|
-
area_proxy&.
|
90
|
+
area_proxy&.auto_redraw
|
91
|
+
end
|
92
|
+
|
93
|
+
def request_auto_redraw
|
94
|
+
area_proxy&.request_auto_redraw
|
91
95
|
end
|
92
96
|
|
93
97
|
def destroy
|
@@ -113,8 +117,10 @@ module Glimmer
|
|
113
117
|
method_name = method_name.to_s
|
114
118
|
parameter_index = self.class.parameters.index(method_name_parameter)
|
115
119
|
if method_name.start_with?('set_') || method_name.end_with?('=') || !args.empty?
|
116
|
-
@args[parameter_index]
|
117
|
-
|
120
|
+
if args.first != @args[parameter_index]
|
121
|
+
@args[parameter_index] = args.first
|
122
|
+
request_auto_redraw
|
123
|
+
end
|
118
124
|
else
|
119
125
|
@args[parameter_index]
|
120
126
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-libui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.19
|
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-
|
11
|
+
date: 2021-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -252,6 +252,11 @@ files:
|
|
252
252
|
- examples/method_based_custom_keyword.rb
|
253
253
|
- examples/midi_player.rb
|
254
254
|
- examples/simple_notepad.rb
|
255
|
+
- examples/tetris.rb
|
256
|
+
- examples/tetris/model/block.rb
|
257
|
+
- examples/tetris/model/game.rb
|
258
|
+
- examples/tetris/model/past_game.rb
|
259
|
+
- examples/tetris/model/tetromino.rb
|
255
260
|
- examples/timer.rb
|
256
261
|
- glimmer-dsl-libui.gemspec
|
257
262
|
- icons/glimmer.png
|
@@ -339,6 +344,9 @@ files:
|
|
339
344
|
- lib/glimmer/libui/shape/circle.rb
|
340
345
|
- lib/glimmer/libui/shape/figure.rb
|
341
346
|
- lib/glimmer/libui/shape/line.rb
|
347
|
+
- lib/glimmer/libui/shape/polybezier.rb
|
348
|
+
- lib/glimmer/libui/shape/polygon.rb
|
349
|
+
- lib/glimmer/libui/shape/polyline.rb
|
342
350
|
- lib/glimmer/libui/shape/rectangle.rb
|
343
351
|
- lib/glimmer/libui/shape/square.rb
|
344
352
|
- sounds/AlanWalker-Faded.mid
|