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
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  [![forthebadge](https://forthebadge.com/images/badges/made-with-ruby.svg)](https://www.ruby-lang.org/en/)
3
3
  [![Gem Version](https://badge.fury.io/rb/libui_paradise.svg)](https://badge.fury.io/rb/libui_paradise)
4
4
 
5
- This gem was <b>last updated</b> on the <span style="color: darkblue; font-weight: bold">09.10.2022</span> (dd.mm.yyyy notation), at <span style="color: steelblue; font-weight: bold">16:36:45</span> o'clock.
5
+ This gem was <b>last updated</b> on the <span style="color: darkblue; font-weight: bold">28.12.2023</span> (dd.mm.yyyy notation), at <span style="color: steelblue; font-weight: bold">22:23:45</span> o'clock.
6
6
 
7
7
  ## The libui_paradise project
8
8
 
@@ -13,12 +13,12 @@ by me via **gimp** and ImageMagick - the rounded borders were
13
13
  done via ImageMagick. You can re-use this image if you would like to,
14
14
  including the colour-pattern, via a **CC BY 3.0** licence. See the following
15
15
  link for that licence: https://creativecommons.org/licenses/by/3.0/. For
16
- **cfdg** itself, have a look at: https://www.contextfreeart.org/gallery/)
16
+ <b>cfdg</b> itself, have a look at: https://www.contextfreeart.org/gallery/)
17
17
 
18
- The **libui_paradise project** aims to enhance the official (upstream)
18
+ The <b>libui_paradise project</b> aims to enhance the official (upstream)
19
19
  ruby-libui bindings a little bit.
20
20
 
21
- You can find the upstream ruby-libui bindings, maintained by **kojix2**,
21
+ You can find the upstream ruby-libui bindings, maintained by <b>kojix2</b>,
22
22
  here:
23
23
 
24
24
  https://rubygems.org/gems/libui
@@ -154,7 +154,7 @@ around one day, that idea should be retained for other GUIs
154
154
  in the future.
155
155
 
156
156
  It's quite difficult to get GTK and ruby-gtk to work on
157
- **windows** - I tried to compile it some weeks ago but I
157
+ <b>windows</b> - I tried to compile it some weeks ago but I
158
158
  ended up having "missing symbols" error messages afterwards.
159
159
  I managed to get the hello-world.c example working, but the
160
160
  more complicated examples did not work for me.
@@ -172,7 +172,7 @@ no binary bundles for ruby-gtk on windows anymore either. I
172
172
  assume it is possible if you know msys2, and the windows
173
173
  platform, but I am no expert on either, so ...)
174
174
 
175
- **libui** is so much simpler to use on windows than GTK,
175
+ <b>libui</b> is so much simpler to use on windows than GTK,
176
176
  though - just do **gem install libui** and it'll work,
177
177
  as-is. Literally. That's it. I tried it on my windows
178
178
  laptop and it **does** indeed work. That convinced me
@@ -286,7 +286,8 @@ sense in this regard.
286
286
 
287
287
  ## How to add a margin in LibUI
288
288
 
289
- Use something like:
289
+ Use the following API if you wish to have your main window
290
+ use a margin:
290
291
 
291
292
  LibUI.window_set_margined(MAIN_WINDOW, 1)
292
293
 
@@ -432,14 +433,19 @@ Or just:
432
433
 
433
434
  Since as of 2022 I prefer the longer variant, e. g. **LibUI**init. The
434
435
  old UI constant ("alias") will be retained, but new code added to the
435
- libui_paradise gem will not use **UI** - instead the slightly longer
436
- **LibUI** is used.
437
-
436
+ libui_paradise gem will not use <b>UI</b> - instead the slightly longer
437
+ <b>LibUI</b> is used.
438
+
439
+ Note that since as of <b>December 2023</b>, whenever the libui_paradise
440
+ gem is required, <b>LibuiParadise.init</b> is automatically called,
441
+ which in turn invokes LibUI.init. The reason as to why this is
442
+ the new default is so that we can omit one line of code.
443
+
438
444
  ## Subclassing
439
445
 
440
446
  Currently subclassing from LibUI elements does not work - I simply
441
- have no idea how to "subclass" from a **Fiddle::Pointer**. Perhaps we
442
- have to build up a data structure that behaves like **Fiddle::Pointer**
447
+ have no idea how to "subclass" from a <b>Fiddle::Pointer</b>. Perhaps we
448
+ have to build up a data structure that behaves like <b>Fiddle::Pointer</b>
443
449
  but also has methods that allow for a more direct 'OOP behaviour'. Has
444
450
  anyone tried this yet? I am scared to try considering I already got
445
451
  segfaults everywhere ...
@@ -456,8 +462,8 @@ The following API can be used to create a new scrolling area:
456
462
 
457
463
  LibUI.new_scrolling_area
458
464
 
459
- Scrolling areas have horziontal and vertical scrollbars. The
460
- amount that can be scrolled is determined by the area's
465
+ <b>Scrolling areas</b> may contain horizontal and vertical scrollbars.
466
+ The amount that can be scrolled is determined by the area's
461
467
  size, which is decided by the programmer (both when creating
462
468
  the Area and by a call to SetSize). Only a portion of the
463
469
  Area is visible at any time; drawing and mouse events are
@@ -465,9 +471,9 @@ automatically adjusted to match what portion is visible,
465
471
  so you do not have to worry about scrolling in your
466
472
  event handlers.
467
473
 
468
- The method LibUI.new_scrolling_area() accepts three arguments.
474
+ The method <b>LibUI.new_scrolling_area()</b> accepts <b>three arguments</b>.
469
475
  The second and third are width and height, respectively
470
- (as **integers**).
476
+ (as <b>integers</b>).
471
477
 
472
478
  The first argument is the area handle. It has the following
473
479
  pointer types (struct):
@@ -478,7 +484,7 @@ pointer types (struct):
478
484
  .DragBroken
479
485
  .KeyEvent
480
486
 
481
- The handlerDraw() function in C looks like this:
487
+ The <b>handlerDraw() function</b> in C looks like this:
482
488
 
483
489
  static void handlerDraw(uiAreaHandler *a, uiArea *area, uiAreaDrawParams *p)
484
490
  {
@@ -497,6 +503,12 @@ The handlerDraw() function in C looks like this:
497
503
  uiFreeFontButtonFont(&defaultFont);
498
504
  }
499
505
 
506
+ This means that you will have to pass three arguments to
507
+ this method - all are mandatory. Failure to do so may yield an
508
+ error message, such as:
509
+
510
+ gems/libui-0.1.2.pre/lib/libui/ffi.rb:20:in `call': wrong number of arguments (given 0, expected 3) (ArgumentError)
511
+
500
512
  The scrollable area may look like this:
501
513
 
502
514
  <img src="https://raw.githubusercontent.com/msink/kotlin-libui/master/samples/hello/hello-windows.png">
@@ -518,9 +530,10 @@ label / ui_text widget.
518
530
 
519
531
  ## Working with combo-boxes
520
532
 
521
- To create a combo-box in vanilla libui, do this:
533
+ To create a combo-box in vanilla libui, do this in plain ruby-libui:
522
534
 
523
- alignment = LibUI.new_combobox
535
+ alignment = LibUI.new_combobox # Here we actually create the combobox.
536
+ # Next, we show how to append to a combobox:
524
537
  LibUI.combobox_append(alignment, 'Left')
525
538
  LibUI.combobox_append(alignment, 'Center')
526
539
  LibUI.combobox_append(alignment, 'Right')
@@ -552,11 +565,11 @@ For instance:
552
565
 
553
566
  LibUI.combobox_set_selected(combobox, 0) # The first one will be active too.
554
567
 
555
- To **query the currently selected value**, use:
568
+ To <b>query the currently selected value</b>, use:
556
569
 
557
570
  LibUI.combobox_selected(pointer)
558
571
 
559
- This is usually done via a **proc {}** object. See kojix2' examples.
572
+ This is usually done via a <b>proc {}</b> object. See kojix2' examples.
560
573
 
561
574
  In LibuiParadise a few custom methods were added, such as
562
575
  **.ui_sync_connect()**. This method was added to connect a
@@ -578,11 +591,32 @@ So:
578
591
  There are probably more elegant ways to solve this, but I only
579
592
  wanted to solve this quickly and move on.
580
593
 
581
- The **source code** to the combo-box in libui, at the least
594
+ To add content to an editable combobox youc an use:
595
+
596
+ LibUI.append() # .append() adds the named item to the end of the EditableCombobox.
597
+
598
+ A more concise example for populating a combobox may be
599
+ this one here:
600
+
601
+ combo_box = LibUI.combobox {
602
+ ['combobox Item 1', 'combobox Item 2', 'combobox Item 3']
603
+ }
604
+
605
+ The <b>source code</b> to the combo-box in libui, at the least
582
606
  for UNIX/Linux, can be seen here:
583
607
 
584
608
  https://github.com/andlabs/libui/blob/master/unix/combobox.c
585
609
 
610
+ ## How to add a libui-widget to the main window - how to designate a child widget:
611
+
612
+ LibUI.window_set_child(main_window, button) # Both these widgets have to be created first, of course.
613
+
614
+ ## LibUI.control_show
615
+
616
+ No clue what this does so far.
617
+
618
+ LibUI.control_show(main_window)
619
+
586
620
  ## Error messages and ui_error_message
587
621
 
588
622
  In LibUI respectively ruby-libui you can display error messages
@@ -606,22 +640,37 @@ respectively.
606
640
  **Form** is a container that takes labels for its contents. This is currently
607
641
  just a stub though - we may have to research this with better examples.
608
642
 
609
- ## Libui Checkbox
643
+ ## Checkboxes in Libui-ng
610
644
 
611
- A simple checkbox example in **plain** ruby-libui follows:
645
+ A simple checkbox example in <b>plain</b> ruby-libui follows:
612
646
 
613
- checkbox = UI.checkbox('Checkbox')
614
- checkbox_toggle_callback = proc { |ptr|
615
- checked = UI.checkbox_checked(ptr) == 1
616
- UI.checkbox_set_text(ptr, "I am the checkbox (#{checked})")
647
+ checkbox = LibUI.checkbox('Checkbox')
648
+ checkbox_toggle_callback = proc { |pointer|
649
+ checked = LibUI.checkbox_checked(pointer) == 1
650
+ LibUI.checkbox_set_text(ptr, "I am the checkbox (#{checked})")
617
651
  }
618
652
 
653
+ Or:
654
+
655
+ checkbox = LibUI.new_checkbox('Checkbox')
656
+ # ui_checkbox can be used if you use the libui_paradise gem.
657
+
619
658
  This may look like so on Linux:
620
659
 
621
660
  <img src="https://i.imgur.com/d7qWalZ.png" style="margin-left: 2em; padding: 4px; border: 1px solid black;">
622
661
 
623
- To query whether a checkbox is **active**, use code such as the
624
- following:
662
+ To set such a checkbox to the <b>checked-state</b> (that is, as if
663
+ the user clicked on it), use the following method, if you use the
664
+ libui_paradise gem:
665
+
666
+ checkbox.set_checked(1)
667
+
668
+ To query its state use:
669
+
670
+ checked = LibUI.checkbox_checked(pointer) == 1
671
+
672
+ To <b>query</b> whether a checkbox is <b>active</b>, use code such as
673
+ the following:
625
674
 
626
675
  checkbox.is_active?
627
676
  checkbox.active?
@@ -630,22 +679,35 @@ This depends on the modifications to Fiddler::Pointer, so
630
679
  be wary when you use this - there be dragons (perhaps). Most
631
680
  of these modifications are based on **.object_id**, which is
632
681
  registered in a main, toplevel Hash in the
633
- **libui_paradise project**. Not very elegant, but simple, and
682
+ <b>libui_paradise project</b>. Not very elegant, but simple, and
634
683
  it works (for the most part).
635
684
 
685
+ The toggle-event for a checkbox can be triggered via:
686
+
687
+ checkbox_toggle_callback = proc { |pointer|
688
+ checked = LibLibUI.checkbox_checked(pointer) == 1
689
+ LibUI.window_set_title(MAIN_WINDOW, "Checkbox is #{checked}")
690
+ LibUI.checkbox_set_text(pointer, "I am the checkbox (#{checked})")
691
+ 0
692
+ }
693
+
694
+ To respond to <b>on-toggled events</b>, do use:
695
+
696
+ LibUI.checkbox_on_toggled(checkbox, checkbox_toggle_callback, nil)
697
+
636
698
  ## Adding a widget into another widget
637
699
 
638
- I chose the following **API** for this:
700
+ I chose the following <b>API</b> for this:
639
701
 
640
702
  box1.add(box2, 1)
641
703
 
642
- Note that this is "cheating" a bit because the method **.add()** is defined
643
- on **Fiddle::Pointer**. That's scary! Segfaults coming your way. But it
644
- also seems to work to some extent. Which is amazing ... :-)
704
+ Note that this is "cheating" a bit because the method <b>.add()</b> is
705
+ defined on <b>Fiddle::Pointer</b>. That's scary! Segfaults coming your
706
+ way. But it also seems to work to some extent. Which is amazing ... :-)
645
707
 
646
708
  In ruby-gtk it is quite common to use **.add()**. While **.pack_start()**
647
709
  and **.pack_end()** are available in ruby-gtk as well, I think .add() is
648
- the simpler name. We just **add a widget to another widget** - job done.
710
+ the simpler name. We just <b>add a widget to another widget</b> - job done.
649
711
 
650
712
  (I may also use << as alias to .add() and while << is great, remember
651
713
  that it can not easily be used all the time, e. g. box1 << box2 <<
@@ -686,6 +748,20 @@ The notebook-tab may look like this:
686
748
 
687
749
  <img src="https://i.imgur.com/olWQAIJ.png" style="margin-left: 2em">
688
750
 
751
+ A new tab can be created via:
752
+
753
+ tab = LibUI.new_tab
754
+
755
+ To populate the notebook-tab you can use .tab_append() such as
756
+ shown next:
757
+
758
+ hbox1 = LibUI.new_horizontal_box
759
+ hbox2 = LibUI.new_horizontal_box
760
+ LibUI.tab_append(tab, 'Page 1', hbox1)
761
+ LibUI.tab_append(tab, 'Page 2', hbox2)
762
+ LibUI.tab_append(tab, 'Page 3', UI.new_horizontal_box)
763
+ LibUI.box_append(inner2, tab, 1)
764
+
689
765
  ## Create a vertical box:
690
766
 
691
767
  Use code like this:
@@ -699,8 +775,8 @@ If you use the libui_paradise gem, you can use this:
699
775
 
700
776
  ## Adding a horizontal separator or a vertical separator
701
777
 
702
- The method **UI.new_horizontal_separator** can be used to add (or rather
703
- first create) a horizontal separator.
778
+ The method <b>LibUI.new_horizontal_separator</b> can be used to add (or
779
+ rather first create) <b>a horizontal separator</b>.
704
780
 
705
781
  You can then add it via .add() or << if you use the libui_paradise
706
782
  project. Alternatively you can use the toplevel method provided by
@@ -749,6 +825,10 @@ not necessarily recommending this be done, but **if** you ever have
749
825
  such a use case then you can use it - which is another reason why
750
826
  I added this screenshot, so that I don't forget. :)
751
827
 
828
+ The toplevel method <b>LibuiParadise.horizontal_separator()</b>
829
+ has also been added; it is simply a wrapper towards
830
+ <b>LibUI.new_horizontal_separator()</b>.
831
+
752
832
  ## Padding elements in LibUI
753
833
 
754
834
  The general API for setting padding to a container in LibUI
@@ -832,18 +912,38 @@ hand. Only the raw filename will be used, so if you
832
912
  have a file at **/tmp/foo/bar.rb** then the title
833
913
  of the window will be **bar.rb**.
834
914
 
835
- ## Entry
915
+ ## Entries in libui (libui-entry)
836
916
 
837
- An entry in libui may look like this:
917
+ Let's first show how an <b>entry</b> in libui may look like:
838
918
 
839
919
  <img src="https://raw.githubusercontent.com/parro-it/libui-node/master/docs/media/UiEntry.png" style="margin-left:1em">
840
920
 
841
- Such an entry can be set to be **read only** (readOnly: Boolean, aka true or false).
921
+ Such an entry can be set to be <b>read only</b> (readOnly: Boolean, aka true or false).
922
+ This means that it can not be changed by the user; it is then only used to
923
+ display some content.
842
924
 
843
- The upstream C code for libui-entry, for **unix/**, can be seen here:
925
+ The upstream C code for libui-entry, for <b>unix/</b>, can be seen here:
844
926
 
845
927
  https://github.com/andlabs/libui/blob/master/unix/entry.c
846
928
 
929
+ To create a new libui-entry, in raw libui-code, use this method:
930
+
931
+ LibUI.new_entry
932
+ entry = LibUI.new_entry # or better, this variant
933
+
934
+ In ruby, for the LibUI namespace, you can set text on an entry
935
+ by calling <b>LibUI.entry_set_text()</b>, such as shown in
936
+ the following example:
937
+
938
+ LibUI.entry_set_text(entry, 'Please enter your feelings')
939
+
940
+ If you use the libui_paradise gem, a modification in Fiddle
941
+ is to allow the method calls called .is_read_only and its
942
+ alias name, .readonly. This can be called on the entry,
943
+ such as:
944
+
945
+ entry.readonly
946
+
847
947
  ## Borderless windows and fullscreen windows
848
948
 
849
949
  A window that is **borderless: true** will not show any title or
@@ -853,18 +953,26 @@ To set the main window to full screen (occupy the whole monitor) do:
853
953
 
854
954
  LibUI.window_set_fullscreen(main_window, 1)
855
955
 
956
+ ## How to add a new main window:
957
+ # width, height, hasMenubar
958
+ main_window = LibUI.new_window('hello world', 300, 200, 1)
959
+
960
+ The source code for this method can be seen here:
961
+
962
+ https://raw.githubusercontent.com/libui-ng/libui-ng/master/unix/window.c
963
+
856
964
  ## Spinbutton / Spinbox
857
965
 
858
966
  You can use the following API for a spinbox:
859
967
 
860
- UI.new_spinbox
968
+ LibUI.new_spinbox
861
969
 
862
970
  To create a new spinbox.
863
971
 
864
972
  To specify the **min** and **max** range, pass them as parameters
865
973
  on creation-time:
866
974
 
867
- UI.new_spinbox(0, 100)
975
+ LibUI.new_spinbox(0, 100)
868
976
 
869
977
  If you use the extensions found in the libui_paradise gem then
870
978
  you can do this instead:
@@ -884,9 +992,9 @@ to see how this works.
884
992
 
885
993
  Relevant methods in regard to the spinbox in libui are as follows:
886
994
 
887
- UI.spinbox_on_changed()
888
- UI.spinbox_set_value()
889
- UI.spinbox_value()
995
+ LibUI.spinbox_on_changed()
996
+ LibUI.spinbox_set_value()
997
+ LibUI.spinbox_value()
890
998
 
891
999
  To **set** a value use either of the following two methods:
892
1000
 
@@ -903,31 +1011,34 @@ A text-view widget shows content, such as the content of a local file.
903
1011
 
904
1012
  In libui the general API for this is:
905
1013
 
906
- UI.new_multiline_entry # this is a textview
1014
+ LibUI.new_multiline_entry # this is a textview
907
1015
 
908
1016
  ## Control Gallery
909
1017
 
910
- Here is an image, from kotlin-libui, how this may look on windows:
1018
+ Here is an image, from <b>kotlin-libui</b>, how this may look on windows:
911
1019
 
912
1020
  <img src="https://raw.githubusercontent.com/msink/kotlin-libui/master/samples/controlgallery/controlgallery-windows7.png" style="margin-left: 2em">
913
1021
 
914
- ## LibUI.new_button() - how to work with buttons in LibUI
1022
+ ## LibUI.new_button() - how to work with buttons in LibUI in general
915
1023
 
916
- <b>LibUI.new_button</b> allows us to create a new button.
1024
+ <b>LibUI.new_button</b> allows us to create a new button, via
1025
+ the LibUI gem maintained by kojix2.
917
1026
 
918
- Examples:
1027
+ Examples for this, syntax-wise, follow:
919
1028
 
920
1029
  button1 = LibUI.new_button('Text')
921
1030
  button2 = LibUI.new_button('▶')
1031
+ button3 = LibUI.new_button('■') # You can use Unicode / Emojis here just fine.
1032
+ button3 = LibUI.new_button('♥') # This also gives you a way to do simple GUI elements, thanks to Unicode / Emoji.
922
1033
 
923
- Now, we need to "tell" this button what to do when it is
924
- clicked. This is done via Libui.button_on_clicked().
1034
+ Now, we need to "<i>tell</i>" this button what to do when it is clicked
1035
+ by the user. This is done via the method <b>LibUI.button_on_clicked()</b>.
925
1036
 
926
- Example:
1037
+ Usage example:
927
1038
 
928
- LibUI.button_on_clicked(button) do
929
- LibUI.msg_box(MAIN_WINDOW, 'Information', 'You clicked the button')
930
- end
1039
+ LibUI.button_on_clicked(button) {
1040
+ LibUI.msg_box(MAIN_WINDOW, 'Information', 'You clicked the button') # Show a message-box upon clicking this button.
1041
+ }
931
1042
 
932
1043
  ## Enabling / Disabling buttons in libui
933
1044
 
@@ -1073,115 +1184,6 @@ to be simpler for the time being. I may plan to change a lot more one day,
1073
1184
  if I ever manage to find out how to simulate proper subclasses via
1074
1185
  Fiddle::Pointer ... :)
1075
1186
 
1076
- --------------------------------------------------------------------------------
1077
- ## SNIPPETS.md
1078
-
1079
- Next, the content of the file called **SNIPPETS.md** will be shown. Note
1080
- that this file will eventually be integreated into this file, and then
1081
- subsequently removed one day.
1082
-
1083
-
1084
- <pre>
1085
- # How to add a new main window:
1086
- # width, height, hasMenubar
1087
- main_window = UI.new_window('hello world', 300, 200, 1)
1088
-
1089
- Source code:
1090
-
1091
- https://raw.githubusercontent.com/andlabs/libui/master/unix/window.c
1092
-
1093
- # How to add a libui-widget to the main window / Designate a child widget:
1094
-
1095
- UI.window_set_child(main_window, button)
1096
-
1097
- # Act on closing-event (on quit tag):
1098
-
1099
- UI.window_on_closing(main_window) {
1100
- puts 'Bye Bye'
1101
- UI.control_destroy(main_window)
1102
- UI.quit
1103
- 0
1104
- }
1105
- # Or simpler:
1106
- close_properly(main_window)
1107
-
1108
- # Add the window to the main UI:
1109
-
1110
- UI.control_show(main_window)
1111
- main_window.show_the_controls # Or use this one here.
1112
-
1113
-
1114
- # Add a checkbox (checkbox tag, checkbutton)
1115
-
1116
- checkbox = UI.new_checkbox('Checkbox') # or ui_checkbox
1117
- checkbox_toggle_callback = proc { |pointer|
1118
- checked = UI.checkbox_checked(pointer) == 1
1119
- UI.window_set_title(MAIN_WINDOW, "Checkbox is #{checked}")
1120
- UI.checkbox_set_text(pointer, "I am the checkbox (#{checked})")
1121
- 0
1122
- }
1123
- UI.checkbox_on_toggled(checkbox, checkbox_toggle_callback, nil)
1124
- UI.box_append(inner, checkbox, 0)
1125
-
1126
- To set it checked:
1127
-
1128
- checkbox.set_checked(1)
1129
-
1130
- To query its state:
1131
-
1132
- checked = UI.checkbox_checked(pointer) == 1
1133
-
1134
- # And the control:
1135
-
1136
- UI.control_show(main_window)
1137
-
1138
- # Using a text-entry (ui entry tag):
1139
-
1140
- text_entry = UI.new_entry
1141
- UI.entry_set_text(text_entry, 'Please enter your feelings')
1142
- UI.entry_on_changed(text_entry, text_changed_callback, nil)
1143
-
1144
- # To set this on a "multiline entry", aka spanning several
1145
- # rows, do use:
1146
- UI.multiline_entry_set_text(entry1, 'Yo there')
1147
- ui_text_view # an alias used in libui_paradise
1148
-
1149
- text1 = UI.entry_text(entry1) # Obtain text. You may have to call .to_s on it, to guarantee the String.
1150
- UI.multiline_entry_text # Obtain the text from a multiline entry.
1151
-
1152
- # Create a combobox (combo tag, combobox tag):
1153
-
1154
- combobox_selected_callback = proc { |ptr|
1155
- puts "New combobox selection: #{UI.combobox_selected(ptr)}"
1156
- }
1157
- cbox = UI.new_combobox
1158
- UI.combobox_append(cbox, 'combobox Item 1')
1159
- UI.combobox_append(cbox, 'combobox Item 2')
1160
- UI.combobox_append(cbox, 'combobox Item 3')
1161
- UI.box_append(inner, cbox, 0)
1162
- UI.combobox_on_selected(cbox, combobox_selected_callback, nil)
1163
-
1164
- # Or more concise:
1165
- combo_box = UI.combobox {
1166
- ['combobox Item 1', 'combobox Item 2', 'combobox Item 3']
1167
- }
1168
-
1169
-
1170
- # Add content to an editable combox:
1171
-
1172
- UI.append() # .append() adds the named item to the end of the EditableCombobox.
1173
-
1174
- # How to build a menu-interface (menu tag):
1175
-
1176
- help_menu = UI.new_menu('Help')
1177
- version_item = UI.menu_append_item(help_menu, 'Version')
1178
-
1179
-
1180
- </pre>
1181
-
1182
-
1183
- --------------------------------------------------------------------------------
1184
-
1185
1187
  ## Advantages and Disadvantages of the libui project
1186
1188
 
1187
1189
  It would be unfair to only selectively name advantages but not talk about
@@ -1189,29 +1191,31 @@ disadvantages, so this subsection will show some limitations, trade-offs,
1189
1191
  constraints and opportunities. This is not complete, but it may become
1190
1192
  somewhat more complete over time. Stay tuned.
1191
1193
 
1192
- (a) Advantages:
1194
+ (a) Advantages of LibUI:
1193
1195
 
1194
- - Works on windows out-of-the-box after you installed the libui-gem.
1196
+ - Works on the windows platform, out-of-the-box, after the libui-gem has been installed.
1195
1197
  - Is super-simple to use compared to other toolkits, including ruby-gtk.
1196
- - Super-simple to build up a prototype for a GUI, buttons that work,
1197
- spin-boxes, text-views and so forth. Faster than any other toolkit
1198
- IMO.
1198
+ - Super-simple to build up a prototype for a GUI, buttons that work, spin-boxes, text-views
1199
+ and so forth. Faster than any other toolkit, IMO.
1199
1200
  - Works cross-platform.
1200
1201
 
1201
- (b) Disadvantage:
1202
+ (b) Disadvantage of LibUI:
1202
1203
 
1203
1204
  - Limited ability to control the layout and size of widgets.
1204
- - May look like utter crap ... :-)
1205
- - Some functionality is missing, such as a scrolled-window for every widget.
1205
+ - May look like utter crap on some platforms ... :-)
1206
+ - Some functionality is flat-out missing, such as a scrolled-window for every widget
1207
+ or tooltips for every widget.
1206
1208
  - No way to use different fonts in the same application and choosing a font
1207
1209
  is needlessly complicated. (This may not be completely correct, though -
1208
- the glimmer-dsl-libui has example that seem to work. But if you ask me
1210
+ the glimmer-dsl-libui has examples that seem to work. But if you ask me
1209
1211
  right now in 2021 how this works via a standalone example then I can
1210
1212
  happily tell you I have absolutely no idea. Which brings me to the
1211
- next problem...)
1212
- - Lack of documentation. This part is REALLY annoying ...
1213
+ next problem ...)
1214
+ - Lack of documentation overall. This part is REALLY annoying, because there
1215
+ are only few users, so asking others about documentation when there is nobody
1216
+ else using it, plan sucks ...
1213
1217
 
1214
- Some more disadvantages relate to Fiddle::Pointer. You kind of need to
1218
+ Some more disadvantages relate to <b>Fiddle::Pointer</b>. You kind of need to
1215
1219
  know C fairly well as well as the GC in ruby, in order to understand
1216
1220
  what is going on. Since I don't, I hit a dead end, kind of.
1217
1221
 
@@ -1219,6 +1223,10 @@ This is so far in September 2021. Let's see what the future brings.
1219
1223
  Perhaps other toolkits will learn from libui and implement the good
1220
1224
  parts for **their own** widget set.
1221
1225
 
1226
+ Update in December 2023: things improved a bit, so the above is not
1227
+ 100% correct anymore. In particular libui-ng may receive some more
1228
+ usability-centric updates in the next months.
1229
+
1222
1230
  ## LibuiParadise.parse_this_config_file()
1223
1231
 
1224
1232
  This method can be used to parse a .config file. This file should
@@ -1268,17 +1276,21 @@ You can also use something like '95%' as input. In that case the
1268
1276
  desired value will be calculated depending on the max-resolution
1269
1277
  of the current display. This presently only works on **linux**; if
1270
1278
  someone knows how to make this work on windows and Mac OSX let
1271
- me know. (On these systems it will instead default to a hardcoded
1272
- value of 1024 for width and 800 for height).
1279
+ me know. (On these two systems the method will instead default
1280
+ to a hardcoded value of 1024 for width and 800 for height; these
1281
+ values, I think, are probably fairly safe, to also support older
1282
+ laptops. Evidently for smartphone devices this won't work, so
1283
+ if anyone has an idea how to handle this differently let me
1284
+ know).
1273
1285
 
1274
1286
  The following example shows how to use a percentage value:
1275
1287
 
1276
- set_height('80%')
1288
+ set_height('80%') # 80% of the max-height.
1277
1289
 
1278
1290
  ## Coloured Text
1279
1291
 
1280
1292
  At this point I only show how this may look on Win7, re-using
1281
- the picture the **kotlin-libui developers** made available:
1293
+ the picture the <b>kotlin-libui developers</b> made available:
1282
1294
 
1283
1295
  <img src="https://raw.githubusercontent.com/msink/kotlin-libui/master/samples/drawtext/drawtext-windows7.png" style="margin-left: 2em">
1284
1296
 
@@ -1390,9 +1402,9 @@ shows how this may look (on icewm):
1390
1402
  The syntax goes something like this:
1391
1403
 
1392
1404
  rb = ui_radio_buttons
1393
- UI.radio_buttons_append(rb, 'Radio Button 1')
1394
- UI.radio_buttons_append(rb, 'Radio Button 2')
1395
- UI.radio_buttons_append(rb, 'Radio Button 3')
1405
+ LibUI.radio_buttons_append(rb, 'Radio Button 1')
1406
+ LibUI.radio_buttons_append(rb, 'Radio Button 2')
1407
+ LibUI.radio_buttons_append(rb, 'Radio Button 3')
1396
1408
  outer_vbox.minimal(rb) # add the radio-button control to the box.
1397
1409
 
1398
1410
  In other words: you instantiate a new rb-radio-button 'pointer';
@@ -1427,26 +1439,67 @@ For "raw" libui, use this:
1427
1439
 
1428
1440
  ## Tables in LibUI
1429
1441
 
1430
- You may be able to create a new table via:
1442
+ The API for creating a new table in <b>LibUI</b> is this:
1431
1443
 
1432
1444
  table = LibUI.new_table
1433
-
1434
- model = LibUI.new_table_model(model_handler)
1445
+ table = LibUI.new_table(table_model)
1446
+
1447
+ You need to use a model for the table, and pass it as
1448
+ its first argument. The next line of code shows how
1449
+ this is done:
1450
+
1451
+ model = LibUI.new_table_model(model_handler) # create the model here
1452
+
1453
+ Next you have to prevent segfaults by .malloc-ating the
1454
+ table params. This can be done in the following manner:
1435
1455
 
1436
1456
  table_params = LibUI::FFI::TableParams.malloc
1437
1457
  table_params = Fiddle::RUBY_FREE
1438
1458
  table_params.Model = model
1439
1459
  table_params.RowBackgroundColorModelColumn = -1
1440
- table = LibUI.new_table(table_params)
1460
+ table = LibUI.new_table(table_params) # And pass it here.
1441
1461
 
1442
- The table header is an array that contains the following attributes:
1462
+ The <b>table header</b> is an array that contains the following attributes:
1443
1463
 
1444
- 1. editable, bool type, the column is whether editable
1464
+ 1. editable, bool type: determines whether column is editable
1445
1465
  2. textColor
1446
1466
  3. title
1447
1467
  4. type, specify value of button, image, imgtext, progress, checkbox, checkboxtext, color, text
1448
1468
 
1449
- Note that this is incomplete; it's a bit complicated.
1469
+ See the example distributed in this gem, in the file at
1470
+ <b>examples/simple/012_table_example.rb</b>.
1471
+
1472
+ This will yield the following result - at the least on Linux and IceWM:
1473
+
1474
+ <img src="https://i.imgur.com/Y7m58DH.png" style="margin: 1em">
1475
+
1476
+ You can append a new text column via:
1477
+
1478
+ ::LibUI.table_append_text_column(table, 'Header goes in here', 0, -1)
1479
+
1480
+ As this is a bit cumbersome to type, libui_paradise simplifies this
1481
+ a tiny bit into:
1482
+
1483
+ table.append_text_column('Header goes in here', 0, -1)
1484
+
1485
+ Be careful to <b>only</b> append entries there if the underlying
1486
+ dataset - our Array - also contains these entries; otherwise the
1487
+ application would segfault. The example at
1488
+ <b>examples/complex/010_table_example.rb</b> shows this - look
1489
+ at the commented out example to test it.
1490
+
1491
+ In November 2023 the API was a bit simplified, towards this:
1492
+
1493
+ table.append_text_column('Header goes in here', 0)
1494
+ table.append_text_column('Another header goes in here', 1)
1495
+ table.append_text_column('And this is yet another header', 2)
1496
+
1497
+ So you can now omit the last -1 part. Expect more simplifications
1498
+ in the future - all that malloc stuff should be handled by
1499
+ libui_paradise, rather than in the downstream application
1500
+ code.
1501
+
1502
+ Note that this section is incomplete; it's a bit complicated.
1450
1503
 
1451
1504
  In the end, this is possible though:
1452
1505
 
@@ -1525,7 +1578,7 @@ Available "**new**"-widgets in LibUI:
1525
1578
  LibUI.new_table_value_color
1526
1579
  LibUI.new_table_value_string
1527
1580
  LibUI.new_time_picker
1528
- LibUI.new_menu
1581
+ LibUI.new_menu # this is a menu, appearing on the upper area
1529
1582
  LibUI.new_multiline_entry # this is a textview
1530
1583
  LibUI.new_non_wrapping_multiline_entry
1531
1584
  LibUI.new_open_type_features
@@ -1544,8 +1597,8 @@ Available "**new**"-widgets in LibUI:
1544
1597
  LibUI.new_weight_attribute
1545
1598
  LibUI.new_form # this is a form
1546
1599
  LibUI.new_size_attribute
1547
- LibUI.new_window
1548
- LibUI.new_slider # this is a slider
1600
+ LibUI.new_window # this will create a new window, such as a gtk-window on linux
1601
+ LibUI.new_slider # this is a slider, allowing the user to set a value via a small GUI-handle
1549
1602
 
1550
1603
  ## A search entry in LibUI
1551
1604
 
@@ -1572,9 +1625,23 @@ Example for this:
1572
1625
  width = canvas.width
1573
1626
  height = canvas.height
1574
1627
 
1575
- ## Creating a new drawing area
1628
+ ## How to to build a menu-interface (menu tag):
1629
+
1630
+ Building a menu in libui is possible by using the method
1631
+ <b>LibUI.new_menu()</b>.
1632
+
1633
+ A more complete example follows:
1634
+
1635
+ help_menu = LibUI.new_menu('Help')
1636
+ version_item = LibUI.menu_append_item(help_menu, 'Version')
1576
1637
 
1577
- This should suffice:
1638
+ On IceWM this may look like this:
1639
+
1640
+ <img src="https://i.imgur.com/1rWYcZM.png" style="margin: 1em">
1641
+
1642
+ ## Creating a new drawing area in LibUI
1643
+
1644
+ The following code should suffice:
1578
1645
 
1579
1646
  handler = LibUI::FFI::AreaHandler.malloc
1580
1647
  handler.to_ptr.free = Fiddle::RUBY_FREE
@@ -1582,12 +1649,19 @@ This should suffice:
1582
1649
 
1583
1650
  ## Horizontal boxes
1584
1651
 
1585
- A HBox represents a horizontal box. The API for putting
1586
- something into a hbox goes as follows, such as when you
1587
- wish to put a text-entry into the hbox:
1652
+ A <b>HBox</b> represents a <b>horizontal box</b>.
1653
+
1654
+ In pure ruby-libui a new horizontal box (hbox) can be created via:
1655
+
1656
+ hbox = LibUI.new_horizontal_box
1657
+
1658
+ The API for putting something into a hbox goes as follows, such as
1659
+ when you wish to put a text-entry into the hbox:
1588
1660
 
1589
1661
  LibUI.box_append(hbox1, text_entry, 1)
1590
1662
 
1663
+ If you use libui_paradise then you can also use << instead.
1664
+
1591
1665
  ## The slider widget
1592
1666
 
1593
1667
  If you use the LibuiParadise gem then you can create and use a new slider
@@ -1600,12 +1674,25 @@ like this:
1600
1674
  puts "New Slider value: #{UI.slider_value(ptr)}"
1601
1675
  0
1602
1676
  }
1603
- UI.slider_on_changed(slider, slider_changed_callback) # last element is nil, but it seems we can omit it
1677
+ LibUI.slider_on_changed(slider, slider_changed_callback) # last element is nil, but it seems we can omit it
1604
1678
 
1605
1679
  This may look like so on Linux:
1606
1680
 
1607
1681
  <img src="https://i.imgur.com/GVKPMS7.png" style="margin-left: 3em">
1608
1682
 
1683
+ In raw-libui you instantiate a new slider in this way:
1684
+
1685
+ slider = LibUI.new_slider(0, 10)
1686
+
1687
+ The two values here, 0 and 10, specify start and end position.
1688
+
1689
+ Note that you can also use the block-form rather than use
1690
+ a proc-callback. Example for this:
1691
+
1692
+ LibUI.slider_on_changed(slider1) {|widget|
1693
+ puts 'The value of the slider was changed.'
1694
+ }
1695
+
1609
1696
  ## Create a new tabbed notebook:
1610
1697
 
1611
1698
  ui_tabs
@@ -1668,7 +1755,7 @@ For instance, the text-weight part accepts these values
1668
1755
  maximum
1669
1756
  # or any number between minimum and maximum
1670
1757
 
1671
- To create an attributed String you can use the following API:
1758
+ To create an <b>attributed String</b> you can use the following API:
1672
1759
 
1673
1760
  string = LibUI.new_attributed_string
1674
1761
  attributes = LibUI.new_family_attribute("Courier New 30") # Specify a certain font.
@@ -1800,6 +1887,7 @@ may be helpful.
1800
1887
  The API for creating a new grid in libui is quite complex and
1801
1888
  hard to remember:
1802
1889
 
1890
+ # gtk-widget, left, top, xspan, yspan, hexpand, halign, vexpand, valign
1803
1891
  LibUI.grid_append(grid, entry1, 0, 0, 2, 1, 0, 0, 1, 0)
1804
1892
  LibUI.grid_append(grid, text('Yo2'), 1, 0, 1, 1, 0, 0, 1, 0) # text() can be used if you use the libui_paradise gem
1805
1893
 
@@ -1830,10 +1918,12 @@ The documentation for Go has this signature:
1830
1918
 
1831
1919
  Append adds the given control to the Grid, at the given coordinate.
1832
1920
 
1833
- I assume that **uiControl c** refers to the widget that is to be embedded
1834
- into the grid, so the numbers that follow afterwards are the ones
1835
- that are important. Let's have a look at them, based on the above API
1836
- call, and only list these again, without the **()**:
1921
+ The element called <b>uiControl c</b> refers to the widget that is to be embedded
1922
+ into the grid-widget, so the numbers that follow afterwards are the ones
1923
+ that are important.
1924
+
1925
+ Let's have a look at these numbers, based on the above API call, and only
1926
+ list these again, without the <b>()</b> this time, to simplify reading:
1837
1927
 
1838
1928
  # left, top, xspan, yspan, hexpand, halign, vexpand, valign
1839
1929
  # 0, 0, 2, 1, 0, 0, 1, 0
@@ -1844,26 +1934,27 @@ expand horizontally or vertically. halign and valign, I think,
1844
1934
  are used to align the grid-cell horizontally and vertically, so you
1845
1935
  can position them exactly in the middle.
1846
1936
 
1847
- Recently (August 2021) I discovered that you can actually put
1848
- a button-in-a-button. I don't know whether this is a bug or
1849
- a feature, but it is hilarious.
1937
+ Recently (in <b>August 2021</b>) I discovered that you can actually
1938
+ put a button-in-a-button. I don't know whether this is a bug or
1939
+ a feature, but it is hilarious nonetheless.
1850
1940
 
1851
- The 'raw' code I used for this was the following:
1941
+ The '<b>raw</b>' code I used for this was the following:
1852
1942
 
1853
- UI.grid_append(grid, UI.new_button('3'),0,1,1,1,1,1,1,1)
1854
- UI.grid_append(grid, UI.new_button('4'),1,1,1,1,1,1,1,1)
1855
- UI.grid_append(grid, UI.new_button('5'),0,1,1,1,1,0,1,0)
1856
- UI.grid_append(grid, UI.new_button('6'),1,1,1,1,1,0,1,0)
1943
+ LibUI.grid_append(grid, UI.new_button('3'),0,1,1,1,1,1,1,1)
1944
+ LibUI.grid_append(grid, UI.new_button('4'),1,1,1,1,1,1,1,1)
1945
+ LibUI.grid_append(grid, UI.new_button('5'),0,1,1,1,1,0,1,0)
1946
+ LibUI.grid_append(grid, UI.new_button('6'),1,1,1,1,1,0,1,0)
1857
1947
 
1858
- This led to the following image:
1948
+ This led to the following widget setup, as shown in this
1949
+ image:
1859
1950
 
1860
1951
  <img src="https://i.imgur.com/6sWwWKh.png" style="margin-left: 1em">
1861
1952
 
1862
1953
  The smaller buttons and the larger buttons can be clicked. They
1863
- reside in the same grid-cell. I don't know whether this is a
1864
- bug or a feature really, but this was quite hilarious to see.
1865
- In the event that I may forget this, I'll keep this here as
1866
- a reference.
1954
+ reside in the same grid-cell. As stated I do not know whether this is
1955
+ a bug or a feature really, but this was quite hilarious to see.
1956
+ In the event that I may forget this, I'll keep this here as a
1957
+ <b>reference</b>.
1867
1958
 
1868
1959
  If you want to pad the grid you can use the following method:
1869
1960
 
@@ -1901,12 +1992,13 @@ Usage example for the new API:
1901
1992
  { left: 2, top: 3, xspan: 3, yspan: 3, hexpand: 0, halign: 0, vexpand: 0, valign: 0 }
1902
1993
  )
1903
1994
 
1904
- In the closing days of <b>August 2022</b> I went on
1905
- to improve the above. Three new methods were "added"
1906
- to grid (actually Fiddle::Pointer, but hopefully one
1907
- day I can find out how to work on a grid directly
1908
- in libui; right now I seem to only have to work with
1909
- raw pointers, which confuses me).
1995
+ This again requires more argument, but on the plus side it allows you complete
1996
+ control over each positional argument.
1997
+
1998
+ In the closing days of <b>August 2022</b> I went on to improve the above. Three
1999
+ new methods were "added" to grid (actually Fiddle::Pointer, but hopefully one
2000
+ day I can find out how to work on a grid directly in libui; right now I seem
2001
+ to only have to work with raw pointers, which confuses me).
1910
2002
 
1911
2003
  These three methods are:
1912
2004
 
@@ -1998,9 +2090,10 @@ An entry can be <b>set read only</b> via:
1998
2090
 
1999
2091
  entry.read_only # This has not been added into libui-paradise yet.
2000
2092
 
2001
- To <b>respond</b> to <b>on-changed events</b>, you can use:
2093
+ To <b>respond</b> to <b>on-changed events</b>, you can use the following
2094
+ toplevel API:
2002
2095
 
2003
- LibUI.entry_on_changed()
2096
+ LibUI.entry_on_changed()
2004
2097
 
2005
2098
  A more complete example of this:
2006
2099
 
@@ -2029,8 +2122,43 @@ following simplified method call instead:
2029
2122
  puts 'The text is now: '+entry.text?
2030
2123
  }
2031
2124
 
2125
+ ## Using a pop-up message box in plain libui:
2126
+
2127
+ LibUI.msg_box(MAIN_WINDOW, 'Information', 'You clicked the button')
2128
+ LibUI.msg_box(main_window,
2129
+ 'Tiny Midi Player',
2130
+ "Written in Ruby\n" \
2131
+ "https://github.com/kojix2/libui\n Version #{VERSION}"
2132
+ )
2133
+
2134
+ ## LibUI.attributed_string_len()
2135
+
2136
+ The method LibUI.attributed_string_len() will return an Integer value.
2137
+
2138
+ A usage example follows:
2139
+
2140
+ start_position = LibUI.attributed_string_len(self)
2141
+
2142
+ ## How to create an .exe file on Windows via libui
2143
+
2144
+ First check: https://github.com/larsch/ocra/
2145
+
2146
+ In order to build an .exe file with Ocra, include 3 DLLs from ruby_builtin_dlls
2147
+ folder:
2148
+
2149
+ ocra examples/control_gallery.rb --dll ruby_builtin_dlls/libssp-0.dll --dll ruby_builtin_dlls/libgmp-10.dll --dll ruby_builtin_dlls/libffi-7.dll --gem-all=fiddle
2150
+
2151
+ Add additional options below if necessary.
2152
+
2153
+ --window
2154
+ --add-all-core
2155
+ --chdir-first
2156
+ --icon assets\app.ico
2157
+ --verbose
2158
+ --output out\gallery.exe
2159
+
2032
2160
 
2033
- ## Contact information and mandatory 2FA coming up in 2022
2161
+ ## Contact information and mandatory 2FA (no longer) coming up in 2022 / 2023
2034
2162
 
2035
2163
  If your creative mind has ideas and specific suggestions to make this gem
2036
2164
  more useful in general, feel free to drop me an email at any time, via:
@@ -2038,35 +2166,53 @@ more useful in general, feel free to drop me an email at any time, via:
2038
2166
  shevy@inbox.lt
2039
2167
 
2040
2168
  Before that email I used an email account at Google gmail, but in **2021** I
2041
- decided to slowly abandon gmail for various reasons. In order to limit this
2169
+ decided to slowly abandon gmail, for various reasons. In order to limit the
2042
2170
  explanation here, allow me to just briefly state that I do not feel as if I
2043
- want to promote any Google service anymore, for various reasons.
2044
-
2045
- Do keep in mind that responding to emails may take some time, depending on
2046
- the amount of work I may have at that moment.
2047
-
2048
- In 2022 rubygems.org decided to make 2FA mandatory for every gem owner:
2049
- see https://blog.rubygems.org/2022/06/13/making-packages-more-secure.html
2050
-
2051
- As I can not use 2FA, for reasons I will skip explaining here (see
2052
- various github issue discussions in the past), this effectively means that
2053
- Betty Li and others who run the show at rubygems.org will perma-ban me
2054
- from using rubygems as a developer.
2055
-
2056
- As I disagree with that decision completely, this will mean that all my
2057
- gems will be removed from rubygems.org prior to that sunset date, e. g.
2058
- before they permanently lock me out from the code that I used
2059
- to maintain. It is pointless to want to discuss this with them anymore -
2060
- they have made up their minds and decided that you can only use
2061
- the code if 2FA is in place, even though the code itself works just
2062
- fine. If you don't use 2FA you are effectively locked out from your
2063
- own code; I consider this a malicious attack. See also how they limited
2064
- discussions to people with mandatory 2FA on the ruby-bugtracker, thus
2065
- banning everyone permanently without 2FA:
2066
-
2067
- https://bugs.ruby-lang.org/issues/18800
2068
-
2069
- Guess it may indeed be time to finally abandon ruby - not because
2070
- ruby is a bad language, but there are people now in charge who
2071
- really should not be part of ruby in the first place.
2171
+ want to promote any Google service anymore when the user becomes the end
2172
+ product (such as via data collection by upstream services, including other
2173
+ proxy-services). My feeling is that this is a hugely flawed business model
2174
+ to begin with, and I no longer wish to support this in any way, even if
2175
+ only indirectly so, such as by using services of companies that try to
2176
+ promote this flawed model.
2177
+
2178
+ In regards to responding to emails: please keep in mind that responding
2179
+ may take some time, depending on the amount of work I may have at that
2180
+ moment. So it is not that emails are ignored; it is more that I have not
2181
+ (yet) found the time to read and reply. This means there may be a delay
2182
+ of days, weeks and in some instances also months. There is, unfortunately,
2183
+ not much I can do when I need to prioritise my time investment, but I try
2184
+ to consider <b>all</b> feedback as an opportunity to improve my projects
2185
+ nonetheless.
2186
+
2187
+ In <b>2022</b> rubygems.org decided to make 2FA mandatory for every
2188
+ gem owner eventually:
2189
+
2190
+ see
2191
+ https://blog.rubygems.org/2022/06/13/making-packages-more-secure.html
2192
+
2193
+ Mandatory 2FA will eventually be extended to all rubygems.org developers and
2194
+ maintainers. As I can not use 2FA, for reasons I will skip explaining here,
2195
+ this means that my projects will eventually be removed, as I no longer
2196
+ have any control over my projects hosted on rubygems.org (because I
2197
+ can not use 2FA).
2198
+
2199
+ At that point, I no longer have any control what is done to my projects
2200
+ since whoever is controlling the gems ecosystem took away our control
2201
+ here. I am not sure at which point ruby became corporate-controlled -
2202
+ that was not the case several years ago, so something has
2203
+ changed.
2204
+
2205
+ Ruby also only allows 2FA users to participate on the issue tracker these
2206
+ days:
2207
+
2208
+ https://bugs.ruby-lang.org/issues/18800
2209
+
2210
+ But this has been reverted some months ago, so it is no longer applicable.
2211
+ Suffice to say that I do not think that we should only be allowed to
2212
+ interact on the world wide web when some 'authority' authenticated us,
2213
+ such as via mandatory 2FA, so I hope this won't come back again.
2214
+
2215
+ Fighting spam is a noble goal, but when it also means you lock out
2216
+ real human people then this is definitely NOT a good situation
2217
+ to be had.
2072
2218