[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2073] trunk/py/scripts/addons/modules/ extensions_framework: extensions_framework: add ability to set UILayout alert state based on a logical test of PropertyGroup members
Doug Hammond
doughammond at hamsterfight.co.uk
Tue Jun 28 22:00:44 CEST 2011
Revision: 2073
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2073
Author: dougal2
Date: 2011-06-28 20:00:43 +0000 (Tue, 28 Jun 2011)
Log Message:
-----------
extensions_framework: add ability to set UILayout alert state based on a logical test of PropertyGroup members
Modified Paths:
--------------
trunk/py/scripts/addons/modules/extensions_framework/__init__.py
trunk/py/scripts/addons/modules/extensions_framework/ui.py
Modified: trunk/py/scripts/addons/modules/extensions_framework/__init__.py
===================================================================
--- trunk/py/scripts/addons/modules/extensions_framework/__init__.py 2011-06-28 19:44:50 UTC (rev 2072)
+++ trunk/py/scripts/addons/modules/extensions_framework/__init__.py 2011-06-28 20:00:43 UTC (rev 2073)
@@ -246,6 +246,13 @@
"""
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'
Modified: trunk/py/scripts/addons/modules/extensions_framework/ui.py
===================================================================
--- trunk/py/scripts/addons/modules/extensions_framework/ui.py 2011-06-28 19:44:50 UTC (rev 2072)
+++ trunk/py/scripts/addons/modules/extensions_framework/ui.py 2011-06-28 20:00:43 UTC (rev 2073)
@@ -116,6 +116,19 @@
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 @@
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 @@
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
More information about the Bf-extensions-cvs
mailing list