check Save Image or Export PLY operator for example.
Also these code changes:
* Added some RNA collection iterator macros to simplify code.
* Fix bpy.props.BoolProperty not working correct.
* Merge uiDefAutoButsRNA/uiDefAutoButsRNA_single into one.
void uiBlockColorbandButtons(struct uiBlock *block, struct ColorBand *coba, struct rctf *butr, int event);
uiBut *uiDefAutoButR(uiBlock *block, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, char *name, int icon, int x1, int y1, int x2, int y2);
-void uiDefAutoButsRNA(const struct bContext *C, uiLayout *layout, struct PointerRNA *ptr);
+void uiDefAutoButsRNA(const struct bContext *C, uiLayout *layout, struct PointerRNA *ptr, int columns);
/* Links
*
static void ui_rna_ID_collection(bContext *C, uiBut *but, PointerRNA *ptr, PropertyRNA **prop)
{
- CollectionPropertyIterator iter;
- PropertyRNA *iterprop, *iprop;
StructRNA *srna;
/* look for collection property in Main */
RNA_pointer_create(NULL, &RNA_Main, CTX_data_main(C), ptr);
- iterprop= RNA_struct_iterator_property(ptr->type);
- RNA_property_collection_begin(ptr, iterprop, &iter);
*prop= NULL;
- for(; iter.valid; RNA_property_collection_next(&iter)) {
- iprop= iter.ptr.data;
-
+ RNA_STRUCT_BEGIN(ptr, iprop) {
/* if it's a collection and has same pointer type, we've got it */
if(RNA_property_type(iprop) == PROP_COLLECTION) {
srna= RNA_property_pointer_type(ptr, iprop);
}
}
}
-
- RNA_property_collection_end(&iter);
+ RNA_STRUCT_END;
}
/* autocomplete callback for RNA pointers */
{
uiBut *but= arg_but;
AutoComplete *autocpl;
- CollectionPropertyIterator iter;
PointerRNA ptr;
PropertyRNA *prop;
char *name;
if(prop==NULL) return;
autocpl= autocomplete_begin(str, ui_get_but_string_max_length(but));
- RNA_property_collection_begin(&ptr, prop, &iter);
/* loop over items in collection */
- for(; iter.valid; RNA_property_collection_next(&iter)) {
- name= RNA_struct_name_get_alloc(&iter.ptr, NULL, 0);
+ RNA_PROP_BEGIN(&ptr, itemptr, prop) {
+ name= RNA_struct_name_get_alloc(&itemptr, NULL, 0);
/* test item name */
if(name) {
MEM_freeN(name);
}
}
+ RNA_PROP_END;
- RNA_property_collection_end(&iter);
autocomplete_end(autocpl, str);
}
scroll= MIN2(scroll, len-items+1);
scroll= MAX2(scroll, 1);
- RNA_BEGIN(ptr, itemptr, propname) {
+ RNA_PROP_BEGIN(ptr, itemptr, prop) {
if(i >= scroll && i<scroll+items) {
name= RNA_struct_name_get_alloc(&itemptr, NULL, 0);
item->activei= i;
if(activetype == PROP_POINTER)
- item->selected= (activeptr.data == itemptr.data);
+ item->selected= (activeptr.data == itemptr.data)? i: -1;
else if(activetype == PROP_INT)
- item->selected= (activei == i);
+ item->selected= (activei == i)? i: -1;
else if(activetype == PROP_STRING)
- item->selected= (strcmp(activename, name) == 0);
+ item->selected= (strcmp(activename, name) == 0)? i: -1;
- but= uiDefIconTextButI(block, TOG, 0, RNA_struct_ui_icon(itemptr.type), name, 0,0,UI_UNIT_X*10,UI_UNIT_Y, &item->selected, 0, 0, 0, 0, "");
+ but= uiDefIconTextButI(block, ROW, 0, RNA_struct_ui_icon(itemptr.type), name, 0,0,UI_UNIT_X*10,UI_UNIT_Y, &item->selected, 0, i, 0, 0, "");
uiButSetFlag(but, UI_ICON_LEFT|UI_TEXT_LEFT);
uiButSetNFunc(but, list_item_cb, item, NULL);
i++;
}
- RNA_END;
+ RNA_PROP_END;
while(i < scroll+items) {
if(i >= scroll)
return but;
}
-void uiDefAutoButsRNA(const bContext *C, uiLayout *layout, PointerRNA *ptr)
+void uiDefAutoButsRNA(const bContext *C, uiLayout *layout, PointerRNA *ptr, int columns)
{
- CollectionPropertyIterator iter;
- PropertyRNA *iterprop, *prop;
- uiLayout *split;
+ uiLayout *split, *col;
char *name;
uiItemL(layout, (char*)RNA_struct_ui_name(ptr->type), 0);
- iterprop= RNA_struct_iterator_property(ptr->type);
- RNA_property_collection_begin(ptr, iterprop, &iter);
-
- for(; iter.valid; RNA_property_collection_next(&iter)) {
- prop= iter.ptr.data;
-
+ RNA_STRUCT_BEGIN(ptr, prop) {
if(strcmp(RNA_property_identifier(prop), "rna_type") == 0)
continue;
- split = uiLayoutSplit(layout, 0.5f);
-
name= (char*)RNA_property_ui_name(prop);
- uiItemL(uiLayoutColumn(split, 0), name, 0);
- uiItemFullR(uiLayoutColumn(split, 0), "", 0, ptr, prop, -1, 0, 0, 0, 0);
- }
+ if(columns == 1) {
+ col= uiLayoutColumn(layout, 1);
+ uiItemL(col, name, 0);
+ }
+ else if(columns == 2) {
+ split = uiLayoutSplit(layout, 0.5f);
- RNA_property_collection_end(&iter);
-}
+ uiItemL(uiLayoutColumn(split, 0), name, 0);
+ col= uiLayoutColumn(split, 0);
+ }
-/* temp call, single collumn, test for toolbar only */
-void uiDefAutoButsRNA_single(const bContext *C, uiLayout *layout, PointerRNA *ptr)
-{
- CollectionPropertyIterator iter;
- PropertyRNA *iterprop, *prop;
- uiLayout *col;
- char *name;
-
- uiItemL(layout, (char*)RNA_struct_ui_name(ptr->type), 0);
-
- iterprop= RNA_struct_iterator_property(ptr->type);
- RNA_property_collection_begin(ptr, iterprop, &iter);
-
- for(; iter.valid; RNA_property_collection_next(&iter)) {
- prop= iter.ptr.data;
-
- if(strcmp(RNA_property_identifier(prop), "rna_type") == 0)
- continue;
-
- name= (char*)RNA_property_ui_name(prop);
- col= uiLayoutColumn(layout, 1);
- uiItemL(col, name, 0);
-
/* temp hack to show normal button for spin/screw */
if(strcmp(name, "Axis")==0) {
- uiDefButR(uiLayoutGetBlock(layout), BUT_NORMAL, 0, name, 0, 0, 100, 100, ptr, "axis", -1, 0, 0, -1, -1, NULL);
+ uiDefButR(uiLayoutGetBlock(col), BUT_NORMAL, 0, name, 0, 0, 100, 100, ptr, "axis", -1, 0, 0, -1, -1, NULL);
}
else uiItemFullR(col, "", 0, ptr, prop, -1, 0, 0, 0, 0);
}
-
- RNA_property_collection_end(&iter);
+ RNA_STRUCT_END;
}
-
/***************************** ID Utilities *******************************/
/* note, C code version, will be replaced with version in interface_templates.c */
}
}
-static void file_draw_fsmenu_category(const bContext *C, ARegion *ar, FSMenuCategory category, const char* category_name, short *starty)
+static void file_draw_fsmenu_category_name(ARegion *ar, const char *category_name, short *starty)
+{
+ short sx, sy;
+ int bmwidth = ar->v2d.cur.xmax - ar->v2d.cur.xmin - 2*TILE_BORDER_X - ICON_DEFAULT_WIDTH - 4;
+ int fontsize = file_font_pointsize();
+
+ sx = ar->v2d.cur.xmin + TILE_BORDER_X;
+ sy = *starty;
+
+ UI_ThemeColor(TH_TEXT_HI);
+ file_draw_string(sx, sy, category_name, bmwidth, fontsize, FILE_SHORTEN_END);
+
+ sy -= fontsize*2.0f;
+
+ *starty= sy;
+}
+
+static void file_draw_fsmenu_category(const bContext *C, ARegion *ar, FSMenuCategory category, short *starty)
{
struct FSMenu* fsmenu = fsmenu_get();
char bookmark[FILE_MAX];
sx = ar->v2d.cur.xmin + TILE_BORDER_X;
sy = *starty;
- UI_ThemeColor(TH_TEXT_HI);
- file_draw_string(sx, sy, category_name, bmwidth, fontsize, FILE_SHORTEN_END);
-
- sy -= fontsize*2.0f;
-
switch(category) {
case FS_CATEGORY_SYSTEM:
cat_icon = ICON_DISK_DRIVE; break;
*starty = sy;
}
+void file_draw_fsmenu_operator(const bContext *C, ARegion *ar, wmOperator *op, short *starty)
+{
+ uiStyle *style= U.uistyles.first;
+ uiBlock *block;
+ uiLayout *layout;
+ int sy;
+
+ sy= *starty;
+
+ block= uiBeginBlock(C, ar, "file_options", UI_EMBOSS);
+ layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, TILE_BORDER_X, sy, ar->winx-2*TILE_BORDER_X, 20, style);
+
+ RNA_STRUCT_BEGIN(op->ptr, prop) {
+ if(strcmp(RNA_property_identifier(prop), "rna_type") == 0)
+ continue;
+ if(strcmp(RNA_property_identifier(prop), "filename") == 0)
+ continue;
+
+ uiItemFullR(layout, NULL, 0, op->ptr, prop, -1, 0, 0, 0, 0);
+ }
+ RNA_STRUCT_END;
+
+ uiBlockLayoutResolve(C, block, NULL, &sy);
+ uiEndBlock(C, block);
+ uiDrawBlock(C, block);
+
+ *starty= sy;
+}
+
void file_draw_fsmenu(const bContext *C, ARegion *ar)
{
+ SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
int linestep = file_font_pointsize()*2.0f;
short sy= ar->v2d.cur.ymax-2*TILE_BORDER_Y;
- file_draw_fsmenu_category(C, ar, FS_CATEGORY_SYSTEM, "SYSTEM", &sy);
+ file_draw_fsmenu_category_name(ar, "SYSTEM", &sy);
+ file_draw_fsmenu_category(C, ar, FS_CATEGORY_SYSTEM, &sy);
sy -= linestep;
- file_draw_fsmenu_category(C, ar, FS_CATEGORY_BOOKMARKS, "BOOKMARKS", &sy);
+ file_draw_fsmenu_category_name(ar, "BOOKMARKS", &sy);
+ file_draw_fsmenu_category(C, ar, FS_CATEGORY_BOOKMARKS, &sy);
sy -= linestep;
- file_draw_fsmenu_category(C, ar, FS_CATEGORY_RECENT, "RECENT", &sy);
-
+ file_draw_fsmenu_category_name(ar, "RECENT", &sy);
+ file_draw_fsmenu_category(C, ar, FS_CATEGORY_RECENT, &sy);
+
+ if(sfile->op) {
+ sy -= linestep;
+ file_draw_fsmenu_category_name(ar, "OPTIONS", &sy);
+ file_draw_fsmenu_operator(C, ar, sfile->op, &sy);
+ }
}
+
/**************** load/replace/save callbacks ******************/
-static char *filesel_imagetype_string(Image *ima)
-{
- char *strp, *str= MEM_callocN(15*32, "menu for filesel");
-
- strp= str;
- str += sprintf(str, "Save Image as: %%t|");
- str += sprintf(str, "Targa %%x%d|", R_TARGA);
- str += sprintf(str, "Targa Raw %%x%d|", R_RAWTGA);
- str += sprintf(str, "PNG %%x%d|", R_PNG);
- str += sprintf(str, "BMP %%x%d|", R_BMP);
- str += sprintf(str, "Jpeg %%x%d|", R_JPEG90);
+/* XXX make dynamic */
+static const EnumPropertyItem image_file_type_items[] = {
+ {R_TARGA, "TARGA", 0, "Targa", ""},
+ {R_RAWTGA, "TARGA RAW", 0, "Targa Raw", ""},
+ {R_PNG, "PNG", 0, "PNG", ""},
+ {R_BMP, "BMP", 0, "BMP", ""},
+ {R_JPEG90, "JPEG", 0, "Jpeg", ""},
#ifdef WITH_OPENJPEG
- str += sprintf(str, "Jpeg 2000 %%x%d|", R_JP2);
+ {R_JP2, "JPEG_2000", 0, "Jpeg 2000", ""},
#endif
- str += sprintf(str, "Iris %%x%d|", R_IRIS);
- if(G.have_libtiff)
- str += sprintf(str, "Tiff %%x%d|", R_TIFF);
- str += sprintf(str, "Radiance HDR %%x%d|", R_RADHDR);
- str += sprintf(str, "Cineon %%x%d|", R_CINEON);
- str += sprintf(str, "DPX %%x%d|", R_DPX);
+ {R_IRIS, "IRIS", 0, "Iris", ""},
+ //if(G.have_libtiff)
+ {R_TIFF, "TIFF", 0, "Tiff", ""},
+ {R_RADHDR, "RADIANCE_HDR", 0, "Radiance HDR", ""},
+ {R_CINEON, "CINEON", 0, "Cineon", ""},
+ {R_DPX, "DPX", 0, "DPX", ""},
#ifdef WITH_OPENEXR
- str += sprintf(str, "OpenEXR %%x%d|", R_OPENEXR);
+ {R_OPENEXR, "OPENEXR", 0, "OpenEXR", ""},
/* saving sequences of multilayer won't work, they copy buffers */
- if(ima->source==IMA_SRC_SEQUENCE && ima->type==IMA_TYPE_MULTILAYER);
- else str += sprintf(str, "MultiLayer %%x%d|", R_MULTILAYER);
+ /*if(ima->source==IMA_SRC_SEQUENCE && ima->type==IMA_TYPE_MULTILAYER);
+ else*/
+ {R_MULTILAYER, "MULTILAYER", 0, "MultiLayer", ""},
#endif
- return strp;
-}
+ {0, NULL, 0, NULL, NULL}};
static void image_filesel(bContext *C, wmOperator *op, const char *path)
{
if(!ima)
return OPERATOR_CANCELLED;
+ sima->imtypenr= RNA_enum_get(op->ptr, "file_type");
RNA_string_get(op->ptr, "filename", str);
+
save_image_doit(C, sima, scene, op, str);
return OPERATOR_FINISHED;
/* always opens fileselect */
if(ibuf) {
- char *strp;
-
- strp= filesel_imagetype_string(ima); // XXX unused still
-
/* cant save multilayer sequence, ima->rr isn't valid for a specific frame */
if(ima->rr && !(ima->source==IMA_SRC_SEQUENCE && ima->type==IMA_TYPE_MULTILAYER))
sima->imtypenr= R_MULTILAYER;
sima->imtypenr= scene->r.imtype;
else
sima->imtypenr= BKE_ftype_to_imtype(ibuf->ftype);
+
+ RNA_enum_set(op->ptr, "file_type", sima->imtypenr);
if(ibuf->name[0]==0)
BLI_strncpy(ibuf->name, G.ima, FILE_MAX);
// XXX note: we can give default menu enums to operator for this
image_filesel(C, op, ibuf->name);
-
- MEM_freeN(strp);
return OPERATOR_RUNNING_MODAL;
}
/* properties */
RNA_def_string_file_path(ot->srna, "filename", "", FILE_MAX, "Filename", "File path to save image to.");
+ RNA_def_enum(ot->srna, "file_type", image_file_type_items, R_PNG, "File Type", "File type to save image as.");
}
/******************** save image operator ********************/
}
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
- uiDefAutoButsRNA(C, pa->layout, &ptr);
+ uiDefAutoButsRNA(C, pa->layout, &ptr, 2);
}
void view3d_buttons_register(ARegionType *art)
static void view3d_panel_operator_redo(const bContext *C, Panel *pa)
{
- /* XXX temp */
- extern void uiDefAutoButsRNA_single(const bContext *C, uiLayout *layout, PointerRNA *ptr);
wmWindowManager *wm= CTX_wm_manager(C);
wmOperator *op;
PointerRNA ptr;
}
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
- uiDefAutoButsRNA_single(C, pa->layout, &ptr);
+ uiDefAutoButsRNA(C, pa->layout, &ptr, 1);
}
void view3d_toolbar_register(ARegionType *art)
RNA_property_collection_end(&rna_macro_iter); \
}
+#define RNA_PROP_BEGIN(sptr, itemptr, prop) \
+ { \
+ CollectionPropertyIterator rna_macro_iter; \
+ for(RNA_property_collection_begin(sptr, prop, &rna_macro_iter); rna_macro_iter.valid; RNA_property_collection_next(&rna_macro_iter)) { \
+ PointerRNA itemptr= rna_macro_iter.ptr;
+
+#define RNA_PROP_END \
+ } \
+ RNA_property_collection_end(&rna_macro_iter); \
+ }
+
+#define RNA_STRUCT_BEGIN(sptr, prop) \
+ { \
+ CollectionPropertyIterator rna_macro_iter; \
+ for(RNA_property_collection_begin(sptr, RNA_struct_iterator_property(sptr->type), &rna_macro_iter); rna_macro_iter.valid; RNA_property_collection_next(&rna_macro_iter)) { \
+ PropertyRNA *prop= rna_macro_iter.ptr.data;
+
+#define RNA_STRUCT_END \
+ } \
+ RNA_property_collection_end(&rna_macro_iter); \
+ }
+
/* check if the idproperty exists, for operators */
int RNA_property_is_set(PointerRNA *ptr, const char *name);
PropertyRNA *RNA_def_string_file_path(StructOrFunctionRNA *cont, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description);
PropertyRNA *RNA_def_string_dir_path(StructOrFunctionRNA *cont, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description);
-PropertyRNA *RNA_def_enum(StructOrFunctionRNA *cont, const char *identifier, EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description);
+PropertyRNA *RNA_def_enum(StructOrFunctionRNA *cont, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description);
PropertyRNA *RNA_def_float(StructOrFunctionRNA *cont, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax);
PropertyRNA *RNA_def_float_vector(StructOrFunctionRNA *cont, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax);
/* Find the property which uses the given nested struct */
PropertyRNA *RNA_struct_find_nested(PointerRNA *ptr, StructRNA *srna)
{
- CollectionPropertyIterator iter;
- PropertyRNA *iterprop, *prop;
- int i = 0;
+ PropertyRNA *prop= NULL;
- iterprop= RNA_struct_iterator_property(ptr->type);
- RNA_property_collection_begin(ptr, iterprop, &iter);
- prop= NULL;
-
- for(; iter.valid; RNA_property_collection_next(&iter), i++) {
+ RNA_STRUCT_BEGIN(ptr, iprop) {
/* This assumes that there can only be one user of this nested struct */
- if (RNA_property_pointer_type(ptr, iter.ptr.data) == srna) {
- prop= iter.ptr.data;
+ if (RNA_property_pointer_type(ptr, iprop) == srna) {
+ prop= iprop;
break;
}
}
-
- RNA_property_collection_end(&iter);
+ RNA_PROP_END;
return prop;
}
FunctionRNA *RNA_struct_find_function(PointerRNA *ptr, const char *identifier)
{
PointerRNA tptr;
- CollectionPropertyIterator iter;
PropertyRNA *iterprop;
FunctionRNA *func;
- int i = 0;
RNA_pointer_create(NULL, &RNA_Struct, ptr->type, &tptr);
iterprop= RNA_struct_find_property(&tptr, "functions");
- RNA_property_collection_begin(&tptr, iterprop, &iter);
func= NULL;
- for(; iter.valid; RNA_property_collection_next(&iter), i++) {
- if(strcmp(identifier, RNA_function_identifier(iter.ptr.data)) == 0) {
- func= iter.ptr.data;
+ RNA_PROP_BEGIN(&tptr, funcptr, iterprop) {
+ if(strcmp(identifier, RNA_function_identifier(funcptr.data)) == 0) {
+ func= funcptr.data;
break;
}
}
-
- RNA_property_collection_end(&iter);
+ RNA_PROP_END;
return func;
}
DynStr *dynstr= BLI_dynstr_new();
char *cstring;
- PropertyRNA *prop, *iterprop;
- CollectionPropertyIterator iter;
const char *propname;
int first_time = 1;
BLI_dynstr_append(dynstr, "{");
- iterprop= RNA_struct_iterator_property(ptr->type);
-
- for(RNA_property_collection_begin(ptr, iterprop, &iter); iter.valid; RNA_property_collection_next(&iter)) {
- prop= iter.ptr.data;
+ RNA_STRUCT_BEGIN(ptr, prop) {
propname = RNA_property_identifier(prop);
if(strcmp(propname, "rna_type")==0)
BLI_dynstr_appendf(dynstr, "\"%s\":%s", propname, cstring);
MEM_freeN(cstring);
}
+ RNA_STRUCT_END;
- RNA_property_collection_end(&iter);
BLI_dynstr_append(dynstr, "}");
return prop;
}
-PropertyRNA *RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, EnumPropertyItem *items, int default_value,
+PropertyRNA *RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value,
const char *ui_name, const char *ui_description)
{
ContainerRNA *cont= cont_;
/* Assign instance attributes from operator properties */
{
- PropertyRNA *prop, *iterprop;
- CollectionPropertyIterator iter;
const char *arg_name;
- iterprop= RNA_struct_iterator_property(op->ptr->type);
- RNA_property_collection_begin(op->ptr, iterprop, &iter);
-
- for(; iter.valid; RNA_property_collection_next(&iter)) {
- prop= iter.ptr.data;
+ RNA_STRUCT_BEGIN(op->ptr, prop) {
arg_name= RNA_property_identifier(prop);
if (strcmp(arg_name, "rna_type")==0) continue;
PyObject_SetAttrString(py_class_instance, arg_name, item);
Py_DECREF(item);
}
-
- RNA_property_collection_end(&iter);
+ RNA_STRUCT_END;
}
/* set operator pointer RNA as instance "__operator__" attribute */
const char *arg_name= NULL;
PyObject *item;
- PropertyRNA *prop, *iterprop;
- CollectionPropertyIterator iter;
-
- iterprop= RNA_struct_iterator_property(ptr->type);
- RNA_property_collection_begin(ptr, iterprop, &iter);
-
totkw = kw ? PyDict_Size(kw):0;
- for(; iter.valid; RNA_property_collection_next(&iter)) {
- prop= iter.ptr.data;
-
+ RNA_STRUCT_BEGIN(ptr, prop) {
arg_name= RNA_property_identifier(prop);
if (strcmp(arg_name, "rna_type")==0) continue;
totkw--;
}
-
- RNA_property_collection_end(&iter);
+ RNA_STRUCT_END;
if (error_val==0 && totkw > 0) { /* some keywords were given that were not used :/ */
PyObject *key, *value;
PyObject *pystring;
/* for looping over attrs and funcs */
- CollectionPropertyIterator iter;
PropertyRNA *iterprop;
/* Include this incase this instance is a subtype of a python class
char name[256], *nameptr;
iterprop= RNA_struct_iterator_property(self->ptr.type);
- RNA_property_collection_begin(&self->ptr, iterprop, &iter);
- for(; iter.valid; RNA_property_collection_next(&iter)) {
- nameptr= RNA_struct_name_get_alloc(&iter.ptr, name, sizeof(name));
+ RNA_PROP_BEGIN(&self->ptr, itemptr, iterprop) {
+ nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name));
if(nameptr) {
pystring = PyUnicode_FromString(nameptr);
MEM_freeN(nameptr);
}
}
- RNA_property_collection_end(&iter);
-
+ RNA_PROP_END;
}
RNA_pointer_create(NULL, &RNA_Struct, self->ptr.type, &tptr);
iterprop= RNA_struct_find_property(&tptr, "functions");
- RNA_property_collection_begin(&tptr, iterprop, &iter);
-
- for(; iter.valid; RNA_property_collection_next(&iter)) {
- pystring = PyUnicode_FromString(RNA_function_identifier(iter.ptr.data));
+ RNA_PROP_BEGIN(&tptr, itemptr, iterprop) {
+ pystring = PyUnicode_FromString(RNA_function_identifier(itemptr.data));
PyList_Append(ret, pystring);
Py_DECREF(pystring);
}
-
- RNA_property_collection_end(&iter);
+ RNA_PROP_END;
}
if(self->ptr.type == &RNA_Context) {
ret = NULL;
} else {
PyObject *item;
- CollectionPropertyIterator iter;
- PropertyRNA *nameprop;
char name[256], *nameptr;
ret = PyList_New(0);
- RNA_property_collection_begin(&self->ptr, self->prop, &iter);
- for(; iter.valid; RNA_property_collection_next(&iter)) {
- nameptr= RNA_struct_name_get_alloc(&iter.ptr, name, sizeof(name));
+ RNA_PROP_BEGIN(&self->ptr, itemptr, self->prop) {
+ nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name));
if(nameptr) {
- nameptr= RNA_property_string_get_alloc(&iter.ptr, nameprop, name, sizeof(name));
-
/* add to python list */
item = PyUnicode_FromString( nameptr );
PyList_Append(ret, item);
MEM_freeN(nameptr);
}
}
- RNA_property_collection_end(&iter);
+ RNA_PROP_END;
}
return ret;
ret = NULL;
} else {
PyObject *item;
- CollectionPropertyIterator iter;
char name[256], *nameptr;
int i= 0;
ret = PyList_New(0);
- RNA_property_collection_begin(&self->ptr, self->prop, &iter);
- for(; iter.valid; RNA_property_collection_next(&iter)) {
- if(iter.ptr.data) {
+ RNA_PROP_BEGIN(&self->ptr, itemptr, self->prop) {
+ if(itemptr.data) {
/* add to python list */
item= PyTuple_New(2);
- nameptr= RNA_struct_name_get_alloc(&iter.ptr, name, sizeof(name));
+ nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name));
if(nameptr) {
PyTuple_SET_ITEM(item, 0, PyUnicode_FromString( nameptr ));
if(name != nameptr)
else {
PyTuple_SET_ITEM(item, 0, PyLong_FromSsize_t(i)); /* a bit strange but better then returning an empty list */
}
- PyTuple_SET_ITEM(item, 1, pyrna_struct_CreatePyObject(&iter.ptr));
+ PyTuple_SET_ITEM(item, 1, pyrna_struct_CreatePyObject(&itemptr));
PyList_Append(ret, item);
Py_DECREF(item);
i++;
}
}
- RNA_property_collection_end(&iter);
+ RNA_PROP_END;
}
return ret;
ret = NULL;
} else {
PyObject *item;
- CollectionPropertyIterator iter;
ret = PyList_New(0);
- RNA_property_collection_begin(&self->ptr, self->prop, &iter);
- for(; iter.valid; RNA_property_collection_next(&iter)) {
- item = pyrna_struct_CreatePyObject(&iter.ptr);
+ RNA_PROP_BEGIN(&self->ptr, itemptr, self->prop) {
+ item = pyrna_struct_CreatePyObject(&itemptr);
PyList_Append(ret, item);
Py_DECREF(item);
}
- RNA_property_collection_end(&iter);
+ RNA_PROP_END;
}
return ret;
char *id, *name="", *description="";
int def=0;
- if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssi:IntProperty", kwlist, &id, &name, &description, &def))
+ if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssi:BoolProperty", kwlist, &id, &name, &description, &def))
return NULL;
if (PyTuple_Size(args) > 0) {
Py_RETURN_NONE;
} else {
PyObject *ret = PyTuple_New(2);
- PyTuple_SET_ITEM(ret, 0, PyCObject_FromVoidPtr((void *)BPy_IntProperty, NULL));
+ PyTuple_SET_ITEM(ret, 0, PyCObject_FromVoidPtr((void *)BPy_BoolProperty, NULL));
PyTuple_SET_ITEM(ret, 1, kw);
Py_INCREF(kw);
return ret;
const char *arg_name= NULL;
PropertyRNA *prop, *iterprop;
- CollectionPropertyIterator iter;
/* for building the string */
DynStr *dynstr= BLI_dynstr_new();
BLI_dynstr_appendf(dynstr, "%s(", op->idname);
iterprop= RNA_struct_iterator_property(op->ptr->type);
- RNA_property_collection_begin(op->ptr, iterprop, &iter);
- for(; iter.valid; RNA_property_collection_next(&iter)) {
- prop= iter.ptr.data;
+ RNA_PROP_BEGIN(op->ptr, propptr, iterprop) {
+ prop= propptr.data;
arg_name= RNA_property_identifier(prop);
if (strcmp(arg_name, "rna_type")==0) continue;
MEM_freeN(buf);
first_iter = 0;
}
-
- RNA_property_collection_end(&iter);
+ RNA_PROP_END;
BLI_dynstr_append(dynstr, ")");
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 300, 20, style);
- uiDefAutoButsRNA(C, layout, &ptr);
+ uiDefAutoButsRNA(C, layout, &ptr, 2);
uiPopupBoundsBlock(block, 4.0f, 0, 0);
uiEndBlock(C, block);
uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN|UI_BLOCK_RET_1);
layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 300, 20, style);
- uiDefAutoButsRNA(C, layout, op->ptr);
+ uiDefAutoButsRNA(C, layout, op->ptr, 2);
uiPopupBoundsBlock(block, 4.0f, 0, 0);
uiEndBlock(C, block);