Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GTK: Infinite lazy list of widgets

Tags:

c

gtk

vala

I need to display a virtually infinite scrollabe list of interactive widgets and add/remove them as necessary when new data is added or the user scrolls into an uncached area.

A TreeView (as asked about here) is no option, because, I need full Widgets as items (composed of standard widgets with multiple actions etc, but CellRenderer isn't for this)

Worse, I don't know my widgets' height in advance (not much variance though), so using a VBox might cause jumpiness.

Using the scrollbar should still feel as if the list was finite (i.e. updated only after scrolling has finished so the scrollbutton doesn't jump away from your mouse), and when resizing the window and the layout of the windows is updated, the scroll position shouldn't change too much (the focused widget should stay where it is, unless of course the focused widget was scrolled away…).

What's the best way to do this? Maybe even a library that just sends me signals when a new widget needs to be added?

Or could the ListView be coerced to do this in a not-too-nasty way? (i.e. draw on an offscreen buffer, copy that into the cell using CellRenderer, relay mouse/keyboard events to the actual widget?)

like image 348
pascal Avatar asked Jan 28 '12 02:01

pascal


1 Answers

If it is a infinity list, then you should not try to achieve anything with a scrollbar - this is only meant for finite lists.

My suggestion is to use an overlay with 2 buttons

+------------+
| UP ARROW   |
+------------+
| ITEM  N    |
| ITEM  N+1  |
| ITEM  N+2  |
+------------+
| DOWN ARROW |
+------------+

For the list between the buttons, you will probably have to implement a custom container widget yourself. I suggest to buffer n (>=2) widgets/items in each direction in advance.

Not really related to custom containers, but custom widgets - a starting point

http://zetcode.com/tutorials/cairographicstutorial/customgtkwidget/

http://gnomejournal.org/article/34/writing-a-widget-using-cairo-and-gtk28

http://old.nabble.com/Custom-container-%2B-Child-type-with-interface-td26863728.html

like image 74
drahnr Avatar answered Oct 20 '22 05:10

drahnr