Commit: eb0b3f04487efd764a251325c49e2b1c9b2c612e Author: Campbell Barton Date: Wed Mar 22 08:30:31 2017 +1100 Branches: app-templates https://developer.blender.org/rBeb0b3f04487efd764a251325c49e2b1c9b2c612e
Add menu filtering =================================================================== M release/scripts/modules/bl_app_override.py =================================================================== diff --git a/release/scripts/modules/bl_app_override.py b/release/scripts/modules/bl_app_override.py index 92478c4796..352ac95015 100644 --- a/release/scripts/modules/bl_app_override.py +++ b/release/scripts/modules/bl_app_override.py @@ -47,6 +47,7 @@ def ui_draw_filter_register( classes=None, filter_operator=None, filter_property=None, + filter_menu=None, filter_label=None, ): import bpy @@ -93,6 +94,7 @@ def ui_draw_filter_register( ret = OperatorProperties_Fake() return ret return dummy_func + elif attr in {"prop", "prop_enum"}: if filter_property is None: return UILayout.__getattribute__(self, attr) @@ -107,6 +109,22 @@ def ui_draw_filter_register( ret = None return ret return dummy_func + + elif attr == "menu": + if filter_menu is None: + return UILayout.__getattribute__(self, attr) + + real_func = UILayout.__getattribute__(self, attr) + + def dummy_func(*args, **kw): + # print("wrapped", attr) + if filter_menu(args[0]): + ret = real_func(*args, **kw) + else: + ret = None + return ret + return dummy_func + elif attr == "label": if filter_label is None: return UILayout.__getattribute__(self, attr) @@ -129,13 +147,6 @@ def ui_draw_filter_register( def operator(*args, **kw): return super().operator(*args, **kw) - def label(*args, **kw): - text = args[1] if args else kw["text"] - if filter_label(text): - return super().label(*args, **kw) - else: - return super().label(args[0], "") - def draw_override(func_orig, self_real, context): # simple, no wrapping _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs