我如何使用GTK中的其他窗口部件渲染具有透明背景的文本? [英] How can I render Text with transparent background over other widgets in GTK?

查看:146
本文介绍了我如何使用GTK中的其他窗口部件渲染具有透明背景的文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望使用透明/半透明背景(或无背景)渲染文本,而不是其他gtk小部件(如GtkImage或GtkButton等)。
主要目标是使文本显示在背景中的Gtk Widgets(尤其是GtkImage)上。
我可以使用pangocairo库在GtkFrame上呈现文本,但我无法摆脱GtkFrame的背景。

I wish to render text with transparent/translucent background (or no background) over other gtk widgets like GtkImage or GtkButton etc. Primary goal is to have text display over Gtk Widgets (esp. GtkImage) in the background. I can render text on GtkFrame using pangocairo library but I am not able to get rid of the background of GtkFrame.

我已经看到了使GtkWindow透明或半透明的,但我希望有GtkLayout用于放置GtkWidgets的不透明GtkWindow,然后将GtkImage放置在布局上,并在GtkImage顶部呈现文本,以便为我的文本提供良好背景。

I have seen examples of making GtkWindow transparent or translucent but I wish to have opaque GtkWindow with GtkLayout for placing the GtkWidgets, then place GtkImage over the layout and render Text on top of GtkImage so that it gives a nice background to my text.

我也尝试过使用GtkDrawingArea,但后来我在创建
pixbuf的cairo上下文并渲染文本时迷失了方向。任何帮助表示赞赏。

I also tried using GtkDrawingArea, but then I get lost in creating the cairo context of the pixbuf and rendering text over that. Any help is appreciated.

注意:我正在使用Compiz进行窗口合成。

Note: I am using Compiz for compositing windows.

推荐答案

您可以使用GtkOverlay部件(至少是Gtk + 3.2)来完成它。

You can do it with GtkOverlay widget (Gtk+ 3.2 at least)


GtkOverlay - 一个将小部件叠加在一起的容器

GtkOverlay — A container which overlays widgets on top of each other

http ://developer.gnome.org/gtk3/stable/GtkOverlay.html

这篇关于我如何使用GTK中的其他窗口部件渲染具有透明背景的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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