libui_paradise 0.2.49 → 0.4.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +405 -259
  3. data/bin/libui_message +7 -0
  4. data/doc/README.gen +356 -131
  5. data/doc/todo/todo.md +14 -5
  6. data/lib/libui_paradise/autoinclude.rb +2 -1
  7. data/lib/libui_paradise/base/base.rb +51 -62
  8. data/lib/libui_paradise/base_module/base_module.rb +1514 -0
  9. data/lib/libui_paradise/colours/colours.rb +14 -2
  10. data/lib/libui_paradise/domain_specific_language/README.md +6 -0
  11. data/lib/libui_paradise/examples/complex/002_tabs_example.rb +1 -2
  12. data/lib/libui_paradise/examples/complex/003_open_file_button_example.rb +3 -5
  13. data/lib/libui_paradise/examples/complex/006_coloured_boxes_example.rb +2 -2
  14. data/lib/libui_paradise/examples/complex/007_slider_example.rb +10 -4
  15. data/lib/libui_paradise/examples/complex/008_radio_button_example.rb +2 -2
  16. data/lib/libui_paradise/examples/complex/009_separator_example.rb +2 -2
  17. data/lib/libui_paradise/examples/complex/010_table_example.rb +139 -49
  18. data/lib/libui_paradise/examples/complex/011_two_buttons_showing_how_to_enable_and_disable_them.rb +2 -1
  19. data/lib/libui_paradise/examples/complex/012_password_entry_example.rb +1 -1
  20. data/lib/libui_paradise/examples/complex/013_form_example.rb +1 -1
  21. data/lib/libui_paradise/examples/complex/014_text_example.rb +1 -1
  22. data/lib/libui_paradise/examples/complex/015_text_view_example.rb +4 -4
  23. data/lib/libui_paradise/examples/complex/016_grid_example.rb +20 -11
  24. data/lib/libui_paradise/examples/complex/017_unicode_text_example.rb +2 -2
  25. data/lib/libui_paradise/examples/complex/018_spinbutton_example.rb +1 -1
  26. data/lib/libui_paradise/examples/complex/019_combo_box_example.rb +1 -1
  27. data/lib/libui_paradise/examples/complex/020_checkbox_example.rb +5 -5
  28. data/lib/libui_paradise/examples/complex/021_font_example.rb +4 -3
  29. data/lib/libui_paradise/examples/complex/022_simple_notepad_example.rb +3 -3
  30. data/lib/libui_paradise/examples/complex/023_msg_box_error.rb +5 -5
  31. data/lib/libui_paradise/examples/complex/024_parse_config_file_example.rb +2 -2
  32. data/lib/libui_paradise/examples/complex/025_colour_button.rb +1 -1
  33. data/lib/libui_paradise/examples/complex/026_basic_table_image.rb +5 -8
  34. data/lib/libui_paradise/examples/complex/027_basic_button_example.rb +3 -3
  35. data/lib/libui_paradise/examples/complex/028_try_for_automatic_button_press_event_after_a_delay.rb +4 -5
  36. data/lib/libui_paradise/examples/complex/029_progressbar_example.rb +4 -5
  37. data/lib/libui_paradise/examples/complex/030_entry_responds_to_comment_as_synonymous_to_the_enter_key_pressed_example.rb +5 -6
  38. data/lib/libui_paradise/examples/complex/031_notification_functionality_example.rb +3 -2
  39. data/lib/libui_paradise/examples/complex/032_simple_window_example.rb +2 -1
  40. data/lib/libui_paradise/examples/complex/033_daemonize_and_exit_after_delay_example.rb +3 -2
  41. data/lib/libui_paradise/examples/complex/034_bold_text_example.rb +115 -0
  42. data/lib/libui_paradise/examples/complex/035_parse_into_table_example.rb +109 -0
  43. data/lib/libui_paradise/examples/simple/001_open_file_example.rb +1 -1
  44. data/lib/libui_paradise/examples/simple/002_histogram_example.rb +6 -6
  45. data/lib/libui_paradise/examples/simple/003_fancy_text_example.rb +80 -43
  46. data/lib/libui_paradise/examples/simple/005_text_drawing_example.rb +11 -11
  47. data/lib/libui_paradise/examples/simple/007_control_gallery.rb +21 -14
  48. data/lib/libui_paradise/examples/simple/009_spectrum.rb +7 -1
  49. data/lib/libui_paradise/examples/simple/010_font_button.rb +31 -0
  50. data/lib/libui_paradise/examples/simple/011_simple_notepad.rb +24 -0
  51. data/lib/libui_paradise/examples/simple/012_table_example.rb +71 -0
  52. data/lib/libui_paradise/examples/simple/013_scrolling_pane_example.rb +28 -0
  53. data/lib/libui_paradise/examples/simple/014_simple_entry_example.rb +30 -0
  54. data/lib/libui_paradise/examples/simple/015_slider_example.rb +32 -0
  55. data/lib/libui_paradise/fiddle/{pointer.rb → fiddle.rb} +768 -615
  56. data/lib/libui_paradise/generic_window/generic_window.rb +1 -1
  57. data/lib/libui_paradise/images/README.md +5 -2
  58. data/lib/libui_paradise/libui_classes/button.rb +31 -0
  59. data/lib/libui_paradise/libui_classes/entry.rb +35 -0
  60. data/lib/libui_paradise/libui_classes/grid.rb +14 -23
  61. data/lib/libui_paradise/libui_classes/hbox.rb +39 -0
  62. data/lib/libui_paradise/libui_classes/libui_classes.rb +9 -1595
  63. data/lib/libui_paradise/libui_classes/msg_box.rb +121 -0
  64. data/lib/libui_paradise/libui_classes/msg_box_error.rb +41 -0
  65. data/lib/libui_paradise/libui_classes/slider.rb +28 -0
  66. data/lib/libui_paradise/libui_classes/spinbox.rb +48 -0
  67. data/lib/libui_paradise/libui_classes/vbox.rb +38 -0
  68. data/lib/libui_paradise/project/project.rb +6 -1
  69. data/lib/libui_paradise/prototype/prototype.rb +8 -10
  70. data/lib/libui_paradise/requires/require_the_libui_classes.rb +2 -2
  71. data/lib/libui_paradise/requires/require_the_libui_paradise_project.rb +5 -3
  72. data/lib/libui_paradise/toplevel_methods/add_to_the_registered_widgets.rb +70 -0
  73. data/lib/libui_paradise/toplevel_methods/hash_fiddle_pointer_widgets.rb +37 -0
  74. data/lib/libui_paradise/toplevel_methods/toplevel_counters.rb +83 -0
  75. data/lib/libui_paradise/toplevel_methods/toplevel_methods.rb +792 -0
  76. data/lib/libui_paradise/version/version.rb +2 -2
  77. data/lib/libui_paradise.rb +0 -0
  78. data/libui_paradise.gemspec +5 -4
  79. data/test/testing_generic_window.rb +2 -0
  80. metadata +35 -30
  81. data/doc/SNIPPETS.md +0 -94
  82. data/lib/libui_paradise/extensions/counters.rb +0 -58
  83. data/lib/libui_paradise/extensions/extensions.rb +0 -29
  84. data/lib/libui_paradise/extensions/hash_fiddle_pointer_widgets.rb +0 -150
  85. data/lib/libui_paradise/extensions/misc.rb +0 -754
  86. data/lib/libui_paradise/libui_classes/box.rb +0 -156
  87. data/lib/libui_paradise/toplevel_methods/misc.rb +0 -13
