I Drag You, You Drop Me #

Today I worked on the dragging half of drag and drop. This turned out to be much easier, since it doesn't require installing and handler procedures. You simply create a new DragReference, attach data of a certain flavor to it, give it a shape (so that it can draw an outline) and call TrackDrag. I really wanted to add translucent dragging, since it looks so cool (although it doesn't have that much use), and that required another line to the code, SetDragImage, with a pixmap and region as parameters. Since I was dragging an image already, getting the pix map was no problem, and neither was the region, which is always the square the contains the current icon.

The only problem I ran into was the fact that I could drag from my application to others and to the desktop, and from the desktop to my application (that's what I worked on yesterday), but I couldn't drag within my app (say from the 48x48 icon to the 48x48 mask). But this turned out to be a line left over from the sample code I had based by ApproveDrag procedure on. It didn't approve it if the target window as the same as the source one. This might make sense when your whole window is a container (the way it is in the Finder) but in my case it wasn't appropriate.

I also trimmed down some of the collections of case statements I had yesterday, and my code is a lot cleaner. However, I'm not sure if it's clear at first glance what I'm trying to do, and that's an important thing (I think) for the IB.

(later on)

I added support for scaling and mask generation when dragging within the application. This way different sizes can be created by simply dragging from one image well to another. Same thing for mask generation. These two features are what transform Icon Mangler from being a simple image editor to becoming more like a real icon editor.

Here's a list of things that remain to be done, in no particular order:

- (multiple) undo support (double linked list?)
- constrain movement of selection to x/y axis when holding down shift
- when moving a selection beyond the edge of the window allow it to be drag and dropped onto other applications
- when holding down shift constrain line drawing to right angles
- add preview which combines current icon and mask (this should go right underneath the icon and mask displays)
- when dragging, don't show a hilite rect if the cursor is over the container that is its source
- add option to choose folders, not just files for icon editing
- extract icons from any file, not just ones with custom icons
- when opening a file with more than one icon resource, put up an "Icon Browser" to let the user pick which one to edit (even allow multiple selections, since I can have more than one editor open at the same time?)
- flip horizontal/vertical and rotate clockwise/counterclockwise (at 90�) commands
- select similar command (depends on how much time I have)
- add a "Icon modified since last save, do you want to save" dialog when closing and quitting (quitting is my chance to add recursion to the app, since I can go through the linked list recursively).
- contextual menu support (unlikely in IB version, probable in final one since the competition (Icon Machine) has it)
- add circle, text drawing, polygon tools
- when dragging a file from the Finder, instead of rejecting the drag take the file's icon and place it (this ties in with getting any file's icon)
- when holding down option and selecting a different bit depth from the menu, transfer the current depth to that depth (most editors do this with drag and drop, but because I implemented 48x48 support too, I don't have the screen space to have all of the on the screen at the same time).
- 68K version (not an issue for IB)
- 8.5 features (proxy icons)?
- importing from .tiff/.xpm files, which are used to store NeXT/UNIX icons (unlikely, unless I can find some libraries to parse the icons)

Going back and looking at my original schedule, I realize that I over estimated how long things would take me (although I think things will slow down once school starts again, plus there's a history project which I should be working during the holidays, and that will be next week).

Post a Comment