More efficient drawing question



Hello,

My application (a sound editor) draws sound waveforms onto a GtkDrawingArea.
The GtkDrawingArea is in the upper part of a two-row GtkVBox. The lower part
of that GtkVBox contains a GtkHScrollbar.

The drawing strategy is very simple. Whenever I get an expose event on the
GtkDrawingArea, I draw the waveforms onto a pixmap, then copy that pixmap
onto the GtkDrawingArea. There is a signal handler for the GtkHScrollbar's
"value-changed" signal which calls gtk_widget_queue_draw() for the
GtkDrawingArea.

The problem is that gtk_widget_queue_draw() causes the entire widget to be
repainted, which can be very expensive. Especially for an operation such as
scrolling it does not make sense to recalculate data that is already on the
screen.

I don't know GTK that well so I'd like to ask you what would be the best way
to solve this. Should I keep track of the previous scrollbar value and use
it to generate the proper expose-event rectangles (and, um, more or less how
would be the best way to do that...) or would it be better to use some more
high-level way, maybe using GtkLayout or GnomeCanvas (I can't figure how, it
seems to me that their child widgets would need to become way too big to
hold a sound waveform)?

Thanks,



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