diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-12-08 04:48:12 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-12-08 04:57:25 +0300 |
commit | 4a734325f754db25138aae990b2abdb5224ba172 (patch) | |
tree | 071c5528f288aa9f6d939ea0b789b963ff5a079b /release/scripts/modules/bl_app_override | |
parent | 237df2f86053e796da98c903185ec3d70ae13910 (diff) |
bl_app_override: support empty UI layout items
Returning None from ui_ignore functions creates empty labels,
allows removing items without breaking layout in some cases.
Diffstat (limited to 'release/scripts/modules/bl_app_override')
-rw-r--r-- | release/scripts/modules/bl_app_override/__init__.py | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/release/scripts/modules/bl_app_override/__init__.py b/release/scripts/modules/bl_app_override/__init__.py index 89cc8a0eb28..f17878b4822 100644 --- a/release/scripts/modules/bl_app_override/__init__.py +++ b/release/scripts/modules/bl_app_override/__init__.py @@ -77,7 +77,7 @@ def ui_draw_filter_register( return UILayout_Fake(ret) return dummy_func - elif attr in {"operator", "operator_menu_enum", "operator_enum"}: + elif attr in {"operator", "operator_menu_enum", "operator_enum", "operator_menu_hold"}: if ui_ignore_operator is None: return UILayout.__getattribute__(self, attr) @@ -85,10 +85,14 @@ def ui_draw_filter_register( def dummy_func(*args, **kw): # print("wrapped", attr) - if not ui_ignore_operator(args[0]): + ui_test = ui_ignore_operator(args[0]) + if ui_test is False: ret = real_func(*args, **kw) else: - # UILayout.__getattribute__(self, "label")() + if ui_test is None: + UILayout.__getattribute__(self, "label")("") + else: + assert(ui_test is True) # may need to be set ret = OperatorProperties_Fake() return ret @@ -102,9 +106,14 @@ def ui_draw_filter_register( def dummy_func(*args, **kw): # print("wrapped", attr) - if not ui_ignore_property(args[0].__class__.__name__, args[1]): + ui_test = ui_ignore_property(args[0].__class__.__name__, args[1]) + if ui_test is False: ret = real_func(*args, **kw) else: + if ui_test is None: + UILayout.__getattribute__(self, "label")("") + else: + assert(ui_test is True) ret = None return ret return dummy_func @@ -117,9 +126,14 @@ def ui_draw_filter_register( def dummy_func(*args, **kw): # print("wrapped", attr) - if not ui_ignore_menu(args[0]): + ui_test = ui_ignore_menu(args[0]) + if ui_test is False: ret = real_func(*args, **kw) else: + if ui_test is None: + UILayout.__getattribute__(self, "label")("") + else: + assert(ui_test is True) ret = None return ret return dummy_func @@ -132,10 +146,14 @@ def ui_draw_filter_register( def dummy_func(*args, **kw): # print("wrapped", attr) - if not ui_ignore_label(args[0] if args else kw.get("text", "")): + ui_test = ui_ignore_label(args[0] if args else kw.get("text", "")) + if ui_test is False: ret = real_func(*args, **kw) else: - # ret = real_func() + if ui_test is None: + real_func("") + else: + assert(ui_test is True) ret = None return ret return dummy_func |