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

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Hammond <doughammond@hamsterfight.co.uk>2011-06-29 00:00:43 +0400
committerDoug Hammond <doughammond@hamsterfight.co.uk>2011-06-29 00:00:43 +0400
commit1cb0ec14fa685680e972c88f68cf4fa9d2475809 (patch)
treee7881e795dc9dccb6f6f15c24fc69d8f5fc829ae /modules
parent9b294b39130c5973bde2ed229d9ff9ce0a76b59a (diff)
extensions_framework: add ability to set UILayout alert state based on a logical test of PropertyGroup members
Diffstat (limited to 'modules')
-rw-r--r--modules/extensions_framework/__init__.py7
-rw-r--r--modules/extensions_framework/ui.py25
2 files changed, 31 insertions, 1 deletions
diff --git a/modules/extensions_framework/__init__.py b/modules/extensions_framework/__init__.py
index b3494042..df815eb3 100644
--- a/modules/extensions_framework/__init__.py
+++ b/modules/extensions_framework/__init__.py
@@ -246,6 +246,13 @@ class declarative_property_group(bpy.types.PropertyGroup):
"""
enabled = {}
+ """The alert dict controls the alert state of properties based on
+ the value of other properties. See extensions_framework.validate
+ for test syntax.
+
+ """
+ alert = {}
+
"""The properties list describes each property to be created. Each
item should be a dict of args to pass to a
bpy.props.<?>Property function, with the exception of 'type'
diff --git a/modules/extensions_framework/ui.py b/modules/extensions_framework/ui.py
index 5c846712..4f24d873 100644
--- a/modules/extensions_framework/ui.py
+++ b/modules/extensions_framework/ui.py
@@ -116,6 +116,19 @@ class property_group_renderer(bpy.types.Panel):
else:
return True
+ def check_alert(self, lookup_property, property_group):
+ """Determine if the lookup_property should be in an alert state in the Panel"""
+ et = Logician(property_group)
+ if lookup_property in property_group.alert.keys():
+ if hasattr(property_group, lookup_property):
+ member = getattr(property_group, lookup_property)
+ else:
+ member = None
+ return et.test_logic(member,
+ property_group.alert[lookup_property])
+ else:
+ return False
+
def is_real_property(self, lookup_property, property_group):
for prop in property_group.properties:
if prop['attr'] == lookup_property:
@@ -158,11 +171,21 @@ class property_group_renderer(bpy.types.Panel):
if current_property['attr'] == control_list_item:
current_property_keys = current_property.keys()
+ sub_layout_created = False
if not self.check_enabled(control_list_item, property_group):
last_layout = layout
+ sub_layout_created = True
+
layout = layout.row()
layout.enabled = False
+ if self.check_alert(control_list_item, property_group):
+ if not sub_layout_created:
+ last_layout = layout
+ sub_layout_created = True
+ layout = layout.row()
+ layout.alert = True
+
if 'type' in current_property_keys:
if current_property['type'] in ['int', 'float',
'float_vector', 'string']:
@@ -304,7 +327,7 @@ class property_group_renderer(bpy.types.Panel):
else:
layout.prop(property_group, control_list_item)
- if not self.check_enabled(control_list_item, property_group):
+ if sub_layout_created:
layout = last_layout
# Fire a draw callback if specified