glimmer-dsl-libui 0.11.6 → 0.11.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -3
  3. data/LICENSE.txt +1 -1
  4. data/README.md +55 -8
  5. data/VERSION +1 -1
  6. data/bin/girb +1 -1
  7. data/bin/girb_runner.rb +1 -1
  8. data/bin/glimmer +1 -1
  9. data/docs/examples/GLIMMER-DSL-LIBUI-ADVANCED-EXAMPLES.md +1 -1
  10. data/docs/examples/GLIMMER-DSL-LIBUI-BASIC-EXAMPLES.md +13 -689
  11. data/examples/basic_area.rb +3 -5
  12. data/examples/basic_area2.rb +6 -8
  13. data/examples/basic_area3.rb +5 -7
  14. data/examples/basic_area4.rb +8 -10
  15. data/examples/basic_table_button.rb +20 -22
  16. data/examples/basic_table_button2.rb +13 -15
  17. data/examples/basic_table_checkbox.rb +17 -19
  18. data/examples/basic_table_checkbox_text.rb +17 -19
  19. data/examples/basic_table_color.rb +8 -10
  20. data/examples/basic_table_color2.rb +7 -9
  21. data/examples/basic_table_color3.rb +7 -9
  22. data/examples/basic_table_image_text.rb +6 -8
  23. data/examples/basic_table_image_text2.rb +6 -8
  24. data/examples/basic_table_image_text3.rb +6 -8
  25. data/examples/date_time_picker.rb +17 -17
  26. data/examples/date_time_picker2.rb +5 -13
  27. data/examples/lazy_table.rb +8 -10
  28. data/examples/lazy_table2.rb +8 -10
  29. data/examples/lazy_table3.rb +8 -10
  30. data/examples/lazy_table4.rb +8 -10
  31. data/examples/simple_notepad.rb +1 -7
  32. data/examples/tetris/model/block.rb +1 -1
  33. data/examples/tetris/model/game.rb +1 -1
  34. data/examples/tetris/model/past_game.rb +1 -1
  35. data/examples/tetris/model/tetromino.rb +1 -1
  36. data/examples/tetris.rb +1 -1
  37. data/examples/tic_tac_toe/board.rb +1 -1
  38. data/examples/tic_tac_toe/cell.rb +1 -1
  39. data/glimmer-dsl-libui.gemspec +0 -0
  40. data/lib/glimmer/dsl/libui/bind_expression.rb +1 -1
  41. data/lib/glimmer/dsl/libui/content_expression.rb +1 -1
  42. data/lib/glimmer/dsl/libui/control_expression.rb +1 -1
  43. data/lib/glimmer/dsl/libui/custom_control_expression.rb +1 -1
  44. data/lib/glimmer/dsl/libui/custom_shape_expression.rb +1 -1
  45. data/lib/glimmer/dsl/libui/data_binding_expression.rb +1 -1
  46. data/lib/glimmer/dsl/libui/dsl.rb +1 -1
  47. data/lib/glimmer/dsl/libui/file_expression.rb +1 -1
  48. data/lib/glimmer/dsl/libui/listener_expression.rb +1 -1
  49. data/lib/glimmer/dsl/libui/observe_expression.rb +2 -1
  50. data/lib/glimmer/dsl/libui/open_file_expression.rb +1 -1
  51. data/lib/glimmer/dsl/libui/open_folder_expression.rb +1 -1
  52. data/lib/glimmer/dsl/libui/operation_expression.rb +1 -1
  53. data/lib/glimmer/dsl/libui/property_expression.rb +1 -1
  54. data/lib/glimmer/dsl/libui/save_file_expression.rb +1 -1
  55. data/lib/glimmer/dsl/libui/shape_expression.rb +1 -1
  56. data/lib/glimmer/dsl/libui/shine_data_binding_expression.rb +1 -1
  57. data/lib/glimmer/dsl/libui/string_expression.rb +1 -1
  58. data/lib/glimmer/dsl/libui/tab_item_expression.rb +1 -1
  59. data/lib/glimmer/fiddle_consumer.rb +1 -1
  60. data/lib/glimmer/libui/attributed_string.rb +1 -1
  61. data/lib/glimmer/libui/control_proxy/area_proxy/scrolling_area_proxy.rb +1 -1
  62. data/lib/glimmer/libui/control_proxy/area_proxy.rb +1 -1
  63. data/lib/glimmer/libui/control_proxy/box/horizontal_box_proxy.rb +1 -1
  64. data/lib/glimmer/libui/control_proxy/box/vertical_box_proxy.rb +1 -1
  65. data/lib/glimmer/libui/control_proxy/box.rb +1 -1
  66. data/lib/glimmer/libui/control_proxy/button_proxy.rb +1 -1
  67. data/lib/glimmer/libui/control_proxy/checkbox_proxy.rb +1 -1
  68. data/lib/glimmer/libui/control_proxy/color_button_proxy.rb +1 -1
  69. data/lib/glimmer/libui/control_proxy/column/background_color_column_proxy.rb +1 -1
  70. data/lib/glimmer/libui/control_proxy/column/button_column_proxy.rb +1 -1
  71. data/lib/glimmer/libui/control_proxy/column/checkbox_column_proxy.rb +1 -1
  72. data/lib/glimmer/libui/control_proxy/column/checkbox_text_color_column_proxy.rb +1 -1
  73. data/lib/glimmer/libui/control_proxy/column/checkbox_text_column_proxy.rb +1 -1
  74. data/lib/glimmer/libui/control_proxy/column/image_column_proxy.rb +1 -1
  75. data/lib/glimmer/libui/control_proxy/column/image_text_color_column_proxy.rb +1 -1
  76. data/lib/glimmer/libui/control_proxy/column/image_text_column_proxy.rb +1 -1
  77. data/lib/glimmer/libui/control_proxy/column/progress_bar_column_proxy.rb +1 -1
  78. data/lib/glimmer/libui/control_proxy/column/text_color_column_proxy.rb +1 -1
  79. data/lib/glimmer/libui/control_proxy/column/text_column_proxy.rb +1 -1
  80. data/lib/glimmer/libui/control_proxy/column.rb +1 -1
  81. data/lib/glimmer/libui/control_proxy/combobox_proxy.rb +1 -1
  82. data/lib/glimmer/libui/control_proxy/date_time_picker_proxy/date_picker_proxy.rb +1 -1
  83. data/lib/glimmer/libui/control_proxy/date_time_picker_proxy/time_picker_proxy.rb +1 -1
  84. data/lib/glimmer/libui/control_proxy/date_time_picker_proxy.rb +1 -1
  85. data/lib/glimmer/libui/control_proxy/dual_column.rb +1 -1
  86. data/lib/glimmer/libui/control_proxy/editable_column.rb +1 -1
  87. data/lib/glimmer/libui/control_proxy/editable_combobox_proxy.rb +1 -1
  88. data/lib/glimmer/libui/control_proxy/enableable_column.rb +1 -1
  89. data/lib/glimmer/libui/control_proxy/entry_proxy/password_entry_proxy.rb +1 -1
  90. data/lib/glimmer/libui/control_proxy/entry_proxy/search_entry_proxy.rb +1 -1
  91. data/lib/glimmer/libui/control_proxy/entry_proxy.rb +1 -1
  92. data/lib/glimmer/libui/control_proxy/font_button_proxy.rb +1 -1
  93. data/lib/glimmer/libui/control_proxy/form_proxy.rb +1 -1
  94. data/lib/glimmer/libui/control_proxy/grid_proxy.rb +1 -1
  95. data/lib/glimmer/libui/control_proxy/group_proxy.rb +1 -1
  96. data/lib/glimmer/libui/control_proxy/image_part_proxy.rb +1 -1
  97. data/lib/glimmer/libui/control_proxy/image_proxy.rb +1 -1
  98. data/lib/glimmer/libui/control_proxy/label_proxy.rb +1 -1
  99. data/lib/glimmer/libui/control_proxy/matrix_proxy.rb +1 -1
  100. data/lib/glimmer/libui/control_proxy/menu_item_proxy/about_menu_item_proxy.rb +1 -1
  101. data/lib/glimmer/libui/control_proxy/menu_item_proxy/check_menu_item_proxy.rb +1 -1
  102. data/lib/glimmer/libui/control_proxy/menu_item_proxy/preferences_menu_item_proxy.rb +1 -1
  103. data/lib/glimmer/libui/control_proxy/menu_item_proxy/quit_menu_item_proxy.rb +1 -1
  104. data/lib/glimmer/libui/control_proxy/menu_item_proxy/radio_menu_item_proxy.rb +1 -1
  105. data/lib/glimmer/libui/control_proxy/menu_item_proxy/separator_menu_item_proxy.rb +1 -1
  106. data/lib/glimmer/libui/control_proxy/menu_item_proxy.rb +1 -1
  107. data/lib/glimmer/libui/control_proxy/menu_proxy.rb +1 -1
  108. data/lib/glimmer/libui/control_proxy/message_box/msg_box_error_proxy.rb +1 -1
  109. data/lib/glimmer/libui/control_proxy/message_box/msg_box_proxy.rb +1 -1
  110. data/lib/glimmer/libui/control_proxy/message_box.rb +1 -1
  111. data/lib/glimmer/libui/control_proxy/multiline_entry_proxy/non_wrapping_multiline_entry_proxy.rb +1 -1
  112. data/lib/glimmer/libui/control_proxy/multiline_entry_proxy.rb +1 -1
  113. data/lib/glimmer/libui/control_proxy/open_type_features_proxy.rb +1 -1
  114. data/lib/glimmer/libui/control_proxy/open_type_tag_proxy.rb +1 -1
  115. data/lib/glimmer/libui/control_proxy/path_proxy.rb +1 -1
  116. data/lib/glimmer/libui/control_proxy/radio_buttons_proxy.rb +1 -1
  117. data/lib/glimmer/libui/control_proxy/slider_proxy.rb +1 -1
  118. data/lib/glimmer/libui/control_proxy/spinbox_proxy.rb +1 -1
  119. data/lib/glimmer/libui/control_proxy/tab_item_proxy.rb +1 -1
  120. data/lib/glimmer/libui/control_proxy/table_proxy.rb +7 -2
  121. data/lib/glimmer/libui/control_proxy/text_proxy.rb +1 -1
  122. data/lib/glimmer/libui/control_proxy/transformable.rb +7 -3
  123. data/lib/glimmer/libui/control_proxy/triple_column.rb +1 -1
  124. data/lib/glimmer/libui/control_proxy/window_proxy.rb +1 -1
  125. data/lib/glimmer/libui/control_proxy.rb +1 -1
  126. data/lib/glimmer/libui/custom_control/code_area.rb +1 -1
  127. data/lib/glimmer/libui/custom_control/refined_table.rb +1 -1
  128. data/lib/glimmer/libui/custom_control.rb +1 -1
  129. data/lib/glimmer/libui/custom_shape.rb +1 -1
  130. data/lib/glimmer/libui/custom_window.rb +1 -1
  131. data/lib/glimmer/libui/data_bindable.rb +1 -1
  132. data/lib/glimmer/libui/parent.rb +1 -1
  133. data/lib/glimmer/libui/shape/arc.rb +1 -1
  134. data/lib/glimmer/libui/shape/bezier.rb +1 -1
  135. data/lib/glimmer/libui/shape/circle.rb +1 -1
  136. data/lib/glimmer/libui/shape/figure.rb +1 -1
  137. data/lib/glimmer/libui/shape/line.rb +1 -1
  138. data/lib/glimmer/libui/shape/polybezier.rb +1 -1
  139. data/lib/glimmer/libui/shape/polygon.rb +1 -1
  140. data/lib/glimmer/libui/shape/polyline.rb +1 -1
  141. data/lib/glimmer/libui/shape/rectangle.rb +1 -1
  142. data/lib/glimmer/libui/shape/square.rb +1 -1
  143. data/lib/glimmer/libui/shape.rb +3 -3
  144. data/lib/glimmer/libui.rb +1 -1
  145. data/lib/glimmer/rake_task/package.rb +1 -1
  146. data/lib/glimmer/rake_task/scaffold.rb +1 -1
  147. data/lib/glimmer/rake_task.rb +1 -1
  148. data/lib/glimmer-dsl-libui.rb +1 -1
  149. metadata +5 -5
