libui_paradise 0.2.49 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +241 -116
  3. data/bin/libui_message +7 -0
  4. data/doc/README.gen +191 -56
  5. data/doc/SNIPPETS.md +1 -30
  6. data/doc/todo/todo.md +13 -8
  7. data/lib/libui_paradise/base/base.rb +64 -25
  8. data/lib/libui_paradise/colours/colours.rb +12 -0
  9. data/lib/libui_paradise/examples/complex/003_open_file_button_example.rb +2 -4
  10. data/lib/libui_paradise/examples/complex/010_table_example.rb +143 -49
  11. data/lib/libui_paradise/examples/simple/003_fancy_text_example.rb +18 -9
  12. data/lib/libui_paradise/examples/simple/005_text_drawing_example.rb +8 -8
  13. data/lib/libui_paradise/examples/simple/007_control_gallery.rb +19 -13
  14. data/lib/libui_paradise/examples/simple/010_font_button.rb +31 -0
  15. data/lib/libui_paradise/examples/simple/011_simple_notepad.rb +24 -0
  16. data/lib/libui_paradise/examples/simple/012_table_example.rb +71 -0
  17. data/lib/libui_paradise/extensions/extensions.rb +961 -11
  18. data/lib/libui_paradise/extensions/toplevel_counters.rb +58 -0
  19. data/lib/libui_paradise/fiddle/{pointer.rb → fiddle.rb} +162 -144
  20. data/lib/libui_paradise/generic_window/generic_window.rb +1 -1
  21. data/lib/libui_paradise/images/README.md +5 -2
  22. data/lib/libui_paradise/libui_classes/box.rb +3 -2
  23. data/lib/libui_paradise/libui_classes/grid.rb +4 -1
  24. data/lib/libui_paradise/libui_classes/libui_classes.rb +113 -78
  25. data/lib/libui_paradise/project/project.rb +5 -1
  26. data/lib/libui_paradise/prototype/prototype.rb +1 -3
  27. data/lib/libui_paradise/requires/require_the_libui_paradise_project.rb +1 -1
  28. data/lib/libui_paradise/version/version.rb +2 -2
  29. data/lib/libui_paradise.rb +0 -0
  30. data/libui_paradise.gemspec +5 -4
  31. metadata +18 -27
  32. data/lib/libui_paradise/extensions/counters.rb +0 -58
  33. data/lib/libui_paradise/extensions/hash_fiddle_pointer_widgets.rb +0 -150
  34. data/lib/libui_paradise/extensions/misc.rb +0 -754
  35. data/lib/libui_paradise/toplevel_methods/misc.rb +0 -13
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'libui_paradise/extensions/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.counter_left?
21
+ # ========================================================================= #
22
+ def self.counter_left?
23
+ @counter_left
24
+ end; self.instance_eval { alias counter_left counter_left? } # === LibuiParadise.counter_left
25
+ self.instance_eval { alias left_counter counter_left? } # === LibuiParadise.left_counter
26
+ self.instance_eval { alias left_counter? counter_left? } # === LibuiParadise.left_counter?
27
+
28
+ # ========================================================================= #
29
+ # === LibuiParadise.counter_left=
30
+ # ========================================================================= #
31
+ def self.counter_left=(i = 1)
32
+ @counter_left = i
33
+ end
34
+
35
+ # ========================================================================= #
36
+ # === LibuiParadise.counter_top?
37
+ # ========================================================================= #
38
+ def self.counter_top?
39
+ @counter_top
40
+ end; self.instance_eval { alias counter_top counter_top? } # === LibuiParadise.counter_top
41
+ self.instance_eval { alias top_counter counter_top? } # === LibuiParadise.top_counter
42
+ self.instance_eval { alias top_counter? counter_top? } # === LibuiParadise.top_counter?
43
+
44
+ # ========================================================================= #
45
+ # === LibuiParadise.counter_top=
46
+ # ========================================================================= #
47
+ def self.counter_top=(i = 1)
48
+ @counter_top = i
49
+ end
50
+
51
+ # ========================================================================= #
52
+ # === LibuiParadise.counters?
53
+ # ========================================================================= #
54
+ def self.counters?
55
+ return [@counter_left, @counter_top]
56
+ end
57
+
58
+ end
@@ -11,13 +11,31 @@
11
11
  # refinements, but I don't quite like the syntax of refinements,
