# the_machinery.h ## Overview
API for interacting with The Machinery editor.
## Index
`THE_MACHINERY_VERSION`

Truth types
`TM_TT_TYPE__APPLICATION_SETTINGS`
`enum TM_TT_PROP__APPLICATION_SETTINGS`
`TM_TT_TYPE__PROJECT_MANAGEMENT_SETTINGS`
`enum TM_TT_PROP__PROJECT_MANAGEMENT_SETTINGS`
`TM_TT_TYPE__INTERFACE_SETTINGS`
`enum TM_TT_PROP__INTERFACE_SETTINGS`
`TM_TT_TYPE__WINDOW_LAYOUTS`
`enum TM_TT_PROP__WINDOW_LAYOUTS`
`TM_TT_TYPE__WINDOW_LAYOUT`
`enum TM_TT_PROP__WINDOW_LAYOUT`
`TM_TT_TYPE__WORKSPACE`
`enum TM_TT_PROP__WORKSPACE`
`TM_TT_TYPE__RECENT_FILE`
`enum TM_TT_PROP__RECENT_FILE`
`TM_TT_TYPE__PUBLISH_SETTINGS`
`enum TM_TT_PROP__PUBLISH_SETTINGS`
`TM_TT_TYPE__APPLICATION_SECURITY`
`enum TM_TT_PROP__APPLICATION_SECURITY`
`TM_TT_TYPE__PROJECT_SETTINGS`
`enum TM_TT_PROP__PROJECT_SETTINGS`
`TM_TT_TYPE__NETWORK_SETTINGS`
`enum TM_TT_PROP__NETWORK_SETTINGS`
`TM_TT_TYPE__LOCALIZATION_SETTINGS`
`enum TM_TT_PROP__LOCALIZATION_SETTINGS`
`tm_the_machinery_project_callback_i`
`tm_the_machinery_project_callback_i_version`
`tm_the_machinery_project_loaded_i`
`tm_the_machinery_project_unloaded_i`
`tm_the_machinery_project_saved_i`

`struct tm_the_machinery_api`
`app`
`open_asset()`
`get_asset_root()`
`reimport_asset()`
`create_or_select_tab()`
`window_for_ui()`
`collaboration()`
`collaboration_p2p()`
`collaboration_discord()`
`settings()`
`project_settings()`
`open_project()`

Used by integration tests
`open_any_project()`
`save_to_asset_database()`
`import_asset()`
`save_all()`
`get_truth()`
`new_project()`

`tm_the_machinery_api_version`
`tm_the_machinery_create_layout_i`
`tm_the_machinery_create_layout_i_version`
## API
### `THE_MACHINERY_VERSION`
~~~c #define THE_MACHINERY_VERSION "2021.11.a" ~~~ Current version of The Machinery.

Truth types

