diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-05-02 11:24:14 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-05-02 12:03:03 +0300 |
commit | 9b21055dfbfb85c85bffd23678616c55de5ddc79 (patch) | |
tree | a3541f1929d3a4ee406504b91eb89a94f48855f6 /source/blender/windowmanager/intern | |
parent | 3def6c7f8e9a6c81947d41f6d5d4d79530a688a2 (diff) |
WM: utility to check if an operator will draw a UI
Checking if a redo operator will show something is needed
to avoid empty redo popover.
Diffstat (limited to 'source/blender/windowmanager/intern')
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index a64b633b000..6e75260c466 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -614,6 +614,39 @@ int WM_operator_poll_context(bContext *C, wmOperatorType *ot, short context) return wm_operator_call_internal(C, ot, NULL, NULL, context, true); } +bool WM_operator_check_ui_empty(wmOperatorType *ot) +{ + if (ot->macro.first != NULL) { + /* for macros, check all have exec() we can call */ + wmOperatorTypeMacro *otmacro; + for (otmacro = ot->macro.first; otmacro; otmacro = otmacro->next) { + wmOperatorType *otm = WM_operatortype_find(otmacro->idname, 0); + if (otm && !WM_operator_check_ui_empty(otm)) { + return false; + } + } + return true; + } + + /* Assume a ui callback will draw something. */ + if (ot->ui) { + return false; + } + + PointerRNA ptr; + WM_operator_properties_create_ptr(&ptr, ot); + RNA_STRUCT_BEGIN (&ptr, prop) + { + int flag = RNA_property_flag(prop); + if (flag & PROP_HIDDEN) { + continue; + } + return false; + } + RNA_STRUCT_END; + return true; +} + /** * Sets the active region for this space from the context. * |