Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmarSquircleArt <mail@OmarEmara.dev>2020-08-17 14:43:19 +0300
committerOmarSquircleArt <mail@OmarEmara.dev>2020-08-17 14:43:19 +0300
commite14de692fc99b5e66d93c6240ec51410d087cf4d (patch)
treee3b641aab70cb462163fc56d7635dd21856e26d5 /release/scripts/modules/nodeitems_utils.py
parent8fda93a4058ac4437d53279c909a44f8eb5b881c (diff)
UI: Only draw node menu search if categories exist
Currently, the search operator in the node add menu NODE_MT_add is drawn even if no node categories exists. This patch only draws the operator if at least one node category passes the poll. This patch is needed because some add-ons use custom search operator and do not register node categories. In this case, it is undesirable to have a search operator drawn that do nothing and is not used. One such add-on is Animation Nodes. Reviewed By: Jacques Lucke Differential Revision: https://developer.blender.org/D8576
Diffstat (limited to 'release/scripts/modules/nodeitems_utils.py')
-rw-r--r--release/scripts/modules/nodeitems_utils.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/release/scripts/modules/nodeitems_utils.py b/release/scripts/modules/nodeitems_utils.py
index 595b6c8ee5f..d1e1cc5e346 100644
--- a/release/scripts/modules/nodeitems_utils.py
+++ b/release/scripts/modules/nodeitems_utils.py
@@ -144,6 +144,14 @@ def node_categories_iter(context):
yield cat
+def has_node_categories(context):
+ for cat_type in _node_categories.values():
+ for cat in cat_type[0]:
+ if cat.poll and ((context is None) or cat.poll(context)):
+ return True
+ return False
+
+
def node_items_iter(context):
for cat in node_categories_iter(context):
for item in cat.items(context):