Re: Background color problem



Sorry, for being a bit stupid and persistent
I appreciate your help, but I've also faced with structures:

When I changed a bit your example (I used 1 instead of 0)
    ClutterColor clutter_background_color = { 1, };

    g_debug("Colors: %x %x %x %x", clutter_background_color.red,
            clutter_background_color.blue,
            clutter_background_color.green,
            clutter_background_color.alpha);

I didn't get an expected result {1, 1, 1, 1}, I got {1, 0, 0, 0}:
DEBUG: Colors: 1 0 0 0

Is the example { num, } suitable only for {0,}? Or it makes the first
field equal to num.
The others attempts such as {1, 2,}; make the first and the second
field equal to 1 and 2, the third and so on are zero.

Thank you
Vlad Volodin


2009/3/17 Emmanuele Bassi <ebassi gmail com>:
On Tue, 2009-03-17 at 07:41 +0300, Vlad Volodin wrote:

Sorry, I've asked this question, but I can't find any explanation:
ÂGdkColor gdk_color = { 0, };
ÂClutterColor clutter_color = { 0, };
They are structures, why do you use commas before the last brackets?

because it will initialize all the members of a struct to 0. it's
equivalent to:

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

or to:

ÂGdkColor gdk_color;
ÂClutterColor clutter_color;

Âmemset (&gdk_color, 0, sizeof (GdkColor));
Âmemset (&clutter_color, 0, sizeof (ClutterColor));

or, in C99:

ÂGdkColor gdk_color = {
 Â.pixel = 0,
 Â.red = 0,
 Â.green = 0,
 Â.blue = 0
Â};
ÂClutterColor clutter_color = {
 Â.red = 0,
 Â.green = 0,
 Â.blue = 0,
 Â.alpha = 0
Â};

I've found C99 standard, where the same rule is applied to enum type
too.

it doesn't have anything to do with enumerations -- enumerations will
use the number to set their value explicitly, and it's something coming
from ANSI C, way before C99.

ciao,
ÂEmmanuele.

Best wishes,
Vlad Volodin

2009/3/17 Emmanuele Bassi <ebassi gmail com>:
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

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

--
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]