libui_paradise 0.1.49

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.

Potentially problematic release.


This version of libui_paradise might be problematic. Click here for more details.

Files changed (87) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +1505 -0
  3. data/doc/README.gen +1252 -0
  4. data/doc/SNIPPETS.md +221 -0
  5. data/doc/TODO.md +14 -0
  6. data/lib/libui_paradise/autoinclude.rb +9 -0
  7. data/lib/libui_paradise/domain_specific_language/README.md +5 -0
  8. data/lib/libui_paradise/domain_specific_language/button.yml +7 -0
  9. data/lib/libui_paradise/examples/001_basic_button_example.rb +17 -0
  10. data/lib/libui_paradise/examples/002_basic_table_image.rb +92 -0
  11. data/lib/libui_paradise/examples/003_font_button.rb +34 -0
  12. data/lib/libui_paradise/examples/004_date_time_picker.rb +31 -0
  13. data/lib/libui_paradise/examples/005_msg_box_error.rb +25 -0
  14. data/lib/libui_paradise/examples/006_histogram.rb +193 -0
  15. data/lib/libui_paradise/examples/007_combo_box_example.rb +41 -0
  16. data/lib/libui_paradise/examples/008_simple_notepad_example.rb +23 -0
  17. data/lib/libui_paradise/examples/009_checkbox_example.rb +82 -0
  18. data/lib/libui_paradise/examples/010_grid_example.rb +26 -0
  19. data/lib/libui_paradise/examples/011_fancy_text_example.rb +21 -0
  20. data/lib/libui_paradise/examples/012_control_gallery.rb +180 -0
  21. data/lib/libui_paradise/examples/013_midi_player.rb +91 -0
  22. data/lib/libui_paradise/examples/014_basic_draw_text.rb +134 -0
  23. data/lib/libui_paradise/examples/015_font_example.rb +91 -0
  24. data/lib/libui_paradise/examples/016_search_entry_example.rb +16 -0
  25. data/lib/libui_paradise/examples/017_tabs_example.rb +22 -0
  26. data/lib/libui_paradise/examples/018_image_example.rb +82 -0
  27. data/lib/libui_paradise/examples/019_open_file_button_example.rb +24 -0
  28. data/lib/libui_paradise/examples/020_unicode_text_example.rb +28 -0
  29. data/lib/libui_paradise/examples/021_spinbutton_example.rb +25 -0
  30. data/lib/libui_paradise/examples/022_text_example.rb +16 -0
  31. data/lib/libui_paradise/examples/023_parse_config_file_example.config +6 -0
  32. data/lib/libui_paradise/examples/023_parse_config_file_example.rb +13 -0
  33. data/lib/libui_paradise/examples/024_text_view_example.rb +14 -0
  34. data/lib/libui_paradise/examples/025_scrolling_area.rb +16 -0
  35. data/lib/libui_paradise/examples/026_colour_button.rb +51 -0
  36. data/lib/libui_paradise/examples/027_form_example.rb +37 -0
  37. data/lib/libui_paradise/examples/028_password_entry_example.rb +17 -0
  38. data/lib/libui_paradise/examples/029_two_buttons_showing_how_to_enable_and_disable_them.rb +32 -0
  39. data/lib/libui_paradise/examples/030_table_example.rb +51 -0
  40. data/lib/libui_paradise/experimental/dsl.rb +17 -0
  41. data/lib/libui_paradise/extensions/extensions.rb +25 -0
  42. data/lib/libui_paradise/extensions/hash_fiddle_pointer_widgets.rb +129 -0
  43. data/lib/libui_paradise/extensions/misc.rb +309 -0
  44. data/lib/libui_paradise/fiddle/pointer.rb +841 -0
  45. data/lib/libui_paradise/images/LIBUI_PARADISE_LOGO.png +0 -0
  46. data/lib/libui_paradise/images/README.md +2 -0
  47. data/lib/libui_paradise/images/form_example.png +0 -0
  48. data/lib/libui_paradise/libui_classes/area_handler.rb +52 -0
  49. data/lib/libui_paradise/libui_classes/button.rb +82 -0
  50. data/lib/libui_paradise/libui_classes/checkbox.rb +37 -0
  51. data/lib/libui_paradise/libui_classes/color_button.rb +44 -0
  52. data/lib/libui_paradise/libui_classes/combobox.rb +55 -0
  53. data/lib/libui_paradise/libui_classes/editable_combobox.rb +51 -0
  54. data/lib/libui_paradise/libui_classes/entry.rb +80 -0
  55. data/lib/libui_paradise/libui_classes/font.rb +78 -0
  56. data/lib/libui_paradise/libui_classes/font_button.rb +40 -0
  57. data/lib/libui_paradise/libui_classes/grid.rb +55 -0
  58. data/lib/libui_paradise/libui_classes/hbox.rb +98 -0
  59. data/lib/libui_paradise/libui_classes/horizontal_separator.rb +41 -0
  60. data/lib/libui_paradise/libui_classes/image.rb +82 -0
  61. data/lib/libui_paradise/libui_classes/label.rb +83 -0
  62. data/lib/libui_paradise/libui_classes/menu.rb +36 -0
  63. data/lib/libui_paradise/libui_classes/msg_box.rb +97 -0
  64. data/lib/libui_paradise/libui_classes/msg_box_error.rb +49 -0
  65. data/lib/libui_paradise/libui_classes/multiline_entry.rb +59 -0
  66. data/lib/libui_paradise/libui_classes/non_wrapping_multiline_entry.rb +41 -0
  67. data/lib/libui_paradise/libui_classes/open_file.rb +42 -0
  68. data/lib/libui_paradise/libui_classes/password_entry.rb +49 -0
  69. data/lib/libui_paradise/libui_classes/progressbar.rb +41 -0
  70. data/lib/libui_paradise/libui_classes/radio_buttons.rb +36 -0
  71. data/lib/libui_paradise/libui_classes/scrolling_area.rb +85 -0
  72. data/lib/libui_paradise/libui_classes/search_entry.rb +36 -0
  73. data/lib/libui_paradise/libui_classes/spinbox.rb +55 -0
  74. data/lib/libui_paradise/libui_classes/tab.rb +39 -0
  75. data/lib/libui_paradise/libui_classes/table.rb +45 -0
  76. data/lib/libui_paradise/libui_classes/text_layout.rb +42 -0
  77. data/lib/libui_paradise/libui_classes/vbox.rb +51 -0
  78. data/lib/libui_paradise/libui_classes/window.rb +167 -0
  79. data/lib/libui_paradise/project/project.rb +26 -0
  80. data/lib/libui_paradise/prototype/README.md +3 -0
  81. data/lib/libui_paradise/prototype/prototype.rb +101 -0
  82. data/lib/libui_paradise/requires/require_the_libui_classes.rb +26 -0
  83. data/lib/libui_paradise/requires/require_the_libui_paradise_project.rb +11 -0
  84. data/lib/libui_paradise/version/version.rb +17 -0
  85. data/lib/libui_paradise.rb +1 -0
  86. data/libui_paradise.gemspec +49 -0
  87. metadata +164 -0
