diff options
author | jon denning <gfxcoder@gmail.com> | 2022-07-26 16:50:35 +0300 |
---|---|---|
committer | jon denning <gfxcoder@gmail.com> | 2022-07-26 16:50:35 +0300 |
commit | 66c6cf0d7120737a90c9762a38188f7d4d49ad01 (patch) | |
tree | 57b79123347290370daca35b4fdeb6b82714943b /source/blender | |
parent | c3bc53162a9daed39ddf8597a678c923db36fb8f (diff) |
Added operator to determine if operator is actively modal
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/makesrna/intern/rna_wm_api.c | 5 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 5 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_window.c | 16 |
3 files changed, 26 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index b82458c4442..c57583d0969 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -714,6 +714,11 @@ void RNA_api_window(StructRNA *srna) FunctionRNA *func; PropertyRNA *parm; + func = RNA_def_function(srna, "is_operator_modal", "WM_active_modal_operator_test"); + RNA_def_function_ui_description(func, "Test if an operator is actively running modal."); + parm = RNA_def_boolean(func, "result", 0, "", "Operator running modal"); + RNA_def_function_return(func, parm); + func = RNA_def_function(srna, "cursor_warp", "WM_cursor_warp"); parm = RNA_def_int(func, "x", 0, INT_MIN, INT_MAX, "", "", INT_MIN, INT_MAX); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 44c5b86857d..f7d67274766 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -311,6 +311,11 @@ void WM_paint_cursor_remove_by_type(struct wmWindowManager *wm, void WM_paint_cursor_tag_redraw(struct wmWindow *win, struct ARegion *region); /** + * Determines whether an operator is actively running modal. + */ +bool WM_active_modal_operator_test(struct wmWindow *win); + +/** * This function requires access to the GHOST_SystemHandle (g_system). */ void WM_cursor_warp(struct wmWindow *win, int x, int y); diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index a1ebe1fc76f..148b4419aaf 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -2001,6 +2001,22 @@ void WM_init_native_pixels(bool do_it) /** \} */ /* -------------------------------------------------------------------- */ +/** \name Operator API + * \{ */ + +bool WM_active_modal_operator_test(struct wmWindow *win) +{ + LISTBASE_FOREACH (wmEventHandler *, handler_base, &win->modalhandlers) { + if (handler_base->type == WM_HANDLER_TYPE_OP) { + return true; + } + } + return false; +} + +/** \} */ + +/* -------------------------------------------------------------------- */ /** \name Cursor API * \{ */ |