First thing I did today was to support the moving of the selection by using the arrow keys. This was very easy, but I tried to replicate Photoshop's behavior as much as possible. This means that when the move tool is selected and the arrow keys are pressed, the whole selection (including it's contents) are offseted. When the marquee tool is selected and the selection isn't floated, only the selection shape is offseted.

There's a bunch of other little things I want to add, such as option dragging (if you have a selection, hold down the option key and move it around, a copy will be left behind at your starting point), x/y axis moving constraints when holding down the shift key, and support for moving around the selection shape with the marquee tool, but I think that I should do the additive/substractive selections first, since they're my main goal for the day.

Doing them shouldn't be that hard. I simply have to save the original selection shape, get the new one, and use either AddRgn or DiffRgn to perform the operations on them. There are little touches such as changing the cursor so that it has a little plus/minus sign, but those can come later.

(15 min later)

That was too easy. I even added the cursor changing. It turns out that it wasn't called AddRgn, it's UnionRgn, but that simply meant a look in the headers. I guess planning ahead takes the fun out of programming :p

Anyway, now I'll work on handling the constraints. This mean limiting the selection to a square when shift is held down, using the anchor point as the center of the selection instead of the corner when option is held down, and for the move tool constraining movement to the x or y axis when shift is held down. And adding option-dragging support too.

(later on)

That was more interesting, mostly because I underestimated what would be involved. Until now I didn't have to worry about the selections going outside the image, since my GetClickPosition function automatically contrained the returned coordinates to the bounding box of the current icon. However, when using the anchor point as the center of the selection, one can go outside the boundaries of the image, since one corner could be within and the rest outside. Clipping it isn't quite as easy as it sounds, since you cannot just cut off the outside portions. Rather you must restrict the expansion to the border, so that the selection is still symmetrical in relation to the center. Add this to the fact that the user can also be holding down shift at the same time (to restrict the selection to a square) and you get a big bunch of if statements. But now it's all done, except for the restriction to the x/y axis. But I think I'll work on the lasso next, since that was one of my original goals for today.

(even later on)

First I did the magic wand, since that seemed much easier than the lasso. And it was, it's simply a variation on the fill tool, instead of filling with a color a region which is a plain color, it just selects it. I even added additive/subtractive options for this too (just like Photoshop). But then I got bogged down when doing the lasso. I know the basic steps in which I want to do it. I should get the shape of the selection shape the user draws, get it's bounding rectangle, call CalcCMask to find out which areas the lasso can "tighten" on, and set that as the current selection. But I wasn't too sure how I wanted to get the selection shape. At first I tried to use a polygon. But apparently you cannot easily append a point to the polygon, and there is no function for converting it into a region. So then I tried to use regions. But again, you cannot simply append a point to a region. In the end I decided that I should use GWorlds. I would have something similar to the pencil tool (except that it would draw it at the magnified scale, so that the lasso lines don't come out 4-10 pixels thick). Then I can use BitMapToRegion to convert it to a region, and set that as the selection. But I'm rather sick of Icon Mangler today, so I'll work on that tomorrow. Once I get the lasso done, I think I'm done with selections. A few miscellaneous tools remain, like the text one, the rectangle/circle and the line one, but those shouldn't take more than a day to implement (all together). The next major step is to add drag and drop support. This is both inside the app (dragging from different sizes/depths/mask to icon) and from/to other applications (I've always liked applications which implemented drag and drop, especially with translucent dragging, so I don't have an excuse for not implementing them in my application). I downloaded the SDK from Apple, but it's not particularly new (I think it's from pre-System 7.5 days). There's a few technotes which cover the changes since, but there aren't any definitive resources. After I do that, I should add undo support, then theoretically I should be done (my god, the end is actually in sight :p).