TreeView: Re-arranging list items
-
On 14/02/2013 at 13:02, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 13
Platform: Windows ;
Language(s) : C++ ;---------
Does anyone have an example of using the drag&drop functions in the tree GUI?I already know how to create a basic tree GUI that reflects the object layout in the OM.
But I want to be able to re-arrange the tree (parent -> child) items like we can do it in the OM.-ScottA
-
On 14/02/2013 at 13:42, xxxxxxxx wrote:
It is quite a complicated process. Instead of inserting a ton of code here, I'll give you a download to one of my TreeView implementations. Realize that this one is manipulating folders and files as the representation but all that you would need do is change that representation to your own.
http://www.kuroyumes-developmentzone.com/wp-content/uploads/2013/02/TreeView.zip
Hope that gets you going!
-
On 14/02/2013 at 14:20, xxxxxxxx wrote:
Thanks Robert.
I think I really need to use the ones in the SDK first before trying to tackle hand made ones.
I'm a bit lost with your code because it doesn't use any of the TreeViewFunctions class functions like DragStart, AcceptDragObject, InsertObject, etc.Or are you saying that none of those sdk functions let us shuffle tree items around in the tree gui. And that kind of thing MUST be written by hand from scratch?
If it helps to make it easier.
I can post a very simple GeDialog plugin example that just has a tree view in it. And then you guys can edit it as needed.-ScottA
-
On 14/02/2013 at 14:40, xxxxxxxx wrote:
FaveFunctions.h has the TreeViewFunctions-derived class. Oh, believe me, it's all there.
-
On 14/02/2013 at 15:22, xxxxxxxx wrote:
I'm sure it is.
In fact. That's the problem. It has too much stuff in it.
I can't even compile it due to lots of undefined errors.I'll keep trying.
But I still don't understand why none of the sdk functions I mentioned are not being used?-ScottA
-
On 14/02/2013 at 20:52, xxxxxxxx wrote:
Here.
Let me do as much work as I can on my part and post a very small working tree GUI plugin.
https://sites.google.com/site/scottayersmedia/TreeGUI_R13.zip-The tree branches are expandable & collapsible
-The tree updates when the OM is changed
-The selected tree items allows me to remotely select objects in the OM and in the sceneWhat I can't figure out is how to go in the other direction. And change the tree gui's parent->child branches to remotely change the OM's tree layout.
I do get the arrow and the orange line showing up in the tree gui acting like the drag&drop is working. But it doesn't actually move the tree items because I don't know how to write that part.-ScottA
-
On 16/02/2013 at 11:57, xxxxxxxx wrote:
Originally posted by xxxxxxxx
I'm sure it is.
In fact. That's the problem. It has too much stuff in it.
I can't even compile it due to lots of undefined errors.I'll keep trying.
But I still don't understand why none of the sdk functions I mentioned are not being used?-ScottA
Remember that the code provided was not a working example. It is just the source files for that feature (which is part of a much, much larger piece of software). Implementing a fully functional TreeView in C4D takes a lot of code. I tend to implement one part at a time (root and items, display and icons, listing and states, context menus, actions, drag-and-drop (internal then external sources), etc.) and build it up to full functionality.
-
On 16/02/2013 at 12:12, xxxxxxxx wrote:
In order to have reordering in your TreeView affect the OM, you need to fill out the InsertObject() method in your TreeViewFunctions class. This is some code to how I do it - though you may not need the restrictions on Obase or the Select() part:
//*---------------------------------------------------------------------------* void InsertObject(void* root, void* userdata, void* obj, LONG dragtype, void* dragobject, LONG insertmode, Bool bCopy) //*---------------------------------------------------------------------------* { if (!root) return; if (dragobject && (dragtype==DRAGTYPE_ATOMARRAY) && ((AtomArray* )dragobject)->GetCount()==1L && ((AtomArray* )dragobject)->GetIndex(0L) && ((AtomArray* )dragobject)->GetIndex(0L)->IsInstanceOf(Obase)) { BaseObject* dragop = (BaseObject* )((AtomArray* )dragobject)->GetIndex(0L); if (!((BaseList2D* )obj)->IsInstanceOf(Obase)) return; BaseObject* op = (BaseObject* )obj; Matrix merk = dragop->GetMg(); dragop->Remove(); switch (insertmode) { case INSERT_BEFORE: dragop->InsertBefore(op); break; case INSERT_UNDER: dragop->InsertUnder(op); Open(root,userdata,op,TRUE); break; default: dragop->InsertAfter(op); break; } dragop->SetMg(merk); Select(root,userdata,dragop,SELECTION_NEW); EventAdd(); } }
-
On 16/02/2013 at 14:47, xxxxxxxx wrote:
Thanks Robert,
When I use your InsertObject() function in my plugin. The tree items still don't change.
Did you try this function out in the plugin I posted?
Or is this another abstract example that I'll need to change to make it work in my plugin?-ScottA
-
On 16/02/2013 at 16:30, xxxxxxxx wrote:
Alright. This works. A lot of your problem is trying to associate the TreeView with the object. Unless you have explicit Root and Item classes to represent the hierarchy, just use the Document and objects directly. Secondly, you need to use the DragArray type for this to work and GenerateDragArray() is required for that.
Here is a download to the updated myResDialog.cpp:
www.kuroyumes-developmentzone.com\wp-content\uploads\2013\02\myResDialog.zip
(For some reason I can't get it to make a hyperlink - but that is the correct URL to get the file) - Oh, it keeps lower-casing the URL on my CASE-SENSITIVE webserver... These guys need an up-to-date forum software.....
-
On 16/02/2013 at 17:23, xxxxxxxx wrote:
Awesome!
Thanks a lot Robert.Do you mind if I post this plugin on my website with my other plugins?
This is something that should have been included in the SDK examples. And It's really helpful to have a working example to learn from.
I'll give you full credit in the code of course.-ScottA
-
On 16/02/2013 at 18:30, xxxxxxxx wrote:
Not at all. The more information out there, the better for everyone.