Re: GtkTransparent



On Ter, 2006-07-11 at 22:34 +0900, Kouhei Sutou wrote:
> 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.
>   * ...

  Can you stack GtkTransparent widgets?  If so, does it have the
expected result with translucency?  If so, does it work correctly even
with non-composite aware X servers (most of them so far)?  What about
performance; does each widget require a separate X11 window?  If so,
dynamically creating 100 widgets will have much higher impact than
creating a 100 canvas items all sharing the same cairo context and
surface...

  And I'm not convinced that writing a gtk+ widget from scratch is
easier than writing a canvas item...

  Regards,

-- 
Gustavo J. A. M. Carneiro
<gjc inescporto pt> <gustavo users sourceforge net>
The universe is always one step beyond logic.

Attachment: smime.p7s
Description: S/MIME cryptographic signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]