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

Drag and drop to UserArea

 Post Reply Post Reply
Author
Message
deepSpec View Drop Down
Member
Member


Joined: 2017 Apr 14
Online Status: Offline
Posts: 13
Post Options Post Options   Quote deepSpec Quote  Post ReplyReply Direct Link To This Post Topic: Drag and drop to UserArea
    Posted: 2017 Dec 25 at 1:22am

User Information:

Cinema 4D Version:   R18 
Platform:   Windows  ;   
Language(s):     C++  ;   

---------

How can I get an animatable parameter by drag and drop?
The Object Manager object was created by adding LinkBoxGUI with AddCustomGui.
Is there a drag-and-drop correspondence GUI for the parameter?
Since I was not able to make LinkBox remodeling because it was difficult, I wanted to create it using user area drag and drop, but I saw the sample file of SDK manual and AsyncTest and made it for the same, but I understood how to receive the message did not.

#pragma once
#include "c4d.h"
#include "c4d_commanddata.h"
#include "c4d_gui.h"

#define IDS_UserAreaTest 1000001

Bool RegisterUserAreaTest(void);

Bool PluginStart(void)
{
     if (!RegisterUserAreaTest())
          return false;
     return true;
}

void PluginEnd(void)
{
}

Bool PluginMessage(Int32 id, void* data)
{
     switch (id)
     {
          case C4DPL_INIT_SYS:
               return true;
          case C4DMSG_PRIORITY:
               return true;
          case C4DPL_BUILDMENU:
               break;
          case C4DPL_COMMANDLINEARGS:
               break;
          case C4DPL_EDITIMAGE:
               return false;
     }
     return false;
}

class UserAreaLinkBox : public GeUserArea
{
public:
     virtual Bool GetMinSize(Int32& w, Int32& h);
     virtual void DrawMsg(Int32 x1, Int32 y1, Int32 x2, Int32 y2, const BaseContainer& msg);
};

Bool UserAreaLinkBox::GetMinSize(Int32& w, Int32& h)
{
     w = 100;
     h = 20;
     return true;
}

void UserAreaLinkBox::DrawMsg(Int32 x1, Int32 y1, Int32 x2, Int32 y2, const BaseContainer& msg)
{
     this->OffScreenOn();
     this->DrawSetPen(Vector(110, 110, 0));
     this->DrawRectangle(x1 + 2, y1 + 2, x2 - 2, y2 - 2);
}

class UserAreaTestDialog : public GeDialog
{
public:
     virtual Bool CreateLayout();
     virtual Int32 Message( const BaseContainer& msg, BaseContainer& result );
     virtual Bool CoreMessage( Int32 id, const BaseContainer &msg );
     void Update();
     UserAreaLinkBox ua;
};

Bool UserAreaTestDialog::CreateLayout()
{
     SetTitle( "UserAreaTest" );
     Update();
     return true;
}

Int32 UserAreaTestDialog::Message( const BaseContainer& msg, BaseContainer& result )
{
     switch (msg.GetId())
     {
          case BFM_DRAGRECEIVE:
               if (msg.GetInt32(BFM_DRAG_LOST))
               {
                    GePrint("BFM_DRAG_LOST");
               }

               if (msg.GetInt32(BFM_DRAG_FINISHED))
               {
                    GePrint("BFM_DRAG_FINISHED");
               }

               if (CheckDropArea(200, msg, true, true))
               {
                    GePrint("CheckDropArea");
               }
               break;
          default:
               break;
     }
     return GeDialog::Message( msg, result );
}

void UserAreaTestDialog::Update()
{
     LayoutFlushGroup(100);
     FreeChildren(100);
     GroupBegin(100, BFH_SCALEFIT, 1, 1, "", BFV_BORDERGROUP_FOLD_OPEN, 0);
     {
          C4DGadget* c4dgadget = AddUserArea(200, BFH_SCALEFIT, 100, 20);
          if (c4dgadget)
               AttachUserArea(ua, 200);
     }
     GroupEnd();
     LayoutChanged(100);
}

Bool UserAreaTestDialog::CoreMessage( Int32 id, const BaseContainer &msg )
{
     switch( id )
     {
          case EVMSG_CHANGE:
               Update();
               break;
     }
     return GeDialog::CoreMessage( id, msg );
};

class UserAreaTest : public CommandData
{
     INSTANCEOF( UserAreaTest, CommandData )
public:
     virtual Bool Execute( BaseDocument* doc );
     virtual Bool RestoreLayout( void* secret );
     static UserAreaTest* Alloc() { return NewObjClear( UserAreaTest ); }
private:
     UserAreaTestDialog _dialog;
};

Bool UserAreaTest::Execute( BaseDocument* doc )
{
     if( _dialog.IsOpen() == false )
          _dialog.Open( DLG_TYPE_ASYNC, IDS_UserAreaTest, -1, -1, 400, 400 );
     return true;
}

Bool UserAreaTest::RestoreLayout( void* secret )
{
     return _dialog.RestoreLayout( IDS_UserAreaTest, 0, secret );
}

Bool RegisterUserAreaTest( void )
{
     return RegisterCommandPlugin( IDS_UserAreaTest, String( "UserAreaTest" ), 0, nullptr, String( "UserAreaTest" ), UserAreaTest::Alloc() );
}



GePrint ("BFM_DRAG_LOST");
GePrint ("BFM_DRAG_FINISHED");
Please tell me how to get to.
Or please tell me if there is better usage.
Back to Top
deepSpec View Drop Down
Member
Member


Joined: 2017 Apr 14
Online Status: Offline
Posts: 13
Post Options Post Options   Quote deepSpec Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Dec 26 at 12:06am
I have now seen the fact of shock.
I accidentally saw this forum with a different personal computer.
When searching using the keyword of drag, the same question hit a lot.
I noticed the cause was investigated.
When this forum is logged in, the search result is greatly reduced.
Why is this forum constantly watching nearly 100 people. I was concerned that there was only one or two people logging in.
I will not be able to recover for the time being.
Back to Top
 Post Reply Post Reply

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.109 seconds.