@@ -0,0 +1,121 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'libui_paradise/libui_classes/msg_box.rb'
6
+ # =========================================================================== #
7
+ module LibuiParadise
8
+
9
+ # ========================================================================= #
10
+ # === LibuiParadise.msg_box
11
+ #
12
+ # Official API documentation for dialogs in libui-ng can be found here:
13
+ #
14
+ # https://raw.githubusercontent.com/libui-ng/libui-ng/master/unix/stddialogs.c
15
+ #
16
+ # The API signature for msg_box() in LibUI is as follows:
17
+ #
18
+ # GtkWindow *parent
19
+ # const char *title
20
+ # const char *description
21
+ # GtkMessageType type
22
+ # GtkButtonsType buttons
23
+ #
24
+ # So the first string is the title and the second string is the
25
+ # description that will be shown to the user.
26
+ #
27
+ # The following method is a convenience-wrapper over LibUI.msg_box().
28
+ #
29
+ # A Hash can also be passed into this method, to allow for more
30
+ # flexibility. The following line of code will demonstrate how
31
+ # this can then be used, via a Hash:
32
+ #
33
+ # message_box(
34
+ # text: 'Hello world!'
35
+ # )
36
+ #
37
+ # Or more verbose:
38
+ #
39
+ # LibuiParadise.message_box(text: 'Hello world!')
40
+ #
41
+ # ========================================================================= #
42
+ def self.msg_box(
43
+ main_window = :default_window,
44
+ title_to_use = '',
45
+ description_to_use = ''
46
+ )
47
+ # ======================================================================= #
48
+ # === Handle Hashes first
49
+ # ======================================================================= #
50
+ if main_window.is_a? Hash
51
+ # ===================================================================== #
52
+ # === :text
53
+ # ===================================================================== #
54
+ if main_window.has_key? :text
55
+ description_to_use = main_window.delete(:text)
56
+ end
57
+ # ===================================================================== #
58
+ # === :title_to_use
59
+ # ===================================================================== #
60
+ if main_window.has_key? :title_to_use
61
+ title_to_use = main_window.delete(:title_to_use)
62
+ end
63
+ if main_window and main_window.empty? # Handle empty Hashes as well here.
64
+ main_window = :default_window
65
+ end
66
+ # ======================================================================= #
67
+ # === Handle Strings next
68
+ # ======================================================================= #
69
+ elsif main_window.is_a?(String) and
70
+ title_to_use.is_a?(String) and
71
+ title_to_use.empty?
72
+ title_to_use = main_window.dup
73
+ main_window = :default_window # And re-set it here.
74
+ end
75
+ case main_window
76
+ # ======================================================================= #
77
+ # === :default_window
78
+ #
79
+ # Note that LibuiParadise.main_window? may be nil.
80
+ # ======================================================================= #
81
+ when :default_window,
82
+ :default
83
+ main_window = main_window?
84
+ end
85
+ if description_to_use.is_a? Array
86
+ description_to_use = description_to_use.join(' ').strip
87
+ end
88
+ # ======================================================================= #
89
+ # Next delegate towards LibUI.msg_box():
90
+ # ======================================================================= #
91
+ _ = ::LibUI.msg_box(
92
+ main_window,
93
+ title_to_use,
94
+ description_to_use
95
+ )
96
+ add_to_the_registered_widgets(_, __method__)
97
+ return _
98
+ end; self.instance_eval { alias ui_msg_box msg_box } # === LibuiParadise.ui_msg_box
99
+ self.instance_eval { alias message_to_the_user msg_box } # === LibuiParadise.message_to_the_user
100
+ self.instance_eval { alias message_box msg_box } # === LibuiParadise.message_box
101
+ self.instance_eval { alias popup_over_this_widget msg_box } # === LibuiParadise.popup_over_this_widget
102
+ self.instance_eval { alias popup_message msg_box } # === LibuiParadise.popup_message
103
+
104
+ # ========================================================================= #
105
+ # === LibuiParadise.notification
106
+ #
107
+ # This method can be used to show a quick message box to the end
108
+ # user.
109
+ # ========================================================================= #
110
+ def self.notification(
111
+ text = 'Backup complete!',
112
+ title_to_use = ''
113
+ )
114
+ ::LibuiParadise.message_box(
115
+ window: :default_window,
116
+ text: text,
117
+ title_to_use: title_to_use
118
+ )
119
+ end
120
+
121
+ end
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'libui_paradise/libui_classes/msg_box_error.rb'
6
+ # =========================================================================== #
7
+ module LibuiParadise
8
+
9
+ # ========================================================================= #
10
+ # === LibuiParadise.msg_box_error
11
+ # ========================================================================= #
12
+ def self.msg_box_error(
13
+ main_window = LibuiParadise.main_window?,
14
+ title_to_use = '',
15
+ whatever = ''
16
+ )
17
+ case main_window
18
+ # ======================================================================= #
19
+ # === :default
20
+ # ======================================================================= #
21
+ when :default
22
+ main_window = LibuiParadise.main_window?
23
+ end
24
+ # ======================================================================= #
25
+ # Delegate towards LibUI.msg_box_error() next:
26
+ # ======================================================================= #
27
+ _ = ::LibUI.msg_box_error(
28
+ main_window,
29
+ title_to_use,
30
+ whatever
31
+ )
32
+ add_to_the_registered_widgets(_, __method__)
33
+ return _
34
+ end; self.instance_eval { alias ui_msg_box_error msg_box_error } # === LibuiParadise.ui_msg_box_error
35
+ self.instance_eval { alias ui_error_msg msg_box_error } # === LibuiParadise.ui_error_msg
36
+ self.instance_eval { alias ui_error_message msg_box_error } # === LibuiParadise.ui_error_message
37
+ self.instance_eval { alias error_message_to_the_user msg_box_error } # === LibuiParadise.error_message_to_the_user
38
+ self.instance_eval { alias error_msg msg_box_error } # === LibuiParadise.error_msg
39
+ self.instance_eval { alias message_box_error msg_box_error } # === LibuiParadise.message_box_error
40
+
41
+ end
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'libui_paradise/libui_classes/slider.rb'
6
+ # =========================================================================== #
7
+ module LibuiParadise
8
+
9
+ require 'libui_paradise/toplevel_methods/add_to_the_registered_widgets.rb'
10
+
11
+ # ========================================================================= #
12
+ # === LibuiParadise.slider
13
+ #
14
+ # This method will return a slider widget.
15
+ # ========================================================================= #
16
+ def self.slider(
17
+ start_value = 0,
18
+ end_value = 100
19
+ )
20
+ _ = ::LibUI.new_slider(start_value, end_value)
21
+ # ======================================================================= #
22
+ # Register it at once:
23
+ # ======================================================================= #
24
+ add_to_the_registered_widgets(_, __method__)
25
+ return _
26
+ end; self.instance_eval { alias ui_slider slider } # === LibuiParadise.ui_slider
27
+
28
+ end
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'libui_paradise/libui_classes/spinbox.rb'
6
+ # =========================================================================== #
7
+ module LibuiParadise
8
+
9
+ # ========================================================================= #
10
+ # === LibuiParadise.spinbox
11
+ #
12
+ # This method will return a spin-button, also called a spin-box.
13
+ #
14
+ # The first argument is the start value; the second argument is the end
15
+ # value.
16
+ #
17
+ # The source code can be found here:
18
+ #
19
+ # https://raw.githubusercontent.com/libui-ng/libui-ng/master/unix/spinbox.c
20
+ #
21
+ # ========================================================================= #
22
+ def self.spinbox(
23
+ start_point = 0,
24
+ end_point = 100,
25
+ increment = 1 # This is currently ignored.
26
+ )
27
+ if start_point.is_a? Hash
28
+ # ===================================================================== #
29
+ # === :end
30
+ # ===================================================================== #
31
+ if start_point.has_key? :end
32
+ end_point = start_point[:end]
33
+ end
34
+ # ===================================================================== #
35
+ # === :start
36
+ # ===================================================================== #
37
+ if start_point.has_key? :start
38
+ start_point = start_point[:start]
39
+ end
40
+ end
41
+ _ = ::LibUI.new_spinbox(start_point.to_i, end_point.to_i)
42
+ add_to_the_registered_widgets(_, __method__)
43
+ return _
44
+ end; self.instance_eval { alias ui_spinbox spinbox } # === LibuiParadise.ui_spinbox
45
+ self.instance_eval { alias ui_spinbutton spinbox } # === LibuiParadise.ui_spinbutton
46
+ self.instance_eval { alias spinbutton spinbox } # === LibuiParadise.spinbutton
47
+
48
+ end
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'libui_paradise/libui_classes/vbox.rb'
6
+ # =========================================================================== #
7
+ module LibuiParadise
8
+
9
+ # ========================================================================= #
10
+ # === LibuiParadise.vbox (vbox tag)
11
+ #
12
+ # This method will create a vertical box.
13
+ # ========================================================================= #
14
+ def self.vbox(*optional_widgets)
15
+ _ = ::LibUI.new_vertical_box
16
+ add_to_the_registered_widgets(_, __method__)
17
+ if optional_widgets and !optional_widgets.empty?
18
+ optional_widgets.flatten.each {|this_widget| _ << this_widget }
19
+ end
20
+ return _
21
+ end; self.instance_eval { alias ui_vbox vbox } # === LibuiParadise.ui_vbox
22
+ self.instance_eval { alias vertical_box vbox } # === LibuiParadise.vertical_box
23
+ self.instance_eval { alias create_vbox vbox } # === LibuiParadise.create_vbox
24
+ self.instance_eval { alias libui_vbox vbox } # === LibuiParadise.libui_vbox
25
+
26
+ # ========================================================================= #
27
+ # === LibuiParadise.ui_padded_vbox
28
+ #
29
+ # This method will call .is_padded on the vbox after it has been
30
+ # initialized.
31
+ # ========================================================================= #
32
+ def self.ui_padded_vbox(*optional_widgets)
33
+ _ = ::LibuiParadise.vbox(optional_widgets)
34
+ _.is_padded
35
+ return _
36
+ end; self.instance_eval { alias padded_vbox ui_padded_vbox } # === LibuiParadise.padded_vbox
37
+
38
+ end
@@ -8,7 +8,7 @@
8
8
  module LibuiParadise
