libui_paradise 0.2.49 → 0.4.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +405 -259
- data/bin/libui_message +7 -0
- data/doc/README.gen +356 -131
- data/doc/todo/todo.md +14 -5
- data/lib/libui_paradise/autoinclude.rb +2 -1
- data/lib/libui_paradise/base/base.rb +51 -62
- data/lib/libui_paradise/base_module/base_module.rb +1514 -0
- data/lib/libui_paradise/colours/colours.rb +14 -2
- data/lib/libui_paradise/domain_specific_language/README.md +6 -0
- data/lib/libui_paradise/examples/complex/002_tabs_example.rb +1 -2
- data/lib/libui_paradise/examples/complex/003_open_file_button_example.rb +3 -5
- data/lib/libui_paradise/examples/complex/006_coloured_boxes_example.rb +2 -2
- data/lib/libui_paradise/examples/complex/007_slider_example.rb +10 -4
- data/lib/libui_paradise/examples/complex/008_radio_button_example.rb +2 -2
- data/lib/libui_paradise/examples/complex/009_separator_example.rb +2 -2
- data/lib/libui_paradise/examples/complex/010_table_example.rb +139 -49
- data/lib/libui_paradise/examples/complex/011_two_buttons_showing_how_to_enable_and_disable_them.rb +2 -1
- data/lib/libui_paradise/examples/complex/012_password_entry_example.rb +1 -1
- data/lib/libui_paradise/examples/complex/013_form_example.rb +1 -1
- data/lib/libui_paradise/examples/complex/014_text_example.rb +1 -1
- data/lib/libui_paradise/examples/complex/015_text_view_example.rb +4 -4
- data/lib/libui_paradise/examples/complex/016_grid_example.rb +20 -11
- data/lib/libui_paradise/examples/complex/017_unicode_text_example.rb +2 -2
- data/lib/libui_paradise/examples/complex/018_spinbutton_example.rb +1 -1
- data/lib/libui_paradise/examples/complex/019_combo_box_example.rb +1 -1
- data/lib/libui_paradise/examples/complex/020_checkbox_example.rb +5 -5
- data/lib/libui_paradise/examples/complex/021_font_example.rb +4 -3
- data/lib/libui_paradise/examples/complex/022_simple_notepad_example.rb +3 -3
- data/lib/libui_paradise/examples/complex/023_msg_box_error.rb +5 -5
- data/lib/libui_paradise/examples/complex/024_parse_config_file_example.rb +2 -2
- data/lib/libui_paradise/examples/complex/025_colour_button.rb +1 -1
- data/lib/libui_paradise/examples/complex/026_basic_table_image.rb +5 -8
- data/lib/libui_paradise/examples/complex/027_basic_button_example.rb +3 -3
- data/lib/libui_paradise/examples/complex/028_try_for_automatic_button_press_event_after_a_delay.rb +4 -5
- data/lib/libui_paradise/examples/complex/029_progressbar_example.rb +4 -5
- data/lib/libui_paradise/examples/complex/030_entry_responds_to_comment_as_synonymous_to_the_enter_key_pressed_example.rb +5 -6
- data/lib/libui_paradise/examples/complex/031_notification_functionality_example.rb +3 -2
- data/lib/libui_paradise/examples/complex/032_simple_window_example.rb +2 -1
- data/lib/libui_paradise/examples/complex/033_daemonize_and_exit_after_delay_example.rb +3 -2
- data/lib/libui_paradise/examples/complex/034_bold_text_example.rb +115 -0
- data/lib/libui_paradise/examples/complex/035_parse_into_table_example.rb +109 -0
- data/lib/libui_paradise/examples/simple/001_open_file_example.rb +1 -1
- data/lib/libui_paradise/examples/simple/002_histogram_example.rb +6 -6
- data/lib/libui_paradise/examples/simple/003_fancy_text_example.rb +80 -43
- data/lib/libui_paradise/examples/simple/005_text_drawing_example.rb +11 -11
- data/lib/libui_paradise/examples/simple/007_control_gallery.rb +21 -14
- data/lib/libui_paradise/examples/simple/009_spectrum.rb +7 -1
- data/lib/libui_paradise/examples/simple/010_font_button.rb +31 -0
- data/lib/libui_paradise/examples/simple/011_simple_notepad.rb +24 -0
- data/lib/libui_paradise/examples/simple/012_table_example.rb +71 -0
- data/lib/libui_paradise/examples/simple/013_scrolling_pane_example.rb +28 -0
- data/lib/libui_paradise/examples/simple/014_simple_entry_example.rb +30 -0
- data/lib/libui_paradise/examples/simple/015_slider_example.rb +32 -0
- data/lib/libui_paradise/fiddle/{pointer.rb → fiddle.rb} +768 -615
- data/lib/libui_paradise/generic_window/generic_window.rb +1 -1
- data/lib/libui_paradise/images/README.md +5 -2
- data/lib/libui_paradise/libui_classes/button.rb +31 -0
- data/lib/libui_paradise/libui_classes/entry.rb +35 -0
- data/lib/libui_paradise/libui_classes/grid.rb +14 -23
- data/lib/libui_paradise/libui_classes/hbox.rb +39 -0
- data/lib/libui_paradise/libui_classes/libui_classes.rb +9 -1595
- data/lib/libui_paradise/libui_classes/msg_box.rb +121 -0
- data/lib/libui_paradise/libui_classes/msg_box_error.rb +41 -0
- data/lib/libui_paradise/libui_classes/slider.rb +28 -0
- data/lib/libui_paradise/libui_classes/spinbox.rb +48 -0
- data/lib/libui_paradise/libui_classes/vbox.rb +38 -0
- data/lib/libui_paradise/project/project.rb +6 -1
- data/lib/libui_paradise/prototype/prototype.rb +8 -10
- data/lib/libui_paradise/requires/require_the_libui_classes.rb +2 -2
- data/lib/libui_paradise/requires/require_the_libui_paradise_project.rb +5 -3
- data/lib/libui_paradise/toplevel_methods/add_to_the_registered_widgets.rb +70 -0
- data/lib/libui_paradise/toplevel_methods/hash_fiddle_pointer_widgets.rb +37 -0
- data/lib/libui_paradise/toplevel_methods/toplevel_counters.rb +83 -0
- data/lib/libui_paradise/toplevel_methods/toplevel_methods.rb +792 -0
- data/lib/libui_paradise/version/version.rb +2 -2
- data/lib/libui_paradise.rb +0 -0
- data/libui_paradise.gemspec +5 -4
- data/test/testing_generic_window.rb +2 -0
- metadata +35 -30
- data/doc/SNIPPETS.md +0 -94
- data/lib/libui_paradise/extensions/counters.rb +0 -58
- data/lib/libui_paradise/extensions/extensions.rb +0 -29
- data/lib/libui_paradise/extensions/hash_fiddle_pointer_widgets.rb +0 -150
- data/lib/libui_paradise/extensions/misc.rb +0 -754
- data/lib/libui_paradise/libui_classes/box.rb +0 -156
- data/lib/libui_paradise/toplevel_methods/misc.rb +0 -13
|
@@ -21,13 +21,31 @@ USE_THIS_FONT = 'Hack' # Or 'Courier New'.
|
|
|
21
21
|
|
|
22
22
|
# =========================================================================== #
|
|
23
23
|
# === append_with_attribute
|
|
24
|
+
#
|
|
25
|
+
# The first argument is the String that is to be appended.
|
|
26
|
+
#
|
|
27
|
+
# To append a bigger font, use something like this:
|
|
28
|
+
#
|
|
29
|
+
# bigger_font = UI.new_size_attribute(62)
|
|
30
|
+
# append_with_attribute(attr_str, 'font size', bigger_font, nil)
|
|
31
|
+
#
|
|
32
|
+
# To append bold text, use:
|
|
33
|
+
#
|
|
34
|
+
# attr1 = LibUI.new_weight_attribute(LibUI::TextWeightBold)
|
|
35
|
+
# append_with_attribute(attr_str, 'font weight', attr1)
|
|
36
|
+
#
|
|
24
37
|
# =========================================================================== #
|
|
25
|
-
def append_with_attribute(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
38
|
+
def append_with_attribute(
|
|
39
|
+
widget,
|
|
40
|
+
use_this_text,
|
|
41
|
+
attr1,
|
|
42
|
+
attr2 # This is rarely needed.
|
|
43
|
+
)
|
|
44
|
+
start_pos = LibUI.attributed_string_len(widget)
|
|
45
|
+
end_pos = start_pos + what.length
|
|
46
|
+
LibUI.attributed_string_append_unattributed(widget, use_this_text)
|
|
47
|
+
LibUI.attributed_string_set_attribute(widget, attr1, start_pos, end_pos)
|
|
48
|
+
LibUI.attributed_string_set_attribute(widget, attr2, start_pos, end_pos) if attr2
|
|
31
49
|
end
|
|
32
50
|
|
|
33
51
|
# =========================================================================== #
|
|
@@ -48,23 +66,27 @@ def make_attribute_string
|
|
|
48
66
|
|
|
49
67
|
# ========================================================================= #
|
|
50
68
|
# === Use a bigger font next
|
|
69
|
+
#
|
|
70
|
+
# The bigger font will be use for the String "font size".
|
|
51
71
|
# ========================================================================= #
|
|
52
|
-
bigger_font = UI.new_size_attribute(
|
|
72
|
+
bigger_font = UI.new_size_attribute(62)
|
|
53
73
|
append_with_attribute(attr_str, 'font size', bigger_font, nil)
|
|
54
|
-
|
|
74
|
+
|
|
75
|
+
LibUI.attributed_string_append_unattributed(attr_str, ', ') # Then append ','.
|
|
55
76
|
|
|
56
77
|
# ========================================================================= #
|
|
57
78
|
# === Make bold text next (bold tag)
|
|
58
79
|
# ========================================================================= #
|
|
59
80
|
attr1 = LibUI.new_weight_attribute(LibUI::TextWeightBold)
|
|
60
81
|
append_with_attribute(attr_str, 'font weight', attr1, nil)
|
|
82
|
+
|
|
61
83
|
LibUI.attributed_string_append_unattributed(attr_str, ', ')
|
|
62
84
|
|
|
63
|
-
attr1 = LibUI.new_italic_attribute(
|
|
85
|
+
attr1 = LibUI.new_italic_attribute(LibUI::TextItalicItalic)
|
|
64
86
|
append_with_attribute(attr_str, 'font italicness', attr1, nil)
|
|
65
87
|
UI.attributed_string_append_unattributed(attr_str, ', ')
|
|
66
88
|
|
|
67
|
-
attr1 = LibUI.new_stretch_attribute(
|
|
89
|
+
attr1 = LibUI.new_stretch_attribute(LibUI::TextStretchCondensed)
|
|
68
90
|
append_with_attribute(attr_str, 'font stretch', attr1, nil)
|
|
69
91
|
UI.attributed_string_append_unattributed(attr_str, ', ')
|
|
70
92
|
|
|
@@ -79,31 +101,31 @@ def make_attribute_string
|
|
|
79
101
|
append_with_attribute(attr_str, 'text background color', attr1, nil)
|
|
80
102
|
UI.attributed_string_append_unattributed(attr_str, ', ')
|
|
81
103
|
|
|
82
|
-
attr1 = UI.new_underline_attribute(
|
|
104
|
+
attr1 = UI.new_underline_attribute(LibUI::UnderlineSingle)
|
|
83
105
|
append_with_attribute(attr_str, 'underline style', attr1, nil)
|
|
84
106
|
UI.attributed_string_append_unattributed(attr_str, ', ')
|
|
85
107
|
|
|
86
108
|
UI.attributed_string_append_unattributed(attr_str, 'and ')
|
|
87
|
-
attr1 = LibUI.new_underline_attribute(
|
|
88
|
-
attr2 = LibUI.new_underline_color_attribute(
|
|
109
|
+
attr1 = LibUI.new_underline_attribute(LibUI::UnderlineDouble)
|
|
110
|
+
attr2 = LibUI.new_underline_color_attribute(LibUI::UnderlineColorCustom, 1.0, 0.0, 0.5, 1.0)
|
|
89
111
|
append_with_attribute(attr_str, 'underline color', attr1, attr2)
|
|
90
112
|
UI.attributed_string_append_unattributed(attr_str, '. ')
|
|
91
113
|
|
|
92
114
|
UI.attributed_string_append_unattributed(attr_str, 'Furthermore, there are attributes allowing for ')
|
|
93
|
-
attr1 = LibUI.new_underline_attribute(
|
|
94
|
-
attr2 = LibUI.new_underline_color_attribute(
|
|
115
|
+
attr1 = LibUI.new_underline_attribute(LibUI::UnderlineSuggestion)
|
|
116
|
+
attr2 = LibUI.new_underline_color_attribute(LibUI::UnderlineColorSpelling, 0, 0, 0, 0)
|
|
95
117
|
append_with_attribute(attr_str, 'special underlines for indicating spelling errors', attr1, attr2)
|
|
96
|
-
|
|
118
|
+
LibUI.attributed_string_append_unattributed(attr_str, ' (and other types of errors) ')
|
|
97
119
|
|
|
98
|
-
|
|
120
|
+
LibUI.attributed_string_append_unattributed(attr_str,
|
|
99
121
|
'and control over OpenType features such as ligatures (for instance, ')
|
|
100
|
-
otf =
|
|
122
|
+
otf = LibUI.new_open_type_features
|
|
101
123
|
UI.open_type_features_add(otf, 'l', 'i', 'g', 'a', 0)
|
|
102
|
-
attr1 =
|
|
124
|
+
attr1 = LibUI.new_features_attribute(otf)
|
|
103
125
|
append_with_attribute(attr_str, 'afford', attr1, nil)
|
|
104
126
|
UI.attributed_string_append_unattributed(attr_str, ' vs. ')
|
|
105
127
|
UI.open_type_features_add(otf, 'l', 'i', 'g', 'a', 1)
|
|
106
|
-
attr1 =
|
|
128
|
+
attr1 = LibUI.new_features_attribute(otf)
|
|
107
129
|
append_with_attribute(attr_str, 'afford', attr1, nil)
|
|
108
130
|
UI.free_open_type_features(otf)
|
|
109
131
|
UI.attributed_string_append_unattributed(attr_str, ").\n")
|
|
@@ -112,30 +134,32 @@ def make_attribute_string
|
|
|
112
134
|
'Use the controls '\
|
|
113
135
|
'opposite to the text '\
|
|
114
136
|
'to control properties of the text.')
|
|
115
|
-
attr_str
|
|
137
|
+
attr_str # And return the String here.
|
|
116
138
|
end
|
|
117
139
|
|
|
118
140
|
# =========================================================================== #
|
|
119
141
|
# === on_font_changed
|
|
120
142
|
# =========================================================================== #
|
|
121
|
-
def on_font_changed(
|
|
122
|
-
UI.area_queue_redraw_all(
|
|
143
|
+
def on_font_changed(i)
|
|
144
|
+
UI.area_queue_redraw_all(i)
|
|
123
145
|
end
|
|
124
146
|
|
|
125
147
|
# =========================================================================== #
|
|
126
148
|
# === on_combobox_selected
|
|
127
149
|
# =========================================================================== #
|
|
128
|
-
def on_combobox_selected(
|
|
129
|
-
UI.area_queue_redraw_all(
|
|
150
|
+
def on_combobox_selected(i)
|
|
151
|
+
UI.area_queue_redraw_all(i)
|
|
130
152
|
end
|
|
131
153
|
|
|
154
|
+
# =========================================================================== #
|
|
132
155
|
# === draw_event
|
|
156
|
+
# =========================================================================== #
|
|
133
157
|
def draw_event(adp, attr_str, font_button, alignment)
|
|
134
158
|
area_draw_params = UI::FFI::AreaDrawParams.new(adp)
|
|
159
|
+
|
|
135
160
|
default_font = UI::FFI::FontDescriptor.malloc
|
|
136
161
|
default_font.to_ptr.free = Fiddle::RUBY_FREE
|
|
137
|
-
|
|
138
|
-
default_font.to_ptr.free = Fiddle::RUBY_FREE
|
|
162
|
+
|
|
139
163
|
params = UI::FFI::DrawTextLayoutParams.malloc
|
|
140
164
|
params.to_ptr.free = Fiddle::RUBY_FREE
|
|
141
165
|
|
|
@@ -145,17 +169,17 @@ def draw_event(adp, attr_str, font_button, alignment)
|
|
|
145
169
|
params.Width = area_draw_params.AreaWidth
|
|
146
170
|
params.Align = UI.combobox_selected(alignment)
|
|
147
171
|
text_layout = UI.draw_new_text_layout(params)
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
172
|
+
LibUI.draw_text(area_draw_params.Context, text_layout, 0, 0)
|
|
173
|
+
LibUI.draw_free_text_layout(text_layout)
|
|
174
|
+
LibUI.free_font_button_font(default_font)
|
|
151
175
|
end
|
|
152
176
|
|
|
153
|
-
|
|
177
|
+
LibUI.init
|
|
154
178
|
|
|
155
179
|
handler = UI::FFI::AreaHandler.malloc
|
|
156
180
|
handler.to_ptr.free = Fiddle::RUBY_FREE
|
|
157
181
|
handler_draw_event = Fiddle::Closure::BlockCaller.new(0, [1, 1, 1]) do |_, _area, adp|
|
|
158
|
-
draw_event(adp, @attr_str, @font_button, @
|
|
182
|
+
draw_event(adp, @attr_str, @font_button, @combobox)
|
|
159
183
|
end
|
|
160
184
|
|
|
161
185
|
handler.Draw = handler_draw_event
|
|
@@ -176,6 +200,9 @@ LibUI.on_should_quit {
|
|
|
176
200
|
# =========================================================================== #
|
|
177
201
|
@attr_str = make_attribute_string
|
|
178
202
|
|
|
203
|
+
# =========================================================================== #
|
|
204
|
+
# Create the main window next:
|
|
205
|
+
# =========================================================================== #
|
|
179
206
|
main_window = LibUI.new_window('Text-Drawing Example', WIDTH, 480, 1)
|
|
180
207
|
LibUI.window_set_margined(main_window, 1)
|
|
181
208
|
LibUI.window_on_closing(main_window) {
|
|
@@ -184,6 +211,9 @@ LibUI.window_on_closing(main_window) {
|
|
|
184
211
|
0
|
|
185
212
|
}
|
|
186
213
|
|
|
214
|
+
# =========================================================================== #
|
|
215
|
+
# Add a hbox:
|
|
216
|
+
# =========================================================================== #
|
|
187
217
|
hbox = LibUI.new_horizontal_box
|
|
188
218
|
LibUI.box_set_padded(hbox, 1)
|
|
189
219
|
LibUI.window_set_child(main_window, hbox)
|
|
@@ -193,28 +223,35 @@ LibUI.box_set_padded(vbox, 1)
|
|
|
193
223
|
LibUI.box_append(hbox, vbox, 0)
|
|
194
224
|
|
|
195
225
|
@font_button = LibUI.new_font_button
|
|
196
|
-
LibUI.font_button_on_changed(@font_button) {
|
|
226
|
+
LibUI.font_button_on_changed(@font_button) {
|
|
227
|
+
# Invoke a method here:
|
|
228
|
+
on_font_changed(@area)
|
|
229
|
+
}
|
|
197
230
|
LibUI.box_append(vbox, @font_button, 0)
|
|
198
231
|
|
|
199
232
|
form = LibUI.new_form
|
|
200
233
|
LibUI.form_set_padded(form, 1)
|
|
201
234
|
LibUI.box_append(vbox, form, 0)
|
|
202
235
|
|
|
236
|
+
# =========================================================================== #
|
|
203
237
|
# Add a combobox entry next.
|
|
204
|
-
# @
|
|
205
|
-
|
|
206
|
-
LibUI.
|
|
207
|
-
LibUI.combobox_append(@
|
|
208
|
-
LibUI.combobox_append(@
|
|
209
|
-
LibUI.
|
|
210
|
-
LibUI.
|
|
211
|
-
LibUI.
|
|
238
|
+
# @combobox = ui_combobox(%w( Left Center Right ))
|
|
239
|
+
# =========================================================================== #
|
|
240
|
+
@combobox = LibUI.new_combobox
|
|
241
|
+
LibUI.combobox_append(@combobox, 'Left')
|
|
242
|
+
LibUI.combobox_append(@combobox, 'Center')
|
|
243
|
+
LibUI.combobox_append(@combobox, 'Right')
|
|
244
|
+
LibUI.combobox_set_selected(@combobox, 0)
|
|
245
|
+
LibUI.combobox_on_selected(@combobox) { on_combobox_selected(@area) }
|
|
246
|
+
LibUI.form_append(form, 'Alignment', @combobox, 0)
|
|
212
247
|
|
|
248
|
+
# =========================================================================== #
|
|
249
|
+
# Add a new area next:
|
|
250
|
+
# =========================================================================== #
|
|
213
251
|
@area = LibUI.new_area(handler)
|
|
214
252
|
LibUI.box_append(hbox, @area, 1)
|
|
215
253
|
|
|
216
254
|
LibUI.control_show(main_window)
|
|
217
255
|
LibUI.main
|
|
218
|
-
|
|
219
256
|
LibUI.free_attributed_string(@attr_str)
|
|
220
|
-
LibUI.uninit
|
|
257
|
+
LibUI.uninit
|
|
@@ -30,15 +30,15 @@ def make_attribute_string
|
|
|
30
30
|
|
|
31
31
|
attr1 = LibUI.new_family_attribute('Courier New')
|
|
32
32
|
append_with_attribute(attr_str, 'font family', attr1, nil)
|
|
33
|
-
|
|
33
|
+
LibUI.attributed_string_append_unattributed(attr_str, ', ')
|
|
34
34
|
|
|
35
35
|
attr1 = LibUI.new_size_attribute(18)
|
|
36
36
|
append_with_attribute(attr_str, 'font size', attr1, nil)
|
|
37
|
-
|
|
37
|
+
LibUI.attributed_string_append_unattributed(attr_str, ', ')
|
|
38
38
|
|
|
39
|
-
attr1 =
|
|
39
|
+
attr1 = LibUI.new_weight_attribute(UI::TextWeightBold)
|
|
40
40
|
append_with_attribute(attr_str, 'font weight', attr1, nil)
|
|
41
|
-
|
|
41
|
+
LibUI.attributed_string_append_unattributed(attr_str, ', ')
|
|
42
42
|
|
|
43
43
|
attr1 = UI.new_italic_attribute(UI::TextItalicItalic)
|
|
44
44
|
append_with_attribute(attr_str, 'font italicness', attr1, nil)
|
|
@@ -66,11 +66,11 @@ def make_attribute_string
|
|
|
66
66
|
append_with_attribute(attr_str, 'underline color', attr1, attr2)
|
|
67
67
|
UI.attributed_string_append_unattributed(attr_str, '. ')
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
LibUI.attributed_string_append_unattributed(attr_str, 'Furthermore, there are attributes allowing for ')
|
|
70
70
|
attr1 = UI.new_underline_attribute(UI::UnderlineSuggestion)
|
|
71
71
|
attr2 = UI.new_underline_color_attribute(UI::UnderlineColorSpelling, 0, 0, 0, 0)
|
|
72
72
|
append_with_attribute(attr_str, 'special underlines for indicating spelling errors', attr1, attr2)
|
|
73
|
-
|
|
73
|
+
LibUI.attributed_string_append_unattributed(attr_str, ' (and other types of errors) ')
|
|
74
74
|
|
|
75
75
|
UI.attributed_string_append_unattributed(attr_str,
|
|
76
76
|
'and control over OpenType features such as ligatures (for instance, ')
|
|
@@ -137,19 +137,19 @@ handler.MouseCrossed = do_nothing
|
|
|
137
137
|
handler.DragBroken = do_nothing
|
|
138
138
|
handler.KeyEvent = key_event
|
|
139
139
|
|
|
140
|
-
UI.on_should_quit
|
|
140
|
+
UI.on_should_quit {
|
|
141
141
|
UI.control_destroy(main_window)
|
|
142
|
-
|
|
142
|
+
}
|
|
143
143
|
|
|
144
144
|
@attr_str = make_attribute_string
|
|
145
145
|
|
|
146
146
|
main_window = UI.new_window('Text-Drawing Example', 640, 480, 1)
|
|
147
147
|
UI.window_set_margined(main_window, 1)
|
|
148
|
-
UI.window_on_closing(main_window)
|
|
148
|
+
UI.window_on_closing(main_window) {
|
|
149
149
|
UI.control_destroy(main_window)
|
|
150
150
|
UI.quit
|
|
151
151
|
0
|
|
152
|
-
|
|
152
|
+
}
|
|
153
153
|
|
|
154
154
|
hbox = UI.new_horizontal_box
|
|
155
155
|
UI.box_set_padded(hbox, 1)
|
|
@@ -173,7 +173,7 @@ UI.combobox_append(@alignment, 'Center')
|
|
|
173
173
|
UI.combobox_append(@alignment, 'Right')
|
|
174
174
|
UI.combobox_set_selected(@alignment, 0)
|
|
175
175
|
UI.combobox_on_selected(@alignment) { on_combobox_selected(@area) }
|
|
176
|
-
|
|
176
|
+
LibUI.form_append(form, 'Alignment', @alignment, 0)
|
|
177
177
|
|
|
178
178
|
@area = LibUI.new_area(handler)
|
|
179
179
|
LibUI.box_append(hbox, @area, 1)
|
|
@@ -80,7 +80,8 @@ end
|
|
|
80
80
|
UI.box_append(inner, checkbox, 0)
|
|
81
81
|
|
|
82
82
|
# Label
|
|
83
|
-
|
|
83
|
+
label = UI.new_label('Label')
|
|
84
|
+
UI.box_append(inner, label, 0)
|
|
84
85
|
|
|
85
86
|
# Separator
|
|
86
87
|
UI.box_append(inner, UI.new_horizontal_separator, 0)
|
|
@@ -150,40 +151,46 @@ UI.combobox_append(cbox, 'combobox Item 1')
|
|
|
150
151
|
UI.combobox_append(cbox, 'combobox Item 2')
|
|
151
152
|
UI.combobox_append(cbox, 'combobox Item 3')
|
|
152
153
|
UI.box_append(inner, cbox, 0)
|
|
153
|
-
UI.combobox_on_selected(cbox)
|
|
154
|
+
UI.combobox_on_selected(cbox) { |ptr|
|
|
154
155
|
puts "New combobox selection: #{UI.combobox_selected(ptr)}"
|
|
155
|
-
|
|
156
|
+
}
|
|
156
157
|
|
|
158
|
+
# =========================================================================== #
|
|
157
159
|
# Editable Combobox
|
|
160
|
+
# =========================================================================== #
|
|
158
161
|
ebox = UI.new_editable_combobox
|
|
159
162
|
UI.editable_combobox_append(ebox, 'Editable Item 1')
|
|
160
163
|
UI.editable_combobox_append(ebox, 'Editable Item 2')
|
|
161
164
|
UI.editable_combobox_append(ebox, 'Editable Item 3')
|
|
162
165
|
UI.box_append(inner, ebox, 0)
|
|
163
166
|
|
|
167
|
+
# =========================================================================== #
|
|
164
168
|
# Radio Buttons
|
|
169
|
+
# =========================================================================== #
|
|
165
170
|
rb = UI.new_radio_buttons
|
|
166
171
|
UI.radio_buttons_append(rb, 'Radio Button 1')
|
|
167
172
|
UI.radio_buttons_append(rb, 'Radio Button 2')
|
|
168
173
|
UI.radio_buttons_append(rb, 'Radio Button 3')
|
|
169
174
|
UI.box_append(inner, rb, 1)
|
|
170
175
|
|
|
176
|
+
# =========================================================================== #
|
|
171
177
|
# Tab
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
178
|
+
# =========================================================================== #
|
|
179
|
+
tab = LibUI.new_tab
|
|
180
|
+
hbox1 = LibUI.new_horizontal_box
|
|
181
|
+
hbox2 = LibUI.new_horizontal_box
|
|
182
|
+
LibUI.tab_append(tab, 'Page 1', hbox1)
|
|
183
|
+
LibUI.tab_append(tab, 'Page 2', hbox2)
|
|
184
|
+
LibUI.tab_append(tab, 'Page 3', UI.new_horizontal_box)
|
|
185
|
+
LibUI.box_append(inner2, tab, 1)
|
|
179
186
|
|
|
180
187
|
# Text Entry
|
|
181
188
|
text_entry = UI.new_entry
|
|
182
|
-
|
|
183
|
-
|
|
189
|
+
LibUI.entry_set_text text_entry, 'Please enter your feelings'
|
|
190
|
+
LibUI.entry_on_changed(text_entry) { |ptr|
|
|
184
191
|
puts "Current textbox data: '#{UI.entry_text(ptr)}'"
|
|
185
|
-
|
|
186
|
-
|
|
192
|
+
}
|
|
193
|
+
LibUI.box_append(hbox1, text_entry, 1)
|
|
187
194
|
|
|
188
195
|
UI.control_show(MAIN_WINDOW)
|
|
189
196
|
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
# =========================================================================== #
|
|
3
3
|
require 'libui'
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
begin
|
|
6
|
+
require 'ffi-portaudio' # https://github.com/nanki/ffi-portaudio
|
|
7
|
+
rescue LoadError
|
|
8
|
+
puts 'Install this: https://github.com/nanki/ffi-portaudio'
|
|
9
|
+
end
|
|
10
|
+
|
|
5
11
|
require 'numo/pocketfft' # https://github.com/yoshoku/numo-pocketfft
|
|
6
12
|
|
|
7
13
|
# =========================================================================== #
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'libui'
|
|
2
|
+
|
|
3
|
+
UI = LibUI
|
|
4
|
+
|
|
5
|
+
UI.init
|
|
6
|
+
|
|
7
|
+
main_window = UI.new_window('Font example', 300, 200, 1)
|
|
8
|
+
|
|
9
|
+
font_button = UI.new_font_button
|
|
10
|
+
font_descriptor = UI::FFI::FontDescriptor.malloc
|
|
11
|
+
font_descriptor.to_ptr.free = Fiddle::RUBY_FREE
|
|
12
|
+
UI.font_button_on_changed(font_button) {
|
|
13
|
+
UI.font_button_font(font_button, font_descriptor) # Add the font_description here.
|
|
14
|
+
p family: font_descriptor.Family.to_s,
|
|
15
|
+
size: font_descriptor.Size,
|
|
16
|
+
weight: font_descriptor.Weight,
|
|
17
|
+
italic: font_descriptor.Italic,
|
|
18
|
+
stretch: font_descriptor.Stretch
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
UI.window_on_closing(main_window) do
|
|
22
|
+
puts 'Bye Bye'
|
|
23
|
+
UI.quit
|
|
24
|
+
1
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
UI.window_set_child(main_window, font_button)
|
|
28
|
+
UI.control_show(main_window)
|
|
29
|
+
|
|
30
|
+
UI.main
|
|
31
|
+
UI.uninit
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'libui'
|
|
4
|
+
|
|
5
|
+
UI = LibUI
|
|
6
|
+
|
|
7
|
+
UI.init
|
|
8
|
+
|
|
9
|
+
main_window = UI.new_window('Notepad', 500, 300, 1)
|
|
10
|
+
UI.window_on_closing(main_window) do
|
|
11
|
+
puts 'Bye Bye'
|
|
12
|
+
UI.quit
|
|
13
|
+
1
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
vbox = UI.new_vertical_box
|
|
17
|
+
UI.window_set_child(main_window, vbox)
|
|
18
|
+
|
|
19
|
+
entry = UI.new_non_wrapping_multiline_entry
|
|
20
|
+
UI.box_append(vbox, entry, 1)
|
|
21
|
+
|
|
22
|
+
UI.control_show(main_window)
|
|
23
|
+
UI.main
|
|
24
|
+
UI.uninit
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# =========================================================================== #
|
|
2
|
+
# === 012_table_example.rb
|
|
3
|
+
# =========================================================================== #
|
|
4
|
+
|
|
5
|
+
# =========================================================================== #
|
|
6
|
+
# Taken from kojix2' upstream code.
|
|
7
|
+
# =========================================================================== #
|
|
8
|
+
require 'libui'
|
|
9
|
+
|
|
10
|
+
alias e puts
|
|
11
|
+
|
|
12
|
+
UI = LibUI
|
|
13
|
+
|
|
14
|
+
LibUI.init
|
|
15
|
+
|
|
16
|
+
main_window = LibUI.new_window('Animal sounds', 300, 200, 1)
|
|
17
|
+
|
|
18
|
+
hbox = LibUI.new_horizontal_box
|
|
19
|
+
LibUI.window_set_child(main_window, hbox)
|
|
20
|
+
|
|
21
|
+
data = [
|
|
22
|
+
%w( cat meow ),
|
|
23
|
+
%w( dog woof ),
|
|
24
|
+
%w( chicken cock-a-doodle-doo ),
|
|
25
|
+
%w( horse neigh ),
|
|
26
|
+
%w( cow moo )
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
# Protects BlockCaller objects from garbage collection.
|
|
30
|
+
@block_callers = []
|
|
31
|
+
def rbcallback(*args, &block)
|
|
32
|
+
args << [0] if args.size == 1 # Argument types are omitted
|
|
33
|
+
block_caller = Fiddle::Closure::BlockCaller.new(*args, &block)
|
|
34
|
+
@block_callers << block_caller
|
|
35
|
+
block_caller
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
model_handler = UI::FFI::TableModelHandler.malloc
|
|
39
|
+
model_handler.to_ptr.free = Fiddle::RUBY_FREE
|
|
40
|
+
model_handler.NumColumns = rbcallback(4) { 2 }
|
|
41
|
+
model_handler.ColumnType = rbcallback(4) { 0 }
|
|
42
|
+
model_handler.NumRows = rbcallback(4) { 5 }
|
|
43
|
+
model_handler.CellValue = rbcallback(1, [1, 1, 4, 4]) do |_, _, row, column|
|
|
44
|
+
UI.new_table_value_string(data[row][column])
|
|
45
|
+
end
|
|
46
|
+
model_handler.SetCellValue = rbcallback(0, [0]) {}
|
|
47
|
+
|
|
48
|
+
# Create the table model:
|
|
49
|
+
model = UI.new_table_model(model_handler)
|
|
50
|
+
|
|
51
|
+
table_params = UI::FFI::TableParams.malloc
|
|
52
|
+
table_params.to_ptr.free = Fiddle::RUBY_FREE
|
|
53
|
+
table_params.Model = model
|
|
54
|
+
table_params.RowBackgroundColorModelColumn = -1
|
|
55
|
+
|
|
56
|
+
table = UI.new_table(table_params)
|
|
57
|
+
LibUI.table_append_text_column(table, 'Animal', 0, -1)
|
|
58
|
+
LibUI.table_append_text_column(table, 'Description', 1, -1)
|
|
59
|
+
|
|
60
|
+
LibUI.box_append(hbox, table, 1)
|
|
61
|
+
LibUI.control_show(main_window)
|
|
62
|
+
|
|
63
|
+
LibUI.window_on_closing(main_window) {
|
|
64
|
+
# e 'Bye Bye'
|
|
65
|
+
LibUI.quit
|
|
66
|
+
1
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
LibUI.main
|
|
70
|
+
LibUI.free_table_model(model)
|
|
71
|
+
LibUI.uninit
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# =========================================================================== #
|
|
2
|
+
# === 013_scrolling_pane_example.rb
|
|
3
|
+
# =========================================================================== #
|
|
4
|
+
# This currently does not work. libui-ng first has to add support for
|
|
5
|
+
# that.
|
|
6
|
+
# =========================================================================== #
|
|
7
|
+
require 'libui'
|
|
8
|
+
|
|
9
|
+
alias e puts
|
|
10
|
+
|
|
11
|
+
LibUI.init
|
|
12
|
+
|
|
13
|
+
main_window = LibUI.new_window('Scrolling pane example', 300, 200, 1)
|
|
14
|
+
|
|
15
|
+
scroll_area = LibUI.new_scrolling_area
|
|
16
|
+
pp scroll_area.class
|
|
17
|
+
hbox = LibUI.new_horizontal_box
|
|
18
|
+
LibUI.window_set_child(main_window, hbox)
|
|
19
|
+
|
|
20
|
+
LibUI.control_show(main_window)
|
|
21
|
+
|
|
22
|
+
LibUI.window_on_closing(main_window) {
|
|
23
|
+
LibUI.quit
|
|
24
|
+
1
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
LibUI.main
|
|
28
|
+
LibUI.uninit
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# =========================================================================== #
|
|
2
|
+
# === 014_simple_entry_example.rb
|
|
3
|
+
# =========================================================================== #
|
|
4
|
+
require 'libui'
|
|
5
|
+
|
|
6
|
+
alias e puts
|
|
7
|
+
|
|
8
|
+
LibUI.init
|
|
9
|
+
|
|
10
|
+
main_window = LibUI.new_window('Two entries example - right one is read-only', 300, 200, 1)
|
|
11
|
+
|
|
12
|
+
hbox = LibUI.new_horizontal_box
|
|
13
|
+
LibUI.box_set_padded(hbox, 1)
|
|
14
|
+
entry1 = LibUI.new_entry
|
|
15
|
+
entry2 = LibUI.new_entry
|
|
16
|
+
LibUI.entry_set_read_only(entry2, 1)
|
|
17
|
+
|
|
18
|
+
LibUI.box_append(hbox, entry1, 1)
|
|
19
|
+
LibUI.box_append(hbox, entry2, 1)
|
|
20
|
+
|
|
21
|
+
LibUI.window_set_child(main_window, hbox)
|
|
22
|
+
LibUI.control_show(main_window)
|
|
23
|
+
|
|
24
|
+
LibUI.window_on_closing(main_window) {
|
|
25
|
+
LibUI.quit
|
|
26
|
+
1
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
LibUI.main
|
|
30
|
+
LibUI.uninit
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# =========================================================================== #
|
|
2
|
+
# === 015_slider_example.rb
|
|
3
|
+
# =========================================================================== #
|
|
4
|
+
require 'libui'
|
|
5
|
+
|
|
6
|
+
alias e puts
|
|
7
|
+
|
|
8
|
+
LibUI.init
|
|
9
|
+
|
|
10
|
+
main_window = LibUI.new_window('Slider example', 800, 240, 1)
|
|
11
|
+
|
|
12
|
+
hbox = LibUI.new_horizontal_box
|
|
13
|
+
LibUI.box_set_padded(hbox, 1)
|
|
14
|
+
slider1 = LibUI.new_slider(0, 10)
|
|
15
|
+
LibUI.slider_set_has_tool_tip(slider1, 1) # Testing this.
|
|
16
|
+
|
|
17
|
+
LibUI.slider_on_changed(slider1) {
|
|
18
|
+
e 'My value was changed to: '+LibUI.slider_value(slider1).to_s
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
LibUI.box_append(hbox, slider1, 1)
|
|
22
|
+
|
|
23
|
+
LibUI.window_set_child(main_window, hbox)
|
|
24
|
+
LibUI.control_show(main_window)
|
|
25
|
+
|
|
26
|
+
LibUI.window_on_closing(main_window) {
|
|
27
|
+
LibUI.quit
|
|
28
|
+
1
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
LibUI.main
|
|
32
|
+
LibUI.uninit
|