Long label scrolling mode for the widget `lv_roller`

Long label scrolling mode for the widget lv_roller.
Many times a longer text then the width of the roller is loaded, such as a file name list for file selection. Making it difficult to select the correct file. The font size reduction works to a certain extent where it becomes difficult to read on smaller screens.

I know there are other ways to implement this, but it would be convenient to have this feature when a nice roller is intended to be used.

3 Likes

Im sitting here with the same problem. Did you figure out a solution to this?

Unfortunately it’s not possible with lv_roller as it has only a single multi-line label and it’s not possible to scroll the lines a label individually. To support this feature we need to add a separate option for each option. But probably it’d be a new widget.

@liamHowatt maybe we could use your infinite loop example as a starting point and just create a custom roller instead of a new widget.

As a suggested solution…

The roller widget should be set up so that it uses lv_label widgets. One widget for each visible item in the roller. The key word there is visible plus an extra 2 to “pre load” the text and are initially hidden. The label widgets get recycled as the roller widget gets “rolled” when a item is no longer in the visible area it gets set with the flag to hide it and it gets moved to the other side of the roller and filled with the item that is next to show on that side of the roller.

This kind of a solution is the better thing to do… why? Virtual items is why. Add new events that occur when an item goes in and out of the visual area. the label widget gets passed to that event and the label widget would also get passed when an event occurs for an item getting clicked on. This gives the user the ability to change the items seen in the widget at the time they are going to become seen. They don’t need to preload what could end up taking up a very large amount of memory. Use case… File names. having to enumerate an entire directories worth of files and concatenating the names of the file to a single char array to pass to the roller widget…That can use a large amount of memory depending on the number of files.

Don’t use a label widget. Instead simply use an empty lv_obj_t and now the user can fill the items with whatever they want… text, widgets, buttons, images… or any combination of those things. It makes the widget more memory efficient and it would add bucket loads of flexibility to it.

The trick is having an event for then an item needs to be loaded and an event for when an item is able to be removed and passing said item to the event callback.

Sounds interesting but we needed to reimplement scrolling for this. :frowning:

how come?

You should be able to control the showing and hiding of the “Item” widgets and generate events internally from the roller widget. The roller widget would simply react to scroll events in order to set the item widgets position and generate it’s own events.