@@ -0,0 +1,309 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'libui_paradise/extensions/misc.rb
6
+ # =========================================================================== #
7
+ module LibuiParadise
8
+
9
+ module Extensions # === LibuiParadise::Extensions
10
+
11
+ # ========================================================================= #
12
+ # === COLOUR_BLUE
13
+ # ========================================================================= #
14
+ COLOUR_BLUE = 0x1E90FF
15
+
16
+ # ========================================================================= #
17
+ # === is_on_roebe?
18
+ # ========================================================================= #
19
+ def is_on_roebe?
20
+ ENV['IS_ROEBE'].to_s == '1'
21
+ end
22
+
23
+ # ========================================================================= #
24
+ # === ui_sync_connect
25
+ #
26
+ # This method can connect two widgets: the first one should be a
27
+ # combo-box, and the second one a ui-entry.
28
+ # ========================================================================= #
29
+ def ui_sync_connect(
30
+ widget1, widget2
31
+ )
32
+ combobox_selected_callback = proc { |pointer|
33
+ widget2.set_text(
34
+ selected?(pointer)
35
+ )
36
+ }
37
+ UI.combobox_on_selected(
38
+ widget1, combobox_selected_callback, nil
39
+ )
40
+ end; alias sync_connect ui_sync_connect # === sync_connect
41
+
42
+ # ========================================================================= #
43
+ # === try_to_parse_this_config_file
44
+ #
45
+ # This method can be used to parse a .config file for data it stores.
46
+ #
47
+ # The .config file must have "width:", "height:" and "title:" settings.
48
+ # ========================================================================= #
49
+ def try_to_parse_this_config_file(i)
50
+ if File.exist? i
51
+ dataset = File.readlines(i)
52
+ width = dataset.select {|line| line.include? 'width:' }.first.
53
+ split(':').last.strip.to_i
54
+ height = dataset.select {|line| line.include? 'height:' }.first.
55
+ split(':').last.strip.to_i
56
+ title = dataset.select {|line| line.include? 'title:' }.first.
57
+ split(':').last.strip
58
+ window = LibuiParadise.window(title, width, height)
59
+ return window
60
+ else
61
+ e 'No file exists at `'+i+'`.'
62
+ end
63
+ end; alias parse_this_config_file try_to_parse_this_config_file # === parse_this_config_file
64
+
65
+ # ========================================================================= #
66
+ # === abort_on_exception
67
+ # ========================================================================= #
68
+ def abort_on_exception
69
+ Thread.abort_on_exception
70
+ end
71
+
72
+ # ========================================================================= #
73
+ # === create_skeleton_then_connect_skeleton
74
+ # ========================================================================= #
75
+ def create_skeleton_then_connect_skeleton
76
+ create_skeleton
77
+ connect_skeleton
78
+ end
79
+
80
+ # ========================================================================= #
81
+ # === ui_draw_text_layout_params
82
+ # ========================================================================= #
83
+ def ui_draw_text_layout_params
84
+ return UI::FFI::DrawTextLayoutParams.malloc
85
+ end
86
+
87
+ # ========================================================================= #
88
+ # === LibuiParadise::Extensions.set_title
89
+ #
90
+ # Simpler window-set-title functionality.
91
+ # ========================================================================= #
92
+ def self.set_title(
93
+ this_title, main_window = MAIN_WINDOW
94
+ )
95
+ window_set_title(main_window, this_title)
96
+ end
97
+
98
+ # ========================================================================= #
99
+ # === LibuiParadise::Extensions.hello_world
100
+ #
101
+ # This is merely an ad-hoc test.
102
+ # ========================================================================= #
103
+ def self.hello_world
104
+ e 'Hello world!'
105
+ end
106
+
107
+ # ========================================================================= #
108
+ # === left_arrow?
109
+ # ========================================================================= #
110
+ def left_arrow?
111
+ ui_text('→')
112
+ end
113
+
114
+ # ========================================================================= #
115
+ # === append_this_array_to_that_combobox
116
+ # ========================================================================= #
117
+ def append_this_array_to_that_combobox(
118
+ this_array,
119
+ that_combobox
120
+ )
121
+ this_array.each {|this_entry|
122
+ UI.combobox_append(that_combobox, this_entry)
123
+ }
124
+ end
125
+
126
+ # ========================================================================= #
127
+ # === use_gtk3?
128
+ # ========================================================================= #
129
+ def use_gtk3?
130
+ Object.const_defined?(:Gtk)
131
+ end; alias use_gtk? use_gtk3? # === use_gtk?
132
+
133
+ # ========================================================================= #
134
+ # === new_brush
135
+ # ========================================================================= #
136
+ def new_brush
137
+ UI::FFI::DrawBrush.malloc
138
+ end
139
+
140
+ # ========================================================================= #
141
+ # === exit_from
142
+ #
143
+ # This method essentially combines UI.control_destroy() and UI.quit(
144
+ # into one method.
145
+ # ========================================================================= #
146
+ def exit_from(
147
+ main_window = ::LibuiParadise::Extensions.main_window?
148
+ )
149
+ UI.control_destroy(main_window)
150
+ UI.quit
151
+ 0
152
+ end
153
+
154
+ # ========================================================================= #
155
+ # === main_then_quit
156
+ # ========================================================================= #
157
+ def main_then_quit
158
+ UI.main
159
+ UI.quit
160
+ end
161
+
162
+ # ========================================================================= #
163
+ # === close_properly
164
+ # ========================================================================= #
165
+ def close_properly(
166
+ main_window = LibuiParadise::Extensions.main_window?
167
+ )
168
+ UI.window_on_closing(main_window) {
169
+ UI.exit_from(main_window)
170
+ }
171
+ end; alias simple_exit close_properly # === simple_exit
172
+
173
+ # ========================================================================= #
174
+ # === LibuiParadise::Extensions.register_sigint
175
+ # ========================================================================= #
176
+ def self.register_sigint
177
+ Signal.trap('SIGINT') { exit }
178
+ end
179
+
180
+ # ========================================================================= #
181
+ # === LibuiParadise::Extensions.initializer
182
+ # ========================================================================= #
183
+ def self.initializer
184
+ LibuiParadise::Extensions.register_sigint
185
+ Object.const_set('UI', LibUI) # This is equal to: UI = LibUI
186
+ UI.extend(LibuiParadise::Extensions) # This call will also trigger the extended-hook.
187
+ end
188
+
189
+ # ========================================================================= #
190
+ # === LibuiParadise::Extensions.extended
191
+ #
192
+ # This method taps into the extended-hook - see the code in the
193
+ # method shown above this method.
194
+ #
195
+ # The purpose of this hook is to automatically call .init. This saves
196
+ # us one line of code.
197
+ #
198
+ # In regular LibUI code this is equal to:
199
+ #
200
+ # UI.init
201
+ #
202
+ # ========================================================================= #
203
+ def self.extended(i)
204
+ i.init
205
+ end
206
+
207
+ # ========================================================================= #
208
+ # === assumed_height?
209
+ # ========================================================================= #
210
+ def assumed_height?
211
+ return_the_resolution_using_xrandr.split('x').last.to_i
212
+ end; alias assumed_max_height? assumed_height? # === assumed_max_height?
213
+
214
+ # ========================================================================= #
215
+ # === assumed_width?
216
+ # ========================================================================= #
217
+ def assumed_width?
218
+ return_the_resolution_using_xrandr.split('x').first.to_i
219
+ end; alias assumed_max_width? assumed_width? # === assumed_max_width?
220
+
221
+ # ========================================================================= #
222
+ # === set_width
223
+ # ========================================================================= #
224
+ def set_width(i = 1024)
225
+ if i.is_a?(String) and i.include?('%')
226
+ # ===================================================================== #
227
+ # In this case we have to modify this a bit.
228
+ # ===================================================================== #
229
+ max_width = assumed_max_width?
230
+ i = (max_width.to_f * i.to_i) / 100.0
231
+ end
232
+ i = i.to_i
233
+ @width = i
234
+ end
235
+
236
+ # ========================================================================= #
237
+ # === set_title
238
+ # ========================================================================= #
239
+ def set_title(i)
240
+ @title = i
241
+ end
242
+
243
+ # ========================================================================= #
244
+ # === title?
245
+ # ========================================================================= #
246
+ def title?
247
+ @title
248
+ end
249
+
250
+ # ========================================================================= #
251
+ # === set_height
252
+ # ========================================================================= #
253
+ def set_height(i = 800)
254
+ if i.is_a?(String) and i.include?('%')
255
+ # ===================================================================== #
256
+ # In this case we have to modify this a bit.
257
+ # ===================================================================== #
258
+ max_height = assumed_max_height?
259
+ i = (max_height.to_f * i.to_i) / 100.0
260
+ end
261
+ i = i.to_i
262
+ @height = i
263
+ end
264
+
265
+ # ========================================================================= #
266
+ # === width?
267
+ # ========================================================================= #
268
+ def width?
269
+ @width
270
+ end
271
+
272
+ # ========================================================================= #
273
+ # === height?
274
+ # ========================================================================= #
275
+ def height?
276
+ @height
277
+ end
278
+
279
+ # ========================================================================= #
280
+ # === return_the_resolution_using_xrandr
281
+ #
282
+ # This method will only work on e. g. Linux.
283
+ #
284
+ # It will then return a String such as "1920x1080".
285
+ # ========================================================================= #
286
+ def return_the_resolution_using_xrandr
287
+ _ = '800x600' # This is a generic failsafe value.
288
+ begin
289
+ _ = `xrandr`.split("\n").select {|line|
290
+ line.include? '*+'
291
+ }.first.strip.squeeze(' ').split(' ').first.to_s
292
+ rescue Errno::ENOENT # Rescue for Windows systems.
293
+ end
294
+ return _ # This will yield e. g. "1920x1080"
295
+ end
296
+
297
+ # ========================================================================= #
298
+ # === ui_table_params_malloc
299
+ # ========================================================================= #
300
+ def ui_table_params_malloc(optional_model = nil)
301
+ _ = LibUI::FFI::TableParams.malloc
302
+ if optional_model
303
+ _.Model = optional_model
304
+ _.RowBackgroundColorModelColumn = -1
305
+ end
306
+ return _
307
+ end
308
+
309
+ end; end