Much to my horror, I discovered that Tux Paint has
distinct near-duplicated code for handling various
mouse-related options. This leads to lots of trouble.

For example, when the variable-size erasers were
added, somebody forgot to update the code that
changes the mouse cursor. This means that the
cursor does not respond to the difference between
active buttons (valid erasers) and inactive ones.

Another example: I fixed scrolling of tool options
when using the purple buttons. The display does not
scroll too far anymore. I missed the existance of
separate mouse wheel code, so that didn't get fixed.
I see a lot of code duplication there.

So, what should the fix be?

Here's one idea: do all the mouse cursor updates via
an SDL_Surface where each pixel is abused for the
storage of a mouse cursor index. When drawing buttons
or whatever, also draw to this surface. When the mouse
moves, simply examine the "color" of this surface to
determine the proper mouse pointer.

For the scrolling, have a global function pointer that
gets called. Both the scroll wheel and the purple
buttons call the same code. The function pointer can
change as needed to allow scrolling of other things.

Here's another idea: create a real widget set, like a
sort of cut-down GTK. Widgets get passed events, and
may pass events on to child widgets, etc.


_______________________________________________
Tuxpaint-dev mailing list
Tuxpaint-dev@tux4kids.net
http://tux4kids.net/mailman/listinfo/tuxpaint-dev

Reply via email to