For someone relatively new to GTK like myself, the thread of messages
from you, Richard Boaz, and Paul Davis was extremely eye-opening but also
confusing. I am grateful to hear the exchange of ideas, to the extent that
I understood it. The confusing part is simply trying to decide which of the
design principles makes sense for what I am trying to do now, but also
to extrapolate and understand what principles to follow in general when
up a new application. I am not fishing for answers here; this problem is

I do still have one question about a specific suggestion that you made in
this thread, below:

> -----Original Message-----
> From: jcupitt gmail com [mailto:jcupitt gmail com]
> Sent: Thursday, November 29, 2007 4:48 PM
>    -- snip --
> This is often not the case, especially in a complex application.
> Instead, you should think of your window as being composed from a
> number of separate layers (like photoshop layers), and that on an
> expose you should completely repaint that section of the window by
> drawing all layers from the back forwards.
>   -- snip --
> Assuming it's raster, you should have two separate data structures.
> Keep a large image around which has the current state of your user's
> image. Only drawing operations go into this, no rubberbanding. This is
> your background layer. Rubberband operations are in another layer
> which floats on top of this.

Do you mean a second pixmap? If so, how does one draw the second one on top
of the first without replacing pixels, assuming the GC function is just

> On an expose, use your background image to paint the exposed pixels.
> Then, if there's a rubber band active at the moment and if the
> bounding box of the rubber band intersects the expose, draw that as
> well on top of the image.

How does one draw layers "on top of" layers?  If I am understanding you
correctly, you are saying that I can use one bg pixmap to store one layer,
and another pixmap to store a second, higher layer. To be precise, suppose
that I have added the original scribble example, tools so that the user can
draw shapes in addition to the brush strokes. I keep the drawing the user
has created so far in a bg pixmap. Now the user wants to put a line on top
of that drawing, and I want to rubberband it. Are you saying that
(1) the rubberbanded line is drawn into a second pixmap that is drawn "on
top of"
    the other, and if so, how does one draw on top without obscuring the
    underneath using a straightforward GDK_COPY function in the gc, or
(2) do you mean that I should draw into the window, not a second pixmap,
    after I have drawn the bg pixmap underneath it?

I have tried drawing directly into the window for the rubberbanded line,
and sending an invalidate_rect event for that line to force a redraw of the
rectangle that includes it as I move the mouse, to make it "disappear",
but the result is that it disappears so fast that it is not visible.  Could
you clarify?


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