在GtkScrolledWindow或GtkEventBox上绘画 [英] Painting on GtkScrolledWindow or GtkEventBox

查看:142
本文介绍了在GtkScrolledWindow或GtkEventBox上绘画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用GTK,我试图在包含在内的 GtkTextView 的角落覆盖一个更多提示符(但它也可以是任何绘图对象)一个 GtkScrolledWindow 。我在处理程序中为文本视图的 expose 信号绘制提示。它的工作原理,但是当我滚动窗口时,我得到了一些工件:提示随着文本视图的内容一起移动,而不是擦除。



为了摆脱我在每次滚动后触发重绘的工件。这大部分都能正常工作,但当您快速滚动时,仍然可以看到提示跳转。有什么办法可以防止这种情况发生?如果提示只是浮动在文本视图的顶部,那将会很不错。



我试图将滚动的窗口放在 GtkEventBox

code>并在其上绘制提示,但这也不起作用;即使您将事件框的窗口设置为在其子窗口前面,滚动条和文本视图也始终绘制在提示上。


$ b

UPDATE



如果我将 GtkEventBox 的揭露回调与 g_signal_connect_after() code>,然后在 GtkScrolledWindow GtkTextView 的揭示回调之后调用它。文本视图仍然绘制了事件框。我认为这是因为滚动是异步发生的。任何人都知道如何防止我的图纸被覆盖?

其他更新



因此,我猜想我实际需要的是在异步滚动完成时连接的信号。如果我能找到它的时间,那么我可以在 GtkEventBox 上触发另一个揭发事件。如何在滚动完成后得到通知?

解决方案

使用提示的弹出窗口。这应该避免滚动工件的所有问题。

Using GTK, I'm trying to overlay a "More" prompt (but it could just as well be any drawing object) in the corner of a GtkTextView contained within a GtkScrolledWindow. I draw the prompt in the handler for the expose signal of the text view. It works, but when I scroll the window I get artifacts: the prompt is moved along with the contents of the text view and not erased.

In order to get rid of the artifacts I trigger a redraw after each scroll. This mostly works, but you can still see the prompt jumping up and down when you scroll quickly. Is there any way to prevent this? It would be nice if the prompt just "floated" on top of the text view.

I tried enclosing the scrolled window in a GtkEventBox and painting the prompt on top of that, but that didn't work either; the scrollbars and text view always paint over the prompt, even when you set the event box's window to go in front of its children's windows.

UPDATE

If I connect the GtkEventBox's expose callback with g_signal_connect_after(), then it is called after the expose callbacks of the GtkScrolledWindow and GtkTextView. The text view still draws over the event box though. I think this is because the scrolling happens asynchronously. Anybody got any idea how I can prevent my drawing from being overwritten?

ANOTHER UPDATE

So I guess what I actually need is a signal to connect to when the asynchronous scrolling has completed. If I can find out when that is, then I can trigger another expose event on the GtkEventBox. How can I get a notification when the scrolling has completed?

解决方案

Use a popup window for the prompt. This should avoid all problems with scrolling artifacts.

这篇关于在GtkScrolledWindow或GtkEventBox上绘画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