Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > SDK Help
  New Posts New Posts
  FAQ FAQ  Forum Search

TreeViewFunctions and tree items

Author
Message
  Topic Search Topic Search
kuroyume0161 View Drop Down
Member
Member
Avatar

Joined: 2002 Oct 29
Location: United States
Online Status: Offline
Posts: 3665
Direct Link To This Post Topic: TreeViewFunctions and tree items
    Posted: 2006 Nov 25 at 4:13pm

User Information:

Cinema 4D Version:   8.2-10.0 
Platform:   Windows  ; Mac  ;  Mac OSX  ; 
Language(s):     C++  ;  

---------

I see that drag-n-drop in the TreeViewFunctions all expects some sort of Cinema 4D object (even though using void*) - esp. AtomArray. The object items would then need to be derived from class Atom, but is it possible to do this directly:

class RuntimeItem : public Atom {...};

or must I use some sort of plugin type for my class so that it inherits Atom indirectly in this way?

I think that I went through this exercise early on in development and decided on not using the drag features. Now that I'd like to, this becomes important as there is no apparent way to do drag-n-drop with non Atom-derived class objects. I'm thinking that this would need to be a plugin type to get all of the linking setup properly. (?)

Thanks,
Back to Top
kuroyume0161 View Drop Down
Member
Member
Avatar

Joined: 2002 Oct 29
Location: United States
Online Status: Offline
Posts: 3665
Direct Link To This Post Posted: 2006 Nov 25 at 6:08pm
I've gone the NodeData plugin route, but methinks that the links will need to be made in the GeListNode for AtomArray to actually fill in. Currently using my own linking and the AtomArray is not getting at the selected drag item.

More work to do. :)
Back to Top
kuroyume0161 View Drop Down
Member
Member
Avatar

Joined: 2002 Oct 29
Location: United States
Online Status: Offline
Posts: 3665
Direct Link To This Post Posted: 2006 Nov 25 at 8:08pm
Okay, now I'm confused. It seems that my Tree root should be a GeListHead (?) so that it can contain the highest level nodes in the tree hierarchy. But I can't derive it since GeListHead() and ~GeListHead() are private (and I have constructor/destructor defined).

Any source to show how to use your own root and item hierarchies (completely untied to Cinema 4D objects - there is no document, there is no object/tag/material/etc., these are just items) and still have access to drag-n-drop?

Thanks,
Back to Top
kuroyume0161 View Drop Down
Member
Member
Avatar

Joined: 2002 Oct 29
Location: United States
Online Status: Offline
Posts: 3665
Direct Link To This Post Posted: 2006 Nov 26 at 11:58am
This has been solved by finding an indirect reference in an old topic. Pretty neat once you realize that you can really do this rather simply. Context menus on the other hand... ;)

Did I mention that I found a simple way to do a 'hover open' for folders? Why doesn't the Object Manager have this so that you can open up hierarchies to dig down in for parenting?

Thanks,
Back to Top
Dani3D View Drop Down
Member
Member


Joined: 2005 Jan 17
Location: Switzerland
Online Status: Offline
Posts: 12
Direct Link To This Post Posted: 2006 Dec 14 at 10:31am

Hi Robert,

actually I'm facing the same problem you are describing here, that with non-C4D-objects there seems no drag&drop possible. Anyway, in your last post you mention an indirect reference to a solution in an old topic. So I have been looking through the forum for a while now, but I don't seem to find it. Maybe this reference is too indirect for me, so that I don't recognize it as a solution.

Well, I would be quite glad, if you could post the link to the topic you mentioned.

Thanks in advance,

Dani

 

Back to Top
kuroyume0161 View Drop Down
Member
Member
Avatar

Joined: 2002 Oct 29
Location: United States
Online Status: Offline
Posts: 3665
Direct Link To This Post Posted: 2006 Dec 14 at 10:52am
Can't remember the reference offhand, but you just want to forget about using 'dragarray' - not tenable. And I'm supporting multiple drag objects by selection flag and not an AtomArray (funky way around this, that is). RuntimeItem is my tree item class (placed under a tree root).

Here's a basic version of what I did:

//*---------------------------------------------------------------------------*
LONG GetDragType(void* root, void* userdata, void* obj)
//*---------------------------------------------------------------------------*
{
     RuntimeItem*     item =     (RuntimeItem*)obj;
     // Note here that:
     // ITEMTYPE_RUNTIME is my own typing
     // ID_RUNTIMEITEM is the plugin ID for the class (just needs to be unique, not even a properly registered plugin)
     if (item->IsTypeOf(ITEMTYPE_RUNTIME))     return ID_RUNTIMEITEM;
     return NOTOK;
}
//*---------------------------------------------------------------------------*
LONG AcceptDragObject(void* root, void* userdata, void* obj, LONG dragtype, void* dragobject, Bool& bAllowCopy)
//*---------------------------------------------------------------------------*
{
     if (dragtype == ID_RUNTIMEITEM)
     {
          RuntimeItem*     drag =     (RuntimeItem*)dragobject;
          if          (drag->IsTypeOf(ITEMTYPE_RUNTIME))
          {
               if (((RuntimeItem*)obj)->IsTypeOf(ITEMTYPE_RUNTIME))     return INSERT_BEFORE|INSERT_AFTER;
          }
     }
     return 0;
}
//*---------------------------------------------------------------------------*
void InsertObject(void* root, void* userdata, void* obj, LONG dragtype, void* dragobject, LONG insertmode, Bool bCopy)
//*---------------------------------------------------------------------------*
{
     if (dragtype != ID_RUNTIMEITEM)     return;

     RuntimeItem*     drag =     (RuntimeItem*)dragobject;

     // Supports multi-select via RTFLAGS_SELECTED since AtomArray cannot be used

     // RUNTIME *******************************************************
     // Rearrange Runtimes in TreeView only
     if (drag->IsTypeOf(ITEMTYPE_RUNTIME))
     {
          if (insertmode == INSERT_BEFORE)
          {
               RuntimeItem*     op =     (RuntimeItem*)obj;
               // Only allow target position wrt other Runtimes
               if (!op->IsTypeOf(ITEMTYPE_RUNTIME))     return;
               RuntimeItem*     next;
               troot =               (TreeRoot*)root;
               for (drag =     troot->GetFirst(); drag; drag = next)
               {
                    next =                                             drag->GetNext();
                    if (!drag->GetBit(RTFLAGS_SELECTED))     continue;
                    if (drag == op)                                   continue;
                    troot->InsertBefore(drag, op);
               }
          }
          else if (insertmode == INSERT_AFTER)
          {
               RuntimeItem*     op =     (RuntimeItem*)obj;
               // Only allow target position wrt other Runtimes
               if (!op->IsTypeOf(ITEMTYPE_RUNTIME))     return;
               RuntimeItem*     next;
               troot =               (TreeRoot*)root;
               for (drag =     troot->GetFirst(); drag; drag = next)
               {
                    next =                                             drag->GetNext();
                    if (!drag->GetBit(RTFLAGS_SELECTED))     continue;
                    if (drag == op)                                   continue;
                    troot->InsertAfter(drag, op);
               }
          }
     }
}

Back to Top
Dani3D View Drop Down
Member
Member


Joined: 2005 Jan 17
Location: Switzerland
Online Status: Offline
Posts: 12
Direct Link To This Post Posted: 2006 Dec 14 at 2:45pm

Thanks, that really helped a lot!

The own ID for the drag type has been the key. It now works perfectly, even without any C4D-based classes/object (except for the treeview itself of course).

Dani

Back to Top

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.125 seconds.