PDA

View Full Version : drag'n'drop question plus properties



Lionheart008
08-08-2013, 16:59
hello. I've a general question about "drag'n'drop" function for folders or files into tbgl window (or similiar to ui canvas modus): it's possible to drag properties of an primitive (sphere, cube etc.) as colour, material, texture, scaling factor or something else via drag'n'drop? does anybody has experience with this one? thanks in advance, frank

ReneMiner
08-08-2013, 19:25
Currently I think only drag-in of files from explorer or desktop is possible when you use just the TBGL-window. So I fear there's no way to drag stuff out of TBGL-window nor to recognize a drag-out - except you have your own GUI within TBGL which would be some internal drag'n drop - or you use UI-canvas and callbacks which both doesn't have much to do with TBGL_BindWindowEvent/TBGL_OnDropFiles then.

A weird idea to get around this: save a small file onto the desktop/ into some special folder if the user clicks onto something. When the file gets dragged in you can use the data - either delete it then or leave it re-useable

Find an example here (http://www.thinbasic.com/community/project.php?issueid=395)(scroll all the way down there)

Petr Schreiber
08-08-2013, 20:28
Hi Frank,

I haven't seen you for a while here, welcome back :)

If I understand you correctly - you are not talking about dragging something into TBGL window, but dragging it out of it?
For example dragging from orange sphere in TBGL world out of the window to notepad for example, where 255,128,64 would magically appear?

I think functionality like this could be done right now this way:

you detect mouse down on some object in 3D world
you use TBGL_GetPixelInfo to retrieve coordinate/color where you clicked
you lookup your internal database to guess which object that fragment belongs to
you store the information you need to clipboard (via Clipboard_SetText)
once you detect mouse up outside of window (that is, TBGL_MouseGetPosX returns -1, but you can still catch the mouse up via GetAsyncKeyState, which works on global level)
you set focus to the window you hover over
you use SendKeys to artifically launch Ctrl-V sequence there


For the other way the approach Rene talks about is perfectly valid and it is only up to you how do you handle dragged file. If it is BMP or TGA, you could load it as texture, and via technique similar to the one above detect and update the object.
If you have material defined in your own fileformat somewhere, you could do it again - just check the extension and based on it decide the action.


Petr

Lionheart008
09-08-2013, 10:28
thanks rene and petr for feedback and the link. yes, I've didn't work a long time with thinbasic and much more with oxygen (great programming software and it's getting better and better as you perhaps know) last weeks and month if there's enough time beside family, job and daughter..


If I understand you correctly - you are not talking about dragging something into TBGL window, but dragging it out of it?

no, I am talking about dragging something from a sdk win api "dialog" with material content or properties or components into TBGL window ;)

I am working with an 3d graphic software and there's a lot of embedded winapi's (sdk modus) with tab's so far as I know and in centre the main openGL window with grid plane and x,y,z axis for 3d coordination. left side theres a "material" tab (own sdk window) inside something like a "list" for material if you cklick it theres a new "dialog" with all properties you can imagine like colour, size, scaling, translate (position) and much more for primitives.

after creation of a simple sphere, activate it (!) in the list view and if you're clicking a material from the "list" (I suppose it's a list) you can "drag'n'drop" the material in directly way onto the open GL window on the primitive you like. now the sphere have detached with (for example) "copper" colour and you have access to all properties of this new colored sphere. so after knowing much more of drag'n'drop behaviour of folder it may possible for script's and files with "tbgl or openGL" content too to go same way as the 3d graphic software. My interest was only how they made it and what's trick behind this drag'n'drop feature for "components" as charles titled it yesterday with a good name.

I will create a demo for my idea.

if you like you can have a look at this oxygen page :-)
http://www.oxygenbasic.org/forum/index.php?topic=824.msg6754;topicseen#msg6754


thanks, frank

ReneMiner
09-08-2013, 10:51
can't you change the behaviour of that dialog/listview-wherever you drag that data from - maybe set it to clipboard on right-click or some shift-click... - and also detect right-click/shift-click in TBGL-window to insert it here?
-even more than one usage possible then - without need to move the mouse back to the other window - just like dipping a brush into the color and paint...

ReneMiner
31-10-2013, 11:03
Just some common - not TBGL-specific question, but fits this topic and I'm too lazy to open extra thread since forum search for Drag & Drop brought me here ...

How can I do similar function (drag in of filenames) using standard windows (or controls), so to say when


Uses "UI"

because have some canvas-bound TBGL-display?

Petr, could you make some *.tBasicU or *.inc-file from Drag-In-Function please? I'm going nuts when I have to find out from MS-sites before I've found out... :D

Petr Schreiber
31-10-2013, 11:27
Hi Rene,

I will port the code from TBGL to ThinBASIC unit, stay tuned!


Petr

Petr Schreiber
31-10-2013, 18:40
Experimental ThinBASIC DragNDrop module at your disposal...

I attach the module, it's source code and testing example to give you idea on how to use.
Module contains the following functions:

DND_Activate - activates given window for user events
DND_Deactivate - deactivates given window for user events
DND_BindWindowEvent - binds specific event, in this case %DND_OnDropFiles
DND_UnBindWindowEvent - unbinds specific event, in this case %DND_OnDropFiles
DND_GetCallingWindow - returns calling window in the handler procedure
DND_OnDropFiles_GetFileCount - returns file count in the handler procedure
DND_OnDropFiles_GetFileName - returns file name #n in the handler procedure


Limitation: I just spent 1,5 hour debugging and then I realised, that if you launch script with Admin privileges, or if you launch script from thinAir with Admin privileges, it won't work. It is a feature of operating system, dragging files does not work for me in Sony Vegas too, when launched with Admin privileges.

I hope you will find it useful, source code is in PB/Win 10, but there is the DLL file directly too, for those who don't feel like modding it :)


Petr

ReneMiner
01-11-2013, 13:50
Great stuff, thanx a lot. Will it become a module because already uses "USES" and also fits naming conventions?

Will there be no admin-issue if I put the dll into thinBasic\lib-folder?

Petr Schreiber
02-11-2013, 11:00
Hi Rene,

I already made it module, I don't think it is worth adding to official distribution yet, but feel free to add it to your Lib directory.
Regarding Admin issue - I am googling for workaround, but I don't give it much chance.


Petr

Lionheart008
02-11-2013, 13:20
good work petr :)

I will test the little module closer this evening if there's time for it.

have you tried to call dropped file into gui window with all names of folder content (files, images and so on..) in it too after dragging?
I know from my 3d application that they are using a lot of sdk windows with material specifications (copper for example) you can drag into openGL window (main window for working) and you can serve a sphere with this copper material via drag'n'drop. this material sdk window (mdi format I am thinking) uses a listview and the object manager with all stuff a treeview, that's all I know until today. my experiences with inka 3d (pbwin 9) ended in 2009 for this one as there wasn't time enough to go on with that idea.

more I will show at a later moment, there wasn't enough time to explore for my own application I've made some years ago with powerbasic 9 as an exercise with openGL and primitives plus materials, but it was only one running demo what's possible to show, nothing to import or export files ;)

as I have unfortunately lost some of my old "usb" sticks last years there's gone the complete source code for that hard work. today I would go another way to build such a 3d software graphic application...

greetings, frank

Petr Schreiber
03-11-2013, 17:59
Hi Lionheart008,

the file drag and drop opens lot of possibilities, as you write.
Names of folder contents can be easily filtered out thanks to FILE module functions, so the answer is - no I didn't try to do this, as I had no need for it yet, but it is possible in ThinBASIC.


Petr