在GtkScrolledWindow或GtkEventBox上绘画 [英] Painting on GtkScrolledWindow or GtkEventBox
问题描述
使用GTK,我试图在包含在内的 GtkTextView
的角落覆盖一个更多提示符(但它也可以是任何绘图对象)一个 GtkScrolledWindow
。我在处理程序中为文本视图的 expose
信号绘制提示。它的工作原理,但是当我滚动窗口时,我得到了一些工件:提示随着文本视图的内容一起移动,而不是擦除。
为了摆脱我在每次滚动后触发重绘的工件。这大部分都能正常工作,但当您快速滚动时,仍然可以看到提示跳转。有什么办法可以防止这种情况发生?如果提示只是浮动在文本视图的顶部,那将会很不错。
我试图将滚动的窗口放在 GtkEventBox
$ 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屋!