12 #include "../generic/py_capi_rna.h"
13 #include "../generic/python_utildefines.h"
19 #include "RNA_prototypes.h"
47 PyObject *cb_func, *cb_args, *
result;
48 PyGILState_STATE gilstate;
52 cb_func = PyTuple_GET_ITEM((PyObject *)customdata, 1);
53 cb_args = PyTuple_GET_ITEM((PyObject *)customdata, 2);
54 result = PyObject_CallObject(cb_func, cb_args);
70 PyObject *dst = PyTuple_New(len_dst);
71 const int len_src = PyTuple_GET_SIZE(
src);
73 for (
int i = 0; i < len_src; i++) {
74 PyObject *item = PyTuple_GET_ITEM(
src, i);
75 PyTuple_SET_ITEM(dst, i, item);
83 PyObject *cb_func, *cb_args, *
result;
84 PyGILState_STATE gilstate;
88 cb_func = PyTuple_GET_ITEM((PyObject *)customdata, 1);
89 cb_args = PyTuple_GET_ITEM((PyObject *)customdata, 2);
91 const int cb_args_len = PyTuple_GET_SIZE(cb_args);
93 PyObject *cb_args_xy = PyTuple_New(2);
97 PyTuple_SET_ITEM(cb_args_with_xy, cb_args_len, cb_args_xy);
99 result = PyObject_CallObject(cb_func, cb_args_with_xy);
101 Py_DECREF(cb_args_with_xy);
115 PyObject *pyrna_callback_add(
BPy_StructRNA *
self, PyObject *args)
119 PyObject *cb_func, *cb_args;
120 char *cb_event_str =
NULL;
123 if (!PyArg_ParseTuple(args,
124 "OO!|s:bpy_struct.callback_add",
132 if (!PyCallable_Check(cb_func)) {
133 PyErr_SetString(PyExc_TypeError,
"callback_add(): first argument isn't callable");
154 PyErr_SetString(PyExc_TypeError,
"callback_add(): type does not support callbacks");
161 PyObject *pyrna_callback_remove(
BPy_StructRNA *
self, PyObject *args)
167 if (!PyArg_ParseTuple(args,
"O!:callback_remove", &PyCapsule_Type, &py_handle)) {
173 if (handle ==
NULL) {
174 PyErr_SetString(PyExc_ValueError,
175 "callback_remove(handle): NULL handle given, invalid or already removed");
180 customdata = ED_region_draw_cb_customdata(handle);
181 Py_DECREF((PyObject *)customdata);
186 PyErr_SetString(PyExc_TypeError,
"callback_remove(): type does not support callbacks");
200 if (srna == &RNA_SpaceView3D) {
203 if (srna == &RNA_SpaceGraphEditor) {
206 if (srna == &RNA_SpaceOutliner) {
209 if (srna == &RNA_SpaceProperties) {
212 if (srna == &RNA_SpaceFileBrowser) {
215 if (srna == &RNA_SpaceImageEditor) {
218 if (srna == &RNA_SpaceInfo) {
221 if (srna == &RNA_SpaceSequenceEditor) {
224 if (srna == &RNA_SpaceTextEditor) {
227 if (srna == &RNA_SpaceDopeSheetEditor) {
230 if (srna == &RNA_SpaceNLA) {
233 if (srna == &RNA_SpaceNodeEditor) {
236 if (srna == &RNA_SpaceConsole) {
239 if (srna == &RNA_SpacePreferences) {
242 if (srna == &RNA_SpaceClipEditor) {
245 if (srna == &RNA_SpaceSpreadsheet) {
253 PyObject *args = PyCapsule_GetContext(capsule);
261 PyObject *cb_func, *cb_args;
264 if (PyTuple_GET_SIZE(args) < 2) {
265 PyErr_SetString(PyExc_ValueError,
"handler_add(handler): expected at least 2 args");
269 cls = PyTuple_GET_ITEM(args, 0);
273 cb_func = PyTuple_GET_ITEM(args, 1);
274 if (!PyCallable_Check(cb_func)) {
275 PyErr_SetString(PyExc_TypeError,
"first argument isn't callable");
281 if (srna == &RNA_WindowManager) {
290 if (!PyArg_ParseTuple(args,
291 "OOO!|O&O&:WindowManager.draw_cursor_add",
299 &
params.region_type_enum)) {
304 params.region_type_enum.value,
318 if (!PyArg_ParseTuple(args,
319 "OOO!O&O&:Space.draw_handler_add",
341 PyExc_TypeError,
"region type %R not in space",
params.region_type_enum.value_orig);
348 PyErr_SetString(PyExc_TypeError,
"callback_add(): type does not support callbacks");
360 PyCapsule_SetContext(
ret, args);
372 bool capsule_clear =
false;
373 bool handle_removed =
false;
375 if (PyTuple_GET_SIZE(args) < 2) {
376 PyErr_SetString(PyExc_ValueError,
"callback_remove(handler): expected at least 2 args");
380 cls = PyTuple_GET_ITEM(args, 0);
384 py_handle = PyTuple_GET_ITEM(args, 1);
386 if (handle ==
NULL) {
387 PyErr_SetString(PyExc_ValueError,
388 "callback_remove(handler): NULL handler given, invalid or already removed");
392 if (srna == &RNA_WindowManager) {
393 if (!PyArg_ParseTuple(
394 args,
"OO!:WindowManager.draw_cursor_remove", &cls, &PyCapsule_Type, &py_handle)) {
398 capsule_clear =
true;
401 const char *error_prefix =
"Space.draw_handler_remove";
408 if (!PyArg_ParseTuple(args,
409 "OO!O&:Space.draw_handler_remove",
414 &
params.region_type_enum)) {
420 PyErr_Format(PyExc_TypeError,
421 "%s: unknown space type '%.200s'",
430 PyErr_Format(PyExc_TypeError,
431 "%s: region type %R not in space",
433 params.region_type_enum.value_orig);
437 capsule_clear =
true;
440 PyErr_SetString(PyExc_TypeError,
"callback_remove(): type does not support callbacks");
447 if (handle_removed ==
true) {
449 PyObject *handle_args = PyCapsule_GetContext(py_handle);
450 Py_DECREF(handle_args);
455 PyCapsule_Destructor destructor_fn = PyCapsule_GetDestructor(py_handle);
457 destructor_fn(py_handle);
458 PyCapsule_SetDestructor(py_handle,
NULL);
472 PyObject *tuple = customdata;
475 PyGILState_STATE gilstate;
477 gilstate = PyGILState_Ensure();
483 PyGILState_Release(gilstate);
struct SpaceType * BKE_spacetype_from_id(int spaceid)
struct ARegionType * BKE_regiontype_from_id(const struct SpaceType *st, int regionid)
#define REGION_DRAW_POST_VIEW
#define REGION_DRAW_BACKDROP
void * ED_region_draw_cb_activate(struct ARegionType *art, void(*draw)(const struct bContext *, struct ARegion *, void *), void *customdata, int type)
void ED_region_draw_cb_remove_by_type(struct ARegionType *art, void *draw_fn, void(*free)(void *))
#define REGION_DRAW_POST_PIXEL
bool ED_region_draw_cb_exit(struct ARegionType *art, void *handle)
#define REGION_DRAW_PRE_VIEW
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
void bpy_context_clear(struct bContext *C, const PyGILState_STATE *gilstate)
void bpy_context_set(struct bContext *C, PyGILState_STATE *gilstate)
StructRNA * pyrna_struct_as_srna(PyObject *self, const bool parent, const char *error_prefix)
static eSpace_Type rna_Space_refine_reverse(StructRNA *srna)
static const char * rna_capsual_id_invalid
PyObject * pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *args)
static PyObject * PyC_Tuple_CopySized(PyObject *src, int len_dst)
static void cb_customdata_free(void *customdata)
static void cb_region_draw(const bContext *C, ARegion *UNUSED(region), void *customdata)
static void cb_rna_capsule_destructor(PyObject *capsule)
static void cb_wm_cursor_draw(bContext *C, int x, int y, void *customdata)
void BPY_callback_screen_free(struct ARegionType *art)
PyObject * pyrna_callback_classmethod_add(PyObject *UNUSED(self), PyObject *args)
static const EnumPropertyItem region_draw_mode_items[]
static const char * rna_capsual_id
void BPY_callback_wm_free(struct wmWindowManager *wm)
SyclQueue void void * src
static const pxr::TfToken st("st", pxr::TfToken::Immortal)
int pyrna_enum_value_from_id(const EnumPropertyItem *item, const char *identifier, int *r_value, const char *error_prefix)
int pyrna_enum_value_parse_string(PyObject *o, void *p)
#define PyTuple_SET_ITEMS(op_arg,...)
const char * RNA_struct_identifier(const StructRNA *type)
bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
const EnumPropertyItem rna_enum_region_type_items[]
const EnumPropertyItem rna_enum_space_type_items[]
bool WM_paint_cursor_end(wmPaintCursor *handle)
void WM_paint_cursor_remove_by_type(wmWindowManager *wm, void *draw_fn, void(*free)(void *))
wmPaintCursor * WM_paint_cursor_activate(short space_type, short region_type, bool(*poll)(bContext *C), wmPaintCursorDraw draw, void *customdata)