glimmer-dsl-libui 0.2.11 → 0.2.15
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 +40 -0
- data/README.md +192 -110
- data/VERSION +1 -1
- data/bin/girb +0 -0
- data/bin/girb_runner.rb +1 -1
- data/examples/area_gallery.rb +1 -3
- data/examples/area_gallery3.rb +1 -3
- data/examples/basic_draw_text2.rb +0 -1
- data/examples/basic_table_button.rb +1 -1
- data/examples/basic_table_checkbox.rb +1 -1
- data/examples/basic_table_image.rb +1 -0
- data/examples/basic_table_image_text.rb +1 -0
- data/examples/color_the_circles.rb +24 -22
- data/examples/control_gallery.rb +6 -0
- data/examples/meta_example.rb +12 -7
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/dsl/libui/control_expression.rb +2 -0
- data/lib/glimmer/dsl/libui/string_expression.rb +9 -2
- data/lib/glimmer/libui/attributed_string.rb +32 -12
- data/lib/glimmer/libui/control_proxy/area_proxy.rb +37 -4
- data/lib/glimmer/libui/control_proxy/table_proxy.rb +30 -10
- 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
- data/lib/glimmer/libui.rb +2 -2
- metadata +13 -10
data/examples/area_gallery3.rb
CHANGED
@@ -5,8 +5,8 @@ class ColorTheCircles
|
|
5
5
|
|
6
6
|
WINDOW_WIDTH = 800
|
7
7
|
WINDOW_HEIGHT = 600
|
8
|
-
|
9
|
-
|
8
|
+
SHAPE_MIN_SIZE = 15
|
9
|
+
SHAPE_MAX_SIZE = 75
|
10
10
|
MARGIN_WIDTH = 55
|
11
11
|
MARGIN_HEIGHT = 155
|
12
12
|
TIME_MAX_EASY = 4
|
@@ -27,15 +27,17 @@ class ColorTheCircles
|
|
27
27
|
|
28
28
|
def register_observers
|
29
29
|
observer = Glimmer::DataBinding::Observer.proc do |new_score|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
30
|
+
Glimmer::LibUI.queue_main do
|
31
|
+
@score_label.text = new_score.to_s
|
32
|
+
if new_score == -20
|
33
|
+
@game_over = true
|
34
|
+
msg_box('You Lost!', 'Sorry! Your score reached -20')
|
35
|
+
restart_game
|
36
|
+
elsif new_score == 0
|
37
|
+
@game_over = true
|
38
|
+
msg_box('You Won!', 'Congratulations! Your score reached 0')
|
39
|
+
restart_game
|
40
|
+
end
|
39
41
|
end
|
40
42
|
end
|
41
43
|
observer.observe(self, :score) # automatically enhances self to become Glimmer::DataBinding::ObservableModel and notify observer on score attribute changes
|
@@ -58,12 +60,12 @@ class ColorTheCircles
|
|
58
60
|
end
|
59
61
|
|
60
62
|
def add_circle
|
61
|
-
|
62
|
-
|
63
|
-
|
63
|
+
circle_x = rand * (WINDOW_WIDTH - MARGIN_WIDTH - SHAPE_MAX_SIZE) + SHAPE_MAX_SIZE
|
64
|
+
circle_y = rand * (WINDOW_HEIGHT - MARGIN_HEIGHT - SHAPE_MAX_SIZE) + SHAPE_MAX_SIZE
|
65
|
+
circle_size = rand * (SHAPE_MAX_SIZE - SHAPE_MIN_SIZE) + SHAPE_MIN_SIZE
|
64
66
|
stroke_color = Glimmer::LibUI.x11_colors.sample
|
65
67
|
@circles_data << {
|
66
|
-
args: [
|
68
|
+
args: [circle_x, circle_y, circle_size],
|
67
69
|
fill: nil,
|
68
70
|
stroke: stroke_color
|
69
71
|
}
|
@@ -79,7 +81,7 @@ class ColorTheCircles
|
|
79
81
|
|
80
82
|
def color_circle(x, y)
|
81
83
|
clicked_circle_data = @circles_data.find do |circle_data|
|
82
|
-
circle_data[:fill].nil? && circle_data[:circle]
|
84
|
+
circle_data[:fill].nil? && circle_data[:circle]&.include?(x, y)
|
83
85
|
end
|
84
86
|
if clicked_circle_data
|
85
87
|
clicked_circle_data[:fill] = clicked_circle_data[:stroke]
|
@@ -95,7 +97,7 @@ class ColorTheCircles
|
|
95
97
|
last_colored_circle_data_index = @circles_data.index(last_colored_circle_data) || -1
|
96
98
|
@circles_data.insert(last_colored_circle_data_index + 1, removed_colored_circle_data)
|
97
99
|
end
|
98
|
-
|
100
|
+
|
99
101
|
def launch
|
100
102
|
menu('Actions') {
|
101
103
|
menu_item('Restart') {
|
@@ -190,24 +192,24 @@ class ColorTheCircles
|
|
190
192
|
vexpand true
|
191
193
|
halign :fill
|
192
194
|
valign :fill
|
193
|
-
|
195
|
+
|
194
196
|
on_draw do |area_draw_params|
|
195
197
|
path {
|
196
198
|
rectangle(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT)
|
197
|
-
|
199
|
+
|
198
200
|
fill :white
|
199
201
|
}
|
200
|
-
|
202
|
+
|
201
203
|
@circles_data.each do |circle_data|
|
202
204
|
path {
|
203
205
|
circle_data[:circle] = circle(*circle_data[:args])
|
204
|
-
|
206
|
+
|
205
207
|
fill circle_data[:fill]
|
206
208
|
stroke circle_data[:stroke]
|
207
209
|
}
|
208
210
|
end
|
209
211
|
end
|
210
|
-
|
212
|
+
|
211
213
|
on_mouse_down do |area_mouse_event|
|
212
214
|
color_circle(area_mouse_event[:x], area_mouse_event[:y])
|
213
215
|
end
|
data/examples/control_gallery.rb
CHANGED
@@ -9,6 +9,7 @@ menu('File') {
|
|
9
9
|
on_clicked do
|
10
10
|
file = open_file
|
11
11
|
puts file unless file.nil?
|
12
|
+
$stdout.flush # for Windows
|
12
13
|
end
|
13
14
|
}
|
14
15
|
|
@@ -16,6 +17,7 @@ menu('File') {
|
|
16
17
|
on_clicked do
|
17
18
|
file = save_file
|
18
19
|
puts file unless file.nil?
|
20
|
+
$stdout.flush # for Windows
|
19
21
|
end
|
20
22
|
}
|
21
23
|
|
@@ -98,6 +100,7 @@ MAIN_WINDOW = window('Control Gallery', 600, 500) {
|
|
98
100
|
|
99
101
|
on_changed do |s|
|
100
102
|
puts "New Spinbox value: #{s.value}"
|
103
|
+
$stdout.flush # for Windows
|
101
104
|
end
|
102
105
|
}
|
103
106
|
|
@@ -107,6 +110,7 @@ MAIN_WINDOW = window('Control Gallery', 600, 500) {
|
|
107
110
|
on_changed do |s|
|
108
111
|
v = s.value
|
109
112
|
puts "New Slider value: #{v}"
|
113
|
+
$stdout.flush # for Windows
|
110
114
|
@progress_bar.value = v
|
111
115
|
end
|
112
116
|
}
|
@@ -125,6 +129,7 @@ MAIN_WINDOW = window('Control Gallery', 600, 500) {
|
|
125
129
|
|
126
130
|
on_selected do |c|
|
127
131
|
puts "New combobox selection: #{c.selected}"
|
132
|
+
$stdout.flush # for Windows
|
128
133
|
end
|
129
134
|
}
|
130
135
|
|
@@ -147,6 +152,7 @@ MAIN_WINDOW = window('Control Gallery', 600, 500) {
|
|
147
152
|
|
148
153
|
on_changed do |e|
|
149
154
|
puts "Current textbox data: '#{e.text}'"
|
155
|
+
$stdout.flush # for Windows
|
150
156
|
end
|
151
157
|
}
|
152
158
|
}
|
data/examples/meta_example.rb
CHANGED
@@ -42,15 +42,20 @@ class MetaExample
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def run_example(example)
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
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.0001) # yield to main thread
|
50
|
+
f.each_line do |line|
|
51
|
+
result << line
|
52
|
+
puts line
|
53
|
+
$stdout.flush # for Windows
|
54
|
+
sleep(0.0001) # yield to main thread
|
55
|
+
end
|
51
56
|
end
|
57
|
+
Glimmer::LibUI.queue_main { msg_box('Error Running Example', result) } if result.downcase.include?('error')
|
52
58
|
end
|
53
|
-
msg_box('Error Running Example', result) if result.downcase.include?('error')
|
54
59
|
end
|
55
60
|
|
56
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
|
|
@@ -32,11 +32,18 @@ module Glimmer
|
|
32
32
|
|
33
33
|
def can_interpret?(parent, keyword, *args, &block)
|
34
34
|
super and
|
35
|
-
|
35
|
+
(
|
36
|
+
parent.is_a?(Glimmer::LibUI::ControlProxy::TextProxy) or
|
37
|
+
parent.is_a?(Glimmer::LibUI::AttributedString)
|
38
|
+
)
|
36
39
|
end
|
37
40
|
|
38
41
|
def interpret(parent, keyword, *args, &block)
|
39
|
-
Glimmer::LibUI::
|
42
|
+
if parent.is_a?(Glimmer::LibUI::ControlProxy::TextProxy)
|
43
|
+
Glimmer::LibUI::AttributedString.new(keyword, parent, args, &block)
|
44
|
+
else
|
45
|
+
parent.string = args.join
|
46
|
+
end
|
40
47
|
end
|
41
48
|
|
42
49
|
def add_content(parent, keyword, *args, &block)
|
@@ -27,7 +27,6 @@ require 'glimmer/libui/control_proxy/transformable'
|
|
27
27
|
module Glimmer
|
28
28
|
module LibUI
|
29
29
|
class AttributedString
|
30
|
-
attr_accessor :string
|
31
30
|
attr_reader :block, :keyword, :parent_proxy, :args
|
32
31
|
|
33
32
|
def initialize(keyword, parent_proxy, args, &block)
|
@@ -39,6 +38,17 @@ module Glimmer
|
|
39
38
|
post_add_content if @block.nil?
|
40
39
|
end
|
41
40
|
|
41
|
+
def string(value = nil)
|
42
|
+
if value.nil?
|
43
|
+
@string
|
44
|
+
else
|
45
|
+
@string = value
|
46
|
+
redraw
|
47
|
+
end
|
48
|
+
end
|
49
|
+
alias string= string
|
50
|
+
alias set_string string
|
51
|
+
|
42
52
|
def font(value = nil)
|
43
53
|
if value.nil?
|
44
54
|
@font
|
@@ -106,7 +116,7 @@ module Glimmer
|
|
106
116
|
alias set_open_type_features open_type_features
|
107
117
|
|
108
118
|
def post_add_content
|
109
|
-
block_result = block&.call
|
119
|
+
block_result = @block&.call
|
110
120
|
@string = block_result if block_result.is_a?(String)
|
111
121
|
@parent_proxy&.post_initialize_child(self)
|
112
122
|
end
|
@@ -141,16 +151,26 @@ module Glimmer
|
|
141
151
|
end
|
142
152
|
end
|
143
153
|
unless font.nil?
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
+
if font[:family]
|
155
|
+
family_attribute = ::LibUI.new_family_attribute(font[:family])
|
156
|
+
::LibUI.attributed_string_set_attribute(@parent_proxy.attributed_string, family_attribute, @start, @start + @string.size)
|
157
|
+
end
|
158
|
+
if font[:size]
|
159
|
+
size_attribute = ::LibUI.new_size_attribute(font[:size])
|
160
|
+
::LibUI.attributed_string_set_attribute(@parent_proxy.attributed_string, size_attribute, @start, @start + @string.size)
|
161
|
+
end
|
162
|
+
if font[:weight]
|
163
|
+
weight_attribute = ::LibUI.new_weight_attribute(Glimmer::LibUI.enum_symbol_to_value(:text_weight, font[:weight]))
|
164
|
+
::LibUI.attributed_string_set_attribute(@parent_proxy.attributed_string, weight_attribute, @start, @start + @string.size)
|
165
|
+
end
|
166
|
+
if font[:italic]
|
167
|
+
italic_attribute = ::LibUI.new_italic_attribute(Glimmer::LibUI.enum_symbol_to_value(:text_italic, font[:italic]))
|
168
|
+
::LibUI.attributed_string_set_attribute(@parent_proxy.attributed_string, italic_attribute, @start, @start + @string.size)
|
169
|
+
end
|
170
|
+
if font[:stretch]
|
171
|
+
stretch_attribute = ::LibUI.new_stretch_attribute(Glimmer::LibUI.enum_symbol_to_value(:text_stretch, font[:stretch]))
|
172
|
+
::LibUI.attributed_string_set_attribute(@parent_proxy.attributed_string, stretch_attribute, @start, @start + @string.size)
|
173
|
+
end
|
154
174
|
end
|
155
175
|
unless open_type_features.nil?
|
156
176
|
open_type_features_attribute = ::LibUI.new_features_attribute(open_type_features.libui)
|
@@ -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)
|
@@ -84,7 +84,7 @@ module Glimmer
|
|
84
84
|
@cell_rows = rows
|
85
85
|
@cell_rows.tap do
|
86
86
|
@last_cell_rows = array_deep_clone(@cell_rows)
|
87
|
-
Glimmer::DataBinding::Observer.proc do
|
87
|
+
Glimmer::DataBinding::Observer.proc do |new_cell_rows|
|
88
88
|
if @cell_rows.size < @last_cell_rows.size && @last_cell_rows.include_all?(*@cell_rows)
|
89
89
|
@last_cell_rows.array_diff_indexes(@cell_rows).reverse.each do |row|
|
90
90
|
::LibUI.table_model_row_deleted(model, row)
|
@@ -103,8 +103,9 @@ module Glimmer
|
|
103
103
|
end
|
104
104
|
end
|
105
105
|
end
|
106
|
+
@last_last_cell_rows = array_deep_clone(@last_cell_rows)
|
106
107
|
@last_cell_rows = array_deep_clone(@cell_rows)
|
107
|
-
end.observe(self, :cell_rows)
|
108
|
+
end.observe(self, :cell_rows, recursive: true)
|
108
109
|
end
|
109
110
|
end
|
110
111
|
end
|
@@ -112,7 +113,11 @@ module Glimmer
|
|
112
113
|
alias set_cell_rows cell_rows
|
113
114
|
|
114
115
|
def expanded_cell_rows
|
115
|
-
cell_rows
|
116
|
+
expand(cell_rows)
|
117
|
+
end
|
118
|
+
|
119
|
+
def expand(cell_rows)
|
120
|
+
cell_rows.to_a.map do |row|
|
116
121
|
row.flatten(1)
|
117
122
|
end
|
118
123
|
end
|
@@ -146,23 +151,39 @@ module Glimmer
|
|
146
151
|
3
|
147
152
|
end
|
148
153
|
end
|
149
|
-
@model_handler.NumRows = fiddle_closure_block_caller(4)
|
154
|
+
@model_handler.NumRows = fiddle_closure_block_caller(4) do
|
155
|
+
# Note: there is a double-delete bug in Windows when performing table_model_row_deleted, which requires pre-adding and extra empty row
|
156
|
+
cell_rows.count + (OS.windows? ? 1 : 0)
|
157
|
+
end
|
150
158
|
@model_handler.CellValue = fiddle_closure_block_caller(1, [1, 1, 4, 4]) do |_, _, row, column|
|
151
159
|
the_cell_rows = expanded_cell_rows
|
152
160
|
case @columns[column]
|
153
161
|
when Column::TextColumnProxy, Column::ButtonColumnProxy, Column::TextColorColumnProxy, :text
|
154
162
|
::LibUI.new_table_value_string((expanded_cell_rows[row] && expanded_cell_rows[row][column]).to_s)
|
155
163
|
when Column::ImageColumnProxy, Column::ImageTextColumnProxy, Column::ImageTextColorColumnProxy
|
156
|
-
|
164
|
+
if OS.windows? && row == cell_rows.count
|
165
|
+
::LibUI.new_table_value_image((expanded_cell_rows[row - 1] && (expanded_cell_rows[row - 1][column].respond_to?(:libui) ? expanded_cell_rows[row - 1][column].libui : expanded_cell_rows[row - 1][column])))
|
166
|
+
else
|
167
|
+
::LibUI.new_table_value_image((expanded_cell_rows[row] && (expanded_cell_rows[row][column].respond_to?(:libui) ? expanded_cell_rows[row][column].libui : expanded_cell_rows[row][column])))
|
168
|
+
end
|
157
169
|
when Column::CheckboxColumnProxy, Column::CheckboxTextColumnProxy, Column::CheckboxTextColorColumnProxy
|
158
|
-
::LibUI.new_table_value_int((expanded_cell_rows[row] && (expanded_cell_rows[row][column] == 1 || expanded_cell_rows[row][column].to_s.strip.downcase == 'true' ? 1 : 0)))
|
170
|
+
::LibUI.new_table_value_int(((expanded_cell_rows[row] && (expanded_cell_rows[row][column] == 1 || expanded_cell_rows[row][column].to_s.strip.downcase == 'true' ? 1 : 0))) || 0)
|
159
171
|
when Column::ProgressBarColumnProxy
|
160
|
-
|
172
|
+
value = (expanded_cell_rows[row] && expanded_cell_rows[row][column]).to_i
|
173
|
+
expanded_last_last_cell_rows = expand(@last_last_cell_rows)
|
174
|
+
old_value = (expanded_last_last_cell_rows[row] && expanded_last_last_cell_rows[row][column]).to_i
|
175
|
+
if OS.windows? && old_value == -1 && value >= 0
|
176
|
+
Glimmer::Config.logger.error('Switching a progress bar value from -1 to a positive value is not supported on Windows')
|
177
|
+
cell_rows[row][column] = -1
|
178
|
+
::LibUI.new_table_value_int(old_value)
|
179
|
+
else
|
180
|
+
::LibUI.new_table_value_int((expanded_cell_rows[row] && expanded_cell_rows[row][column]).to_i)
|
181
|
+
end
|
161
182
|
when Column::BackgroundColorColumnProxy
|
162
|
-
background_color = Glimmer::LibUI.interpret_color(expanded_cell_rows[row] && expanded_cell_rows[row][column])
|
183
|
+
background_color = Glimmer::LibUI.interpret_color(expanded_cell_rows[row] && expanded_cell_rows[row][column]) || {r: 255, g: 255, b: 255}
|
163
184
|
::LibUI.new_table_value_color(background_color[:r] / 255.0, background_color[:g] / 255.0, background_color[:b] / 255.0, background_color[:a] || 1.0)
|
164
185
|
when :color
|
165
|
-
color = Glimmer::LibUI.interpret_color(expanded_cell_rows[row] && expanded_cell_rows[row][column])
|
186
|
+
color = Glimmer::LibUI.interpret_color(expanded_cell_rows[row] && expanded_cell_rows[row][column]) || {r: 0, g: 0, b: 0}
|
166
187
|
::LibUI.new_table_value_color(color[:r] / 255.0, color[:g] / 255.0, color[:b] / 255.0, color[:a] || 1.0)
|
167
188
|
end
|
168
189
|
end
|
@@ -182,7 +203,6 @@ module Glimmer
|
|
182
203
|
@cell_rows[row] ||= []
|
183
204
|
@cell_rows[row][column] = ::LibUI.table_value_int(val).to_i == 1
|
184
205
|
end
|
185
|
-
on_changed.each {|listener| listener.call(row, :changed, @cell_rows[row])}
|
186
206
|
on_edited.each {|listener| listener.call(row, @cell_rows[row])}
|
187
207
|
end
|
188
208
|
|
@@ -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
|
data/lib/glimmer/libui.rb
CHANGED
@@ -27,11 +27,11 @@ module Glimmer
|
|
27
27
|
include Glimmer::FiddleConsumer
|
28
28
|
|
29
29
|
def integer_to_boolean(int, allow_nil: true)
|
30
|
-
int.nil? ? (allow_nil ? nil : false) : ((int.is_a?(TrueClass) || int.is_a?(FalseClass)) ? int : int == 1)
|
30
|
+
int.nil? ? (allow_nil ? nil : false) : ((int.is_a?(TrueClass) || int.is_a?(FalseClass)) ? int : (int.is_a?(Integer) ? int == 1 : (allow_nil ? nil : false)))
|
31
31
|
end
|
32
32
|
|
33
33
|
def boolean_to_integer(bool, allow_nil: true)
|
34
|
-
bool.nil? ? (allow_nil ? nil : 0) : (bool.is_a?(Integer) ? bool : (bool == true ? 1 : 0))
|
34
|
+
bool.nil? ? (allow_nil ? nil : 0) : (bool.is_a?(Integer) ? bool : (bool.is_a?(TrueClass) || bool.is_a?(FalseClass) ? (bool == true ? 1 : 0) : (allow_nil ? nil : 0)))
|
35
35
|
end
|
36
36
|
|
37
37
|
def degrees_to_radians(degrees)
|