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-05-26 17:57:18 +0400
committerDoug Hammond <doughammond@hamsterfight.co.uk>2011-05-26 17:57:18 +0400
commit1834dc6ce513c363611749958af36c1783067e77 (patch)
tree979354703c5da52aa5a96e319d16b85777cde4f2 /modules
parentd8f7f124df1734d1eb1fb7d8d4bf140908e3c1df (diff)
extensions_framework: add support for property enable state control in declarative_property_group analagous to how visibility works. Also removed some old commented debugging code.
Diffstat (limited to 'modules')
-rw-r--r--modules/extensions_framework/__init__.py9
-rw-r--r--modules/extensions_framework/ui.py35
2 files changed, 31 insertions, 13 deletions
diff --git a/modules/extensions_framework/__init__.py b/modules/extensions_framework/__init__.py
index 4a4763f6..32fc924e 100644
--- a/modules/extensions_framework/__init__.py
+++ b/modules/extensions_framework/__init__.py
@@ -221,13 +221,20 @@ class declarative_property_group(bpy.types.PropertyGroup):
"""
controls = []
- """The visibility dict controls the display of properties based on
+ """The visibility dict controls the visibility of properties based on
the value of other properties. See extensions_framework.validate
for test syntax.
"""
visibility = {}
+ """The enabled dict controls the enabled state of properties based on
+ the value of other properties. See extensions_framework.validate
+ for test syntax.
+
+ """
+ enabled = {}
+
"""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 ee29af03..5c846712 100644
--- a/modules/extensions_framework/ui.py
+++ b/modules/extensions_framework/ui.py
@@ -26,7 +26,7 @@
#
import bpy
-from extensions_framework.validate import Visibility
+from extensions_framework.validate import Logician
class EF_OT_msg(bpy.types.Operator):
"""An operator to show simple messages in the UI"""
@@ -92,7 +92,7 @@ class property_group_renderer(bpy.types.Panel):
def check_visibility(self, lookup_property, property_group):
"""Determine if the lookup_property should be drawn in the Panel"""
- vt = Visibility(property_group)
+ vt = Logician(property_group)
if lookup_property in property_group.visibility.keys():
if hasattr(property_group, lookup_property):
member = getattr(property_group, lookup_property)
@@ -103,7 +103,18 @@ class property_group_renderer(bpy.types.Panel):
else:
return True
- # tab_level = 0
+ def check_enabled(self, lookup_property, property_group):
+ """Determine if the lookup_property should be enabled in the Panel"""
+ et = Logician(property_group)
+ if lookup_property in property_group.enabled.keys():
+ if hasattr(property_group, lookup_property):
+ member = getattr(property_group, lookup_property)
+ else:
+ member = None
+ return et.test_logic(member,
+ property_group.enabled[lookup_property])
+ else:
+ return True
def is_real_property(self, lookup_property, property_group):
for prop in property_group.properties:
@@ -114,28 +125,21 @@ class property_group_renderer(bpy.types.Panel):
def draw_column(self, control_list_item, layout, context,
supercontext=None, property_group=None):
- # self.tab_level += 1
"""Draw a column's worth of UI controls in this Panel"""
if type(control_list_item) is list:
draw_row = False
found_percent = None
- # print('\t'*self.tab_level, '--', property_group, '--')
for sp in control_list_item:
- # print('\t'*self.tab_level, sp)
if type(sp) is float:
found_percent = sp
elif type(sp) is list:
for ssp in [s for s in sp if self.is_real_property(s, property_group)]:
draw_row = draw_row or self.check_visibility(ssp,
property_group)
- # print('\t'*self.tab_level, 'List: ', draw_row)
else:
draw_row = draw_row or self.check_visibility(sp,
property_group)
- # print('\t'*self.tab_level, 'Single: ', draw_row)
- # print('\t'*self.tab_level, '-->', draw_row)
- # print('\t'*self.tab_level, '--', property_group, '--')
next_items = [s for s in control_list_item if type(s) in [str, list]]
if draw_row and len(next_items) > 0:
@@ -153,8 +157,13 @@ class property_group_renderer(bpy.types.Panel):
for current_property in property_group.properties:
if current_property['attr'] == control_list_item:
current_property_keys = current_property.keys()
+
+ if not self.check_enabled(control_list_item, property_group):
+ last_layout = layout
+ layout = layout.row()
+ layout.enabled = False
+
if 'type' in current_property_keys:
-
if current_property['type'] in ['int', 'float',
'float_vector', 'string']:
layout.prop(
@@ -295,9 +304,11 @@ 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):
+ layout = last_layout
+
# Fire a draw callback if specified
if 'draw' in current_property_keys:
current_property['draw'](supercontext, context)
break
- # self.tab_level -= 1