9
9
 
10
10
  # ========================================================================= #
11
- # === PROJECT_BASE_DIRECTORY
11
+ # === LibuiParadise::PROJECT_BASE_DIRECTORY
12
12
  # ========================================================================= #
13
13
  PROJECT_BASE_DIRECTORY =
14
14
  File.absolute_path("#{__dir__}/..")+'/'
@@ -25,4 +25,9 @@ module LibuiParadise
25
25
  self.instance_eval { alias project_base_dir? project_base_dir? } # === LibuiParadise.project_base_dir?
26
26
  self.instance_eval { alias project_base_directory? project_base_dir? } # === LibuiParadise.project_base_directory?
27
27
 
28
+ end
29
+
30
+ if __FILE__ == $PROGRAM_NAME
31
+ alias e puts
32
+ e LibuiParadise.project_base_dir?
28
33
  end
@@ -4,18 +4,15 @@
4
4
  # =========================================================================== #
5
5
  # === LibuiParadise::GUI::LibUI::Prototype
6
6
  # =========================================================================== #
7
+ require 'libui_paradise/base/base.rb'
8
+
7
9
  module LibuiParadise
8
10
 
9
11
  module GUI
10
12
 
11
13
  module LibUI
12
14
 
13
- class Prototype # === LibuiParadise::GUI::LibUI::Prototype
14
-
15
- alias e puts
16
-
17
- require 'libui_paradise'
18
- include LibuiParadise::Extensions
15
+ class Prototype < LibuiParadise::Base # === LibuiParadise::GUI::LibUI::Prototype
19
16
 
