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

Re: [pygame] Interface Surfaces



Does the original surface have alpha information?  Because if not, when it's converted to be blitted onto an alpha surface, it assumes all the Alphas are 0.

On 4/20/07, Kris Schnee <kschnee@xxxxxxxxxx> wrote:
I was thinking about UI code again the other day. In "Driftwood," the
interface stuff I did before, each widget (window, button etc.) has a
drawing surface and can contain other widgets. The "chief widget" calls
its subwidgets and they call theirs. No widget needs to know the
absolute screen position of its parent widget.

That's good, but having all these surfaces causes transparency problems.
If I remember correctly: If I want, say, a button with rounded edges
atop a window, then blitting the button -- originally a
transparent-background surface --  onto the window -- which is
translucent -- seems to give me black around the edges. The button is
drawn without transparency when it's drawn onto another surface with
alpha effects, in other words.

You can kind of see the problem in the upper-left corner of this
"Nutshell" screenshot: <http://kschnee.xepher.net/pics/070416island.jpg >
It doesn't use Driftwood, but it has the little UI box as a drawing
surface to which a rounded box, loaded from a file, is blitted. The
corners come out black instead of transparent.

The upshot: I'd like to clean up that UI code and make it easier to use.
What do you think of having each widget draw directly to the screen
instead of to the parent widget's surface? Sounds awkward, since they'd
need to know their absolute drawing location. Would it help to use the
Pygame "subsurface" code?

Oh, and "Pango" is fun to say. 8)

Kris