TreeViewFunctions and tree items



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 25/11/2006 at 16:13, xxxxxxxx wrote:

    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,



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 25/11/2006 at 18:08, xxxxxxxx wrote:

    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. :)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 25/11/2006 at 20:08, xxxxxxxx wrote:

    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,



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 26/11/2006 at 11:58, xxxxxxxx wrote:

    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,



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 14/12/2006 at 10:31, xxxxxxxx wrote:

    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



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 14/12/2006 at 10:52, xxxxxxxx wrote:

    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);  
                   }  
              }  
         }  
    }
    


  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 14/12/2006 at 14:45, xxxxxxxx wrote:

    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


Log in to reply