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:
authorCampbell Barton <ideasman42@gmail.com>2009-11-19 21:22:21 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-11-19 21:22:21 +0300
commit512c06afdb61740e4c102b590ee563e8b83f2e65 (patch)
tree5e14b124c00875dfcc025778f88b228ef210e7f6 /release/scripts/modules/rna_prop_ui.py
parente61c90e4162040f564e154da055995e2ed280fdf (diff)
- StructRNA's __dir__ was missing members from its classes __dict__
- property editor can now set button min/max values and edit the tooltip - custom props tooltips were not displayed - cleanup the property UI - remove hacks that were used for editing (edit is now a popup operator) - object.children was broken
Diffstat (limited to 'release/scripts/modules/rna_prop_ui.py')
-rw-r--r--release/scripts/modules/rna_prop_ui.py122
1 files changed, 41 insertions, 81 deletions
diff --git a/release/scripts/modules/rna_prop_ui.py b/release/scripts/modules/rna_prop_ui.py
index e4d3de2cef0..ec0a47981d3 100644
--- a/release/scripts/modules/rna_prop_ui.py
+++ b/release/scripts/modules/rna_prop_ui.py
@@ -20,22 +20,6 @@
import bpy
-EVIL_PROP = "act_property"
-EVIL_PROP_PATH = EVIL_PROP + '_path'
-EVIL_PROP_VALUE = EVIL_PROP + '_value'
-EVIL_PROP_PROP = EVIL_PROP + '_prop'
-EVIL_PROP_PROP_ORIG = EVIL_PROP + '_prop_orig'
-
-
-# nasty!, use a scene property to store the active edit item
-def evil_prop_init():
- Scene = bpy.types.Scene
- if EVIL_PROP_PROP_ORIG not in Scene.bl_rna.properties:
- Scene.StringProperty(attr=EVIL_PROP_PATH)
- Scene.StringProperty(attr=EVIL_PROP_VALUE)
- Scene.StringProperty(attr=EVIL_PROP_PROP)
- Scene.StringProperty(attr=EVIL_PROP_PROP_ORIG)
-
def rna_idprop_ui_get(item, create=True):
try:
return item['_RNA_UI']
@@ -85,17 +69,6 @@ def draw(layout, context, context_member, use_edit = True):
pass
rna_item = eval("context." + context_member)
-
- evil_prop_init()
-
- scene = context.scene
-
- global_path = getattr(scene, EVIL_PROP_PATH)
- global_value = getattr(scene, EVIL_PROP_VALUE)
- global_prop = getattr(scene, EVIL_PROP_PROP)
- global_prop_orig = getattr(scene, EVIL_PROP_PROP_ORIG)
-
- # print((global_path, global_value, global_prop, global_prop_orig))
items = rna_item.items()
items.sort()
@@ -107,7 +80,7 @@ def draw(layout, context, context_member, use_edit = True):
del row
for key, val in items:
- print("KEY - " + key)
+
if key == '_RNA_UI':
continue
@@ -122,43 +95,28 @@ def draw(layout, context, context_member, use_edit = True):
val_draw = val
box = row.box()
-
- '''
- if use_edit and key == global_prop_orig and context_member == global_path:
+
+ if use_edit:
split = box.split(percentage=0.75)
-
row = split.row()
- row.itemR(scene, EVIL_PROP_PROP)
- row.itemR(scene, EVIL_PROP_VALUE)
-
- row = split.column()
- prop = row.itemO("wm.properties_edit", properties=True, text="done")
- assign_props(prop, val_draw, key)
-
else:
- '''
- if 1:
- if use_edit:
- split = box.split(percentage=0.75)
- row = split.row()
- else:
- row = box.row()
+ row = box.row()
+
+ row.itemL(text=key)
+
+ # explicit exception for arrays
+ if convert_to_pyobject and not hasattr(val_orig, "len"):
+ row.itemL(text=val_draw)
+ else:
+ row.itemR(rna_item, '["%s"]' % key, text="")
- row.itemL(text=key)
+ if use_edit:
+ row = split.row(align=True)
+ prop = row.itemO("wm.properties_edit", properties=True, text="edit")
+ assign_props(prop, val_draw, key)
- # explicit exception for arrays
- if convert_to_pyobject and not hasattr(val_orig, "len"):
- row.itemL(text=val_draw)
- else:
- row.itemR(rna_item, '["%s"]' % key, text="")
-
- if use_edit:
- row = split.row(align=True)
- prop = row.itemO("wm.properties_edit", properties=True, text="edit")
- assign_props(prop, val_draw, key)
-
- prop = row.itemO("wm.properties_remove", properties=True, text="", icon='ICON_ZOOMOUT')
- assign_props(prop, val_draw, key)
+ prop = row.itemO("wm.properties_remove", properties=True, text="", icon='ICON_ZOOMOUT')
+ assign_props(prop, val_draw, key)
from bpy.props import *
@@ -173,62 +131,64 @@ rna_value = StringProperty(name="Property Value",
rna_property = StringProperty(name="Property Name",
description="Property name edit", maxlen=1024, default="")
-rna_min = FloatProperty(name="Min", default=0.0)
-rna_min = FloatProperty(name="Max", default=1.0)
+rna_min = FloatProperty(name="Min", default=0.0, precision=3)
+rna_max = FloatProperty(name="Max", default=1.0, precision=3)
class WM_OT_properties_edit(bpy.types.Operator):
'''Internal use (edit a property path)'''
bl_idname = "wm.properties_edit"
bl_label = "Edit Property!"
+ description = StringProperty(name="Tip", default="")
path = rna_path
value = rna_value
property = rna_property
- min = FloatProperty(name="Min", default=0.0)
- max = FloatProperty(name="Max", default=1.0)
- description = StringProperty(name="Tip", default="")
+ min = rna_min
+ max = rna_max
# the class instance is not persistant, need to store in the class
# not ideal but changes as the op runs.
_last_prop = ['']
def execute(self, context):
- global_path = self.properties.path
- global_value = self.properties.value
- global_prop = self.properties.property
- global_prop_old = self._last_prop[0]
+ path = self.properties.path
+ value = self.properties.value
+ prop = self.properties.property
+ prop_old = self._last_prop[0]
try:
- value = eval(global_value)
+ value_eval = eval(value)
except:
- value = global_value
+ value_eval = value
- if type(value) == str:
- value = '"' + value + '"'
+ if type(value_eval) == str:
+ value_eval = '"' + value_eval + '"'
# First remove
- item = eval("context.%s" % global_path)
+ item = eval("context.%s" % path)
- rna_idprop_ui_prop_clear(item, global_prop_old)
- exec_str = "del item['%s']" % global_prop_old
+ rna_idprop_ui_prop_clear(item, prop_old)
+ exec_str = "del item['%s']" % prop_old
# print(exec_str)
exec(exec_str)
# Reassign
- exec_str = "item['%s'] = %s" % (global_prop, value)
+ exec_str = "item['%s'] = %s" % (prop, value_eval)
# print(exec_str)
exec(exec_str)
- prop_type = type(item[global_prop])
+ prop_type = type(item[prop])
- prop_ui = rna_idprop_ui_prop_get(item, global_prop)
+ prop_ui = rna_idprop_ui_prop_get(item, prop)
if prop_type in (float, int):
prop_ui['soft_min'] = prop_ui['min'] = prop_type(self.properties.min)
prop_ui['soft_max'] = prop_ui['max'] = prop_type(self.properties.max)
+
+ prop_ui['description'] = self.properties.description
return ('FINISHED',)
@@ -242,7 +202,7 @@ class WM_OT_properties_edit(bpy.types.Operator):
prop_ui = rna_idprop_ui_prop_get(item, self.properties.property, False) # dont create
if prop_ui:
self.properties.min = prop_ui.get("min", -1000000000)
- self.properties.min = prop_ui.get("max", 1000000000)
+ self.properties.max = prop_ui.get("max", 1000000000)
self.properties.description = prop_ui.get("description", "")
if 0:
@@ -280,7 +240,7 @@ class WM_OT_properties_add(bpy.types.Operator):
path = rna_path
def execute(self, context):
- item = eval("context.%s" % self.path)
+ item = eval("context.%s" % self.properties.path)
def unique_name(names):
prop = 'prop'