I have an application that allows a user to drop files from the Finder and then allows the user to link them together. This is done in a very abstract way at the moment; I am creating an object for each of the files in memory and then a predicate to capture the link between them. I can then write the resulting triple out to a file or a triple store.
What I would really like to do is to drag each file into a desktop or workspace (vague, I know) and have the program display them with the appropriate icon to represent the file type (again, a bit vague, but I’m happy to use the Finder defaults as a starting point). I’d like to be able to move the file objects around the workspace and to make a link between them (maybe by dragging a line from one to the other).
I’ve been thinking about whether a DesktopCanvas would work as a workspace, because I think it is possible to place objects on this and possibly move them around. But I don’t know how to get started on this.
Is this kind of thing even remotely achievable in Xojo? Are there any plugins that might make parts of this easier?
a. I collated the icons for displaying, then import them in the project,
In a Canvas (for example, the drop is done and the correcponding icon is displayes while specs for the image is displayed in a TextArea.
No the project is not handy, but somewhere in my bin.
There’s an example project ‘Objects in Canvas’ that allows the user to manipulate (move etc.) the objects in the canvas. Looks like a good starter. Drawing lines between the objects is absolutely doable.
If you have MBS plugins, this is how you get the default icon for a file.
dim nsImageIcon as NSImageMBS = NSWorkSpaceMBS.iconForFile(SpecialFolder.Desktop)
nsImageIcon.setSize(64,64)
dim pictureIcon as Picture = nsImageIcon.CopyPictureWithAlpha
Also, instead of using CopyPictureWithAlpha, which won’t give you a picture that’s suitable for retina displays, this extension method can be helpful.
Public Function CopyHiDPIPictureWithAlpha(extends image as NSImageMBS, width as Integer, height as Integer) As Picture
dim bitmaps() as Picture
image.SetSize(width,height)
bitmaps.Append image.CopyPictureWithAlpha
image.SetSize(width*2,height*2)
bitmaps.Append image.CopyPictureWithAlpha
return new Picture(width,height,bitmaps)
End Function