Thursday, October 14, 2004

Simplicity is king

After having done some more thought on the GUI subject, I've come up with a minimalistic design for the GUI system. I asked myself the following question: "What is the simplest possible design for a GUI system that
  1. Given a coordinate (x,y) returns the widget on that window location
  2. Given a rectangle, draws the widgets intersecting it"

.. and of course both operations should be fast, at least faster than O(n) in the number of widgets. (of course impossible for 2. given the whole window but that is hopefully not the case in many more instances than program boot).

I choose the following two basic classes:

Code snippet

The key idea I got was that any event handling could be completely managed by the application developer -- no handleMouseDown etc. etc. here! Since this is also very application specific, it feels nice to remove it from this somewhat more general code.

Til next time,

/Olof


0 Comments:

Post a Comment

<< Home