12
12
  # so I opted for the simpler toplevel modification instead.
13
13
  # =========================================================================== #
14
- # require 'libui_paradise/fiddle/pointer.rb'
14
+ # require 'libui_paradise/fiddle/fiddle.rb'
15
15
  # =========================================================================== #
16
16
  module Fiddle
17
17
 
18
18
  class Pointer # === Fiddle::Pointer
19
19
 
20
- require 'libui_paradise/extensions/counters.rb'
20
+ require 'libui_paradise/extensions/toplevel_counters.rb'
21
+
22
+ # ========================================================================= #
23
+ # === enable (enable tag)
24
+ # ========================================================================= #
25
+ def enable(&block)
26
+ object_id = self.object_id
27
+ hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
28
+ type = hash[object_id].last # The last entry contains the type.
29
+ case type
30
+ # ======================================================================= #
31
+ # === :button
32
+ # ======================================================================= #
33
+ when :button
34
+ LibUI.control_enable(self)
35
+ else
36
+ e 'Not registered type in .enable(): '+type.to_s
37
+ end
38
+ end
21
39
 
22
40
  # ========================================================================= #
23
41
  # === on_changed
@@ -254,9 +272,9 @@ class Pointer # === Fiddle::Pointer
254
272
  alias start_position= set_value # === start_position=
255
273
 
256
274
  # ========================================================================= #
257
- # === right (right tag)
275
+ # === left (left tag)
258
276
  # ========================================================================= #