### `TM_TT_TYPE__APPLICATION_SETTINGS`
~~~c #define TM_TT_TYPE__APPLICATION_SETTINGS "tm_application_settings" #define TM_TT_TYPE_HASH__APPLICATION_SETTINGS TM_STATIC_HASH("tm_application_settings", 0x398c20b061fe24b9ULL) ~~~ Truth type used to store application settings.
### `enum TM_TT_PROP__APPLICATION_SETTINGS`
Properties for `TM_TT_TYPE__APPLICATION_SETTINGS`. ~~~c enum { TM_TT_PROP__APPLICATION_SETTINGS__ANALYTICS_CLIENT_ID, // string TM_TT_PROP__APPLICATION_SETTINGS__ANALYTICS_OPT_OUT, // bool TM_TT_PROP__APPLICATION_SETTINGS__CAMERA_SETTINGS, // subobject [[TM_TT_TYPE__CAMERA_COMPONENT]] TM_TT_PROP__APPLICATION_SETTINGS__NETWORK_SETTINGS, // subobject [[TM_TT_TYPE__NETWORK_SETTINGS]] TM_TT_PROP__APPLICATION_SETTINGS__GRID_SETTINGS, // subobject [[TM_TT_TYPE__GRID_SETTINGS]] TM_TT_PROP__APPLICATION_SETTINGS__WINDOW_LAYOUTS, // subobject [[TM_TT_TYPE__WINDOW_LAYOUTS]] TM_TT_PROP__APPLICATION_SETTINGS__RECENT_FILES, // subobject_set [[TM_TT_TYPE__RECENT_FILE]] TM_TT_PROP__APPLICATION_SETTINGS__INTERFACE_SETTINGS, // subobject [[TM_TT_TYPE__INTERFACE_SETTINGS]] TM_TT_PROP__APPLICATION_SETTINGS__LOCALIZATION_SETTINGS, // subobject [[TM_TT_TYPE__LOCALIZATION_SETTINGS]] // Shortcuts for the application. TM_TT_PROP__APPLICATION_SETTINGS__KEYBOARD_SHORTCUTS, // subobject [[TM_TT_TYPE__SHORTCUTS_INDEX]] // UI themes for the application. TM_TT_PROP__APPLICATION_SETTINGS__UI_THEMES, // subobject_set [[TM_TT_TYPE__UI_THEME]] // Current UI theme. If the current UI theme is one of the default built-in themes, this // reference will be 0 and `BUILTIN_UI_THEME` will indicate the built-in UI theme to use. TM_TT_PROP__APPLICATION_SETTINGS__UI_THEME, // reference [[TM_TT_TYPE__UI_THEME]] // Built-in UI theme to use. If `UI_THEME` is non-zero, this value is ignored. TM_TT_PROP__APPLICATION_SETTINGS__BUILTIN_UI_THEME, // uint32_t // Workspace bar mode. TM_TT_PROP__APPLICATION_SETTINGS__WORKSPACES_BAR_MODE, // uint32_t // Project-specific application settings, i.e. per-user-per-project settings. TM_TT_PROP__APPLICATION_SETTINGS__PROJECTS_SETTINGS, // subobject_set [[TM_TT_TYPE__PROJECT_SETTINGS]] TM_TT_PROP__APPLICATION_SETTINGS__UPDATES, // subobject [[TM_TT_TYPE__APPLICATION_SETTINGS__UPDATES]] // Records all the files that have been downloaded through the Download tab. TM_TT_PROP__APPLICATION_SETTINGS__DOWNLOADS, // subobject_set [[TM_TT_TYPE__APPLICATION_SETTINGS__DOWNLOAD]] TM_TT_PROP__APPLICATION_SETTINGS__LAST_OPENED_PROJECT, // string TM_TT_PROP__APPLICATION_SETTINGS__DOCKING_SETTINGS, // subobject [[TM_TT_TYPE__DOCKING_SETTINGS]] TM_TT_PROP__APPLICATION_SETTINGS__PROJECT_MANAGEMENT, // subobject [[TM_TT_TYPE__PROJECT_MANAGEMENT_SETTINGS]] // Security settings for the application. TM_TT_PROP__APPLICATION_SETTINGS__SECURITY, // subobject [[TM_TT_TYPE__APPLICATION_SECURITY]] // Hold plugins settings managed by `tm_settings_api` TM_TT_PROP__APPLICATION_SETTINGS__PLUGINS_SETTINGS, // subobject [[TM_TT_TYPE__SETTINGS]] }; ~~~
### `TM_TT_TYPE__PROJECT_MANAGEMENT_SETTINGS`
~~~c #define TM_TT_TYPE__PROJECT_MANAGEMENT_SETTINGS "tm_project_management_settings" #define TM_TT_TYPE_HASH__PROJECT_MANAGEMENT_SETTINGS TM_STATIC_HASH("tm_project_management_settings", 0x8b8a016cc0d8f90fULL) ~~~ Truth type for storing settings related to project management.
### `enum TM_TT_PROP__PROJECT_MANAGEMENT_SETTINGS`
Properties for `TM_TT_TYPE__PROJECT_MANAGEMENT_SETTINGS`. ~~~c enum { TM_TT_PROP__PROJECT_MANAGEMENT_SETTINGS__OPEN_EMPTY_PROJECT_ON_STARTUP, // bool TM_TT_PROP__PROJECT_MANAGEMENT_SETTINGS__ALWAYS_OPEN_DEFAULT_PROJECT_WINDOW, // bool }; ~~~
### `TM_TT_TYPE__INTERFACE_SETTINGS`
~~~c #define TM_TT_TYPE__INTERFACE_SETTINGS "tm_interface_settings" #define TM_TT_TYPE_HASH__INTERFACE_SETTINGS TM_STATIC_HASH("tm_interface_settings", 0xd2e5a5bb1c32c070ULL) ~~~ Truth type for storing interface settings.
### `enum TM_TT_PROP__INTERFACE_SETTINGS`
Properties for `TM_TT_TYPE__INTERFACE_SETTINGS`. ~~~c enum { // User defined scale factor for user interface. TM_TT_PROP__INTERFACE_SETTINGS__RESOLUTION_SCALE, // float TM_TT_PROP__INTERFACE_SETTINGS__WHEEL_SCROLL_LINES, // float TM_TT_PROP__INTERFACE_SETTINGS__COLOR_BLIND_MODE, // bool TM_TT_PROP__INTERFACE_SETTINGS__THROTTLE_IN_BACKGROUND, // bool }; ~~~
### `TM_TT_TYPE__WINDOW_LAYOUTS`
~~~c #define TM_TT_TYPE__WINDOW_LAYOUTS "tm_window_layouts" #define TM_TT_TYPE_HASH__WINDOW_LAYOUTS TM_STATIC_HASH("tm_window_layouts", 0xad48e16db7ef5b35ULL) ~~~ Truth type for storing window layouts.
### `enum TM_TT_PROP__WINDOW_LAYOUTS`
Properties for `TM_TT_TYPE__WINDOW_LAYOUTS`. ~~~c enum { TM_TT_PROP__WINDOW_LAYOUTS__LAYOUTS, // subobject_set [[TM_TT_TYPE__WINDOW_LAYOUT]] }; ~~~
### `TM_TT_TYPE__WINDOW_LAYOUT`
~~~c #define TM_TT_TYPE__WINDOW_LAYOUT "tm_window_layout" #define TM_TT_TYPE_HASH__WINDOW_LAYOUT TM_STATIC_HASH("tm_window_layout", 0x1f1ea8c1548bab03ULL) ~~~ Truth type for storing the layout of a single window.
### `enum TM_TT_PROP__WINDOW_LAYOUT`
Properties of `TM_TT_TYPE__WINDOW_LAYOUT`. ~~~c enum { TM_TT_PROP__WINDOW_LAYOUT__NAME, // string TM_TT_PROP__WINDOW_LAYOUT__ICON, // uint32_t TM_TT_PROP__WINDOW_LAYOUT__WINDOW_X, // float TM_TT_PROP__WINDOW_LAYOUT__WINDOW_Y, // float TM_TT_PROP__WINDOW_LAYOUT__WINDOW_WIDTH, // float TM_TT_PROP__WINDOW_LAYOUT__WINDOW_HEIGHT, // float TM_TT_PROP__WINDOW_LAYOUT__WINDOW_MAXIMIZED, // bool // The tabs of the window can either be stored in a single tabwell object or in a set of // workspace objects. TM_TT_PROP__WINDOW_LAYOUT__TABWELL, // subobject [[TM_TT_TYPE__TABWELL]] TM_TT_PROP__WINDOW_LAYOUT__WORKSPACES, // subobject_set [[TM_TT_TYPE__WORKSPACE]] }; ~~~
### `TM_TT_TYPE__WORKSPACE`
~~~c #define TM_TT_TYPE__WORKSPACE "tm_workspace" #define TM_TT_TYPE_HASH__WORKSPACE TM_STATIC_HASH("tm_workspace", 0xcdcdce9f19a8aef1ULL) ~~~ Truth type for storing the setup of a workspace.
### `enum TM_TT_PROP__WORKSPACE`
Properties of `TM_TT_TYPE__WORKSPACE`. ~~~c enum { TM_TT_PROP__WORKSPACE__NAME, // string TM_TT_PROP__WORKSPACE__ICON, // uint32_t TM_TT_PROP__WORKSPACE__TABWELL, // subobject [[TM_TT_TYPE__TABWELL]] }; ~~~
### `TM_TT_TYPE__RECENT_FILE`
~~~c #define TM_TT_TYPE__RECENT_FILE "tm_recent_file" #define TM_TT_TYPE_HASH__RECENT_FILE TM_STATIC_HASH("tm_recent_file", 0xba4e5d5c28639596ULL) ~~~ Truth type for storing the recent file list.
### `enum TM_TT_PROP__RECENT_FILE`
Properties of `TM_TT_TYPE__RECENT_FILE`. ~~~c enum { TM_TT_PROP__RECENT_FILE__PATH, // string TM_TT_PROP__RECENT_FILE__TIME_STAMP, // uint64_t }; ~~~
### `TM_TT_TYPE__PUBLISH_SETTINGS`
~~~c #define TM_TT_TYPE__PUBLISH_SETTINGS "tm_publish_settings" #define TM_TT_TYPE_HASH__PUBLISH_SETTINGS TM_STATIC_HASH("tm_publish_settings", 0x8eebe36bc038a3ccULL) ~~~ Truth types that stores the settings for the publish tab.
### `enum TM_TT_PROP__PUBLISH_SETTINGS`
Properties of `TM_TT_TYPE__PUBLISH_SETTINGS`. ~~~c enum { // If true, the project data will be saved as a directory project TM_TT_PROP__PUBLISH_SETTINGS__DIRECTORY_PROJECT, // bool // The name of the executable. TM_TT_PROP__PUBLISH_SETTINGS__EXECUTABLE_NAME, // string // The title of the application window. TM_TT_PROP__PUBLISH_SETTINGS__WINDOW_TITLE, // string // The entity to use open when the runner loads the project. TM_TT_PROP__PUBLISH_SETTINGS__WORLD_ENTITY, // string // The default resolution of the window TM_TT_PROP__PUBLISH_SETTINGS__RESOLUTION, // vec2 // Fullscreen TM_TT_PROP__PUBLISH_SETTINGS__FULLSCREEN, // bool }; ~~~
### `TM_TT_TYPE__APPLICATION_SECURITY`
~~~c #define TM_TT_TYPE__APPLICATION_SECURITY "tm_application_security" #define TM_TT_TYPE_HASH__APPLICATION_SECURITY TM_STATIC_HASH("tm_application_security", 0xb0a29343c40c021fULL) ~~~ Truth type that stores security settings.
### `enum TM_TT_PROP__APPLICATION_SECURITY`
Properties of `TM_TT_TYPE__APPLICATION_SECURITY`. ~~~c enum { TM_TT_PROP__APPLICATION_SECURITY__ALWAYS_ALLOW_DLL_PROJECT_PATHS, // subobject_set [[TM_TT_TYPE__STRING]] TM_TT_PROP__APPLICATION_SECURITY__ALWAYS_DENY_DLL_PROJECT_PATHS, // subobject_set [[TM_TT_TYPE__STRING]] }; ~~~
### `TM_TT_TYPE__PROJECT_SETTINGS`
~~~c #define TM_TT_TYPE__PROJECT_SETTINGS "tm_project_settings" #define TM_TT_TYPE_HASH__PROJECT_SETTINGS TM_STATIC_HASH("tm_project_settings", 0xe1defaa0c3c62d2dULL) ~~~ Truth type that stores the settings for a particular project.
### `enum TM_TT_PROP__PROJECT_SETTINGS`
Properties of `TM_TT_TYPE__PROJECT_SETTINGS`. ~~~c enum { TM_TT_PROP__PROJECT_SETTINGS__PATH, // string TM_TT_PROP__PROJECT_SETTINGS__GLOBAL_GRAPH_SETTINGS, // subobject [[TM_TT_TYPE__GLOBAL_GRAPH_SETTINGS]] TM_TT_PROP__PROJECT_SETTINGS__GRAPHS_SETTINGS, // subobject_set [[TM_TT_TYPE__GRAPH_SETTINGS]] TM_TT_PROP__PROJECT_SETTINGS__SCENES_SETTINGS, // subobject_set [[TM_TT_TYPE__SCENE_SETTINGS]] TM_TT_PROP__PROJECT_SETTINGS__PUBLISH_SETTINGS, // subobject [[TM_TT_TYPE__PUBLISH_SETTINGS]] TM_TT_PROP__PROJECT_SETTINGS__WINDOW_LAYOUT, // subobject_set [[TM_TT_TYPE__WINDOW_LAYOUT]] TM_TT_PROP__PROJECT_SETTINGS__GRAPH_DEBUGGER_PERSISTENT_SETTINGS, // subobject [[TM_TT_TYPE__GRAPH_DEBUGGER_PERSISTENT_SETTINGS]] // Hold plugins settings managed by `tm_settings_api` TM_TT_PROP__PROJECT_SETTINGS__PLUGINS_SETTINGS, // subobject [[TM_TT_TYPE__SETTINGS]] }; ~~~
### `TM_TT_TYPE__NETWORK_SETTINGS`
~~~c #define TM_TT_TYPE__NETWORK_SETTINGS "tm_network_settings" #define TM_TT_TYPE_HASH__NETWORK_SETTINGS TM_STATIC_HASH("tm_network_settings", 0x395cfd1a7615a887ULL) ~~~ Truth type that stores network settings.
### `enum TM_TT_PROP__NETWORK_SETTINGS`
Properties of `TM_TT_TYPE__NETWORK_SETTINGS`. ~~~c enum { TM_TT_PROP__NETWORK_SETTINGS__NODE_INSTANCES, // subobject_set [[TM_TT_TYPE__NETWORK_NODE_INSTANCE]] }; ~~~
### `TM_TT_TYPE__LOCALIZATION_SETTINGS`
~~~c #define TM_TT_TYPE__LOCALIZATION_SETTINGS "tm_localization_settings" #define TM_TT_TYPE_HASH__LOCALIZATION_SETTINGS TM_STATIC_HASH("tm_localization_settings", 0xa9afaf1feec8f7aaULL) ~~~ Truth type that stores localization settings.
### `enum TM_TT_PROP__LOCALIZATION_SETTINGS`
~~~c enum { TM_TT_PROP__LOCALIZATION_SETTINGS__MICROSOFT_CACHE, // subobject_set [[TM_TT_TYPE__TRANSLATION_CACHE]] TM_TT_PROP__LOCALIZATION_SETTINGS__GOOGLE_CACHE, // subobject_set [[TM_TT_TYPE__TRANSLATION_CACHE]] TM_TT_PROP__LOCALIZATION_SETTINGS__LANGUAGE, // string TM_TT_PROP__LOCALIZATION_SETTINGS__USE_GOOGLE, // bool TM_TT_PROP__LOCALIZATION_SETTINGS__USE_MICROSOFT, // bool }; ~~~
### `tm_the_machinery_project_callback_i`
~~~c typedef void tm_the_machinery_project_callback_i(struct tm_application_o *app, struct tm_the_truth_o *truth, tm_tt_id_t asset_root); ~~~ Callback that gets invoked by `tm_the_machinery_project_loaded_i`, `tm_the_machinery_project_unloaded_i`, and `tm_the_machinery_project_saved_i`.
### `tm_the_machinery_project_callback_i_version`
~~~c #define tm_the_machinery_project_callback_i_version ~~~
### `tm_the_machinery_project_loaded_i`
~~~c typedef tm_the_machinery_project_callback_i tm_the_machinery_project_loaded_i; ~~~ This callback is invoked right after is loaded. The passed truth is the new truth. !!! WARNING: WARNING This callback does not guarantee that all background tasks are done at the time if invocation.
### `tm_the_machinery_project_unloaded_i`
~~~c typedef tm_the_machinery_project_callback_i tm_the_machinery_project_unloaded_i; ~~~ This callback is invoked right before the project is unloaded.Therefore the passed truth is still the old truth.
### `tm_the_machinery_project_saved_i`
~~~c typedef tm_the_machinery_project_callback_i tm_the_machinery_project_saved_i; ~~~ This callback is invoked right after the project has been saved.
### `struct tm_the_machinery_api`
API for interacting with The Machinery. #### `app` ~~~c struct tm_application_o *app; ~~~ #### `open_asset()` ~~~c void (*open_asset)(struct tm_application_o *app, struct tm_ui_o *ui, struct tm_tab_i *from_tab, tm_tt_id_t asset); ~~~ Opens an asset for editing. #### `get_asset_root()` ~~~c tm_tt_id_t (*get_asset_root)(struct tm_application_o *app); ~~~ Gets the `TM_TT_TYPE__ASSET_ROOT` object of the application. Thread-safe (unless we are in the middle of opening a new project). #### `reimport_asset()` ~~~c void (*reimport_asset)(struct tm_application_o *app, struct tm_ui_o *ui, struct tm_the_truth_o *tt, tm_tt_id_t asset); ~~~ Reimports an asset file into the existing DCC Asset object. Thread-safe. #### `create_or_select_tab()` ~~~c struct tm_tab_i *(*create_or_select_tab)(struct tm_application_o *app, struct tm_ui_o *ui, const char *vt_name, const struct tm_docking_find_tab_opt_t *opt); ~~~ Finds or creates a tab of the type specified by `vt_name` (matches `tm_tab_vt->name`). If `opt` is not NULL, the docking API is used to search for a matching tab of the specified type. If it exists, it is returned. Otherwise, a new tab is created. If `opt` is NULL, a new tab is created regardless of whether a matching tab exists. The new tab is created in the biggest tabwell in the `ui`. If you want to position it somewhere else, use `tm_docking_api->move_tab()` on the new tab to move it. #### `window_for_ui()` ~~~c struct tm_window_o *(*window_for_ui)(struct tm_application_o *app, const struct tm_ui_o *ui); ~~~ Fetches the opaque window object associated with the UI `ui`. Returns NULL if there is no match. Thread-safe to call from multi-thread tabs (or in any other situation where we can guarantee that windows are not being created or destroyed). Not thread-safe to call while windows may be created or destroyed. #### `collaboration()` ~~~c struct tm_collaboration_o *(*collaboration)(struct tm_application_o *app); ~~~ Returns the collaboration object for the application. #### `collaboration_p2p()` ~~~c struct tm_collaboration_p2p_o *(*collaboration_p2p)(struct tm_application_o *app); ~~~ #### `collaboration_discord()` ~~~c struct tm_collaboration_discord_o *(*collaboration_discord)(struct tm_application_o *app); ~~~ #### `settings()` ~~~c struct tm_the_truth_o *(*settings)(struct tm_application_o *app, tm_tt_id_t *id); ~~~ Returns The Truth used to store application settings and the id of the application settings object in `id`. Thread-safe. #### `project_settings()` ~~~c struct tm_the_truth_o *(*project_settings)(struct tm_application_o *app, tm_tt_id_t *id); ~~~ Returns The Truth used to store project-specific application settings and the id of the project settings object. Thread-safe. #### `open_project()` ~~~c bool (*open_project)(struct tm_application_o *app, struct tm_ui_o *ui, const char *path); ~~~ Opens the project at the specified `path`. The user will first be asked to save any current changes. If the user doesn't want to open the project, the function will return *false*.

Used by integration tests

#### `open_any_project()` ~~~c void (*open_any_project)(struct tm_application_o *app, const char *file); ~~~ Opens the specified project without first asking the user to save. #### `save_to_asset_database()` ~~~c void (*save_to_asset_database)(struct tm_application_o *app, const char *file); ~~~ Saves the project as an asset database to the specified path. #### `import_asset()` ~~~c void (*import_asset)(struct tm_application_o *app, const char *file, tm_tt_id_t reimport_into); ~~~ Imports the specified asset. #### `save_all()` ~~~c void (*save_all)(struct tm_application_o *app); ~~~ Saves all assets. #### `get_truth()` ~~~c struct tm_the_truth_o *(*get_truth)(struct tm_application_o *app); ~~~ Returns the truth used by the application. #### `new_project()` ~~~c void (*new_project)(struct tm_application_o *app); ~~~ Creates a new project.
### `tm_the_machinery_api_version`
~~~c #define tm_the_machinery_api_version ~~~
### `tm_the_machinery_create_layout_i`
~~~c typedef void tm_the_machinery_create_layout_i(struct tm_application_o *app); ~~~ Defines an interface for setting default windows layouts for The Machinery.
### `tm_the_machinery_create_layout_i_version`
~~~c #define tm_the_machinery_create_layout_i_version ~~~