@@ -48,30 +48,6 @@ Mac | Windows | Linux
48
48
  ----|---------|------
49
49
  ![glimmer-dsl-libui-mac-basic-window.png](/images/glimmer-dsl-libui-mac-basic-window.png) | ![glimmer-dsl-libui-windows-basic-window.png](/images/glimmer-dsl-libui-windows-basic-window.png) | ![glimmer-dsl-libui-linux-basic-window.png](/images/glimmer-dsl-libui-linux-basic-window.png)
50
50
 
51
- [LibUI](https://github.com/kojix2/LibUI) Original Version:
52
-
53
- ```ruby
54
- require 'libui'
55
-
56
- UI = LibUI
57
-
58
- UI.init
59
-
60
- main_window = UI.new_window('hello world', 300, 200, 1)
61
-
62
- UI.control_show(main_window)
63
-
64
- UI.window_on_closing(main_window) do
65
- puts 'Bye Bye'
66
- UI.control_destroy(main_window)
67
- UI.quit
68
- 0
69
- end
70
-
71
- UI.main
72
- UI.quit
73
- ```
74
-
75
51
  [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
76
52
 
77
53
  ```ruby
@@ -143,37 +119,6 @@ Mac | Windows | Linux
143
119
  ----|---------|------
144
120
  ![glimmer-dsl-libui-mac-basic-button.png](/images/glimmer-dsl-libui-mac-basic-button.png) ![glimmer-dsl-libui-mac-basic-button-msg-box.png](/images/glimmer-dsl-libui-mac-basic-button-msg-box.png) | ![glimmer-dsl-libui-windows-basic-button.png](/images/glimmer-dsl-libui-windows-basic-button.png) ![glimmer-dsl-libui-windows-basic-button-msg-box.png](/images/glimmer-dsl-libui-windows-basic-button-msg-box.png) | ![glimmer-dsl-libui-linux-basic-button.png](/images/glimmer-dsl-libui-linux-basic-button.png) ![glimmer-dsl-libui-linux-basic-button-msg-box.png](/images/glimmer-dsl-libui-linux-basic-button-msg-box.png)
145
121
 
146
- [LibUI](https://github.com/kojix2/LibUI) Original Version:
147
-
148
- ```ruby
149
- require 'libui'
150
-
151
- UI = LibUI
152
-
153
- UI.init
154
-
155
- main_window = UI.new_window('hello world', 300, 200, 1)
156
-
157
- button = UI.new_button('Button')
158
-
159
- UI.button_on_clicked(button) do
160
- UI.msg_box(main_window, 'Information', 'You clicked the button')
161
- end
162
-
163
- UI.window_on_closing(main_window) do
164
- puts 'Bye Bye'
165
- UI.control_destroy(main_window)
166
- UI.quit
167
- 0
168
- end
169
-
170
- UI.window_set_child(main_window, button)
171
- UI.control_show(main_window)
172
-
173
- UI.main
174
- UI.quit
175
- ```
176
-
177
122
  [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
178
123
 
179
124
  ```ruby
@@ -214,122 +159,16 @@ Mac | Windows | Linux
214
159
  ----|---------|------
215
160
  ![glimmer-dsl-libui-mac-basic-entry.png](/images/glimmer-dsl-libui-mac-basic-entry.png) ![glimmer-dsl-libui-mac-basic-entry-msg-box.png](/images/glimmer-dsl-libui-mac-basic-entry-msg-box.png) | ![glimmer-dsl-libui-windows-basic-entry.png](/images/glimmer-dsl-libui-windows-basic-entry.png) ![glimmer-dsl-libui-windows-basic-entry-msg-box.png](/images/glimmer-dsl-libui-windows-basic-entry-msg-box.png) | ![glimmer-dsl-libui-linux-basic-entry.png](/images/glimmer-dsl-libui-linux-basic-entry.png) ![glimmer-dsl-libui-linux-basic-entry-msg-box.png](/images/glimmer-dsl-libui-linux-basic-entry-msg-box.png)
216
161
 
217
- [LibUI](https://github.com/kojix2/LibUI) Original Version:
218
-
219
- ```ruby
220
- require 'libui'
221
-
222
- UI = LibUI
223
-
224
- UI.init
225
-
226
- main_window = UI.new_window('Basic Entry', 300, 50, 1)
227
- UI.window_on_closing(main_window) do
228
- puts 'Bye Bye'
229
- UI.control_destroy(main_window)
230
- UI.quit
231
- 0
232
- end
233
-
234
- hbox = UI.new_horizontal_box
235
- UI.window_set_child(main_window, hbox)
236
-
237
- entry = UI.new_entry
238
- UI.entry_on_changed(entry) do
239
- puts UI.entry_text(entry).to_s
240
- $stdout.flush # For Windows
241
- end
242
- UI.box_append(hbox, entry, 1)
243
-
244
- button = UI.new_button('Button')
245
- UI.button_on_clicked(button) do
246
- text = UI.entry_text(entry).to_s
247
- UI.msg_box(main_window, 'You entered', text)
248
- 0
249
- end
250
-
251
- UI.box_append(hbox, button, 0)
252
-
253
- UI.control_show(main_window)
254
- UI.main
255
- UI.quit
256
- ```
257
-
258
162
  [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version (with [data-binding](#data-binding)):
259
163
 
260
- ```ruby
261
- require 'glimmer-dsl-libui'
262
-
263
- class BasicEntry
264
- include Glimmer
265
-
266
- attr_accessor :entry_text
267
-
268
- def launch
269
- window('Basic Entry', 300, 50) {
270
- horizontal_box {
271
- entry {
272
- # stretchy true # Smart default option for appending to horizontal_box
273
- text <=> [self, :entry_text, after_write: ->(text) {puts text; $stdout.flush}] # bidirectional data-binding between text property and entry_text attribute, printing after write to model.
274
- }
275
-
276
- button('Button') {
277
- stretchy false # stretchy property is available when control is nested under horizontal_box
278
-
279
- on_clicked do
280
- msg_box('You entered', entry_text)
281
- end
282
- }
283
- }
284
-
285
- on_closing do
286
- puts 'Bye Bye'
287
- end
288
- }.show
289
- end
290
- end
291
-
292
- BasicEntry.new.launch
293
- ```
164
+ [examples/basic_entry.rb](/examples/basic_entry.rb)
294
165
 
295
166
  [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 2 (without [data-binding](#data-binding)):
296
167
 
297
- ```ruby
298
- require 'glimmer-dsl-libui'
299
-
300
- include Glimmer
301
-
302
- window('Basic Entry', 300, 50) {
303
- horizontal_box {
304
- e = entry {
305
- # stretchy true # Smart default option for appending to horizontal_box
306
-
307
- on_changed do
308
- puts e.text
309
- $stdout.flush # For Windows
310
- end
311
- }
312
-
313
- button('Button') {
314
- stretchy false # stretchy property is available when control is nested under horizontal_box
315
-
316
- on_clicked do
317
- text = e.text
318
- msg_box('You entered', text)
319
- end
320
- }
321
- }
322
-
323
- on_closing do
324
- puts 'Bye Bye'
325
- end
326
- }.show
327
- ```
168
+ [examples/basic_entry2.rb](/examples/basic_entry2.rb)
328
169
 
329
170
  ## Simple Notepad
330
171
 
331
- [examples/simple_notepad.rb](/examples/simple_notepad.rb)
332
-
333
172
  Run with this command from the root of the project if you cloned the project:
334
173
 
335
174
  ```
@@ -346,51 +185,7 @@ Mac | Windows | Linux
346
185
  ----|---------|------
347
186
  ![glimmer-dsl-libui-mac-simple-notepad.png](/images/glimmer-dsl-libui-mac-simple-notepad.png) | ![glimmer-dsl-libui-windows-simple-notepad.png](/images/glimmer-dsl-libui-windows-simple-notepad.png) | ![glimmer-dsl-libui-linux-simple-notepad.png](/images/glimmer-dsl-libui-linux-simple-notepad.png)
348
187
 
349
- [LibUI](https://github.com/kojix2/LibUI) Original Version:
350
-
351
- ```ruby
352
- require 'libui'
353
-
354
- UI = LibUI
355
-
356
- UI.init
357
-
358
- main_window = UI.new_window('Notepad', 500, 300, 1)
359
- UI.window_on_closing(main_window) do
360
- puts 'Bye Bye'
361
- UI.control_destroy(main_window)
362
- UI.quit
363
- 0
364
- end
365
-
366
- vbox = UI.new_vertical_box
367
- UI.window_set_child(main_window, vbox)
368
-
369
- entry = UI.new_non_wrapping_multiline_entry
370
- UI.box_append(vbox, entry, 1)
371
-
372
- UI.control_show(main_window)
373
- UI.main
374
- UI.quit
375
- ```
376
-
377
- [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
378
-
379
- ```ruby
380
- require 'glimmer-dsl-libui'
381
-
382
- include Glimmer
383
-
384
- window('Notepad', 500, 300) {
385
- on_closing do
386
- puts 'Bye Bye'
387
- end
388
-
389
- vertical_box {
390
- non_wrapping_multiline_entry
391
- }
392
- }.show
393
- ```
188
+ [examples/simple_notepad.rb](/examples/simple_notepad.rb)
394
189
 
395
190
  ## Font Button
396
191
 
@@ -412,44 +207,6 @@ Mac | Windows | Linux
412
207
  ----|---------|------
413
208
  ![glimmer-dsl-libui-mac-font-button.png](/images/glimmer-dsl-libui-mac-font-button.png) ![glimmer-dsl-libui-mac-font-button-selection.png](/images/glimmer-dsl-libui-mac-font-button-selection.png) | ![glimmer-dsl-libui-windows-font-button.png](/images/glimmer-dsl-libui-windows-font-button.png) ![glimmer-dsl-libui-windows-font-button-selection.png](/images/glimmer-dsl-libui-windows-font-button-selection.png) | ![glimmer-dsl-libui-linux-font-button.png](/images/glimmer-dsl-libui-linux-font-button.png) ![glimmer-dsl-libui-linux-font-button-selection.png](/images/glimmer-dsl-libui-linux-font-button-selection.png)
414
209
 
415
- [LibUI](https://github.com/kojix2/LibUI) Original Version:
416
-
417
- ```ruby
418
- require 'libui'
419
-
420
- UI = LibUI
421
-
422
- UI.init
423
-
424
- main_window = UI.new_window('hello world', 300, 200, 1)
425
-
426
- font_button = UI.new_font_button
427
- font_descriptor = UI::FFI::FontDescriptor.malloc
428
- font_descriptor.to_ptr.free = Fiddle::RUBY_FREE
429
- UI.font_button_on_changed(font_button) do
430
- UI.font_button_font(font_button, font_descriptor)
431
- p family: font_descriptor.Family.to_s,
432
- size: font_descriptor.Size,
433
- weight: font_descriptor.Weight,
434
- italic: font_descriptor.Italic,
435
- stretch: font_descriptor.Stretch
436
- end
437
-
438
- UI.window_on_closing(main_window) do
439
- puts 'Bye Bye'
440
- UI.control_destroy(main_window)
441
- UI.quit
442
- 0
443
- end
444
-
445
- UI.window_set_child(main_window, font_button)
446
- UI.control_show(main_window)
447
-
448
- UI.main
449
- UI.quit
450
-
451
- ```
452
-
453
210
  [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version (with [data-binding](#data-binding)):
454
211
 
455
212
  ```ruby
@@ -564,8 +321,6 @@ window('color button', 240) {
564
321
 
565
322
  ## Date Time Picker
566
323
 
567
- [examples/date_time_picker.rb](/examples/date_time_picker.rb)
568
-
569
324
  Run with this command from the root of the project if you cloned the project:
570
325
 
571
326
  ```
@@ -582,99 +337,13 @@ Mac | Windows | Linux
582
337
  ----|---------|------
583
338
  ![glimmer-dsl-libui-mac-date-time-picker.png](/images/glimmer-dsl-libui-mac-date-time-picker.png) | ![glimmer-dsl-libui-windows-date-time-picker.png](/images/glimmer-dsl-libui-windows-date-time-picker.png) | ![glimmer-dsl-libui-linux-date-time-picker.png](/images/glimmer-dsl-libui-linux-date-time-picker.png)
584
339
 
585
- [LibUI](https://github.com/kojix2/LibUI) Original Version:
586
-
587
- ```ruby
588
- require 'libui'
589
-
590
- UI = LibUI
591
-
592
- UI.init
593
-
594
- vbox = UI.new_vertical_box
595
-
596
- date_time_picker = UI.new_date_time_picker
597
-
598
- time = UI::FFI::TM.malloc
599
-
600
- UI.date_time_picker_on_changed(date_time_picker) do
601
- UI.date_time_picker_time(date_time_picker, time)
602
- p sec: time.tm_sec,
603
- min: time.tm_min,
604
- hour: time.tm_hour,
605
- mday: time.tm_mday,
606
- mon: time.tm_mon,
607
- year: time.tm_year,
608
- wday: time.tm_wday,
609
- yday: time.tm_yday,
610
- isdst: time.tm_isdst
611
- end
612
- UI.box_append(vbox, date_time_picker, 1)
613
-
614
- main_window = UI.new_window('Date Time Pickers', 300, 200, 1)
615
- UI.window_on_closing(main_window) do
616
- puts 'Bye Bye'
617
- UI.control_destroy(main_window)
618
- UI.quit
619
- 0
620
- end
621
- UI.window_set_child(main_window, vbox)
622
- UI.control_show(main_window)
623
-
624
- UI.main
625
- UI.quit
626
- ```
627
-
628
340
  [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version (with [data-binding](#data-binding)):
629
341
 
630
- ```ruby
631
- require 'glimmer-dsl-libui'
632
-
633
- class DateTimePicker
634
- include Glimmer
635
-
636
- attr_accessor :picked_time
637
-
638
- def launch
639
- window('Date Time Pickers', 300, 200) {
640
- vertical_box {
641
- date_time_picker {
642
- time <=> [self, :picked_time, after_write: ->(time) { p time }]
643
- }
644
- }
645
-
646
- on_closing do
647
- puts 'Bye Bye'
648
- end
649
- }.show
650
- end
651
- end
652
-
653
- DateTimePicker.new.launch
654
- ```
342
+ [examples/date_time_picker.rb](/examples/date_time_picker.rb)
655
343
 
656
344
  [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 2 (without [data-binding](#data-binding)):
657
345
 
658
- ```ruby
659
- require 'glimmer-dsl-libui'
660
-
661
- include Glimmer
662
-
663
- window('Date Time Pickers', 300, 200) {
664
- vertical_box {
665
- date_time_picker { |dtp|
666
- on_changed do
667
- time = dtp.time
668
- p time
669
- end
670
- }
671
- }
672
-
673
- on_closing do
674
- puts 'Bye Bye'
675
- end
676
- }.show
677
- ```
346
+ [examples/date_time_picker2.rb](/examples/date_time_picker2.rb)
678
347
 
679
348
  ## Form
680
349
 
@@ -808,71 +477,6 @@ Mac | Windows | Linux
808
477
  ----|---------|------
809
478
  ![glimmer-dsl-libui-mac-basic-table.png](/images/glimmer-dsl-libui-mac-basic-table.png) | ![glimmer-dsl-libui-windows-basic-table.png](/images/glimmer-dsl-libui-windows-basic-table.png) | ![glimmer-dsl-libui-linux-basic-table.png](/images/glimmer-dsl-libui-linux-basic-table.png)
810
479
 
811
- [LibUI](https://github.com/kojix2/LibUI) Original Version:
812
-
813
- ```ruby
814
- require 'libui'
815
-
816
- UI = LibUI
817
-
818
- UI.init
819
-
820
- main_window = UI.new_window('Animal sounds', 300, 200, 1)
821
-
822
- hbox = UI.new_horizontal_box
823
- UI.window_set_child(main_window, hbox)
824
-
825
- data = [
826
- %w[cat meow],
827
- %w[dog woof],
828
- %w[checken cock-a-doodle-doo],
829
- %w[horse neigh],
830
- %w[cow moo]
831
- ]
832
-
833
- # Protects BlockCaller objects from garbage collection.
834
- @blockcaller = []
835
- def rbcallback(*args, &block)
836
- args << [0] if args.size == 1 # Argument types are ommited
837
- blockcaller = Fiddle::Closure::BlockCaller.new(*args, &block)
838
- @blockcaller << blockcaller
839
- blockcaller
840
- end
841
-
842
- model_handler = UI::FFI::TableModelHandler.malloc
843
- model_handler.NumColumns = rbcallback(4) { 2 }
844
- model_handler.ColumnType = rbcallback(4) { 0 }
845
- model_handler.NumRows = rbcallback(4) { 5 }
846
- model_handler.CellValue = rbcallback(1, [1, 1, 4, 4]) do |_, _, row, column|
847
- UI.new_table_value_string(data[row][column])
848
- end
849
- model_handler.SetCellValue = rbcallback(0, [0]) {}
850
-
851
- model = UI.new_table_model(model_handler)
852
-
853
- table_params = UI::FFI::TableParams.malloc
854
- table_params.Model = model
855
- table_params.RowBackgroundColorModelColumn = -1
856
-
857
- table = UI.new_table(table_params)
858
- UI.table_append_text_column(table, 'Animal', 0, -1)
859
- UI.table_append_text_column(table, 'Description', 1, -1)
860
-
861
- UI.box_append(hbox, table, 1)
862
- UI.control_show(main_window)
863
-
864
- UI.window_on_closing(main_window) do
865
- puts 'Bye Bye'
866
- UI.control_destroy(main_window)
867
- UI.free_table_model(model)
868
- UI.quit
869
- 0
870
- end
871
-
872
- UI.main
873
- UI.quit
874
- ```
875
-
876
480
  [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
877
481
 
878
482
  ```ruby
@@ -926,86 +530,6 @@ Mac | Windows | Linux
926
530
  ----|---------|------
927
531
  ![glimmer-dsl-libui-mac-basic-table-image.png](/images/glimmer-dsl-libui-mac-basic-table-image.png) | ![glimmer-dsl-libui-windows-basic-table-image.png](/images/glimmer-dsl-libui-windows-basic-table-image.png) | ![glimmer-dsl-libui-linux-basic-table-image.png](/images/glimmer-dsl-libui-linux-basic-table-image.png)
928
532
 
929
- [LibUI](https://github.com/kojix2/LibUI) Original Version:
930
-
931
- ```ruby
932
- # NOTE:
933
- # This example displays images that can be freely downloaded from the Studio Ghibli website.
934
-
935
- require 'libui'
936
- require 'chunky_png'
937
- require 'open-uri'
938
-
939
- UI = LibUI
940
-
941
- UI.init
942
-
943
- main_window = UI.new_window('The Red Turtle', 310, 350, 0)
944
-
945
- hbox = UI.new_horizontal_box
946
- UI.window_set_child(main_window, hbox)
947
-
948
- IMAGES = []
949
-
950
- 50.times do |i|
951
- url = format('https://www.ghibli.jp/gallery/thumb-redturtle%03d.png', (i + 1))
952
- puts "Processing Image: #{url}"
953
- f = URI.open(url)
954
- canvas = ChunkyPNG::Canvas.from_io(f)
955
- f.close
956
- data = canvas.to_rgba_stream
957
- width = canvas.width
958
- height = canvas.height
959
- image = UI.new_image(width, height)
960
- UI.image_append(image, data, width, height, width * 4)
961
- IMAGES << image
962
- rescue StandardError => e
963
- warn url, e.message
964
- end
965
-
966
- # Protects BlockCaller objects from garbage collection.
967
- @blockcaller = []
968
- def rbcallback(*args, &block)
969
- args << [0] if args.size == 1 # Argument types are ommited
970
- blockcaller = Fiddle::Closure::BlockCaller.new(*args, &block)
971
- @blockcaller << blockcaller
972
- blockcaller
973
- end
974
-
975
- model_handler = UI::FFI::TableModelHandler.malloc
976
- model_handler.NumColumns = rbcallback(4) { 1 }
977
- model_handler.ColumnType = rbcallback(4) { 1 } # Image
978
- model_handler.NumRows = rbcallback(4) { IMAGES.size }
979
- model_handler.CellValue = rbcallback(1, [1, 1, 4, 4]) do |_, _, row, _column|
980
- UI.new_table_value_image(/images[row])
981
- end
982
- model_handler.SetCellValue = rbcallback(0, [0]) {}
983
-
984
- model = UI.new_table_model(model_handler)
985
-
986
- table_params = UI::FFI::TableParams.malloc
987
- table_params.Model = model
988
- table_params.RowBackgroundColorModelColumn = -1
989
-
990
- table = UI.new_table(table_params)
991
- UI.table_append_image_column(table, 'www.ghibli.jp/works/red-turtle', 0)
992
-
993
- UI.box_append(hbox, table, 1)
994
- UI.control_show(main_window)
995
-
996
- UI.window_on_closing(main_window) do
997
- puts 'Bye Bye'
998
- UI.control_destroy(main_window)
999
- UI.free_table_model(model)
1000
- IMAGES.each { |i| UI.free_image(i) }
1001
- UI.quit
1002
- 0
1003
- end
1004
-
1005
- UI.main
1006
- UI.quit
1007
- ```
1008
-
1009
533
  [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version (passing file url as image):
1010
534
 
1011
535
  ```ruby
@@ -1542,8 +1066,6 @@ Version 3 (custom sorting without data-binding):
1542
1066
 
1543
1067
  ## Basic Area
1544
1068
 
1545
- [examples/basic_area.rb](/examples/basic_area.rb)
1546
-
1547
1069
  Run with this command from the root of the project if you cloned the project:
1548
1070
 
1549
1071
  ```
@@ -1560,103 +1082,21 @@ Mac | Windows | Linux
1560
1082
  ----|---------|------
1561
1083
  ![glimmer-dsl-libui-mac-basic-area.png](/images/glimmer-dsl-libui-mac-basic-area.png) | ![glimmer-dsl-libui-windows-basic-area.png](/images/glimmer-dsl-libui-windows-basic-area.png) | ![glimmer-dsl-libui-linux-basic-area.png](/images/glimmer-dsl-libui-linux-basic-area.png)
1562
1084
 
1563
- [LibUI](https://github.com/kojix2/LibUI) Original Version:
1564
-
1565
- ```ruby
1566
- require 'libui'
1567
-
1568
- UI = LibUI
1569
-
1570
- UI.init
1571
-
1572
- handler = UI::FFI::AreaHandler.malloc
1573
- area = UI.new_area(handler)
1574
- brush = UI::FFI::DrawBrush.malloc
1575
-
1576
- handler_draw_event = Fiddle::Closure::BlockCaller.new(0, [1, 1, 1]) do |_, _, area_draw_params|
1577
- path = UI.draw_new_path(0)
1578
- UI.draw_path_add_rectangle(path, 0, 0, 400, 400)
1579
- UI.draw_path_end(path)
1580
- brush.Type = 0
1581
- brush.R = 0.4
1582
- brush.G = 0.4
1583
- brush.B = 0.8
1584
- brush.A = 1.0
1585
- area_draw_params = UI::FFI::AreaDrawParams.new(area_draw_params)
1586
- UI.draw_fill(area_draw_params.Context, path, brush.to_ptr)
1587
- UI.draw_free_path(path)
1588
- end
1589
-
1590
- handler.Draw = handler_draw_event
1591
- handler.MouseEvent = Fiddle::Closure::BlockCaller.new(0, [0]) {}
1592
- handler.MouseCrossed = Fiddle::Closure::BlockCaller.new(0, [0]) {}
1593
- handler.DragBroken = Fiddle::Closure::BlockCaller.new(0, [0]) {}
1594
- handler.KeyEvent = Fiddle::Closure::BlockCaller.new(0, [0]) {}
1085
+ [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 1 (shortcut syntax declarative retained mode):
1595
1086
 
1596
- box = UI.new_vertical_box
1597
- UI.box_set_padded(box, 1)
1598
- UI.box_append(box, area, 1)
1087
+ [examples/basic_area.rb](/examples/basic_area.rb)
1599
1088
 
1600
- main_window = UI.new_window('Basic Area', 400, 400, 1)
1601
- UI.window_set_margined(main_window, 1)
1602
- UI.window_set_child(main_window, box)
1089
+ [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 2 (shortcut syntax semi-declarative immediate mode `on_draw` dynamic `path` approach):
1603
1090
 
1604
- UI.window_on_closing(main_window) do
1605
- UI.control_destroy(main_window)
1606
- UI.quit
1607
- 0
1608
- end
1609
- UI.control_show(main_window)
1091
+ [examples/basic_area2.rb](/examples/basic_area2.rb)
1610
1092
 
1611
- UI.main
1612
- UI.quit
1613
- ```
1093
+ [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 3 (explicit libui syntax declarative retained mode):
1614
1094
 
1615
- [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
1095
+ [examples/basic_area3.rb](/examples/basic_area3.rb)
1616
1096
 
1617
- ```ruby
1618
- require 'glimmer-dsl-libui'
1097
+ [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 4 (explicit libui syntax semi-declarative immediate mode `on_draw` dynamic `path` approach):
1619
1098
 
1620
- include Glimmer
1621
-
1622
- window('Basic Area', 400, 400) {
1623
- margined true
1624
-
1625
- vertical_box {
1626
- area {
1627
- path { # a stable path is added declaratively
1628
- rectangle(0, 0, 400, 400)
1629
-
1630
- fill r: 102, g: 102, b: 204, a: 1.0
1631
- }
1632
- }
1633
- }
1634
- }.show
1635
- ```
1636
-
1637
- [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 2 (semi-declarative `on_draw` dynamic `path` approach):
1638
-
1639
- ```ruby
1640
- require 'glimmer-dsl-libui'
1641
-
1642
- include Glimmer
1643
-
1644
- window('Basic Area', 400, 400) {
1645
- margined true
1646
-
1647
- vertical_box {
1648
- area {
1649
- on_draw do |area_draw_params|
1650
- path { # a dynamic path is added semi-declaratively inside on_draw block
1651
- rectangle(0, 0, 400, 400)
1652
-
1653
- fill r: 102, g: 102, b: 204, a: 1.0
1654
- }
1655
- end
1656
- }
1657
- }
1658
- }.show
1659
- ```
1099
+ [examples/basic_area4.rb](/examples/basic_area4.rb)
1660
1100
 
1661
1101
  ## Basic Scrolling Area
1662
1102
 
@@ -2066,122 +1506,6 @@ Mac | Windows | Linux
2066
1506
  ----|---------|------
2067
1507
  ![glimmer-dsl-libui-mac-basic-draw-text.png](/images/glimmer-dsl-libui-mac-basic-draw-text.png) | ![glimmer-dsl-libui-windows-basic-draw-text.png](/images/glimmer-dsl-libui-windows-basic-draw-text.png) | ![glimmer-dsl-libui-linux-basic-draw-text.png](/images/glimmer-dsl-libui-linux-basic-draw-text.png)
2068
1508
 
2069
- [LibUI](https://github.com/kojix2/LibUI) Original Version:
2070
-
2071
- ```ruby
2072
- require 'libui'
2073
-
2074
- UI = LibUI
2075
-
2076
- UI.init
2077
-
2078
- handler = UI::FFI::AreaHandler.malloc
2079
- area = UI.new_area(handler)
2080
-
2081
- # Michael Ende (1929-1995)
2082
- # The Neverending Story is a fantasy novel by German writer Michael Ende,
2083
- # The English version, translated by Ralph Manheim, was published in 1983.
2084
-
2085
- TITLE = 'Michael Ende (1929-1995) The Neverending Story'
2086
-
2087
- str1 = \
2088
- ' At last Ygramul sensed that something was coming toward ' \
2089
- 'her. With the speed of lightning, she turned about, confronting ' \
2090
- 'Atreyu with an enormous steel-blue face. Her single eye had a ' \
2091
- 'vertical pupil, which stared at Atreyu with inconceivable malignancy. '
2092
-
2093
- str2 = \
2094
- ' A cry of fear escaped Bastian. '
2095
-
2096
- str3 = \
2097
- ' A cry of terror passed through the ravine and echoed from ' \
2098
- 'side to side. Ygramul turned her eye to left and right, to see if ' \
2099
- 'someone else had arrived, for that sound could not have been ' \
2100
- 'made by the boy who stood there as though paralyzed with ' \
2101
- 'horror. '
2102
-
2103
- str4 = \
2104
- ' Could she have heard my cry? Bastion wondered in alarm. ' \
2105
- "But that's not possible. "
2106
-
2107
- str5 = \
2108
- ' And then Atreyu heard Ygramuls voice. It was very high ' \
2109
- 'and slightly hoarse, not at all the right kind of voice for that ' \
2110
- 'enormous face. Her lips did not move as she spoke. It was the ' \
2111
- 'buzzing of a great swarm of hornets that shaped itself into ' \
2112
- 'words. '
2113
-
2114
- str = ''
2115
- attr_str = UI.new_attributed_string(str)
2116
-
2117
- def attr_str.append(what, color)
2118
- case color
2119
- when :red
2120
- color_attribute = UI.new_color_attribute(0.0, 0.5, 0.0, 0.7)
2121
- when :green
2122
- color_attribute = UI.new_color_attribute(0.5, 0.0, 0.25, 0.7)
2123
- end
2124
- start = UI.attributed_string_len(self)
2125
- UI.attributed_string_append_unattributed(self, what)
2126
- UI.attributed_string_set_attribute(self, color_attribute, start, start + what.size)
2127
- UI.attributed_string_append_unattributed(self, "\n\n")
2128
- end
2129
-
2130
- attr_str.append(str1, :green)
2131
- attr_str.append(str2, :red)
2132
- attr_str.append(str3, :green)
2133
- attr_str.append(str4, :red)
2134
- attr_str.append(str5, :green)
2135
-
2136
- Georgia = 'Georgia'
2137
-
2138
- handler_draw_event = Fiddle::Closure::BlockCaller.new(0, [1, 1, 1]) do |_, _, adp|
2139
- area_draw_params = UI::FFI::AreaDrawParams.new(adp)
2140
- default_font = UI::FFI::FontDescriptor.malloc
2141
- default_font.Family = Georgia
2142
- default_font.Size = 13
2143
- default_font.Weight = 500
2144
- default_font.Italic = 0
2145
- default_font.Stretch = 4
2146
- params = UI::FFI::DrawTextLayoutParams.malloc
2147
-
2148
- # UI.font_button_font(font_button, default_font)
2149
- params.String = attr_str
2150
- params.DefaultFont = default_font
2151
- params.Width = area_draw_params.AreaWidth
2152
- params.Align = 0
2153
- text_layout = UI.draw_new_text_layout(params)
2154
- UI.draw_text(area_draw_params.Context, text_layout, 0, 0)
2155
- UI.draw_free_text_layout(text_layout)
2156
- end
2157
-
2158
- handler.Draw = handler_draw_event
2159
- # Assigning to local variables
2160
- # This is intended to protect Fiddle::Closure from garbage collection.
2161
- handler.MouseEvent = (c1 = Fiddle::Closure::BlockCaller.new(0, [0]) {})
2162
- handler.MouseCrossed = (c2 = Fiddle::Closure::BlockCaller.new(0, [0]) {})
2163
- handler.DragBroken = (c3 = Fiddle::Closure::BlockCaller.new(0, [0]) {})
2164
- handler.KeyEvent = (c4 = Fiddle::Closure::BlockCaller.new(0, [0]) {})
2165
-
2166
- box = UI.new_vertical_box
2167
- UI.box_set_padded(box, 1)
2168
- UI.box_append(box, area, 1)
2169
-
2170
- main_window = UI.new_window(TITLE, 600, 400, 1)
2171
- UI.window_set_margined(main_window, 1)
2172
- UI.window_set_child(main_window, box)
2173
-
2174
- UI.window_on_closing(main_window) do
2175
- UI.control_destroy(main_window)
2176
- UI.quit
2177
- 0
2178
- end
2179
- UI.control_show(main_window)
2180
-
2181
- UI.main
2182
- UI.quit
2183
- ```
2184
-
2185
1509
  [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
2186
1510
 
2187
1511
  ```ruby