libui_paradise 0.2.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.
- checksums.yaml +7 -0
- data/README.md +2072 -0
- data/doc/README.gen +1931 -0
- data/doc/SNIPPETS.md +94 -0
- data/doc/todo/todo.md +16 -0
- data/lib/libui_paradise/autoinclude.rb +9 -0
- data/lib/libui_paradise/base/base.rb +154 -0
- data/lib/libui_paradise/colours/colours.rb +14 -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/complex/001_hbox_example.rb +17 -0
- data/lib/libui_paradise/examples/complex/002_tabs_example.rb +25 -0
- data/lib/libui_paradise/examples/complex/003_open_file_button_example.rb +38 -0
- data/lib/libui_paradise/examples/complex/004_font_button.rb +41 -0
- data/lib/libui_paradise/examples/complex/005_search_entry_example.rb +18 -0
- data/lib/libui_paradise/examples/complex/006_coloured_boxes_example.rb +22 -0
- data/lib/libui_paradise/examples/complex/007_slider_example.rb +31 -0
- data/lib/libui_paradise/examples/complex/008_radio_button_example.rb +23 -0
- data/lib/libui_paradise/examples/complex/009_separator_example.rb +25 -0
- data/lib/libui_paradise/examples/complex/010_table_example.rb +55 -0
- data/lib/libui_paradise/examples/complex/011_two_buttons_showing_how_to_enable_and_disable_them.rb +32 -0
- data/lib/libui_paradise/examples/complex/012_password_entry_example.rb +29 -0
- data/lib/libui_paradise/examples/complex/013_form_example.rb +38 -0
- data/lib/libui_paradise/examples/complex/014_text_example.rb +18 -0
- data/lib/libui_paradise/examples/complex/015_text_view_example.rb +16 -0
- data/lib/libui_paradise/examples/complex/016_grid_example.rb +31 -0
- data/lib/libui_paradise/examples/complex/017_unicode_text_example.rb +30 -0
- data/lib/libui_paradise/examples/complex/018_spinbutton_example.rb +33 -0
- data/lib/libui_paradise/examples/complex/019_combo_box_example.rb +50 -0
- data/lib/libui_paradise/examples/complex/020_checkbox_example.rb +81 -0
- data/lib/libui_paradise/examples/complex/021_font_example.rb +115 -0
- data/lib/libui_paradise/examples/complex/022_simple_notepad_example.rb +25 -0
- data/lib/libui_paradise/examples/complex/023_msg_box_error.rb +27 -0
- data/lib/libui_paradise/examples/complex/024_parse_config_file_example.config +6 -0
- data/lib/libui_paradise/examples/complex/024_parse_config_file_example.rb +15 -0
- data/lib/libui_paradise/examples/complex/025_colour_button.rb +53 -0
- data/lib/libui_paradise/examples/complex/026_basic_table_image.rb +96 -0
- data/lib/libui_paradise/examples/complex/027_basic_button_example.rb +19 -0
- data/lib/libui_paradise/examples/complex/028_try_for_automatic_button_press_event_after_a_delay.rb +47 -0
- data/lib/libui_paradise/examples/complex/029_progressbar_example.rb +116 -0
- data/lib/libui_paradise/examples/complex/030_entry_responds_to_comment_as_synonymous_to_the_enter_key_pressed_example.rb +140 -0
- data/lib/libui_paradise/examples/complex/031_notification_functionality_example.rb +96 -0
- data/lib/libui_paradise/examples/complex/032_simple_window_example.rb +69 -0
- data/lib/libui_paradise/examples/complex/033_daemonize_and_exit_after_delay_example.rb +91 -0
- data/lib/libui_paradise/examples/simple/001_open_file_example.rb +35 -0
- data/lib/libui_paradise/examples/simple/002_histogram_example.rb +213 -0
- data/lib/libui_paradise/examples/simple/003_fancy_text_example.rb +220 -0
- data/lib/libui_paradise/examples/simple/004_date_time_picker.rb +52 -0
- data/lib/libui_paradise/examples/simple/005_text_drawing_example.rb +185 -0
- data/lib/libui_paradise/examples/simple/006_midi_player.rb +96 -0
- data/lib/libui_paradise/examples/simple/007_control_gallery.rb +191 -0
- data/lib/libui_paradise/examples/simple/008_basic_area_example.rb +56 -0
- data/lib/libui_paradise/examples/simple/009_spectrum.rb +107 -0
- data/lib/libui_paradise/examples/simple/README.md +7 -0
- data/lib/libui_paradise/experimental/dsl.rb +17 -0
- data/lib/libui_paradise/extensions/counters.rb +58 -0
- data/lib/libui_paradise/extensions/extensions.rb +29 -0
- data/lib/libui_paradise/extensions/hash_fiddle_pointer_widgets.rb +150 -0
- data/lib/libui_paradise/extensions/misc.rb +754 -0
- data/lib/libui_paradise/fiddle/pointer.rb +1158 -0
- data/lib/libui_paradise/generic_window/README.md +9 -0
- data/lib/libui_paradise/generic_window/generic_window.rb +79 -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/box.rb +156 -0
- data/lib/libui_paradise/libui_classes/grid.rb +55 -0
- data/lib/libui_paradise/libui_classes/libui_classes.rb +1611 -0
- data/lib/libui_paradise/project/project.rb +28 -0
- data/lib/libui_paradise/prototype/README.md +3 -0
- data/lib/libui_paradise/prototype/prototype.rb +107 -0
- data/lib/libui_paradise/requires/require_the_libui_classes.rb +29 -0
- data/lib/libui_paradise/requires/require_the_libui_paradise_project.rb +12 -0
- data/lib/libui_paradise/toplevel_methods/misc.rb +13 -0
- data/lib/libui_paradise/version/version.rb +17 -0
- data/lib/libui_paradise.rb +1 -0
- data/libui_paradise.gemspec +49 -0
- data/test/testing_generic_window.rb +20 -0
- metadata +156 -0
data/doc/SNIPPETS.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# How to add a new main window:
|
|
2
|
+
# width, height, hasMenubar
|
|
3
|
+
main_window = UI.new_window('hello world', 300, 200, 1)
|
|
4
|
+
|
|
5
|
+
Source code:
|
|
6
|
+
|
|
7
|
+
https://raw.githubusercontent.com/andlabs/libui/master/unix/window.c
|
|
8
|
+
|
|
9
|
+
# How to add a libui-widget to the main window / Designate a child widget:
|
|
10
|
+
|
|
11
|
+
UI.window_set_child(main_window, button)
|
|
12
|
+
|
|
13
|
+
# Act on closing-event (on quit tag):
|
|
14
|
+
|
|
15
|
+
UI.window_on_closing(main_window) {
|
|
16
|
+
puts 'Bye Bye'
|
|
17
|
+
UI.control_destroy(main_window)
|
|
18
|
+
UI.quit
|
|
19
|
+
0
|
|
20
|
+
}
|
|
21
|
+
# Or simpler:
|
|
22
|
+
close_properly(main_window)
|
|
23
|
+
|
|
24
|
+
# Add the window to the main UI:
|
|
25
|
+
|
|
26
|
+
UI.control_show(main_window)
|
|
27
|
+
main_window.show_the_controls # Or use this one here.
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# Add a checkbox (checkbox tag, checkbutton)
|
|
31
|
+
|
|
32
|
+
checkbox = UI.new_checkbox('Checkbox') # or ui_checkbox
|
|
33
|
+
checkbox_toggle_callback = proc { |pointer|
|
|
34
|
+
checked = UI.checkbox_checked(pointer) == 1
|
|
35
|
+
UI.window_set_title(MAIN_WINDOW, "Checkbox is #{checked}")
|
|
36
|
+
UI.checkbox_set_text(pointer, "I am the checkbox (#{checked})")
|
|
37
|
+
0
|
|
38
|
+
}
|
|
39
|
+
UI.checkbox_on_toggled(checkbox, checkbox_toggle_callback, nil)
|
|
40
|
+
UI.box_append(inner, checkbox, 0)
|
|
41
|
+
|
|
42
|
+
To set it checked:
|
|
43
|
+
|
|
44
|
+
checkbox.set_checked(1)
|
|
45
|
+
|
|
46
|
+
To query its state:
|
|
47
|
+
|
|
48
|
+
checked = UI.checkbox_checked(pointer) == 1
|
|
49
|
+
|
|
50
|
+
# And the control:
|
|
51
|
+
|
|
52
|
+
UI.control_show(main_window)
|
|
53
|
+
|
|
54
|
+
# Using a text-entry (ui entry tag):
|
|
55
|
+
|
|
56
|
+
text_entry = UI.new_entry
|
|
57
|
+
UI.entry_set_text(text_entry, 'Please enter your feelings')
|
|
58
|
+
UI.entry_on_changed(text_entry, text_changed_callback, nil)
|
|
59
|
+
|
|
60
|
+
# To set this on a "multiline entry", aka spanning several
|
|
61
|
+
# rows, do use:
|
|
62
|
+
UI.multiline_entry_set_text(entry1, 'Yo there')
|
|
63
|
+
ui_text_view # an alias used in libui_paradise
|
|
64
|
+
|
|
65
|
+
text1 = UI.entry_text(entry1) # Obtain text. You may have to call .to_s on it, to guarantee the String.
|
|
66
|
+
UI.multiline_entry_text # Obtain the text from a multiline entry.
|
|
67
|
+
|
|
68
|
+
# Create a combobox (combo tag, combobox tag):
|
|
69
|
+
|
|
70
|
+
combobox_selected_callback = proc { |ptr|
|
|
71
|
+
puts "New combobox selection: #{UI.combobox_selected(ptr)}"
|
|
72
|
+
}
|
|
73
|
+
cbox = UI.new_combobox
|
|
74
|
+
UI.combobox_append(cbox, 'combobox Item 1')
|
|
75
|
+
UI.combobox_append(cbox, 'combobox Item 2')
|
|
76
|
+
UI.combobox_append(cbox, 'combobox Item 3')
|
|
77
|
+
UI.box_append(inner, cbox, 0)
|
|
78
|
+
UI.combobox_on_selected(cbox, combobox_selected_callback, nil)
|
|
79
|
+
|
|
80
|
+
# Or more concise:
|
|
81
|
+
combo_box = UI.combobox {
|
|
82
|
+
['combobox Item 1', 'combobox Item 2', 'combobox Item 3']
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
# Add content to an editable combox:
|
|
87
|
+
|
|
88
|
+
UI.append() # .append() adds the named item to the end of the EditableCombobox.
|
|
89
|
+
|
|
90
|
+
# How to build a menu-interface (menu tag):
|
|
91
|
+
|
|
92
|
+
help_menu = UI.new_menu('Help')
|
|
93
|
+
version_item = UI.menu_append_item(help_menu, 'Version')
|
|
94
|
+
|
data/doc/todo/todo.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
- Make sure that each component has a screenshot. It's ok to
|
|
2
|
+
re-use existing screenshots from other projects.
|
|
3
|
+
|
|
4
|
+
- Make sure the project is API compatible to glimmer-libui.
|
|
5
|
+
|
|
6
|
+
- Rewrite the project from the get-go. Also integrate
|
|
7
|
+
@main_window into the main hash, rather than have it
|
|
8
|
+
standalone. ^^^ this should be fixed ASAP - it is not
|
|
9
|
+
elegant to have a separate @main_window ... but for
|
|
10
|
+
now we'll keep it as-is.
|
|
11
|
+
|
|
12
|
+
- Re-organize the examples, perhaps starting with another
|
|
13
|
+
one.
|
|
14
|
+
|
|
15
|
+
- Check for image and font support again. Something isn't
|
|
16
|
+
working!
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/ruby -w
|
|
2
|
+
# Encoding: UTF-8
|
|
3
|
+
# frozen_string_literal: true
|
|
4
|
+
# =========================================================================== #
|
|
5
|
+
# require 'libui_paradise/autoinclude.rb'
|
|
6
|
+
# =========================================================================== #
|
|
7
|
+
require 'libui_paradise/requires/require_the_libui_paradise_project.rb'
|
|
8
|
+
|
|
9
|
+
include LibuiParadise::Extensions
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
#!/usr/bin/ruby -w
|
|
2
|
+
# Encoding: UTF-8
|
|
3
|
+
# frozen_string_literal: true
|
|
4
|
+
# =========================================================================== #
|
|
5
|
+
# === LibuiParadise::Base
|
|
6
|
+
# =========================================================================== #
|
|
7
|
+
# require 'libui_paradise/base/base.rb'
|
|
8
|
+
# < LibuiParadise::Base
|
|
9
|
+
# =========================================================================== #
|
|
10
|
+
module LibuiParadise
|
|
11
|
+
|
|
12
|
+
class Base # === LibuiParadise::Base
|
|
13
|
+
|
|
14
|
+
alias e puts
|
|
15
|
+
|
|
16
|
+
require 'libui_paradise'
|
|
17
|
+
include LibuiParadise::Extensions
|
|
18
|
+
|
|
19
|
+
# ========================================================================= #
|
|
20
|
+
# === TITLE
|
|
21
|
+
# ========================================================================= #
|
|
22
|
+
TITLE = 'Generic Title'
|
|
23
|
+
|
|
24
|
+
# ========================================================================= #
|
|
25
|
+
# === WIDTH
|
|
26
|
+
# ========================================================================= #
|
|
27
|
+
WIDTH = 800
|
|
28
|
+
|
|
29
|
+
# ========================================================================= #
|
|
30
|
+
# === HEIGHT
|
|
31
|
+
# ========================================================================= #
|
|
32
|
+
HEIGHT = 640
|
|
33
|
+
|
|
34
|
+
# ========================================================================= #
|
|
35
|
+
# === default_title_width_height
|
|
36
|
+
# ========================================================================= #
|
|
37
|
+
def default_title_width_height(
|
|
38
|
+
title = TITLE,
|
|
39
|
+
width = WIDTH,
|
|
40
|
+
height = HEIGHT
|
|
41
|
+
)
|
|
42
|
+
title_width_height(
|
|
43
|
+
title,
|
|
44
|
+
width,
|
|
45
|
+
height
|
|
46
|
+
)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# ========================================================================= #
|
|
50
|
+
# === reset (reset tag)
|
|
51
|
+
# ========================================================================= #
|
|
52
|
+
def reset
|
|
53
|
+
title_width_height(TITLE, WIDTH, HEIGHT)
|
|
54
|
+
# ======================================================================= #
|
|
55
|
+
# === @window
|
|
56
|
+
# ======================================================================= #
|
|
57
|
+
set_window(
|
|
58
|
+
return_default_window
|
|
59
|
+
)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# ======================================================================= #
|
|
63
|
+
# === update_the_main_window
|
|
64
|
+
# ======================================================================= #
|
|
65
|
+
def update_the_main_window
|
|
66
|
+
set_window(
|
|
67
|
+
return_default_window
|
|
68
|
+
)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# ======================================================================= #
|
|
72
|
+
# === return_default_window
|
|
73
|
+
# ======================================================================= #
|
|
74
|
+
def return_default_window(
|
|
75
|
+
title = title?,
|
|
76
|
+
width = width?,
|
|
77
|
+
height = height?
|
|
78
|
+
)
|
|
79
|
+
return ui_padded_main_window(title, width, height, 0)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# ======================================================================= #
|
|
83
|
+
# === set_window
|
|
84
|
+
#
|
|
85
|
+
# Simply assign to @window here.
|
|
86
|
+
# ======================================================================= #
|
|
87
|
+
def set_window(i = return_default_window)
|
|
88
|
+
@window = i
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# ========================================================================= #
|
|
92
|
+
# === create_skeleton (create tag, skeleton tag)
|
|
93
|
+
# ========================================================================= #
|
|
94
|
+
def create_skeleton
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# ========================================================================= #
|
|
98
|
+
# === add_these_widgets_to_the_main_window
|
|
99
|
+
#
|
|
100
|
+
# This method can be used to batch-add several widgets into the
|
|
101
|
+
# main window at hand. It has been created in September 2022 to
|
|
102
|
+
# simplify adding widgets from simple scripts. If we can easily
|
|
103
|
+
# add widgets then this will help write smaller GUIs quickly.
|
|
104
|
+
#
|
|
105
|
+
# For now the main container to be used is a vertical-box here.
|
|
106
|
+
# In theory this could be changed, but for now this is how it
|
|
107
|
+
# is.
|
|
108
|
+
# ========================================================================= #
|
|
109
|
+
def add_these_widgets_to_the_main_window(*i)
|
|
110
|
+
outer_vbox = padded_vbox
|
|
111
|
+
# ======================================================================= #
|
|
112
|
+
# First add the two buttons on top:
|
|
113
|
+
# ======================================================================= #
|
|
114
|
+
outer_vbox.add_hsep
|
|
115
|
+
i.flatten.each {|this_widget|
|
|
116
|
+
# ===================================================================== #
|
|
117
|
+
# Some symbols exist as special keywords:
|
|
118
|
+
# ===================================================================== #
|
|
119
|
+
case this_widget
|
|
120
|
+
# ===================================================================== #
|
|
121
|
+
# === :create_a_quit_button
|
|
122
|
+
# ===================================================================== #
|
|
123
|
+
when :create_a_quit_button
|
|
124
|
+
this_widget = quit_button
|
|
125
|
+
end
|
|
126
|
+
outer_vbox.minimal(this_widget)
|
|
127
|
+
}
|
|
128
|
+
@window.add(outer_vbox)
|
|
129
|
+
if i.size > 0
|
|
130
|
+
Thread.new {
|
|
131
|
+
sleep 5
|
|
132
|
+
require 'save_file'
|
|
133
|
+
SaveFile.write_what_into('YO','/Depot/j/ACK.md')
|
|
134
|
+
exit
|
|
135
|
+
}
|
|
136
|
+
end
|
|
137
|
+
@window.intelligent_exit
|
|
138
|
+
end; alias add_these_widgets add_these_widgets_to_the_main_window # === add_these_widgets
|
|
139
|
+
|
|
140
|
+
# ========================================================================= #
|
|
141
|
+
# === run_in_the_background
|
|
142
|
+
# ========================================================================= #
|
|
143
|
+
def run_in_the_background
|
|
144
|
+
Process.daemon
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
# ========================================================================= #
|
|
148
|
+
# === run
|
|
149
|
+
# ========================================================================= #
|
|
150
|
+
def run
|
|
151
|
+
create_skeleton_then_connect_skeleton
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
end; end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/ruby -w
|
|
2
|
+
# Encoding: UTF-8
|
|
3
|
+
# frozen_string_literal: true
|
|
4
|
+
# =========================================================================== #
|
|
5
|
+
# require 'libui_paradise/colours/colours.rb
|
|
6
|
+
# =========================================================================== #
|
|
7
|
+
module LibuiParadise
|
|
8
|
+
|
|
9
|
+
# ========================================================================= #
|
|
10
|
+
# === COLOR_BLUE
|
|
11
|
+
# ========================================================================= #
|
|
12
|
+
COLOR_BLUE = 0x1E90FF
|
|
13
|
+
|
|
14
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/ruby -w
|
|
2
|
+
# Encoding: UTF-8
|
|
3
|
+
# frozen_string_literal: true
|
|
4
|
+
# =========================================================================== #
|
|
5
|
+
# require 'complex/001_hbox_example.rb'
|
|
6
|
+
# =========================================================================== #
|
|
7
|
+
require 'libui_paradise/autoinclude'
|
|
8
|
+
|
|
9
|
+
window = ui_padded_window(:filename, 500, 200)
|
|
10
|
+
|
|
11
|
+
hbox1 = ui_hbox
|
|
12
|
+
hbox1 << text('This is a hbox example.')
|
|
13
|
+
hbox1 << ui_entry
|
|
14
|
+
hbox1 << text('As can be seen we add elements in a horizontal (side-by-side) manner.')
|
|
15
|
+
window << hbox1
|
|
16
|
+
window.child = hbox1
|
|
17
|
+
window.intelligent_exit
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/ruby -w
|
|
2
|
+
# Encoding: UTF-8
|
|
3
|
+
# frozen_string_literal: true
|
|
4
|
+
# =========================================================================== #
|
|
5
|
+
# require '002_tabs_example.rb'
|
|
6
|
+
# =========================================================================== #
|
|
7
|
+
require 'libui_paradise/autoinclude'
|
|
8
|
+
#require 'libui_paradise/requires/require_the_libui_paradise_project.rb'
|
|
9
|
+
|
|
10
|
+
window = ui_main_window('A notebook with tabs example', 1200, 200, 15)
|
|
11
|
+
|
|
12
|
+
tab = ui_tabs
|
|
13
|
+
tab.add('Page 1', hbox(text('One! 😎️')))
|
|
14
|
+
tab.add('Page 2', hbox(text('Two! 😍️')))
|
|
15
|
+
tab.add('Page 3', hbox(text('Three! 😘️')))
|
|
16
|
+
tab.add('Page 4', hbox(text('Four! 😗️')))
|
|
17
|
+
tab.add('Page 5', hbox(text('Five! 😙️')))
|
|
18
|
+
tab.add('Page 6', hbox(text('Six! 😚️')))
|
|
19
|
+
|
|
20
|
+
box = ui_padded_vbox
|
|
21
|
+
box << tab
|
|
22
|
+
|
|
23
|
+
window.child = box
|
|
24
|
+
window.control_show
|
|
25
|
+
window.intelligent_exit
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/ruby -w
|
|
2
|
+
# Encoding: UTF-8
|
|
3
|
+
# frozen_string_literal: true
|
|
4
|
+
# =========================================================================== #
|
|
5
|
+
# This example shows how to open a file via ruby-libui.
|
|
6
|
+
# =========================================================================== #
|
|
7
|
+
# require 'libui_paradise/complex/003_open_file_button_example.rb'
|
|
8
|
+
# =========================================================================== #
|
|
9
|
+
require 'libui_paradise/autoinclude'
|
|
10
|
+
|
|
11
|
+
window = ui_padded_main_window('An open-file button-example', 1200, 200, 15)
|
|
12
|
+
|
|
13
|
+
outer_vbox = ui_padded_vbox
|
|
14
|
+
button_open_file = ui_button('Open file')
|
|
15
|
+
button_open_file.on_clicked {
|
|
16
|
+
begin
|
|
17
|
+
#filename = ui_open_file(window).to_s
|
|
18
|
+
filename = ::LibUI.open_file(main_window).to_s
|
|
19
|
+
e "The filename was: #{filename}"
|
|
20
|
+
rescue ArgumentError => error # Rescue from "NULL pointer given"
|
|
21
|
+
pp error
|
|
22
|
+
end
|
|
23
|
+
}
|
|
24
|
+
outer_vbox << button_open_file
|
|
25
|
+
|
|
26
|
+
window.child = outer_vbox
|
|
27
|
+
window.intelligent_quit
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
if false
|
|
31
|
+
LibUI.button_on_clicked(button) {
|
|
32
|
+
result = ::LibUI.open_file(main_window).to_s
|
|
33
|
+
if File.exist?(result)
|
|
34
|
+
e 'The file exists. \o/'
|
|
35
|
+
end
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/ruby -w
|
|
2
|
+
# Encoding: UTF-8
|
|
3
|
+
# frozen_string_literal: true
|
|
4
|
+
# =========================================================================== #
|
|
5
|
+
# require 'examples/complex/004_font_button.rb'
|
|
6
|
+
# =========================================================================== #
|
|
7
|
+
require 'libui_paradise/autoinclude'
|
|
8
|
+
|
|
9
|
+
alias e puts
|
|
10
|
+
|
|
11
|
+
main_window = ui_window('hello world', 300, 200, 1)
|
|
12
|
+
|
|
13
|
+
font_button = ui_font_button
|
|
14
|
+
# =========================================================================== #
|
|
15
|
+
# === font_descriptor
|
|
16
|
+
#
|
|
17
|
+
# The font_descriptor will contain all the important information about the
|
|
18
|
+
# font at hand. It will be updated via UI.font_button_font().
|
|
19
|
+
# =========================================================================== #
|
|
20
|
+
font_descriptor = ui_font_descriptor('Hack')
|
|
21
|
+
LibUI.font_button_on_changed(font_button) {
|
|
22
|
+
LibUI.font_button_font(font_button, font_descriptor)
|
|
23
|
+
# ========================================================================= #
|
|
24
|
+
# The following line will output something like:
|
|
25
|
+
#
|
|
26
|
+
# {:family=>"Georgia", :size=>12.0, :weight=>700, :italic=>0, :stretch=>4}
|
|
27
|
+
#
|
|
28
|
+
# ========================================================================= #
|
|
29
|
+
e
|
|
30
|
+
e 'The chosen font is:'
|
|
31
|
+
e
|
|
32
|
+
p family: font_descriptor.Family.to_s,
|
|
33
|
+
size: font_descriptor.Size,
|
|
34
|
+
weight: font_descriptor.Weight,
|
|
35
|
+
italic: font_descriptor.Italic,
|
|
36
|
+
stretch: font_descriptor.Stretch
|
|
37
|
+
}
|
|
38
|
+
main_window.close_properly
|
|
39
|
+
main_window.child = font_button
|
|
40
|
+
main_window.control_show
|
|
41
|
+
LibUI.main_then_quit
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/ruby -w
|
|
2
|
+
# Encoding: UTF-8
|
|
3
|
+
# frozen_string_literal: true
|
|
4
|
+
# =========================================================================== #
|
|
5
|
+
# require '005_search_entry_example.rb'
|
|
6
|
+
# =========================================================================== #
|
|
7
|
+
require 'libui_paradise/autoinclude'
|
|
8
|
+
|
|
9
|
+
window = ui_main_window('A search-entry example', 1200, 200, 15)
|
|
10
|
+
|
|
11
|
+
search_entry = ui_search_entry
|
|
12
|
+
box = ui_padded_vbox
|
|
13
|
+
box << search_entry
|
|
14
|
+
box.is_padded
|
|
15
|
+
|
|
16
|
+
window.child = box
|
|
17
|
+
window.control_show
|
|
18
|
+
window.intelligent_exit
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/ruby -w
|
|
2
|
+
# Encoding: UTF-8
|
|
3
|
+
# frozen_string_literal: true
|
|
4
|
+
# =========================================================================== #
|
|
5
|
+
# require 'libui_paradise/examples/complex/006_coloured_boxes_example.rb'
|
|
6
|
+
# =========================================================================== #
|
|
7
|
+
require 'libui_paradise/autoinclude'
|
|
8
|
+
|
|
9
|
+
require 'colours' # Needs the colours gem.
|
|
10
|
+
|
|
11
|
+
window = ui_main_window('Coloured boxes example', 320, 200, 1)
|
|
12
|
+
|
|
13
|
+
outer_hbox = ui_hbox
|
|
14
|
+
outer_hbox.maximal LibuiParadise.draw_rectangle(:default, :default, Colours.random_html_colour)
|
|
15
|
+
outer_hbox.maximal LibuiParadise.draw_rectangle(:default, :default, :seagreen)
|
|
16
|
+
outer_hbox.maximal LibuiParadise.draw_rectangle(:default, :default, :springgreen)
|
|
17
|
+
outer_hbox.maximal LibuiParadise.draw_rectangle(:default, :default, :royalblue)
|
|
18
|
+
outer_hbox.maximal LibuiParadise.draw_rectangle(:default, :default, :lightblue)
|
|
19
|
+
outer_hbox.maximal LibuiParadise.draw_rectangle(:default, :default, :steelblue)
|
|
20
|
+
|
|
21
|
+
window.add(outer_hbox)
|
|
22
|
+
window.intelligent_quit
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/ruby -w
|
|
2
|
+
# Encoding: UTF-8
|
|
3
|
+
# frozen_string_literal: true
|
|
4
|
+
# =========================================================================== #
|
|
5
|
+
# require 'libui_paradise/examples/033_slider_example.rb'
|
|
6
|
+
# =========================================================================== #
|
|
7
|
+
require 'libui_paradise/autoinclude'
|
|
8
|
+
|
|
9
|
+
window = ui_main_window('Slider Example', 250, 70, 1)
|
|
10
|
+
|
|
11
|
+
slider = ui_slider(0, 100)
|
|
12
|
+
|
|
13
|
+
# =========================================================================== #
|
|
14
|
+
# === callback_for_the_slider
|
|
15
|
+
# =========================================================================== #
|
|
16
|
+
def callback_for_the_slider
|
|
17
|
+
proc { |pointer|
|
|
18
|
+
puts "New Slider value: #{UI.slider_value(pointer)}"
|
|
19
|
+
}
|
|
20
|
+
end
|
|
21
|
+
slider.on_changed { callback_for_the_slider }
|
|
22
|
+
|
|
23
|
+
# =========================================================================== #
|
|
24
|
+
# The original variant would go like this:
|
|
25
|
+
#
|
|
26
|
+
# LibUI.slider_on_changed(slider, slider_changed_callback)
|
|
27
|
+
#
|
|
28
|
+
# =========================================================================== #
|
|
29
|
+
outer_vbox = ui_padded_vbox(slider)
|
|
30
|
+
window.add(outer_vbox)
|
|
31
|
+
window.intelligent_quit
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/ruby -w
|
|
2
|
+
# Encoding: UTF-8
|
|
3
|
+
# frozen_string_literal: true
|
|
4
|
+
# =========================================================================== #
|
|
5
|
+
# require '032_form_example.rb'
|
|
6
|
+
# =========================================================================== #
|
|
7
|
+
require 'libui_paradise/autoinclude'
|
|
8
|
+
|
|
9
|
+
window = margined_window(:filename, 320, 200, 0)
|
|
10
|
+
|
|
11
|
+
outer_vbox = padded_vbox
|
|
12
|
+
array_to_use = ['Radio Button 1', 'Radio Button 2', 'Radio Button 3']
|
|
13
|
+
# =========================================================================== #
|
|
14
|
+
# Keep the buttons padded via hsep on top and on the bottom.
|
|
15
|
+
# =========================================================================== #
|
|
16
|
+
|
|
17
|
+
outer_vbox.minimal(hsep, 0)
|
|
18
|
+
rb = ui_radio_buttons(array_to_use)
|
|
19
|
+
outer_vbox.minimal(rb)
|
|
20
|
+
outer_vbox.minimal(hsep, 0)
|
|
21
|
+
|
|
22
|
+
window.child = outer_vbox
|
|
23
|
+
window.intelligent_quit
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/ruby -w
|
|
2
|
+
# Encoding: UTF-8
|
|
3
|
+
# frozen_string_literal: true
|
|
4
|
+
# =========================================================================== #
|
|
5
|
+
# require 'libui_paradise/009_separator_example.rb'
|
|
6
|
+
# =========================================================================== #
|
|
7
|
+
require 'libui_paradise/autoinclude'
|
|
8
|
+
|
|
9
|
+
window = margined_window(:filename, 250, 150, 0)
|
|
10
|
+
|
|
11
|
+
outer_vbox = padded_vbox
|
|
12
|
+
|
|
13
|
+
button_hello_world = button('A button')
|
|
14
|
+
button_hello_world.on_clicked {
|
|
15
|
+
e 'Hello world!'
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
outer_vbox.minimal(hsep, 1)
|
|
19
|
+
outer_vbox.minimal(hsep, 0)
|
|
20
|
+
outer_vbox.minimal(button_hello_world, 1)
|
|
21
|
+
outer_vbox.minimal(hsep, 0)
|
|
22
|
+
outer_vbox.minimal(hsep, 1)
|
|
23
|
+
|
|
24
|
+
window.child = outer_vbox
|
|
25
|
+
window.intelligent_quit
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/bin/ruby -w
|
|
2
|
+
# Encoding: UTF-8
|
|
3
|
+
# frozen_string_literal: true
|
|
4
|
+
# =========================================================================== #
|
|
5
|
+
# Todo:
|
|
6
|
+
#
|
|
7
|
+
# - Add editable entry to the table
|
|
8
|
+
#
|
|
9
|
+
# =========================================================================== #
|
|
10
|
+
# require 'libui_paradise/010_table_example.rb'
|
|
11
|
+
# =========================================================================== #
|
|
12
|
+
require 'libui_paradise/autoinclude'
|
|
13
|
+
|
|
14
|
+
main_window = padded_window('30) Table example', 300, 200, 1)
|
|
15
|
+
hbox = padded_hbox
|
|
16
|
+
data = [
|
|
17
|
+
%w( cat calm meow ),
|
|
18
|
+
%w( dog loyal woof ),
|
|
19
|
+
%w( chicken bird cock-a-doodle-doo ),
|
|
20
|
+
%w( horse fast neigh ),
|
|
21
|
+
%w( cow slow moo )
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
# Protect BlockCaller objects from garbage collection.
|
|
25
|
+
@block_callers = []
|
|
26
|
+
def rbcallback(*args, &block)
|
|
27
|
+
args << [0] if args.size == 1 # Argument types are ommited
|
|
28
|
+
block_caller = Fiddle::Closure::BlockCaller.new(*args, &block)
|
|
29
|
+
@block_callers << block_caller
|
|
30
|
+
block_caller
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
model_handler = LibUI::FFI::TableModelHandler.malloc
|
|
34
|
+
model_handler.to_ptr.free = Fiddle::RUBY_FREE
|
|
35
|
+
|
|
36
|
+
model_handler.NumColumns = rbcallback(4) { 2 }
|
|
37
|
+
model_handler.ColumnType = rbcallback(4) { 0 }
|
|
38
|
+
model_handler.NumRows = rbcallback(4) { 5 }
|
|
39
|
+
model_handler.CellValue = rbcallback(1, [1, 1, 4, 4]) do |_, _, row, column|
|
|
40
|
+
LibUI.new_table_value_string(data[row][column])
|
|
41
|
+
end
|
|
42
|
+
model_handler.SetCellValue = rbcallback(0, [0]) {}
|
|
43
|
+
|
|
44
|
+
model = LibUI.new_table_model(model_handler)
|
|
45
|
+
|
|
46
|
+
table_params = ui_table_params_malloc(model)
|
|
47
|
+
|
|
48
|
+
table = ui_table(table_params)
|
|
49
|
+
table.append_text_column('Animal', 0, -1)
|
|
50
|
+
table.append_text_column('Description', 1, -1)
|
|
51
|
+
table.append_text_column('Fancy Stuff', 2, -1)
|
|
52
|
+
|
|
53
|
+
hbox.add(table, 1)
|
|
54
|
+
main_window.child = hbox
|
|
55
|
+
main_window.intelligent_quit
|
data/lib/libui_paradise/examples/complex/011_two_buttons_showing_how_to_enable_and_disable_them.rb
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/ruby -w
|
|
2
|
+
# Encoding: UTF-8
|
|
3
|
+
# frozen_string_literal: true
|
|
4
|
+
# =========================================================================== #
|
|
5
|
+
# require 'examples/complex/011_two_buttons_showing_how_to_enable_and_disable_them.rb'
|
|
6
|
+
# =========================================================================== #
|
|
7
|
+
require 'libui_paradise/autoinclude'
|
|
8
|
+
|
|
9
|
+
main_window = padded_main_window(
|
|
10
|
+
'Two buttons showing how to enable and disable them', 300, 60, 0
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
outer_hbox = padded_hbox
|
|
14
|
+
|
|
15
|
+
button1 = button('Button #1')
|
|
16
|
+
button2 = button('Button #2')
|
|
17
|
+
button2.disable # Start-state for this button.
|
|
18
|
+
|
|
19
|
+
outer_hbox << button1
|
|
20
|
+
outer_hbox << button2
|
|
21
|
+
|
|
22
|
+
button1.on_clicked {|widget|
|
|
23
|
+
button2.enable
|
|
24
|
+
button1.disable
|
|
25
|
+
}
|
|
26
|
+
button2.on_clicked {|widget|
|
|
27
|
+
button1.enable
|
|
28
|
+
button2.disable
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
main_window.child = outer_hbox
|
|
32
|
+
main_window.intelligent_exit
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/ruby -w
|
|
2
|
+
# Encoding: UTF-8
|
|
3
|
+
# frozen_string_literal: true
|
|
4
|
+
# =========================================================================== #
|
|
5
|
+
# require 'libui_paradise/examples/012_password_entry_example.rb'
|
|
6
|
+
# =========================================================================== #
|
|
7
|
+
require 'libui_paradise/autoinclude'
|
|
8
|
+
|
|
9
|
+
window = margined_window('Password Entry Example', 280, 80, 0)
|
|
10
|
+
|
|
11
|
+
outer_vbox = padded_vbox
|
|
12
|
+
entry_containing_the_password = password_entry
|
|
13
|
+
LibUI.entry_on_changed(entry_containing_the_password) { |entry|
|
|
14
|
+
e 'The text is now: '+entry_containing_the_password.text?
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
outer_vbox.minimal(text('Password: '), 0)
|
|
18
|
+
outer_vbox.minimal(entry_containing_the_password, 0)
|
|
19
|
+
|
|
20
|
+
button = button('Show the password')
|
|
21
|
+
button.on_clicked {
|
|
22
|
+
_ = entry_containing_the_password.text?.to_s
|
|
23
|
+
e _
|
|
24
|
+
message_box(window, _)
|
|
25
|
+
}
|
|
26
|
+
outer_vbox.minimal(button, 0)
|
|
27
|
+
|
|
28
|
+
window.child = outer_vbox
|
|
29
|
+
window.intelligent_quit
|