subtype support for properties in bpy.props.
This commit is contained in:
parent
26cfe812f8
commit
039d087171
@ -1122,7 +1122,7 @@ class Export3DS(bpy.types.Operator):
|
|||||||
|
|
||||||
# filename = StringProperty(name="File Name", description="File name used for exporting the 3DS file", maxlen= 1024, default= ""),
|
# filename = StringProperty(name="File Name", description="File name used for exporting the 3DS file", maxlen= 1024, default= ""),
|
||||||
path = StringProperty(name="File Path", description="File path used for exporting the 3DS file", maxlen= 1024, default= "")
|
path = StringProperty(name="File Path", description="File path used for exporting the 3DS file", maxlen= 1024, default= "")
|
||||||
check_existing = BoolProperty(name="Check Existing", description="Check and warn on overwriting existing files", default=True, hidden=True)
|
check_existing = BoolProperty(name="Check Existing", description="Check and warn on overwriting existing files", default=True, options={'HIDDEN'})
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
save_3ds(self.properties.path, context)
|
save_3ds(self.properties.path, context)
|
||||||
|
@ -3363,7 +3363,7 @@ class ExportFBX(bpy.types.Operator):
|
|||||||
|
|
||||||
|
|
||||||
path = StringProperty(name="File Path", description="File path used for exporting the FBX file", maxlen= 1024, default="")
|
path = StringProperty(name="File Path", description="File path used for exporting the FBX file", maxlen= 1024, default="")
|
||||||
check_existing = BoolProperty(name="Check Existing", description="Check and warn on overwriting existing files", default=True, hidden=True)
|
check_existing = BoolProperty(name="Check Existing", description="Check and warn on overwriting existing files", default=True, options={'HIDDEN'})
|
||||||
|
|
||||||
EXP_OBS_SELECTED = BoolProperty(name="Selected Objects", description="Export selected objects on visible layers", default=True)
|
EXP_OBS_SELECTED = BoolProperty(name="Selected Objects", description="Export selected objects on visible layers", default=True)
|
||||||
# EXP_OBS_SCENE = BoolProperty(name="Scene Objects", description="Export all objects in this scene", default=True)
|
# EXP_OBS_SCENE = BoolProperty(name="Scene Objects", description="Export all objects in this scene", default=True)
|
||||||
|
@ -160,7 +160,7 @@ class ExportMDD(bpy.types.Operator):
|
|||||||
# List of operator properties, the attributes will be assigned
|
# List of operator properties, the attributes will be assigned
|
||||||
# to the class instance from the operator settings before calling.
|
# to the class instance from the operator settings before calling.
|
||||||
path = StringProperty(name="File Path", description="File path used for exporting the MDD file", maxlen=1024)
|
path = StringProperty(name="File Path", description="File path used for exporting the MDD file", maxlen=1024)
|
||||||
check_existing = BoolProperty(name="Check Existing", description="Check and warn on overwriting existing files", default=True, hidden=True)
|
check_existing = BoolProperty(name="Check Existing", description="Check and warn on overwriting existing files", default=True, options={'HIDDEN'})
|
||||||
fps = IntProperty(name="Frames Per Second", description="Number of frames/second", min=minfps, max=maxfps, default=25)
|
fps = IntProperty(name="Frames Per Second", description="Number of frames/second", min=minfps, max=maxfps, default=25)
|
||||||
start_frame = IntProperty(name="Start Frame", description="Start frame for baking", min=minframe, max=maxframe, default=1)
|
start_frame = IntProperty(name="Start Frame", description="Start frame for baking", min=minframe, max=maxframe, default=1)
|
||||||
end_frame = IntProperty(name="End Frame", description="End frame for baking", min=minframe, max=maxframe, default=250)
|
end_frame = IntProperty(name="End Frame", description="End frame for baking", min=minframe, max=maxframe, default=250)
|
||||||
|
@ -897,7 +897,7 @@ class ExportOBJ(bpy.types.Operator):
|
|||||||
# to the class instance from the operator settings before calling.
|
# to the class instance from the operator settings before calling.
|
||||||
|
|
||||||
path = StringProperty(name="File Path", description="File path used for exporting the OBJ file", maxlen= 1024, default= "")
|
path = StringProperty(name="File Path", description="File path used for exporting the OBJ file", maxlen= 1024, default= "")
|
||||||
check_existing = BoolProperty(name="Check Existing", description="Check and warn on overwriting existing files", default=True, hidden=True)
|
check_existing = BoolProperty(name="Check Existing", description="Check and warn on overwriting existing files", default=True, options={'HIDDEN'})
|
||||||
|
|
||||||
# context group
|
# context group
|
||||||
use_selection = BoolProperty(name="Selection Only", description="", default= False)
|
use_selection = BoolProperty(name="Selection Only", description="", default= False)
|
||||||
|
@ -275,7 +275,7 @@ class ExportPLY(bpy.types.Operator):
|
|||||||
|
|
||||||
|
|
||||||
path = StringProperty(name="File Path", description="File path used for exporting the PLY file", maxlen=1024, default="")
|
path = StringProperty(name="File Path", description="File path used for exporting the PLY file", maxlen=1024, default="")
|
||||||
check_existing = BoolProperty(name="Check Existing", description="Check and warn on overwriting existing files", default=True, hidden=True)
|
check_existing = BoolProperty(name="Check Existing", description="Check and warn on overwriting existing files", default=True, options={'HIDDEN'})
|
||||||
use_modifiers = BoolProperty(name="Apply Modifiers", description="Apply Modifiers to the exported mesh", default=True)
|
use_modifiers = BoolProperty(name="Apply Modifiers", description="Apply Modifiers to the exported mesh", default=True)
|
||||||
use_normals = BoolProperty(name="Normals", description="Export Normals for smooth and hard shaded faces", default=True)
|
use_normals = BoolProperty(name="Normals", description="Export Normals for smooth and hard shaded faces", default=True)
|
||||||
use_uvs = BoolProperty(name="UVs", description="Exort the active UV layer", default=True)
|
use_uvs = BoolProperty(name="UVs", description="Exort the active UV layer", default=True)
|
||||||
|
@ -1227,7 +1227,7 @@ class ExportX3D(bpy.types.Operator):
|
|||||||
# List of operator properties, the attributes will be assigned
|
# List of operator properties, the attributes will be assigned
|
||||||
# to the class instance from the operator settings before calling.
|
# to the class instance from the operator settings before calling.
|
||||||
path = StringProperty(name="File Path", description="File path used for exporting the X3D file", maxlen= 1024, default= "")
|
path = StringProperty(name="File Path", description="File path used for exporting the X3D file", maxlen= 1024, default= "")
|
||||||
check_existing = BoolProperty(name="Check Existing", description="Check and warn on overwriting existing files", default=True, hidden=True)
|
check_existing = BoolProperty(name="Check Existing", description="Check and warn on overwriting existing files", default=True, options={'HIDDEN'})
|
||||||
|
|
||||||
apply_modifiers = BoolProperty(name="Apply Modifiers", description="Use transformed mesh data from each object.", default=True)
|
apply_modifiers = BoolProperty(name="Apply Modifiers", description="Use transformed mesh data from each object.", default=True)
|
||||||
triangulate = BoolProperty(name="Triangulate", description="Triangulate quads.", default=False)
|
triangulate = BoolProperty(name="Triangulate", description="Triangulate quads.", default=False)
|
||||||
|
@ -140,7 +140,7 @@ from bpy.props import *
|
|||||||
|
|
||||||
|
|
||||||
rna_path = StringProperty(name="Property Edit",
|
rna_path = StringProperty(name="Property Edit",
|
||||||
description="Property path edit", maxlen=1024, default="", hidden=True)
|
description="Property path edit", maxlen=1024, default="", options={'HIDDEN'})
|
||||||
|
|
||||||
rna_value = StringProperty(name="Property Value",
|
rna_value = StringProperty(name="Property Value",
|
||||||
description="Property value edit", maxlen=1024, default="")
|
description="Property value edit", maxlen=1024, default="")
|
||||||
|
@ -93,16 +93,16 @@ class RandomizeLocRotSize(bpy.types.Operator):
|
|||||||
use_loc = BoolProperty(name="Randomize Location",
|
use_loc = BoolProperty(name="Randomize Location",
|
||||||
description="Randomize the scale values", default=True)
|
description="Randomize the scale values", default=True)
|
||||||
|
|
||||||
loc = FloatVectorProperty(name="Location",
|
sdfwefreloc = FloatVectorProperty(name="Location",
|
||||||
description="Maximun distance the objects can spread over each axis",
|
description="Maximun distance the objects can spread over each axis",
|
||||||
default=(0.0, 0.0, 0.0), min=-100.0, max=100.0)
|
default=(0.0, 0.0, 0.0), min=-100.0, max=100.0, subtype='TRANSLATION')
|
||||||
|
|
||||||
use_rot = BoolProperty(name="Randomize Rotation",
|
use_rot = BoolProperty(name="Randomize Rotation",
|
||||||
description="Randomize the rotation values", default=True)
|
description="Randomize the rotation values", default=True)
|
||||||
|
|
||||||
rot = FloatVectorProperty(name="Rotation",
|
rot = FloatVectorProperty(name="Rotation",
|
||||||
description="Maximun rotation over each axis",
|
description="Maximun rotation over each axis",
|
||||||
default=(0.0, 0.0, 0.0), min=-180.0, max=180.0)
|
default=(0.0, 0.0, 0.0), min=-180.0, max=180.0, subtype='TRANSLATION')
|
||||||
|
|
||||||
use_scale = BoolProperty(name="Randomize Scale",
|
use_scale = BoolProperty(name="Randomize Scale",
|
||||||
description="Randomize the scale values", default=True)
|
description="Randomize the scale values", default=True)
|
||||||
@ -116,7 +116,7 @@ class RandomizeLocRotSize(bpy.types.Operator):
|
|||||||
|
|
||||||
scale = FloatVectorProperty(name="Scale",
|
scale = FloatVectorProperty(name="Scale",
|
||||||
description="Maximum scale randomization over each axis",
|
description="Maximum scale randomization over each axis",
|
||||||
default=(0.0, 0.0, 0.0), min=-100.0, max=100.0)
|
default=(0.0, 0.0, 0.0), min=-100.0, max=100.0, subtype='TRANSLATION')
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
from math import radians
|
from math import radians
|
||||||
|
@ -31,7 +31,7 @@ class ExportUVLayout(bpy.types.Operator):
|
|||||||
bl_undo = True
|
bl_undo = True
|
||||||
|
|
||||||
path = StringProperty(name="File Path", description="File path used for exporting the SVG file", maxlen=1024, default="")
|
path = StringProperty(name="File Path", description="File path used for exporting the SVG file", maxlen=1024, default="")
|
||||||
check_existing = BoolProperty(name="Check Existing", description="Check and warn on overwriting existing files", default=True, hidden=True)
|
check_existing = BoolProperty(name="Check Existing", description="Check and warn on overwriting existing files", default=True, options={'HIDDEN'})
|
||||||
only_selected = BoolProperty(name="Only Selected", description="Export Only the selected UVs", default=False)
|
only_selected = BoolProperty(name="Only Selected", description="Export Only the selected UVs", default=False)
|
||||||
|
|
||||||
def poll(self, context):
|
def poll(self, context):
|
||||||
|
@ -291,7 +291,7 @@ class WM_OT_context_cycle_enum(bpy.types.Operator):
|
|||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
doc_id = StringProperty(name="Doc ID",
|
doc_id = StringProperty(name="Doc ID",
|
||||||
description="", maxlen=1024, default="", hidden=True)
|
description="", maxlen=1024, default="", options={'HIDDEN'})
|
||||||
|
|
||||||
doc_new = StringProperty(name="Edit Description",
|
doc_new = StringProperty(name="Edit Description",
|
||||||
description="", maxlen=1024, default="")
|
description="", maxlen=1024, default="")
|
||||||
|
@ -235,9 +235,9 @@ class ANIM_OT_keying_set_export(bpy.types.Operator):
|
|||||||
path = bpy.props.StringProperty(name="File Path", description="File path to write file to.")
|
path = bpy.props.StringProperty(name="File Path", description="File path to write file to.")
|
||||||
filename = bpy.props.StringProperty(name="File Name", description="Name of the file.")
|
filename = bpy.props.StringProperty(name="File Name", description="Name of the file.")
|
||||||
directory = bpy.props.StringProperty(name="Directory", description="Directory of the file.")
|
directory = bpy.props.StringProperty(name="Directory", description="Directory of the file.")
|
||||||
filter_folder = bpy.props.BoolProperty(name="Filter folders", description="", default=True, hidden=True)
|
filter_folder = bpy.props.BoolProperty(name="Filter folders", description="", default=True, options={'HIDDEN'})
|
||||||
filter_text = bpy.props.BoolProperty(name="Filter text", description="", default=True, hidden=True)
|
filter_text = bpy.props.BoolProperty(name="Filter text", description="", default=True, options={'HIDDEN'})
|
||||||
filter_python = bpy.props.BoolProperty(name="Filter python", description="", default=True, hidden=True)
|
filter_python = bpy.props.BoolProperty(name="Filter python", description="", default=True, options={'HIDDEN'})
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
if not self.properties.path:
|
if not self.properties.path:
|
||||||
|
@ -1502,9 +1502,9 @@ class WM_OT_keyconfig_import(bpy.types.Operator):
|
|||||||
path = bpy.props.StringProperty(name="File Path", description="File path to write file to.")
|
path = bpy.props.StringProperty(name="File Path", description="File path to write file to.")
|
||||||
filename = bpy.props.StringProperty(name="File Name", description="Name of the file.")
|
filename = bpy.props.StringProperty(name="File Name", description="Name of the file.")
|
||||||
directory = bpy.props.StringProperty(name="Directory", description="Directory of the file.")
|
directory = bpy.props.StringProperty(name="Directory", description="Directory of the file.")
|
||||||
filter_folder = bpy.props.BoolProperty(name="Filter folders", description="", default=True, hidden=True)
|
filter_folder = bpy.props.BoolProperty(name="Filter folders", description="", default=True, options={'HIDDEN'})
|
||||||
filter_text = bpy.props.BoolProperty(name="Filter text", description="", default=True, hidden=True)
|
filter_text = bpy.props.BoolProperty(name="Filter text", description="", default=True, options={'HIDDEN'})
|
||||||
filter_python = bpy.props.BoolProperty(name="Filter python", description="", default=True, hidden=True)
|
filter_python = bpy.props.BoolProperty(name="Filter python", description="", default=True, options={'HIDDEN'})
|
||||||
|
|
||||||
keep_original = bpy.props.BoolProperty(name="Keep original", description="Keep original file after copying to configuration folder", default=True)
|
keep_original = bpy.props.BoolProperty(name="Keep original", description="Keep original file after copying to configuration folder", default=True)
|
||||||
|
|
||||||
@ -1561,9 +1561,9 @@ class WM_OT_keyconfig_export(bpy.types.Operator):
|
|||||||
path = bpy.props.StringProperty(name="File Path", description="File path to write file to.")
|
path = bpy.props.StringProperty(name="File Path", description="File path to write file to.")
|
||||||
filename = bpy.props.StringProperty(name="File Name", description="Name of the file.")
|
filename = bpy.props.StringProperty(name="File Name", description="Name of the file.")
|
||||||
directory = bpy.props.StringProperty(name="Directory", description="Directory of the file.")
|
directory = bpy.props.StringProperty(name="Directory", description="Directory of the file.")
|
||||||
filter_folder = bpy.props.BoolProperty(name="Filter folders", description="", default=True, hidden=True)
|
filter_folder = bpy.props.BoolProperty(name="Filter folders", description="", default=True, options={'HIDDEN'})
|
||||||
filter_text = bpy.props.BoolProperty(name="Filter text", description="", default=True, hidden=True)
|
filter_text = bpy.props.BoolProperty(name="Filter text", description="", default=True, options={'HIDDEN'})
|
||||||
filter_python = bpy.props.BoolProperty(name="Filter python", description="", default=True, hidden=True)
|
filter_python = bpy.props.BoolProperty(name="Filter python", description="", default=True, options={'HIDDEN'})
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
if not self.properties.path:
|
if not self.properties.path:
|
||||||
|
@ -649,6 +649,7 @@ void RNA_property_float_ui_range(PointerRNA *ptr, PropertyRNA *prop, float *soft
|
|||||||
int RNA_enum_identifier(EnumPropertyItem *item, const int value, const char **identifier);
|
int RNA_enum_identifier(EnumPropertyItem *item, const int value, const char **identifier);
|
||||||
int RNA_enum_bitflag_identifiers(EnumPropertyItem *item, const int value, const char **identifier);
|
int RNA_enum_bitflag_identifiers(EnumPropertyItem *item, const int value, const char **identifier);
|
||||||
int RNA_enum_name(EnumPropertyItem *item, const int value, const char **name);
|
int RNA_enum_name(EnumPropertyItem *item, const int value, const char **name);
|
||||||
|
int RNA_enum_value(EnumPropertyItem *item, const char *name, int *r_value);
|
||||||
|
|
||||||
void RNA_property_enum_items(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, EnumPropertyItem **item, int *totitem, int *free);
|
void RNA_property_enum_items(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, EnumPropertyItem **item, int *totitem, int *free);
|
||||||
int RNA_property_enum_value(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, const char *identifier, int *value);
|
int RNA_property_enum_value(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, const char *identifier, int *value);
|
||||||
|
@ -90,7 +90,7 @@ typedef enum PropertyUnit {
|
|||||||
|
|
||||||
#define RNA_ENUM_BITFLAG_SIZE 32
|
#define RNA_ENUM_BITFLAG_SIZE 32
|
||||||
|
|
||||||
/* also update rna_property_subtypename when you change this */
|
/* also update enums in bpy_props.c when adding items here */
|
||||||
typedef enum PropertySubType {
|
typedef enum PropertySubType {
|
||||||
PROP_NONE = 0,
|
PROP_NONE = 0,
|
||||||
|
|
||||||
@ -125,6 +125,7 @@ typedef enum PropertySubType {
|
|||||||
PROP_LAYER_MEMBER = 41
|
PROP_LAYER_MEMBER = 41
|
||||||
} PropertySubType;
|
} PropertySubType;
|
||||||
|
|
||||||
|
/* Make sure enums are updated with thses */
|
||||||
typedef enum PropertyFlag {
|
typedef enum PropertyFlag {
|
||||||
/* editable means the property is editable in the user
|
/* editable means the property is editable in the user
|
||||||
* interface, properties are editable by default except
|
* interface, properties are editable by default except
|
||||||
|
@ -1034,6 +1034,17 @@ int RNA_enum_name(EnumPropertyItem *item, const int value, const char **name)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int RNA_enum_value(EnumPropertyItem *item, const char *name, int *r_value)
|
||||||
|
{
|
||||||
|
for (; item->identifier; item++) {
|
||||||
|
if(item->identifier[0] && strcmp(item->identifier, name)==0) {
|
||||||
|
*r_value= item->value;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int RNA_property_enum_identifier(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value, const char **identifier)
|
int RNA_property_enum_identifier(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value, const char **identifier)
|
||||||
{
|
{
|
||||||
EnumPropertyItem *item= NULL;
|
EnumPropertyItem *item= NULL;
|
||||||
|
@ -33,6 +33,47 @@
|
|||||||
|
|
||||||
#include "float.h" /* FLT_MIN/MAX */
|
#include "float.h" /* FLT_MIN/MAX */
|
||||||
|
|
||||||
|
EnumPropertyItem property_flag_items[] = {
|
||||||
|
{PROP_HIDDEN, "HIDDEN", 0, "Hidden", ""},
|
||||||
|
{PROP_ANIMATEABLE, "ANIMATEABLE", 0, "Animateable", ""},
|
||||||
|
{0, NULL, 0, NULL, NULL}};
|
||||||
|
|
||||||
|
/* subtypes */
|
||||||
|
EnumPropertyItem property_subtype_string_items[] = {
|
||||||
|
{PROP_FILEPATH, "FILE_PATH", 0, "File Path", ""},
|
||||||
|
{PROP_DIRPATH, "DIR_PATH", 0, "Directory Path", ""},
|
||||||
|
{PROP_FILENAME, "FILENAME", 0, "Filename", ""},
|
||||||
|
|
||||||
|
{PROP_NONE, "NONE", 0, "None", ""},
|
||||||
|
{0, NULL, 0, NULL, NULL}};
|
||||||
|
|
||||||
|
EnumPropertyItem property_subtype_number_items[] = {
|
||||||
|
{PROP_UNSIGNED, "UNSIGNED", 0, "Unsigned", ""},
|
||||||
|
{PROP_PERCENTAGE, "PERCENTAGE", 0, "Percentage", ""},
|
||||||
|
{PROP_FACTOR, "FACTOR", 0, "Factor", ""},
|
||||||
|
{PROP_ANGLE, "ANGLE", 0, "Angle", ""},
|
||||||
|
{PROP_TIME, "TIME", 0, "Time", ""},
|
||||||
|
{PROP_DISTANCE, "DISTANCE", 0, "Distance", ""},
|
||||||
|
|
||||||
|
{PROP_NONE, "NONE", 0, "None", ""},
|
||||||
|
{0, NULL, 0, NULL, NULL}};
|
||||||
|
|
||||||
|
EnumPropertyItem property_subtype_array_items[] = {
|
||||||
|
{PROP_COLOR, "COLOR", 0, "Color", ""},
|
||||||
|
{PROP_TRANSLATION, "TRANSLATION", 0, "Translation", ""},
|
||||||
|
{PROP_DIRECTION, "DIRECTION", 0, "Direction", ""},
|
||||||
|
{PROP_VELOCITY, "VELOCITY", 0, "Velocity", ""},
|
||||||
|
{PROP_ACCELERATION, "ACCELERATION", 0, "Acceleration", ""},
|
||||||
|
{PROP_MATRIX, "MATRIX", 0, "Matrix", ""},
|
||||||
|
{PROP_EULER, "EULER", 0, "Euler", ""},
|
||||||
|
{PROP_QUATERNION, "QUATERNION", 0, "Quaternion", ""},
|
||||||
|
{PROP_AXISANGLE, "AXISANGLE", 0, "Axis Angle", ""},
|
||||||
|
{PROP_XYZ, "XYZ", 0, "XYZ", ""},
|
||||||
|
{PROP_COLOR_GAMMA, "COLOR_GAMMA", 0, "Color Gamma", ""},
|
||||||
|
|
||||||
|
{PROP_NONE, "NONE", 0, "None", ""},
|
||||||
|
{0, NULL, 0, NULL, NULL}};
|
||||||
|
|
||||||
/* operators use this so it can store the args given but defer running
|
/* operators use this so it can store the args given but defer running
|
||||||
* it until the operator runs where these values are used to setup the
|
* it until the operator runs where these values are used to setup the
|
||||||
* default args for that operator instance */
|
* default args for that operator instance */
|
||||||
@ -48,9 +89,14 @@ static PyObject *bpy_prop_deferred_return(void *func, PyObject *kw)
|
|||||||
/* Function that sets RNA, NOTE - self is NULL when called from python, but being abused from C so we can pass the srna allong
|
/* Function that sets RNA, NOTE - self is NULL when called from python, but being abused from C so we can pass the srna allong
|
||||||
* This isnt incorrect since its a python object - but be careful */
|
* This isnt incorrect since its a python object - but be careful */
|
||||||
static char BPy_BoolProperty_doc[] =
|
static char BPy_BoolProperty_doc[] =
|
||||||
".. function:: BoolProperty(name=\"\", description=\"\", default=False, hidden=False)\n"
|
".. function:: BoolProperty(name=\"\", description=\"\", default=False, options={'ANIMATEABLE'}, subtype='NONE')\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Returns a new boolean property definition..";
|
" Returns a new boolean property definition.\n"
|
||||||
|
"\n"
|
||||||
|
" :arg options: Enumerator in ['HIDDEN', 'ANIMATEABLE'].\n"
|
||||||
|
" :type options: set\n"
|
||||||
|
" :arg subtype: Enumerator in ['UNSIGNED', 'PERCENTAGE', 'FACTOR', 'ANGLE', 'TIME', 'DISTANCE', 'NONE'].\n"
|
||||||
|
" :type subtype: string";
|
||||||
|
|
||||||
PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
|
PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||||
{
|
{
|
||||||
@ -66,16 +112,35 @@ PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
return NULL; /* self's type was compatible but error getting the srna */
|
return NULL; /* self's type was compatible but error getting the srna */
|
||||||
}
|
}
|
||||||
else if(srna) {
|
else if(srna) {
|
||||||
static char *kwlist[] = {"attr", "name", "description", "default", "hidden", NULL};
|
static char *kwlist[] = {"attr", "name", "description", "default", "options", "subtype", NULL};
|
||||||
char *id=NULL, *name="", *description="";
|
char *id=NULL, *name="", *description="";
|
||||||
int def=0, hidden=0;
|
int def=0;
|
||||||
PropertyRNA *prop;
|
PropertyRNA *prop;
|
||||||
|
PyObject *pyopts= NULL;
|
||||||
|
int opts=0;
|
||||||
|
char *pysubtype= NULL;
|
||||||
|
int subtype= PROP_NONE;
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssii:BoolProperty", kwlist, &id, &name, &description, &def, &hidden))
|
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssiO!s:BoolProperty", kwlist, &id, &name, &description, &def, &PySet_Type, &pyopts, &pysubtype))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
prop= RNA_def_boolean(srna, id, def, name, description);
|
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "BoolProperty(options={...}):"))
|
||||||
if(hidden) RNA_def_property_flag(prop, PROP_HIDDEN);
|
return NULL;
|
||||||
|
|
||||||
|
if(pysubtype && RNA_enum_value(property_subtype_number_items, pysubtype, &subtype)==0) {
|
||||||
|
PyErr_Format(PyExc_TypeError, "BoolProperty(subtype='%s'): invalid subtype.");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// prop= RNA_def_boolean(srna, id, def, name, description);
|
||||||
|
prop= RNA_def_property(srna, id, PROP_BOOLEAN, subtype);
|
||||||
|
RNA_def_property_boolean_default(prop, def);
|
||||||
|
RNA_def_property_ui_text(prop, name, description);
|
||||||
|
|
||||||
|
if(pyopts) {
|
||||||
|
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||||
|
if((opts & PROP_ANIMATEABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATEABLE);
|
||||||
|
}
|
||||||
RNA_def_property_duplicate_pointers(prop);
|
RNA_def_property_duplicate_pointers(prop);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
@ -85,9 +150,14 @@ PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char BPy_BoolVectorProperty_doc[] =
|
static char BPy_BoolVectorProperty_doc[] =
|
||||||
".. function:: BoolVectorProperty(name=\"\", description=\"\", default=(False, False, False), hidden=False, size=3)\n"
|
".. function:: BoolVectorProperty(name=\"\", description=\"\", default=(False, False, False), options={'ANIMATEABLE'}, subtype='NONE', size=3)\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Returns a new vector boolean property definition.";
|
" Returns a new vector boolean property definition.\n"
|
||||||
|
"\n"
|
||||||
|
" :arg options: Enumerator in ['HIDDEN', 'ANIMATEABLE'].\n"
|
||||||
|
" :type options: set\n"
|
||||||
|
" :arg subtype: Enumerator in ['COLOR', 'TRANSLATION', 'DIRECTION', 'VELOCITY', 'ACCELERATION', 'MATRIX', 'EULER', 'QUATERNION', 'AXISANGLE', 'XYZ', 'COLOR_GAMMA', 'NONE'].\n"
|
||||||
|
" :type subtype: string";
|
||||||
PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
|
PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||||
{
|
{
|
||||||
StructRNA *srna;
|
StructRNA *srna;
|
||||||
@ -102,16 +172,28 @@ PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
return NULL; /* self's type was compatible but error getting the srna */
|
return NULL; /* self's type was compatible but error getting the srna */
|
||||||
}
|
}
|
||||||
else if(srna) {
|
else if(srna) {
|
||||||
static char *kwlist[] = {"attr", "name", "description", "default", "hidden", "size", NULL};
|
static char *kwlist[] = {"attr", "name", "description", "default", "options", "subtype", "size", NULL};
|
||||||
char *id=NULL, *name="", *description="";
|
char *id=NULL, *name="", *description="";
|
||||||
int def[PYRNA_STACK_ARRAY]={0};
|
int def[PYRNA_STACK_ARRAY]={0};
|
||||||
int hidden=0, size=3;
|
int size=3;
|
||||||
PropertyRNA *prop;
|
PropertyRNA *prop;
|
||||||
PyObject *pydef= NULL;
|
PyObject *pydef= NULL;
|
||||||
|
PyObject *pyopts= NULL;
|
||||||
|
int opts=0;
|
||||||
|
char *pysubtype= NULL;
|
||||||
|
int subtype= PROP_NONE;
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssOii:BoolVectorProperty", kwlist, &id, &name, &description, &pydef, &hidden, &size))
|
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssOO!si:BoolVectorProperty", kwlist, &id, &name, &description, &pydef, &PySet_Type, &pyopts, &pysubtype, &size))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "BoolVectorProperty(options={...}):"))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if(pysubtype && RNA_enum_value(property_subtype_array_items, pysubtype, &subtype)==0) {
|
||||||
|
PyErr_Format(PyExc_TypeError, "BoolVectorProperty(subtype='%s'): invalid subtype.");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if(size < 1 || size > PYRNA_STACK_ARRAY) {
|
if(size < 1 || size > PYRNA_STACK_ARRAY) {
|
||||||
PyErr_Format(PyExc_TypeError, "BoolVectorProperty(size=%d): size must be between 0 and %d.", size, PYRNA_STACK_ARRAY);
|
PyErr_Format(PyExc_TypeError, "BoolVectorProperty(size=%d): size must be between 0 and %d.", size, PYRNA_STACK_ARRAY);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -120,8 +202,16 @@ PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
if(pydef && BPyAsPrimitiveArray(def, pydef, size, &PyBool_Type, "BoolVectorProperty(default=sequence)") < 0)
|
if(pydef && BPyAsPrimitiveArray(def, pydef, size, &PyBool_Type, "BoolVectorProperty(default=sequence)") < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
prop= RNA_def_boolean_array(srna, id, size, pydef ? def:NULL, name, description);
|
// prop= RNA_def_boolean_array(srna, id, size, pydef ? def:NULL, name, description);
|
||||||
if(hidden) RNA_def_property_flag(prop, PROP_HIDDEN);
|
prop= RNA_def_property(srna, id, PROP_BOOLEAN, subtype);
|
||||||
|
RNA_def_property_array(prop, size);
|
||||||
|
if(pydef) RNA_def_property_boolean_array_default(prop, def);
|
||||||
|
RNA_def_property_ui_text(prop, name, description);
|
||||||
|
|
||||||
|
if(pyopts) {
|
||||||
|
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||||
|
if((opts & PROP_ANIMATEABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATEABLE);
|
||||||
|
}
|
||||||
RNA_def_property_duplicate_pointers(prop);
|
RNA_def_property_duplicate_pointers(prop);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
@ -131,9 +221,14 @@ PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char BPy_IntProperty_doc[] =
|
static char BPy_IntProperty_doc[] =
|
||||||
".. function:: IntProperty(name=\"\", description=\"\", default=0, min=-sys.maxint, max=sys.maxint, soft_min=-sys.maxint, soft_max=sys.maxint, step=1, hidden=False)\n"
|
".. function:: IntProperty(name=\"\", description=\"\", default=0, min=-sys.maxint, max=sys.maxint, soft_min=-sys.maxint, soft_max=sys.maxint, step=1, options={'ANIMATEABLE'}, subtype='NONE')\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Returns a new int property definition.";
|
" Returns a new int property definition.\n"
|
||||||
|
"\n"
|
||||||
|
" :arg options: Enumerator in ['HIDDEN', 'ANIMATEABLE'].\n"
|
||||||
|
" :type options: set\n"
|
||||||
|
" :arg subtype: Enumerator in ['UNSIGNED', 'PERCENTAGE', 'FACTOR', 'ANGLE', 'TIME', 'DISTANCE', 'NONE'].\n"
|
||||||
|
" :type subtype: string";
|
||||||
PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw)
|
PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||||
{
|
{
|
||||||
StructRNA *srna;
|
StructRNA *srna;
|
||||||
@ -148,18 +243,36 @@ PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
return NULL; /* self's type was compatible but error getting the srna */
|
return NULL; /* self's type was compatible but error getting the srna */
|
||||||
}
|
}
|
||||||
else if(srna) {
|
else if(srna) {
|
||||||
static char *kwlist[] = {"attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", "step", "hidden", NULL};
|
static char *kwlist[] = {"attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", "step", "options", "subtype", NULL};
|
||||||
char *id=NULL, *name="", *description="";
|
char *id=NULL, *name="", *description="";
|
||||||
int min=INT_MIN, max=INT_MAX, soft_min=INT_MIN, soft_max=INT_MAX, step=1, def=0;
|
int min=INT_MIN, max=INT_MAX, soft_min=INT_MIN, soft_max=INT_MAX, step=1, def=0;
|
||||||
int hidden=0;
|
|
||||||
PropertyRNA *prop;
|
PropertyRNA *prop;
|
||||||
|
PyObject *pyopts= NULL;
|
||||||
|
int opts=0;
|
||||||
|
char *pysubtype= NULL;
|
||||||
|
int subtype= PROP_NONE;
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssiiiiiii:IntProperty", kwlist, &id, &name, &description, &def, &min, &max, &soft_min, &soft_max, &step, &hidden))
|
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssiiiiiiis:IntProperty", kwlist, &id, &name, &description, &def, &min, &max, &soft_min, &soft_max, &step, &PySet_Type, &pyopts, &pysubtype))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
prop= RNA_def_int(srna, id, def, min, max, name, description, soft_min, soft_max);
|
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "IntProperty(options={...}):"))
|
||||||
RNA_def_property_ui_range(prop, min, max, step, 0);
|
return NULL;
|
||||||
if(hidden) RNA_def_property_flag(prop, PROP_HIDDEN);
|
|
||||||
|
if(pysubtype && RNA_enum_value(property_subtype_number_items, pysubtype, &subtype)==0) {
|
||||||
|
PyErr_Format(PyExc_TypeError, "IntProperty(subtype='%s'): invalid subtype.");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
prop= RNA_def_property(srna, id, PROP_INT, subtype);
|
||||||
|
RNA_def_property_int_default(prop, def);
|
||||||
|
RNA_def_property_range(prop, min, max);
|
||||||
|
RNA_def_property_ui_text(prop, name, description);
|
||||||
|
RNA_def_property_ui_range(prop, soft_min, soft_max, step, 3);
|
||||||
|
|
||||||
|
if(pyopts) {
|
||||||
|
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||||
|
if((opts & PROP_ANIMATEABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATEABLE);
|
||||||
|
}
|
||||||
RNA_def_property_duplicate_pointers(prop);
|
RNA_def_property_duplicate_pointers(prop);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
@ -169,9 +282,14 @@ PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char BPy_IntVectorProperty_doc[] =
|
static char BPy_IntVectorProperty_doc[] =
|
||||||
".. function:: IntVectorProperty(name=\"\", description=\"\", default=(0, 0, 0), min=-sys.maxint, max=sys.maxint, soft_min=-sys.maxint, soft_max=sys.maxint, hidden=False, size=3)\n"
|
".. function:: IntVectorProperty(name=\"\", description=\"\", default=(0, 0, 0), min=-sys.maxint, max=sys.maxint, soft_min=-sys.maxint, soft_max=sys.maxint, options={'ANIMATEABLE'}, subtype='NONE', size=3)\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Returns a new vector int property definition.";
|
" Returns a new vector int property definition.\n"
|
||||||
|
"\n"
|
||||||
|
" :arg options: Enumerator in ['HIDDEN', 'ANIMATEABLE'].\n"
|
||||||
|
" :type options: set\n"
|
||||||
|
" :arg subtype: Enumerator in ['COLOR', 'TRANSLATION', 'DIRECTION', 'VELOCITY', 'ACCELERATION', 'MATRIX', 'EULER', 'QUATERNION', 'AXISANGLE', 'XYZ', 'COLOR_GAMMA', 'NONE'].\n"
|
||||||
|
" :type subtype: string";
|
||||||
PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
|
PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||||
{
|
{
|
||||||
StructRNA *srna;
|
StructRNA *srna;
|
||||||
@ -186,16 +304,28 @@ PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
return NULL; /* self's type was compatible but error getting the srna */
|
return NULL; /* self's type was compatible but error getting the srna */
|
||||||
}
|
}
|
||||||
else if(srna) {
|
else if(srna) {
|
||||||
static char *kwlist[] = {"attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", "step", "hidden", "size", NULL};
|
static char *kwlist[] = {"attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", "step", "options", "subtype", "size", NULL};
|
||||||
char *id=NULL, *name="", *description="";
|
char *id=NULL, *name="", *description="";
|
||||||
int min=INT_MIN, max=INT_MAX, soft_min=INT_MIN, soft_max=INT_MAX, step=1, def[PYRNA_STACK_ARRAY]={0};
|
int min=INT_MIN, max=INT_MAX, soft_min=INT_MIN, soft_max=INT_MAX, step=1, def[PYRNA_STACK_ARRAY]={0};
|
||||||
int hidden=0, size=3;
|
int size=3;
|
||||||
PropertyRNA *prop;
|
PropertyRNA *prop;
|
||||||
PyObject *pydef= NULL;
|
PyObject *pydef= NULL;
|
||||||
|
PyObject *pyopts= NULL;
|
||||||
|
int opts=0;
|
||||||
|
char *pysubtype= NULL;
|
||||||
|
int subtype= PROP_NONE;
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssOiiiiii:IntVectorProperty", kwlist, &id, &name, &description, &pydef, &min, &max, &soft_min, &soft_max, &hidden, &size))
|
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssOiiiiiO!si:IntVectorProperty", kwlist, &id, &name, &description, &pydef, &min, &max, &soft_min, &soft_max, &PySet_Type, &pyopts, &pysubtype, &size))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "IntVectorProperty(options={...}):"))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if(pysubtype && RNA_enum_value(property_subtype_array_items, pysubtype, &subtype)==0) {
|
||||||
|
PyErr_Format(PyExc_TypeError, "IntVectorProperty(subtype='%s'): invalid subtype.");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if(size < 1 || size > PYRNA_STACK_ARRAY) {
|
if(size < 1 || size > PYRNA_STACK_ARRAY) {
|
||||||
PyErr_Format(PyExc_TypeError, "IntVectorProperty(size=%d): size must be between 0 and %d.", size, PYRNA_STACK_ARRAY);
|
PyErr_Format(PyExc_TypeError, "IntVectorProperty(size=%d): size must be between 0 and %d.", size, PYRNA_STACK_ARRAY);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -204,9 +334,17 @@ PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
if(pydef && BPyAsPrimitiveArray(def, pydef, size, &PyLong_Type, "IntVectorProperty(default=sequence)") < 0)
|
if(pydef && BPyAsPrimitiveArray(def, pydef, size, &PyLong_Type, "IntVectorProperty(default=sequence)") < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
prop= RNA_def_int_array(srna, id, size, pydef ? def:NULL, min, max, name, description, soft_min, soft_max);
|
prop= RNA_def_property(srna, id, PROP_INT, subtype);
|
||||||
RNA_def_property_ui_range(prop, min, max, step, 0);
|
RNA_def_property_array(prop, size);
|
||||||
if(hidden) RNA_def_property_flag(prop, PROP_HIDDEN);
|
if(pydef) RNA_def_property_int_array_default(prop, def);
|
||||||
|
RNA_def_property_range(prop, min, max);
|
||||||
|
RNA_def_property_ui_text(prop, name, description);
|
||||||
|
RNA_def_property_ui_range(prop, soft_min, soft_max, step, 3);
|
||||||
|
|
||||||
|
if(pyopts) {
|
||||||
|
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||||
|
if((opts & PROP_ANIMATEABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATEABLE);
|
||||||
|
}
|
||||||
RNA_def_property_duplicate_pointers(prop);
|
RNA_def_property_duplicate_pointers(prop);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
@ -217,9 +355,14 @@ PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
|
|
||||||
|
|
||||||
static char BPy_FloatProperty_doc[] =
|
static char BPy_FloatProperty_doc[] =
|
||||||
".. function:: FloatProperty(name=\"\", description=\"\", default=0.0, min=sys.float_info.min, max=sys.float_info.max, soft_min=sys.float_info.min, soft_max=sys.float_info.max, step=3, precision=2, hidden=False)\n"
|
".. function:: FloatProperty(name=\"\", description=\"\", default=0.0, min=sys.float_info.min, max=sys.float_info.max, soft_min=sys.float_info.min, soft_max=sys.float_info.max, step=3, precision=2, options={'ANIMATEABLE'}, subtype='NONE')\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Returns a new float property definition.";
|
" Returns a new float property definition.\n"
|
||||||
|
"\n"
|
||||||
|
" :arg options: Enumerator in ['HIDDEN', 'ANIMATEABLE'].\n"
|
||||||
|
" :type options: set\n"
|
||||||
|
" :arg subtype: Enumerator in ['UNSIGNED', 'PERCENTAGE', 'FACTOR', 'ANGLE', 'TIME', 'DISTANCE', 'NONE'].\n"
|
||||||
|
" :type subtype: string";
|
||||||
PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
|
PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||||
{
|
{
|
||||||
StructRNA *srna;
|
StructRNA *srna;
|
||||||
@ -234,18 +377,37 @@ PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
return NULL; /* self's type was compatible but error getting the srna */
|
return NULL; /* self's type was compatible but error getting the srna */
|
||||||
}
|
}
|
||||||
else if(srna) {
|
else if(srna) {
|
||||||
static char *kwlist[] = {"attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", "step", "precision", "hidden", NULL};
|
static char *kwlist[] = {"attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", "step", "precision", "options", "subtype", NULL};
|
||||||
char *id=NULL, *name="", *description="";
|
char *id=NULL, *name="", *description="";
|
||||||
float min=-FLT_MAX, max=FLT_MAX, soft_min=-FLT_MAX, soft_max=FLT_MAX, step=3, def=0.0f;
|
float min=-FLT_MAX, max=FLT_MAX, soft_min=-FLT_MAX, soft_max=FLT_MAX, step=3, def=0.0f;
|
||||||
int precision= 2, hidden=0;
|
int precision= 2;
|
||||||
PropertyRNA *prop;
|
PropertyRNA *prop;
|
||||||
|
PyObject *pyopts= NULL;
|
||||||
|
int opts=0;
|
||||||
|
char *pysubtype= NULL;
|
||||||
|
int subtype= PROP_NONE;
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssffffffii:FloatProperty", kwlist, &id, &name, &description, &def, &min, &max, &soft_min, &soft_max, &step, &precision, &hidden))
|
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssffffffiiO!s:FloatProperty", kwlist, &id, &name, &description, &def, &min, &max, &soft_min, &soft_max, &step, &precision, &PySet_Type, &pyopts, &pysubtype))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
prop= RNA_def_float(srna, id, def, min, max, name, description, soft_min, soft_max);
|
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "FloatProperty(options={...}):"))
|
||||||
RNA_def_property_ui_range(prop, min, max, step, precision);
|
return NULL;
|
||||||
if(hidden) RNA_def_property_flag(prop, PROP_HIDDEN);
|
|
||||||
|
if(pysubtype && RNA_enum_value(property_subtype_number_items, pysubtype, &subtype)==0) {
|
||||||
|
PyErr_Format(PyExc_TypeError, "FloatProperty(subtype='%s'): invalid subtype.");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
prop= RNA_def_property(srna, id, PROP_FLOAT, subtype);
|
||||||
|
RNA_def_property_float_default(prop, def);
|
||||||
|
RNA_def_property_range(prop, min, max);
|
||||||
|
RNA_def_property_ui_text(prop, name, description);
|
||||||
|
RNA_def_property_ui_range(prop, soft_min, soft_max, step, precision);
|
||||||
|
|
||||||
|
if(pyopts) {
|
||||||
|
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||||
|
if((opts & PROP_ANIMATEABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATEABLE);
|
||||||
|
}
|
||||||
RNA_def_property_duplicate_pointers(prop);
|
RNA_def_property_duplicate_pointers(prop);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
@ -255,9 +417,14 @@ PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char BPy_FloatVectorProperty_doc[] =
|
static char BPy_FloatVectorProperty_doc[] =
|
||||||
".. function:: FloatVectorProperty(name=\"\", description=\"\", default=(0.0, 0.0, 0.0), min=sys.float_info.min, max=sys.float_info.max, soft_min=sys.float_info.min, soft_max=sys.float_info.max, step=3, precision=2, hidden=False, size=3)\n"
|
".. function:: FloatVectorProperty(name=\"\", description=\"\", default=(0.0, 0.0, 0.0), min=sys.float_info.min, max=sys.float_info.max, soft_min=sys.float_info.min, soft_max=sys.float_info.max, step=3, precision=2, options={'ANIMATEABLE'}, subtype='NONE', size=3)\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Returns a new vector float property definition.";
|
" Returns a new vector float property definition.\n"
|
||||||
|
"\n"
|
||||||
|
" :arg options: Enumerator in ['HIDDEN', 'ANIMATEABLE'].\n"
|
||||||
|
" :type options: set\n"
|
||||||
|
" :arg subtype: Enumerator in ['COLOR', 'TRANSLATION', 'DIRECTION', 'VELOCITY', 'ACCELERATION', 'MATRIX', 'EULER', 'QUATERNION', 'AXISANGLE', 'XYZ', 'COLOR_GAMMA', 'NONE'].\n"
|
||||||
|
" :type subtype: string";
|
||||||
PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
|
PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||||
{
|
{
|
||||||
StructRNA *srna;
|
StructRNA *srna;
|
||||||
@ -272,16 +439,28 @@ PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
return NULL; /* self's type was compatible but error getting the srna */
|
return NULL; /* self's type was compatible but error getting the srna */
|
||||||
}
|
}
|
||||||
else if(srna) {
|
else if(srna) {
|
||||||
static char *kwlist[] = {"attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", "step", "precision", "hidden", "size", NULL};
|
static char *kwlist[] = {"attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", "step", "precision", "options", "subtype", "size", NULL};
|
||||||
char *id=NULL, *name="", *description="";
|
char *id=NULL, *name="", *description="";
|
||||||
float min=-FLT_MAX, max=FLT_MAX, soft_min=-FLT_MAX, soft_max=FLT_MAX, step=3, def[PYRNA_STACK_ARRAY]={0.0f};
|
float min=-FLT_MAX, max=FLT_MAX, soft_min=-FLT_MAX, soft_max=FLT_MAX, step=3, def[PYRNA_STACK_ARRAY]={0.0f};
|
||||||
int precision= 2, hidden=0, size=3;
|
int precision= 2, size=3;
|
||||||
PropertyRNA *prop;
|
PropertyRNA *prop;
|
||||||
PyObject *pydef= NULL;
|
PyObject *pydef= NULL;
|
||||||
|
PyObject *pyopts= NULL;
|
||||||
|
int opts=0;
|
||||||
|
char *pysubtype= NULL;
|
||||||
|
int subtype= PROP_NONE;
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssOfffffiii:FloatVectorProperty", kwlist, &id, &name, &description, &pydef, &min, &max, &soft_min, &soft_max, &step, &precision, &hidden, &size))
|
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssOfffffiO!si:FloatVectorProperty", kwlist, &id, &name, &description, &pydef, &min, &max, &soft_min, &soft_max, &step, &precision, &PySet_Type, &pyopts, &pysubtype, &size))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "FloatVectorProperty(options={...}):"))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if(pysubtype && RNA_enum_value(property_subtype_array_items, pysubtype, &subtype)==0) {
|
||||||
|
PyErr_Format(PyExc_TypeError, "FloatVectorProperty(subtype='%s'): invalid subtype.");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if(size < 1 || size > PYRNA_STACK_ARRAY) {
|
if(size < 1 || size > PYRNA_STACK_ARRAY) {
|
||||||
PyErr_Format(PyExc_TypeError, "FloatVectorProperty(size=%d): size must be between 0 and %d.", size, PYRNA_STACK_ARRAY);
|
PyErr_Format(PyExc_TypeError, "FloatVectorProperty(size=%d): size must be between 0 and %d.", size, PYRNA_STACK_ARRAY);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -290,9 +469,17 @@ PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
if(pydef && BPyAsPrimitiveArray(def, pydef, size, &PyFloat_Type, "FloatVectorProperty(default=sequence)") < 0)
|
if(pydef && BPyAsPrimitiveArray(def, pydef, size, &PyFloat_Type, "FloatVectorProperty(default=sequence)") < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
prop= RNA_def_float_array(srna, id, size, pydef ? def:NULL, min, max, name, description, soft_min, soft_max);
|
prop= RNA_def_property(srna, id, PROP_FLOAT, subtype);
|
||||||
RNA_def_property_ui_range(prop, min, max, step, precision);
|
RNA_def_property_array(prop, size);
|
||||||
if(hidden) RNA_def_property_flag(prop, PROP_HIDDEN);
|
if(pydef) RNA_def_property_float_array_default(prop, def);
|
||||||
|
RNA_def_property_range(prop, min, max);
|
||||||
|
RNA_def_property_ui_text(prop, name, description);
|
||||||
|
RNA_def_property_ui_range(prop, soft_min, soft_max, step, precision);
|
||||||
|
|
||||||
|
if(pyopts) {
|
||||||
|
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||||
|
if((opts & PROP_ANIMATEABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATEABLE);
|
||||||
|
}
|
||||||
RNA_def_property_duplicate_pointers(prop);
|
RNA_def_property_duplicate_pointers(prop);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
@ -302,9 +489,14 @@ PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char BPy_StringProperty_doc[] =
|
static char BPy_StringProperty_doc[] =
|
||||||
".. function:: StringProperty(name=\"\", description=\"\", default=\"\", maxlen=0, hidden=False)\n"
|
".. function:: StringProperty(name=\"\", description=\"\", default=\"\", maxlen=0, options={'ANIMATEABLE'}, subtype='NONE')\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Returns a new string property definition.";
|
" Returns a new string property definition.\n"
|
||||||
|
"\n"
|
||||||
|
" :arg options: Enumerator in ['HIDDEN', 'ANIMATEABLE'].\n"
|
||||||
|
" :type options: set\n"
|
||||||
|
" :arg subtype: Enumerator in ['FILE_PATH', 'DIR_PATH', 'FILENAME', 'NONE'].\n"
|
||||||
|
" :type subtype: string";
|
||||||
PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw)
|
PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||||
{
|
{
|
||||||
StructRNA *srna;
|
StructRNA *srna;
|
||||||
@ -319,16 +511,35 @@ PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
return NULL; /* self's type was compatible but error getting the srna */
|
return NULL; /* self's type was compatible but error getting the srna */
|
||||||
}
|
}
|
||||||
else if(srna) {
|
else if(srna) {
|
||||||
static char *kwlist[] = {"attr", "name", "description", "default", "maxlen", "hidden", NULL};
|
static char *kwlist[] = {"attr", "name", "description", "default", "maxlen", "options", "subtype", NULL};
|
||||||
char *id=NULL, *name="", *description="", *def="";
|
char *id=NULL, *name="", *description="", *def="";
|
||||||
int maxlen=0, hidden=0;
|
int maxlen=0;
|
||||||
PropertyRNA *prop;
|
PropertyRNA *prop;
|
||||||
|
PyObject *pyopts= NULL;
|
||||||
|
int opts=0;
|
||||||
|
char *pysubtype= NULL;
|
||||||
|
int subtype= PROP_NONE;
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|sssii:StringProperty", kwlist, &id, &name, &description, &def, &maxlen, &hidden))
|
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|sssiO!s:StringProperty", kwlist, &id, &name, &description, &def, &maxlen, &PySet_Type, &pyopts, &pysubtype))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
prop= RNA_def_string(srna, id, def, maxlen, name, description);
|
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "StringProperty(options={...}):"))
|
||||||
if(hidden) RNA_def_property_flag(prop, PROP_HIDDEN);
|
return NULL;
|
||||||
|
|
||||||
|
if(pysubtype && RNA_enum_value(property_subtype_string_items, pysubtype, &subtype)==0) {
|
||||||
|
PyErr_Format(PyExc_TypeError, "StringProperty(subtype='%s'): invalid subtype.");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
prop= RNA_def_property(srna, id, PROP_STRING, subtype);
|
||||||
|
if(maxlen != 0) RNA_def_property_string_maxlength(prop, maxlen);
|
||||||
|
if(def) RNA_def_property_string_default(prop, def);
|
||||||
|
RNA_def_property_ui_text(prop, name, description);
|
||||||
|
|
||||||
|
if(pyopts) {
|
||||||
|
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||||
|
if((opts & PROP_ANIMATEABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATEABLE);
|
||||||
|
}
|
||||||
RNA_def_property_duplicate_pointers(prop);
|
RNA_def_property_duplicate_pointers(prop);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
@ -384,10 +595,12 @@ static EnumPropertyItem *enum_items_from_py(PyObject *value, const char *def, in
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char BPy_EnumProperty_doc[] =
|
static char BPy_EnumProperty_doc[] =
|
||||||
".. function:: EnumProperty(items, name=\"\", description=\"\", default=\"\", hidden=False)\n"
|
".. function:: EnumProperty(items, name=\"\", description=\"\", default=\"\", options={'ANIMATEABLE'})\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Returns a new enumerator property definition.\n"
|
" Returns a new enumerator property definition.\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
" :arg options: Enumerator in ['HIDDEN', 'ANIMATEABLE'].\n"
|
||||||
|
" :type options: set\n"
|
||||||
" :arg items: The items that make up this enumerator.\n"
|
" :arg items: The items that make up this enumerator.\n"
|
||||||
" :type items: sequence of string triplets";
|
" :type items: sequence of string triplets";
|
||||||
PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
|
PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||||
@ -404,14 +617,19 @@ PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
return NULL; /* self's type was compatible but error getting the srna */
|
return NULL; /* self's type was compatible but error getting the srna */
|
||||||
}
|
}
|
||||||
else if(srna) {
|
else if(srna) {
|
||||||
static char *kwlist[] = {"attr", "items", "name", "description", "default", "hidden", NULL};
|
static char *kwlist[] = {"attr", "items", "name", "description", "default", "options", NULL};
|
||||||
char *id=NULL, *name="", *description="", *def="";
|
char *id=NULL, *name="", *description="", *def="";
|
||||||
int defvalue=0, hidden=0;
|
int defvalue=0;
|
||||||
PyObject *items= Py_None;
|
PyObject *items= Py_None;
|
||||||
EnumPropertyItem *eitems;
|
EnumPropertyItem *eitems;
|
||||||
PropertyRNA *prop;
|
PropertyRNA *prop;
|
||||||
|
PyObject *pyopts= NULL;
|
||||||
|
int opts=0;
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kw, "sO|sssi:EnumProperty", kwlist, &id, &items, &name, &description, &def, &hidden))
|
if (!PyArg_ParseTupleAndKeywords(args, kw, "sO|sssO!:EnumProperty", kwlist, &id, &items, &name, &description, &def, &PySet_Type, &pyopts))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "EnumProperty(options={...}):"))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
eitems= enum_items_from_py(items, def, &defvalue);
|
eitems= enum_items_from_py(items, def, &defvalue);
|
||||||
@ -419,7 +637,10 @@ PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
prop= RNA_def_enum(srna, id, eitems, defvalue, name, description);
|
prop= RNA_def_enum(srna, id, eitems, defvalue, name, description);
|
||||||
if(hidden) RNA_def_property_flag(prop, PROP_HIDDEN);
|
if(pyopts) {
|
||||||
|
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||||
|
if((opts & PROP_ANIMATEABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATEABLE);
|
||||||
|
}
|
||||||
RNA_def_property_duplicate_pointers(prop);
|
RNA_def_property_duplicate_pointers(prop);
|
||||||
MEM_freeN(eitems);
|
MEM_freeN(eitems);
|
||||||
|
|
||||||
@ -449,10 +670,12 @@ static StructRNA *pointer_type_from_py(PyObject *value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char BPy_PointerProperty_doc[] =
|
static char BPy_PointerProperty_doc[] =
|
||||||
".. function:: PointerProperty(items, type=\"\", description=\"\", default=\"\", hidden=False)\n"
|
".. function:: PointerProperty(items, type=\"\", description=\"\", default=\"\", options={'ANIMATEABLE'})\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Returns a new pointer property definition.\n"
|
" Returns a new pointer property definition.\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
" :arg options: Enumerator in ['HIDDEN', 'ANIMATEABLE'].\n"
|
||||||
|
" :type options: set\n"
|
||||||
" :arg type: Dynamic type from :mod:`bpy.types`.\n"
|
" :arg type: Dynamic type from :mod:`bpy.types`.\n"
|
||||||
" :type type: class";
|
" :type type: class";
|
||||||
PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw)
|
PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||||
@ -469,14 +692,18 @@ PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
return NULL; /* self's type was compatible but error getting the srna */
|
return NULL; /* self's type was compatible but error getting the srna */
|
||||||
}
|
}
|
||||||
else if(srna) {
|
else if(srna) {
|
||||||
static char *kwlist[] = {"attr", "type", "name", "description", "hidden", NULL};
|
static char *kwlist[] = {"attr", "type", "name", "description", "options", NULL};
|
||||||
char *id=NULL, *name="", *description="";
|
char *id=NULL, *name="", *description="";
|
||||||
int hidden= 0;
|
|
||||||
PropertyRNA *prop;
|
PropertyRNA *prop;
|
||||||
StructRNA *ptype;
|
StructRNA *ptype;
|
||||||
PyObject *type= Py_None;
|
PyObject *type= Py_None;
|
||||||
|
PyObject *pyopts= NULL;
|
||||||
|
int opts=0;
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kw, "sO|ssi:PointerProperty", kwlist, &id, &type, &name, &description, &hidden))
|
if (!PyArg_ParseTupleAndKeywords(args, kw, "sO|ssO!:PointerProperty", kwlist, &id, &type, &name, &description, &PySet_Type, &pyopts))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "PointerProperty(options={...}):"))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ptype= pointer_type_from_py(type);
|
ptype= pointer_type_from_py(type);
|
||||||
@ -484,7 +711,10 @@ PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
prop= RNA_def_pointer_runtime(srna, id, ptype, name, description);
|
prop= RNA_def_pointer_runtime(srna, id, ptype, name, description);
|
||||||
if(hidden) RNA_def_property_flag(prop, PROP_HIDDEN);
|
if(pyopts) {
|
||||||
|
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||||
|
if((opts & PROP_ANIMATEABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATEABLE);
|
||||||
|
}
|
||||||
RNA_def_property_duplicate_pointers(prop);
|
RNA_def_property_duplicate_pointers(prop);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
@ -495,10 +725,12 @@ PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char BPy_CollectionProperty_doc[] =
|
static char BPy_CollectionProperty_doc[] =
|
||||||
".. function:: CollectionProperty(items, type=\"\", description=\"\", default=\"\", hidden=False)\n"
|
".. function:: CollectionProperty(items, type=\"\", description=\"\", default=\"\", options={'ANIMATEABLE'})\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Returns a new collection property definition.\n"
|
" Returns a new collection property definition.\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
" :arg options: Enumerator in ['HIDDEN', 'ANIMATEABLE'].\n"
|
||||||
|
" :type options: set\n"
|
||||||
" :arg type: Dynamic type from :mod:`bpy.types`.\n"
|
" :arg type: Dynamic type from :mod:`bpy.types`.\n"
|
||||||
" :type type: class";
|
" :type type: class";
|
||||||
PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw)
|
PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||||
@ -515,14 +747,18 @@ PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
return NULL; /* self's type was compatible but error getting the srna */
|
return NULL; /* self's type was compatible but error getting the srna */
|
||||||
}
|
}
|
||||||
else if(srna) {
|
else if(srna) {
|
||||||
static char *kwlist[] = {"attr", "type", "name", "description", "hidden", NULL};
|
static char *kwlist[] = {"attr", "type", "name", "description", "options", NULL};
|
||||||
char *id=NULL, *name="", *description="";
|
char *id=NULL, *name="", *description="";
|
||||||
int hidden= 0;
|
|
||||||
PropertyRNA *prop;
|
PropertyRNA *prop;
|
||||||
StructRNA *ptype;
|
StructRNA *ptype;
|
||||||
PyObject *type= Py_None;
|
PyObject *type= Py_None;
|
||||||
|
PyObject *pyopts= NULL;
|
||||||
|
int opts=0;
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kw, "sO|ssi:CollectionProperty", kwlist, &id, &type, &name, &description, &hidden))
|
if (!PyArg_ParseTupleAndKeywords(args, kw, "sO|ssO!:CollectionProperty", kwlist, &id, &type, &name, &description, &PySet_Type, &pyopts))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "CollectionProperty(options={...}):"))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ptype= pointer_type_from_py(type);
|
ptype= pointer_type_from_py(type);
|
||||||
@ -530,7 +766,10 @@ PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
prop= RNA_def_collection_runtime(srna, id, ptype, name, description);
|
prop= RNA_def_collection_runtime(srna, id, ptype, name, description);
|
||||||
if(hidden) RNA_def_property_flag(prop, PROP_HIDDEN);
|
if(pyopts) {
|
||||||
|
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||||
|
if((opts & PROP_ANIMATEABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATEABLE);
|
||||||
|
}
|
||||||
RNA_def_property_duplicate_pointers(prop);
|
RNA_def_property_duplicate_pointers(prop);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@
|
|||||||
#include "../generic/Mathutils.h" /* so we can have mathutils callbacks */
|
#include "../generic/Mathutils.h" /* so we can have mathutils callbacks */
|
||||||
#include "../generic/IDProp.h" /* for IDprop lookups */
|
#include "../generic/IDProp.h" /* for IDprop lookups */
|
||||||
|
|
||||||
|
|
||||||
static PyObject *prop_subscript_array_slice(BPy_PropertyRNA *self, PointerRNA *ptr, PropertyRNA *prop, int start, int stop, int length);
|
static PyObject *prop_subscript_array_slice(BPy_PropertyRNA *self, PointerRNA *ptr, PropertyRNA *prop, int start, int stop, int length);
|
||||||
|
|
||||||
/* bpyrna vector/euler/quat callbacks */
|
/* bpyrna vector/euler/quat callbacks */
|
||||||
@ -421,6 +422,69 @@ static int pyrna_string_to_enum(PyObject *item, PointerRNA *ptr, PropertyRNA *pr
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int pyrna_set_to_enum_bitfield(EnumPropertyItem *items, PyObject *value, int *r_value, const char *error_prefix)
|
||||||
|
{
|
||||||
|
/* set of enum items, concatenate all values with OR */
|
||||||
|
int ret, flag= 0;
|
||||||
|
|
||||||
|
/* set looping */
|
||||||
|
Py_ssize_t pos = 0;
|
||||||
|
PyObject *key;
|
||||||
|
long hash;
|
||||||
|
|
||||||
|
*r_value= 0;
|
||||||
|
|
||||||
|
while (_PySet_NextEntry(value, &pos, &key, &hash)) {
|
||||||
|
char *param= _PyUnicode_AsString(key);
|
||||||
|
|
||||||
|
if(param==NULL) {
|
||||||
|
PyErr_Format(PyExc_TypeError, "%s expected a string. found a %.200s", error_prefix, Py_TYPE(key)->tp_name);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(RNA_enum_value(items, param, &ret) == 0) {
|
||||||
|
char *enum_str= BPy_enum_as_string(items);
|
||||||
|
PyErr_Format(PyExc_TypeError, "%s \"%.200s\" not found in (%.200s)", error_prefix, param, enum_str);
|
||||||
|
MEM_freeN(enum_str);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
flag |= ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
*r_value= flag;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int pyrna_prop_to_enum_bitfield(PointerRNA *ptr, PropertyRNA *prop, PyObject *value, int *r_value, const char *error_prefix)
|
||||||
|
{
|
||||||
|
EnumPropertyItem *item;
|
||||||
|
int ret;
|
||||||
|
int free= FALSE;
|
||||||
|
|
||||||
|
*r_value= 0;
|
||||||
|
|
||||||
|
RNA_property_enum_items(BPy_GetContext(), ptr, prop, &item, NULL, &free);
|
||||||
|
|
||||||
|
if(item) {
|
||||||
|
ret= pyrna_set_to_enum_bitfield(item, value, r_value, error_prefix);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(PySet_GET_SIZE(value)) {
|
||||||
|
PyErr_Format(PyExc_TypeError, "%s: empty enum \"%.200s\" could not have any values assigned.", error_prefix, RNA_property_identifier(prop));
|
||||||
|
ret= -1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ret= 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(free)
|
||||||
|
MEM_freeN(item);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
PyObject *pyrna_enum_bitfield_to_py(EnumPropertyItem *items, int value)
|
PyObject *pyrna_enum_bitfield_to_py(EnumPropertyItem *items, int value)
|
||||||
{
|
{
|
||||||
PyObject *ret= PySet_New(NULL);
|
PyObject *ret= PySet_New(NULL);
|
||||||
@ -738,7 +802,7 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, ParameterList *parms, v
|
|||||||
}
|
}
|
||||||
case PROP_ENUM:
|
case PROP_ENUM:
|
||||||
{
|
{
|
||||||
int val= 0, tmpval;
|
int val= 0;
|
||||||
|
|
||||||
if (PyUnicode_Check(value)) {
|
if (PyUnicode_Check(value)) {
|
||||||
if (!pyrna_string_to_enum(value, ptr, prop, &val, error_prefix))
|
if (!pyrna_string_to_enum(value, ptr, prop, &val, error_prefix))
|
||||||
@ -747,18 +811,8 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, ParameterList *parms, v
|
|||||||
else if (PyAnySet_Check(value)) {
|
else if (PyAnySet_Check(value)) {
|
||||||
if(RNA_property_flag(prop) & PROP_ENUM_FLAG) {
|
if(RNA_property_flag(prop) & PROP_ENUM_FLAG) {
|
||||||
/* set of enum items, concatenate all values with OR */
|
/* set of enum items, concatenate all values with OR */
|
||||||
|
if(pyrna_prop_to_enum_bitfield(ptr, prop, value, &val, error_prefix) < 0)
|
||||||
/* set looping */
|
return -1;
|
||||||
Py_ssize_t pos = 0;
|
|
||||||
PyObject *key;
|
|
||||||
long hash;
|
|
||||||
|
|
||||||
while (_PySet_NextEntry(value, &pos, &key, &hash)) {
|
|
||||||
if (!pyrna_string_to_enum(key, ptr, prop, &tmpval, error_prefix))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
val |= tmpval;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PyErr_Format(PyExc_TypeError, "%.200s, %.200s.%.200s is not a bitflag enum type", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop));
|
PyErr_Format(PyExc_TypeError, "%.200s, %.200s.%.200s is not a bitflag enum type", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop));
|
||||||
@ -3679,7 +3733,9 @@ static int deferred_register_prop(StructRNA *srna, PyObject *item, PyObject *key
|
|||||||
PyErr_Print();
|
PyErr_Print();
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
|
|
||||||
|
// PyLineSpit();
|
||||||
PyErr_Format(PyExc_ValueError, "StructRNA \"%.200s\" registration error: %.200s could not register\n", RNA_struct_identifier(srna), _PyUnicode_AsString(key));
|
PyErr_Format(PyExc_ValueError, "StructRNA \"%.200s\" registration error: %.200s could not register\n", RNA_struct_identifier(srna), _PyUnicode_AsString(key));
|
||||||
|
|
||||||
Py_DECREF(dummy_args);
|
Py_DECREF(dummy_args);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -80,6 +80,7 @@ int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, int all_args, const cha
|
|||||||
PyObject * pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop);
|
PyObject * pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop);
|
||||||
|
|
||||||
PyObject *pyrna_enum_bitfield_to_py(struct EnumPropertyItem *items, int value);
|
PyObject *pyrna_enum_bitfield_to_py(struct EnumPropertyItem *items, int value);
|
||||||
|
int pyrna_set_to_enum_bitfield(EnumPropertyItem *items, PyObject *value, int *r_value, const char *error_prefix);
|
||||||
|
|
||||||
/* function for registering types */
|
/* function for registering types */
|
||||||
PyObject *pyrna_basetype_register(PyObject *self, PyObject *args);
|
PyObject *pyrna_basetype_register(PyObject *self, PyObject *args);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user