2008-04-26

ListBox Rethink

Got the ListBox to scroll by just making it inherit from the ScrollingPanel and adjusting the canvas height every time a new list item is added. Easy! Except there’s a problem.

The ScrollingPanel only uses the DMA hardware to scroll portions of itself that aren’t overlapped by child gadgets. Child gadgets are responsible for redrawing themselves when the panel tells them to move. Scrolling children is just an illusion created by calling child->moveTo(newX, newY) whenever the canvas co-ordinates change. The problem is that redrawing all of the children every frame is a slow process. Works great on the Mac, but not so good on the DS.

I’m going to have to change the ListBox so that it doesn’t use child gadgets. Instead, I’ll need to draw each option manually (allowing the ScrollingPanel to use the DMA hardware when scrolling), work out where clicks are, etc. Tedious, but fortunately the clipping is all done for me.

Couple of other small changes. The SDL/Xcode project has a new icon:

Woopsi OSX Icon

Lastly, Gadget::redrawDirty(), which is called when a gadget higher in the z-order is erased, wasn’t clipping to parent gadgets. I hate having to monkey about in the clipping system, but that’s now fixed.