The
x::w::listlayoutmanager
:
does not manage discrete widgets, but a vertical list of text
labels in selection lists,
combo-boxes, and
menus.
The append_items
(), insert_items
(), replace_items
(), and replace_all_items
() items add new items to the list, combo-box, or a menu,
whatever the case may be. These methods receive
a std::vector
containing the new list items.
This vector contains
x::w::list_item_param
s.
x::w::list_item_param
is a (subclass-of a) std::variant
.
llmanager->append_items( { "Lorem", "Ipsum", x::w::separator{}, "Dolor sit amet" });
This is an example of passing a
std::vector<x::w::list_item_param>
to append_items
(), adding new items to the list.
The basic values of x::w::list_item_param
are:
A std::string
or a unicode
std::u32string
.
A constructed x::w::text_param
label, specifying custom fonts and colors, instead of the default
list font.
A x::w::separator
value visually draws
a separator value between groups of list items.
Other x::w::list_item_param
values
set additional properties related to the new list item. They all
appear before the list item's basic value. For example,
menu list items have an optional
keyboard shortcut.
This is done with a
x::w::shortcut
value that precedes the menu item's
x::w::text_param
All items in a selection list
get automatically numbered starting with 0, and get
automatically renumbered whenever list items get added or removed from
the list.
size
() returns the number of items in the list.
Each list item is specified by its item number,
when using
selected
(),
enabled
(), and other list methods.
A x::w::separator
is a discrete list item,
and merits an item number of its own, in that regard.
The above example creates items #0 through #3, if the selection list
was empty.
size
() will not immediately reflect the
new size of the list after calling append_items
(), insert_items
(), replace_items
(), replace_all_items
() and remove_item
().
The contents of the widget get updated by the
connection thread. These methods send a message to the connection
thread, which then makes the corresponding update.
A callback from the connection thread has access to the overloaded
IN_THREAD
methods, which immediately update the
list items.
The height of the selection list gets specified as the number of list rows. The actual height gets computed based on the height of the list's items. Using custom fonts and separators results in a selection list with rows of varying height.