259
- def right(
277
+ def left(
260
278
  widget,
261
279
  left = LibuiParadise.counter_left?,
262
280
  top = LibuiParadise.counter_top?,
@@ -309,9 +327,9 @@ class Pointer # === Fiddle::Pointer
309
327
  end
310
328
 
311
329
  # ========================================================================= #
312
- # === left (left tag)
330
+ # === right (right tag)
313
331
  # ========================================================================= #
314
- def left(
332
+ def right(
315
333
  widget,
316
334
  left = LibuiParadise.counter_left?,
317
335
  top = LibuiParadise.counter_top?,
@@ -587,84 +605,8 @@ class Pointer # === Fiddle::Pointer
587
605
  # display_this_text.to_s
588
606
  # )
589
607
  else
590
- puts 'Unhandled case in clear(): '+
591
- type.to_s
592
- end
593
- end
594
-
595
- # ========================================================================= #
596
- # === empty?
597
- # ========================================================================= #
598
- def empty?(
599
- type = nil
600
- )
601
- object_id = self.object_id
602
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
603
- if type.nil?
604
- # ===================================================================== #
605
- # In this case we must determine the type in use.
606
- # ===================================================================== #
607
- if hash.has_key? object_id
608
- type = hash[object_id].last # The last entry contains the type.
609
- end
610
- end
611
- case type
612
- # ======================================================================= #
613
- # === :entry
614
- # ======================================================================= #
615
- when :entry
616
- self.text?.empty?
617
- else
618
- return true
619
- end
620
- end
621
-
622
- # ========================================================================= #
623
- # === is_read_only
624
- # ========================================================================= #
625
- def is_read_only(
626
- current_widget = available_pointers?[self.object_id] # This will be an Array.
627
- )
628
- _pointer = current_widget.first # Not used currently in this method.
629
- type = current_widget.last
630
- case type
631
- # ======================================================================= #
632
- # === :multiline_entry
633
- # ======================================================================= #
634
- when :multiline_entry
635
- LibUI.multiline_entry_set_read_only(self, 1)
636
- else
637
- pp caller()
638
- puts "#{type} (class #{type.class}) is not yet implemented in .padded=."
639
- end
640
- end
641
-
642
- # ========================================================================= #
643
- # === append_this_string
644
- #
645
- # This method can be used to append a String to an existing String.
646
- # ========================================================================= #
647
- def append_this_string(i)
648
- ::LibUI.attributed_string_append_unattributed(self, i)
649
- end
650
-
651
- # ========================================================================= #
652
- # === append_text_column
653
- #
654
- # This method is specifically used for libui-tables.
655
- # ========================================================================= #
656
- def append_text_column(text, a, b)
657
- object_id = self.object_id
658
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
659
- type = hash[object_id].last # The last entry contains the type.
660
- case type
661
- # ======================================================================= #
662
- # === :button
663
- # ======================================================================= #
664
- when :table
665
- LibUI.table_append_text_column(self, text, a, b)
666
- else
667
- e 'Not registered type in .append_text_column(): '+type.to_s
608
+ puts "Unhandled case in clear(): "\
609
+ "#{type}"
668
610
  end
669
611
  end
670
612
 
@@ -739,24 +681,6 @@ class Pointer # === Fiddle::Pointer
739
681
  end
740
682
  end
741
683
 
742
- # ========================================================================= #
743
- # === enable (enable tag)
744
- # ========================================================================= #
745
- def enable(&block)
746
- object_id = self.object_id
747
- hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
748
- type = hash[object_id].last # The last entry contains the type.
749
- case type
750
- # ======================================================================= #
751
- # === :button
752
- # ======================================================================= #
753
- when :button
754
- LibUI.control_enable(self)
755
- else
756
- e 'Not registered type in .enable(): '+type.to_s
757
- end
758
- end
759
-
760
684
  # ========================================================================= #
761
685
  # === populate
762
686
  # ========================================================================= #
@@ -780,20 +704,6 @@ class Pointer # === Fiddle::Pointer
780
704
  set_padded(1)
781
705
  end
782
706
 
783
- # ========================================================================= #
784
- # === show_then_main_then_quit
785
- #
786
- # This method ultimately combines three other method calls.
787
- # ========================================================================= #
788
- def show_then_main_then_quit
789
- LibUI.control_show(self)
790
- main_then_quit
791
- end; alias elegant_exit show_then_main_then_quit # === elegant_exit
792
- alias complex_finalizer show_then_main_then_quit # === complex_finalizer
793
- alias intelligent_close_down show_then_main_then_quit # === intelligent_close_down
794
- alias intelligent_quit show_then_main_then_quit # === intelligent_quit
795
- alias intelligent_exit show_then_main_then_quit # === intelligent_exit
796
-
797
707
  # ========================================================================= #
798
708
  # === on_clicked
799
709
  #
@@ -810,6 +720,62 @@ class Pointer # === Fiddle::Pointer
810
720
  LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
811
721
  end; alias main_hash? available_pointers? # === main_hash?
812
722
 
723
+ # ========================================================================= #
724
+ # === empty?
725
+ # ========================================================================= #
726
+ def empty?(
727
+ type = nil
728
+ )
729
+ object_id = self.object_id
730
+ hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
731
+ if type.nil?
732
+ # ===================================================================== #
733
+ # In this case we must determine the type in use.
734
+ # ===================================================================== #
735
+ if hash.has_key? object_id
736
+ type = hash[object_id].last # The last entry contains the type.
737
+ end
738
+ end
739
+ case type
740
+ # ======================================================================= #
741
+ # === :entry
742
+ # ======================================================================= #
743
+ when :entry
744
+ self.text?.empty?
745
+ else
746
+ return true
747
+ end
748
+ end
749
+
750
+ # ========================================================================= #
751
+ # === is_read_only
752
+ # ========================================================================= #
753
+ def is_read_only(
754
+ current_widget = available_pointers?[self.object_id] # This will be an Array.
755
+ )
756
+ _pointer = current_widget.first # Not used currently in this method.
757
+ type = current_widget.last
758
+ case type
759
+ # ======================================================================= #
760
+ # === :multiline_entry
761
+ # ======================================================================= #
762
+ when :multiline_entry
763
+ LibUI.multiline_entry_set_read_only(self, 1)
764
+ else
765
+ pp caller()
766
+ puts "#{type} (class #{type.class}) is not yet implemented in .padded=."
767
+ end
768
+ end
769
+
770
+ # ========================================================================= #
771
+ # === append_this_string
772
+ #
773
+ # This method can be used to append a String to an existing String.
774
+ # ========================================================================= #
775
+ def append_this_string(i)
776
+ ::LibUI.attributed_string_append_unattributed(self, i)
777
+ end
778
+
813
779
  # ========================================================================= #
814
780
  # === append_this_array
815
781
  # ========================================================================= #
@@ -1009,16 +975,6 @@ class Pointer # === Fiddle::Pointer
1009
975
  end; alias uses_a_margin is_margined # === uses_a_margin
1010
976
  alias has_margin is_margined # === has_margin
1011
977
 
1012
- # ========================================================================= #
1013
- # === main_then_quit
1014
- #
1015
- # We use ::LibUI just in case to avoid any possible name-collisions.
1016
- # ========================================================================= #
1017
- def main_then_quit
1018
- ::LibUI.main
1019
- ::LibUI.quit
1020
- end
1021
-
1022
978
  # ========================================================================= #
1023
979
  # === close_properly
1024
980
  #
@@ -1033,15 +989,80 @@ class Pointer # === Fiddle::Pointer
1033
989
  }
1034
990
  end; alias simple_exit close_properly # === simple_exit
1035
991
  alias sane_exit close_properly # === sane_exit
1036
- alias should_quit close_properly # === should_quit
1037
992
  alias do_quit close_properly # === should_quit
993
+ alias should_quit close_properly # === should_quit
994
+
995
+ # ========================================================================= #
996
+ # === main_then_quit
997
+ #
998
+ # We use ::LibUI just in case to avoid any possible name-collisions.
999
+ # ========================================================================= #
1000
+ def main_then_quit
1001
+ ::LibUI.main
1002
+ ::LibUI.quit
1003
+ #::LibUI.uninit # Trying this since as of November 2023. Nope, does not work.
1004
+ end
1005
+
1006
+ # ========================================================================= #
1007
+ # === show_then_main_then_quit
1008
+ #
1009
+ # This method ultimately combines three other method calls.
1010
+ # ========================================================================= #
1011
+ def show_then_main_then_quit
1012
+ ::LibUI.control_show(self)
1013
+ main_then_quit
1014
+ end; alias elegant_exit show_then_main_then_quit # === elegant_exit
1015
+ alias complex_finalizer show_then_main_then_quit # === complex_finalizer
1016
+ alias intelligent_close_down show_then_main_then_quit # === intelligent_close_down
1017
+ alias intelligent_quit show_then_main_then_quit # === intelligent_quit
1018
+ alias intelligent_exit show_then_main_then_quit # === intelligent_exit
1019
+
1020
+ # ========================================================================= #
1021
+ # === append_text_column
1022
+ #
1023
+ # This method is specifically used for libui-tables.
1024
+ # ========================================================================= #
1025
+ def append_text_column(
1026
+ text,
1027
+ a,
1028
+ b = -1
1029
+ )
1030
+ object_id = self.object_id
1031
+ hash = LibuiParadise::Extensions.hash_fiddle_pointer_widgets?
1032
+ type = hash[object_id].last # The last entry contains the type.
1033
+ case type
1034
+ # ======================================================================= #
1035
+ # === :table
1036
+ #
1037
+ # This is the primary entry point for this method.
1038
+ # ======================================================================= #
1039
+ when :table
1040
+ ::LibUI.table_append_text_column(self, text, a, b)
1041
+ else
1042
+ e 'Not registered type in .append_text_column(): '+type.to_s
1043
+ end
1044
+ end
1045
+
1046
+ # ========================================================================= #
1047
+ # === on_key_press_event
1048
+ # ========================================================================= #
1049
+ def on_key_press_event(&block)
1050
+ # e 'NOT YET IMPLEMENTED.'
1051
+ end
1052
+
1053
+ # ========================================================================= #
1054
+ # === on_button_press_event
1055
+ # ========================================================================= #
1056
+ def on_button_press_event(&block)
1057
+ # e 'NOT YET IMPLEMENTED'
1058
+ end
1038
1059
 
1039
1060
  # ========================================================================= #
1040
- # === Skeleton methods:
1061
+ # === Skeleton methods
1041
1062
  #
1042
- # A "skeleton" method is one that doesn't do anything right now. These
1043
- # were added to increase compatibility with the gtk_paradise gem in
1044
- # particular.
1063
+ # A "skeleton" method is one that doesn't do anything right now.
1064
+ # These were added to increase compatibility with the gtk_paradise
1065
+ # gem in particular.
1045
1066
  #
1046
1067
  # Some of these skeleton methods may become real methods one day,
1047
1068
  # depending on how sophisticated the libui code will be - but
@@ -1071,7 +1092,6 @@ class Pointer # === Fiddle::Pointer
1071
1092
  def reset_the_internal_variables; end
1072
1093
  def editable=(true_or_false = false); end
1073
1094
  def set_max_length(n = 100); end
1074
- def use_gtk_paradise_project_css_file; end
1075
1095
  def append_project_CSS_file; end
1076
1096
  def infer_the_size_automatically; end
1077
1097
  def set_column_spacing(i = 1); end
@@ -1135,24 +1155,22 @@ class Pointer # === Fiddle::Pointer
1135
1155
  def spacing1=(i = 2); end
1136
1156
  def spacing2=(i = 2); end
1137
1157
  def spacing=(i = 0); end
1158
+ def light_blue_background; end
1159
+ def hover(i = :hack_26) # Currently not in use.
1160
+ end
1161
+ def set_font_size(i = :hack_26) # Currently not in use.
1162
+ end
1163
+ def use_gtk_paradise_project_css_file; end
1164
+ def on_hover_colour(i = '', &block); end
1138
1165
  def deselect; end
1139
1166
  # def fraction=(i = ''); end
1140
1167
  def return_all_entries
1141
1168
  []
1142
1169
  end
1143
-
1144
- # ========================================================================= #
1145
- # === on_key_press_event
1146
- # ========================================================================= #
1147
- def on_key_press_event(&block)
1148
- # e 'NOT YET IMPLEMENTED.'
1170
+ def drag_via_left_to_right(a, b)
1171
+ vbox(a, b)
1149
1172
  end
1150
-
1151
- # ========================================================================= #
1152
- # === on_button_press_event
1153
- # ========================================================================= #
1154
- def on_button_press_event(&block)
1155
- # e 'NOT YET IMPLEMENTED'
1173
+ def default_styling(i = '')
1156
1174
  end
1157
1175
 
1158
1176
  end; end
@@ -69,7 +69,7 @@ class GenericWindow < LibuiParadise::Base # === LibuiParadise::GenericWindow
69
69
  # === run
70
70
  # ========================================================================= #
71
71
  def run
72
- super()
72
+ super() # Call any parent method.
73
73
  end
74
74
 
75
75
  end; end
@@ -1,2 +1,5 @@
1
- This directory only contains the libui_paradise logo that was
2
- created on 27.08.2021 via cfdg, gimp, kolourpaint and pngquant.
1
+ This directory contains the libui_paradise logo that was created on
2
+ 27.08.2021 via cfdg, gimp, kolourpaint and pngquant.
3
+
4
+ Additional images may also be stored here, in regards to documentation
5
+ for the libui_paradise gem.
@@ -121,8 +121,9 @@ module Extensions # === LibuiParadise::Extensions
121
121
  # ========================================================================= #
122
122
  def vbox(*optional_widgets)
123
123
  ::LibuiParadise::Extensions.vbox(optional_widgets)
124
- end; alias ui_vbox vbox # === ui_vbox
125
- alias gtk_box vbox # === gtk_box
124
+ end; alias ui_vbox vbox # === ui_vbox
125
+ alias gtk_box vbox # === gtk_box
126
+ alias create_vbox vbox # === create_vbox
126
127
 
127
128
  end
128
129
 
@@ -37,10 +37,13 @@ module Extensions # === LibuiParadise::Extensions
37
37
 
38
38
  # ========================================================================= #
39
39
  # === grid
40
+ #
41
+ # This method can be used to create (and return) a new grid.
40
42
  # ========================================================================= #
41
43
  def grid
42
44
  ::LibuiParadise::Extensions.grid
43
- end; alias ui_grid grid # === ui_grid
45
+ end; alias ui_grid grid # === ui_grid
46
+ alias create_default_grid grid # === create_default_grid
44
47
 
45
48
  # ========================================================================= #
46
49
  # === ui_padded_grid