glimmer-dsl-libui 0.2.12 → 0.2.16

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.12
1
+ 0.2.16
data/bin/girb CHANGED
File without changes
data/bin/girb_runner.rb CHANGED
@@ -27,7 +27,7 @@ require_relative '../lib/glimmer-dsl-libui'
27
27
 
28
28
  include Glimmer
29
29
 
30
- GIRB_RUNNER_EXIT_FILE = "#{Etc.getpwuid.dir}/.girb_runner_exit"
30
+ GIRB_RUNNER_EXIT_FILE = "#{Dir.home}/.girb_runner_exit"
31
31
  FileUtils.rm_rf GIRB_RUNNER_EXIT_FILE
32
32
 
33
33
  @exit_method = method(:exit)
@@ -12,7 +12,7 @@ data = [
12
12
  %w[cow moo delete]
13
13
  ]
14
14
 
15
- window('Animal sounds', 300, 200) {
15
+ window('Animal sounds', 400, 200) {
16
16
  horizontal_box {
17
17
  table {
18
18
  text_column('Animal')
@@ -12,7 +12,7 @@ data = [
12
12
  ['cow', 'moo', true]
13
13
  ]
14
14
 
15
- window('Animal sounds', 300, 200) {
15
+ window('Animal sounds', 400, 200) {
16
16
  horizontal_box {
17
17
  table {
18
18
  text_column('Animal')
@@ -14,6 +14,7 @@ IMAGE_ROWS = []
14
14
  50.times do |i|
15
15
  url = format('https://www.ghibli.jp/gallery/thumb-redturtle%03d.png', (i + 1))
16
16
  puts "Processing Image: #{url}"
17
+ $stdout.flush # for Windows
17
18
  f = URI.open(url)
18
19
  canvas = ChunkyPNG::Canvas.from_io(f)
19
20
  f.close
@@ -14,6 +14,7 @@ IMAGE_ROWS = []
14
14
  5.times do |i|
15
15
  url = format('https://www.ghibli.jp/gallery/thumb-redturtle%03d.png', (i + 1))
16
16
  puts "Processing Image: #{url}"
17
+ $stdout.flush # for Windows
17
18
  f = URI.open(url)
18
19
  canvas = ChunkyPNG::Canvas.from_io(f)
19
20
  f.close
@@ -16,10 +16,16 @@ window('Basic Transform', 350, 350) {
16
16
  fill r: [255 - n*5, 0].max, g: [n*5, 255].min, b: 0, a: 0.5
17
17
  stroke :black, thickness: 2
18
18
  transform {
19
- skew 0.15, 0.15
20
- translate 50, 50
19
+ unless OS.windows?
20
+ skew 0.15, 0.15
21
+ translate 50, 50
22
+ end
21
23
  rotate 100, 100, -9 * n
22
24
  scale 1.1, 1.1
25
+ if OS.windows?
26
+ skew 0.15, 0.15
27
+ translate 50, 50
28
+ end
23
29
  }
24
30
  }
25
31
  end
@@ -4,7 +4,7 @@ require 'glimmer-dsl-libui'
4
4
 
5
5
  include Glimmer
6
6
 
7
- window('color button', 230) {
7
+ window('color button', 240) {
8
8
  color_button { |cb|
9
9
  color :blue
10
10
 
@@ -5,8 +5,8 @@ class ColorTheCircles
5
5
 
6
6
  WINDOW_WIDTH = 800
7
7
  WINDOW_HEIGHT = 600
8
- CIRCLE_MIN_RADIUS = 15
9
- CIRCLE_MAX_RADIUS = 50
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
- @score_label.text = new_score.to_s
31
- if new_score == -20
32
- @game_over = true
33
- msg_box('You Lost!', 'Sorry! Your score reached -20')
34
- restart_game
35
- elsif new_score == 0
36
- @game_over = true
37
- msg_box('You Won!', 'Congratulations! Your score reached 0')
38
- restart_game
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
- circle_x_center = rand * (WINDOW_WIDTH - MARGIN_WIDTH - CIRCLE_MAX_RADIUS) + CIRCLE_MAX_RADIUS
62
- circle_y_center = rand * (WINDOW_HEIGHT - MARGIN_HEIGHT - CIRCLE_MAX_RADIUS) + CIRCLE_MAX_RADIUS
63
- circle_radius = rand * (CIRCLE_MAX_RADIUS - CIRCLE_MIN_RADIUS) + CIRCLE_MIN_RADIUS
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: [circle_x_center, circle_y_center, circle_radius],
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].include?(x, y)
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
@@ -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
  }
@@ -42,15 +42,20 @@ class MetaExample
42
42
  end
43
43
 
44
44
  def run_example(example)
45
- command = "ruby -r #{glimmer_dsl_libui_file} #{example} 2>&1"
46
- result = ''
47
- IO.popen(command) do |f|
48
- f.each_line do |line|
49
- result << line
50
- puts line
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
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
 
@@ -151,16 +151,26 @@ module Glimmer
151
151
  end
152
152
  end
153
153
  unless font.nil?
154
- family_attribute = ::LibUI.new_family_attribute(font[:family])
155
- ::LibUI.attributed_string_set_attribute(@parent_proxy.attributed_string, family_attribute, @start, @start + @string.size)
156
- size_attribute = ::LibUI.new_size_attribute(font[:size])
157
- ::LibUI.attributed_string_set_attribute(@parent_proxy.attributed_string, size_attribute, @start, @start + @string.size)
158
- weight_attribute = ::LibUI.new_weight_attribute(Glimmer::LibUI.enum_symbol_to_value(:text_weight, font[:weight]))
159
- ::LibUI.attributed_string_set_attribute(@parent_proxy.attributed_string, weight_attribute, @start, @start + @string.size)
160
- italic_attribute = ::LibUI.new_italic_attribute(Glimmer::LibUI.enum_symbol_to_value(:text_italic, font[:italic]))
161
- ::LibUI.attributed_string_set_attribute(@parent_proxy.attributed_string, italic_attribute, @start, @start + @string.size)
162
- stretch_attribute = ::LibUI.new_stretch_attribute(Glimmer::LibUI.enum_symbol_to_value(:text_stretch, font[:stretch]))
163
- ::LibUI.attributed_string_set_attribute(@parent_proxy.attributed_string, stretch_attribute, @start, @start + @string.size)
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
164
174
  end
165
175
  unless open_type_features.nil?
166
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: modifiers_to_symbols(area_key_event.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
- key.chr if key > 0
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,6 +103,7 @@ 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
108
  end.observe(self, :cell_rows, recursive: true)
108
109
  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.map do |row|
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) { cell_rows.count }
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
- ::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])))
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
- ::LibUI.new_table_value_int((expanded_cell_rows[row] && (expanded_cell_rows[row][column].to_i)))
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
- ::LibUI.draw_path_arc_to(path_proxy.libui, *arc_args)
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
- ::LibUI.draw_path_arc_to(path_proxy.libui, *arc_args)
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)
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.12
4
+ version: 0.2.16
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-16 00:00:00.000000000 Z
11
+ date: 2021-10-28 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 - Prerequisite-Free Ruby Desktop Development GUI
194
- Library (No need to pre-install any prerequisites. Just install the gem and have
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
- declarative DSL syntax that visually maps to the GUI control hierarchy, convention
197
- over configuration via smart defaults and automation of low-level details, requiring
198
- the least amount of syntax possible to build GUI, and custom control support.)
196
+ declarative DSL syntax that visually maps to GUI control hierarchy, convention over
197
+ configuration via smart defaults, automation of low-level details, requiring the
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