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

Undocking custom plugin menu

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


Joined: 2015 Dec 01
Online Status: Offline
Posts: 91
Post Options Post Options   Quote C4DS Quote  Post ReplyReply Direct Link To This Post Topic: Undocking custom plugin menu
    Posted: 2017 May 03 at 12:06pm

User Information:

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

---------

Hi,

Something being reported by one of my customers, for which I don't find an explanation.
I have this "proxy" CommandData plugin, which its sole purpose is to provide custom menu entries in the plugin menu. The plugin has no icon, and an empty string as plugin name.
In GetSubContainer() I insert 3 submenus (Object Mode, Selection Mode, UV Commands).
When the user opens the plugin menu, the whole set of menu items is nicely shown as expected.

As soon as the user undocks the menu, the submenus disappear and the empty menu entry of the "proxy" command plugin is shown, with a default icon. When the user selects this menu item a popup menu appears with the 3 submenus listed.

I suppose that when a menu is undocked, it becomes some sort of palette, and the only way to show submenu is as a popup menu?
Or is there anyway to make an undocked menu look similar to the original docked menu?










Edited by C4DS - 2017 May 03 at 12:09pm
Back to Top
Yannick Puech View Drop Down
Forum Moderator
Forum Moderator


Joined: 2011 Apr 13
Location: Spain
Online Status: Offline
Posts: 1009
Post Options Post Options   Quote Yannick Puech Quote  Post ReplyReply Direct Link To This Post Posted: 2017 May 04 at 1:13am
Hi,

Implementing GetSubContainer() should be enough.
Could you post the code you use in GetSubContainer() to insert the 3 sub-menus?




MAXON
Developer Support
Back to Top
C4DS View Drop Down
Member
Member


Joined: 2015 Dec 01
Online Status: Offline
Posts: 91
Post Options Post Options   Quote C4DS Quote  Post ReplyReply Direct Link To This Post Posted: 2017 May 04 at 10:25am
Here's the full implementation of the CommandData plugin.
Note that all ID_x and IDS_x are defined in c4d_symbols.h and c4d_strings.h
These are simply numbered ID_1 ... ID_n for demonstration purpose.



class CustomMenuOrder : public CommandData
{
public:
    virtual Bool Execute(BaseDocument* doc);
    virtual Bool ExecuteSubID(BaseDocument* doc, Int32 subid);
    virtual Int32 GetState(BaseDocument* doc);
    virtual Bool GetSubContainer(BaseDocument* doc, BaseContainer& submenu);
};

Bool CustomMenuOrder::Execute(BaseDocument* doc)
{
    return true;
}
Bool CustomMenuOrder::ExecuteSubID(BaseDocument* doc, Int32 subid)
{
    // pass the selected submenu ID to the main UV View Command plugin
    CallCommand(UVVIEW_PLUGIN_ID, subid);
    return true;
}
Int32 CustomMenuOrder::GetState(BaseDocument* doc)
{
    return CMD_ENABLED;
}

Bool CustomMenuOrder::GetSubContainer(BaseDocument* doc, BaseContainer& submenu)
{
    BaseContainer bcObjMode;
    bcObjMode.SetString(1, GeLoadString(IDS_UVVIEW_OBJECTMODE));
    bcObjMode.SetString(ID_1, GeLoadString(IDS_1));
    bcObjMode.SetString(ID_2, GeLoadString(IDS_2));
    submenu.InsData(0, bcObjMode);

    BaseContainer bcSelMode;
    bcSelMode.SetString(1, GeLoadString(IDS_UVVIEW_SELECTIONMODE));
    bcSelMode.SetString(ID_3, GeLoadString(IDS_3));
    bcSelMode.SetString(ID_4, GeLoadString(IDS_4));
    bcSelMode.SetString(ID_5, GeLoadString(IDS_5));
    bcSelMode.SetString(ID_6, GeLoadString(IDS_6));
    submenu.InsData(0, bcSelMode);

    BaseContainer bcCmds;
    bcCmds.SetString(1, GeLoadString(IDS_UVVIEW_COMMANDS));
    bcCmds.SetString(ID_7, GeLoadString(IDS_7));
    bcCmds.SetString(ID_8, GeLoadString(IDS_8));
    bcCmds.SetString(ID_9, GeLoadString(IDS_9));
    bcCmds.SetString(ID_10, GeLoadString(IDS_10));
    bcCmds.SetString(ID_11, GeLoadString(IDS_11));
    submenu.InsData(0, bcCmds);

    return true;
}

