AL_USDMaya  0.16.6
USD to Maya Bridge
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
AL::maya::MenuBuilder Class Reference

You shouldn't need to care about this class (sort of). Probably the only thing you'll want to do is execute. More...

#include <MenuBuilder.h>

Classes

struct  Menu
 
struct  MenuItem
 A structure that represents a menu item. More...
 

Static Public Member Functions

static const std::set< Menu > & rootMenus ()
 
static void clearRootMenus ()
 
static MenuItemaddEntry (const char *menuItemPath, const char *command, bool hasCheckbox=false, bool defaultCheckBoxValue=false)
 add an entry to the menu More...
 
static bool addEntry (const char *menuItemPath, const char *command, const char *optionBoxCommand)
 add an entry to the menu More...
 
template<typename FnPlugin >
static MStatus generatePluginUI (FnPlugin &fnPlugin, const MString &prefix, const MString &extraOnInit="", const MString &extraOnExit="")
 generates an init and exit script that intialises the GUI on plugin load/unload (via MFnPlugin::registerUI). This method should only be called once during your plugins initializePlugin method, and that should probably be at or near the end of that function call. More...
 

Detailed Description

You shouldn't need to care about this class (sort of). Probably the only thing you'll want to do is execute.

MenuBuilder::generatePluginUI<MFnPlugin>(fnPlugin, "myplugin");

somewhere at the end of your plugins' initialize function. Any command GUI's that have previously been defined, will end up being added into the main menu.

I suppose there is absolutely no reason why you couldn't add your own menu items. All it needs is either:

// simple command from the menu item
MenuBuilder::addEntry("My Menu/Sub Menu/Menu Item", "someMelCommand");
// or simple command connected to checkbox.
// first param indicates we want a checkbox, second param indicates the checkbox value
MenuBuilder::addEntry("My Menu/Sub Menu/Menu Item", "someMelCommand", true, true);
// or with an option box
MenuBuilder::addEntry("My Menu/Sub Menu/Menu Item", "someMelCommand", "optionBoxMelCommand");

That wasn't quite what I had in mind when I wrote the class, but it will work just fine. Just make sure that MenuBuilder::generatePluginUI is the last method you call in your initializePlugin method.

Member Function Documentation

static MenuItem* AL::maya::MenuBuilder::addEntry ( const char *  menuItemPath,
const char *  command,
bool  hasCheckbox = false,
bool  defaultCheckBoxValue = false 
)
static

add an entry to the menu

Parameters
menuItemPathforward slash seperated path to the menu item, e.g. "Create/polygons/Construct Teapot"
commandthe MEL command to execute when the item is clicked.
hasCheckboxif true, the menu item will have a check box. If false, only a menu item will exist.
defaultCheckBoxValueIf the checkbox has been enabled, this will determine whether it is on or off by default
Returns
pointer to the menu item added
static bool AL::maya::MenuBuilder::addEntry ( const char *  menuItemPath,
const char *  command,
const char *  optionBoxCommand 
)
static

add an entry to the menu

Parameters
menuItemPathforward slash seperated path to the menu item, e.g. "Create/polygons/Construct Teapot"
commandthe MEL command to execute when the item is clicked.
optionBoxCommandthe MEL command to execute when the option box of the menu is clicked.
Returns
true if the item was added successfully
template<typename FnPlugin >
static MStatus AL::maya::MenuBuilder::generatePluginUI ( FnPlugin &  fnPlugin,
const MString &  prefix,
const MString &  extraOnInit = "",
const MString &  extraOnExit = "" 
)
inlinestatic

generates an init and exit script that intialises the GUI on plugin load/unload (via MFnPlugin::registerUI). This method should only be called once during your plugins initializePlugin method, and that should probably be at or near the end of that function call.

Parameters
fnPluginan instance of an MFnPlugin class
prefixsome unique prefix that is unique to your plugin
extraOnInitsome extra MEL code to execute within the initGUI method for your plugin
extraOnExitsome extra MEL code to execute within the uninitGUI method for your plugin
Returns
MS::kSuccess is everything went well.

The documentation for this class was generated from the following file: