I’ve improved yesterday’s DimmedScreen hack-a-gadget. Following Jeff’s advice, I’ve optimised it to the point where it’s fast enough to be a useful class. It does have one problem that can only be overcome by clever GUI design, though - if gadgets beneath an instance of the DimmedScreen are animated, they will appear to freeze. This happens because the DimmedScreen is not animated, so doesn’t redraw every frame. You could make it redraw by registering it for VBLs, but then you’d be wasting all of your CPU time refreshing the entire framebuffer every frame.
Next up, I’ve created a “Requester” class. This is a compound gadget that inherits from the AmigaWindow and contains a listbox, an “OK” button and a “Cancel” button, and allows the user to choose from a set of options. When the user selects an option, either by double-clicking it or by clicking the “OK” button, the requester fires a “value changed” event and then closes itself. Clicking “cancel” just closes the window. An event handler that listens for the “value changed” event can, therefore, quite easily loop through the list of options and identify the selected ones.
Related to this, I’ve created a file requester using the same pattern. If you enable libfat support in your makefile and initialise it somewhere, you can drop the FileRequester files into your project (they’re in the “bonus” folder by default) and get an instant file requester. I’m surprised that it is fast, despite the very clunky string handling that it does presently to sort the file list (totally unoptimised sorted insert) and parse pathnames (even worse mix of a multitude of calls to strcmp(), strcat() and strlen()).
The file requester was one of my holy grails for this project, so I’m pleased that it’s working so well.