Bool RegisterCustomMenuOrder(void)
{
    return RegisterCommandPlugin(
        CUSTOM_MENUORDER_PLUGINID,
        GeLoadString(IDS_UVVIEW_CUSTOMMENUORDER),
        0,
        0,
        "",
        NewObjClear(CustomMenuOrder));
}

Back to Top
Yannick Puech View Drop Down
Forum Moderator
Forum Moderator


Joined: 2011 Apr 13
Location: Spain
Online Status: Offline
Posts: 1009
Post Options Post Options   Quote Yannick Puech Quote  Post ReplyReply Direct Link To This Post Posted: 2017 May 05 at 2:34am
Hi,

I'm sorry I won't be able to investigate much your issue these days as next week we have MAXON's development meeting (See SDK Team at MAXON's Dev Meeting post).

You can try to use FIRST_POPUP_ID or maybe even better ID_TREEVIEW_FIRST_NEW_ID (even if you're not showing a popup menu inside a TreeView) as base ID for the SetString(id, string) calls, except for the SetString(1, string) that sets the sub-menu title.






Edited by Yannick Puech - 2017 May 05 at 2:35am
MAXON
Developer Support
Back to Top
C4DS View Drop Down
Member
Member


Joined: 2015 Dec 01
Online Status: Offline
Posts: 91
Post Options Post Options   Quote C4DS Quote  Post ReplyReply Direct Link To This Post Posted: 2017 May 05 at 4:50am
Hi Yannick,
Thanks for reminding me of the potential ID clashes.
However, I tried ID_TREEVIEW_FIRST_NEW_ID, and even tried ID_TREEVIEW_FIRST_NEW_ID * 2 to make sure I was in the safe zone of IDs. But same issue as with the original IDs. No difference at all.

So, I'll wait for the return of the SDK support team
Back to Top
C4DS View Drop Down
Member
Member


Joined: 2015 Dec 01
Online Status: Offline
Posts: 91
Post Options Post Options   Quote C4DS Quote  Post ReplyReply Direct Link To This Post Posted: 2017 May 23 at 11:35pm
I'd like to bring this back to your attention, in case it slipped through.
Back to Top
Yannick Puech View Drop Down
Forum Moderator
Forum Moderator


Joined: 2011 Apr 13
Location: Spain
Online Status: Offline
Posts: 1009
Post Options Post Options   Quote Yannick Puech Quote  Post ReplyReply Direct Link To This Post Posted: 2017 May 24 at 4:58am
Hi,

Thanks for the reminder Smile

The issue is dynamically submenus added from GetSubContainer() can't be converted into a palette buttons.  Only commands are supported. This explains why the undocked menu only displays the dummy command icon, and not its dynamic submenus.
You can see the same behavior if the "Plugins" menu is undocked. The menu items for each plugin are no longer shown directly, but accessible from "Plugins" command.



MAXON
Developer Support
Back to Top
C4DS View Drop Down
Member
Member


Joined: 2015 Dec 01
Online Status: Offline
Posts: 91
Post Options Post Options   Quote C4DS Quote  Post ReplyReply Direct Link To This Post Posted: 2017 May 26 at 1:11am
Hello Yannick,
I see what you mean with the "plugins" menu.
Currently, my command plugin responsible for the custom menu is registered without icon and empty string. Hence the reason for this dummy command icon.
As such, the only option I have is to provide a string and icon, so that these are displayed in case of undocked state.
Alternatively, I could get rid of the grouping of commands in submenus, and let them all be shown in the main list, including some separators to "group" commands belonging together. But this might turn out to become a long list.

Haven't figured out the separator solution yet, so will probably go for the first solution.
Thanks for your time.

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