20
17
  # require 'bioroebe/gui/shared_code/levensthein_distance/levensthein_distance_module.rb'
21
18
  # include Bioroebe::GUI::LevenstheinDistanceModule
@@ -23,7 +20,7 @@ class Prototype # === LibuiParadise::GUI::LibUI::Prototype
23
20
  # ========================================================================= #
24
21
  # === TITLE
25
22
  # ========================================================================= #
26
- TITLE = 'A prototype for LibUI'
23
+ TITLE = 'A prototype GUI for LibUI'
27
24
 
28
25
  # ========================================================================= #
29
26
  # === WIDTH
@@ -49,6 +46,7 @@ class Prototype # === LibuiParadise::GUI::LibUI::Prototype
49
46
  # === reset (reset tag)
50
47
  # ========================================================================= #
51
48
  def reset
49
+ reset_the_internal_hash
52
50
  title_width_height(TITLE, WIDTH, HEIGHT)
53
51
  end
54
52
 
@@ -59,11 +57,11 @@ class Prototype # === LibuiParadise::GUI::LibUI::Prototype
59
57
  # ======================================================================= #
60
58
  # === @window
61
59
  # ======================================================================= #
62
- @window = ui_padded_main_window(title?, width?, height?, 0)
60
+ @window = padded_main_window(title?, width?, height?, 0)
63
61
  end
