Drag+Drop

cwright's picture

While exploring how to go about performing drag & drop for patches into macros (KinemeCore beta thread stuff), I inadvertently discovered the two simple methods (functions) required to make patches out of drag/dropped files in the editor.

I quickly modified Kineme3D to add this functionality, and surprisingly, it worked on the first try. ;)

Shockingly easy, but somehow it slipped under the radar all this time.

(I think yanomano mentioned adding this functionality to something in the past, perhaps kineme3d itself?)

So, which file types do we need to look out for when updating future patches?

smokris's picture
File Types

Besides Kineme3D, I'm thinking:

  • AudioTools: .wav, .aiff, .mp3, and .m4a should instantiate "Audio File Input" or "Audio File Player"... (how do we decide which patch to instantiate when there are multiple options?)
  • FileTools: .txt should instantiate "String With File"
  • FileTools: .plist should instantiate "Structure With File"

Also, how do we handle mapping relative vs. absolute paths? (The only cases I know of where Apple uses drag-and-drop are "Image Importer" and when dragging a composition in from Finder, both of which copy the file into the composition, avoiding this issue.)

cwright's picture
options and relatives

For handling multiple files, I'm not sure (I don't know the internals, but if multiple patches can be created from a file, it might make multiple files...)

for paths, I'm not sure. We can do absolute automatically (that's the default). Performing relativization might be possible at creation time (when the path's provided, we could parse through user info stuff to find our composition's path, and make it relative from there with some string munching).

kimba23's picture
movie files

movie files would be nice to be able to D&D

dust's picture
d&d

i was actually thinking of this the other day as well... it would be a nice way to encapsulate more features into quartz without having to use IB. i think being able to drag and drop a .qtz file would be cool. maybe i am confused how this where to work. would it be a drop zone kind of thing that could be connected to something. or would you be just dropping a file onto a directory patch ?

cwright's picture
already works

You can already drop movie files into the editor and get Movie Loaders from them.

cwright's picture
already works

You can already drop qtz files into the editor and get Macro Patches from them.

dust's picture
drop&drag

thats what i thought, i can all ready drag and drop things. but for an image you have to open the inspector etc. i was thinking of more or less dragging and dropping onto the viewer.

gtoledo3's picture
I think this is really

I think this is really cool... I just second Steve's comment about overlap of patches, in that nothing comes to mind that is a truly logical way of handling that. All I could think of, is if there were something on the patch creator itself ... you could have a bar under the description to "check box" that it should be the default drag and drop patch for a file?... and maybe have options for other value defaults as well (like whether the 3D loader defaults to smooth, loop or no loop for the audio player... all of the inputs with initial value selections basically). You could even put defaults on the patch creator for patches that that don't load files (as in, set the 3D render to always load with backface culling, or to always load everything with Alpha blending, etc.).

.... Forgetting about my blathering about default check boxes and whatnot... I can see how it would be equally cool, that if I dragged a file onto the editor, for it to simply create an appropriate input splitter... I could then hook THAT to whatever patch(es) I wanted. That isn't quite as flashy though. So it would basically just be the file name with an output path. That behavior option might solve the problem for files that have patch overlap... if you could choose which you prefer to be default (audio file, vs audio player for example) OR choose the file name with output(input splitter) behavior.

It doesn't really come to mind where the most logical place is to control the menu that chooses that behavior. The patch creator itself seems to make the most sense.

cwright's picture
multi-files

Just did a quick 2-patches-respond-to-the-same-file-type test, and only one gets instantiated (the first patch registered, I think).

So perhaps this is a subtle way of saying "rethink your paradigm" if there are multiple patches that use the same file types. (i.e. create a generic loader patch or something).

cwright's picture
uncontrol

We're not in much control over the file->patch creation step -- I just figured out the functions our patches need to perform to respond when the call arises ("Does anyone know what to do with this file?!" "I do!" -- just figured out the "I do!" part, followed by the "do it!" part).

So picking a default when conflicts arise isn't really easy (that would be a kinemeCore thing, since it would modify QC internally).

I thought about the path thing a bit... not sure if it would do the right thing all the time though (splitters would get a very high priority, being QC-internal, and would thus take over before other plugins, should a conflict arise).

Defaults on patches can be changed in the source pretty easily. Configuring them via user settings would be possible, but there's no current precedent for doing that.

gtoledo3's picture
The paradigm of pulling a

The paradigm of pulling a file onto the editor and just getting a input splitter type of thing probably isn't the type of "wow" that having a plugin loaded is... but probably useful still. I for one, almost 100% of the time take an input splitter for file path and then feed it to both the audio player, and the audio file (the one for offline stuff) for example. I almost never have just one or the other loaded.

I could see scenarios where maybe someone would want to pull a 3D file onto the editor and have it just load an input splitter... so that they could take that and feed it to two separate renderers, to compare overhead or the look of various object manipulation settings or something.

kimba23's picture
oh thanks

I always typed in the path..., never tried to drag and drop. my bad. on the subject of functionality. There is another node based editor called Sandbox 2 that I often play with, it is a game engine editor. It has a nice feature called "paste with links"; where after copying a node or a group of nodes, while pasting, it will attempt to link the pasted nodes to appropriate inputs and outputs, kind of mirroring the links of the copied node(s). Maybe there is a way to do this already, and i dont know it :) thanks for the tips! Next time I try before I cry. promise

gtoledo3's picture
Understood, since you are

Understood, since you are saying this is actually necessary to code into each patch, not just in kinemecore or something.... so loading the splitter isn't so straightforward.

I know that it's way simple to change the defaults via source, but had been thinking about whether this was possible for an overall plug in... and it seemed to be a little complimentary of a feature since it deals with default patch loading behavior... so I figured it was a good time to chime in.

Since those values (default values when loaded) are coded into the source, it doesn't seem like anything could intercept it and change the default value of the patch when pulled to the editor as/before it loads... or if it did, it might slow things down too much or make things glitchy. However, there has been many a time that I wished that I could change culling or blend defaults, or even change them globally once loaded. That seems way outside of what is possible from my poking around, but then again, you know a LOT more than me about workarounds.

dust's picture
sand box

haven't tried sandbox looks interesting. i have the torque engine, but don't own an xbox 360 and unity 3d but both can make osx for you. actually unity is cool cause it builds the x code project for you. but i like nodes will look at sand box, seems it is for pc only, usually don't fire up the pc much but was thinking of trying VVV there is a web based node thing out called lilly app. kind of neat. made a program that searches for restaurants, and gives map for your area in like 5 min a couple years ago im sure it has progressed since then. lilly....