[Bf-blender-cvs] [a5f6fcd] gooseberry: Refactor: move all collapsed image variables into a struct.
Antony Riakiotakis
noreply at git.blender.org
Mon Jun 8 14:34:41 CEST 2015
Commit: a5f6fcde2e401a9f0c5e8001f34433751624a86e
Author: Antony Riakiotakis
Date: Mon Jun 8 14:34:10 2015 +0200
Branches: gooseberry
https://developer.blender.org/rBa5f6fcde2e401a9f0c5e8001f34433751624a86e
Refactor: move all collapsed image variables into a struct.
===================================================================
M source/blender/blenlib/BLI_fileops_types.h
M source/blender/blenlib/intern/BLI_filelist.c
M source/blender/editors/space_file/file_draw.c
M source/blender/editors/space_file/file_ops.c
M source/blender/editors/space_file/filelist.c
M source/blender/editors/space_file/filesel.c
===================================================================
diff --git a/source/blender/blenlib/BLI_fileops_types.h b/source/blender/blenlib/BLI_fileops_types.h
index 73d0c50..de834c5 100644
--- a/source/blender/blenlib/BLI_fileops_types.h
+++ b/source/blender/blenlib/BLI_fileops_types.h
@@ -42,6 +42,17 @@ typedef unsigned int mode_t;
struct ImBuf;
+typedef struct CollapsedEntry {
+ /* list that gets populated during file open */
+ ListBase list;
+ /* sorted array of the files for quick access of frames */
+ struct direntry *darray;
+ off_t totalsize;
+ int minframe;
+ int maxframe;
+ int numdigits;
+} CollapsedEntry;
+
struct direntry {
mode_t type;
char *relname;
@@ -70,17 +81,9 @@ struct direntry {
int nr;
struct ImBuf *image;
unsigned int selflag; /* selection flag */
-
- /* ultra dirty temporary ugliness, store the container for the image sequence here.
- * ideally we should store this to a struct in a customdata pointer.
- * Maybe poin can be used instead */
- ListBase list;
- /* it sucks to store this as well but it's needed */
off_t realsize;
- off_t collapsedsize;
- int minframe;
- int maxframe;
- int numdigits;
+
+ CollapsedEntry collapsed_info;
};
struct dirlink {
diff --git a/source/blender/blenlib/intern/BLI_filelist.c b/source/blender/blenlib/intern/BLI_filelist.c
index 7d59f05..b5a0a01 100644
--- a/source/blender/blenlib/intern/BLI_filelist.c
+++ b/source/blender/blenlib/intern/BLI_filelist.c
@@ -385,8 +385,8 @@ void BLI_filelist_free(struct direntry *filelist, unsigned int nrentries, void (
MEM_freeN(entry->path);
if (entry->poin && free_poin)
free_poin(entry->poin);
- if (entry->list.first) {
- BLI_freelistN(&entry->list);
+ if (entry->collapsed_info.list.first) {
+ BLI_freelistN(&entry->collapsed_info.list);
}
}
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 879e372..cbbd1cf 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -614,10 +614,11 @@ void file_draw_list(const bContext *C, ARegion *ar)
char fname[PATH_MAX];
char finalname[PATH_MAX];
char ext[PATH_MAX];
+ CollapsedEntry *collapsed = &file->collapsed_info;
BLI_strncpy(fname, file->relname, sizeof(fname));
BLI_path_frame_strip(fname, false, ext);
BLI_snprintf(finalname, sizeof(finalname), "%s%.*d-%.*d%s",
- fname, file->numdigits, file->minframe, file->numdigits, file->maxframe, ext);
+ fname, collapsed->numdigits, collapsed->minframe, collapsed->numdigits, collapsed->maxframe, ext);
file_draw_string(sx + 1, tpos, finalname, (float)textwidth, textheight, align);
}
else
@@ -628,8 +629,9 @@ void file_draw_list(const bContext *C, ARegion *ar)
sx += (int)layout->column_widths[COLUMN_NAME] + column_space;
if (!(file->type & S_IFDIR)) {
if (file->selflag & FILE_SEL_COLLAPSED) {
+ CollapsedEntry *collapsed = &file->collapsed_info;
char sizestr[16];
- BLI_file_size_string(file->collapsedsize, sizestr, sizeof(sizestr));
+ BLI_file_size_string(collapsed->totalsize, sizestr, sizeof(sizestr));
file_draw_string(sx, sy, sizestr, layout->column_widths[COLUMN_SIZE], layout->tile_h, align);
}
else
@@ -643,7 +645,8 @@ void file_draw_list(const bContext *C, ARegion *ar)
/* for collapsed files it doesn't make sense to display all info */
if (file->selflag & FILE_SEL_COLLAPSED) {
char sizestr[16];
- BLI_file_size_string(file->collapsedsize, sizestr, sizeof(sizestr));
+ CollapsedEntry *collapsed = &file->collapsed_info;
+ BLI_file_size_string(collapsed->totalsize, sizestr, sizeof(sizestr));
file_draw_string(sx, sy, sizestr, layout->column_widths[COLUMN_SIZE], layout->tile_h, align);
}
else {
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 656ce60..6da20e0 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -870,7 +870,8 @@ void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath)
struct direntry *file = filelist_file(sfile->files, i);
if (file->selflag & FILE_SEL_COLLAPSED) {
- LinkData *link_iter = file->list.first;
+ CollapsedEntry *collapsed = &file->collapsed_info;
+ LinkData *link_iter = collapsed->list.first;
while (link_iter) {
LinkData *link_tmp = link_iter->next;
@@ -882,7 +883,7 @@ void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath)
link_iter = link_tmp;
}
- BLI_listbase_clear(&file->list);
+ BLI_listbase_clear(&collapsed->list);
}
RNA_property_collection_add(op->ptr, prop, &itemptr);
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index b208536..9d241f6 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -480,21 +480,22 @@ static bool is_filtered_file(struct direntry *file, const char *UNUSED(root), Fi
BLI_path_frame_strip(filename, false, NULL);
if ((ofile = BLI_ghash_lookup(filter->unique_image_list, filename)) &&
- numdigits == ofile->numdigits)
+ numdigits == ofile->collapsed_info.numdigits)
{
+ CollapsedEntry *collapsed = &ofile->collapsed_info;
is_filtered = false;
ofile->selflag |= FILE_SEL_COLLAPSED;
file->selflag |= FILE_SEL_COLLAPSED;
- BLI_addhead(&ofile->list, BLI_genericNodeN(file));
- ofile->collapsedsize += file->realsize;
- ofile->maxframe = MAX2(frame, ofile->maxframe);
- ofile->minframe = MIN2(frame, ofile->minframe);
+ BLI_addhead(&collapsed->list, BLI_genericNodeN(file));
+ collapsed->totalsize += file->realsize;
+ collapsed->maxframe = MAX2(frame, collapsed->maxframe);
+ collapsed->minframe = MIN2(frame, collapsed->minframe);
}
else {
BLI_ghash_insert(filter->unique_image_list, BLI_strdup(filename), file);
- file->collapsedsize = file->realsize;
- file->maxframe = file->minframe = frame;
- file->numdigits = numdigits;
+ file->collapsed_info.totalsize = file->realsize;
+ file->collapsed_info.maxframe = file->collapsed_info.minframe = frame;
+ file->collapsed_info.numdigits = numdigits;
}
}
}
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index 0fd853b..6778daa 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -456,10 +456,11 @@ static void column_widths(struct FileList *files, struct FileLayout *layout)
char fname[PATH_MAX];
char finalname[PATH_MAX];
char ext[PATH_MAX];
+ CollapsedEntry *collapsed = &file->collapsed_info;
BLI_strncpy(fname, file->relname, sizeof(fname));
BLI_path_frame_strip(fname, false, ext);
BLI_snprintf(finalname, sizeof(finalname), "%s%.*d-%.*d%s",
- fname, file->numdigits, file->minframe, file->numdigits, file->maxframe, ext);
+ fname, collapsed->numdigits, collapsed->minframe, collapsed->numdigits, collapsed->maxframe, ext);
len = file_string_width(finalname);
}
else {
More information about the Bf-blender-cvs
mailing list