Attributes (lxu-attributes.hpp)

From The Foundry MODO SDK wiki
Revision as of 18:43, 4 July 2012 by Jangell (Talk | contribs)

Jump to: navigation, search

This module provides utility classes for presenting attributes interfaces on exported objects.


This class implements Attributes and AttributesUI interfaces for classes that need to export them, like commands and tools.


The client calls the following methods from their constructor to initialize their attributes.

  • dyna_Add() -- add an attribute with a name and type. Attributes are assigned indices in the order they are added.
  • dyna_SetHint() -- set the text hints for integer arguments by index.
 CMyCommand::CMyCommand ()
         static LXtTextValueHint hint_mode[] = {
             {  1,  "yes"   },
             {  0,  "no"    },
             { -1,  "maybe" },
             { -1,  NULL    }
         dyna_Add ("name", LXsTYPE_STRING);     // attribute 0
         dyna_Add ("mode", LXsTYPE_INTEGER);    // attribute 1
         dyna_SetHint (1, hint_mode);

Values of attributes can be read using these methods.

  • dyna_IsSet() -- true if the attribute's value has been set.
  • dyna_Object() -- get a localized object from an attribute.
  • methods to read values, with optional defaults for attributes are are unset:
    • dyna_Bool() -- read a boolean attribute.
    • dyna_Int() -- read an integer attribute.
    • dyna_Float() -- read a float attribute.
    • dyna_String() -- read a string attribute.
 CMyCommand::cmd_Execute (
         unsigned                  flags)
         std::string               name;
         int                       mode;
         dyna_String (0, name);
         mode = dyna_Int (1, -1);

Attribute values can be set using these methods.

  • dyna_Value() -- a reference to the CLxUser_Value for the given index.
  • the raw Attributes methods can also be used:
    • attr_SetInt() -- set an integer value (including boolean).
    • attr_SetFlt() -- set a float value.
    • attr_SetString() -- set a string value.
Custom UI

The client subclass can optionally implement some virtual methods for customizing attribute UI properties.

  • attrui_Enabled() -- return true for an enabled value, otherwise return false and set the disabled message.
  • attrui_UIHints() -- set UI hints for this attribute in the UIHints Interface.
  • attrui_UIValue() -- allocate and return a CLxDynamicUIValue instance for this attribute.


Simple UI behaviors can be defined by calling methods on the UIHints Interface for the attribute. more complex behaviors require UI value object. This class is a simple abstract class providing virtual methods that can be overridden by the client. Returned from attrui_UIValue(), this presents these specializations to nexus. These are all just C++ friendly versions of the methods of the UIValueHints Interface.


The list popup class is a special subclass of CLxDynamicUIValue which just creates dynamic popups. The client need only implement the update function to set strings into the internal and user lists. The internal name list can be left empty if there are none.

 class CMyPopup : public CLxUIListPopup
         UpdateLists ()
                 user_list.push_back ("George");
                 user_list.push_back ("Martha");
                 user_list.push_back ("Thomas");