glimmer-dsl-libui 0.2.13 → 0.2.14
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 +9 -0
- data/README.md +205 -167
- data/VERSION +1 -1
- data/examples/area_gallery.rb +13 -15
- data/examples/area_gallery2.rb +22 -24
- data/examples/area_gallery3.rb +13 -15
- data/examples/area_gallery4.rb +22 -24
- data/examples/{color_the_shapes.rb → color_the_circles.rb} +37 -38
- data/examples/meta_example.rb +12 -8
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/dsl/libui/control_expression.rb +2 -0
- data/lib/glimmer/libui/control_proxy/area_proxy.rb +37 -4
- data/lib/glimmer/libui/control_proxy.rb +17 -2
- data/lib/glimmer/libui/shape/arc.rb +5 -1
- data/lib/glimmer/libui/shape/circle.rb +5 -1
- metadata +6 -6
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.14
|
data/examples/area_gallery.rb
CHANGED
@@ -41,21 +41,19 @@ window('Area Gallery', 400, 400) {
|
|
41
41
|
fill r: 202, g: 102, b: 204, a: 0.5
|
42
42
|
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
43
43
|
}
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
}
|
58
|
-
end
|
44
|
+
path { # declarative stable path
|
45
|
+
arc(400, 220, 180, 90, 90, false)
|
46
|
+
|
47
|
+
# radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
|
48
|
+
fill outer_radius: 90, x0: 0, y0: 0, x1: 500, y1: 500, stops: [{pos: 0.25, r: 102, g: 102, b: 204, a: 0.5}, {pos: 0.75, r: 204, g: 102, b: 204}]
|
49
|
+
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
50
|
+
}
|
51
|
+
path { # declarative stable path
|
52
|
+
circle(200, 200, 90)
|
53
|
+
|
54
|
+
fill r: 202, g: 102, b: 204, a: 0.5
|
55
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
56
|
+
}
|
59
57
|
text(160, 40, 100) { # x, y, width
|
60
58
|
string('Area Gallery') {
|
61
59
|
font family: 'Times', size: 14
|
data/examples/area_gallery2.rb
CHANGED
@@ -95,32 +95,30 @@ window('Area Gallery', 400, 400) {
|
|
95
95
|
fill r: 202, g: 102, b: 204, a: 0.5
|
96
96
|
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
97
97
|
}
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
is_negative false
|
107
|
-
}
|
108
|
-
|
109
|
-
# radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
|
110
|
-
fill outer_radius: 90, x0: 0, y0: 0, x1: 500, y1: 500, stops: [{pos: 0.25, r: 102, g: 102, b: 204, a: 0.5}, {pos: 0.75, r: 204, g: 102, b: 204}]
|
111
|
-
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
98
|
+
path { # declarative stable path
|
99
|
+
arc {
|
100
|
+
x_center 400
|
101
|
+
y_center 220
|
102
|
+
radius 180
|
103
|
+
start_angle 90
|
104
|
+
sweep 90
|
105
|
+
is_negative false
|
112
106
|
}
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
107
|
+
|
108
|
+
# radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
|
109
|
+
fill outer_radius: 90, x0: 0, y0: 0, x1: 500, y1: 500, stops: [{pos: 0.25, r: 102, g: 102, b: 204, a: 0.5}, {pos: 0.75, r: 204, g: 102, b: 204}]
|
110
|
+
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
111
|
+
}
|
112
|
+
path { # declarative stable path
|
113
|
+
circle {
|
114
|
+
x_center 200
|
115
|
+
y_center 200
|
116
|
+
radius 90
|
122
117
|
}
|
123
|
-
|
118
|
+
|
119
|
+
fill r: 202, g: 102, b: 204, a: 0.5
|
120
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
121
|
+
}
|
124
122
|
text {
|
125
123
|
x 160
|
126
124
|
y 40
|
data/examples/area_gallery3.rb
CHANGED
@@ -42,21 +42,19 @@ window('Area Gallery', 400, 400) {
|
|
42
42
|
fill r: 202, g: 102, b: 204, a: 0.5
|
43
43
|
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
44
44
|
}
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
}
|
59
|
-
end
|
45
|
+
path { # a dynamic path is added semi-declaratively inside on_draw block
|
46
|
+
arc(400, 220, 180, 90, 90, false)
|
47
|
+
|
48
|
+
# radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
|
49
|
+
fill outer_radius: 90, x0: 0, y0: 0, x1: 500, y1: 500, stops: [{pos: 0.25, r: 102, g: 102, b: 204, a: 0.5}, {pos: 0.75, r: 204, g: 102, b: 204}]
|
50
|
+
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
51
|
+
}
|
52
|
+
path { # a dynamic path is added semi-declaratively inside on_draw block
|
53
|
+
circle(200, 200, 90)
|
54
|
+
|
55
|
+
fill r: 202, g: 102, b: 204, a: 0.5
|
56
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
57
|
+
}
|
60
58
|
text(160, 40, 100) { # x, y, width
|
61
59
|
string('Area Gallery') {
|
62
60
|
font family: 'Times', size: 14
|
data/examples/area_gallery4.rb
CHANGED
@@ -96,32 +96,30 @@ window('Area Gallery', 400, 400) {
|
|
96
96
|
fill r: 202, g: 102, b: 204, a: 0.5
|
97
97
|
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
98
98
|
}
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
is_negative false
|
108
|
-
}
|
109
|
-
|
110
|
-
# radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
|
111
|
-
fill outer_radius: 90, x0: 0, y0: 0, x1: 500, y1: 500, stops: [{pos: 0.25, r: 102, g: 102, b: 204, a: 0.5}, {pos: 0.75, r: 204, g: 102, b: 204}]
|
112
|
-
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
99
|
+
path { # a dynamic path is added semi-declaratively inside on_draw block
|
100
|
+
arc {
|
101
|
+
x_center 400
|
102
|
+
y_center 220
|
103
|
+
radius 180
|
104
|
+
start_angle 90
|
105
|
+
sweep 90
|
106
|
+
is_negative false
|
113
107
|
}
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
108
|
+
|
109
|
+
# radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
|
110
|
+
fill outer_radius: 90, x0: 0, y0: 0, x1: 500, y1: 500, stops: [{pos: 0.25, r: 102, g: 102, b: 204, a: 0.5}, {pos: 0.75, r: 204, g: 102, b: 204}]
|
111
|
+
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
112
|
+
}
|
113
|
+
path { # a dynamic path is added semi-declaratively inside on_draw block
|
114
|
+
circle {
|
115
|
+
x_center 200
|
116
|
+
y_center 200
|
117
|
+
radius 90
|
123
118
|
}
|
124
|
-
|
119
|
+
|
120
|
+
fill r: 202, g: 102, b: 204, a: 0.5
|
121
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
122
|
+
}
|
125
123
|
text {
|
126
124
|
x 160
|
127
125
|
y 40
|
@@ -1,29 +1,28 @@
|
|
1
1
|
require 'glimmer-dsl-libui'
|
2
2
|
|
3
|
-
class
|
3
|
+
class ColorTheCircles
|
4
4
|
include Glimmer
|
5
5
|
|
6
6
|
WINDOW_WIDTH = 800
|
7
7
|
WINDOW_HEIGHT = 600
|
8
8
|
SHAPE_MIN_SIZE = 15
|
9
|
-
SHAPE_MAX_SIZE =
|
9
|
+
SHAPE_MAX_SIZE = 75
|
10
10
|
MARGIN_WIDTH = 55
|
11
11
|
MARGIN_HEIGHT = 155
|
12
12
|
TIME_MAX_EASY = 4
|
13
13
|
TIME_MAX_MEDIUM = 3
|
14
14
|
TIME_MAX_HARD = 2
|
15
15
|
TIME_MAX_INSANE = 1
|
16
|
-
SHAPES = ['square'] + (OS.windows? ? [] : ['circle'])
|
17
16
|
|
18
17
|
attr_accessor :score
|
19
18
|
|
20
19
|
def initialize
|
21
|
-
@
|
20
|
+
@circles_data = []
|
22
21
|
@score = 0
|
23
22
|
@time_max = TIME_MAX_HARD
|
24
23
|
@game_over = false
|
25
24
|
register_observers
|
26
|
-
|
25
|
+
setup_circle_factory
|
27
26
|
end
|
28
27
|
|
29
28
|
def register_observers
|
@@ -42,14 +41,14 @@ class ColorTheShapes
|
|
42
41
|
observer.observe(self, :score) # automatically enhances self to become Glimmer::DataBinding::ObservableModel and notify observer on score attribute changes
|
43
42
|
end
|
44
43
|
|
45
|
-
def
|
44
|
+
def setup_circle_factory
|
46
45
|
consumer = Proc.new do
|
47
46
|
unless @game_over
|
48
|
-
if @
|
49
|
-
# start with 3
|
50
|
-
|
47
|
+
if @circles_data.empty?
|
48
|
+
# start with 3 circles to make more challenging
|
49
|
+
add_circle until @circles_data.size > 3
|
51
50
|
else
|
52
|
-
|
51
|
+
add_circle
|
53
52
|
end
|
54
53
|
end
|
55
54
|
delay = rand * @time_max
|
@@ -58,13 +57,13 @@ class ColorTheShapes
|
|
58
57
|
Glimmer::LibUI.queue_main(&consumer)
|
59
58
|
end
|
60
59
|
|
61
|
-
def
|
62
|
-
|
63
|
-
|
64
|
-
|
60
|
+
def add_circle
|
61
|
+
circle_x = rand * (WINDOW_WIDTH - MARGIN_WIDTH - SHAPE_MAX_SIZE) + SHAPE_MAX_SIZE
|
62
|
+
circle_y = rand * (WINDOW_HEIGHT - MARGIN_HEIGHT - SHAPE_MAX_SIZE) + SHAPE_MAX_SIZE
|
63
|
+
circle_size = rand * (SHAPE_MAX_SIZE - SHAPE_MIN_SIZE) + SHAPE_MIN_SIZE
|
65
64
|
stroke_color = Glimmer::LibUI.x11_colors.sample
|
66
|
-
@
|
67
|
-
args: [
|
65
|
+
@circles_data << {
|
66
|
+
args: [circle_x, circle_y, circle_size],
|
68
67
|
fill: nil,
|
69
68
|
stroke: stroke_color
|
70
69
|
}
|
@@ -74,27 +73,27 @@ class ColorTheShapes
|
|
74
73
|
|
75
74
|
def restart_game
|
76
75
|
@score = 0 # update variable directly to avoid notifying observers
|
77
|
-
@
|
76
|
+
@circles_data.clear
|
78
77
|
@game_over = false
|
79
78
|
end
|
80
79
|
|
81
|
-
def
|
82
|
-
|
83
|
-
|
80
|
+
def color_circle(x, y)
|
81
|
+
clicked_circle_data = @circles_data.find do |circle_data|
|
82
|
+
circle_data[:fill].nil? && circle_data[:circle]&.include?(x, y)
|
84
83
|
end
|
85
|
-
if
|
86
|
-
|
87
|
-
|
84
|
+
if clicked_circle_data
|
85
|
+
clicked_circle_data[:fill] = clicked_circle_data[:stroke]
|
86
|
+
push_colored_circle_behind_uncolored_circles(clicked_circle_data)
|
88
87
|
@area.queue_redraw_all
|
89
88
|
self.score += 1 # notifies score observers automatically of change
|
90
89
|
end
|
91
90
|
end
|
92
91
|
|
93
|
-
def
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
@
|
92
|
+
def push_colored_circle_behind_uncolored_circles(colored_circle_data)
|
93
|
+
removed_colored_circle_data = @circles_data.delete(colored_circle_data)
|
94
|
+
last_colored_circle_data = @circles_data.select {|cd| cd[:fill]}.last
|
95
|
+
last_colored_circle_data_index = @circles_data.index(last_colored_circle_data) || -1
|
96
|
+
@circles_data.insert(last_colored_circle_data_index + 1, removed_colored_circle_data)
|
98
97
|
end
|
99
98
|
|
100
99
|
def launch
|
@@ -139,12 +138,12 @@ class ColorTheShapes
|
|
139
138
|
menu('Help') {
|
140
139
|
menu_item('Instructions') {
|
141
140
|
on_clicked do
|
142
|
-
msg_box('Instructions', "Score goes down as
|
141
|
+
msg_box('Instructions', "Score goes down as circles are added.\nIf it reaches -20, you lose!\n\nClick circles to color and score!\nOnce score reaches 0, you win!\n\nBeware of concealed light-colored circles!\nThey are revealed once darker circles intersect them.\n\nThere are four levels of difficulty.\nChange via difficulty menu if the game gets too tough.")
|
143
142
|
end
|
144
143
|
}
|
145
144
|
}
|
146
145
|
|
147
|
-
window('Color The
|
146
|
+
window('Color The Circles', WINDOW_WIDTH, WINDOW_HEIGHT) {
|
148
147
|
margined true
|
149
148
|
|
150
149
|
grid {
|
@@ -158,13 +157,13 @@ class ColorTheShapes
|
|
158
157
|
end
|
159
158
|
}
|
160
159
|
|
161
|
-
label('Score goes down as
|
160
|
+
label('Score goes down as circles are added. If it reaches -20, you lose!') {
|
162
161
|
left 0
|
163
162
|
top 1
|
164
163
|
halign :center
|
165
164
|
}
|
166
165
|
|
167
|
-
label('Click
|
166
|
+
label('Click circles to color and score! Once score reaches 0, you win!') {
|
168
167
|
left 0
|
169
168
|
top 2
|
170
169
|
halign :center
|
@@ -199,18 +198,18 @@ class ColorTheShapes
|
|
199
198
|
fill :white
|
200
199
|
}
|
201
200
|
|
202
|
-
@
|
201
|
+
@circles_data.each do |circle_data|
|
203
202
|
path {
|
204
|
-
|
203
|
+
circle_data[:circle] = circle(*circle_data[:args])
|
205
204
|
|
206
|
-
fill
|
207
|
-
stroke
|
205
|
+
fill circle_data[:fill]
|
206
|
+
stroke circle_data[:stroke]
|
208
207
|
}
|
209
208
|
end
|
210
209
|
end
|
211
210
|
|
212
211
|
on_mouse_down do |area_mouse_event|
|
213
|
-
|
212
|
+
color_circle(area_mouse_event[:x], area_mouse_event[:y])
|
214
213
|
end
|
215
214
|
}
|
216
215
|
}
|
@@ -218,4 +217,4 @@ class ColorTheShapes
|
|
218
217
|
end
|
219
218
|
end
|
220
219
|
|
221
|
-
|
220
|
+
ColorTheCircles.new.launch
|
data/examples/meta_example.rb
CHANGED
@@ -42,16 +42,20 @@ class MetaExample
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def run_example(example)
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
45
|
+
Thread.new do
|
46
|
+
command = "ruby -r #{glimmer_dsl_libui_file} #{example} 2>&1"
|
47
|
+
result = ''
|
48
|
+
IO.popen(command) do |f|
|
49
|
+
sleep(0.01) # yield to main thread
|
50
|
+
f.each_line do |line|
|
51
|
+
result << line
|
52
|
+
puts line
|
53
|
+
$stdout.flush # for Windows
|
54
|
+
sleep(0.01) # yield to main thread
|
55
|
+
end
|
52
56
|
end
|
57
|
+
Glimmer::LibUI.queue_main { msg_box('Error Running Example', result) } if result.downcase.include?('error')
|
53
58
|
end
|
54
|
-
msg_box('Error Running Example', result) if result.downcase.include?('error')
|
55
59
|
end
|
56
60
|
|
57
61
|
def launch
|
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
@@ -33,6 +33,8 @@ module Glimmer
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def interpret(parent, keyword, *args, &block)
|
36
|
+
@@inverted_keyword_aliases = Glimmer::LibUI::ControlProxy::KEYWORD_ALIASES.invert unless defined?(@@inverted_keyword_aliases)
|
37
|
+
keyword = @@inverted_keyword_aliases[keyword] || keyword
|
36
38
|
Glimmer::LibUI::ControlProxy.create(keyword, parent, args, &block)
|
37
39
|
end
|
38
40
|
|
@@ -37,6 +37,7 @@ module Glimmer
|
|
37
37
|
end
|
38
38
|
|
39
39
|
LISTENERS = ['on_draw', 'on_mouse_event', 'on_mouse_move', 'on_mouse_down', 'on_mouse_up', 'on_mouse_drag_start', 'on_mouse_drag', 'on_mouse_drop', 'on_mouse_crossed', 'on_mouse_enter', 'on_mouse_exit', 'on_drag_broken', 'on_key_event', 'on_key_down', 'on_key_up']
|
40
|
+
|
40
41
|
LISTENER_ALIASES = {
|
41
42
|
on_drawn: 'on_draw',
|
42
43
|
on_mouse_moved: 'on_mouse_move',
|
@@ -49,6 +50,30 @@ module Glimmer
|
|
49
50
|
on_drag_break: 'on_drag_broken',
|
50
51
|
}
|
51
52
|
|
53
|
+
SHIFTED_KEY_CODE_CHARS = {
|
54
|
+
'`' => '~',
|
55
|
+
'1' => '!',
|
56
|
+
'2' => '@',
|
57
|
+
'3' => '#',
|
58
|
+
'4' => '$',
|
59
|
+
'5' => '%',
|
60
|
+
'6' => '^',
|
61
|
+
'7' => '&',
|
62
|
+
'8' => '*',
|
63
|
+
'9' => '(',
|
64
|
+
'10' => ')',
|
65
|
+
'-' => '_',
|
66
|
+
'=' => '+',
|
67
|
+
',' => '<',
|
68
|
+
'.' => '>',
|
69
|
+
'/' => '?',
|
70
|
+
';' => ':',
|
71
|
+
"'" => '"',
|
72
|
+
'[' => '{',
|
73
|
+
']' => '}',
|
74
|
+
"\\" => '|',
|
75
|
+
}
|
76
|
+
|
52
77
|
include Glimmer::FiddleConsumer
|
53
78
|
include Parent
|
54
79
|
prepend Transformable
|
@@ -164,19 +189,27 @@ module Glimmer
|
|
164
189
|
end
|
165
190
|
|
166
191
|
def area_key_event_hash(area_key_event)
|
192
|
+
modifiers = modifiers_to_symbols(area_key_event.Modifiers)
|
167
193
|
{
|
168
|
-
key: key_to_char(area_key_event.Key),
|
194
|
+
key: key_to_char(area_key_event.Key, modifiers),
|
169
195
|
key_value: area_key_event.Key,
|
170
196
|
ext_key: ext_key_to_symbol(area_key_event.ExtKey),
|
171
197
|
ext_key_value: area_key_event.ExtKey,
|
172
198
|
modifier: modifiers_to_symbols(area_key_event.Modifier).first,
|
173
|
-
modifiers:
|
199
|
+
modifiers: modifiers,
|
174
200
|
up: Glimmer::LibUI.integer_to_boolean(area_key_event.Up),
|
175
201
|
}
|
176
202
|
end
|
177
203
|
|
178
|
-
def key_to_char(key)
|
179
|
-
|
204
|
+
def key_to_char(key, modifiers = [])
|
205
|
+
if key > 0
|
206
|
+
char = key.chr
|
207
|
+
if modifiers == [:shift]
|
208
|
+
SHIFTED_KEY_CODE_CHARS[char]
|
209
|
+
else
|
210
|
+
char
|
211
|
+
end
|
212
|
+
end
|
180
213
|
end
|
181
214
|
|
182
215
|
def ext_key_to_symbol(ext_key_value)
|
@@ -37,7 +37,6 @@ module Glimmer
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def widget_proxy_class(keyword)
|
40
|
-
class_name = constant_symbol(keyword)
|
41
40
|
descendant_keyword_constant_map[keyword] || ControlProxy
|
42
41
|
end
|
43
42
|
|
@@ -72,7 +71,7 @@ module Glimmer
|
|
72
71
|
end
|
73
72
|
|
74
73
|
def descendant_keyword_constant_map
|
75
|
-
@descendant_keyword_constant_map ||= map_descendant_keyword_constants_for(self)
|
74
|
+
@descendant_keyword_constant_map ||= add_aliases_to_keyword_constant_map(map_descendant_keyword_constants_for(self))
|
76
75
|
end
|
77
76
|
|
78
77
|
def reset_descendant_keyword_constant_map
|
@@ -91,8 +90,22 @@ module Glimmer
|
|
91
90
|
end
|
92
91
|
accumulator
|
93
92
|
end
|
93
|
+
|
94
|
+
private
|
95
|
+
|
96
|
+
def add_aliases_to_keyword_constant_map(keyword_constant_map)
|
97
|
+
KEYWORD_ALIASES.each do |keyword, alias_keyword|
|
98
|
+
keyword_constant_map[alias_keyword] = keyword_constant_map[keyword]
|
99
|
+
end
|
100
|
+
keyword_constant_map
|
101
|
+
end
|
94
102
|
end
|
95
103
|
|
104
|
+
KEYWORD_ALIASES = {
|
105
|
+
'msg_box' => 'message_box',
|
106
|
+
'msg_box_error' => 'message_box_error',
|
107
|
+
}
|
108
|
+
|
96
109
|
BOOLEAN_PROPERTIES = %w[
|
97
110
|
padded
|
98
111
|
checked
|
@@ -223,6 +236,7 @@ module Glimmer
|
|
223
236
|
elsif ::LibUI.respond_to?("#{libui_api_keyword}_set_#{method_name.to_s.sub(/=$/, '')}") && !args.empty?
|
224
237
|
property = method_name.to_s.sub(/=$/, '')
|
225
238
|
args[0] = Glimmer::LibUI.boolean_to_integer(args.first) if BOOLEAN_PROPERTIES.include?(property) && (args.first.is_a?(TrueClass) || args.first.is_a?(FalseClass))
|
239
|
+
args[0] = '' if STRING_PROPERTIES.include?(property) && args.first == nil
|
226
240
|
if property.to_s == 'checked'
|
227
241
|
current_value = Glimmer::LibUI.integer_to_boolean(::LibUI.send("#{libui_api_keyword}_checked", @libui))
|
228
242
|
new_value = Glimmer::LibUI.integer_to_boolean(args[0])
|
@@ -239,6 +253,7 @@ module Glimmer
|
|
239
253
|
elsif ::LibUI.respond_to?("control_set_#{method_name.to_s.sub(/=$/, '')}")
|
240
254
|
property = method_name.to_s.sub(/=$/, '')
|
241
255
|
args[0] = Glimmer::LibUI.boolean_to_integer(args.first) if BOOLEAN_PROPERTIES.include?(property) && (args.first.is_a?(TrueClass) || args.first.is_a?(FalseClass))
|
256
|
+
args[0] = '' if STRING_PROPERTIES.include?(property) && args.first == nil
|
242
257
|
::LibUI.send("control_set_#{method_name.to_s.sub(/=$/, '')}", @libui, *args)
|
243
258
|
elsif ::LibUI.respond_to?("control_#{method_name}") && !args.empty?
|
244
259
|
::LibUI.send("control_#{method_name}", @libui, *args)
|
@@ -36,7 +36,11 @@ module Glimmer
|
|
36
36
|
if parent.is_a?(Figure) && parent.x.nil? && parent.y.nil?
|
37
37
|
::LibUI.draw_path_new_figure_with_arc(path_proxy.libui, *arc_args)
|
38
38
|
else
|
39
|
-
|
39
|
+
if OS.windows? && parent.children.find {|child| child.is_a?(Arc)} == self
|
40
|
+
::LibUI.draw_path_new_figure_with_arc(path_proxy.libui, *arc_args)
|
41
|
+
else
|
42
|
+
::LibUI.draw_path_arc_to(path_proxy.libui, *arc_args)
|
43
|
+
end
|
40
44
|
end
|
41
45
|
super
|
42
46
|
end
|
@@ -36,7 +36,11 @@ module Glimmer
|
|
36
36
|
if parent.is_a?(Figure) && parent.x.nil? && parent.y.nil?
|
37
37
|
::LibUI.draw_path_new_figure_with_arc(path_proxy.libui, *arc_args)
|
38
38
|
else
|
39
|
-
|
39
|
+
if OS.windows? && parent.children.find {|child| child.is_a?(Circle)} == self
|
40
|
+
::LibUI.draw_path_new_figure_with_arc(path_proxy.libui, *arc_args)
|
41
|
+
else
|
42
|
+
::LibUI.draw_path_arc_to(path_proxy.libui, *arc_args)
|
43
|
+
end
|
40
44
|
end
|
41
45
|
super
|
42
46
|
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.14
|
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-10-
|
11
|
+
date: 2021-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -190,12 +190,12 @@ dependencies:
|
|
190
190
|
- - "~>"
|
191
191
|
- !ruby/object:Gem::Version
|
192
192
|
version: 1.4.0
|
193
|
-
description: Glimmer DSL for LibUI
|
194
|
-
Library
|
193
|
+
description: Glimmer DSL for LibUI (Prerequisite-Free Ruby Desktop Development GUI
|
194
|
+
Library) - No need to pre-install any prerequisites. Just install the gem and have
|
195
195
|
platform-independent native GUI that just works! Glimmer DSL for LibUI aims to provide
|
196
196
|
declarative DSL syntax that visually maps to GUI control hierarchy, convention over
|
197
197
|
configuration via smart defaults, automation of low-level details, requiring the
|
198
|
-
least amount of syntax possible to build GUI, and custom
|
198
|
+
least amount of syntax possible to build GUI, and custom keyword support.
|
199
199
|
email: andy.am@gmail.com
|
200
200
|
executables:
|
201
201
|
- girb
|
@@ -233,7 +233,7 @@ files:
|
|
233
233
|
- examples/basic_window.rb
|
234
234
|
- examples/basic_window2.rb
|
235
235
|
- examples/color_button.rb
|
236
|
-
- examples/
|
236
|
+
- examples/color_the_circles.rb
|
237
237
|
- examples/control_gallery.rb
|
238
238
|
- examples/custom_draw_text.rb
|
239
239
|
- examples/custom_draw_text2.rb
|