Extending Atoms UI and Variation UI buttons

Users can add buttons to the Atoms UI (next to the "Remove" button on top of the item lists).


Atoms UI

For the Atoms UI, a dictionary can be populated before the Atoms UI is opened.
The keys for the dictionaries must be event types like EVENT_TYPES.AGENT_TYPE_EVENT, the values should be a list of lists/tuples. The first element of the list/tuple should be the button name, while the second should be a callback.
The callback will receive the following arguments: the event type, the atoms node hostbridge and the event wrapper widget (i.e. the agent type or animation clip widgets).

def my_callback(event_type, host_bridge, event_wrapper_widget):
    print(event_type, host_bridge, event_wrapper_widget)

from Atoms.ui.constants import ATOMS_UI_USER_BUTTONS
from Atoms.constants import EVENT_TYPES
ATOMS_UI_USER_BUTTONS[EVENT_TYPES.AGENT_TYPE_EVENT] = [["AT_Button", my_callback]]
ATOMS_UI_USER_BUTTONS[EVENT_TYPES.ANIMATION_CLIP_EVENT] = [["AC_Button", my_callback]]

Variation UI

For the Variation UI, the workflow is essentially the same. The main difference is that the VARIATION_UI_USER_BUTTONS is a list and not a dict.
def my_callback(host_bridge, event_wrapper_widget):
    print(host_bridge, event_wrapper_widget)

from Atoms.ui.constants import VARIATION_UI_USER_BUTTONS
VARIATION_UI_USER_BUTTONS.append(["V_Button", my_callback])
    

Copyright © 2017, Toolchefs LTD.