RNA
* Enums can now be dynamically created in the _itemf callback, using RNA_enum_item(s)_add, RNA_enum_item_end. All places asking for enum items now need to potentially free the items. * This callback now also gets context, this was added specifically for operators. This doesn't fit design well at all, needed to do some ugly hacks, but can't find a good solution at the moment. * All enums must have a default list of items too, even with an _itemf callback, for docs and fallback in case there is no context. * Used by MESH_OT_merge, MESH_OT_select_similar, TFM_OT_select_orientation. * Also changes some operator properties that were enums to booleas (unselected, deselect), to make them consistent with other ops.
This commit is contained in:
@@ -242,7 +242,7 @@ class SEQUENCER_MT_strip(bpy.types.Menu):
|
|||||||
layout.itemO("SEQUENCER_OT_mute")
|
layout.itemO("SEQUENCER_OT_mute")
|
||||||
layout.itemO("SEQUENCER_OT_unmute")
|
layout.itemO("SEQUENCER_OT_unmute")
|
||||||
|
|
||||||
layout.item_enumO("SEQUENCER_OT_mute", property="type", value='UNSELECTED', text="Mute Deselected Strips")
|
layout.item_booleanO("SEQUENCER_OT_mute", "unselected", 1, text="Mute Deselected Strips")
|
||||||
|
|
||||||
layout.itemO("SEQUENCER_OT_snap")
|
layout.itemO("SEQUENCER_OT_snap")
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ struct wmEvent;
|
|||||||
struct bContext;
|
struct bContext;
|
||||||
struct Object;
|
struct Object;
|
||||||
struct uiLayout;
|
struct uiLayout;
|
||||||
|
struct EnumPropertyItem;
|
||||||
|
|
||||||
void transform_keymap_for_space(struct wmWindowManager *wm, struct ListBase *keymap, int spaceid);
|
void transform_keymap_for_space(struct wmWindowManager *wm, struct ListBase *keymap, int spaceid);
|
||||||
void transform_operatortypes(void);
|
void transform_operatortypes(void);
|
||||||
@@ -114,7 +115,7 @@ int BIF_menuselectTransformOrientation(void);
|
|||||||
void BIF_selectTransformOrientation(struct bContext *C, struct TransformOrientation *ts);
|
void BIF_selectTransformOrientation(struct bContext *C, struct TransformOrientation *ts);
|
||||||
void BIF_selectTransformOrientationValue(struct bContext *C, int orientation);
|
void BIF_selectTransformOrientationValue(struct bContext *C, int orientation);
|
||||||
|
|
||||||
void BIF_menuTransformOrientation(struct bContext *C, struct uiLayout *layout, void *arg);
|
struct EnumPropertyItem *BIF_enumTransformOrientation(struct bContext *C);
|
||||||
char * BIF_menustringTransformOrientation(const struct bContext *C, char *title); /* the returned value was allocated and needs to be freed after use */
|
char * BIF_menustringTransformOrientation(const struct bContext *C, char *title); /* the returned value was allocated and needs to be freed after use */
|
||||||
int BIF_countTransformOrientation(const struct bContext *C);
|
int BIF_countTransformOrientation(const struct bContext *C);
|
||||||
|
|
||||||
|
|||||||
@@ -1615,6 +1615,7 @@ uiBlock *uiBeginBlock(const bContext *C, ARegion *region, const char *name, shor
|
|||||||
block= MEM_callocN(sizeof(uiBlock), "uiBlock");
|
block= MEM_callocN(sizeof(uiBlock), "uiBlock");
|
||||||
block->active= 1;
|
block->active= 1;
|
||||||
block->dt= dt;
|
block->dt= dt;
|
||||||
|
block->evil_C= C; // XXX
|
||||||
BLI_strncpy(block->name, name, sizeof(block->name));
|
BLI_strncpy(block->name, name, sizeof(block->name));
|
||||||
|
|
||||||
if(region)
|
if(region)
|
||||||
@@ -2113,11 +2114,11 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1,
|
|||||||
/* use rna values if parameters are not specified */
|
/* use rna values if parameters are not specified */
|
||||||
if(!str) {
|
if(!str) {
|
||||||
if(type == MENU && proptype == PROP_ENUM) {
|
if(type == MENU && proptype == PROP_ENUM) {
|
||||||
const EnumPropertyItem *item;
|
EnumPropertyItem *item;
|
||||||
DynStr *dynstr;
|
DynStr *dynstr;
|
||||||
int i, totitem, value;
|
int i, totitem, value, free;
|
||||||
|
|
||||||
RNA_property_enum_items(ptr, prop, &item, &totitem);
|
RNA_property_enum_items(block->evil_C, ptr, prop, &item, &totitem, &free);
|
||||||
value= RNA_property_enum_get(ptr, prop);
|
value= RNA_property_enum_get(ptr, prop);
|
||||||
|
|
||||||
dynstr= BLI_dynstr_new();
|
dynstr= BLI_dynstr_new();
|
||||||
@@ -2136,13 +2137,16 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1,
|
|||||||
str= BLI_dynstr_get_cstring(dynstr);
|
str= BLI_dynstr_get_cstring(dynstr);
|
||||||
BLI_dynstr_free(dynstr);
|
BLI_dynstr_free(dynstr);
|
||||||
|
|
||||||
|
if(free)
|
||||||
|
MEM_freeN(item);
|
||||||
|
|
||||||
freestr= 1;
|
freestr= 1;
|
||||||
}
|
}
|
||||||
else if(type == ROW && proptype == PROP_ENUM) {
|
else if(type == ROW && proptype == PROP_ENUM) {
|
||||||
const EnumPropertyItem *item;
|
EnumPropertyItem *item;
|
||||||
int i, totitem;
|
int i, totitem, free;
|
||||||
|
|
||||||
RNA_property_enum_items(ptr, prop, &item, &totitem);
|
RNA_property_enum_items(block->evil_C, ptr, prop, &item, &totitem, &free);
|
||||||
for(i=0; i<totitem; i++) {
|
for(i=0; i<totitem; i++) {
|
||||||
if(item[i].identifier[0] && item[i].value == (int)max) {
|
if(item[i].identifier[0] && item[i].value == (int)max) {
|
||||||
str= (char*)item[i].name;
|
str= (char*)item[i].name;
|
||||||
@@ -2152,6 +2156,8 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1,
|
|||||||
|
|
||||||
if(!str)
|
if(!str)
|
||||||
str= (char*)RNA_property_ui_name(prop);
|
str= (char*)RNA_property_ui_name(prop);
|
||||||
|
if(free)
|
||||||
|
MEM_freeN(item);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
str= (char*)RNA_property_ui_name(prop);
|
str= (char*)RNA_property_ui_name(prop);
|
||||||
@@ -2161,10 +2167,10 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1,
|
|||||||
|
|
||||||
if(!tip) {
|
if(!tip) {
|
||||||
if(type == ROW && proptype == PROP_ENUM) {
|
if(type == ROW && proptype == PROP_ENUM) {
|
||||||
const EnumPropertyItem *item;
|
EnumPropertyItem *item;
|
||||||
int i, totitem;
|
int i, totitem, free;
|
||||||
|
|
||||||
RNA_property_enum_items(ptr, prop, &item, &totitem);
|
RNA_property_enum_items(block->evil_C, ptr, prop, &item, &totitem, &free);
|
||||||
|
|
||||||
for(i=0; i<totitem; i++) {
|
for(i=0; i<totitem; i++) {
|
||||||
if(item[i].identifier[0] && item[i].value == (int)max) {
|
if(item[i].identifier[0] && item[i].value == (int)max) {
|
||||||
@@ -2173,6 +2179,9 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(free)
|
||||||
|
MEM_freeN(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -290,6 +290,8 @@ struct uiBlock {
|
|||||||
int tooltipdisabled; // to avoid tooltip after click
|
int tooltipdisabled; // to avoid tooltip after click
|
||||||
|
|
||||||
int active; // to keep blocks while drawing and free them afterwards
|
int active; // to keep blocks while drawing and free them afterwards
|
||||||
|
|
||||||
|
void *evil_C; // XXX hack for dynamic operator enums
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct uiSafetyRct {
|
typedef struct uiSafetyRct {
|
||||||
|
|||||||
@@ -429,13 +429,13 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, char *name, int icon
|
|||||||
|
|
||||||
static void ui_item_enum_row(uiLayout *layout, uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, char *uiname, int x, int y, int w, int h)
|
static void ui_item_enum_row(uiLayout *layout, uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, char *uiname, int x, int y, int w, int h)
|
||||||
{
|
{
|
||||||
const EnumPropertyItem *item;
|
EnumPropertyItem *item;
|
||||||
const char *identifier;
|
const char *identifier;
|
||||||
char *name;
|
char *name;
|
||||||
int a, totitem, itemw, icon, value;
|
int a, totitem, itemw, icon, value, free;
|
||||||
|
|
||||||
identifier= RNA_property_identifier(prop);
|
identifier= RNA_property_identifier(prop);
|
||||||
RNA_property_enum_items(ptr, prop, &item, &totitem);
|
RNA_property_enum_items(block->evil_C, ptr, prop, &item, &totitem, &free);
|
||||||
|
|
||||||
uiBlockSetCurLayout(block, ui_item_local_sublayout(layout, layout, 1));
|
uiBlockSetCurLayout(block, ui_item_local_sublayout(layout, layout, 1));
|
||||||
for(a=0; a<totitem; a++) {
|
for(a=0; a<totitem; a++) {
|
||||||
@@ -455,6 +455,9 @@ static void ui_item_enum_row(uiLayout *layout, uiBlock *block, PointerRNA *ptr,
|
|||||||
uiDefButR(block, ROW, 0, name, 0, 0, itemw, h, ptr, identifier, -1, 0, value, -1, -1, NULL);
|
uiDefButR(block, ROW, 0, name, 0, 0, itemw, h, ptr, identifier, -1, 0, value, -1, -1, NULL);
|
||||||
}
|
}
|
||||||
uiBlockSetCurLayout(block, layout);
|
uiBlockSetCurLayout(block, layout);
|
||||||
|
|
||||||
|
if(free)
|
||||||
|
MEM_freeN(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create label + button for RNA property */
|
/* create label + button for RNA property */
|
||||||
@@ -545,7 +548,7 @@ void uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, IDPropert
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *ui_menu_enumpropname(char *opname, char *propname, int retval)
|
static char *ui_menu_enumpropname(uiLayout *layout, char *opname, char *propname, int retval)
|
||||||
{
|
{
|
||||||
wmOperatorType *ot= WM_operatortype_find(opname);
|
wmOperatorType *ot= WM_operatortype_find(opname);
|
||||||
PointerRNA ptr;
|
PointerRNA ptr;
|
||||||
@@ -558,15 +561,20 @@ static char *ui_menu_enumpropname(char *opname, char *propname, int retval)
|
|||||||
prop= RNA_struct_find_property(&ptr, propname);
|
prop= RNA_struct_find_property(&ptr, propname);
|
||||||
|
|
||||||
if(prop) {
|
if(prop) {
|
||||||
const EnumPropertyItem *item;
|
EnumPropertyItem *item;
|
||||||
int totitem;
|
int totitem, free;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
||||||
RNA_property_enum_items(&ptr, prop, &item, &totitem);
|
RNA_property_enum_items(layout->root->block->evil_C, &ptr, prop, &item, &totitem, &free);
|
||||||
if(RNA_enum_name(item, retval, &name))
|
if(RNA_enum_name(item, retval, &name)) {
|
||||||
|
if(free) MEM_freeN(item);
|
||||||
return (char*)name;
|
return (char*)name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(free)
|
||||||
|
MEM_freeN(item);
|
||||||
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -578,7 +586,7 @@ void uiItemEnumO(uiLayout *layout, char *name, int icon, char *opname, char *pro
|
|||||||
RNA_enum_set(&ptr, propname, value);
|
RNA_enum_set(&ptr, propname, value);
|
||||||
|
|
||||||
if(!name)
|
if(!name)
|
||||||
name= ui_menu_enumpropname(opname, propname, value);
|
name= ui_menu_enumpropname(layout, opname, propname, value);
|
||||||
|
|
||||||
uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext);
|
uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext);
|
||||||
}
|
}
|
||||||
@@ -598,16 +606,19 @@ void uiItemsEnumO(uiLayout *layout, char *opname, char *propname)
|
|||||||
prop= RNA_struct_find_property(&ptr, propname);
|
prop= RNA_struct_find_property(&ptr, propname);
|
||||||
|
|
||||||
if(prop && RNA_property_type(prop) == PROP_ENUM) {
|
if(prop && RNA_property_type(prop) == PROP_ENUM) {
|
||||||
const EnumPropertyItem *item;
|
EnumPropertyItem *item;
|
||||||
int totitem, i;
|
int totitem, i, free;
|
||||||
|
|
||||||
RNA_property_enum_items(&ptr, prop, &item, &totitem);
|
RNA_property_enum_items(layout->root->block->evil_C, &ptr, prop, &item, &totitem, &free);
|
||||||
|
|
||||||
for(i=0; i<totitem; i++)
|
for(i=0; i<totitem; i++)
|
||||||
if(item[i].identifier[0])
|
if(item[i].identifier[0])
|
||||||
uiItemEnumO(layout, (char*)item[i].name, item[i].icon, opname, propname, item[i].value);
|
uiItemEnumO(layout, (char*)item[i].name, item[i].icon, opname, propname, item[i].value);
|
||||||
else
|
else
|
||||||
uiItemS(layout);
|
uiItemS(layout);
|
||||||
|
|
||||||
|
if(free)
|
||||||
|
MEM_freeN(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -618,18 +629,22 @@ void uiItemEnumO_string(uiLayout *layout, char *name, int icon, char *opname, ch
|
|||||||
|
|
||||||
/* for getting the enum */
|
/* for getting the enum */
|
||||||
PropertyRNA *prop;
|
PropertyRNA *prop;
|
||||||
const EnumPropertyItem *item;
|
EnumPropertyItem *item;
|
||||||
int value;
|
int value, free;
|
||||||
|
|
||||||
WM_operator_properties_create(&ptr, opname);
|
WM_operator_properties_create(&ptr, opname);
|
||||||
|
|
||||||
/* enum lookup */
|
/* enum lookup */
|
||||||
if((prop= RNA_struct_find_property(&ptr, propname))) {
|
if((prop= RNA_struct_find_property(&ptr, propname))) {
|
||||||
RNA_property_enum_items(&ptr, prop, &item, NULL);
|
RNA_property_enum_items(layout->root->block->evil_C, &ptr, prop, &item, NULL, &free);
|
||||||
if(RNA_enum_value_from_id(item, value_str, &value)==0) {
|
if(RNA_enum_value_from_id(item, value_str, &value)==0) {
|
||||||
|
if(free) MEM_freeN(item);
|
||||||
printf("uiItemEnumO_string: %s.%s, enum %s not found.\n", RNA_struct_identifier(ptr.type), propname, value_str);
|
printf("uiItemEnumO_string: %s.%s, enum %s not found.\n", RNA_struct_identifier(ptr.type), propname, value_str);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(free)
|
||||||
|
MEM_freeN(item);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("uiItemEnumO_string: %s.%s not found.\n", RNA_struct_identifier(ptr.type), propname);
|
printf("uiItemEnumO_string: %s.%s not found.\n", RNA_struct_identifier(ptr.type), propname);
|
||||||
@@ -640,7 +655,7 @@ void uiItemEnumO_string(uiLayout *layout, char *name, int icon, char *opname, ch
|
|||||||
|
|
||||||
/* same as uiItemEnumO */
|
/* same as uiItemEnumO */
|
||||||
if(!name)
|
if(!name)
|
||||||
name= ui_menu_enumpropname(opname, propname, value);
|
name= ui_menu_enumpropname(layout, opname, propname, value);
|
||||||
|
|
||||||
uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext);
|
uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext);
|
||||||
}
|
}
|
||||||
@@ -845,8 +860,8 @@ void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr,
|
|||||||
void uiItemEnumR_string(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, char *value)
|
void uiItemEnumR_string(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, char *value)
|
||||||
{
|
{
|
||||||
PropertyRNA *prop;
|
PropertyRNA *prop;
|
||||||
const EnumPropertyItem *item;
|
EnumPropertyItem *item;
|
||||||
int ivalue, a;
|
int ivalue, a, free;
|
||||||
|
|
||||||
if(!ptr->data || !propname)
|
if(!ptr->data || !propname)
|
||||||
return;
|
return;
|
||||||
@@ -859,9 +874,10 @@ void uiItemEnumR_string(uiLayout *layout, char *name, int icon, struct PointerRN
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RNA_property_enum_items(ptr, prop, &item, NULL);
|
RNA_property_enum_items(layout->root->block->evil_C, ptr, prop, &item, NULL, &free);
|
||||||
|
|
||||||
if(!RNA_enum_value_from_id(item, value, &ivalue)) {
|
if(!RNA_enum_value_from_id(item, value, &ivalue)) {
|
||||||
|
if(free) MEM_freeN(item);
|
||||||
ui_item_disabled(layout, propname);
|
ui_item_disabled(layout, propname);
|
||||||
printf("uiItemEnumR: enum property value not found: %s\n", value);
|
printf("uiItemEnumR: enum property value not found: %s\n", value);
|
||||||
return;
|
return;
|
||||||
@@ -873,6 +889,9 @@ void uiItemEnumR_string(uiLayout *layout, char *name, int icon, struct PointerRN
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(free)
|
||||||
|
MEM_freeN(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname)
|
void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname)
|
||||||
@@ -887,16 +906,19 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(RNA_property_type(prop) == PROP_ENUM) {
|
if(RNA_property_type(prop) == PROP_ENUM) {
|
||||||
const EnumPropertyItem *item;
|
EnumPropertyItem *item;
|
||||||
int totitem, i;
|
int totitem, i, free;
|
||||||
|
|
||||||
RNA_property_enum_items(ptr, prop, &item, &totitem);
|
RNA_property_enum_items(layout->root->block->evil_C, ptr, prop, &item, &totitem, &free);
|
||||||
|
|
||||||
for(i=0; i<totitem; i++)
|
for(i=0; i<totitem; i++)
|
||||||
if(item[i].identifier[0])
|
if(item[i].identifier[0])
|
||||||
uiItemEnumR(layout, (char*)item[i].name, 0, ptr, propname, item[i].value);
|
uiItemEnumR(layout, (char*)item[i].name, 0, ptr, propname, item[i].value);
|
||||||
else
|
else
|
||||||
uiItemS(layout);
|
uiItemS(layout);
|
||||||
|
|
||||||
|
if(free)
|
||||||
|
MEM_freeN(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1606,13 +1606,13 @@ static int mesh_separate_exec(bContext *C, wmOperator *op)
|
|||||||
{
|
{
|
||||||
Scene *scene= CTX_data_scene(C);
|
Scene *scene= CTX_data_scene(C);
|
||||||
Base *base= CTX_data_active_base(C);
|
Base *base= CTX_data_active_base(C);
|
||||||
int retval= 0;
|
int retval= 0, type= RNA_enum_get(op->ptr, "type");
|
||||||
|
|
||||||
if(RNA_enum_is_equal(op->ptr, "type", "SELECTED"))
|
if(type == 0)
|
||||||
retval= mesh_separate_selected(scene, base);
|
retval= mesh_separate_selected(scene, base);
|
||||||
else if(RNA_enum_is_equal(op->ptr, "type", "MATERIAL"))
|
else if(type == 1)
|
||||||
retval= mesh_separate_material (scene, base);
|
retval= mesh_separate_material (scene, base);
|
||||||
else if(RNA_enum_is_equal(op->ptr, "type", "LOOSE"))
|
else if(type == 2)
|
||||||
retval= mesh_separate_loose(scene, base);
|
retval= mesh_separate_loose(scene, base);
|
||||||
|
|
||||||
if(retval) {
|
if(retval) {
|
||||||
|
|||||||
@@ -1227,12 +1227,29 @@ static int select_similar_exec(bContext *C, wmOperator *op)
|
|||||||
return similar_face_select_exec(C, op);
|
return similar_face_select_exec(C, op);
|
||||||
}
|
}
|
||||||
|
|
||||||
static EnumPropertyItem *select_similar_type_itemf(PointerRNA *ptr)
|
static EnumPropertyItem *select_similar_type_itemf(bContext *C, PointerRNA *ptr, int *free)
|
||||||
{
|
{
|
||||||
/* XXX need context! */
|
Object *obedit= CTX_data_edit_object(C);
|
||||||
return prop_simface_types;
|
|
||||||
return prop_simvertex_types;
|
if(obedit && obedit->type == OB_MESH) {
|
||||||
return prop_simedge_types;
|
EditMesh *em= BKE_mesh_get_editmesh(obedit->data);
|
||||||
|
EnumPropertyItem *item= NULL;
|
||||||
|
int totitem= 0;
|
||||||
|
|
||||||
|
if(em->selectmode & SCE_SELECT_VERTEX)
|
||||||
|
RNA_enum_items_add(&item, &totitem, prop_simvertex_types);
|
||||||
|
else if(em->selectmode & SCE_SELECT_EDGE)
|
||||||
|
RNA_enum_items_add(&item, &totitem, prop_simedge_types);
|
||||||
|
else if(em->selectmode & SCE_SELECT_FACE)
|
||||||
|
RNA_enum_items_add(&item, &totitem, prop_simface_types);
|
||||||
|
RNA_enum_item_end(&item, &totitem);
|
||||||
|
|
||||||
|
*free= 1;
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MESH_OT_select_similar(wmOperatorType *ot)
|
void MESH_OT_select_similar(wmOperatorType *ot)
|
||||||
|
|||||||
@@ -5799,29 +5799,38 @@ static EnumPropertyItem merge_type_items[]= {
|
|||||||
{5, "COLLAPSE", 0, "Collapse", ""},
|
{5, "COLLAPSE", 0, "Collapse", ""},
|
||||||
{0, NULL, 0, NULL, NULL}};
|
{0, NULL, 0, NULL, NULL}};
|
||||||
|
|
||||||
static EnumPropertyItem *merge_type_itemf(PointerRNA *ptr)
|
static EnumPropertyItem *merge_type_itemf(bContext *C, PointerRNA *ptr, int *free)
|
||||||
{
|
{
|
||||||
/* XXX need context here */
|
|
||||||
#if 0
|
|
||||||
Scene *scene= CTX_data_scene(C);
|
|
||||||
Object *obedit= CTX_data_edit_object(C);
|
Object *obedit= CTX_data_edit_object(C);
|
||||||
EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
|
|
||||||
|
|
||||||
if(em->selectmode & SCE_SELECT_VERTEX)
|
if(obedit && obedit->type == OB_MESH) {
|
||||||
|
EditMesh *em= BKE_mesh_get_editmesh(obedit->data);
|
||||||
|
EnumPropertyItem *item= NULL;
|
||||||
|
int totitem= 0;
|
||||||
|
|
||||||
|
if(em->selectmode & SCE_SELECT_VERTEX) {
|
||||||
if(em->selected.first && em->selected.last &&
|
if(em->selected.first && em->selected.last &&
|
||||||
((EditSelection*)em->selected.first)->type == EDITVERT && ((EditSelection*)em->selected.last)->type == EDITVERT)
|
((EditSelection*)em->selected.first)->type == EDITVERT && ((EditSelection*)em->selected.last)->type == EDITVERT) {
|
||||||
event = pupmenu("Merge %t|At First %x6|At Last%x1|At Center%x3|At Cursor%x4|Collapse%x2");
|
RNA_enum_item_add(&item, &totitem, &merge_type_items[0]);
|
||||||
|
RNA_enum_item_add(&item, &totitem, &merge_type_items[1]);
|
||||||
|
}
|
||||||
else if(em->selected.first && ((EditSelection*)em->selected.first)->type == EDITVERT)
|
else if(em->selected.first && ((EditSelection*)em->selected.first)->type == EDITVERT)
|
||||||
event = pupmenu("Merge %t|At First %x6|At Center%x3|At Cursor%x4|Collapse%x2");
|
RNA_enum_item_add(&item, &totitem, &merge_type_items[1]);
|
||||||
else if(em->selected.last && ((EditSelection*)em->selected.last)->type == EDITVERT)
|
else if(em->selected.last && ((EditSelection*)em->selected.last)->type == EDITVERT)
|
||||||
event = pupmenu("Merge %t|At Last %x1|At Center%x3|At Cursor%x4|Collapse%x2");
|
RNA_enum_item_add(&item, &totitem, &merge_type_items[0]);
|
||||||
else event = pupmenu("Merge %t|At Center%x3|At Cursor%x4|Collapse%x2");
|
}
|
||||||
else event = pupmenu("Merge %t|At Center%x3|At Cursor%x4|Collapse%x2");
|
|
||||||
|
|
||||||
BKE_mesh_end_editmesh(obedit->data, em);
|
RNA_enum_item_add(&item, &totitem, &merge_type_items[2]);
|
||||||
#endif
|
RNA_enum_item_add(&item, &totitem, &merge_type_items[3]);
|
||||||
|
RNA_enum_item_add(&item, &totitem, &merge_type_items[4]);
|
||||||
|
RNA_enum_item_end(&item, &totitem);
|
||||||
|
|
||||||
return merge_type_items;
|
*free= 1;
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MESH_OT_merge(wmOperatorType *ot)
|
void MESH_OT_merge(wmOperatorType *ot)
|
||||||
@@ -5841,7 +5850,7 @@ void MESH_OT_merge(wmOperatorType *ot)
|
|||||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||||
|
|
||||||
/* properties */
|
/* properties */
|
||||||
prop= RNA_def_enum(ot->srna, "type", merge_type_items, 6, "Type", "Merge method to use.");
|
prop= RNA_def_enum(ot->srna, "type", merge_type_items, 3, "Type", "Merge method to use.");
|
||||||
RNA_def_enum_funcs(prop, merge_type_itemf);
|
RNA_def_enum_funcs(prop, merge_type_itemf);
|
||||||
RNA_def_boolean(ot->srna, "uvs", 0, "UVs", "Move UVs according to merge.");
|
RNA_def_boolean(ot->srna, "uvs", 0, "UVs", "Move UVs according to merge.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ static int vertex_specials_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
|||||||
uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_REGION_WIN);
|
uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_REGION_WIN);
|
||||||
|
|
||||||
uiItemO(layout, "Remove Doubles", 0, "MESH_OT_remove_doubles");
|
uiItemO(layout, "Remove Doubles", 0, "MESH_OT_remove_doubles");
|
||||||
uiItemO(layout, "Merge...", 0, "MESH_OT_merge"); // mergmenu(em)
|
uiItemO(layout, "Merge...", 0, "MESH_OT_merge");
|
||||||
uiItemO(layout, "Smooth", 0, "MESH_OT_vertices_smooth");
|
uiItemO(layout, "Smooth", 0, "MESH_OT_vertices_smooth");
|
||||||
uiItemO(layout, "Select Vertex Path", 0, "MESH_OT_select_vertex_path");
|
uiItemO(layout, "Select Vertex Path", 0, "MESH_OT_select_vertex_path");
|
||||||
//uiItemO(layout, "Blend From Shape", 0, "MESH_OT_blend_from_shape");
|
//uiItemO(layout, "Blend From Shape", 0, "MESH_OT_blend_from_shape");
|
||||||
@@ -387,6 +387,7 @@ void ED_keymap_mesh(wmWindowManager *wm)
|
|||||||
WM_keymap_add_item(keymap, "MESH_OT_colors_mirror",EIGHTKEY, KM_PRESS, KM_ALT, 0);
|
WM_keymap_add_item(keymap, "MESH_OT_colors_mirror",EIGHTKEY, KM_PRESS, KM_ALT, 0);
|
||||||
|
|
||||||
WM_keymap_add_item(keymap, "MESH_OT_rip",VKEY, KM_PRESS, 0, 0);
|
WM_keymap_add_item(keymap, "MESH_OT_rip",VKEY, KM_PRESS, 0, 0);
|
||||||
|
WM_keymap_add_item(keymap, "MESH_OT_merge", MKEY, KM_PRESS, KM_ALT, 0);
|
||||||
|
|
||||||
/* add/remove */
|
/* add/remove */
|
||||||
WM_keymap_add_item(keymap, "MESH_OT_edge_face_add", FKEY, KM_PRESS, 0, 0);
|
WM_keymap_add_item(keymap, "MESH_OT_edge_face_add", FKEY, KM_PRESS, 0, 0);
|
||||||
|
|||||||
@@ -1379,20 +1379,21 @@ static EnumPropertyItem prop_clear_parent_types[] = {
|
|||||||
/* note, poll should check for editable scene */
|
/* note, poll should check for editable scene */
|
||||||
static int parent_clear_exec(bContext *C, wmOperator *op)
|
static int parent_clear_exec(bContext *C, wmOperator *op)
|
||||||
{
|
{
|
||||||
|
int type= RNA_enum_get(op->ptr, "type");
|
||||||
|
|
||||||
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
|
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
|
||||||
|
|
||||||
if(RNA_enum_is_equal(op->ptr, "type", "CLEAR")) {
|
if(type == 0) {
|
||||||
ob->parent= NULL;
|
ob->parent= NULL;
|
||||||
}
|
}
|
||||||
if(RNA_enum_is_equal(op->ptr, "type", "CLEAR_KEEP_TRANSFORM")) {
|
else if(type == 1) {
|
||||||
ob->parent= NULL;
|
ob->parent= NULL;
|
||||||
ob->track= NULL;
|
ob->track= NULL;
|
||||||
ED_object_apply_obmat(ob);
|
ED_object_apply_obmat(ob);
|
||||||
}
|
}
|
||||||
if(RNA_enum_is_equal(op->ptr, "type", "CLEAR_INVERSE")) {
|
else if(type == 2)
|
||||||
Mat4One(ob->parentinv);
|
Mat4One(ob->parentinv);
|
||||||
}
|
|
||||||
ob->recalc |= OB_RECALC;
|
ob->recalc |= OB_RECALC;
|
||||||
}
|
}
|
||||||
CTX_DATA_END;
|
CTX_DATA_END;
|
||||||
@@ -1435,6 +1436,8 @@ static EnumPropertyItem prop_clear_track_types[] = {
|
|||||||
/* note, poll should check for editable scene */
|
/* note, poll should check for editable scene */
|
||||||
static int object_track_clear_exec(bContext *C, wmOperator *op)
|
static int object_track_clear_exec(bContext *C, wmOperator *op)
|
||||||
{
|
{
|
||||||
|
int type= RNA_enum_get(op->ptr, "type");
|
||||||
|
|
||||||
if(CTX_data_edit_object(C)) {
|
if(CTX_data_edit_object(C)) {
|
||||||
BKE_report(op->reports, RPT_ERROR, "Operation cannot be performed in EditMode");
|
BKE_report(op->reports, RPT_ERROR, "Operation cannot be performed in EditMode");
|
||||||
return OPERATOR_CANCELLED;
|
return OPERATOR_CANCELLED;
|
||||||
@@ -1443,10 +1446,9 @@ static int object_track_clear_exec(bContext *C, wmOperator *op)
|
|||||||
ob->track= NULL;
|
ob->track= NULL;
|
||||||
ob->recalc |= OB_RECALC;
|
ob->recalc |= OB_RECALC;
|
||||||
|
|
||||||
if(RNA_enum_is_equal(op->ptr, "type", "CLEAR_KEEP_TRANSFORM")) {
|
if(type == 1)
|
||||||
ED_object_apply_obmat(ob);
|
ED_object_apply_obmat(ob);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
CTX_DATA_END;
|
CTX_DATA_END;
|
||||||
|
|
||||||
DAG_scene_sort(CTX_data_scene(C));
|
DAG_scene_sort(CTX_data_scene(C));
|
||||||
@@ -2663,8 +2665,9 @@ static EnumPropertyItem prop_make_track_types[] = {
|
|||||||
static int track_set_exec(bContext *C, wmOperator *op)
|
static int track_set_exec(bContext *C, wmOperator *op)
|
||||||
{
|
{
|
||||||
Scene *scene= CTX_data_scene(C);
|
Scene *scene= CTX_data_scene(C);
|
||||||
|
int type= RNA_enum_get(op->ptr, "type");
|
||||||
|
|
||||||
if(RNA_enum_is_equal(op->ptr, "type", "TRACKTO")){
|
if(type == 1) {
|
||||||
bConstraint *con;
|
bConstraint *con;
|
||||||
bTrackToConstraint *data;
|
bTrackToConstraint *data;
|
||||||
|
|
||||||
@@ -2688,7 +2691,7 @@ static int track_set_exec(bContext *C, wmOperator *op)
|
|||||||
}
|
}
|
||||||
CTX_DATA_END;
|
CTX_DATA_END;
|
||||||
}
|
}
|
||||||
else if(RNA_enum_is_equal(op->ptr, "type", "LOCKTRACK")){
|
else if(type == 2) {
|
||||||
bConstraint *con;
|
bConstraint *con;
|
||||||
bLockTrackConstraint *data;
|
bLockTrackConstraint *data;
|
||||||
|
|
||||||
@@ -2712,7 +2715,7 @@ static int track_set_exec(bContext *C, wmOperator *op)
|
|||||||
}
|
}
|
||||||
CTX_DATA_END;
|
CTX_DATA_END;
|
||||||
}
|
}
|
||||||
else if(RNA_enum_is_equal(op->ptr, "type", "OLDTRACK")){
|
else {
|
||||||
CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
|
CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
|
||||||
if(base!=BASACT) {
|
if(base!=BASACT) {
|
||||||
base->object->track= BASACT->object;
|
base->object->track= BASACT->object;
|
||||||
|
|||||||
@@ -122,11 +122,6 @@ EnumPropertyItem sequencer_prop_effect_types[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* mute operator */
|
/* mute operator */
|
||||||
EnumPropertyItem sequencer_prop_operate_types[] = { /* better name? */
|
|
||||||
{SEQ_SELECTED, "SELECTED", 0, "Selected", ""},
|
|
||||||
{SEQ_UNSELECTED, "UNSELECTED", 0, "Unselected ", ""},
|
|
||||||
{0, NULL, 0, NULL, NULL}
|
|
||||||
};
|
|
||||||
|
|
||||||
EnumPropertyItem prop_side_types[] = {
|
EnumPropertyItem prop_side_types[] = {
|
||||||
{SEQ_SIDE_LEFT, "LEFT", 0, "Left", ""},
|
{SEQ_SIDE_LEFT, "LEFT", 0, "Left", ""},
|
||||||
@@ -1491,8 +1486,7 @@ static int sequencer_mute_exec(bContext *C, wmOperator *op)
|
|||||||
if(ed==NULL)
|
if(ed==NULL)
|
||||||
return OPERATOR_CANCELLED;
|
return OPERATOR_CANCELLED;
|
||||||
|
|
||||||
selected= RNA_enum_is_equal(op->ptr, "type", "SELECTED");
|
selected= !RNA_boolean_get(op->ptr, "unselected");
|
||||||
|
|
||||||
|
|
||||||
for(seq= ed->seqbasep->first; seq; seq= seq->next) {
|
for(seq= ed->seqbasep->first; seq; seq= seq->next) {
|
||||||
if ((seq->flag & SEQ_LOCK)==0) {
|
if ((seq->flag & SEQ_LOCK)==0) {
|
||||||
@@ -1528,7 +1522,7 @@ void SEQUENCER_OT_mute(struct wmOperatorType *ot)
|
|||||||
/* flags */
|
/* flags */
|
||||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||||
|
|
||||||
RNA_def_enum(ot->srna, "type", sequencer_prop_operate_types, SEQ_SELECTED, "Type", "");
|
RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Mute unselected rather than selected strips.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1543,8 +1537,7 @@ static int sequencer_unmute_exec(bContext *C, wmOperator *op)
|
|||||||
if(ed==NULL)
|
if(ed==NULL)
|
||||||
return OPERATOR_CANCELLED;
|
return OPERATOR_CANCELLED;
|
||||||
|
|
||||||
selected= RNA_enum_is_equal(op->ptr, "type", "SELECTED");
|
selected= !RNA_boolean_get(op->ptr, "unselected");
|
||||||
|
|
||||||
|
|
||||||
for(seq= ed->seqbasep->first; seq; seq= seq->next) {
|
for(seq= ed->seqbasep->first; seq; seq= seq->next) {
|
||||||
if ((seq->flag & SEQ_LOCK)==0) {
|
if ((seq->flag & SEQ_LOCK)==0) {
|
||||||
@@ -1580,7 +1573,7 @@ void SEQUENCER_OT_unmute(struct wmOperatorType *ot)
|
|||||||
/* flags */
|
/* flags */
|
||||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||||
|
|
||||||
RNA_def_enum(ot->srna, "type", sequencer_prop_operate_types, SEQ_SELECTED, "Type", "");
|
RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "UnMute unselected rather than selected strips.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -116,11 +116,11 @@ void sequencer_keymap(wmWindowManager *wm)
|
|||||||
RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_cut", KKEY, KM_PRESS, 0, 0)->ptr, "type", SEQ_CUT_SOFT);
|
RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_cut", KKEY, KM_PRESS, 0, 0)->ptr, "type", SEQ_CUT_SOFT);
|
||||||
RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_cut", KKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", SEQ_CUT_HARD);
|
RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_cut", KKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", SEQ_CUT_HARD);
|
||||||
|
|
||||||
RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, 0, 0)->ptr, "type", SEQ_SELECTED);
|
WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, 0, 0);
|
||||||
RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", SEQ_UNSELECTED);
|
RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "unselected", 1);
|
||||||
|
|
||||||
RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_unmute", HKEY, KM_PRESS, KM_ALT, 0)->ptr, "type", SEQ_SELECTED);
|
WM_keymap_add_item(keymap, "SEQUENCER_OT_unmute", HKEY, KM_PRESS, KM_ALT, 0);
|
||||||
RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_unmute", HKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0)->ptr, "type", SEQ_UNSELECTED);
|
RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_unmute", HKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0)->ptr, "unselected", 1);
|
||||||
|
|
||||||
WM_keymap_add_item(keymap, "SEQUENCER_OT_lock", LKEY, KM_PRESS, KM_SHIFT, 0);
|
WM_keymap_add_item(keymap, "SEQUENCER_OT_lock", LKEY, KM_PRESS, KM_SHIFT, 0);
|
||||||
WM_keymap_add_item(keymap, "SEQUENCER_OT_unlock", HKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0);
|
WM_keymap_add_item(keymap, "SEQUENCER_OT_unlock", HKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0);
|
||||||
|
|||||||
@@ -203,10 +203,10 @@ void view3d_keymap(wmWindowManager *wm)
|
|||||||
|
|
||||||
/* selection*/
|
/* selection*/
|
||||||
WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
|
WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
|
||||||
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "type", 1);
|
RNA_boolean_set(WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "extend", 1);
|
||||||
WM_keymap_add_item(keymap, "VIEW3D_OT_select_border", BKEY, KM_PRESS, 0, 0);
|
WM_keymap_add_item(keymap, "VIEW3D_OT_select_border", BKEY, KM_PRESS, 0, 0);
|
||||||
WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL, 0);
|
WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL, 0);
|
||||||
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_SHIFT|KM_CTRL, 0)->ptr, "type", 1);
|
RNA_boolean_set(WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_SHIFT|KM_CTRL, 0)->ptr, "deselect", 1);
|
||||||
WM_keymap_add_item(keymap, "VIEW3D_OT_select_circle", CKEY, KM_PRESS, 0, 0);
|
WM_keymap_add_item(keymap, "VIEW3D_OT_select_circle", CKEY, KM_PRESS, 0, 0);
|
||||||
|
|
||||||
WM_keymap_add_item(keymap, "VIEW3D_OT_clip_border", BKEY, KM_PRESS, KM_ALT, 0);
|
WM_keymap_add_item(keymap, "VIEW3D_OT_clip_border", BKEY, KM_PRESS, KM_ALT, 0);
|
||||||
|
|||||||
@@ -715,12 +715,6 @@ void view3d_lasso_select(bContext *C, ViewContext *vc, short mcords[][2], short
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static EnumPropertyItem lasso_select_types[] = {
|
|
||||||
{0, "SELECT", 0, "Select", ""},
|
|
||||||
{1, "DESELECT", 0, "Deselect", ""},
|
|
||||||
{0, NULL, 0, NULL, NULL}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/* lasso operator gives properties, but since old code works
|
/* lasso operator gives properties, but since old code works
|
||||||
with short array we convert */
|
with short array we convert */
|
||||||
@@ -747,7 +741,7 @@ static int view3d_lasso_select_exec(bContext *C, wmOperator *op)
|
|||||||
/* setup view context for argument to callbacks */
|
/* setup view context for argument to callbacks */
|
||||||
view3d_set_viewcontext(C, &vc);
|
view3d_set_viewcontext(C, &vc);
|
||||||
|
|
||||||
select= RNA_enum_is_equal(op->ptr, "type", "SELECT");
|
select= !RNA_boolean_get(op->ptr, "deselect");
|
||||||
view3d_lasso_select(C, &vc, mcords, i, select);
|
view3d_lasso_select(C, &vc, mcords, i, select);
|
||||||
|
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
@@ -769,7 +763,7 @@ void VIEW3D_OT_select_lasso(wmOperatorType *ot)
|
|||||||
ot->flag= OPTYPE_UNDO;
|
ot->flag= OPTYPE_UNDO;
|
||||||
|
|
||||||
RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", "");
|
RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", "");
|
||||||
RNA_def_enum(ot->srna, "type", lasso_select_types, 0, "Type", "");
|
RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Deselect rather than select items.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1528,11 +1522,6 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
|
|||||||
|
|
||||||
|
|
||||||
/* *****************Selection Operators******************* */
|
/* *****************Selection Operators******************* */
|
||||||
static EnumPropertyItem prop_select_types[] = {
|
|
||||||
{0, "EXCLUSIVE", 0, "Exclusive", ""},
|
|
||||||
{1, "EXTEND", 0, "Extend", ""},
|
|
||||||
{0, NULL, 0, NULL, NULL}
|
|
||||||
};
|
|
||||||
|
|
||||||
/* ****** Border Select ****** */
|
/* ****** Border Select ****** */
|
||||||
void VIEW3D_OT_select_border(wmOperatorType *ot)
|
void VIEW3D_OT_select_border(wmOperatorType *ot)
|
||||||
@@ -1558,7 +1547,7 @@ void VIEW3D_OT_select_border(wmOperatorType *ot)
|
|||||||
RNA_def_int(ot->srna, "ymin", 0, INT_MIN, INT_MAX, "Y Min", "", INT_MIN, INT_MAX);
|
RNA_def_int(ot->srna, "ymin", 0, INT_MIN, INT_MAX, "Y Min", "", INT_MIN, INT_MAX);
|
||||||
RNA_def_int(ot->srna, "ymax", 0, INT_MIN, INT_MAX, "Y Max", "", INT_MIN, INT_MAX);
|
RNA_def_int(ot->srna, "ymax", 0, INT_MIN, INT_MAX, "Y Max", "", INT_MIN, INT_MAX);
|
||||||
|
|
||||||
RNA_def_enum(ot->srna, "type", prop_select_types, 0, "Type", "");
|
RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend selection instead of deselecting everyting first.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ****** Mouse Select ****** */
|
/* ****** Mouse Select ****** */
|
||||||
@@ -1567,7 +1556,7 @@ void VIEW3D_OT_select_border(wmOperatorType *ot)
|
|||||||
static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||||
{
|
{
|
||||||
Object *obedit= CTX_data_edit_object(C);
|
Object *obedit= CTX_data_edit_object(C);
|
||||||
short extend= RNA_enum_is_equal(op->ptr, "type", "EXTEND");
|
short extend= RNA_boolean_get(op->ptr, "extend");
|
||||||
|
|
||||||
view3d_operator_needs_opengl(C);
|
view3d_operator_needs_opengl(C);
|
||||||
|
|
||||||
@@ -1605,7 +1594,7 @@ void VIEW3D_OT_select(wmOperatorType *ot)
|
|||||||
ot->flag= OPTYPE_UNDO;
|
ot->flag= OPTYPE_UNDO;
|
||||||
|
|
||||||
/* properties */
|
/* properties */
|
||||||
RNA_def_enum(ot->srna, "type", prop_select_types, 0, "Type", "");
|
RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend selection instead of deselecting everyting first.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -109,10 +109,6 @@ TransformModeItem transform_modes[] =
|
|||||||
static int select_orientation_exec(bContext *C, wmOperator *op)
|
static int select_orientation_exec(bContext *C, wmOperator *op)
|
||||||
{
|
{
|
||||||
int orientation = RNA_enum_get(op->ptr, "orientation");
|
int orientation = RNA_enum_get(op->ptr, "orientation");
|
||||||
int custom_index= RNA_int_get(op->ptr, "custom_index");;
|
|
||||||
|
|
||||||
if(orientation == V3D_MANIP_CUSTOM)
|
|
||||||
orientation += custom_index;
|
|
||||||
|
|
||||||
BIF_selectTransformOrientationValue(C, orientation);
|
BIF_selectTransformOrientationValue(C, orientation);
|
||||||
|
|
||||||
@@ -126,20 +122,26 @@ static int select_orientation_invoke(bContext *C, wmOperator *op, wmEvent *event
|
|||||||
|
|
||||||
pup= uiPupMenuBegin(C, "Orientation", 0);
|
pup= uiPupMenuBegin(C, "Orientation", 0);
|
||||||
layout= uiPupMenuLayout(pup);
|
layout= uiPupMenuLayout(pup);
|
||||||
BIF_menuTransformOrientation(C, layout, NULL);
|
uiItemsEnumO(layout, "TFM_OT_select_orientation", "orientation");
|
||||||
uiPupMenuEnd(C, pup);
|
uiPupMenuEnd(C, pup);
|
||||||
|
|
||||||
return OPERATOR_CANCELLED;
|
return OPERATOR_CANCELLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static EnumPropertyItem *select_orientation_itemf(bContext *C, PointerRNA *ptr, int *free)
|
||||||
|
{
|
||||||
|
*free= 1;
|
||||||
|
return BIF_enumTransformOrientation(C);
|
||||||
|
}
|
||||||
|
|
||||||
void TFM_OT_select_orientation(struct wmOperatorType *ot)
|
void TFM_OT_select_orientation(struct wmOperatorType *ot)
|
||||||
{
|
{
|
||||||
|
PropertyRNA *prop;
|
||||||
static EnumPropertyItem orientation_items[]= {
|
static EnumPropertyItem orientation_items[]= {
|
||||||
{V3D_MANIP_GLOBAL, "GLOBAL", 0, "Global", ""},
|
{V3D_MANIP_GLOBAL, "GLOBAL", 0, "Global", ""},
|
||||||
{V3D_MANIP_NORMAL, "NORMAL", 0, "Normal", ""},
|
{V3D_MANIP_NORMAL, "NORMAL", 0, "Normal", ""},
|
||||||
{V3D_MANIP_LOCAL, "LOCAL", 0, "Local", ""},
|
{V3D_MANIP_LOCAL, "LOCAL", 0, "Local", ""},
|
||||||
{V3D_MANIP_VIEW, "VIEW", 0, "View", ""},
|
{V3D_MANIP_VIEW, "VIEW", 0, "View", ""},
|
||||||
{V3D_MANIP_CUSTOM, "CUSTOM", 0, "Custom", ""},
|
|
||||||
{0, NULL, 0, NULL, NULL}};
|
{0, NULL, 0, NULL, NULL}};
|
||||||
|
|
||||||
/* identifiers */
|
/* identifiers */
|
||||||
@@ -151,8 +153,8 @@ void TFM_OT_select_orientation(struct wmOperatorType *ot)
|
|||||||
ot->exec = select_orientation_exec;
|
ot->exec = select_orientation_exec;
|
||||||
ot->poll = ED_operator_areaactive;
|
ot->poll = ED_operator_areaactive;
|
||||||
|
|
||||||
RNA_def_enum(ot->srna, "orientation", orientation_items, V3D_MANIP_CUSTOM, "Orientation", "DOC_BROKEN");
|
prop= RNA_def_enum(ot->srna, "orientation", orientation_items, V3D_MANIP_GLOBAL, "Orientation", "DOC_BROKEN");
|
||||||
RNA_def_int(ot->srna, "custom_index", 0, 0, INT_MAX, "Custom Index", "", 0, INT_MAX);
|
RNA_def_enum_funcs(prop, select_orientation_itemf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void transformops_exit(bContext *C, wmOperator *op)
|
static void transformops_exit(bContext *C, wmOperator *op)
|
||||||
|
|||||||
@@ -59,6 +59,8 @@
|
|||||||
|
|
||||||
#include "UI_interface.h"
|
#include "UI_interface.h"
|
||||||
|
|
||||||
|
#include "RNA_define.h"
|
||||||
|
|
||||||
#include "transform.h"
|
#include "transform.h"
|
||||||
|
|
||||||
/* *********************** TransSpace ************************** */
|
/* *********************** TransSpace ************************** */
|
||||||
@@ -354,19 +356,37 @@ void BIF_selectTransformOrientationValue(bContext *C, int orientation) {
|
|||||||
v3d->twmode = orientation;
|
v3d->twmode = orientation;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BIF_menuTransformOrientation(bContext *C, uiLayout *layout, void *arg)
|
EnumPropertyItem *BIF_enumTransformOrientation(bContext *C)
|
||||||
{
|
{
|
||||||
ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces;
|
ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces;
|
||||||
TransformOrientation *ts;
|
TransformOrientation *ts = transform_spaces->first;
|
||||||
int i= V3D_MANIP_CUSTOM;
|
EnumPropertyItem global = {V3D_MANIP_GLOBAL, "GLOBAL", 0, "Global", ""};
|
||||||
|
EnumPropertyItem normal = {V3D_MANIP_NORMAL, "NORMAL", 0, "Normal", ""};
|
||||||
|
EnumPropertyItem local = {V3D_MANIP_LOCAL, "LOCAL", 0, "Local", ""};
|
||||||
|
EnumPropertyItem view = {V3D_MANIP_VIEW, "VIEW", 0, "View", ""};
|
||||||
|
EnumPropertyItem sepr = {0, "", 0, NULL, NULL};
|
||||||
|
EnumPropertyItem tmp = {0, "", 0, "", ""};
|
||||||
|
EnumPropertyItem *item= NULL;
|
||||||
|
int i = V3D_MANIP_CUSTOM, totitem= 0;
|
||||||
|
|
||||||
uiItemEnumO(layout, NULL, 0, "TFM_OT_select_orientation", "orientation", V3D_MANIP_GLOBAL);
|
RNA_enum_item_add(&item, &totitem, &global);
|
||||||
uiItemEnumO(layout, NULL, 0, "TFM_OT_select_orientation", "orientation", V3D_MANIP_LOCAL);
|
RNA_enum_item_add(&item, &totitem, &normal);
|
||||||
uiItemEnumO(layout, NULL, 0, "TFM_OT_select_orientation", "orientation", V3D_MANIP_NORMAL);
|
RNA_enum_item_add(&item, &totitem, &local);
|
||||||
uiItemEnumO(layout, NULL, 0, "TFM_OT_select_orientation", "orientation", V3D_MANIP_VIEW);
|
RNA_enum_item_add(&item, &totitem, &view);
|
||||||
|
|
||||||
for(ts = transform_spaces->first; ts; ts = ts->next)
|
if(ts)
|
||||||
uiItemIntO(layout, ts->name, 0, "TFM_OT_select_orientation", "custom_index", i++);
|
RNA_enum_item_add(&item, &totitem, &sepr);
|
||||||
|
|
||||||
|
for(; ts; ts = ts->next) {
|
||||||
|
tmp.identifier = "CUSTOM";
|
||||||
|
tmp.name= ts->name;
|
||||||
|
tmp.value = i++;
|
||||||
|
RNA_enum_item_add(&item, &totitem, &tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
RNA_enum_item_end(&item, &totitem);
|
||||||
|
|
||||||
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
char * BIF_menustringTransformOrientation(const bContext *C, char *title) {
|
char * BIF_menustringTransformOrientation(const bContext *C, char *title) {
|
||||||
|
|||||||
@@ -548,12 +548,12 @@ void RNA_property_int_ui_range(PointerRNA *ptr, PropertyRNA *prop, int *softmin,
|
|||||||
void RNA_property_float_range(PointerRNA *ptr, PropertyRNA *prop, float *hardmin, float *hardmax);
|
void RNA_property_float_range(PointerRNA *ptr, PropertyRNA *prop, float *hardmin, float *hardmax);
|
||||||
void RNA_property_float_ui_range(PointerRNA *ptr, PropertyRNA *prop, float *softmin, float *softmax, float *step, float *precision);
|
void RNA_property_float_ui_range(PointerRNA *ptr, PropertyRNA *prop, float *softmin, float *softmax, float *step, float *precision);
|
||||||
|
|
||||||
int RNA_enum_identifier(const EnumPropertyItem *item, const int value, const char **identifier);
|
int RNA_enum_identifier(EnumPropertyItem *item, const int value, const char **identifier);
|
||||||
int RNA_enum_name(const EnumPropertyItem *item, const int value, const char **name);
|
int RNA_enum_name(EnumPropertyItem *item, const int value, const char **name);
|
||||||
|
|
||||||
void RNA_property_enum_items(PointerRNA *ptr, PropertyRNA *prop, const EnumPropertyItem **item, int *totitem);
|
void RNA_property_enum_items(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, EnumPropertyItem **item, int *totitem, int *free);
|
||||||
int RNA_property_enum_value(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);
|
||||||
int RNA_property_enum_identifier(PointerRNA *ptr, PropertyRNA *prop, const int value, const char **identifier);
|
int RNA_property_enum_identifier(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value, const char **identifier);
|
||||||
|
|
||||||
StructRNA *RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop);
|
StructRNA *RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop);
|
||||||
|
|
||||||
@@ -677,11 +677,11 @@ void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
|
|||||||
|
|
||||||
int RNA_enum_get(PointerRNA *ptr, const char *name);
|
int RNA_enum_get(PointerRNA *ptr, const char *name);
|
||||||
void RNA_enum_set(PointerRNA *ptr, const char *name, int value);
|
void RNA_enum_set(PointerRNA *ptr, const char *name, int value);
|
||||||
int RNA_enum_is_equal(PointerRNA *ptr, const char *name, const char *enumname);
|
int RNA_enum_is_equal(struct bContext *C, PointerRNA *ptr, const char *name, const char *enumname);
|
||||||
|
|
||||||
/* lower level functions that donr use a PointerRNA */
|
/* lower level functions that donr use a PointerRNA */
|
||||||
int RNA_enum_value_from_id(const EnumPropertyItem *item, const char *identifier, int *value);
|
int RNA_enum_value_from_id(EnumPropertyItem *item, const char *identifier, int *value);
|
||||||
int RNA_enum_id_from_value(const EnumPropertyItem *item, int value, const char **identifier);
|
int RNA_enum_id_from_value(EnumPropertyItem *item, int value, const char **identifier);
|
||||||
|
|
||||||
void RNA_string_get(PointerRNA *ptr, const char *name, char *value);
|
void RNA_string_get(PointerRNA *ptr, const char *name, char *value);
|
||||||
char *RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, int fixedlen);
|
char *RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, int fixedlen);
|
||||||
|
|||||||
@@ -160,6 +160,13 @@ void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret);
|
|||||||
void RNA_def_function_flag(FunctionRNA *func, int flag);
|
void RNA_def_function_flag(FunctionRNA *func, int flag);
|
||||||
void RNA_def_function_ui_description(FunctionRNA *func, const char *description);
|
void RNA_def_function_ui_description(FunctionRNA *func, const char *description);
|
||||||
|
|
||||||
|
/* Dynamic Enums
|
||||||
|
* strings are not freed, assumed pointing to static location. */
|
||||||
|
|
||||||
|
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, EnumPropertyItem *item);
|
||||||
|
void RNA_enum_items_add(EnumPropertyItem **items, int *totitem, EnumPropertyItem *item);
|
||||||
|
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ typedef struct EnumPropertyItem {
|
|||||||
const char *description;
|
const char *description;
|
||||||
} EnumPropertyItem;
|
} EnumPropertyItem;
|
||||||
|
|
||||||
typedef EnumPropertyItem *(*EnumPropertyItemFunc)(PointerRNA *ptr);
|
typedef EnumPropertyItem *(*EnumPropertyItemFunc)(struct bContext *C, PointerRNA *ptr, int *free);
|
||||||
|
|
||||||
typedef struct PropertyRNA PropertyRNA;
|
typedef struct PropertyRNA PropertyRNA;
|
||||||
|
|
||||||
|
|||||||
@@ -1597,7 +1597,6 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
|
|||||||
DefRNA.error= 1;
|
DefRNA.error= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(eprop->itemf);
|
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "rna_generate_structs: %s%s.%s, enum must have items defined.\n", srna->identifier, errnest, prop->identifier);
|
fprintf(stderr, "rna_generate_structs: %s%s.%s, enum must have items defined.\n", srna->identifier, errnest, prop->identifier);
|
||||||
DefRNA.error= 1;
|
DefRNA.error= 1;
|
||||||
|
|||||||
@@ -640,18 +640,20 @@ StructRNA *RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop)
|
|||||||
return &RNA_UnknownType;
|
return &RNA_UnknownType;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RNA_property_enum_items(PointerRNA *ptr, PropertyRNA *prop, const EnumPropertyItem **item, int *totitem)
|
void RNA_property_enum_items(bContext *C, PointerRNA *ptr, PropertyRNA *prop, EnumPropertyItem **item, int *totitem, int *free)
|
||||||
{
|
{
|
||||||
EnumPropertyRNA *eprop= (EnumPropertyRNA*)rna_ensure_property(prop);
|
EnumPropertyRNA *eprop= (EnumPropertyRNA*)rna_ensure_property(prop);
|
||||||
int tot;
|
int tot;
|
||||||
|
|
||||||
if(eprop->itemf) {
|
*free= 0;
|
||||||
*item= eprop->itemf(ptr);
|
|
||||||
if(totitem) {
|
if(C && eprop->itemf) {
|
||||||
|
*item= eprop->itemf(C, ptr, free);
|
||||||
|
|
||||||
|
if(totitem)
|
||||||
for(tot=0; (*item)[tot].identifier; tot++);
|
for(tot=0; (*item)[tot].identifier; tot++);
|
||||||
*totitem= tot;
|
*totitem= tot;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
*item= eprop->item;
|
*item= eprop->item;
|
||||||
if(totitem)
|
if(totitem)
|
||||||
@@ -659,11 +661,12 @@ void RNA_property_enum_items(PointerRNA *ptr, PropertyRNA *prop, const EnumPrope
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int RNA_property_enum_value(PointerRNA *ptr, PropertyRNA *prop, const char *identifier, int *value)
|
int RNA_property_enum_value(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const char *identifier, int *value)
|
||||||
{
|
{
|
||||||
const EnumPropertyItem *item;
|
EnumPropertyItem *item;
|
||||||
|
int free;
|
||||||
|
|
||||||
RNA_property_enum_items(ptr, prop, &item, NULL);
|
RNA_property_enum_items(C, ptr, prop, &item, NULL, &free);
|
||||||
|
|
||||||
for(; item->identifier; item++) {
|
for(; item->identifier; item++) {
|
||||||
if(item->identifier[0] && strcmp(item->identifier, identifier)==0) {
|
if(item->identifier[0] && strcmp(item->identifier, identifier)==0) {
|
||||||
@@ -672,10 +675,13 @@ int RNA_property_enum_value(PointerRNA *ptr, PropertyRNA *prop, const char *iden
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(free)
|
||||||
|
MEM_freeN(item);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RNA_enum_identifier(const EnumPropertyItem *item, const int value, const char **identifier)
|
int RNA_enum_identifier(EnumPropertyItem *item, const int value, const char **identifier)
|
||||||
{
|
{
|
||||||
for (; item->identifier; item++) {
|
for (; item->identifier; item++) {
|
||||||
if(item->identifier[0] && item->value==value) {
|
if(item->identifier[0] && item->value==value) {
|
||||||
@@ -686,7 +692,7 @@ int RNA_enum_identifier(const EnumPropertyItem *item, const int value, const cha
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RNA_enum_name(const EnumPropertyItem *item, const int value, const char **name)
|
int RNA_enum_name(EnumPropertyItem *item, const int value, const char **name)
|
||||||
{
|
{
|
||||||
for (; item->identifier; item++) {
|
for (; item->identifier; item++) {
|
||||||
if(item->identifier[0] && item->value==value) {
|
if(item->identifier[0] && item->value==value) {
|
||||||
@@ -697,12 +703,17 @@ int RNA_enum_name(const EnumPropertyItem *item, const int value, const char **na
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RNA_property_enum_identifier(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)
|
||||||
{
|
{
|
||||||
const EnumPropertyItem *item= NULL;
|
EnumPropertyItem *item= NULL;
|
||||||
|
int result, free;
|
||||||
|
|
||||||
RNA_property_enum_items(ptr, prop, &item, NULL);
|
RNA_property_enum_items(C, ptr, prop, &item, NULL, &free);
|
||||||
return RNA_enum_identifier(item, value, identifier);
|
result= RNA_enum_identifier(item, value, identifier);
|
||||||
|
if(free)
|
||||||
|
MEM_freeN(item);
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *RNA_property_ui_name(PropertyRNA *prop)
|
const char *RNA_property_ui_name(PropertyRNA *prop)
|
||||||
@@ -2384,18 +2395,22 @@ void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
|
|||||||
printf("RNA_enum_set: %s.%s not found.\n", ptr->type->identifier, name);
|
printf("RNA_enum_set: %s.%s not found.\n", ptr->type->identifier, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
int RNA_enum_is_equal(PointerRNA *ptr, const char *name, const char *enumname)
|
int RNA_enum_is_equal(bContext *C, PointerRNA *ptr, const char *name, const char *enumname)
|
||||||
{
|
{
|
||||||
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
|
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
|
||||||
const EnumPropertyItem *item;
|
EnumPropertyItem *item;
|
||||||
|
int free;
|
||||||
|
|
||||||
if(prop) {
|
if(prop) {
|
||||||
RNA_property_enum_items(ptr, prop, &item, NULL);
|
RNA_property_enum_items(C, ptr, prop, &item, NULL, &free);
|
||||||
|
|
||||||
for(; item->identifier; item++)
|
for(; item->identifier; item++)
|
||||||
if(strcmp(item->identifier, enumname) == 0)
|
if(strcmp(item->identifier, enumname) == 0)
|
||||||
return (item->value == RNA_property_enum_get(ptr, prop));
|
return (item->value == RNA_property_enum_get(ptr, prop));
|
||||||
|
|
||||||
|
if(free)
|
||||||
|
MEM_freeN(item);
|
||||||
|
|
||||||
printf("RNA_enum_is_equal: %s.%s item %s not found.\n", ptr->type->identifier, name, enumname);
|
printf("RNA_enum_is_equal: %s.%s item %s not found.\n", ptr->type->identifier, name, enumname);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -2405,7 +2420,7 @@ int RNA_enum_is_equal(PointerRNA *ptr, const char *name, const char *enumname)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int RNA_enum_value_from_id(const EnumPropertyItem *item, const char *identifier, int *value)
|
int RNA_enum_value_from_id(EnumPropertyItem *item, const char *identifier, int *value)
|
||||||
{
|
{
|
||||||
for( ; item->identifier; item++) {
|
for( ; item->identifier; item++) {
|
||||||
if(strcmp(item->identifier, identifier)==0) {
|
if(strcmp(item->identifier, identifier)==0) {
|
||||||
@@ -2417,7 +2432,7 @@ int RNA_enum_value_from_id(const EnumPropertyItem *item, const char *identifier,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RNA_enum_id_from_value(const EnumPropertyItem *item, int value, const char **identifier)
|
int RNA_enum_id_from_value(EnumPropertyItem *item, int value, const char **identifier)
|
||||||
{
|
{
|
||||||
for( ; item->identifier; item++) {
|
for( ; item->identifier; item++) {
|
||||||
if(item->value==value) {
|
if(item->value==value) {
|
||||||
@@ -2659,7 +2674,7 @@ char *RNA_property_as_string(PointerRNA *ptr, PropertyRNA *prop)
|
|||||||
const char *identifier;
|
const char *identifier;
|
||||||
int val = RNA_property_enum_get(ptr, prop);
|
int val = RNA_property_enum_get(ptr, prop);
|
||||||
|
|
||||||
if(RNA_property_enum_identifier(ptr, prop, val, &identifier)) {
|
if(RNA_property_enum_identifier(NULL, ptr, prop, val, &identifier)) {
|
||||||
BLI_dynstr_appendf(dynstr, "'%s'", identifier);
|
BLI_dynstr_appendf(dynstr, "'%s'", identifier);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -68,6 +68,17 @@ EnumPropertyItem constraint_type_items[] ={
|
|||||||
{CONSTRAINT_TYPE_NULL, "NULL", 0, "Null", ""},
|
{CONSTRAINT_TYPE_NULL, "NULL", 0, "Null", ""},
|
||||||
{0, NULL, 0, NULL, NULL}};
|
{0, NULL, 0, NULL, NULL}};
|
||||||
|
|
||||||
|
EnumPropertyItem space_pchan_items[] = {
|
||||||
|
{0, "WORLD", 0, "World Space", ""},
|
||||||
|
{2, "POSE", 0, "Pose Space", ""},
|
||||||
|
{3, "LOCAL_WITH_PARENT", 0, "Local With Parent", ""},
|
||||||
|
{1, "LOCAL", 0, "Local Space", ""},
|
||||||
|
{0, NULL, 0, NULL, NULL}};
|
||||||
|
|
||||||
|
EnumPropertyItem space_object_items[] = {
|
||||||
|
{0, "WORLD", 0, "World Space", ""},
|
||||||
|
{1, "LOCAL", 0, "Local (Without Parent) Space", ""},
|
||||||
|
{0, NULL, 0, NULL, NULL}};
|
||||||
|
|
||||||
#ifdef RNA_RUNTIME
|
#ifdef RNA_RUNTIME
|
||||||
|
|
||||||
@@ -166,19 +177,7 @@ static void rna_Constraint_influence_update(bContext *C, PointerRNA *ptr)
|
|||||||
rna_Constraint_update(C, ptr);
|
rna_Constraint_update(C, ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static EnumPropertyItem space_pchan_items[] = {
|
static EnumPropertyItem *rna_Constraint_owner_space_itemf(bContext *C, PointerRNA *ptr, int *free)
|
||||||
{0, "WORLD", 0, "World Space", ""},
|
|
||||||
{2, "POSE", 0, "Pose Space", ""},
|
|
||||||
{3, "LOCAL_WITH_PARENT", 0, "Local With Parent", ""},
|
|
||||||
{1, "LOCAL", 0, "Local Space", ""},
|
|
||||||
{0, NULL, 0, NULL, NULL}};
|
|
||||||
|
|
||||||
static EnumPropertyItem space_object_items[] = {
|
|
||||||
{0, "WORLD", 0, "World Space", ""},
|
|
||||||
{1, "LOCAL", 0, "Local (Without Parent) Space", ""},
|
|
||||||
{0, NULL, 0, NULL, NULL}};
|
|
||||||
|
|
||||||
static EnumPropertyItem *rna_Constraint_owner_space_itemf(PointerRNA *ptr)
|
|
||||||
{
|
{
|
||||||
Object *ob= (Object*)ptr->id.data;
|
Object *ob= (Object*)ptr->id.data;
|
||||||
bConstraint *con= (bConstraint*)ptr->data;
|
bConstraint *con= (bConstraint*)ptr->data;
|
||||||
@@ -189,7 +188,7 @@ static EnumPropertyItem *rna_Constraint_owner_space_itemf(PointerRNA *ptr)
|
|||||||
return space_object_items;
|
return space_object_items;
|
||||||
}
|
}
|
||||||
|
|
||||||
static EnumPropertyItem *rna_Constraint_target_space_itemf(PointerRNA *ptr)
|
static EnumPropertyItem *rna_Constraint_target_space_itemf(bContext *C, PointerRNA *ptr, int *free)
|
||||||
{
|
{
|
||||||
bConstraint *con= (bConstraint*)ptr->data;
|
bConstraint *con= (bConstraint*)ptr->data;
|
||||||
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
|
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
|
||||||
@@ -1505,11 +1504,13 @@ void RNA_def_constraint(BlenderRNA *brna)
|
|||||||
|
|
||||||
prop= RNA_def_property(srna, "owner_space", PROP_ENUM, PROP_NONE);
|
prop= RNA_def_property(srna, "owner_space", PROP_ENUM, PROP_NONE);
|
||||||
RNA_def_property_enum_sdna(prop, NULL, "ownspace");
|
RNA_def_property_enum_sdna(prop, NULL, "ownspace");
|
||||||
|
RNA_def_property_enum_items(prop, space_pchan_items);
|
||||||
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Constraint_owner_space_itemf");
|
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Constraint_owner_space_itemf");
|
||||||
RNA_def_property_ui_text(prop, "Owner Space", "Space that owner is evaluated in.");
|
RNA_def_property_ui_text(prop, "Owner Space", "Space that owner is evaluated in.");
|
||||||
|
|
||||||
prop= RNA_def_property(srna, "target_space", PROP_ENUM, PROP_NONE);
|
prop= RNA_def_property(srna, "target_space", PROP_ENUM, PROP_NONE);
|
||||||
RNA_def_property_enum_sdna(prop, NULL, "tarspace");
|
RNA_def_property_enum_sdna(prop, NULL, "tarspace");
|
||||||
|
RNA_def_property_enum_items(prop, space_pchan_items);
|
||||||
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Constraint_target_space_itemf");
|
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Constraint_target_space_itemf");
|
||||||
RNA_def_property_ui_text(prop, "Target Space", "Space that target is evaluated in.");
|
RNA_def_property_ui_text(prop, "Target Space", "Space that target is evaluated in.");
|
||||||
|
|
||||||
|
|||||||
@@ -1112,7 +1112,7 @@ void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item
|
|||||||
switch(prop->type) {
|
switch(prop->type) {
|
||||||
case PROP_ENUM: {
|
case PROP_ENUM: {
|
||||||
EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
|
EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
|
||||||
eprop->item= item;
|
eprop->item= (EnumPropertyItem*)item;
|
||||||
eprop->totitem= 0;
|
eprop->totitem= 0;
|
||||||
for(i=0; item[i].identifier; i++) {
|
for(i=0; item[i].identifier; i++) {
|
||||||
eprop->totitem++;
|
eprop->totitem++;
|
||||||
@@ -2262,3 +2262,37 @@ int rna_parameter_size(PropertyRNA *parm)
|
|||||||
return sizeof(void *);
|
return sizeof(void *);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Dynamic Enums */
|
||||||
|
|
||||||
|
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, EnumPropertyItem *item)
|
||||||
|
{
|
||||||
|
EnumPropertyItem *newitems;
|
||||||
|
int tot= *totitem;
|
||||||
|
|
||||||
|
if(tot == 0) {
|
||||||
|
*items= MEM_callocN(sizeof(EnumPropertyItem)*8, "RNA_enum_items_add");
|
||||||
|
}
|
||||||
|
else if(tot >= 8 && (tot&(tot-1)) == 0){
|
||||||
|
/* power of two > 8 */
|
||||||
|
newitems= MEM_callocN(sizeof(EnumPropertyItem)*tot*2, "RNA_enum_items_add");
|
||||||
|
memcpy(newitems, *items, sizeof(EnumPropertyItem)*tot);
|
||||||
|
MEM_freeN(*items);
|
||||||
|
*items= newitems;
|
||||||
|
}
|
||||||
|
|
||||||
|
(*items)[tot]= *item;
|
||||||
|
*totitem= tot+1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RNA_enum_items_add(EnumPropertyItem **items, int *totitem, EnumPropertyItem *item)
|
||||||
|
{
|
||||||
|
for(; item->identifier; item++)
|
||||||
|
RNA_enum_item_add(items, totitem, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
|
||||||
|
{
|
||||||
|
static EnumPropertyItem empty = {0, NULL, 0, NULL, NULL};
|
||||||
|
RNA_enum_item_add(items, totitem, &empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ typedef int (*PropStringLengthFunc)(struct PointerRNA *ptr);
|
|||||||
typedef void (*PropStringSetFunc)(struct PointerRNA *ptr, const char *value);
|
typedef void (*PropStringSetFunc)(struct PointerRNA *ptr, const char *value);
|
||||||
typedef int (*PropEnumGetFunc)(struct PointerRNA *ptr);
|
typedef int (*PropEnumGetFunc)(struct PointerRNA *ptr);
|
||||||
typedef void (*PropEnumSetFunc)(struct PointerRNA *ptr, int value);
|
typedef void (*PropEnumSetFunc)(struct PointerRNA *ptr, int value);
|
||||||
typedef EnumPropertyItem *(*PropEnumItemFunc)(struct PointerRNA *ptr);
|
typedef EnumPropertyItem *(*PropEnumItemFunc)(struct bContext *C, struct PointerRNA *ptr, int *free);
|
||||||
typedef PointerRNA (*PropPointerGetFunc)(struct PointerRNA *ptr);
|
typedef PointerRNA (*PropPointerGetFunc)(struct PointerRNA *ptr);
|
||||||
typedef StructRNA* (*PropPointerTypeFunc)(struct PointerRNA *ptr);
|
typedef StructRNA* (*PropPointerTypeFunc)(struct PointerRNA *ptr);
|
||||||
typedef void (*PropPointerSetFunc)(struct PointerRNA *ptr, const PointerRNA value);
|
typedef void (*PropPointerSetFunc)(struct PointerRNA *ptr, const PointerRNA value);
|
||||||
@@ -225,7 +225,7 @@ typedef struct EnumPropertyRNA {
|
|||||||
PropEnumSetFunc set;
|
PropEnumSetFunc set;
|
||||||
PropEnumItemFunc itemf;
|
PropEnumItemFunc itemf;
|
||||||
|
|
||||||
const EnumPropertyItem *item;
|
EnumPropertyItem *item;
|
||||||
int totitem;
|
int totitem;
|
||||||
|
|
||||||
int defaultvalue;
|
int defaultvalue;
|
||||||
|
|||||||
@@ -40,6 +40,57 @@
|
|||||||
#include "WM_types.h"
|
#include "WM_types.h"
|
||||||
#include "WM_api.h"
|
#include "WM_api.h"
|
||||||
|
|
||||||
|
EnumPropertyItem part_from_items[] = {
|
||||||
|
{PART_FROM_VERT, "VERT", 0, "Verts", ""},
|
||||||
|
{PART_FROM_FACE, "FACE", 0, "Faces", ""},
|
||||||
|
{PART_FROM_VOLUME, "VOLUME", 0, "Volume", ""},
|
||||||
|
{0, NULL, 0, NULL, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
EnumPropertyItem part_reactor_from_items[] = {
|
||||||
|
{PART_FROM_VERT, "VERT", 0, "Verts", ""},
|
||||||
|
{PART_FROM_FACE, "FACE", 0, "Faces", ""},
|
||||||
|
{PART_FROM_VOLUME, "VOLUME", 0, "Volume", ""},
|
||||||
|
{PART_FROM_PARTICLE, "PARTICLE", 0, "Particle", ""},
|
||||||
|
{0, NULL, 0, NULL, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
EnumPropertyItem part_draw_as_items[] = {
|
||||||
|
{PART_DRAW_NOT, "NONE", 0, "None", ""},
|
||||||
|
{PART_DRAW_REND, "RENDER", 0, "Rendered", ""},
|
||||||
|
{PART_DRAW_DOT, "DOT", 0, "Point", ""},
|
||||||
|
{PART_DRAW_CIRC, "CIRC", 0, "Circle", ""},
|
||||||
|
{PART_DRAW_CROSS, "CROSS", 0, "Cross", ""},
|
||||||
|
{PART_DRAW_AXIS, "AXIS", 0, "Axis", ""},
|
||||||
|
{0, NULL, 0, NULL, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
EnumPropertyItem part_hair_draw_as_items[] = {
|
||||||
|
{PART_DRAW_NOT, "NONE", 0, "None", ""},
|
||||||
|
{PART_DRAW_REND, "RENDER", 0, "Rendered", ""},
|
||||||
|
{PART_DRAW_PATH, "PATH", 0, "Path", ""},
|
||||||
|
{0, NULL, 0, NULL, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
EnumPropertyItem part_ren_as_items[] = {
|
||||||
|
{PART_DRAW_NOT, "NONE", 0, "None", ""},
|
||||||
|
{PART_DRAW_HALO, "HALO", 0, "Halo", ""},
|
||||||
|
{PART_DRAW_LINE, "LINE", 0, "Line", ""},
|
||||||
|
{PART_DRAW_PATH, "PATH", 0, "Path", ""},
|
||||||
|
{PART_DRAW_OB, "OBJECT", 0, "Object", ""},
|
||||||
|
{PART_DRAW_GR, "GROUP", 0, "Group", ""},
|
||||||
|
{PART_DRAW_BB, "BILLBOARD", 0, "Billboard", ""},
|
||||||
|
{0, NULL, 0, NULL, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
EnumPropertyItem part_hair_ren_as_items[] = {
|
||||||
|
{PART_DRAW_NOT, "NONE", 0, "None", ""},
|
||||||
|
{PART_DRAW_PATH, "PATH", 0, "Path", ""},
|
||||||
|
{PART_DRAW_OB, "OBJECT", 0, "Object", ""},
|
||||||
|
{PART_DRAW_GR, "GROUP", 0, "Group", ""},
|
||||||
|
{0, NULL, 0, NULL, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
#ifdef RNA_RUNTIME
|
#ifdef RNA_RUNTIME
|
||||||
|
|
||||||
#include "BKE_context.h"
|
#include "BKE_context.h"
|
||||||
@@ -248,85 +299,34 @@ static void rna_ParticleSystem_name_get(PointerRNA *ptr, char *str)
|
|||||||
strcpy(str, "");
|
strcpy(str, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
static EnumPropertyItem from_items[] = {
|
static EnumPropertyItem *rna_Particle_from_itemf(bContext *C, PointerRNA *ptr, int *free)
|
||||||
{PART_FROM_VERT, "VERT", 0, "Vertexes", ""},
|
|
||||||
{PART_FROM_FACE, "FACE", 0, "Faces", ""},
|
|
||||||
{PART_FROM_VOLUME, "VOLUME", 0, "Volume", ""},
|
|
||||||
{0, NULL, 0, NULL, NULL}
|
|
||||||
};
|
|
||||||
|
|
||||||
static EnumPropertyItem reactor_from_items[] = {
|
|
||||||
{PART_FROM_VERT, "VERT", 0, "Vertexes", ""},
|
|
||||||
{PART_FROM_FACE, "FACE", 0, "Faces", ""},
|
|
||||||
{PART_FROM_VOLUME, "VOLUME", 0, "Volume", ""},
|
|
||||||
{PART_FROM_PARTICLE, "PARTICLE", 0, "Particle", ""},
|
|
||||||
{0, NULL, 0, NULL, NULL}
|
|
||||||
};
|
|
||||||
|
|
||||||
static EnumPropertyItem *rna_Particle_from_itemf(PointerRNA *ptr)
|
|
||||||
{
|
{
|
||||||
ParticleSettings *part = ptr->id.data;
|
ParticleSettings *part = ptr->id.data;
|
||||||
|
|
||||||
if(part->type==PART_REACTOR)
|
if(part->type==PART_REACTOR)
|
||||||
return reactor_from_items;
|
return part_reactor_from_items;
|
||||||
else
|
else
|
||||||
return from_items;
|
return part_from_items;
|
||||||
}
|
}
|
||||||
|
|
||||||
static EnumPropertyItem draw_as_items[] = {
|
static EnumPropertyItem *rna_Particle_draw_as_itemf(bContext *C, PointerRNA *ptr, int *free)
|
||||||
{PART_DRAW_NOT, "NONE", 0, "None", ""},
|
|
||||||
{PART_DRAW_REND, "RENDER", 0, "Rendered", ""},
|
|
||||||
{PART_DRAW_DOT, "DOT", 0, "Point", ""},
|
|
||||||
{PART_DRAW_CIRC, "CIRC", 0, "Circle", ""},
|
|
||||||
{PART_DRAW_CROSS, "CROSS", 0, "Cross", ""},
|
|
||||||
{PART_DRAW_AXIS, "AXIS", 0, "Axis", ""},
|
|
||||||
{0, NULL, 0, NULL, NULL}
|
|
||||||
};
|
|
||||||
|
|
||||||
static EnumPropertyItem hair_draw_as_items[] = {
|
|
||||||
{PART_DRAW_NOT, "NONE", 0, "None", ""},
|
|
||||||
{PART_DRAW_REND, "RENDER", 0, "Rendered", ""},
|
|
||||||
{PART_DRAW_PATH, "PATH", 0, "Path", ""},
|
|
||||||
{0, NULL, 0, NULL, NULL}
|
|
||||||
};
|
|
||||||
|
|
||||||
static EnumPropertyItem ren_as_items[] = {
|
|
||||||
{PART_DRAW_NOT, "NONE", 0, "None", ""},
|
|
||||||
{PART_DRAW_HALO, "HALO", 0, "Halo", ""},
|
|
||||||
{PART_DRAW_LINE, "LINE", 0, "Line", ""},
|
|
||||||
{PART_DRAW_PATH, "PATH", 0, "Path", ""},
|
|
||||||
{PART_DRAW_OB, "OBJECT", 0, "Object", ""},
|
|
||||||
{PART_DRAW_GR, "GROUP", 0, "Group", ""},
|
|
||||||
{PART_DRAW_BB, "BILLBOARD", 0, "Billboard", ""},
|
|
||||||
{0, NULL, 0, NULL, NULL}
|
|
||||||
};
|
|
||||||
|
|
||||||
static EnumPropertyItem hair_ren_as_items[] = {
|
|
||||||
{PART_DRAW_NOT, "NONE", 0, "None", ""},
|
|
||||||
{PART_DRAW_PATH, "PATH", 0, "Path", ""},
|
|
||||||
{PART_DRAW_OB, "OBJECT", 0, "Object", ""},
|
|
||||||
{PART_DRAW_GR, "GROUP", 0, "Group", ""},
|
|
||||||
{0, NULL, 0, NULL, NULL}
|
|
||||||
};
|
|
||||||
|
|
||||||
static EnumPropertyItem *rna_Particle_draw_as_itemf(PointerRNA *ptr)
|
|
||||||
{
|
{
|
||||||
ParticleSettings *part = ptr->id.data;
|
ParticleSettings *part = ptr->id.data;
|
||||||
|
|
||||||
if(part->type==PART_HAIR)
|
if(part->type==PART_HAIR)
|
||||||
return hair_draw_as_items;
|
return part_hair_draw_as_items;
|
||||||
else
|
else
|
||||||
return draw_as_items;
|
return part_draw_as_items;
|
||||||
}
|
}
|
||||||
|
|
||||||
static EnumPropertyItem *rna_Particle_ren_as_itemf(PointerRNA *ptr)
|
static EnumPropertyItem *rna_Particle_ren_as_itemf(bContext *C, PointerRNA *ptr, int *free)
|
||||||
{
|
{
|
||||||
ParticleSettings *part = ptr->id.data;
|
ParticleSettings *part = ptr->id.data;
|
||||||
|
|
||||||
if(part->type==PART_HAIR)
|
if(part->type==PART_HAIR)
|
||||||
return hair_ren_as_items;
|
return part_hair_ren_as_items;
|
||||||
else
|
else
|
||||||
return ren_as_items;
|
return part_ren_as_items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -801,6 +801,7 @@ static void rna_def_particle_settings(BlenderRNA *brna)
|
|||||||
|
|
||||||
prop= RNA_def_property(srna, "emit_from", PROP_ENUM, PROP_NONE);
|
prop= RNA_def_property(srna, "emit_from", PROP_ENUM, PROP_NONE);
|
||||||
RNA_def_property_enum_sdna(prop, NULL, "from");
|
RNA_def_property_enum_sdna(prop, NULL, "from");
|
||||||
|
RNA_def_property_enum_items(prop, part_reactor_from_items);
|
||||||
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Particle_from_itemf");
|
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Particle_from_itemf");
|
||||||
RNA_def_property_ui_text(prop, "Emit From", "Where to emit particles from");
|
RNA_def_property_ui_text(prop, "Emit From", "Where to emit particles from");
|
||||||
RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset");
|
RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset");
|
||||||
@@ -914,12 +915,14 @@ static void rna_def_particle_settings(BlenderRNA *brna)
|
|||||||
|
|
||||||
prop= RNA_def_property(srna, "draw_as", PROP_ENUM, PROP_NONE);
|
prop= RNA_def_property(srna, "draw_as", PROP_ENUM, PROP_NONE);
|
||||||
RNA_def_property_enum_sdna(prop, NULL, "draw_as");
|
RNA_def_property_enum_sdna(prop, NULL, "draw_as");
|
||||||
|
RNA_def_property_enum_items(prop, part_draw_as_items);
|
||||||
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Particle_draw_as_itemf");
|
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Particle_draw_as_itemf");
|
||||||
RNA_def_property_ui_text(prop, "Particle Drawing", "How particles are drawn in viewport");
|
RNA_def_property_ui_text(prop, "Particle Drawing", "How particles are drawn in viewport");
|
||||||
RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo");
|
RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo");
|
||||||
|
|
||||||
prop= RNA_def_property(srna, "ren_as", PROP_ENUM, PROP_NONE);
|
prop= RNA_def_property(srna, "ren_as", PROP_ENUM, PROP_NONE);
|
||||||
RNA_def_property_enum_sdna(prop, NULL, "ren_as");
|
RNA_def_property_enum_sdna(prop, NULL, "ren_as");
|
||||||
|
RNA_def_property_enum_items(prop, part_ren_as_items);
|
||||||
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Particle_ren_as_itemf");
|
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Particle_ren_as_itemf");
|
||||||
RNA_def_property_ui_text(prop, "Particle Rendering", "How particles are rendered");
|
RNA_def_property_ui_text(prop, "Particle Rendering", "How particles are rendered");
|
||||||
RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo");
|
RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo");
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ static EnumPropertyItem dc_rgb_items[] = {DC_RGB, DC_LCMS, DC_ZERO};
|
|||||||
static EnumPropertyItem dc_alpha_items[] = {DC_RGB, DC_RGBA, DC_ALPHA, DC_LCMS, DC_ZERO};
|
static EnumPropertyItem dc_alpha_items[] = {DC_RGB, DC_RGBA, DC_ALPHA, DC_LCMS, DC_ZERO};
|
||||||
static EnumPropertyItem dc_z_items[] = {DC_RGB, DC_Z, DC_LCMS, DC_ZERO};
|
static EnumPropertyItem dc_z_items[] = {DC_RGB, DC_Z, DC_LCMS, DC_ZERO};
|
||||||
|
|
||||||
static EnumPropertyItem *rna_SpaceImageEditor_draw_channels_itemf(PointerRNA *ptr)
|
static EnumPropertyItem *rna_SpaceImageEditor_draw_channels_itemf(bContext *C, PointerRNA *ptr, int *free)
|
||||||
{
|
{
|
||||||
SpaceImage *sima= (SpaceImage*)ptr->data;
|
SpaceImage *sima= (SpaceImage*)ptr->data;
|
||||||
ImBuf *ibuf= ED_space_image_buffer(sima);
|
ImBuf *ibuf= ED_space_image_buffer(sima);
|
||||||
|
|||||||
@@ -223,10 +223,16 @@ static void pyrna_struct_dealloc( BPy_StructRNA * self )
|
|||||||
|
|
||||||
static char *pyrna_enum_as_string(PointerRNA *ptr, PropertyRNA *prop)
|
static char *pyrna_enum_as_string(PointerRNA *ptr, PropertyRNA *prop)
|
||||||
{
|
{
|
||||||
const EnumPropertyItem *item;
|
EnumPropertyItem *item;
|
||||||
|
char *result;
|
||||||
|
int free;
|
||||||
|
|
||||||
RNA_property_enum_items(ptr, prop, &item, NULL);
|
RNA_property_enum_items(BPy_GetContext(), ptr, prop, &item, NULL, &free);
|
||||||
return (char*)BPy_enum_as_string((EnumPropertyItem*)item);
|
result= (char*)BPy_enum_as_string(item);
|
||||||
|
if(free)
|
||||||
|
MEM_freeN(item);
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject * pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop)
|
PyObject * pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop)
|
||||||
@@ -309,14 +315,15 @@ PyObject * pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop)
|
|||||||
const char *identifier;
|
const char *identifier;
|
||||||
int val = RNA_property_enum_get(ptr, prop);
|
int val = RNA_property_enum_get(ptr, prop);
|
||||||
|
|
||||||
if (RNA_property_enum_identifier(ptr, prop, val, &identifier)) {
|
if (RNA_property_enum_identifier(BPy_GetContext(), ptr, prop, val, &identifier)) {
|
||||||
ret = PyUnicode_FromString( identifier );
|
ret = PyUnicode_FromString( identifier );
|
||||||
} else {
|
} else {
|
||||||
const EnumPropertyItem *item;
|
EnumPropertyItem *item;
|
||||||
|
int free;
|
||||||
|
|
||||||
/* don't throw error here, can't trust blender 100% to give the
|
/* don't throw error here, can't trust blender 100% to give the
|
||||||
* right values, python code should not generate error for that */
|
* right values, python code should not generate error for that */
|
||||||
RNA_property_enum_items(ptr, prop, &item, NULL);
|
RNA_property_enum_items(BPy_GetContext(), ptr, prop, &item, NULL, &free);
|
||||||
if(item->identifier) {
|
if(item->identifier) {
|
||||||
ret = PyUnicode_FromString( item->identifier );
|
ret = PyUnicode_FromString( item->identifier );
|
||||||
}
|
}
|
||||||
@@ -329,6 +336,9 @@ PyObject * pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop)
|
|||||||
ret = PyUnicode_FromString( "" );
|
ret = PyUnicode_FromString( "" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(free)
|
||||||
|
MEM_freeN(item);
|
||||||
|
|
||||||
/*PyErr_Format(PyExc_AttributeError, "RNA Error: Current value \"%d\" matches no enum", val);
|
/*PyErr_Format(PyExc_AttributeError, "RNA Error: Current value \"%d\" matches no enum", val);
|
||||||
ret = NULL;*/
|
ret = NULL;*/
|
||||||
}
|
}
|
||||||
@@ -626,7 +636,7 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyObject *v
|
|||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
int val;
|
int val;
|
||||||
if (RNA_property_enum_value(ptr, prop, param, &val)) {
|
if (RNA_property_enum_value(BPy_GetContext(), ptr, prop, param, &val)) {
|
||||||
if(data) *((int*)data)= val;
|
if(data) *((int*)data)= val;
|
||||||
else RNA_property_enum_set(ptr, prop, val);
|
else RNA_property_enum_set(ptr, prop, val);
|
||||||
} else {
|
} else {
|
||||||
@@ -1818,19 +1828,23 @@ PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *data)
|
|||||||
const char *identifier;
|
const char *identifier;
|
||||||
int val = *(int*)data;
|
int val = *(int*)data;
|
||||||
|
|
||||||
if (RNA_property_enum_identifier(ptr, prop, val, &identifier)) {
|
if (RNA_property_enum_identifier(BPy_GetContext(), ptr, prop, val, &identifier)) {
|
||||||
ret = PyUnicode_FromString( identifier );
|
ret = PyUnicode_FromString( identifier );
|
||||||
} else {
|
} else {
|
||||||
const EnumPropertyItem *item;
|
EnumPropertyItem *item;
|
||||||
|
int free;
|
||||||
|
|
||||||
/* don't throw error here, can't trust blender 100% to give the
|
/* don't throw error here, can't trust blender 100% to give the
|
||||||
* right values, python code should not generate error for that */
|
* right values, python code should not generate error for that */
|
||||||
RNA_property_enum_items(ptr, prop, &item, NULL);
|
RNA_property_enum_items(BPy_GetContext(), ptr, prop, &item, NULL, &free);
|
||||||
if(item[0].identifier)
|
if(item[0].identifier)
|
||||||
ret = PyUnicode_FromString( item[0].identifier );
|
ret = PyUnicode_FromString( item[0].identifier );
|
||||||
else
|
else
|
||||||
ret = PyUnicode_FromString( "" );
|
ret = PyUnicode_FromString( "" );
|
||||||
|
|
||||||
|
if(free)
|
||||||
|
MEM_freeN(item);
|
||||||
|
|
||||||
/*PyErr_Format(PyExc_AttributeError, "RNA Error: Current value \"%d\" matches no enum", val);
|
/*PyErr_Format(PyExc_AttributeError, "RNA Error: Current value \"%d\" matches no enum", val);
|
||||||
ret = NULL;*/
|
ret = NULL;*/
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -412,6 +412,7 @@ char *BPy_enum_as_string(EnumPropertyItem *item)
|
|||||||
char *cstring;
|
char *cstring;
|
||||||
|
|
||||||
for (e= item; item->identifier; item++) {
|
for (e= item; item->identifier; item++) {
|
||||||
|
if(item->identifier[0])
|
||||||
BLI_dynstr_appendf(dynstr, (e==item)?"'%s'":", '%s'", item->identifier);
|
BLI_dynstr_appendf(dynstr, (e==item)?"'%s'":", '%s'", item->identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user