Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/context.c
| Show First 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | struct { | ||||
| struct wmWindow *window; | struct wmWindow *window; | ||||
| struct WorkSpace *workspace; | struct WorkSpace *workspace; | ||||
| struct bScreen *screen; | struct bScreen *screen; | ||||
| struct ScrArea *area; | struct ScrArea *area; | ||||
| struct ARegion *region; | struct ARegion *region; | ||||
| struct ARegion *menu; | struct ARegion *menu; | ||||
| struct wmGizmoGroup *gizmo_group; | struct wmGizmoGroup *gizmo_group; | ||||
| struct bContextStore *store; | struct bContextStore *store; | ||||
| const char *operator_poll_msg; /* reason for poll failing */ | |||||
| /* Operator poll. */ | |||||
| /** | |||||
| * Store the reason the poll function fails (static string, not allocated). | |||||
| * For more advanced formatting use `operator_poll_msg_dyn_params`. | |||||
| */ | |||||
| const char *operator_poll_msg; | |||||
| /** | |||||
| * Store values to dynamically to create the string (called when a tool-tip is shown). | |||||
| */ | |||||
| struct bContextPollMsgDyn_Params operator_poll_msg_dyn_params; | |||||
| } wm; | } wm; | ||||
| /* data context */ | /* data context */ | ||||
| struct { | struct { | ||||
| struct Main *main; | struct Main *main; | ||||
| struct Scene *scene; | struct Scene *scene; | ||||
| int recursion; | int recursion; | ||||
| Show All 16 Lines | bContext *CTX_create(void) | ||||
| return C; | return C; | ||||
| } | } | ||||
| bContext *CTX_copy(const bContext *C) | bContext *CTX_copy(const bContext *C) | ||||
| { | { | ||||
| bContext *newC = MEM_dupallocN((void *)C); | bContext *newC = MEM_dupallocN((void *)C); | ||||
| memset(&newC->wm.operator_poll_msg_dyn_params, 0, sizeof(newC->wm.operator_poll_msg_dyn_params)); | |||||
| return newC; | return newC; | ||||
| } | } | ||||
| void CTX_free(bContext *C) | void CTX_free(bContext *C) | ||||
| { | { | ||||
| /* This may contain a dynamically allocated message, free. */ | |||||
| CTX_wm_operator_poll_msg_clear(C); | |||||
| MEM_freeN(C); | MEM_freeN(C); | ||||
| } | } | ||||
| /* store */ | /* store */ | ||||
| bContextStore *CTX_store_add(ListBase *contexts, const char *name, const PointerRNA *ptr) | bContextStore *CTX_store_add(ListBase *contexts, const char *name, const PointerRNA *ptr) | ||||
| { | { | ||||
| /* ensure we have a context to put the entry in, if it was already used | /* ensure we have a context to put the entry in, if it was already used | ||||
| ▲ Show 20 Lines • Show All 869 Lines • ▼ Show 20 Lines | void CTX_wm_menu_set(bContext *C, ARegion *menu) | ||||
| C->wm.menu = menu; | C->wm.menu = menu; | ||||
| } | } | ||||
| void CTX_wm_gizmo_group_set(bContext *C, struct wmGizmoGroup *gzgroup) | void CTX_wm_gizmo_group_set(bContext *C, struct wmGizmoGroup *gzgroup) | ||||
| { | { | ||||
| C->wm.gizmo_group = gzgroup; | C->wm.gizmo_group = gzgroup; | ||||
| } | } | ||||
| void CTX_wm_operator_poll_msg_clear(bContext *C) | |||||
| { | |||||
| struct bContextPollMsgDyn_Params *params = &C->wm.operator_poll_msg_dyn_params; | |||||
| if (params->free_fn != NULL) { | |||||
| params->free_fn(C, params->user_data); | |||||
| } | |||||
| params->get_fn = NULL; | |||||
| params->free_fn = NULL; | |||||
| params->user_data = NULL; | |||||
| C->wm.operator_poll_msg = NULL; | |||||
| } | |||||
| void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg) | void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg) | ||||
| { | { | ||||
| CTX_wm_operator_poll_msg_clear(C); | |||||
| C->wm.operator_poll_msg = msg; | C->wm.operator_poll_msg = msg; | ||||
| } | } | ||||
| const char *CTX_wm_operator_poll_msg_get(bContext *C) | void CTX_wm_operator_poll_msg_set_dynamic(bContext *C, | ||||
| const struct bContextPollMsgDyn_Params *params) | |||||
| { | { | ||||
| CTX_wm_operator_poll_msg_clear(C); | |||||
| C->wm.operator_poll_msg_dyn_params = *params; | |||||
| } | |||||
| const char *CTX_wm_operator_poll_msg_get(bContext *C, bool *r_free) | |||||
| { | |||||
| struct bContextPollMsgDyn_Params *params = &C->wm.operator_poll_msg_dyn_params; | |||||
| if (params->get_fn != NULL) { | |||||
| char *msg = params->get_fn(C, params->user_data); | |||||
| if (msg != NULL) { | |||||
| *r_free = true; | |||||
| } | |||||
| return msg; | |||||
| } | |||||
| *r_free = false; | |||||
| return IFACE_(C->wm.operator_poll_msg); | return IFACE_(C->wm.operator_poll_msg); | ||||
| } | } | ||||
| /* data context */ | /* data context */ | ||||
| Main *CTX_data_main(const bContext *C) | Main *CTX_data_main(const bContext *C) | ||||
| { | { | ||||
| Main *bmain; | Main *bmain; | ||||
| ▲ Show 20 Lines • Show All 417 Lines • Show Last 20 Lines | |||||