Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-06-25 01:27:10 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-06-25 01:27:10 +0400
commit7a357cba3994bee7d05c7a8bf5736eb94067d564 (patch)
tree942d61fdd1138867710ed41604c4d2947565f7b1 /source/blender/editors
parent169fdf9e9757a8c31d950f5902d7c4cfd1f96a88 (diff)
2.5: File Selector: display operator properties in the side region,
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.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/include/UI_interface.h2
-rw-r--r--source/blender/editors/interface/interface.c19
-rw-r--r--source/blender/editors/interface/interface_templates.c12
-rw-r--r--source/blender/editors/interface/interface_utils.c58
-rw-r--r--source/blender/editors/space_file/file_draw.c71
-rw-r--r--source/blender/editors/space_image/image_ops.c53
-rw-r--r--source/blender/editors/space_view3d/view3d_buttons.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_toolbar.c4
8 files changed, 113 insertions, 108 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 2f054f7a08a..f5e2b45d41e 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -417,7 +417,7 @@ void uiBlockPickerButtons(struct uiBlock *block, float *col, float *hsv, float *
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
*
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 892a126feb6..73425eac0e1 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -1336,20 +1336,14 @@ void ui_get_but_string(uiBut *but, char *str, int maxlen)
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);
@@ -1360,8 +1354,7 @@ static void ui_rna_ID_collection(bContext *C, uiBut *but, PointerRNA *ptr, Prope
}
}
}
-
- RNA_property_collection_end(&iter);
+ RNA_STRUCT_END;
}
/* autocomplete callback for RNA pointers */
@@ -1369,7 +1362,6 @@ static void ui_rna_ID_autocomplete(bContext *C, char *str, void *arg_but)
{
uiBut *but= arg_but;
AutoComplete *autocpl;
- CollectionPropertyIterator iter;
PointerRNA ptr;
PropertyRNA *prop;
char *name;
@@ -1381,11 +1373,10 @@ static void ui_rna_ID_autocomplete(bContext *C, char *str, void *arg_but)
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) {
@@ -1393,8 +1384,8 @@ static void ui_rna_ID_autocomplete(bContext *C, char *str, void *arg_but)
MEM_freeN(name);
}
}
+ RNA_PROP_END;
- RNA_property_collection_end(&iter);
autocomplete_end(autocpl, str);
}
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 4dcf1590a65..dd87ee15474 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -1620,7 +1620,7 @@ void uiTemplateList(uiLayout *layout, PointerRNA *ptr, char *propname, char *act
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);
@@ -1634,13 +1634,13 @@ void uiTemplateList(uiLayout *layout, PointerRNA *ptr, char *propname, char *act
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);
@@ -1650,7 +1650,7 @@ void uiTemplateList(uiLayout *layout, PointerRNA *ptr, char *propname, char *act
i++;
}
- RNA_END;
+ RNA_PROP_END;
while(i < scroll+items) {
if(i >= scroll)
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c
index 69104c87e64..e67e5b5a871 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.c
@@ -142,69 +142,39 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind
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 */
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 6ed8f87d987..bb47d3458fe 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -550,7 +550,24 @@ void file_draw_list(const bContext *C, ARegion *ar)
}
}
-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];
@@ -565,11 +582,6 @@ static void file_draw_fsmenu_category(const bContext *C, ARegion *ar, FSMenuCate
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;
@@ -616,15 +628,54 @@ static void file_draw_fsmenu_category(const bContext *C, ARegion *ar, FSMenuCate
*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);
+ }
}
+
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 537996601b8..8f9bb0d05fe 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -577,34 +577,30 @@ void IMAGE_OT_view_zoom_ratio(wmOperatorType *ot)
/**************** 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)
{
@@ -799,7 +795,9 @@ static int save_as_exec(bContext *C, wmOperator *op)
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;
@@ -820,10 +818,6 @@ static int save_as_invoke(bContext *C, wmOperator *op, wmEvent *event)
/* 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;
@@ -831,14 +825,14 @@ static int save_as_invoke(bContext *C, wmOperator *op, wmEvent *event)
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;
}
@@ -862,6 +856,7 @@ void IMAGE_OT_save_as(wmOperatorType *ot)
/* 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 ********************/
diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c
index ca911876c89..91565235591 100644
--- a/source/blender/editors/space_view3d/view3d_buttons.c
+++ b/source/blender/editors/space_view3d/view3d_buttons.c
@@ -1710,7 +1710,7 @@ static void view3d_panel_operator_redo(const bContext *C, Panel *pa)
}
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)
diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c
index 1e55f2e4a9a..15254ba505e 100644
--- a/source/blender/editors/space_view3d/view3d_toolbar.c
+++ b/source/blender/editors/space_view3d/view3d_toolbar.c
@@ -120,8 +120,6 @@ static void redo_cb(bContext *C, void *arg_op, void *arg2)
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;
@@ -147,7 +145,7 @@ static void view3d_panel_operator_redo(const bContext *C, Panel *pa)
}
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)