1 /* 2 * This program is free software; you can redistribute it and/or 3 * modify it under the terms of the GNU General Public License 4 * as published by the Free Software Foundation; either version 2 5 * of the License, or (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software Foundation, 14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 15 */ 16 17 /** \file 18 * \ingroup bke 19 */ 20 21 #pragma once 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 struct Depsgraph; 28 struct ID; 29 struct Main; 30 struct PointerRNA; 31 32 /** 33 * Common suffix uses: 34 * - ``_PRE/_POST``: 35 * For handling discrete non-interactive events. 36 * - ``_INIT/_COMPLETE/_CANCEL``: 37 * For handling jobs (which may in turn cause other handlers to be called). 38 */ 39 typedef enum { 40 BKE_CB_EVT_FRAME_CHANGE_PRE, 41 BKE_CB_EVT_FRAME_CHANGE_POST, 42 BKE_CB_EVT_RENDER_PRE, 43 BKE_CB_EVT_RENDER_POST, 44 BKE_CB_EVT_RENDER_WRITE, 45 BKE_CB_EVT_RENDER_STATS, 46 BKE_CB_EVT_RENDER_INIT, 47 BKE_CB_EVT_RENDER_COMPLETE, 48 BKE_CB_EVT_RENDER_CANCEL, 49 BKE_CB_EVT_LOAD_PRE, 50 BKE_CB_EVT_LOAD_POST, 51 BKE_CB_EVT_SAVE_PRE, 52 BKE_CB_EVT_SAVE_POST, 53 BKE_CB_EVT_UNDO_PRE, 54 BKE_CB_EVT_UNDO_POST, 55 BKE_CB_EVT_REDO_PRE, 56 BKE_CB_EVT_REDO_POST, 57 BKE_CB_EVT_DEPSGRAPH_UPDATE_PRE, 58 BKE_CB_EVT_DEPSGRAPH_UPDATE_POST, 59 BKE_CB_EVT_VERSION_UPDATE, 60 BKE_CB_EVT_LOAD_FACTORY_USERDEF_POST, 61 BKE_CB_EVT_LOAD_FACTORY_STARTUP_POST, 62 BKE_CB_EVT_TOT, 63 } eCbEvent; 64 65 typedef struct bCallbackFuncStore { 66 struct bCallbackFuncStore *next, *prev; 67 void (*func)(struct Main *, struct PointerRNA **, const int num_pointers, void *arg); 68 void *arg; 69 short alloc; 70 } bCallbackFuncStore; 71 72 void BKE_callback_exec(struct Main *bmain, 73 struct PointerRNA **pointers, 74 const int num_pointers, 75 eCbEvent evt); 76 void BKE_callback_exec_null(struct Main *bmain, eCbEvent evt); 77 void BKE_callback_exec_id(struct Main *bmain, struct ID *id, eCbEvent evt); 78 void BKE_callback_exec_id_depsgraph(struct Main *bmain, 79 struct ID *id, 80 struct Depsgraph *depsgraph, 81 eCbEvent evt); 82 void BKE_callback_add(bCallbackFuncStore *funcstore, eCbEvent evt); 83 84 void BKE_callback_global_init(void); 85 void BKE_callback_global_finalize(void); 86 87 #ifdef __cplusplus 88 } 89 #endif 90