libui_paradise 0.1.49
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of libui_paradise might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/README.md +1505 -0
- data/doc/README.gen +1252 -0
- data/doc/SNIPPETS.md +221 -0
- data/doc/TODO.md +14 -0
- data/lib/libui_paradise/autoinclude.rb +9 -0
- data/lib/libui_paradise/domain_specific_language/README.md +5 -0
- data/lib/libui_paradise/domain_specific_language/button.yml +7 -0
- data/lib/libui_paradise/examples/001_basic_button_example.rb +17 -0
- data/lib/libui_paradise/examples/002_basic_table_image.rb +92 -0
- data/lib/libui_paradise/examples/003_font_button.rb +34 -0
- data/lib/libui_paradise/examples/004_date_time_picker.rb +31 -0
- data/lib/libui_paradise/examples/005_msg_box_error.rb +25 -0
- data/lib/libui_paradise/examples/006_histogram.rb +193 -0
- data/lib/libui_paradise/examples/007_combo_box_example.rb +41 -0
- data/lib/libui_paradise/examples/008_simple_notepad_example.rb +23 -0
- data/lib/libui_paradise/examples/009_checkbox_example.rb +82 -0
- data/lib/libui_paradise/examples/010_grid_example.rb +26 -0
- data/lib/libui_paradise/examples/011_fancy_text_example.rb +21 -0
- data/lib/libui_paradise/examples/012_control_gallery.rb +180 -0
- data/lib/libui_paradise/examples/013_midi_player.rb +91 -0
- data/lib/libui_paradise/examples/014_basic_draw_text.rb +134 -0
- data/lib/libui_paradise/examples/015_font_example.rb +91 -0
- data/lib/libui_paradise/examples/016_search_entry_example.rb +16 -0
- data/lib/libui_paradise/examples/017_tabs_example.rb +22 -0
- data/lib/libui_paradise/examples/018_image_example.rb +82 -0
- data/lib/libui_paradise/examples/019_open_file_button_example.rb +24 -0
- data/lib/libui_paradise/examples/020_unicode_text_example.rb +28 -0
- data/lib/libui_paradise/examples/021_spinbutton_example.rb +25 -0
- data/lib/libui_paradise/examples/022_text_example.rb +16 -0
- data/lib/libui_paradise/examples/023_parse_config_file_example.config +6 -0
- data/lib/libui_paradise/examples/023_parse_config_file_example.rb +13 -0
- data/lib/libui_paradise/examples/024_text_view_example.rb +14 -0
- data/lib/libui_paradise/examples/025_scrolling_area.rb +16 -0
- data/lib/libui_paradise/examples/026_colour_button.rb +51 -0
- data/lib/libui_paradise/examples/027_form_example.rb +37 -0
- data/lib/libui_paradise/examples/028_password_entry_example.rb +17 -0
- data/lib/libui_paradise/examples/029_two_buttons_showing_how_to_enable_and_disable_them.rb +32 -0
- data/lib/libui_paradise/examples/030_table_example.rb +51 -0
- data/lib/libui_paradise/experimental/dsl.rb +17 -0
- data/lib/libui_paradise/extensions/extensions.rb +25 -0
- data/lib/libui_paradise/extensions/hash_fiddle_pointer_widgets.rb +129 -0
- data/lib/libui_paradise/extensions/misc.rb +309 -0
- data/lib/libui_paradise/fiddle/pointer.rb +841 -0
- data/lib/libui_paradise/images/LIBUI_PARADISE_LOGO.png +0 -0
- data/lib/libui_paradise/images/README.md +2 -0
- data/lib/libui_paradise/images/form_example.png +0 -0
- data/lib/libui_paradise/libui_classes/area_handler.rb +52 -0
- data/lib/libui_paradise/libui_classes/button.rb +82 -0
- data/lib/libui_paradise/libui_classes/checkbox.rb +37 -0
- data/lib/libui_paradise/libui_classes/color_button.rb +44 -0
- data/lib/libui_paradise/libui_classes/combobox.rb +55 -0
- data/lib/libui_paradise/libui_classes/editable_combobox.rb +51 -0
- data/lib/libui_paradise/libui_classes/entry.rb +80 -0
- data/lib/libui_paradise/libui_classes/font.rb +78 -0
- data/lib/libui_paradise/libui_classes/font_button.rb +40 -0
- data/lib/libui_paradise/libui_classes/grid.rb +55 -0
- data/lib/libui_paradise/libui_classes/hbox.rb +98 -0
- data/lib/libui_paradise/libui_classes/horizontal_separator.rb +41 -0
- data/lib/libui_paradise/libui_classes/image.rb +82 -0
- data/lib/libui_paradise/libui_classes/label.rb +83 -0
- data/lib/libui_paradise/libui_classes/menu.rb +36 -0
- data/lib/libui_paradise/libui_classes/msg_box.rb +97 -0
- data/lib/libui_paradise/libui_classes/msg_box_error.rb +49 -0
- data/lib/libui_paradise/libui_classes/multiline_entry.rb +59 -0
- data/lib/libui_paradise/libui_classes/non_wrapping_multiline_entry.rb +41 -0
- data/lib/libui_paradise/libui_classes/open_file.rb +42 -0
- data/lib/libui_paradise/libui_classes/password_entry.rb +49 -0
- data/lib/libui_paradise/libui_classes/progressbar.rb +41 -0
- data/lib/libui_paradise/libui_classes/radio_buttons.rb +36 -0
- data/lib/libui_paradise/libui_classes/scrolling_area.rb +85 -0
- data/lib/libui_paradise/libui_classes/search_entry.rb +36 -0
- data/lib/libui_paradise/libui_classes/spinbox.rb +55 -0
- data/lib/libui_paradise/libui_classes/tab.rb +39 -0
- data/lib/libui_paradise/libui_classes/table.rb +45 -0
- data/lib/libui_paradise/libui_classes/text_layout.rb +42 -0
- data/lib/libui_paradise/libui_classes/vbox.rb +51 -0
- data/lib/libui_paradise/libui_classes/window.rb +167 -0
- data/lib/libui_paradise/project/project.rb +26 -0
- data/lib/libui_paradise/prototype/README.md +3 -0
- data/lib/libui_paradise/prototype/prototype.rb +101 -0
- data/lib/libui_paradise/requires/require_the_libui_classes.rb +26 -0
- data/lib/libui_paradise/requires/require_the_libui_paradise_project.rb +11 -0
- data/lib/libui_paradise/version/version.rb +17 -0
- data/lib/libui_paradise.rb +1 -0
- data/libui_paradise.gemspec +49 -0
- 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
|