The undo states take up a lot of memory (17K each when editing 32x32 32 bit icons). I realized that a selection GWorld is unecessary if there is no current selection (actually it's not even necessary then if the selection isn't floated) so that cuts down the size to 7K in those cases. The reason why the state takes up 7K, instead of the 4K that a 32x32 32 bit pixmap takes up is because QuickDraw has this annoying habit of adding 16 pixels to each row as padding (don't know why). If I can find a way to eliminate that I'll save even more space. I don't know what to do when the memory fills up however (I haven't even added any checks). I can warn the user that the memory is full, and start deleting the earliest states, which are unlikely to be used anyway. Or I could limit the number of undo steps from the beginning, perhaps by having a setting in the preferences. But that will limit some of the usefullness of the linked list, and the user isn't likely to want to go in change it.
This reminds me that I must start adding error checks, since my program currently relies on the fact that all resource are available, and there is free memory (there aren't any potentially negative user actions that I need to worry about, since this is a GUI-based program). I guess this is just one more step in the things I must do in the coming month.
I think I'll have to spin off my todo list as a separate file, and use it to keep track of what I need to work on. This wasn't necessary before, since I just had to work on any one of the main features, and I could be sure that I was moving ahead. I'll copy any new entries and status updates into here, but I'll use that file to be able to tell at a glance what I'm supposed to be doing.
Today I worked on improving the undo support, and started to work on the preview. One of the probles that I had was that when dragging from one icon to another, the undo wouldn't work. This was because I wasn't storing the initial state of the icon I was dragging to (since it wasn't the current icon, and thus it didn't get saved as the drawing went along). I also had a problem with the selections not getting erased after I undid one. It turned out that in my DoIdle i was doing a status -= needsUpdate even if the needsUpdate bit wasn't on (updates can also be executed if there is a selection) therefore the status variable was getting smaller and smaller (so instead of doing a status -= needsUpdate I changed it to status &= ~needsUpdate, which should set the bit off it it was on, and leave it off if it was already off).
I also worked on adding the preview today. The preview combines the currently display icons and masks, and displays the merged result in an image well with the desktop as the background. This works well, except if there is a floating selection it is not displayed.
Found another bug in the undo routines. When I create an icon, I save the current state. However, when opening the file, the first state isn't a blank canvas, but the initial contents of the icon. There's two ways in which I can fix this. I can rewrite part of the file loading routines, so that the icon is loaded before the state is saved. Or I could add a couple of lines to the loading function to delete the current state and resave it. Right now I'll choose the latter, since I don't see what can be gained by choosing the former.
Fixed a bug in the file handling routines that would cause no files to show up in the file selection dialog if the older style open/save dialogs were used. I took this opportunity to add the proper flags so that invisible files would show up in the dialogs (this way folder icons can be edited too).
I've made two interface prototypes for the planned Icon Browser, which will show up when a file that has more than one icon is opened. I'm using REALBasic for the prototyping, since it has a nice WYSIWYG window/control editor, thus it's very easy to do layouts. Then I took a screenshot of the windows, imported them into Photoshop and added the icon previews, as a mockup of what the final version will look like. I uploaded both copies to a hotline server I go to often, and requested feedback (as to which one was better).
Added items to TODO file:
- GWorld updates: Draw to an external GWorld first, and then copy to the window, so that there will be no flickering when updating (this applies to the icon and mask display, as well as the preview)