[Bf-blender-cvs] [12a77b7] gooseberry: Collapsed images:
Antony Riakiotakis
noreply at git.blender.org
Fri Jun 5 14:02:15 CEST 2015
Commit: 12a77b7ac7d200c954e13729af997f92a63d508a
Author: Antony Riakiotakis
Date: Fri Jun 5 13:54:26 2015 +0200
Branches: gooseberry
https://developer.blender.org/rB12a77b7ac7d200c954e13729af997f92a63d508a
Collapsed images:
* Icon of collapsed images is same as a movie
* Size displayed is cummulative size of all images
* Frame range is displayed in the filename
===================================================================
M source/blender/blenlib/BLI_fileops.h
M source/blender/blenlib/BLI_fileops_types.h
M source/blender/blenlib/intern/BLI_filelist.c
M source/blender/blenlib/intern/path_util.c
M source/blender/editors/space_file/file_draw.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.h b/source/blender/blenlib/BLI_fileops.h
index 01aa5d3..642896a 100644
--- a/source/blender/blenlib/BLI_fileops.h
+++ b/source/blender/blenlib/BLI_fileops.h
@@ -106,6 +106,7 @@ int BLI_access(const char *filename, int mode) ATTR_WARN_UNUSED_RESULT ATTR_N
bool BLI_file_is_writable(const char *file) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
bool BLI_file_touch(const char *file) ATTR_NONNULL();
+void BLI_file_size_string(off_t st_size, char *size, size_t len);
#if 0 /* UNUSED */
int BLI_file_gzip(const char *from, const char *to) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
diff --git a/source/blender/blenlib/BLI_fileops_types.h b/source/blender/blenlib/BLI_fileops_types.h
index 917f6ff..73d0c50 100644
--- a/source/blender/blenlib/BLI_fileops_types.h
+++ b/source/blender/blenlib/BLI_fileops_types.h
@@ -75,6 +75,12 @@ struct direntry {
* 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;
};
struct dirlink {
diff --git a/source/blender/blenlib/intern/BLI_filelist.c b/source/blender/blenlib/intern/BLI_filelist.c
index 1dc308c..7d59f05 100644
--- a/source/blender/blenlib/intern/BLI_filelist.c
+++ b/source/blender/blenlib/intern/BLI_filelist.c
@@ -218,7 +218,6 @@ static void bli_adddirstrings(struct BuildDirCtx *dir_ctx)
const char *types[8] = {"---", "--x", "-w-", "-wx", "r--", "r-x", "rw-", "rwx"};
/* symbolic display, indexed by mode field value */
int num;
- off_t st_size;
struct direntry *file;
struct tm *tm;
time_t zero = 0;
@@ -288,20 +287,25 @@ static void bli_adddirstrings(struct BuildDirCtx *dir_ctx)
* will buy us some time until files get bigger than 4GB or until
* everyone starts using __USE_FILE_OFFSET64 or equivalent.
*/
- st_size = file->s.st_size;
+ file->realsize = file->s.st_size;
- if (st_size > 1024 * 1024 * 1024) {
- BLI_snprintf(file->size, sizeof(file->size), "%.2f GiB", ((double)st_size) / (1024 * 1024 * 1024));
- }
- else if (st_size > 1024 * 1024) {
- BLI_snprintf(file->size, sizeof(file->size), "%.1f MiB", ((double)st_size) / (1024 * 1024));
- }
- else if (st_size > 1024) {
- BLI_snprintf(file->size, sizeof(file->size), "%d KiB", (int)(st_size / 1024));
- }
- else {
- BLI_snprintf(file->size, sizeof(file->size), "%d B", (int)st_size);
- }
+ BLI_file_size_string(file->realsize, file->size, sizeof(file->size));
+ }
+}
+
+void BLI_file_size_string(off_t st_size, char *size, size_t len)
+{
+ if (st_size > 1024 * 1024 * 1024) {
+ BLI_snprintf(size, len, "%.2f GiB", ((double)st_size) / (1024 * 1024 * 1024));
+ }
+ else if (st_size > 1024 * 1024) {
+ BLI_snprintf(size, len, "%.1f MiB", ((double)st_size) / (1024 * 1024));
+ }
+ else if (st_size > 1024) {
+ BLI_snprintf(size, len, "%d KiB", (int)(st_size / 1024));
+ }
+ else {
+ BLI_snprintf(size, len, "%d B", (int)st_size);
}
}
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index f9c899a..0f1500e 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -947,17 +947,34 @@ bool BLI_path_frame_strip(char *path, bool setsharp, char *ext)
c++;
if(numdigits) {
- /* replace the number with the suffix and terminate the string */
- while (numdigits--) {
- if (ext) *ext++ = *suffix;
-
- if (setsharp) *c++ = '#';
- else *c++ = *suffix;
+ /* logic here is a bit complex. Idea is: if ext has been provided,
+ * fill it with the extension part and do not keep it in filename
+ * if no ext has been provided, just strip the number or fill it with #
+ */
+ if (ext) {
+ while (*suffix) {
+ *ext++ = *suffix++;
+ }
+ *ext = 0;
- suffix++;
+ if (setsharp) {
+ while (numdigits--) {
+ *c++ = '#';
+ }
+ }
+ *c = 0;
+ }
+ else {
+ if (setsharp) {
+ while (numdigits--) {
+ *c++ = '#';
+ }
+ }
+ while (*suffix) {
+ *c++ = *suffix++;
+ }
+ *c = 0;
}
- *c = 0;
- if (ext) *ext = 0;
return true;
}
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 0e4d885..879e372 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -254,8 +254,13 @@ static int get_file_icon(struct direntry *file)
return ICON_FILE_BLEND;
else if (file->flags & FILE_TYPE_BLENDER_BACKUP)
return ICON_FILE_BACKUP;
- else if (file->flags & FILE_TYPE_IMAGE)
- return ICON_FILE_IMAGE;
+ else if (file->flags & FILE_TYPE_IMAGE) {
+ if (file->selflag & FILE_SEL_COLLAPSED) {
+ return ICON_FILE_MOVIE;
+ }
+ else
+ return ICON_FILE_IMAGE;
+ }
else if (file->flags & FILE_TYPE_MOVIE)
return ICON_FILE_MOVIE;
else if (file->flags & FILE_TYPE_PYSCRIPT)
@@ -605,43 +610,68 @@ void file_draw_list(const bContext *C, ARegion *ar)
if (!(file->selflag & FILE_SEL_EDITING)) {
int tpos = (FILE_IMGDISPLAY == params->display) ? sy - layout->tile_h + layout->textheight : sy;
- file_draw_string(sx + 1, tpos, file->relname, (float)textwidth, textheight, align);
+ if (file->selflag & FILE_SEL_COLLAPSED) {
+ char fname[PATH_MAX];
+ char finalname[PATH_MAX];
+ char ext[PATH_MAX];
+ 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);
+ file_draw_string(sx + 1, tpos, finalname, (float)textwidth, textheight, align);
+ }
+ else
+ file_draw_string(sx + 1, tpos, file->relname, (float)textwidth, textheight, align);
}
if (params->display == FILE_SHORTDISPLAY) {
sx += (int)layout->column_widths[COLUMN_NAME] + column_space;
if (!(file->type & S_IFDIR)) {
- file_draw_string(sx, sy, file->size, layout->column_widths[COLUMN_SIZE], layout->tile_h, align);
+ if (file->selflag & FILE_SEL_COLLAPSED) {
+ char sizestr[16];
+ BLI_file_size_string(file->collapsedsize, sizestr, sizeof(sizestr));
+ file_draw_string(sx, sy, sizestr, layout->column_widths[COLUMN_SIZE], layout->tile_h, align);
+ }
+ else
+ file_draw_string(sx, sy, file->size, layout->column_widths[COLUMN_SIZE], layout->tile_h, align);
sx += (int)layout->column_widths[COLUMN_SIZE] + column_space;
}
}
else if (params->display == FILE_LONGDISPLAY) {
sx += (int)layout->column_widths[COLUMN_NAME] + column_space;
+ /* 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));
+ file_draw_string(sx, sy, sizestr, layout->column_widths[COLUMN_SIZE], layout->tile_h, align);
+ }
+ else {
#ifndef WIN32
- /* rwx rwx rwx */
- file_draw_string(sx, sy, file->mode1, layout->column_widths[COLUMN_MODE1], layout->tile_h, align);
- sx += layout->column_widths[COLUMN_MODE1] + column_space;
+ /* rwx rwx rwx */
+ file_draw_string(sx, sy, file->mode1, layout->column_widths[COLUMN_MODE1], layout->tile_h, align);
+ sx += layout->column_widths[COLUMN_MODE1] + column_space;
- file_draw_string(sx, sy, file->mode2, layout->column_widths[COLUMN_MODE2], layout->tile_h, align);
- sx += layout->column_widths[COLUMN_MODE2] + column_space;
+ file_draw_string(sx, sy, file->mode2, layout->column_widths[COLUMN_MODE2], layout->tile_h, align);
+ sx += layout->column_widths[COLUMN_MODE2] + column_space;
- file_draw_string(sx, sy, file->mode3, layout->column_widths[COLUMN_MODE3], layout->tile_h, align);
- sx += layout->column_widths[COLUMN_MODE3] + column_space;
+ file_draw_string(sx, sy, file->mode3, layout->column_widths[COLUMN_MODE3], layout->tile_h, align);
+ sx += layout->column_widths[COLUMN_MODE3] + column_space;
- file_draw_string(sx, sy, file->owner, layout->column_widths[COLUMN_OWNER], layout->tile_h, align);
- sx += layout->column_widths[COLUMN_OWNER] + column_space;
+ file_draw_string(sx, sy, file->owner, layout->column_widths[COLUMN_OWNER], layout->tile_h, align);
+ sx += layout->column_widths[COLUMN_OWNER] + column_space;
#endif
- file_draw_string(sx, sy, file->date, layout->column_widths[COLUMN_DATE], layout->tile_h, align);
- sx += (int)layout->column_widths[COLUMN_DATE] + column_space;
+ file_draw_string(sx, sy, file->date, layout->column_widths[COLUMN_DATE], layout->tile_h, align);
+ sx += (int)layout->column_widths[COLUMN_DATE] + column_space;
- file_draw_string(sx, sy, file->time, layout->column_widths[COLUMN_TIME], layout->tile_h, align);
- sx += (int)layout->column_widths[COLUMN_TIME] + column_space;
+ file_draw_string(sx, sy, file->time, layout->column_widths[COLUMN_TIME], layout->tile_h, align);
+ sx += (int)layout->column_widths[COLUMN_TIME] + column_space;
- if (!(file->type & S_IFDIR)) {
- file_draw_string(sx, sy, file->size, layout->column_widths[COLUMN_SIZE], layout->tile_h, align);
- sx += (int)layout->column_widths[COLUMN_SIZE] + column_space;
+ if (!(file->type & S_IFDIR)) {
+ file_draw_string(sx, sy, file->size, layout->column_widths[COLUMN_SIZE], layout->tile_h, align);
+ sx += (int)layout->column_widths[COLUMN_SIZE] + column_space;
+ }
}
}
}
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index a0213f0..0df9aa0 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -469,22 +469,32 @@ static bool is_filtered_file(struct direntry *file, const char *UNUSED(root), Fi
}
if (is_filtered && filter->collapse_ima_seq) {
- char filename[PATH_MAX];
-
if (file->relname) {
struct direntry *ofile;
- BLI_strncpy(filename, file->relname, sizeof(filename));
+ int frame, numdigits;
+
+ if (BLI_path_frame_get(file->relname, &frame, &numdigits)) {
+ char filename[PATH_MAX];
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list