64
62
 
65
63
  # ========================================================================= #
66
- # === run
64
+ # === run (run tag)
67
65
  # ========================================================================= #
68
66
  def run
69
67
  create_skeleton_then_connect_skeleton
@@ -72,7 +70,7 @@ class Prototype # === LibuiParadise::GUI::LibUI::Prototype
72
70
  # First add the two buttons on top:
73
71
  # ======================================================================= #
74
72
  hbox_on_top = padded_hbox
75
- button_refresh = ui_button('Refresh')
73
+ button_refresh = create_button('Refresh')
76
74
  button_refresh.on_clicked {
77
75
  e 'TODO: Refresh this ... or add any other functionality.'
78
76
  }
@@ -11,8 +11,8 @@ module LibuiParadise
11
11
  # ========================================================================= #
12
12
  # === LibuiParadise.do_require_the_libui_classes
13
13
  #
14
- # This method will batch-require all libui-paradise classes under
15
- # the libui_classes/ subdirectory.
14
+ # This method will batch-require all libui-paradise classes residing
15
+ # under the libui_classes/ subdirectory.
16
16
  # ========================================================================= #
17
17
  def self.do_require_the_libui_classes
18
18
  target = LibuiParadise.project_base_dir?+'libui_classes/*.rb'
@@ -4,9 +4,11 @@
4
4
  # =========================================================================== #
