Re: ideas on how to use overlays with GTK/GDK ?




Paul Barton-Davis <pbd@Op.Net> writes:

> Adrian Nye's Xlib book has a nice explanation on the use of
> XAllocColorCells() to do non-destructive overlays. I notice that gdk
> has a function which calls this (gdk_colors_alloc()), but I'm having a
> hard time convincing myself that I understand how to use the GDK color
> allocation/use interface to do the same thing as Nye's example.

My advice (being helpful again ;-) forget XAllocColorCells.

 - You can only do it on pseudo-color displays. Nobody in
   there right mind runs pseudo-color on the PC hardware
   being sold today. (OK, it works for direct-color and
   GrayScale visuals as well - even more rare)

 - Most people running pseudocolor aren't going to have enough
   free colors left in the right places in the colormap
   for XAllocColorCells to be effective. So you are going
   to have to use a private color map.

 - People with pseudo-color displays have few enough colors
   left before using planes for overlays.
 
Yes, there is some old workstation hardware where these
arguments don't hold as much weight. If 1% of your
users have such hardware, you're lucky.

gdk_colors_alloc() is basically a deprecated API. The
newer, better way is gdk_colormap_alloc_colors(), which
simply doesn't provide any way of doing cells at
all. I made the decision that hardware is moving to fast true-color
displays, and colormap tricks are a best left to nostalgic
reminiscence.

> Could anyone point me to some source (maybe in the gimp ?) that does
> this, so I can take a look ? I have my stuff working with XOR, but I
> think that overlays would be a lot more useful for lots of reasons.

Well, the only thing I can think of which allocates writeable
is the GIMP. I think it uses them for the colors in the
two color squares at the bottom of the toolbox, and for the
crawling anys under some circumstances.
 
> Oh, and Owen, the reason that Gnome_Canvas isn't the right thing is
> that I'm actively redrawing the overlays as I move a mouse. I don't
> get the impression that the GnomeCanvas model is really designed with
> this in mind.

Actually, it is. Try out the gnome-canvas demo in gnome-libs.
Hardware is a _lot_ faster than when Nye wrote that book.

Regards,
                                        Owen



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