Re: Background color problem



On Mon, 2009-03-16 at 23:28 +0300, Vlad Volodin wrote:

first of all, you really want to use the clutter list.

I'm using libclutter-gtk (with GtkClutterEmbed widget), where I want
to display some graphics. If somebody doesn't know it, I'll describe
it a bit. It is derived from GtkWidget. Then it uses it's own canvas.
The canvas is white, and it doesn't have some kind of transparency.

So, as I thought, I decided to fill it's background with color, got
from it's GtkStyle. After some experiments I realized, that widgets
(main window, container and GtkClutterEmbed) don't have needed color:

Containers in GTK+ do not usually have a background: they are assumed to
be transparent transparent. GtkWindow does have a background color,
though, since it'll have to provide the background for most widgets.

to set the color of the Stage embedded inside GtkClutterEmbed you can
get a specific color out of the GtkWindow style; you cannot do this at
any time you like: you'll have to connect to the style-set signal of the
GtkWindow that contains the GtkClutterEmbed-- at which point you have a
guarantee that a GtkStyle has been applied to the widget.

also, you have to remember that GdkColor and ClutterColor are not
compatible structures: you have to convert between the two.

  GdkColor gdk_color = { 0, };
  ClutterColor clutter_color = { 0, };

  gdk_color = widget->style->bg[GTK_STATE_NORMAL];

  clutter_color.red   = CLAMP (((gdk_color.red   / 65535.0) * 255), 0, 255);
  clutter_color.green = CLAMP (((gdk_color.green / 65535.0) * 255), 0, 255);
  clutter_color.blue  = CLAMP (((gdk_color.blue  / 65535.0) * 255), 0, 255);
  clutter_color.alpha = 255;

ciao,
 Emmanuele.

-- 
Emmanuele Bassi,
W: http://www.emmanuelebassi.net
B: http://log.emmanuelebassi.net




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