Monday, May 21, 2007

Contain the container

I have been wrestling with using draw2d for over a month now (OK, having a vacation in between, but anyway), especially with hierarchic containers. I wanted to make it easy to create a small "group" of things, say; a label, a textfield and an image, and then drop the whole things inside a larger container which has lots of other form elements in it, and most importantly to resize and position the "group" inside the larger container in a simple way.

After losing my mind the third time I finally registered with the forum and wrote a short plea for help. I didn't expect much, after all draw2d is a on-person project (as are all other projects, for that matter), but the next day Andreas Herz had written a fix for hierarchical components just like that. And it worked and it was beautiful. I really hope he puts up the paypal donation button somewhere on his site, so I can thank him properly.

The only downside was that draw2d uses a separate hierarchy beside the actual DOM, so that all 'figures' sit flat beside each other, and move by draw2d logic depending on how draw2d thinks which one is inside the other. I have now learned to live with this, and written some extra logic to handle this, especially for the GenericForm blueprint.

So after some fairly minor amount of hacking I was able to get back to where I was a month ago, but now with a workable and intuitive GUI, with a toolbar and everything.

Next steps are to finally finish the load/save page stuff, so that the created pages can be serialized. And after that comes the holy grail of export as CMS module, with joomla and MAJ as the first CMS targets.

No comments: