libui_paradise 0.2.48

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.

Files changed (79) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +2064 -0
  3. data/doc/README.gen +1923 -0
  4. data/doc/SNIPPETS.md +94 -0
  5. data/doc/todo/todo.md +16 -0
  6. data/lib/libui_paradise/autoinclude.rb +9 -0
  7. data/lib/libui_paradise/base/base.rb +154 -0
  8. data/lib/libui_paradise/colours/colours.rb +14 -0
  9. data/lib/libui_paradise/domain_specific_language/README.md +5 -0
  10. data/lib/libui_paradise/domain_specific_language/button.yml +7 -0
  11. data/lib/libui_paradise/examples/complex/001_hbox_example.rb +17 -0
  12. data/lib/libui_paradise/examples/complex/002_tabs_example.rb +25 -0
  13. data/lib/libui_paradise/examples/complex/003_open_file_button_example.rb +38 -0
  14. data/lib/libui_paradise/examples/complex/004_font_button.rb +41 -0
  15. data/lib/libui_paradise/examples/complex/005_search_entry_example.rb +18 -0
  16. data/lib/libui_paradise/examples/complex/006_coloured_boxes_example.rb +22 -0
  17. data/lib/libui_paradise/examples/complex/007_slider_example.rb +31 -0
  18. data/lib/libui_paradise/examples/complex/008_radio_button_example.rb +23 -0
  19. data/lib/libui_paradise/examples/complex/009_separator_example.rb +25 -0
  20. data/lib/libui_paradise/examples/complex/010_table_example.rb +55 -0
  21. data/lib/libui_paradise/examples/complex/011_two_buttons_showing_how_to_enable_and_disable_them.rb +32 -0
  22. data/lib/libui_paradise/examples/complex/012_password_entry_example.rb +29 -0
  23. data/lib/libui_paradise/examples/complex/013_form_example.rb +38 -0
  24. data/lib/libui_paradise/examples/complex/014_text_example.rb +18 -0
  25. data/lib/libui_paradise/examples/complex/015_text_view_example.rb +16 -0
  26. data/lib/libui_paradise/examples/complex/016_grid_example.rb +31 -0
  27. data/lib/libui_paradise/examples/complex/017_unicode_text_example.rb +30 -0
  28. data/lib/libui_paradise/examples/complex/018_spinbutton_example.rb +33 -0
  29. data/lib/libui_paradise/examples/complex/019_combo_box_example.rb +50 -0
  30. data/lib/libui_paradise/examples/complex/020_checkbox_example.rb +81 -0
  31. data/lib/libui_paradise/examples/complex/021_font_example.rb +115 -0
  32. data/lib/libui_paradise/examples/complex/022_simple_notepad_example.rb +25 -0
  33. data/lib/libui_paradise/examples/complex/023_msg_box_error.rb +27 -0
  34. data/lib/libui_paradise/examples/complex/024_parse_config_file_example.config +6 -0
  35. data/lib/libui_paradise/examples/complex/024_parse_config_file_example.rb +15 -0
  36. data/lib/libui_paradise/examples/complex/025_colour_button.rb +53 -0
  37. data/lib/libui_paradise/examples/complex/026_basic_table_image.rb +96 -0
  38. data/lib/libui_paradise/examples/complex/027_basic_button_example.rb +19 -0
  39. data/lib/libui_paradise/examples/complex/028_try_for_automatic_button_press_event_after_a_delay.rb +47 -0
  40. data/lib/libui_paradise/examples/complex/029_progressbar_example.rb +116 -0
  41. data/lib/libui_paradise/examples/complex/030_entry_responds_to_comment_as_synonymous_to_the_enter_key_pressed_example.rb +140 -0
  42. data/lib/libui_paradise/examples/complex/031_notification_functionality_example.rb +96 -0
  43. data/lib/libui_paradise/examples/complex/032_simple_window_example.rb +69 -0
  44. data/lib/libui_paradise/examples/complex/033_daemonize_and_exit_after_delay_example.rb +91 -0
  45. data/lib/libui_paradise/examples/simple/001_open_file_example.rb +35 -0
  46. data/lib/libui_paradise/examples/simple/002_histogram_example.rb +207 -0
  47. data/lib/libui_paradise/examples/simple/003_fancy_text_example.rb +220 -0
  48. data/lib/libui_paradise/examples/simple/004_date_time_picker.rb +52 -0
  49. data/lib/libui_paradise/examples/simple/005_text_drawing_example.rb +185 -0
  50. data/lib/libui_paradise/examples/simple/006_midi_player.rb +96 -0
  51. data/lib/libui_paradise/examples/simple/007_control_gallery.rb +191 -0
  52. data/lib/libui_paradise/examples/simple/008_basic_area_example.rb +56 -0
  53. data/lib/libui_paradise/examples/simple/009_spectrum.rb +107 -0
  54. data/lib/libui_paradise/examples/simple/README.md +7 -0
  55. data/lib/libui_paradise/experimental/dsl.rb +17 -0
  56. data/lib/libui_paradise/extensions/counters.rb +58 -0
  57. data/lib/libui_paradise/extensions/extensions.rb +29 -0
  58. data/lib/libui_paradise/extensions/hash_fiddle_pointer_widgets.rb +150 -0
  59. data/lib/libui_paradise/extensions/misc.rb +754 -0
  60. data/lib/libui_paradise/fiddle/pointer.rb +1157 -0
  61. data/lib/libui_paradise/generic_window/README.md +9 -0
  62. data/lib/libui_paradise/generic_window/generic_window.rb +79 -0
  63. data/lib/libui_paradise/images/LIBUI_PARADISE_LOGO.png +0 -0
  64. data/lib/libui_paradise/images/README.md +2 -0
  65. data/lib/libui_paradise/images/form_example.png +0 -0
  66. data/lib/libui_paradise/libui_classes/box.rb +156 -0
  67. data/lib/libui_paradise/libui_classes/grid.rb +55 -0
  68. data/lib/libui_paradise/libui_classes/libui_classes.rb +1610 -0
  69. data/lib/libui_paradise/project/project.rb +28 -0
  70. data/lib/libui_paradise/prototype/README.md +3 -0
  71. data/lib/libui_paradise/prototype/prototype.rb +107 -0
  72. data/lib/libui_paradise/requires/require_the_libui_classes.rb +29 -0
  73. data/lib/libui_paradise/requires/require_the_libui_paradise_project.rb +12 -0
  74. data/lib/libui_paradise/toplevel_methods/misc.rb +13 -0
  75. data/lib/libui_paradise/version/version.rb +17 -0
  76. data/lib/libui_paradise.rb +1 -0
  77. data/libui_paradise.gemspec +49 -0
  78. data/test/testing_generic_window.rb +19 -0
  79. metadata +156 -0
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'libui_paradise/examples/complex/013_form_example.rb'
6
+ # =========================================================================== #
7
+ require 'libui_paradise/autoinclude'
8
+
9
+ window = margined_window('Form Example', 250, 150, 0)
10
+
11
+ outer_vbox = padded_vbox
12
+
13
+ hbox1 = padded_hbox
14
+ hbox1.minimal(text('First Name'), 0)
15
+ @first_name_entry = entry
16
+ hbox1.minimal(@first_name_entry, 0)
17
+ outer_vbox.minimal(hbox1, 0)
18
+
19
+ hbox2 = padded_hbox
20
+ hbox2.minimal(text('Last Name'), 0)
21
+ @last_name_entry = entry
22
+ hbox2.minimal(@last_name_entry, 0)
23
+ outer_vbox.minimal(hbox2, 0)
24
+
25
+ button_display_name = button('Display Name')
26
+ button_display_name.on_clicked {
27
+ ui_msg_box(
28
+ :default,
29
+ 'Name',
30
+ "#{@first_name_entry.text?} #{@last_name_entry.text?}"
31
+ )
32
+ }
33
+
34
+ outer_vbox.minimal(hsep, 0)
35
+ outer_vbox.minimal(button_display_name, 1)
36
+
37
+ window.child = outer_vbox
38
+ window.intelligent_quit
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # '014_text_example.rb'
6
+ # =========================================================================== #
7
+ require 'libui_paradise/autoinclude'
8
+
9
+ window = padded_main_window('Text Example', 200, 100, 1)
10
+
11
+ outer_vbox = padded_vbox
12
+ text = ui_text
13
+
14
+ outer_vbox.minimal(text, 1)
15
+
16
+ text.set_text('Hello world!')
17
+ window.child = outer_vbox
18
+ window.intelligent_quit
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # 024_text_view_example.rb
6
+ # =========================================================================== #
7
+ require 'libui_paradise/autoinclude'
8
+
9
+ window = padded_main_window('Text View Example', 500, 300, 0)
10
+
11
+ outer_vbox = padded_vbox
12
+ text = multiline_entry('Hello world! This can be set to read only via .is_read_only().')
13
+ # text.is_read_only
14
+ outer_vbox.minimal(text, 1)
15
+ window.child = outer_vbox
16
+ window.intelligent_quit
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # This example shows how to use the grid-related aspects of ruby-libui.
6
+ # =========================================================================== #
7
+ # require 'libui_paradise/016_grid_example.rb'
8
+ # =========================================================================== #
9
+ require 'libui_paradise/autoinclude'
10
+
11
+ window = padded_main_window('A simple grid-example', 1200, 200, 15)
12
+
13
+ grid = ui_padded_grid
14
+ UI.grid_append(grid, text('Yo1'), 0, 0, 1, 1, 0, 0, 1, 0)
15
+ UI.grid_append(grid, text('Yo2'), 1, 0, 1, 1, 0, 0, 1, 0)
16
+ UI.grid_append(grid, text('Yo3'), 2, 0, 1, 1, 0, 0, 1, 0)
17
+
18
+ UI.grid_append(grid, text('Yo4'), 0, 1, 1, 1, 0, 0, 1, 0)
19
+ UI.grid_append(grid, text('Yo5'), 1, 1, 1, 1, 0, 0, 1, 0)
20
+ UI.grid_append(grid, text('Yo6'), 2, 1, 1, 1, 0, 0, 1, 0)
21
+
22
+ grid.hash_grid(
23
+ text('Yo7'),
24
+ { left: 2, top: 3, xspan: 3, yspan: 3, hexpand: 0, halign: 0, vexpand: 0, valign: 0 }
25
+ )
26
+
27
+ vbox = padded_vbox
28
+ vbox << grid
29
+
30
+ window.child = vbox
31
+ window.intelligent_exit
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # This example just shows that unicode text works.
6
+ # =========================================================================== #
7
+ # require 'examples/complex/017_unicode_text_example.rb'
8
+ # =========================================================================== #
9
+ require 'libui_paradise/autoinclude'
10
+
11
+ window = ui_margined_main_window('Unicode Text Example', 1200, 200, 15)
12
+
13
+ outer_vbox = padded_vbox
14
+ text = text(
15
+ "This is some text. You do not even have to wrap it - the newlines will
16
+ appear in the text as-is.
17
+
18
+ If something is supported then unicode should be able to show that.
19
+
20
+ Let's test this next with some unicode:
21
+
22
+ 🎉 用户界面 사용자 인터페이스
23
+ ₀₁₂₃₄₅₆₇₈₉
24
+
25
+ ")
26
+
27
+ outer_vbox << text
28
+
29
+ window.child = outer_vbox
30
+ window.intelligent_quit
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # This example just shows a spinbutton example.
6
+ # =========================================================================== #
7
+ # require '018_spinbutton_example.rb'
8
+ # =========================================================================== #
9
+ require 'libui_paradise/autoinclude'
10
+
11
+ window = padded_main_window('Spinbutton Example', 250, 70, 1)
12
+
13
+ outer_vbox = padded_vbox
14
+ spinbutton = ui_spinbutton(0, 100)
15
+ spinbutton.set_value(42)
16
+
17
+ # =========================================================================== #
18
+ # Add the on-spin event next:
19
+ # =========================================================================== #
20
+ spinbox_changed_callback = proc { |pointer|
21
+ # ========================================================================= #
22
+ # Notify the user that the spinbox-value has changed.
23
+ # ========================================================================= #
24
+ puts "Changed value to: #{UI.spinbox_value(pointer)}"
25
+ 0
26
+ }
27
+
28
+ LibUI.spinbox_on_changed(spinbutton, spinbox_changed_callback, nil)
29
+
30
+ outer_vbox << spinbutton
31
+
32
+ window.child = outer_vbox
33
+ window.intelligent_quit
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require '019_combo_box_example.rb'
6
+ # =========================================================================== #
7
+ require 'libui_paradise/autoinclude'
8
+
9
+ TITLE = 'Combo Box Example'
10
+ WIDTH = 500
11
+ HEIGHT = 250
12
+ main_window = ui_main_window(TITLE, WIDTH, HEIGHT, 0)
13
+
14
+ @entry = ui_entry
15
+
16
+ @combo_box = ui_combobox(
17
+ [
18
+ 'combobox Item 1',
19
+ 'combobox Item 2',
20
+ 'combobox Item 3'
21
+ ]
22
+ )
23
+
24
+ # =========================================================================== #
25
+ # The next code used to be in place until September 2021. I will retain it
26
+ # here in the event that we need to use it again one day.
27
+ # =========================================================================== #
28
+
29
+ # combobox_selected_callback = proc { |pointer|
30
+ # e "New combobox selection: #{UI.combobox_selected(pointer)}"
31
+ # @entry.set_text(selected?(pointer))
32
+ # }
33
+ #
34
+ # UI.combobox_on_selected(@combo_box, combobox_selected_callback, nil)
35
+
36
+ ui_sync_connect(@combo_box, @entry)
37
+
38
+ box = padded_vbox
39
+ box << @combo_box
40
+ box << @entry
41
+
42
+ button_clear_the_combo_box = LibuiParadise.button('Clear the combo box')
43
+ button_clear_the_combo_box.on_clicked {
44
+ e 'Trying to clear the combo-box next.'
45
+ @combo_box.clear
46
+ }
47
+
48
+ box.minimal(button_clear_the_combo_box)
49
+ main_window.child = box
50
+ main_window.intelligent_exit
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require '020_checkbox_example'
6
+ # =========================================================================== #
7
+ require 'libui_paradise/autoinclude'
8
+
9
+ # =========================================================================== #
10
+ # === HEIGHT
11
+ # =========================================================================== #
12
+ HEIGHT = 120
13
+
14
+ should_quit_callback = proc {
15
+ LibUI.control_destroy(MAIN_WINDOW)
16
+ LibUI.quit
17
+ 0
18
+ }
19
+
20
+ open_menu_item_clicked = proc {
21
+ puts "Clicked 'Open'"
22
+ 0
23
+ }
24
+
25
+ save_menu_item_clicked = proc {
26
+ puts "Clicked 'Save'"
27
+ 0
28
+ }
29
+
30
+ # =========================================================================== #
31
+ # Create 'File' menu with a few items and callbacks when the items are
32
+ # clicked.
33
+ # =========================================================================== #
34
+ menu = UI.menu('File')
35
+ open_menu_item = UI.menu_append_item(menu, 'Open')
36
+ UI.menu_item_on_clicked(open_menu_item, open_menu_item_clicked, nil)
37
+ save_menu_item = UI.menu_append_item(menu, 'Save')
38
+ UI.menu_item_on_clicked(save_menu_item, save_menu_item_clicked, nil)
39
+ UI.menu_append_quit_item(menu)
40
+ UI.on_should_quit(should_quit_callback, nil)
41
+
42
+ # =========================================================================== #
43
+ # Create the 'Help' menu
44
+ # =========================================================================== #
45
+ help_menu = UI.menu('Help')
46
+ UI.menu_append_item(help_menu, 'Help')
47
+ UI.menu_append_about_item(help_menu)
48
+
49
+ vbox = UI.vbox
50
+
51
+ a_hbox = UI.hbox
52
+ UI.box_set_padded(vbox, 1)
53
+ UI.box_set_padded(a_hbox, 1)
54
+
55
+ vbox << a_hbox
56
+
57
+ group = UI.new_group('Top Group')
58
+ UI.group_set_margined(group, 1)
59
+ a_hbox.add(group, 0)
60
+
61
+ inner = UI.vbox
62
+ UI.box_set_padded(inner, 1)
63
+ UI.group_set_child(group, inner)
64
+
65
+ checkbox = UI.checkbox('Checkbox')
66
+ checkbox_toggle_callback = proc { |ptr|
67
+ checked = UI.checkbox_checked(ptr) == 1
68
+ UI.checkbox_set_text(ptr, "I am the checkbox (#{checked})")
69
+ }
70
+
71
+ UI.checkbox_on_toggled(checkbox, checkbox_toggle_callback, nil)
72
+ inner.add(checkbox, 0)
73
+
74
+ MAIN_WINDOW = UI.window('hello world', 600, HEIGHT, 1)
75
+
76
+ UI.window_set_margined(MAIN_WINDOW, 1)
77
+ UI.window_set_child(MAIN_WINDOW, vbox)
78
+
79
+ UI.window_on_closing(MAIN_WINDOW, should_quit_callback, nil)
80
+ MAIN_WINDOW.control_show
81
+ UI.main_then_quit
@@ -0,0 +1,115 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === 021_font_example.rb
6
+ # =========================================================================== #
7
+ # This example shows how to display coloured text.
8
+ #
9
+ # An AttributedString is a string which also contains information
10
+ # about styles such as text color, font, font size. It will be
11
+ # drawn in an UiArea element.
12
+ # =========================================================================== #
13
+ # require 'libui_paradise/examples/complex/021_font_example.rb'
14
+ # =========================================================================== #
15
+ class FontExample
16
+
17
+ require 'libui_paradise'
18
+ include LibuiParadise::Extensions
19
+
20
+ # ========================================================================= #
21
+ # === USE_THIS_FONT
22
+ #
23
+ # Specify a certain font to use.
24
+ # ========================================================================= #
25
+ USE_THIS_FONT = 'Georgia'
26
+
27
+ # ========================================================================= #
28
+ # === USE_THIS_FONT_SIZE
29
+ # ========================================================================= #
30
+ USE_THIS_FONT_SIZE = 25
31
+
32
+ # ========================================================================= #
33
+ # === TITLE
34
+ # ========================================================================= #
35
+ TITLE = 'Font Example'
36
+
37
+ # ========================================================================= #
38
+ # === WIDTH
39
+ # ========================================================================= #
40
+ WIDTH = 500
41
+
42
+ # ========================================================================= #
43
+ # === initialize
44
+ # ========================================================================= #
45
+ def initialize(
46
+ run_already = true
47
+ )
48
+ run if run_already
49
+ end
50
+
51
+ # ========================================================================= #
52
+ # === run
53
+ # ========================================================================= #
54
+ def run
55
+ handler = LibUI::FFI::AreaHandler.malloc
56
+ area = LibUI.new_area(handler)
57
+ str1 = 'At last Ygramul sensed that something was coming toward her.'
58
+ attr_str = LibuiParadise.fancy_text('')
59
+ def attr_str.append(what)
60
+ color_attribute = LibUI.new_color_attribute(0.5, 0.0, 0.25, 0.7)
61
+ start = LibUI.attributed_string_len(self)
62
+ LibUI.attributed_string_append_unattributed(self, what)
63
+ LibUI.attributed_string_set_attribute(self, color_attribute, start, start + what.size)
64
+ LibUI.attributed_string_append_unattributed(self, "\n\n")
65
+ end
66
+ attr_str.append(str1)
67
+ handler_draw_event = Fiddle::Closure::BlockCaller.new(0, [1, 1, 1]) { |_, _, adp|
68
+ area_draw_params = LibUI::FFI::AreaDrawParams.new(adp)
69
+ default_font = font {{
70
+ font_size: USE_THIS_FONT_SIZE,
71
+ font_family: USE_THIS_FONT,
72
+ italic: false,
73
+ stretch: 2,
74
+ weight: 500
75
+ }}
76
+
77
+ params = ui_draw_text_layout_params
78
+
79
+ params.String = attr_str
80
+ params.DefaultFont = default_font
81
+ params.Width = area_draw_params.AreaWidth
82
+ params.Align = 0
83
+ text_layout = LibUI.draw_new_text_layout(params)
84
+ LibUI.draw_text(area_draw_params.Context, text_layout, 0, 0)
85
+ LibUI.draw_free_text_layout(text_layout)
86
+ }
87
+ # =========================================================================== #
88
+ # Assigning to local variables:
89
+ #
90
+ # This is intended to protect Fiddle::Closure from garbage collection.
91
+ #
92
+ # =========================================================================== #
93
+ handler.Draw = handler_draw_event
94
+ handler.MouseEvent = (c1 = Fiddle::Closure::BlockCaller.new(0, [0]) {})
95
+ handler.MouseCrossed = (c2 = Fiddle::Closure::BlockCaller.new(0, [0]) {})
96
+ # handler.DragBroken = (c3 = Fiddle::Closure::BlockCaller.new(0, [0]) {})
97
+ # handler.KeyEvent = (c4 = Fiddle::Closure::BlockCaller.new(0, [0]) {})
98
+
99
+ box = ui_padded_vbox
100
+ box.maximal(area)
101
+ box.maximal(ui_hseparator)
102
+
103
+ main_window = ui_main_window(TITLE, WIDTH, 400, 1)
104
+ LibUI.window_set_margined(main_window, 1)
105
+ main_window.child = box
106
+ main_window.simple_exit
107
+ main_window.control_show
108
+ main_window.intelligent_exit
109
+ end
110
+
111
+ end
112
+
113
+ if __FILE__ == $PROGRAM_NAME
114
+ FontExample.new
115
+ end
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'libui_paradise/examples/022_simple_notepad_example.rb'
6
+ # =========================================================================== #
7
+ require 'libui_paradise/autoinclude'
8
+
9
+ window = padded_window('Notepad', 500, 300, 1)
10
+
11
+ vbox = ui_vbox
12
+
13
+ text_view = ui_text_view
14
+ text_view.set_text(
15
+ "This is an example.\nAs can be seen, text has been assigned to this.\n"
16
+ )
17
+ vbox << text_view
18
+ button_show_content = button('Paste the content of the text-buffer above')
19
+ button_show_content.on_clicked {
20
+ e text_view.text?.to_s
21
+ }
22
+
23
+ vbox << button_show_content
24
+ window.child = vbox
25
+ window.intelligent_exit
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require '005_msg_box_error.rb'
6
+ # =========================================================================== #
7
+ require 'libui_paradise/autoinclude'
8
+
9
+ TITLE = 'msg box error'
10
+ main_window = ui_padded_window(TITLE, 300, 200, 1)
11
+
12
+ button1 = ui_button('Text (click me)')
13
+ button1.on_clicked {
14
+ LibuiParadise::Extensions.message_box_error(
15
+ main_window,
16
+ 'Error',
17
+ "You clicked \nthe button"
18
+ )
19
+ 0
20
+ }
21
+
22
+ hbox = padded_hbox
23
+ hbox << button1
24
+ main_window.close_properly
25
+ main_window.child = hbox
26
+ main_window.control_show
27
+ UI.main_then_quit
@@ -0,0 +1,6 @@
1
+ width: 1000
2
+ height: 150
3
+ padding: 5
4
+ title: Parse Config File Example
5
+ favicon: :tabble
6
+ font_in_use: Sans 22
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require '022_'
6
+ # =========================================================================== #
7
+ require 'libui_paradise/autoinclude'
8
+
9
+ use_this_config_file = '024_parse_config_file_example.config'
10
+ window = LibuiParadise.parse_this_config_file(use_this_config_file)
11
+ outer_vbox = padded_vbox
12
+ text = text('The config file was '+use_this_config_file)
13
+ outer_vbox << text
14
+ window.child = outer_vbox
15
+ window.intelligent_quit
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # This button doesn't work properly right now. :(
6
+ # =========================================================================== #
7
+ # require '025_colour_button.rb'
8
+ # =========================================================================== #
9
+ require 'libui_paradise/autoinclude'
10
+
11
+ window = main_window('Colour Button', 500, 300, 0)
12
+ outer_vbox = padded_vbox
13
+ our_colour_button = ui_colour_button
14
+
15
+ # colour_button.on_changed {|callback|
16
+ # pp callback.class
17
+ # rgba = callback.color
18
+ # pp rgba
19
+ # }
20
+
21
+ # on_changed_proc = proc {|callback|
22
+ # rgba = callback.color
23
+ # pp rgba
24
+ # }
25
+
26
+ xyz = proc {|pointer|
27
+ # rgba = pointer.color
28
+ #pp rgba
29
+ pp pointer.to_s
30
+ nil
31
+ }
32
+
33
+ LibUI.color_button_on_changed(our_colour_button, xyz, nil)
34
+ # # rgba = pointer.color
35
+ # # pp rgba
36
+ # pp pointer
37
+ # pp pointer.to_s
38
+ # }
39
+
40
+
41
+ # UI.color_button_on_changed(color_button) do
42
+ # UI.area_queue_redraw_all(histogram)
43
+ # end
44
+
45
+ #, on_changed_proc.call, nil)
46
+
47
+ #UI.spinbox_on_changed(spinbox) do |ptr|
48
+ # puts "New Spinbox value: #{UI.spinbox_value(ptr)}"
49
+ #end
50
+
51
+ outer_vbox.minimal(our_colour_button, 1)
52
+ window.child = outer_vbox
53
+ window.intelligent_quit
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # This example displays images that can be freely downloaded from the
6
+ # Studio Ghibli website.
7
+ # =========================================================================== #
8
+ # require 'examples/complex/026_basic_table_image.rb'
9
+ # =========================================================================== #
10
+ require 'libui_paradise/autoinclude'
11
+ require 'chunky_png'
12
+ require 'open-uri'
13
+
14
+ N_TIMES = 10
15
+ # =========================================================================== #
16
+ # === REMOTE_URL
17
+ # =========================================================================== #
18
+ REMOTE_URL = 'https://www.ghibli.jp/gallery/thumb-redturtle%03d.png'
19
+
20
+ main_window = ui_main_window('The Red Turtle', 310, 350, 0)
21
+
22
+ hbox = ui_padded_hbox
23
+ main_window.simple_exit
24
+ main_window.child = hbox
25
+
26
+ # =========================================================================== #
27
+ # === IMAGES
28
+ # =========================================================================== #
29
+ IMAGES = []
30
+
31
+ N_TIMES.times { |i|
32
+ url = format(REMOTE_URL, (i + 1))
33
+ this_file = URI.open(url)
34
+ # =========================================================================== #
35
+ # Use ChunkyPNG::Canvas to get information about the image at hand.
36
+ # =========================================================================== #
37
+ canvas = ChunkyPNG::Canvas.from_io(this_file)
38
+ this_file.close
39
+ data = canvas.to_rgba_stream
40
+ width = canvas.width
41
+ height = canvas.height
42
+ # ========================================================================= #
43
+ # Add a new image next:
44
+ # ========================================================================= #
45
+ image = UI.new_image(width, height)
46
+ UI.image_append(image, data, width, height, width * 4)
47
+ IMAGES << image # Store all images in the following area.
48
+ rescue StandardError => error
49
+ warn url, error.message
50
+ }
51
+
52
+ # =========================================================================== #
53
+ # Protects BlockCaller objects from garbage collection.
54
+ # =========================================================================== #
55
+ @blockcaller = []
56
+ # =========================================================================== #
57
+ # === rbcallback
58
+ # =========================================================================== #
59
+ def rbcallback(*args, &block)
60
+ args << [0] if args.size == 1 # Argument types are ommited
61
+ blockcaller = Fiddle::Closure::BlockCaller.new(*args, &block)
62
+ @blockcaller << blockcaller
63
+ blockcaller
64
+ end
65
+
66
+ model_handler = LibUI::FFI::TableModelHandler.malloc
67
+ model_handler.NumColumns = rbcallback(4) { 1 }
68
+ model_handler.ColumnType = rbcallback(4) { 1 } # Image
69
+ model_handler.NumRows = rbcallback(4) { IMAGES.size }
70
+ model_handler.CellValue = rbcallback(1, [1, 1, 4, 4]) do |_, _, row, _column|
71
+ LibUI.new_table_value_image(IMAGES[row])
72
+ end
73
+ model_handler.SetCellValue = rbcallback(0, [0]) {}
74
+
75
+ model = LibUI.new_table_model(model_handler)
76
+
77
+ table_params = LibUI::FFI::TableParams.malloc
78
+ table_params.Model = model
79
+ table_params.RowBackgroundColorModelColumn = -1
80
+
81
+ table = ui_table(table_params)
82
+ UI.table_append_image_column(table, 'www.ghibli.jp/works/red-turtle', -1)
83
+ hbox.maximal(table)
84
+
85
+ main_window.show_the_controls
86
+
87
+ UI.window_on_closing(main_window) {
88
+ e 'Bye Bye'
89
+ UI.control_destroy(main_window)
90
+ UI.free_table_model(model)
91
+ IMAGES.each { |i| UI.free_image(i) }
92
+ UI.quit
93
+ 0
94
+ }
95
+
96
+ UI.main_then_quit
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'complex/027_basic_button_example.rb'
6
+ # =========================================================================== #
7
+ require 'libui_paradise/autoinclude'
8
+
9
+ main_window = main_window('hello world', 300, 200, 0)
10
+
11
+ button = button('Button')
12
+ button.on_clicked {|widget| # is a <Fiddle::Pointer:0x00005590774f1ca0 ptr=0x0000559077484c90 size=0 free=0x0000000000000000>
13
+ e 'The main button was clicked.'
14
+ ui_msg_box(main_window, 'Information', 'You clicked the button')
15
+ 0
16
+ }
17
+
18
+ main_window.child = button
19
+ main_window.intelligent_exit