libui_paradise 0.2.49 → 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 +405 -259
- data/bin/libui_message +7 -0
- data/doc/README.gen +356 -131
- data/doc/todo/todo.md +14 -5
- data/lib/libui_paradise/autoinclude.rb +2 -1
- data/lib/libui_paradise/base/base.rb +51 -62
- data/lib/libui_paradise/base_module/base_module.rb +1514 -0
- data/lib/libui_paradise/colours/colours.rb +14 -2
- 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 +3 -5
- 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 +139 -49
- 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 +80 -43
- data/lib/libui_paradise/examples/simple/005_text_drawing_example.rb +11 -11
- data/lib/libui_paradise/examples/simple/007_control_gallery.rb +21 -14
- data/lib/libui_paradise/examples/simple/009_spectrum.rb +7 -1
- data/lib/libui_paradise/examples/simple/010_font_button.rb +31 -0
- data/lib/libui_paradise/examples/simple/011_simple_notepad.rb +24 -0
- data/lib/libui_paradise/examples/simple/012_table_example.rb +71 -0
- 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/{pointer.rb → fiddle.rb} +768 -615
- data/lib/libui_paradise/generic_window/generic_window.rb +1 -1
- data/lib/libui_paradise/images/README.md +5 -2
- 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 -23
- data/lib/libui_paradise/libui_classes/hbox.rb +39 -0
- data/lib/libui_paradise/libui_classes/libui_classes.rb +9 -1595
- 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 +6 -1
- data/lib/libui_paradise/prototype/prototype.rb +8 -10
- data/lib/libui_paradise/requires/require_the_libui_classes.rb +2 -2
- data/lib/libui_paradise/requires/require_the_libui_paradise_project.rb +5 -3
- 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/toplevel_methods/toplevel_counters.rb +83 -0
- data/lib/libui_paradise/toplevel_methods/toplevel_methods.rb +792 -0
- data/lib/libui_paradise/version/version.rb +2 -2
- data/lib/libui_paradise.rb +0 -0
- data/libui_paradise.gemspec +5 -4
- data/test/testing_generic_window.rb +2 -0
- metadata +35 -30
- data/doc/SNIPPETS.md +0 -94
- data/lib/libui_paradise/extensions/counters.rb +0 -58
- data/lib/libui_paradise/extensions/extensions.rb +0 -29
- data/lib/libui_paradise/extensions/hash_fiddle_pointer_widgets.rb +0 -150
- data/lib/libui_paradise/extensions/misc.rb +0 -754
- data/lib/libui_paradise/libui_classes/box.rb +0 -156
- data/lib/libui_paradise/toplevel_methods/misc.rb +0 -13
data/doc/README.gen
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
ADD_LAST_UPDATE
|
|
1
|
+
DEFAULT_HEADER
|
|
3
2
|
|
|
4
3
|
## The libui_paradise project
|
|
5
4
|
|
|
@@ -10,12 +9,12 @@ by me via **gimp** and ImageMagick - the rounded borders were
|
|
|
10
9
|
done via ImageMagick. You can re-use this image if you would like to,
|
|
11
10
|
including the colour-pattern, via a **CC BY 3.0** licence. See the following
|
|
12
11
|
link for that licence: https://creativecommons.org/licenses/by/3.0/. For
|
|
13
|
-
|
|
12
|
+
<b>cfdg</b> itself, have a look at: https://www.contextfreeart.org/gallery/)
|
|
14
13
|
|
|
15
|
-
The
|
|
14
|
+
The <b>libui_paradise project</b> aims to enhance the official (upstream)
|
|
16
15
|
ruby-libui bindings a little bit.
|
|
17
16
|
|
|
18
|
-
You can find the upstream ruby-libui bindings, maintained by
|
|
17
|
+
You can find the upstream ruby-libui bindings, maintained by <b>kojix2</b>,
|
|
19
18
|
here:
|
|
20
19
|
|
|
21
20
|
https://rubygems.org/gems/libui
|
|
@@ -151,7 +150,7 @@ around one day, that idea should be retained for other GUIs
|
|
|
151
150
|
in the future.
|
|
152
151
|
|
|
153
152
|
It's quite difficult to get GTK and ruby-gtk to work on
|
|
154
|
-
|
|
153
|
+
<b>windows</b> - I tried to compile it some weeks ago but I
|
|
155
154
|
ended up having "missing symbols" error messages afterwards.
|
|
156
155
|
I managed to get the hello-world.c example working, but the
|
|
157
156
|
more complicated examples did not work for me.
|
|
@@ -169,7 +168,7 @@ no binary bundles for ruby-gtk on windows anymore either. I
|
|
|
169
168
|
assume it is possible if you know msys2, and the windows
|
|
170
169
|
platform, but I am no expert on either, so ...)
|
|
171
170
|
|
|
172
|
-
|
|
171
|
+
<b>libui</b> is so much simpler to use on windows than GTK,
|
|
173
172
|
though - just do **gem install libui** and it'll work,
|
|
174
173
|
as-is. Literally. That's it. I tried it on my windows
|
|
175
174
|
laptop and it **does** indeed work. That convinced me
|
|
@@ -283,7 +282,8 @@ sense in this regard.
|
|
|
283
282
|
|
|
284
283
|
## How to add a margin in LibUI
|
|
285
284
|
|
|
286
|
-
Use
|
|
285
|
+
Use the following API if you wish to have your main window
|
|
286
|
+
use a margin:
|
|
287
287
|
|
|
288
288
|
LibUI.window_set_margined(MAIN_WINDOW, 1)
|
|
289
289
|
|
|
@@ -429,14 +429,19 @@ Or just:
|
|
|
429
429
|
|
|
430
430
|
Since as of 2022 I prefer the longer variant, e. g. **LibUI**init. The
|
|
431
431
|
old UI constant ("alias") will be retained, but new code added to the
|
|
432
|
-
libui_paradise gem will not use
|
|
433
|
-
|
|
434
|
-
|
|
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
|
+
|
|
435
440
|
## Subclassing
|
|
436
441
|
|
|
437
442
|
Currently subclassing from LibUI elements does not work - I simply
|
|
438
|
-
have no idea how to "subclass" from a
|
|
439
|
-
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>
|
|
440
445
|
but also has methods that allow for a more direct 'OOP behaviour'. Has
|
|
441
446
|
anyone tried this yet? I am scared to try considering I already got
|
|
442
447
|
segfaults everywhere ...
|
|
@@ -453,8 +458,8 @@ The following API can be used to create a new scrolling area:
|
|
|
453
458
|
|
|
454
459
|
LibUI.new_scrolling_area
|
|
455
460
|
|
|
456
|
-
Scrolling areas
|
|
457
|
-
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
|
|
458
463
|
size, which is decided by the programmer (both when creating
|
|
459
464
|
the Area and by a call to SetSize). Only a portion of the
|
|
460
465
|
Area is visible at any time; drawing and mouse events are
|
|
@@ -462,9 +467,9 @@ automatically adjusted to match what portion is visible,
|
|
|
462
467
|
so you do not have to worry about scrolling in your
|
|
463
468
|
event handlers.
|
|
464
469
|
|
|
465
|
-
The method LibUI.new_scrolling_area() accepts three arguments
|
|
470
|
+
The method <b>LibUI.new_scrolling_area()</b> accepts <b>three arguments</b>.
|
|
466
471
|
The second and third are width and height, respectively
|
|
467
|
-
(as
|
|
472
|
+
(as <b>integers</b>).
|
|
468
473
|
|
|
469
474
|
The first argument is the area handle. It has the following
|
|
470
475
|
pointer types (struct):
|
|
@@ -475,7 +480,7 @@ pointer types (struct):
|
|
|
475
480
|
.DragBroken
|
|
476
481
|
.KeyEvent
|
|
477
482
|
|
|
478
|
-
The handlerDraw() function in C looks like this:
|
|
483
|
+
The <b>handlerDraw() function</b> in C looks like this:
|
|
479
484
|
|
|
480
485
|
static void handlerDraw(uiAreaHandler *a, uiArea *area, uiAreaDrawParams *p)
|
|
481
486
|
{
|
|
@@ -494,6 +499,12 @@ The handlerDraw() function in C looks like this:
|
|
|
494
499
|
uiFreeFontButtonFont(&defaultFont);
|
|
495
500
|
}
|
|
496
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
|
+
|
|
497
508
|
The scrollable area may look like this:
|
|
498
509
|
|
|
499
510
|
<img src="https://raw.githubusercontent.com/msink/kotlin-libui/master/samples/hello/hello-windows.png">
|
|
@@ -515,9 +526,10 @@ label / ui_text widget.
|
|
|
515
526
|
|
|
516
527
|
## Working with combo-boxes
|
|
517
528
|
|
|
518
|
-
To create a combo-box in vanilla libui, do this:
|
|
529
|
+
To create a combo-box in vanilla libui, do this in plain ruby-libui:
|
|
519
530
|
|
|
520
|
-
alignment = LibUI.new_combobox
|
|
531
|
+
alignment = LibUI.new_combobox # Here we actually create the combobox.
|
|
532
|
+
# Next, we show how to append to a combobox:
|
|
521
533
|
LibUI.combobox_append(alignment, 'Left')
|
|
522
534
|
LibUI.combobox_append(alignment, 'Center')
|
|
523
535
|
LibUI.combobox_append(alignment, 'Right')
|
|
@@ -549,11 +561,11 @@ For instance:
|
|
|
549
561
|
|
|
550
562
|
LibUI.combobox_set_selected(combobox, 0) # The first one will be active too.
|
|
551
563
|
|
|
552
|
-
To
|
|
564
|
+
To <b>query the currently selected value</b>, use:
|
|
553
565
|
|
|
554
566
|
LibUI.combobox_selected(pointer)
|
|
555
567
|
|
|
556
|
-
This is usually done via a
|
|
568
|
+
This is usually done via a <b>proc {}</b> object. See kojix2' examples.
|
|
557
569
|
|
|
558
570
|
In LibuiParadise a few custom methods were added, such as
|
|
559
571
|
**.ui_sync_connect()**. This method was added to connect a
|
|
@@ -575,11 +587,32 @@ So:
|
|
|
575
587
|
There are probably more elegant ways to solve this, but I only
|
|
576
588
|
wanted to solve this quickly and move on.
|
|
577
589
|
|
|
578
|
-
|
|
590
|
+
To add content to an editable combobox youc an use:
|
|
591
|
+
|
|
592
|
+
LibUI.append() # .append() adds the named item to the end of the EditableCombobox.
|
|
593
|
+
|
|
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
|
|
579
602
|
for UNIX/Linux, can be seen here:
|
|
580
603
|
|
|
581
604
|
https://github.com/andlabs/libui/blob/master/unix/combobox.c
|
|
582
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
|
+
|
|
583
616
|
## Error messages and ui_error_message
|
|
584
617
|
|
|
585
618
|
In LibUI respectively ruby-libui you can display error messages
|
|
@@ -603,22 +636,37 @@ respectively.
|
|
|
603
636
|
**Form** is a container that takes labels for its contents. This is currently
|
|
604
637
|
just a stub though - we may have to research this with better examples.
|
|
605
638
|
|
|
606
|
-
## Libui
|
|
639
|
+
## Checkboxes in Libui-ng
|
|
607
640
|
|
|
608
|
-
A simple checkbox example in
|
|
641
|
+
A simple checkbox example in <b>plain</b> ruby-libui follows:
|
|
609
642
|
|
|
610
|
-
checkbox =
|
|
611
|
-
checkbox_toggle_callback = proc { |
|
|
612
|
-
checked =
|
|
613
|
-
|
|
643
|
+
checkbox = LibUI.checkbox('Checkbox')
|
|
644
|
+
checkbox_toggle_callback = proc { |pointer|
|
|
645
|
+
checked = LibUI.checkbox_checked(pointer) == 1
|
|
646
|
+
LibUI.checkbox_set_text(ptr, "I am the checkbox (#{checked})")
|
|
614
647
|
}
|
|
615
648
|
|
|
649
|
+
Or:
|
|
650
|
+
|
|
651
|
+
checkbox = LibUI.new_checkbox('Checkbox')
|
|
652
|
+
# ui_checkbox can be used if you use the libui_paradise gem.
|
|
653
|
+
|
|
616
654
|
This may look like so on Linux:
|
|
617
655
|
|
|
618
656
|
<img src="https://i.imgur.com/d7qWalZ.png" style="margin-left: 2em; padding: 4px; border: 1px solid black;">
|
|
619
657
|
|
|
620
|
-
To
|
|
621
|
-
following
|
|
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
|
|
660
|
+
libui_paradise gem:
|
|
661
|
+
|
|
662
|
+
checkbox.set_checked(1)
|
|
663
|
+
|
|
664
|
+
To query its state use:
|
|
665
|
+
|
|
666
|
+
checked = LibUI.checkbox_checked(pointer) == 1
|
|
667
|
+
|
|
668
|
+
To <b>query</b> whether a checkbox is <b>active</b>, use code such as
|
|
669
|
+
the following:
|
|
622
670
|
|
|
623
671
|
checkbox.is_active?
|
|
624
672
|
checkbox.active?
|
|
@@ -627,22 +675,35 @@ This depends on the modifications to Fiddler::Pointer, so
|
|
|
627
675
|
be wary when you use this - there be dragons (perhaps). Most
|
|
628
676
|
of these modifications are based on **.object_id**, which is
|
|
629
677
|
registered in a main, toplevel Hash in the
|
|
630
|
-
|
|
678
|
+
<b>libui_paradise project</b>. Not very elegant, but simple, and
|
|
631
679
|
it works (for the most part).
|
|
632
680
|
|
|
681
|
+
The toggle-event for a checkbox can be triggered via:
|
|
682
|
+
|
|
683
|
+
checkbox_toggle_callback = proc { |pointer|
|
|
684
|
+
checked = LibLibUI.checkbox_checked(pointer) == 1
|
|
685
|
+
LibUI.window_set_title(MAIN_WINDOW, "Checkbox is #{checked}")
|
|
686
|
+
LibUI.checkbox_set_text(pointer, "I am the checkbox (#{checked})")
|
|
687
|
+
0
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
To respond to <b>on-toggled events</b>, do use:
|
|
691
|
+
|
|
692
|
+
LibUI.checkbox_on_toggled(checkbox, checkbox_toggle_callback, nil)
|
|
693
|
+
|
|
633
694
|
## Adding a widget into another widget
|
|
634
695
|
|
|
635
|
-
I chose the following
|
|
696
|
+
I chose the following <b>API</b> for this:
|
|
636
697
|
|
|
637
698
|
box1.add(box2, 1)
|
|
638
699
|
|
|
639
|
-
Note that this is "cheating" a bit because the method
|
|
640
|
-
on
|
|
641
|
-
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 ... :-)
|
|
642
703
|
|
|
643
704
|
In ruby-gtk it is quite common to use **.add()**. While **.pack_start()**
|
|
644
705
|
and **.pack_end()** are available in ruby-gtk as well, I think .add() is
|
|
645
|
-
the simpler name. We just
|
|
706
|
+
the simpler name. We just <b>add a widget to another widget</b> - job done.
|
|
646
707
|
|
|
647
708
|
(I may also use << as alias to .add() and while << is great, remember
|
|
648
709
|
that it can not easily be used all the time, e. g. box1 << box2 <<
|
|
@@ -683,6 +744,20 @@ The notebook-tab may look like this:
|
|
|
683
744
|
|
|
684
745
|
<img src="https://i.imgur.com/olWQAIJ.png" style="margin-left: 2em">
|
|
685
746
|
|
|
747
|
+
A new tab can be created via:
|
|
748
|
+
|
|
749
|
+
tab = LibUI.new_tab
|
|
750
|
+
|
|
751
|
+
To populate the notebook-tab you can use .tab_append() such as
|
|
752
|
+
shown next:
|
|
753
|
+
|
|
754
|
+
hbox1 = LibUI.new_horizontal_box
|
|
755
|
+
hbox2 = LibUI.new_horizontal_box
|
|
756
|
+
LibUI.tab_append(tab, 'Page 1', hbox1)
|
|
757
|
+
LibUI.tab_append(tab, 'Page 2', hbox2)
|
|
758
|
+
LibUI.tab_append(tab, 'Page 3', UI.new_horizontal_box)
|
|
759
|
+
LibUI.box_append(inner2, tab, 1)
|
|
760
|
+
|
|
686
761
|
## Create a vertical box:
|
|
687
762
|
|
|
688
763
|
Use code like this:
|
|
@@ -696,8 +771,8 @@ If you use the libui_paradise gem, you can use this:
|
|
|
696
771
|
|
|
697
772
|
## Adding a horizontal separator or a vertical separator
|
|
698
773
|
|
|
699
|
-
The method
|
|
700
|
-
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>.
|
|
701
776
|
|
|
702
777
|
You can then add it via .add() or << if you use the libui_paradise
|
|
703
778
|
project. Alternatively you can use the toplevel method provided by
|
|
@@ -746,6 +821,10 @@ not necessarily recommending this be done, but **if** you ever have
|
|
|
746
821
|
such a use case then you can use it - which is another reason why
|
|
747
822
|
I added this screenshot, so that I don't forget. :)
|
|
748
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
|
+
|
|
749
828
|
## Padding elements in LibUI
|
|
750
829
|
|
|
751
830
|
The general API for setting padding to a container in LibUI
|
|
@@ -829,18 +908,38 @@ hand. Only the raw filename will be used, so if you
|
|
|
829
908
|
have a file at **/tmp/foo/bar.rb** then the title
|
|
830
909
|
of the window will be **bar.rb**.
|
|
831
910
|
|
|
832
|
-
##
|
|
911
|
+
## Entries in libui (libui-entry)
|
|
833
912
|
|
|
834
|
-
|
|
913
|
+
Let's first show how an <b>entry</b> in libui may look like:
|
|
835
914
|
|
|
836
915
|
<img src="https://raw.githubusercontent.com/parro-it/libui-node/master/docs/media/UiEntry.png" style="margin-left:1em">
|
|
837
916
|
|
|
838
|
-
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.
|
|
839
920
|
|
|
840
|
-
The upstream C code for libui-entry, for
|
|
921
|
+
The upstream C code for libui-entry, for <b>unix/</b>, can be seen here:
|
|
841
922
|
|
|
842
923
|
https://github.com/andlabs/libui/blob/master/unix/entry.c
|
|
843
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
|
+
|
|
930
|
+
In ruby, for the LibUI namespace, you can set text on an entry
|
|
931
|
+
by calling <b>LibUI.entry_set_text()</b>, such as shown in
|
|
932
|
+
the following example:
|
|
933
|
+
|
|
934
|
+
LibUI.entry_set_text(entry, 'Please enter your feelings')
|
|
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
|
+
|
|
844
943
|
## Borderless windows and fullscreen windows
|
|
845
944
|
|
|
846
945
|
A window that is **borderless: true** will not show any title or
|
|
@@ -850,18 +949,26 @@ To set the main window to full screen (occupy the whole monitor) do:
|
|
|
850
949
|
|
|
851
950
|
LibUI.window_set_fullscreen(main_window, 1)
|
|
852
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
|
+
|
|
853
960
|
## Spinbutton / Spinbox
|
|
854
961
|
|
|
855
962
|
You can use the following API for a spinbox:
|
|
856
963
|
|
|
857
|
-
|
|
964
|
+
LibUI.new_spinbox
|
|
858
965
|
|
|
859
966
|
To create a new spinbox.
|
|
860
967
|
|
|
861
968
|
To specify the **min** and **max** range, pass them as parameters
|
|
862
969
|
on creation-time:
|
|
863
970
|
|
|
864
|
-
|
|
971
|
+
LibUI.new_spinbox(0, 100)
|
|
865
972
|
|
|
866
973
|
If you use the extensions found in the libui_paradise gem then
|
|
867
974
|
you can do this instead:
|
|
@@ -881,9 +988,9 @@ to see how this works.
|
|
|
881
988
|
|
|
882
989
|
Relevant methods in regard to the spinbox in libui are as follows:
|
|
883
990
|
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
991
|
+
LibUI.spinbox_on_changed()
|
|
992
|
+
LibUI.spinbox_set_value()
|
|
993
|
+
LibUI.spinbox_value()
|
|
887
994
|
|
|
888
995
|
To **set** a value use either of the following two methods:
|
|
889
996
|
|
|
@@ -900,31 +1007,34 @@ A text-view widget shows content, such as the content of a local file.
|
|
|
900
1007
|
|
|
901
1008
|
In libui the general API for this is:
|
|
902
1009
|
|
|
903
|
-
|
|
1010
|
+
LibUI.new_multiline_entry # this is a textview
|
|
904
1011
|
|
|
905
1012
|
## Control Gallery
|
|
906
1013
|
|
|
907
|
-
Here is an image, from kotlin-libui
|
|
1014
|
+
Here is an image, from <b>kotlin-libui</b>, how this may look on windows:
|
|
908
1015
|
|
|
909
1016
|
<img src="https://raw.githubusercontent.com/msink/kotlin-libui/master/samples/controlgallery/controlgallery-windows7.png" style="margin-left: 2em">
|
|
910
1017
|
|
|
911
|
-
## LibUI.new_button() - how to work with buttons in LibUI
|
|
1018
|
+
## LibUI.new_button() - how to work with buttons in LibUI in general
|
|
912
1019
|
|
|
913
|
-
<b>LibUI.new_button</b> allows us to create a new button
|
|
1020
|
+
<b>LibUI.new_button</b> allows us to create a new button, via
|
|
1021
|
+
the LibUI gem maintained by kojix2.
|
|
914
1022
|
|
|
915
|
-
Examples:
|
|
1023
|
+
Examples for this, syntax-wise, follow:
|
|
916
1024
|
|
|
917
1025
|
button1 = LibUI.new_button('Text')
|
|
918
1026
|
button2 = LibUI.new_button('▶')
|
|
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.
|
|
919
1029
|
|
|
920
|
-
Now, we need to "tell" this button what to do when it is
|
|
921
|
-
|
|
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>.
|
|
922
1032
|
|
|
923
|
-
|
|
1033
|
+
Usage example:
|
|
924
1034
|
|
|
925
|
-
LibUI.button_on_clicked(button)
|
|
926
|
-
LibUI.msg_box(MAIN_WINDOW, 'Information', 'You clicked the button')
|
|
927
|
-
|
|
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
|
+
}
|
|
928
1038
|
|
|
929
1039
|
## Enabling / Disabling buttons in libui
|
|
930
1040
|
|
|
@@ -1070,17 +1180,6 @@ to be simpler for the time being. I may plan to change a lot more one day,
|
|
|
1070
1180
|
if I ever manage to find out how to simulate proper subclasses via
|
|
1071
1181
|
Fiddle::Pointer ... :)
|
|
1072
1182
|
|
|
1073
|
-
--------------------------------------------------------------------------------
|
|
1074
|
-
## SNIPPETS.md
|
|
1075
|
-
|
|
1076
|
-
Next, the content of the file called **SNIPPETS.md** will be shown. Note
|
|
1077
|
-
that this file will eventually be integreated into this file, and then
|
|
1078
|
-
subsequently removed one day.
|
|
1079
|
-
|
|
1080
|
-
EMBED_THIS_FILE /home/x/programming/ruby/src/libui_paradise/doc/SNIPPETS.md
|
|
1081
|
-
|
|
1082
|
-
--------------------------------------------------------------------------------
|
|
1083
|
-
|
|
1084
1183
|
## Advantages and Disadvantages of the libui project
|
|
1085
1184
|
|
|
1086
1185
|
It would be unfair to only selectively name advantages but not talk about
|
|
@@ -1088,29 +1187,31 @@ disadvantages, so this subsection will show some limitations, trade-offs,
|
|
|
1088
1187
|
constraints and opportunities. This is not complete, but it may become
|
|
1089
1188
|
somewhat more complete over time. Stay tuned.
|
|
1090
1189
|
|
|
1091
|
-
(a) Advantages:
|
|
1190
|
+
(a) Advantages of LibUI:
|
|
1092
1191
|
|
|
1093
|
-
- 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.
|
|
1094
1193
|
- Is super-simple to use compared to other toolkits, including ruby-gtk.
|
|
1095
|
-
- Super-simple to build up a prototype for a GUI, buttons that work,
|
|
1096
|
-
|
|
1097
|
-
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.
|
|
1098
1196
|
- Works cross-platform.
|
|
1099
1197
|
|
|
1100
|
-
(b) Disadvantage:
|
|
1198
|
+
(b) Disadvantage of LibUI:
|
|
1101
1199
|
|
|
1102
1200
|
- Limited ability to control the layout and size of widgets.
|
|
1103
|
-
- May look like utter crap ... :-)
|
|
1104
|
-
- 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.
|
|
1105
1204
|
- No way to use different fonts in the same application and choosing a font
|
|
1106
1205
|
is needlessly complicated. (This may not be completely correct, though -
|
|
1107
|
-
the glimmer-dsl-libui has
|
|
1206
|
+
the glimmer-dsl-libui has examples that seem to work. But if you ask me
|
|
1108
1207
|
right now in 2021 how this works via a standalone example then I can
|
|
1109
1208
|
happily tell you I have absolutely no idea. Which brings me to the
|
|
1110
|
-
next problem...)
|
|
1111
|
-
- 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 ...
|
|
1112
1213
|
|
|
1113
|
-
Some more disadvantages relate to Fiddle::Pointer
|
|
1214
|
+
Some more disadvantages relate to <b>Fiddle::Pointer</b>. You kind of need to
|
|
1114
1215
|
know C fairly well as well as the GC in ruby, in order to understand
|
|
1115
1216
|
what is going on. Since I don't, I hit a dead end, kind of.
|
|
1116
1217
|
|
|
@@ -1118,6 +1219,10 @@ This is so far in September 2021. Let's see what the future brings.
|
|
|
1118
1219
|
Perhaps other toolkits will learn from libui and implement the good
|
|
1119
1220
|
parts for **their own** widget set.
|
|
1120
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
|
+
|
|
1121
1226
|
## LibuiParadise.parse_this_config_file()
|
|
1122
1227
|
|
|
1123
1228
|
This method can be used to parse a .config file. This file should
|
|
@@ -1167,17 +1272,21 @@ You can also use something like '95%' as input. In that case the
|
|
|
1167
1272
|
desired value will be calculated depending on the max-resolution
|
|
1168
1273
|
of the current display. This presently only works on **linux**; if
|
|
1169
1274
|
someone knows how to make this work on windows and Mac OSX let
|
|
1170
|
-
me know. (On these systems
|
|
1171
|
-
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).
|
|
1172
1281
|
|
|
1173
1282
|
The following example shows how to use a percentage value:
|
|
1174
1283
|
|
|
1175
|
-
set_height('80%')
|
|
1284
|
+
set_height('80%') # 80% of the max-height.
|
|
1176
1285
|
|
|
1177
1286
|
## Coloured Text
|
|
1178
1287
|
|
|
1179
1288
|
At this point I only show how this may look on Win7, re-using
|
|
1180
|
-
the picture the
|
|
1289
|
+
the picture the <b>kotlin-libui developers</b> made available:
|
|
1181
1290
|
|
|
1182
1291
|
<img src="https://raw.githubusercontent.com/msink/kotlin-libui/master/samples/drawtext/drawtext-windows7.png" style="margin-left: 2em">
|
|
1183
1292
|
|
|
@@ -1289,9 +1398,9 @@ shows how this may look (on icewm):
|
|
|
1289
1398
|
The syntax goes something like this:
|
|
1290
1399
|
|
|
1291
1400
|
rb = ui_radio_buttons
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1401
|
+
LibUI.radio_buttons_append(rb, 'Radio Button 1')
|
|
1402
|
+
LibUI.radio_buttons_append(rb, 'Radio Button 2')
|
|
1403
|
+
LibUI.radio_buttons_append(rb, 'Radio Button 3')
|
|
1295
1404
|
outer_vbox.minimal(rb) # add the radio-button control to the box.
|
|
1296
1405
|
|
|
1297
1406
|
In other words: you instantiate a new rb-radio-button 'pointer';
|
|
@@ -1326,26 +1435,67 @@ For "raw" libui, use this:
|
|
|
1326
1435
|
|
|
1327
1436
|
## Tables in LibUI
|
|
1328
1437
|
|
|
1329
|
-
|
|
1438
|
+
The API for creating a new table in <b>LibUI</b> is this:
|
|
1330
1439
|
|
|
1331
1440
|
table = LibUI.new_table
|
|
1332
|
-
|
|
1333
|
-
|
|
1441
|
+
table = LibUI.new_table(table_model)
|
|
1442
|
+
|
|
1443
|
+
You need to use a model for the table, and pass it as
|
|
1444
|
+
its first argument. The next line of code shows how
|
|
1445
|
+
this is done:
|
|
1446
|
+
|
|
1447
|
+
model = LibUI.new_table_model(model_handler) # create the model here
|
|
1448
|
+
|
|
1449
|
+
Next you have to prevent segfaults by .malloc-ating the
|
|
1450
|
+
table params. This can be done in the following manner:
|
|
1334
1451
|
|
|
1335
1452
|
table_params = LibUI::FFI::TableParams.malloc
|
|
1336
1453
|
table_params = Fiddle::RUBY_FREE
|
|
1337
1454
|
table_params.Model = model
|
|
1338
1455
|
table_params.RowBackgroundColorModelColumn = -1
|
|
1339
|
-
table = LibUI.new_table(table_params)
|
|
1456
|
+
table = LibUI.new_table(table_params) # And pass it here.
|
|
1340
1457
|
|
|
1341
|
-
The table header is an array that contains the following attributes:
|
|
1458
|
+
The <b>table header</b> is an array that contains the following attributes:
|
|
1342
1459
|
|
|
1343
|
-
1. editable, bool type
|
|
1460
|
+
1. editable, bool type: determines whether column is editable
|
|
1344
1461
|
2. textColor
|
|
1345
1462
|
3. title
|
|
1346
1463
|
4. type, specify value of button, image, imgtext, progress, checkbox, checkboxtext, color, text
|
|
1347
1464
|
|
|
1348
|
-
|
|
1465
|
+
See the example distributed in this gem, in the file at
|
|
1466
|
+
<b>examples/simple/012_table_example.rb</b>.
|
|
1467
|
+
|
|
1468
|
+
This will yield the following result - at the least on Linux and IceWM:
|
|
1469
|
+
|
|
1470
|
+
<img src="https://i.imgur.com/Y7m58DH.png" style="margin: 1em">
|
|
1471
|
+
|
|
1472
|
+
You can append a new text column via:
|
|
1473
|
+
|
|
1474
|
+
::LibUI.table_append_text_column(table, 'Header goes in here', 0, -1)
|
|
1475
|
+
|
|
1476
|
+
As this is a bit cumbersome to type, libui_paradise simplifies this
|
|
1477
|
+
a tiny bit into:
|
|
1478
|
+
|
|
1479
|
+
table.append_text_column('Header goes in here', 0, -1)
|
|
1480
|
+
|
|
1481
|
+
Be careful to <b>only</b> append entries there if the underlying
|
|
1482
|
+
dataset - our Array - also contains these entries; otherwise the
|
|
1483
|
+
application would segfault. The example at
|
|
1484
|
+
<b>examples/complex/010_table_example.rb</b> shows this - look
|
|
1485
|
+
at the commented out example to test it.
|
|
1486
|
+
|
|
1487
|
+
In November 2023 the API was a bit simplified, towards this:
|
|
1488
|
+
|
|
1489
|
+
table.append_text_column('Header goes in here', 0)
|
|
1490
|
+
table.append_text_column('Another header goes in here', 1)
|
|
1491
|
+
table.append_text_column('And this is yet another header', 2)
|
|
1492
|
+
|
|
1493
|
+
So you can now omit the last -1 part. Expect more simplifications
|
|
1494
|
+
in the future - all that malloc stuff should be handled by
|
|
1495
|
+
libui_paradise, rather than in the downstream application
|
|
1496
|
+
code.
|
|
1497
|
+
|
|
1498
|
+
Note that this section is incomplete; it's a bit complicated.
|
|
1349
1499
|
|
|
1350
1500
|
In the end, this is possible though:
|
|
1351
1501
|
|
|
@@ -1424,7 +1574,7 @@ Available "**new**"-widgets in LibUI:
|
|
|
1424
1574
|
LibUI.new_table_value_color
|
|
1425
1575
|
LibUI.new_table_value_string
|
|
1426
1576
|
LibUI.new_time_picker
|
|
1427
|
-
LibUI.new_menu
|
|
1577
|
+
LibUI.new_menu # this is a menu, appearing on the upper area
|
|
1428
1578
|
LibUI.new_multiline_entry # this is a textview
|
|
1429
1579
|
LibUI.new_non_wrapping_multiline_entry
|
|
1430
1580
|
LibUI.new_open_type_features
|
|
@@ -1443,8 +1593,8 @@ Available "**new**"-widgets in LibUI:
|
|
|
1443
1593
|
LibUI.new_weight_attribute
|
|
1444
1594
|
LibUI.new_form # this is a form
|
|
1445
1595
|
LibUI.new_size_attribute
|
|
1446
|
-
LibUI.new_window
|
|
1447
|
-
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
|
|
1448
1598
|
|
|
1449
1599
|
## A search entry in LibUI
|
|
1450
1600
|
|
|
@@ -1471,9 +1621,23 @@ Example for this:
|
|
|
1471
1621
|
width = canvas.width
|
|
1472
1622
|
height = canvas.height
|
|
1473
1623
|
|
|
1474
|
-
##
|
|
1624
|
+
## How to to build a menu-interface (menu tag):
|
|
1625
|
+
|
|
1626
|
+
Building a menu in libui is possible by using the method
|
|
1627
|
+
<b>LibUI.new_menu()</b>.
|
|
1475
1628
|
|
|
1476
|
-
|
|
1629
|
+
A more complete example follows:
|
|
1630
|
+
|
|
1631
|
+
help_menu = LibUI.new_menu('Help')
|
|
1632
|
+
version_item = LibUI.menu_append_item(help_menu, 'Version')
|
|
1633
|
+
|
|
1634
|
+
On IceWM this may look like this:
|
|
1635
|
+
|
|
1636
|
+
<img src="https://i.imgur.com/1rWYcZM.png" style="margin: 1em">
|
|
1637
|
+
|
|
1638
|
+
## Creating a new drawing area in LibUI
|
|
1639
|
+
|
|
1640
|
+
The following code should suffice:
|
|
1477
1641
|
|
|
1478
1642
|
handler = LibUI::FFI::AreaHandler.malloc
|
|
1479
1643
|
handler.to_ptr.free = Fiddle::RUBY_FREE
|
|
@@ -1481,12 +1645,19 @@ This should suffice:
|
|
|
1481
1645
|
|
|
1482
1646
|
## Horizontal boxes
|
|
1483
1647
|
|
|
1484
|
-
A HBox represents a horizontal box
|
|
1485
|
-
|
|
1486
|
-
|
|
1648
|
+
A <b>HBox</b> represents a <b>horizontal box</b>.
|
|
1649
|
+
|
|
1650
|
+
In pure ruby-libui a new horizontal box (hbox) can be created via:
|
|
1651
|
+
|
|
1652
|
+
hbox = LibUI.new_horizontal_box
|
|
1653
|
+
|
|
1654
|
+
The API for putting something into a hbox goes as follows, such as
|
|
1655
|
+
when you wish to put a text-entry into the hbox:
|
|
1487
1656
|
|
|
1488
1657
|
LibUI.box_append(hbox1, text_entry, 1)
|
|
1489
1658
|
|
|
1659
|
+
If you use libui_paradise then you can also use << instead.
|
|
1660
|
+
|
|
1490
1661
|
## The slider widget
|
|
1491
1662
|
|
|
1492
1663
|
If you use the LibuiParadise gem then you can create and use a new slider
|
|
@@ -1499,12 +1670,25 @@ like this:
|
|
|
1499
1670
|
puts "New Slider value: #{UI.slider_value(ptr)}"
|
|
1500
1671
|
0
|
|
1501
1672
|
}
|
|
1502
|
-
|
|
1673
|
+
LibUI.slider_on_changed(slider, slider_changed_callback) # last element is nil, but it seems we can omit it
|
|
1503
1674
|
|
|
1504
1675
|
This may look like so on Linux:
|
|
1505
1676
|
|
|
1506
1677
|
<img src="https://i.imgur.com/GVKPMS7.png" style="margin-left: 3em">
|
|
1507
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
|
+
|
|
1508
1692
|
## Create a new tabbed notebook:
|
|
1509
1693
|
|
|
1510
1694
|
ui_tabs
|
|
@@ -1567,7 +1751,7 @@ For instance, the text-weight part accepts these values
|
|
|
1567
1751
|
maximum
|
|
1568
1752
|
# or any number between minimum and maximum
|
|
1569
1753
|
|
|
1570
|
-
To create an attributed String you can use the following API:
|
|
1754
|
+
To create an <b>attributed String</b> you can use the following API:
|
|
1571
1755
|
|
|
1572
1756
|
string = LibUI.new_attributed_string
|
|
1573
1757
|
attributes = LibUI.new_family_attribute("Courier New 30") # Specify a certain font.
|
|
@@ -1699,6 +1883,7 @@ may be helpful.
|
|
|
1699
1883
|
The API for creating a new grid in libui is quite complex and
|
|
1700
1884
|
hard to remember:
|
|
1701
1885
|
|
|
1886
|
+
# gtk-widget, left, top, xspan, yspan, hexpand, halign, vexpand, valign
|
|
1702
1887
|
LibUI.grid_append(grid, entry1, 0, 0, 2, 1, 0, 0, 1, 0)
|
|
1703
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
|
|
1704
1889
|
|
|
@@ -1729,10 +1914,12 @@ The documentation for Go has this signature:
|
|
|
1729
1914
|
|
|
1730
1915
|
Append adds the given control to the Grid, at the given coordinate.
|
|
1731
1916
|
|
|
1732
|
-
|
|
1733
|
-
into the grid, so the numbers that follow afterwards are the ones
|
|
1734
|
-
that are important.
|
|
1735
|
-
|
|
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:
|
|
1736
1923
|
|
|
1737
1924
|
# left, top, xspan, yspan, hexpand, halign, vexpand, valign
|
|
1738
1925
|
# 0, 0, 2, 1, 0, 0, 1, 0
|
|
@@ -1743,26 +1930,27 @@ expand horizontally or vertically. halign and valign, I think,
|
|
|
1743
1930
|
are used to align the grid-cell horizontally and vertically, so you
|
|
1744
1931
|
can position them exactly in the middle.
|
|
1745
1932
|
|
|
1746
|
-
Recently (August 2021) I discovered that you can actually
|
|
1747
|
-
a button-in-a-button. I don't know whether this is a bug or
|
|
1748
|
-
a feature, but it is hilarious.
|
|
1933
|
+
Recently (in <b>August 2021</b>) I discovered that you can actually
|
|
1934
|
+
put a button-in-a-button. I don't know whether this is a bug or
|
|
1935
|
+
a feature, but it is hilarious nonetheless.
|
|
1749
1936
|
|
|
1750
|
-
The 'raw' code I used for this was the following:
|
|
1937
|
+
The '<b>raw</b>' code I used for this was the following:
|
|
1751
1938
|
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1939
|
+
LibUI.grid_append(grid, UI.new_button('3'),0,1,1,1,1,1,1,1)
|
|
1940
|
+
LibUI.grid_append(grid, UI.new_button('4'),1,1,1,1,1,1,1,1)
|
|
1941
|
+
LibUI.grid_append(grid, UI.new_button('5'),0,1,1,1,1,0,1,0)
|
|
1942
|
+
LibUI.grid_append(grid, UI.new_button('6'),1,1,1,1,1,0,1,0)
|
|
1756
1943
|
|
|
1757
|
-
This led to the following
|
|
1944
|
+
This led to the following widget setup, as shown in this
|
|
1945
|
+
image:
|
|
1758
1946
|
|
|
1759
1947
|
<img src="https://i.imgur.com/6sWwWKh.png" style="margin-left: 1em">
|
|
1760
1948
|
|
|
1761
1949
|
The smaller buttons and the larger buttons can be clicked. They
|
|
1762
|
-
reside in the same grid-cell. I
|
|
1763
|
-
bug or a feature really, but this was quite hilarious to see.
|
|
1764
|
-
In the event that I may forget this, I'll keep this here as
|
|
1765
|
-
|
|
1950
|
+
reside in the same grid-cell. As stated I do not know whether this is
|
|
1951
|
+
a bug or a feature really, but this was quite hilarious to see.
|
|
1952
|
+
In the event that I may forget this, I'll keep this here as a
|
|
1953
|
+
<b>reference</b>.
|
|
1766
1954
|
|
|
1767
1955
|
If you want to pad the grid you can use the following method:
|
|
1768
1956
|
|
|
@@ -1800,12 +1988,13 @@ Usage example for the new API:
|
|
|
1800
1988
|
{ left: 2, top: 3, xspan: 3, yspan: 3, hexpand: 0, halign: 0, vexpand: 0, valign: 0 }
|
|
1801
1989
|
)
|
|
1802
1990
|
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
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).
|
|
1809
1998
|
|
|
1810
1999
|
These three methods are:
|
|
1811
2000
|
|
|
@@ -1897,9 +2086,10 @@ An entry can be <b>set read only</b> via:
|
|
|
1897
2086
|
|
|
1898
2087
|
entry.read_only # This has not been added into libui-paradise yet.
|
|
1899
2088
|
|
|
1900
|
-
To <b>respond</b> to <b>on-changed events</b>, you can use
|
|
2089
|
+
To <b>respond</b> to <b>on-changed events</b>, you can use the following
|
|
2090
|
+
toplevel API:
|
|
1901
2091
|
|
|
1902
|
-
|
|
2092
|
+
LibUI.entry_on_changed()
|
|
1903
2093
|
|
|
1904
2094
|
A more complete example of this:
|
|
1905
2095
|
|
|
@@ -1928,4 +2118,39 @@ following simplified method call instead:
|
|
|
1928
2118
|
puts 'The text is now: '+entry.text?
|
|
1929
2119
|
}
|
|
1930
2120
|
|
|
2121
|
+
## Using a pop-up message box in plain libui:
|
|
2122
|
+
|
|
2123
|
+
LibUI.msg_box(MAIN_WINDOW, 'Information', 'You clicked the button')
|
|
2124
|
+
LibUI.msg_box(main_window,
|
|
2125
|
+
'Tiny Midi Player',
|
|
2126
|
+
"Written in Ruby\n" \
|
|
2127
|
+
"https://github.com/kojix2/libui\n Version #{VERSION}"
|
|
2128
|
+
)
|
|
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
|
+
|
|
2138
|
+
## How to create an .exe file on Windows via libui
|
|
2139
|
+
|
|
2140
|
+
First check: https://github.com/larsch/ocra/
|
|
2141
|
+
|
|
2142
|
+
In order to build an .exe file with Ocra, include 3 DLLs from ruby_builtin_dlls
|
|
2143
|
+
folder:
|
|
2144
|
+
|
|
2145
|
+
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
|
|
2146
|
+
|
|
2147
|
+
Add additional options below if necessary.
|
|
2148
|
+
|
|
2149
|
+
--window
|
|
2150
|
+
--add-all-core
|
|
2151
|
+
--chdir-first
|
|
2152
|
+
--icon assets\app.ico
|
|
2153
|
+
--verbose
|
|
2154
|
+
--output out\gallery.exe
|
|
2155
|
+
|
|
1931
2156
|
ADD_CONTACT_INFORMATION
|