UI: use enum for thumbnail size

This commit is contained in:
Campbell Barton 2015-05-01 01:49:58 +10:00
parent 5ced6cb2bc
commit 4d6584ba6a
5 changed files with 19 additions and 10 deletions

@ -55,7 +55,7 @@ class FILEBROWSER_HT_header(Header):
layout.prop(params, "display_type", expand=True, text="")
if params.display_type == 'FILE_IMGDISPLAY':
layout.prop(params, "thumbnails_size")
layout.prop(params, "thumbnail_size", text="")
layout.prop(params, "sort_method", expand=True, text="")

@ -803,7 +803,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
if (!MAIN_VERSION_ATLEAST(main, 274, 6)) {
bScreen *screen;
if (!DNA_struct_elem_find(fd->filesdna, "FileSelectParams", "int", "thumbnails_size")) {
if (!DNA_struct_elem_find(fd->filesdna, "FileSelectParams", "int", "thumbnail_size")) {
for (screen = main->screen.first; screen; screen = screen->id.next) {
ScrArea *sa;
@ -815,7 +815,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
SpaceFile *sfile = (SpaceFile *)sl;
if (sfile->params) {
sfile->params->thumbnails_size = 128;
sfile->params->thumbnail_size = 128;
}
}
}

@ -103,7 +103,7 @@ short ED_fileselect_set_params(SpaceFile *sfile)
BLI_split_dirfile(G.main->name, sfile->params->dir, sfile->params->file, sizeof(sfile->params->dir), sizeof(sfile->params->file));
sfile->params->filter_glob[0] = '\0';
/* set the default thumbnails size */
sfile->params->thumbnails_size = 128;
sfile->params->thumbnail_size = 128;
}
params = sfile->params;
@ -529,8 +529,8 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *ar)
layout->textheight = textheight;
if (params->display == FILE_IMGDISPLAY) {
layout->prv_w = ((float)params->thumbnails_size / 20.0f) * UI_UNIT_X;
layout->prv_h = ((float)params->thumbnails_size / 20.0f) * UI_UNIT_Y;
layout->prv_w = ((float)params->thumbnail_size / 20.0f) * UI_UNIT_X;
layout->prv_h = ((float)params->thumbnail_size / 20.0f) * UI_UNIT_Y;
layout->tile_border_x = 0.3f * UI_UNIT_X;
layout->tile_border_y = 0.3f * UI_UNIT_X;
layout->prv_border_x = 0.3f * UI_UNIT_X;

@ -590,7 +590,8 @@ typedef struct FileSelectParams {
int active_file;
int sel_first;
int sel_last;
int thumbnails_size;
unsigned short thumbnail_size;
short pad;
/* short */
short type; /* XXXXX for now store type here, should be moved to the operator */

@ -3698,6 +3698,14 @@ static void rna_def_fileselect_params(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}
};
static EnumPropertyItem thumbnail_size_items[] = {
{32, "TINY", 0, "Tiny", ""},
{64, "SMALL", 0, "Small", ""},
{128, "NORMAL", 0, "Normal", ""},
{256, "LARGE", 0, "Large", ""},
{0, NULL, 0, NULL, NULL}
};
srna = RNA_def_struct(brna, "FileSelectParams", NULL);
RNA_def_struct_ui_text(srna, "File Select Parameters", "File Select Parameters");
@ -3803,9 +3811,9 @@ static void rna_def_fileselect_params(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_TEXTEDIT_UPDATE);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
prop = RNA_def_property(srna, "thumbnails_size", PROP_INT, PROP_PIXEL);
RNA_def_property_int_sdna(prop, NULL, "thumbnails_size");
RNA_def_property_range(prop, 32, 256);
prop = RNA_def_property(srna, "thumbnail_size", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "thumbnail_size");
RNA_def_property_enum_items(prop, thumbnail_size_items);
RNA_def_property_ui_text(prop, "Thumbnails Size", "Change the size of the thumbnails");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
}