RE: GTK scribble example




I'm making a small drawing program with GTK, and I'm having an
issue that's also in the "scribble" example tutorial (using this as
an example because people would likely know what I'm talking about
that way). Anyways, the issue that I'm having is that the program
doesn't receive mouse movement events for every pixel that the
mouse moves, especially when the mouse moves fast.  So my question
is, how do I make it receive more mouse movement events, even when
the mouse is moving fast, or how can I get around such problems in
a way that's smooth unlike just making lines to the last known
location of the mouse.

Is the problem simply the turn-around time between mouse movements and drawing to the window?

It may help if instead of drawing to the screen, you instead store all the mouse movements into a list (just 
the bits you actually need from the mouse event).  A nice quick routine that stores the movements and gets 
out ready for the next one.  You can also try to use allocation pools to avoid unnecessary memory allocations.

Actually drawing stuff would then be handled by an idle timer, lauched from the mouse down event (which, by 
the way, is a pretty good place to prepare for any undo actions).  Though you could check  The idle handler 
checks the list for items, and does those line things you mentioned.

You'll still get lines if you move the mouse really fast, but then who can move the mouse quickly and still 
land exactly where they want to anyhow?  (If you're REALLY worried, you could probably draw a bezier or a 
bspline or whatever they're called, instead of straight lines. ;) )  You'll also find that the drawing lags 
behind the mouse movements a little, but that shouldn't be a problem (I think Gimp does that too, from 
memory).


Perhaps that may help some...?


Fredderic

_______________________________________________
Join Excite! - http://www.excite.com
The most personalized portal on the Web!





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