GtkTransparent
- From: Kouhei Sutou <kou cozmixng org>
- To: gtk-devel-list gnome org
- Subject: GtkTransparent
- Date: Tue, 11 Jul 2006 22:34:45 +0900 (JST)
Hi,
I wrote a widget GtkTransparent that makes your custom shape
widget easily. If you want to get an arc shape widget, you
can write the following:
static gboolean
expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
cairo_t *cr;
/* Normally:
cr = gdk_cairo_create (widget->window);
*/
cr = gtk_transparent_cairo_create (GTK_TRANSPARENT (widget));
cairo_set_source_rgba (cr, 1.0, 0.0, 0.0, 1.0);
cairo_move_to (cr, 0, 0);
cairo_arc (cr, 50, 50, 50, 0, 2 * M_PI);
cairo_fill (cr);
return FALSE;
}
= How to use?
You need a new cairo surface. The surface is
cairo-combined-surface. You can get by:
% cg-clone http://pub.cozmixng.org/~kou/git/cairo/.git
And you can install by the following commands:
% cd cairo
% ./autogen.sh --enable-combined
% make
% make install
Then you need to get GtkTransparent source by:
% svn co http://www.cozmixng.org/repos/c/libgtktransparent/trunk libgtktransparent
And you need to compile:
% cd libgtktransparent
% ./autogen.sh
% ./configure
% make
Now, you can try some samples:
% sample/simple # An arc shape widget
% sample/dnd # Three arc shape widgets that are DnD available
= Advantages over GnomeCanvas
* GtkTransparent handles signals same as other
widgets. GnomeCanvas widget handles all signal as one
"event" signal.
* GtkTransparent makes all shape what you want with
cairo. GnomeCanvas uses GnomeCanvas related
widget. cairo is used in normal widgets like
GtkDrawingArea. So learning cost of GtkTransparent is
lower than GnomeCanvas.
= Known problems
* GtkTransparent can't tell invalidated region to
GdkWindow well.
* cairo-combined-surface must have many bugs.
* ...
Regards,
--
kou
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]