GTK:小部件的无限惰性列表

发布于 2024-12-29 08:08:38 字数 553 浏览 2 评论 0原文

我需要显示几乎无限滚动的交互式小部件列表,并在添加新数据或用户滚动到未缓存区域时根据需要添加/删除它们。

TreeView(如此处询问)是没有选择的,因为,我需要完整的小部件作为项目(由具有多个操作等的标准小部件组成,但 CellRenderer 不适用于此)

更糟糕的是,我事先不知道我的小部件的高度(尽管差异不大),因此使用 VBox 可能会导致跳跃性。

使用滚动条仍然应该感觉列表是有限的(即仅在滚动完成后更新,因此滚动按钮不会跳离鼠标),并且当调整窗口大小和更新窗口布局时,滚动位置不应该改变太多(聚焦的小部件应该保持在原来的位置,除非聚焦的小部件被滚动走了……)。

最好的方法是什么?也许甚至是一个在需要添加新小部件时只向我发送信号的库?

或者是否可以强制 ListView 以不太令人讨厌的方式执行此操作? (即在屏幕外缓冲区上绘制,使用 CellRenderer 将其复制到单元格中,将鼠标/键盘事件中继到实际的小部件?)

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?)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

○愚か者の日 2025-01-05 08:08:38

如果它是无限列表,那么您不应该尝试使用滚动条实现任何目标 - 这仅适用于有限列表。

我的建议是使用带有 2 个按钮的覆盖层

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

对于按钮之间的列表,您可能必须自己实现一个自定义容器小部件。
我建议提前在每个方向缓冲 n (>=2) 个小部件/项目。

与自定义容器并不真正相关,而是自定义小部件 - 一个起点

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

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

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文