- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

# MenuMessenger/MenuMessenger.cpp

    //**************************************************************************/
    // Copyright (c) 2008 Autodesk, Inc.
    // All rights reserved.
    //
    // Use of this software is subject to the terms of the Autodesk license
    // agreement provided at the time of installation or download, or which
    // otherwise accompanies this software in either electronic or hard copy form.
    //
    //**************************************************************************/
    // DESCRIPTION:
    // CREATED: December 2008
    //**************************************************************************/

    #include "MenuMessenger.h"

    // This macro provides some information about the plugin to Mudbox. It also
    // specifies a function that will be called after all the plug-ins are loaded
    MB_PLUGIN( "MenuMessenger", "Sample plugin adds menu items", "Autodesk", "http://www.mudbox3d.com", MenuMessenger::Initializer );

    void MenuMessenger::Initializer()
    // This is called after the plug-ins are all loaded.
    //
    // Add a series of menu items, sub-menus, and menus to the Mudbox interface.
    // Each item should show a different message.
    {
        // Add two menu items and a sub-menu with three items to the Edit menu
        Kernel()->Interface()->AddCallbackMenuItem(mudbox::Interface::menuEdit, QString::null, "Menu Messenger #1",MenuMessenger::ShowMessage1);
        Kernel()->Interface()->AddCallbackMenuItem(mudbox::Interface::menuEdit, "Messenger Sub-Menu","Menu Messenger #2",MenuMessenger::ShowMessage2);
        Kernel()->Interface()->AddCallbackMenuItem(mudbox::Interface::menuEdit, "Messenger Sub-Menu","Menu Messenger #3",MenuMessenger::ShowMessage3);
        Kernel()->Interface()->AddCallbackMenuItem(mudbox::Interface::menuEdit, "Messenger Sub-Menu","Menu Messenger #4",MenuMessenger::ShowMessage4);
        Kernel()->Interface()->AddCallbackMenuItem(mudbox::Interface::menuEdit, QString::null, "Menu Messenger #5",MenuMessenger::ShowMessage5);

        // Create a new menu named Plug-ins and add menu items to it.
        Kernel()->Interface()->AddCallbackMenuItem(mudbox::Interface::menuPlugins, QString::null, "Menu Messenger #6",MenuMessenger::ShowMessage6);
        Kernel()->Interface()->AddCallbackMenuItem(mudbox::Interface::menuPlugins, QString::null, "Show Message that Stays Up",MenuMessenger::ShowMessage7);
        Kernel()->Interface()->AddCallbackMenuItem(mudbox::Interface::menuPlugins, QString::null, "Clear Messages",MenuMessenger::ShowMessage8);
    }

    void MenuMessenger::ShowMessage1(){
        // Display a basic message on the HUD
        Kernel()->Interface()->HUDMessageShow("Menu Message #1", mudbox::Interface::HUDmsgFade );
    }

    void MenuMessenger::ShowMessage2(){
        // Display some useful information
        QString message(QString("You are running Mudbox from this folder:<p>%1").arg( Kernel()->ApplicationDirectory()));
        Kernel()->Interface()->HUDMessageShow( message, mudbox::Interface::HUDmsgFade );
    }

    void MenuMessenger::ShowMessage3(){
        Kernel()->Interface()->HUDMessageShow("Menu Message #3", mudbox::Interface::HUDmsgFade );
    }

    void MenuMessenger::ShowMessage4(){
        Kernel()->Interface()->HUDMessageShow("Menu Message #4 demonstrates <b>bold</b> text", mudbox::Interface::HUDmsgFade );
    }

    void MenuMessenger::ShowMessage5(){
        Kernel()->Interface()->HUDMessageShow("Menu Message #5 demonstrates <i>italic</i>text", mudbox::Interface::HUDmsgFade );
    }

    void MenuMessenger::ShowMessage6(){
        Kernel()->Interface()->HUDMessageShow("Menu Message #6", mudbox::Interface::HUDmsgFade );
    }

    void MenuMessenger::ShowMessage7(){
        // using "HUDmsgPin" leaves the message on the screen until it is cleared or overwritten
        // by another message
        Kernel()->Interface()->HUDMessageShow("This message stays up", mudbox::Interface::HUDmsgPin );
    }

    void MenuMessenger::ShowMessage8(){
        // This call clears a pinned message
        Kernel()->Interface()->HUDMessageHide();
    }