libui_paradise 0.3.9 → 0.4.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +176 -155
- data/bin/libui_message +1 -1
- data/doc/README.gen +175 -85
- data/doc/todo/todo.md +9 -5
- data/lib/libui_paradise/autoinclude.rb +2 -1
- data/lib/libui_paradise/base/base.rb +17 -67
- data/lib/libui_paradise/base_module/base_module.rb +1514 -0
- data/lib/libui_paradise/colours/colours.rb +4 -4
- data/lib/libui_paradise/domain_specific_language/README.md +6 -0
- data/lib/libui_paradise/examples/complex/002_tabs_example.rb +1 -2
- data/lib/libui_paradise/examples/complex/003_open_file_button_example.rb +1 -1
- data/lib/libui_paradise/examples/complex/006_coloured_boxes_example.rb +2 -2
- data/lib/libui_paradise/examples/complex/007_slider_example.rb +10 -4
- data/lib/libui_paradise/examples/complex/008_radio_button_example.rb +2 -2
- data/lib/libui_paradise/examples/complex/009_separator_example.rb +2 -2
- data/lib/libui_paradise/examples/complex/010_table_example.rb +5 -9
- data/lib/libui_paradise/examples/complex/011_two_buttons_showing_how_to_enable_and_disable_them.rb +2 -1
- data/lib/libui_paradise/examples/complex/012_password_entry_example.rb +1 -1
- data/lib/libui_paradise/examples/complex/013_form_example.rb +1 -1
- data/lib/libui_paradise/examples/complex/014_text_example.rb +1 -1
- data/lib/libui_paradise/examples/complex/015_text_view_example.rb +4 -4
- data/lib/libui_paradise/examples/complex/016_grid_example.rb +20 -11
- data/lib/libui_paradise/examples/complex/017_unicode_text_example.rb +2 -2
- data/lib/libui_paradise/examples/complex/018_spinbutton_example.rb +1 -1
- data/lib/libui_paradise/examples/complex/019_combo_box_example.rb +1 -1
- data/lib/libui_paradise/examples/complex/020_checkbox_example.rb +5 -5
- data/lib/libui_paradise/examples/complex/021_font_example.rb +4 -3
- data/lib/libui_paradise/examples/complex/022_simple_notepad_example.rb +3 -3
- data/lib/libui_paradise/examples/complex/023_msg_box_error.rb +5 -5
- data/lib/libui_paradise/examples/complex/024_parse_config_file_example.rb +2 -2
- data/lib/libui_paradise/examples/complex/025_colour_button.rb +1 -1
- data/lib/libui_paradise/examples/complex/026_basic_table_image.rb +5 -8
- data/lib/libui_paradise/examples/complex/027_basic_button_example.rb +3 -3
- data/lib/libui_paradise/examples/complex/028_try_for_automatic_button_press_event_after_a_delay.rb +4 -5
- data/lib/libui_paradise/examples/complex/029_progressbar_example.rb +4 -5
- data/lib/libui_paradise/examples/complex/030_entry_responds_to_comment_as_synonymous_to_the_enter_key_pressed_example.rb +5 -6
- data/lib/libui_paradise/examples/complex/031_notification_functionality_example.rb +3 -2
- data/lib/libui_paradise/examples/complex/032_simple_window_example.rb +2 -1
- data/lib/libui_paradise/examples/complex/033_daemonize_and_exit_after_delay_example.rb +3 -2
- data/lib/libui_paradise/examples/complex/034_bold_text_example.rb +115 -0
- data/lib/libui_paradise/examples/complex/035_parse_into_table_example.rb +109 -0
- data/lib/libui_paradise/examples/simple/001_open_file_example.rb +1 -1
- data/lib/libui_paradise/examples/simple/002_histogram_example.rb +6 -6
- data/lib/libui_paradise/examples/simple/003_fancy_text_example.rb +63 -35
- data/lib/libui_paradise/examples/simple/005_text_drawing_example.rb +3 -3
- data/lib/libui_paradise/examples/simple/007_control_gallery.rb +2 -1
- data/lib/libui_paradise/examples/simple/009_spectrum.rb +7 -1
- data/lib/libui_paradise/examples/simple/012_table_example.rb +5 -5
- data/lib/libui_paradise/examples/simple/013_scrolling_pane_example.rb +28 -0
- data/lib/libui_paradise/examples/simple/014_simple_entry_example.rb +30 -0
- data/lib/libui_paradise/examples/simple/015_slider_example.rb +32 -0
- data/lib/libui_paradise/fiddle/fiddle.rb +771 -636
- data/lib/libui_paradise/libui_classes/button.rb +31 -0
- data/lib/libui_paradise/libui_classes/entry.rb +35 -0
- data/lib/libui_paradise/libui_classes/grid.rb +14 -26
- data/lib/libui_paradise/libui_classes/hbox.rb +39 -0
- data/lib/libui_paradise/libui_classes/libui_classes.rb +9 -1630
- data/lib/libui_paradise/libui_classes/msg_box.rb +121 -0
- data/lib/libui_paradise/libui_classes/msg_box_error.rb +41 -0
- data/lib/libui_paradise/libui_classes/slider.rb +28 -0
- data/lib/libui_paradise/libui_classes/spinbox.rb +48 -0
- data/lib/libui_paradise/libui_classes/vbox.rb +38 -0
- data/lib/libui_paradise/project/project.rb +2 -1
- data/lib/libui_paradise/prototype/prototype.rb +8 -8
- data/lib/libui_paradise/requires/require_the_libui_classes.rb +2 -2
- data/lib/libui_paradise/requires/require_the_libui_paradise_project.rb +4 -2
- data/lib/libui_paradise/toplevel_methods/add_to_the_registered_widgets.rb +70 -0
- data/lib/libui_paradise/toplevel_methods/hash_fiddle_pointer_widgets.rb +37 -0
- data/lib/libui_paradise/{extensions → toplevel_methods}/toplevel_counters.rb +26 -1
- data/lib/libui_paradise/toplevel_methods/toplevel_methods.rb +792 -0
- data/lib/libui_paradise/version/version.rb +2 -2
- data/test/testing_generic_window.rb +2 -0
- metadata +22 -8
- data/doc/SNIPPETS.md +0 -65
- data/lib/libui_paradise/extensions/extensions.rb +0 -979
- data/lib/libui_paradise/libui_classes/box.rb +0 -157
data/doc/README.gen
CHANGED
|
@@ -9,12 +9,12 @@ by me via **gimp** and ImageMagick - the rounded borders were
|
|
|
9
9
|
done via ImageMagick. You can re-use this image if you would like to,
|
|
10
10
|
including the colour-pattern, via a **CC BY 3.0** licence. See the following
|
|
11
11
|
link for that licence: https://creativecommons.org/licenses/by/3.0/. For
|
|
12
|
-
|
|
12
|
+
<b>cfdg</b> itself, have a look at: https://www.contextfreeart.org/gallery/)
|
|
13
13
|
|
|
14
|
-
The
|
|
14
|
+
The <b>libui_paradise project</b> aims to enhance the official (upstream)
|
|
15
15
|
ruby-libui bindings a little bit.
|
|
16
16
|
|
|
17
|
-
You can find the upstream ruby-libui bindings, maintained by
|
|
17
|
+
You can find the upstream ruby-libui bindings, maintained by <b>kojix2</b>,
|
|
18
18
|
here:
|
|
19
19
|
|
|
20
20
|
https://rubygems.org/gems/libui
|
|
@@ -150,7 +150,7 @@ around one day, that idea should be retained for other GUIs
|
|
|
150
150
|
in the future.
|
|
151
151
|
|
|
152
152
|
It's quite difficult to get GTK and ruby-gtk to work on
|
|
153
|
-
|
|
153
|
+
<b>windows</b> - I tried to compile it some weeks ago but I
|
|
154
154
|
ended up having "missing symbols" error messages afterwards.
|
|
155
155
|
I managed to get the hello-world.c example working, but the
|
|
156
156
|
more complicated examples did not work for me.
|
|
@@ -168,7 +168,7 @@ no binary bundles for ruby-gtk on windows anymore either. I
|
|
|
168
168
|
assume it is possible if you know msys2, and the windows
|
|
169
169
|
platform, but I am no expert on either, so ...)
|
|
170
170
|
|
|
171
|
-
|
|
171
|
+
<b>libui</b> is so much simpler to use on windows than GTK,
|
|
172
172
|
though - just do **gem install libui** and it'll work,
|
|
173
173
|
as-is. Literally. That's it. I tried it on my windows
|
|
174
174
|
laptop and it **does** indeed work. That convinced me
|
|
@@ -282,7 +282,8 @@ sense in this regard.
|
|
|
282
282
|
|
|
283
283
|
## How to add a margin in LibUI
|
|
284
284
|
|
|
285
|
-
Use
|
|
285
|
+
Use the following API if you wish to have your main window
|
|
286
|
+
use a margin:
|
|
286
287
|
|
|
287
288
|
LibUI.window_set_margined(MAIN_WINDOW, 1)
|
|
288
289
|
|
|
@@ -428,14 +429,19 @@ Or just:
|
|
|
428
429
|
|
|
429
430
|
Since as of 2022 I prefer the longer variant, e. g. **LibUI**init. The
|
|
430
431
|
old UI constant ("alias") will be retained, but new code added to the
|
|
431
|
-
libui_paradise gem will not use
|
|
432
|
-
|
|
433
|
-
|
|
432
|
+
libui_paradise gem will not use <b>UI</b> - instead the slightly longer
|
|
433
|
+
<b>LibUI</b> is used.
|
|
434
|
+
|
|
435
|
+
Note that since as of <b>December 2023</b>, whenever the libui_paradise
|
|
436
|
+
gem is required, <b>LibuiParadise.init</b> is automatically called,
|
|
437
|
+
which in turn invokes LibUI.init. The reason as to why this is
|
|
438
|
+
the new default is so that we can omit one line of code.
|
|
439
|
+
|
|
434
440
|
## Subclassing
|
|
435
441
|
|
|
436
442
|
Currently subclassing from LibUI elements does not work - I simply
|
|
437
|
-
have no idea how to "subclass" from a
|
|
438
|
-
have to build up a data structure that behaves like
|
|
443
|
+
have no idea how to "subclass" from a <b>Fiddle::Pointer</b>. Perhaps we
|
|
444
|
+
have to build up a data structure that behaves like <b>Fiddle::Pointer</b>
|
|
439
445
|
but also has methods that allow for a more direct 'OOP behaviour'. Has
|
|
440
446
|
anyone tried this yet? I am scared to try considering I already got
|
|
441
447
|
segfaults everywhere ...
|
|
@@ -452,8 +458,8 @@ The following API can be used to create a new scrolling area:
|
|
|
452
458
|
|
|
453
459
|
LibUI.new_scrolling_area
|
|
454
460
|
|
|
455
|
-
Scrolling areas
|
|
456
|
-
amount that can be scrolled is determined by the area's
|
|
461
|
+
<b>Scrolling areas</b> may contain horizontal and vertical scrollbars.
|
|
462
|
+
The amount that can be scrolled is determined by the area's
|
|
457
463
|
size, which is decided by the programmer (both when creating
|
|
458
464
|
the Area and by a call to SetSize). Only a portion of the
|
|
459
465
|
Area is visible at any time; drawing and mouse events are
|
|
@@ -461,9 +467,9 @@ automatically adjusted to match what portion is visible,
|
|
|
461
467
|
so you do not have to worry about scrolling in your
|
|
462
468
|
event handlers.
|
|
463
469
|
|
|
464
|
-
The method LibUI.new_scrolling_area() accepts three arguments
|
|
470
|
+
The method <b>LibUI.new_scrolling_area()</b> accepts <b>three arguments</b>.
|
|
465
471
|
The second and third are width and height, respectively
|
|
466
|
-
(as
|
|
472
|
+
(as <b>integers</b>).
|
|
467
473
|
|
|
468
474
|
The first argument is the area handle. It has the following
|
|
469
475
|
pointer types (struct):
|
|
@@ -493,6 +499,12 @@ The <b>handlerDraw() function</b> in C looks like this:
|
|
|
493
499
|
uiFreeFontButtonFont(&defaultFont);
|
|
494
500
|
}
|
|
495
501
|
|
|
502
|
+
This means that you will have to pass three arguments to
|
|
503
|
+
this method - all are mandatory. Failure to do so may yield an
|
|
504
|
+
error message, such as:
|
|
505
|
+
|
|
506
|
+
gems/libui-0.1.2.pre/lib/libui/ffi.rb:20:in `call': wrong number of arguments (given 0, expected 3) (ArgumentError)
|
|
507
|
+
|
|
496
508
|
The scrollable area may look like this:
|
|
497
509
|
|
|
498
510
|
<img src="https://raw.githubusercontent.com/msink/kotlin-libui/master/samples/hello/hello-windows.png">
|
|
@@ -517,6 +529,7 @@ label / ui_text widget.
|
|
|
517
529
|
To create a combo-box in vanilla libui, do this in plain ruby-libui:
|
|
518
530
|
|
|
519
531
|
alignment = LibUI.new_combobox # Here we actually create the combobox.
|
|
532
|
+
# Next, we show how to append to a combobox:
|
|
520
533
|
LibUI.combobox_append(alignment, 'Left')
|
|
521
534
|
LibUI.combobox_append(alignment, 'Center')
|
|
522
535
|
LibUI.combobox_append(alignment, 'Right')
|
|
@@ -548,11 +561,11 @@ For instance:
|
|
|
548
561
|
|
|
549
562
|
LibUI.combobox_set_selected(combobox, 0) # The first one will be active too.
|
|
550
563
|
|
|
551
|
-
To
|
|
564
|
+
To <b>query the currently selected value</b>, use:
|
|
552
565
|
|
|
553
566
|
LibUI.combobox_selected(pointer)
|
|
554
567
|
|
|
555
|
-
This is usually done via a
|
|
568
|
+
This is usually done via a <b>proc {}</b> object. See kojix2' examples.
|
|
556
569
|
|
|
557
570
|
In LibuiParadise a few custom methods were added, such as
|
|
558
571
|
**.ui_sync_connect()**. This method was added to connect a
|
|
@@ -578,11 +591,28 @@ To add content to an editable combobox youc an use:
|
|
|
578
591
|
|
|
579
592
|
LibUI.append() # .append() adds the named item to the end of the EditableCombobox.
|
|
580
593
|
|
|
581
|
-
|
|
594
|
+
A more concise example for populating a combobox may be
|
|
595
|
+
this one here:
|
|
596
|
+
|
|
597
|
+
combo_box = LibUI.combobox {
|
|
598
|
+
['combobox Item 1', 'combobox Item 2', 'combobox Item 3']
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
The <b>source code</b> to the combo-box in libui, at the least
|
|
582
602
|
for UNIX/Linux, can be seen here:
|
|
583
603
|
|
|
584
604
|
https://github.com/andlabs/libui/blob/master/unix/combobox.c
|
|
585
605
|
|
|
606
|
+
## How to add a libui-widget to the main window - how to designate a child widget:
|
|
607
|
+
|
|
608
|
+
LibUI.window_set_child(main_window, button) # Both these widgets have to be created first, of course.
|
|
609
|
+
|
|
610
|
+
## LibUI.control_show
|
|
611
|
+
|
|
612
|
+
No clue what this does so far.
|
|
613
|
+
|
|
614
|
+
LibUI.control_show(main_window)
|
|
615
|
+
|
|
586
616
|
## Error messages and ui_error_message
|
|
587
617
|
|
|
588
618
|
In LibUI respectively ruby-libui you can display error messages
|
|
@@ -608,7 +638,7 @@ just a stub though - we may have to research this with better examples.
|
|
|
608
638
|
|
|
609
639
|
## Checkboxes in Libui-ng
|
|
610
640
|
|
|
611
|
-
A simple checkbox example in
|
|
641
|
+
A simple checkbox example in <b>plain</b> ruby-libui follows:
|
|
612
642
|
|
|
613
643
|
checkbox = LibUI.checkbox('Checkbox')
|
|
614
644
|
checkbox_toggle_callback = proc { |pointer|
|
|
@@ -625,8 +655,8 @@ This may look like so on Linux:
|
|
|
625
655
|
|
|
626
656
|
<img src="https://i.imgur.com/d7qWalZ.png" style="margin-left: 2em; padding: 4px; border: 1px solid black;">
|
|
627
657
|
|
|
628
|
-
To set such a checkbox to the checked-state (that is, as if
|
|
629
|
-
user clicked on it), use the following method, if you use the
|
|
658
|
+
To set such a checkbox to the <b>checked-state</b> (that is, as if
|
|
659
|
+
the user clicked on it), use the following method, if you use the
|
|
630
660
|
libui_paradise gem:
|
|
631
661
|
|
|
632
662
|
checkbox.set_checked(1)
|
|
@@ -635,8 +665,8 @@ To query its state use:
|
|
|
635
665
|
|
|
636
666
|
checked = LibUI.checkbox_checked(pointer) == 1
|
|
637
667
|
|
|
638
|
-
To <b>query</b> whether a checkbox is
|
|
639
|
-
following:
|
|
668
|
+
To <b>query</b> whether a checkbox is <b>active</b>, use code such as
|
|
669
|
+
the following:
|
|
640
670
|
|
|
641
671
|
checkbox.is_active?
|
|
642
672
|
checkbox.active?
|
|
@@ -645,7 +675,7 @@ This depends on the modifications to Fiddler::Pointer, so
|
|
|
645
675
|
be wary when you use this - there be dragons (perhaps). Most
|
|
646
676
|
of these modifications are based on **.object_id**, which is
|
|
647
677
|
registered in a main, toplevel Hash in the
|
|
648
|
-
|
|
678
|
+
<b>libui_paradise project</b>. Not very elegant, but simple, and
|
|
649
679
|
it works (for the most part).
|
|
650
680
|
|
|
651
681
|
The toggle-event for a checkbox can be triggered via:
|
|
@@ -657,23 +687,23 @@ The toggle-event for a checkbox can be triggered via:
|
|
|
657
687
|
0
|
|
658
688
|
}
|
|
659
689
|
|
|
660
|
-
To respond to on-toggled events
|
|
690
|
+
To respond to <b>on-toggled events</b>, do use:
|
|
661
691
|
|
|
662
692
|
LibUI.checkbox_on_toggled(checkbox, checkbox_toggle_callback, nil)
|
|
663
693
|
|
|
664
694
|
## Adding a widget into another widget
|
|
665
695
|
|
|
666
|
-
I chose the following
|
|
696
|
+
I chose the following <b>API</b> for this:
|
|
667
697
|
|
|
668
698
|
box1.add(box2, 1)
|
|
669
699
|
|
|
670
|
-
Note that this is "cheating" a bit because the method
|
|
671
|
-
on
|
|
672
|
-
also seems to work to some extent. Which is amazing ... :-)
|
|
700
|
+
Note that this is "cheating" a bit because the method <b>.add()</b> is
|
|
701
|
+
defined on <b>Fiddle::Pointer</b>. That's scary! Segfaults coming your
|
|
702
|
+
way. But it also seems to work to some extent. Which is amazing ... :-)
|
|
673
703
|
|
|
674
704
|
In ruby-gtk it is quite common to use **.add()**. While **.pack_start()**
|
|
675
705
|
and **.pack_end()** are available in ruby-gtk as well, I think .add() is
|
|
676
|
-
the simpler name. We just
|
|
706
|
+
the simpler name. We just <b>add a widget to another widget</b> - job done.
|
|
677
707
|
|
|
678
708
|
(I may also use << as alias to .add() and while << is great, remember
|
|
679
709
|
that it can not easily be used all the time, e. g. box1 << box2 <<
|
|
@@ -741,8 +771,8 @@ If you use the libui_paradise gem, you can use this:
|
|
|
741
771
|
|
|
742
772
|
## Adding a horizontal separator or a vertical separator
|
|
743
773
|
|
|
744
|
-
The method
|
|
745
|
-
first create) a horizontal separator
|
|
774
|
+
The method <b>LibUI.new_horizontal_separator</b> can be used to add (or
|
|
775
|
+
rather first create) <b>a horizontal separator</b>.
|
|
746
776
|
|
|
747
777
|
You can then add it via .add() or << if you use the libui_paradise
|
|
748
778
|
project. Alternatively you can use the toplevel method provided by
|
|
@@ -791,6 +821,10 @@ not necessarily recommending this be done, but **if** you ever have
|
|
|
791
821
|
such a use case then you can use it - which is another reason why
|
|
792
822
|
I added this screenshot, so that I don't forget. :)
|
|
793
823
|
|
|
824
|
+
The toplevel method <b>LibuiParadise.horizontal_separator()</b>
|
|
825
|
+
has also been added; it is simply a wrapper towards
|
|
826
|
+
<b>LibUI.new_horizontal_separator()</b>.
|
|
827
|
+
|
|
794
828
|
## Padding elements in LibUI
|
|
795
829
|
|
|
796
830
|
The general API for setting padding to a container in LibUI
|
|
@@ -874,24 +908,38 @@ hand. Only the raw filename will be used, so if you
|
|
|
874
908
|
have a file at **/tmp/foo/bar.rb** then the title
|
|
875
909
|
of the window will be **bar.rb**.
|
|
876
910
|
|
|
877
|
-
##
|
|
911
|
+
## Entries in libui (libui-entry)
|
|
878
912
|
|
|
879
|
-
|
|
913
|
+
Let's first show how an <b>entry</b> in libui may look like:
|
|
880
914
|
|
|
881
915
|
<img src="https://raw.githubusercontent.com/parro-it/libui-node/master/docs/media/UiEntry.png" style="margin-left:1em">
|
|
882
916
|
|
|
883
|
-
Such an entry can be set to be
|
|
917
|
+
Such an entry can be set to be <b>read only</b> (readOnly: Boolean, aka true or false).
|
|
918
|
+
This means that it can not be changed by the user; it is then only used to
|
|
919
|
+
display some content.
|
|
884
920
|
|
|
885
|
-
The upstream C code for libui-entry, for
|
|
921
|
+
The upstream C code for libui-entry, for <b>unix/</b>, can be seen here:
|
|
886
922
|
|
|
887
923
|
https://github.com/andlabs/libui/blob/master/unix/entry.c
|
|
888
924
|
|
|
925
|
+
To create a new libui-entry, in raw libui-code, use this method:
|
|
926
|
+
|
|
927
|
+
LibUI.new_entry
|
|
928
|
+
entry = LibUI.new_entry # or better, this variant
|
|
929
|
+
|
|
889
930
|
In ruby, for the LibUI namespace, you can set text on an entry
|
|
890
931
|
by calling <b>LibUI.entry_set_text()</b>, such as shown in
|
|
891
932
|
the following example:
|
|
892
933
|
|
|
893
934
|
LibUI.entry_set_text(entry, 'Please enter your feelings')
|
|
894
935
|
|
|
936
|
+
If you use the libui_paradise gem, a modification in Fiddle
|
|
937
|
+
is to allow the method calls called .is_read_only and its
|
|
938
|
+
alias name, .readonly. This can be called on the entry,
|
|
939
|
+
such as:
|
|
940
|
+
|
|
941
|
+
entry.readonly
|
|
942
|
+
|
|
895
943
|
## Borderless windows and fullscreen windows
|
|
896
944
|
|
|
897
945
|
A window that is **borderless: true** will not show any title or
|
|
@@ -901,6 +949,14 @@ To set the main window to full screen (occupy the whole monitor) do:
|
|
|
901
949
|
|
|
902
950
|
LibUI.window_set_fullscreen(main_window, 1)
|
|
903
951
|
|
|
952
|
+
## How to add a new main window:
|
|
953
|
+
# width, height, hasMenubar
|
|
954
|
+
main_window = LibUI.new_window('hello world', 300, 200, 1)
|
|
955
|
+
|
|
956
|
+
The source code for this method can be seen here:
|
|
957
|
+
|
|
958
|
+
https://raw.githubusercontent.com/libui-ng/libui-ng/master/unix/window.c
|
|
959
|
+
|
|
904
960
|
## Spinbutton / Spinbox
|
|
905
961
|
|
|
906
962
|
You can use the following API for a spinbox:
|
|
@@ -955,29 +1011,30 @@ In libui the general API for this is:
|
|
|
955
1011
|
|
|
956
1012
|
## Control Gallery
|
|
957
1013
|
|
|
958
|
-
Here is an image, from kotlin-libui
|
|
1014
|
+
Here is an image, from <b>kotlin-libui</b>, how this may look on windows:
|
|
959
1015
|
|
|
960
1016
|
<img src="https://raw.githubusercontent.com/msink/kotlin-libui/master/samples/controlgallery/controlgallery-windows7.png" style="margin-left: 2em">
|
|
961
1017
|
|
|
962
1018
|
## LibUI.new_button() - how to work with buttons in LibUI in general
|
|
963
1019
|
|
|
964
|
-
<b>LibUI.new_button</b> allows us to create a new button via
|
|
965
|
-
LibUI.
|
|
1020
|
+
<b>LibUI.new_button</b> allows us to create a new button, via
|
|
1021
|
+
the LibUI gem maintained by kojix2.
|
|
966
1022
|
|
|
967
|
-
Examples for this:
|
|
1023
|
+
Examples for this, syntax-wise, follow:
|
|
968
1024
|
|
|
969
1025
|
button1 = LibUI.new_button('Text')
|
|
970
1026
|
button2 = LibUI.new_button('▶')
|
|
971
1027
|
button3 = LibUI.new_button('■') # You can use Unicode / Emojis here just fine.
|
|
1028
|
+
button3 = LibUI.new_button('♥') # This also gives you a way to do simple GUI elements, thanks to Unicode / Emoji.
|
|
972
1029
|
|
|
973
|
-
Now, we need to "tell" this button what to do when it is clicked
|
|
974
|
-
This is done via
|
|
1030
|
+
Now, we need to "<i>tell</i>" this button what to do when it is clicked
|
|
1031
|
+
by the user. This is done via the method <b>LibUI.button_on_clicked()</b>.
|
|
975
1032
|
|
|
976
|
-
|
|
1033
|
+
Usage example:
|
|
977
1034
|
|
|
978
|
-
LibUI.button_on_clicked(button)
|
|
979
|
-
LibUI.msg_box(MAIN_WINDOW, 'Information', 'You clicked the button')
|
|
980
|
-
|
|
1035
|
+
LibUI.button_on_clicked(button) {
|
|
1036
|
+
LibUI.msg_box(MAIN_WINDOW, 'Information', 'You clicked the button') # Show a message-box upon clicking this button.
|
|
1037
|
+
}
|
|
981
1038
|
|
|
982
1039
|
## Enabling / Disabling buttons in libui
|
|
983
1040
|
|
|
@@ -1123,17 +1180,6 @@ to be simpler for the time being. I may plan to change a lot more one day,
|
|
|
1123
1180
|
if I ever manage to find out how to simulate proper subclasses via
|
|
1124
1181
|
Fiddle::Pointer ... :)
|
|
1125
1182
|
|
|
1126
|
-
--------------------------------------------------------------------------------
|
|
1127
|
-
## SNIPPETS.md
|
|
1128
|
-
|
|
1129
|
-
Next, the content of the file called **SNIPPETS.md** will be shown. Note
|
|
1130
|
-
that this file will eventually be integreated into this file, and then
|
|
1131
|
-
subsequently removed one day.
|
|
1132
|
-
|
|
1133
|
-
EMBED_THIS_FILE /home/x/programming/ruby/src/libui_paradise/doc/SNIPPETS.md
|
|
1134
|
-
|
|
1135
|
-
--------------------------------------------------------------------------------
|
|
1136
|
-
|
|
1137
1183
|
## Advantages and Disadvantages of the libui project
|
|
1138
1184
|
|
|
1139
1185
|
It would be unfair to only selectively name advantages but not talk about
|
|
@@ -1141,29 +1187,31 @@ disadvantages, so this subsection will show some limitations, trade-offs,
|
|
|
1141
1187
|
constraints and opportunities. This is not complete, but it may become
|
|
1142
1188
|
somewhat more complete over time. Stay tuned.
|
|
1143
1189
|
|
|
1144
|
-
(a) Advantages:
|
|
1190
|
+
(a) Advantages of LibUI:
|
|
1145
1191
|
|
|
1146
|
-
- Works on windows out-of-the-box after
|
|
1192
|
+
- Works on the windows platform, out-of-the-box, after the libui-gem has been installed.
|
|
1147
1193
|
- Is super-simple to use compared to other toolkits, including ruby-gtk.
|
|
1148
|
-
- Super-simple to build up a prototype for a GUI, buttons that work,
|
|
1149
|
-
|
|
1150
|
-
IMO.
|
|
1194
|
+
- Super-simple to build up a prototype for a GUI, buttons that work, spin-boxes, text-views
|
|
1195
|
+
and so forth. Faster than any other toolkit, IMO.
|
|
1151
1196
|
- Works cross-platform.
|
|
1152
1197
|
|
|
1153
|
-
(b) Disadvantage:
|
|
1198
|
+
(b) Disadvantage of LibUI:
|
|
1154
1199
|
|
|
1155
1200
|
- Limited ability to control the layout and size of widgets.
|
|
1156
|
-
- May look like utter crap ... :-)
|
|
1157
|
-
- Some functionality is missing, such as a scrolled-window for every widget
|
|
1201
|
+
- May look like utter crap on some platforms ... :-)
|
|
1202
|
+
- Some functionality is flat-out missing, such as a scrolled-window for every widget
|
|
1203
|
+
or tooltips for every widget.
|
|
1158
1204
|
- No way to use different fonts in the same application and choosing a font
|
|
1159
1205
|
is needlessly complicated. (This may not be completely correct, though -
|
|
1160
|
-
the glimmer-dsl-libui has
|
|
1206
|
+
the glimmer-dsl-libui has examples that seem to work. But if you ask me
|
|
1161
1207
|
right now in 2021 how this works via a standalone example then I can
|
|
1162
1208
|
happily tell you I have absolutely no idea. Which brings me to the
|
|
1163
|
-
next problem...)
|
|
1164
|
-
- Lack of documentation. This part is REALLY annoying
|
|
1209
|
+
next problem ...)
|
|
1210
|
+
- Lack of documentation overall. This part is REALLY annoying, because there
|
|
1211
|
+
are only few users, so asking others about documentation when there is nobody
|
|
1212
|
+
else using it, plan sucks ...
|
|
1165
1213
|
|
|
1166
|
-
Some more disadvantages relate to Fiddle::Pointer
|
|
1214
|
+
Some more disadvantages relate to <b>Fiddle::Pointer</b>. You kind of need to
|
|
1167
1215
|
know C fairly well as well as the GC in ruby, in order to understand
|
|
1168
1216
|
what is going on. Since I don't, I hit a dead end, kind of.
|
|
1169
1217
|
|
|
@@ -1171,6 +1219,10 @@ This is so far in September 2021. Let's see what the future brings.
|
|
|
1171
1219
|
Perhaps other toolkits will learn from libui and implement the good
|
|
1172
1220
|
parts for **their own** widget set.
|
|
1173
1221
|
|
|
1222
|
+
Update in December 2023: things improved a bit, so the above is not
|
|
1223
|
+
100% correct anymore. In particular libui-ng may receive some more
|
|
1224
|
+
usability-centric updates in the next months.
|
|
1225
|
+
|
|
1174
1226
|
## LibuiParadise.parse_this_config_file()
|
|
1175
1227
|
|
|
1176
1228
|
This method can be used to parse a .config file. This file should
|
|
@@ -1220,17 +1272,21 @@ You can also use something like '95%' as input. In that case the
|
|
|
1220
1272
|
desired value will be calculated depending on the max-resolution
|
|
1221
1273
|
of the current display. This presently only works on **linux**; if
|
|
1222
1274
|
someone knows how to make this work on windows and Mac OSX let
|
|
1223
|
-
me know. (On these systems
|
|
1224
|
-
value of 1024 for width and 800 for height
|
|
1275
|
+
me know. (On these two systems the method will instead default
|
|
1276
|
+
to a hardcoded value of 1024 for width and 800 for height; these
|
|
1277
|
+
values, I think, are probably fairly safe, to also support older
|
|
1278
|
+
laptops. Evidently for smartphone devices this won't work, so
|
|
1279
|
+
if anyone has an idea how to handle this differently let me
|
|
1280
|
+
know).
|
|
1225
1281
|
|
|
1226
1282
|
The following example shows how to use a percentage value:
|
|
1227
1283
|
|
|
1228
|
-
set_height('80%')
|
|
1284
|
+
set_height('80%') # 80% of the max-height.
|
|
1229
1285
|
|
|
1230
1286
|
## Coloured Text
|
|
1231
1287
|
|
|
1232
1288
|
At this point I only show how this may look on Win7, re-using
|
|
1233
|
-
the picture the
|
|
1289
|
+
the picture the <b>kotlin-libui developers</b> made available:
|
|
1234
1290
|
|
|
1235
1291
|
<img src="https://raw.githubusercontent.com/msink/kotlin-libui/master/samples/drawtext/drawtext-windows7.png" style="margin-left: 2em">
|
|
1236
1292
|
|
|
@@ -1537,8 +1593,8 @@ Available "**new**"-widgets in LibUI:
|
|
|
1537
1593
|
LibUI.new_weight_attribute
|
|
1538
1594
|
LibUI.new_form # this is a form
|
|
1539
1595
|
LibUI.new_size_attribute
|
|
1540
|
-
LibUI.new_window
|
|
1541
|
-
LibUI.new_slider # this is a slider
|
|
1596
|
+
LibUI.new_window # this will create a new window, such as a gtk-window on linux
|
|
1597
|
+
LibUI.new_slider # this is a slider, allowing the user to set a value via a small GUI-handle
|
|
1542
1598
|
|
|
1543
1599
|
## A search entry in LibUI
|
|
1544
1600
|
|
|
@@ -1567,9 +1623,18 @@ Example for this:
|
|
|
1567
1623
|
|
|
1568
1624
|
## How to to build a menu-interface (menu tag):
|
|
1569
1625
|
|
|
1626
|
+
Building a menu in libui is possible by using the method
|
|
1627
|
+
<b>LibUI.new_menu()</b>.
|
|
1628
|
+
|
|
1629
|
+
A more complete example follows:
|
|
1630
|
+
|
|
1570
1631
|
help_menu = LibUI.new_menu('Help')
|
|
1571
1632
|
version_item = LibUI.menu_append_item(help_menu, 'Version')
|
|
1572
1633
|
|
|
1634
|
+
On IceWM this may look like this:
|
|
1635
|
+
|
|
1636
|
+
<img src="https://i.imgur.com/1rWYcZM.png" style="margin: 1em">
|
|
1637
|
+
|
|
1573
1638
|
## Creating a new drawing area in LibUI
|
|
1574
1639
|
|
|
1575
1640
|
The following code should suffice:
|
|
@@ -1611,6 +1676,19 @@ This may look like so on Linux:
|
|
|
1611
1676
|
|
|
1612
1677
|
<img src="https://i.imgur.com/GVKPMS7.png" style="margin-left: 3em">
|
|
1613
1678
|
|
|
1679
|
+
In raw-libui you instantiate a new slider in this way:
|
|
1680
|
+
|
|
1681
|
+
slider = LibUI.new_slider(0, 10)
|
|
1682
|
+
|
|
1683
|
+
The two values here, 0 and 10, specify start and end position.
|
|
1684
|
+
|
|
1685
|
+
Note that you can also use the block-form rather than use
|
|
1686
|
+
a proc-callback. Example for this:
|
|
1687
|
+
|
|
1688
|
+
LibUI.slider_on_changed(slider1) {|widget|
|
|
1689
|
+
puts 'The value of the slider was changed.'
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1614
1692
|
## Create a new tabbed notebook:
|
|
1615
1693
|
|
|
1616
1694
|
ui_tabs
|
|
@@ -1805,6 +1883,7 @@ may be helpful.
|
|
|
1805
1883
|
The API for creating a new grid in libui is quite complex and
|
|
1806
1884
|
hard to remember:
|
|
1807
1885
|
|
|
1886
|
+
# gtk-widget, left, top, xspan, yspan, hexpand, halign, vexpand, valign
|
|
1808
1887
|
LibUI.grid_append(grid, entry1, 0, 0, 2, 1, 0, 0, 1, 0)
|
|
1809
1888
|
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
|
|
1810
1889
|
|
|
@@ -1835,10 +1914,12 @@ The documentation for Go has this signature:
|
|
|
1835
1914
|
|
|
1836
1915
|
Append adds the given control to the Grid, at the given coordinate.
|
|
1837
1916
|
|
|
1838
|
-
|
|
1839
|
-
into the grid, so the numbers that follow afterwards are the ones
|
|
1840
|
-
that are important.
|
|
1841
|
-
|
|
1917
|
+
The element called <b>uiControl c</b> refers to the widget that is to be embedded
|
|
1918
|
+
into the grid-widget, so the numbers that follow afterwards are the ones
|
|
1919
|
+
that are important.
|
|
1920
|
+
|
|
1921
|
+
Let's have a look at these numbers, based on the above API call, and only
|
|
1922
|
+
list these again, without the <b>()</b> this time, to simplify reading:
|
|
1842
1923
|
|
|
1843
1924
|
# left, top, xspan, yspan, hexpand, halign, vexpand, valign
|
|
1844
1925
|
# 0, 0, 2, 1, 0, 0, 1, 0
|
|
@@ -1907,12 +1988,13 @@ Usage example for the new API:
|
|
|
1907
1988
|
{ left: 2, top: 3, xspan: 3, yspan: 3, hexpand: 0, halign: 0, vexpand: 0, valign: 0 }
|
|
1908
1989
|
)
|
|
1909
1990
|
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1991
|
+
This again requires more argument, but on the plus side it allows you complete
|
|
1992
|
+
control over each positional argument.
|
|
1993
|
+
|
|
1994
|
+
In the closing days of <b>August 2022</b> I went on to improve the above. Three
|
|
1995
|
+
new methods were "added" to grid (actually Fiddle::Pointer, but hopefully one
|
|
1996
|
+
day I can find out how to work on a grid directly in libui; right now I seem
|
|
1997
|
+
to only have to work with raw pointers, which confuses me).
|
|
1916
1998
|
|
|
1917
1999
|
These three methods are:
|
|
1918
2000
|
|
|
@@ -2045,6 +2127,14 @@ following simplified method call instead:
|
|
|
2045
2127
|
"https://github.com/kojix2/libui\n Version #{VERSION}"
|
|
2046
2128
|
)
|
|
2047
2129
|
|
|
2130
|
+
## LibUI.attributed_string_len()
|
|
2131
|
+
|
|
2132
|
+
The method LibUI.attributed_string_len() will return an Integer value.
|
|
2133
|
+
|
|
2134
|
+
A usage example follows:
|
|
2135
|
+
|
|
2136
|
+
start_position = LibUI.attributed_string_len(self)
|
|
2137
|
+
|
|
2048
2138
|
## How to create an .exe file on Windows via libui
|
|
2049
2139
|
|
|
2050
2140
|
First check: https://github.com/larsch/ocra/
|
data/doc/todo/todo.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
------------------------------------------------------------------------------------
|
|
2
|
+
- Make sure that each component has a screenshot. It's ok to
|
|
3
|
+
re-use existing screenshots from other projects.
|
|
4
|
+
Perhaps also look at the examples again to show how this
|
|
5
|
+
can be used.
|
|
6
|
+
|
|
7
|
+
What is missing still?
|
|
8
|
+
|
|
9
|
+
|
|
1
10
|
------------------------------------------------------------------------------------
|
|
2
11
|
- Rewrite the project from the get-go. Also integrate
|
|
3
12
|
@main_window into the main hash, rather than have it
|
|
@@ -6,11 +15,6 @@
|
|
|
6
15
|
now we'll keep it as-is.
|
|
7
16
|
As we rewrite it, improve the documentation.
|
|
8
17
|
------------------------------------------------------------------------------------
|
|
9
|
-
- Make sure that each component has a screenshot. It's ok to
|
|
10
|
-
re-use existing screenshots from other projects.
|
|
11
|
-
Perhaps also look at the examples again to show how this
|
|
12
|
-
can be used.
|
|
13
|
-
------------------------------------------------------------------------------------
|
|
14
18
|
- Make sure the project is API compatible to glimmer-libui.
|
|
15
19
|
------------------------------------------------------------------------------------
|
|
16
20
|
- Re-organize the examples, perhaps starting with another
|