I've tackled this topic maybe a dozen of times, but each time I write a GUI library, at some point I look at it and see that it's badly designed (from a programmers point of view). I've looked through many other API's, studied the implementations, however, I keep designing little things wrong, and end up doing significant rewrites.
Are there any sites, articles or books about how to design a programmer API for a GUI library? Or maybe someone could share some tips from his experience?