[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24686] trunk/blender: - StructRNA' s __dir__ was missing members from its classes __dict__
Campbell Barton
ideasman42 at gmail.com
Thu Nov 19 19:22:22 CET 2009
Revision: 24686
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24686
Author: campbellbarton
Date: 2009-11-19 19:22:21 +0100 (Thu, 19 Nov 2009)
Log Message:
-----------
- 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
Modified Paths:
--------------
trunk/blender/release/scripts/modules/bpy_types.py
trunk/blender/release/scripts/modules/rna_prop_ui.py
trunk/blender/source/blender/makesrna/intern/rna_access.c
trunk/blender/source/blender/python/intern/bpy_rna.c
Modified: trunk/blender/release/scripts/modules/bpy_types.py
===================================================================
--- trunk/blender/release/scripts/modules/bpy_types.py 2009-11-19 17:12:08 UTC (rev 24685)
+++ trunk/blender/release/scripts/modules/bpy_types.py 2009-11-19 18:22:21 UTC (rev 24686)
@@ -15,7 +15,6 @@
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# ##### END GPL LICENSE BLOCK #####
-
from _bpy import types as bpy_types
StructRNA = bpy_types.Struct.__bases__[0]
@@ -37,6 +36,7 @@
class Object(bpy_types.ID):
def _get_children(self):
+ import bpy
return [child for child in bpy.data.objects if child.parent == self]
children = property(_get_children)
Modified: trunk/blender/release/scripts/modules/rna_prop_ui.py
===================================================================
--- trunk/blender/release/scripts/modules/rna_prop_ui.py 2009-11-19 17:12:08 UTC (rev 24685)
+++ trunk/blender/release/scripts/modules/rna_prop_ui.py 2009-11-19 18:22:21 UTC (rev 24686)
@@ -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,18 +69,7 @@
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 @@
del row
for key, val in items:
- print("KEY - " + key)
+
if key == '_RNA_UI':
continue
@@ -122,43 +95,28 @@
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)
+ else:
+ 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 = split.column()
- prop = row.itemO("wm.properties_edit", properties=True, text="done")
+ if use_edit:
+ row = split.row(align=True)
+ prop = row.itemO("wm.properties_edit", properties=True, text="edit")
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.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="")
-
- 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_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 @@
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 @@
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'
Modified: trunk/blender/source/blender/makesrna/intern/rna_access.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_access.c 2009-11-19 17:12:08 UTC (rev 24685)
+++ trunk/blender/source/blender/makesrna/intern/rna_access.c 2009-11-19 18:22:21 UTC (rev 24686)
@@ -424,8 +424,10 @@
IDProperty *idp_ui= rna_idproperty_ui(prop);
if(idp_ui) { /* TODO, type checking on ID props */
+
IDProperty *item= IDP_GetPropertyFromGroup(idp_ui, "description");
- return item ? ((IDProperty*)prop)->name : item->data.pointer;
+ if(item)
+ return (char *)item->data.pointer ;
}
return ((IDProperty*)prop)->name; /* XXX - not correct */
@@ -955,7 +957,7 @@
const char *RNA_property_ui_description(PropertyRNA *prop)
{
- return rna_ensure_property(prop)->description;
+ return rna_ensure_property_description(prop);
}
int RNA_property_ui_icon(PropertyRNA *prop)
Modified: trunk/blender/source/blender/python/intern/bpy_rna.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_rna.c 2009-11-19 17:12:08 UTC (rev 24685)
+++ trunk/blender/source/blender/python/intern/bpy_rna.c 2009-11-19 18:22:21 UTC (rev 24686)
@@ -1443,18 +1443,22 @@
if (BPy_StructRNA_CheckExact(self)) {
ret = PyList_New(0);
} else {
- pystring = PyUnicode_FromString("__dict__");
- dict = PyObject_GenericGetAttr((PyObject *)self, pystring);
- Py_DECREF(pystring);
+ PyObject *list;
+ /* class instances */
+ dict = *_PyObject_GetDictPtr((PyObject *)self);
if (dict==NULL) {
- PyErr_Clear();
ret = PyList_New(0);
}
else {
ret = PyDict_Keys(dict);
- Py_DECREF(dict);
}
+
+ /* classes dict */
+ dict= ((PyTypeObject *)Py_TYPE(self))->tp_dict;
+ list = PyDict_Keys(dict);
+ PyList_SetSlice(ret, INT_MAX, INT_MAX, list);
+ Py_DECREF(list);
}
/* Collect RNA items*/
@@ -1617,6 +1621,17 @@
return ret;
}
+#if 0
+static int pyrna_struct_pydict_contains(PyObject *self, PyObject *pyname)
+{
+ PyObject *dict= *(_PyObject_GetDictPtr((PyObject *)self));
+ if (dict==NULL) /* unlikely */
+ return 0;
+
+ return PyDict_Contains(dict, pyname);
+}
+#endif
+
//--------------- setattr-------------------------------------------
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list