5
5
  # require 'libui_paradise/requires/require_the_libui_paradise_project.rb'
6
6
  # =========================================================================== #
7
- require 'libui_paradise/extensions/extensions.rb' # This also pulls in another file, called pointer.rb.
7
+ require 'libui_paradise/base_module/base_module.rb' # This also pulls in another file, called pointer.rb.
8
8
  require 'libui_paradise/project/project.rb'
9
- require 'libui_paradise/toplevel_methods/misc.rb'
10
9
  require 'libui_paradise/requires/require_the_libui_classes.rb'
10
+ require 'libui_paradise/colours/colours.rb'
11
11
 
12
- LibuiParadise.do_require_the_libui_classes
12
+ LibuiParadise.do_require_the_libui_classes
13
+
14
+ LibuiParadise.init # This is the new default since as of December 2023.
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'libui_paradise/toplevel_methods/add_to_the_registered_widgets.rb'
6
+ # =========================================================================== #
7
+ module LibuiParadise
8
+
9
+ # ========================================================================= #
10
+ # === @hash_fiddle_pointer_widgets
11
+ # ========================================================================= #
12
+ @hash_fiddle_pointer_widgets = {}
13
+
14
+ # ========================================================================= #
15
+ # === LibuiParadise.register_this_fiddle_pointer_widget
16
+ #
17
+ # This method registers the particular widget in use.
18
+ #
19
+ # Every new_* method available via LibUI.new* that creates a new widget
20
+ # has to be registered via this method here, by calling it.
21
+ #
22
+ # That way we have a main Hash that contains lots of Fiddle::Pointers
23
+ # and we can, at a later time, modify these Fiddle::Pointer or call
24
+ # toplevel methods with these registered pointers. This will only
25
+ # work if we have registered these pointers, though, which is why
26
+ # each method that creates a new libui-widget has to make use of
27
+ # this method here.
28
+ #
29
+ # Since as of November 2022, the main window is also handled by
30
+ # this method here. The proper way to refer to it is now via
31
+ # LibuiParadise.main_window?.
32
+ #
33
+ # The mandatory entries given to this method must conform to the
34
+ # following format:
35
+ #
36
+ # object_id -> [:the_fiddle_pointer_widget, :the_type]
37
+ #
38
+ # In other words, a key (as an Integer), and an Array as
39
+ # its primary value.
40
+ #
41
+ # The object_id will be determined automatically, so it can
42
+ # be omitted. It is the value that is simply returned by
43
+ # calling the .object_id method, so we do not have to do
44
+ # anything else here.
45
+ #
46
+ # The very last argument of the two-member Array should be a
47
+ # symbol, such as :grid. This is automatically ensured via a
48
+ # call to __method__ which will return a Symbol. That way we
49
+ # can then call the correct method internally, once we know
50
+ # we have a :grid or any other widget.
51
+ # ========================================================================= #
52
+ def self.register_this_fiddle_pointer_widget(
53
+ the_fiddle_pointer_widget,
54
+ the_type_of_the_widget = nil # such as :grid or :entry
55
+ )
56
+ # ======================================================================= #
57
+ # Determine the object-id automatically next:
58
+ # ======================================================================= #
59
+ object_id_to_use = the_fiddle_pointer_widget.object_id
60
+ # ======================================================================= #
61
+ # Then, store it on the main Hash.
62
+ # ======================================================================= #
63
+ @hash_fiddle_pointer_widgets[object_id_to_use] =
64
+ [
65
+ the_fiddle_pointer_widget,
66
+ the_type_of_the_widget
67
+ ]
68
+ end; self.instance_eval { alias add_to_the_registered_widgets register_this_fiddle_pointer_widget } # === LibuiParadise::Extensions.add_to_the_registered_widgets
69
+
70
+ end
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'libui_paradise/toplevel_methods/hash_fiddle_pointer_widgets.rb'
6
+ # =========================================================================== #
7
+ module LibuiParadise
8
+
9
+ # ========================================================================= #
10
+ # === @hash_fiddle_pointer_widgets
11
+ #
12
+ # This hash will contain all widgets, via pointer.
13
+ # ========================================================================= #
14
+ @hash_fiddle_pointer_widgets = {}
15
+
16
+ # ========================================================================= #
17
+ # === LibuiParadise.hash_fiddle_pointer_widgets?
18
+ # ========================================================================= #
19
+ def self.hash_fiddle_pointer_widgets?
20
+ @hash_fiddle_pointer_widgets
21
+ end
22
+
23
+ # ========================================================================= #
24
+ # === LibuiParadise.current_widget_pointer?
25
+ #
26
+ # This method will always point to the last widget element that was
27
+ # added.
28
+ # ========================================================================= #
29
+ def self.current_widget_pointer?
30
+ hash_fiddle_pointer_widgets?.values.last.first
31
+ end
32
+
33
+ end
34
+
35
+ if __FILE__ == $PROGRAM_NAME
36
+ pp LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
37
+ end
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'libui_paradise/toplevel_methods/toplevel_counters.rb'
6
+ # =========================================================================== #
7
+ module LibuiParadise
8
+
9
+ # ========================================================================= #
10
+ # === @counter_top
11
+ # ========================================================================= #
12
+ @counter_top = 0
13
+
14
+ # ========================================================================= #
15
+ # === @counter_left
16
+ # ========================================================================= #
17
+ @counter_left = 0
18
+
19
+ # ========================================================================= #
20
+ # === LibuiParadise.reset_the_counters
21
+ #
22
+ # This method can be used to reset the two counters defined above.
23
+ # ========================================================================= #
24
+ def self.reset_the_counters
25
+ @counter_top = 0
26
+ @counter_left = 0
27
+ end; self.instance_eval { alias reset_the_grid_counter reset_the_counters } # === LibuiParadise.reset_the_grid_counter
28
+
29
+ # ========================================================================= #
30
+ # === LibuiParadise.counter_left?
31
+ # ========================================================================= #
32
+ def self.counter_left?
33
+ @counter_left
34
+ end; self.instance_eval { alias counter_left counter_left? } # === LibuiParadise.counter_left
35
+ self.instance_eval { alias left_counter counter_left? } # === LibuiParadise.left_counter
36
+ self.instance_eval { alias left_counter? counter_left? } # === LibuiParadise.left_counter?
37
+
38
+ # ========================================================================= #
39
+ # === LibuiParadise.increment_counter_left
40
+ # ========================================================================= #
41
+ def self.increment_counter_left
42
+ @counter_left += 1
43
+ end; self.instance_eval { alias increment_the_left_counter increment_counter_left } # === LibuiParadise.increment_the_left_counter
44
+
45
+ # ========================================================================= #
46
+ # === LibuiParadise.counter_left=
47
+ # ========================================================================= #
48
+ def self.counter_left=(i = 1)
49
+ @counter_left = i
50
+ end
51
+
52
+ # ========================================================================= #
53
+ # === LibuiParadise.counter_top?
54
+ # ========================================================================= #
55
+ def self.counter_top?
56
+ @counter_top
57
+ end; self.instance_eval { alias counter_top counter_top? } # === LibuiParadise.counter_top
58
+ self.instance_eval { alias top_counter counter_top? } # === LibuiParadise.top_counter
59
+ self.instance_eval { alias top_counter? counter_top? } # === LibuiParadise.top_counter?
60
+
61
+ # ========================================================================= #
62
+ # === LibuiParadise.counter_top=
63
+ # ========================================================================= #
64
+ def self.counter_top=(i = 1)
65
+ @counter_top = i
66
+ end
67
+
68
+ # ========================================================================= #
69
+ # === LibuiParadise.counters?
70
+ # ========================================================================= #
71
+ def self.counters?
72
+ return [@counter_left, @counter_top]
73
+ end
74
+
75
+ # ========================================================================= #
76
+ # === LibuiParadise.new_row
77
+ # ========================================================================= #
78
+ def self.new_row
79
+ ::LibuiParadise.counter_left = 0 # Reset towards 0, which means "very left".
80
+ ::LibuiParadise.counter_top += 1 # And we go down to the next row here.
81
+ end
82
+
83
+ end