On 9/30/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > On 9/30/07, Keith Feesh <[EMAIL PROTECTED]> wrote: > > The way that I do things now includes redrawing the entire canvas every time > > the mouse is moved, in order to clear the old > > outline's drawing, and then to redraw the outline once again. This brings my > > system to it's knees and I figure there must be > > a better method, just I can't think of any method. Any hints would be great. > > The animation is done with gtk_widget_queue_draw_area().
I was thinking about this again, and it seems to me that there are two separate problems. How to quickly draw a brush outline (XOR lines or repaint areas of your window) and how best to do rubberbanding in GTK (drawing tracks mouse movement). (2) is actually the more difficult part, IMO. GTK only really supports drawing in the expose handler. You can draw elsewhere (eg. in the mouse movement handler) but it may not be portable to non-X11 backends, it's very hard to control multiple drawing events that happen together, you lose all of GTK's nice framework for doublebuffering and for event compression, and you lose the decoupling between input and output that will make you app work well under load. So ... I would very strongly urge a solution like this: 1) make your expose handler work well for small repaints (ie. don't redraw the whole view on every expose). For a vector drawing application you might need some fancy datastructure for efficient culling. Take a look at gdk_region_get_rectangles() too, if you want to get finer-grained expose events 2) put the rubberband (or brush outline) position and size into your model and draw it as part of your expose handler 3) in the mouse motion handler, queue a redraw for the current position of the outline, update the model to the new position, queue a draw there as well 4) use mouse motion compression to make sure you don't get lag when your machine is running slowly John _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list