libyui / libyui-ncurses

libyui-ncurses
http://doc.opensuse.org/projects/libyui
19 stars 18 forks source link

New ItemSelector widget for NCurses #81

Closed shundhammer closed 5 years ago

shundhammer commented 5 years ago

Trello

https://trello.com/c/7qI1AAvN/1300-5-libyui-1-of-n-selection-widget-ysingleitemselector-ymultiitemselector

Description

This implements the new ItemSelector widget for the NCurses UI.

Screenshots

nc-ItemSelector1

nc-SingleItemSelector2-icons

The @ and ^@ artifacts appear to be a constant thing on my machine with the NCurses UI; they were there before I even started working on this. To be clarified what that is all about.

Implementation Details

Large parts of this are a copy of the NCMultiSelectionBox widget.

That NCMultSelectionBox creates a scrollable NCTablePad (which inherits NCPad) with two columns: a NCTableTag for the [x] indicator which also holds a pointer to the corresponding YItem and a NCTableCol for the text.

This NCItemSelector also does that, but after that line for the item's label, it also adds a line for each line of the description text. Those lines have an empty NCTableCol for column 0 and another NCTableCol with one line of description text in column 1.

That of course means that the mapping of lines to the corresponding YItem is no longer so easy; the currentItem() method has to check if there is an NCTableTag in column 0, and only in that case fetch the YItem pointer (because all the description lines and also the separator line between the items don't have an NCTableTag in that column that would store that pointer.

Other Changes

Lots of nonsensical function parameters were changed to sensible types: It does not make any sense to pass const bool or const int as a parameter because C++ always passes parameters by value unless a non-const reference or a pointer is explicitly passed. const enum & also does not make any sense. But in other cases classes were passed directly as parameters; many of them are now passed as const reference for performance.