[Bf-blender-cvs] [468c96c] gooseberry: Load image sequence collapsing for sequencer

Antony Riakiotakis noreply at git.blender.org
Thu Jun 4 12:48:54 CEST 2015


Commit: 468c96c0fa825260a3a964345591ff6a9f7f4410
Author: Antony Riakiotakis
Date:   Wed Jun 3 15:16:10 2015 +0200
Branches: gooseberry
https://developer.blender.org/rB468c96c0fa825260a3a964345591ff6a9f7f4410

Load image sequence collapsing for sequencer

Very dirty feature that will have to be reimplemented when the new asset engine makes it into blender.

This commit tweaks the filebrowser to detect sequences of images that form parts of a movie. The
files need to be in the format <number>filelame.ext or <number>.filename.ext

There is a new option next to hidden file option that makes it so this collapsing takes place.

When collapsing is on, any movie files that have the same filename will be collapsed to the first
detected file in the sequence. Selecting that file will select all files in the sequence.

There is a shortcut in the sequence editor in the Add menu, "Image Sequence" that enables collapsing
by default. Unfortunately, selecting multiple movies will not add multiple sequences to the sequencer,
at least for now, but it should make it quite easier for people to quickly select the whole range of
images for a movie. Importing the image sequence into the sequencer will use placeholders, so any missing images
will display as black.

===================================================================

M	release/scripts/startup/bl_ui/space_filebrowser.py
M	release/scripts/startup/bl_ui/space_sequencer.py
M	source/blender/blenlib/BLI_fileops_types.h
M	source/blender/blenlib/intern/BLI_filelist.c
M	source/blender/editors/space_file/file_ops.c
M	source/blender/editors/space_file/filelist.c
M	source/blender/editors/space_file/filelist.h
M	source/blender/editors/space_file/filesel.c
M	source/blender/editors/space_file/space_file.c
M	source/blender/editors/space_sequencer/sequencer_add.c
M	source/blender/editors/space_sequencer/sequencer_intern.h
M	source/blender/editors/space_sequencer/sequencer_ops.c
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/makesrna/intern/rna_space.c
M	source/blender/windowmanager/WM_api.h
M	source/blender/windowmanager/intern/wm_operators.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_filebrowser.py b/release/scripts/startup/bl_ui/space_filebrowser.py
index 0d900a4..12ea097 100644
--- a/release/scripts/startup/bl_ui/space_filebrowser.py
+++ b/release/scripts/startup/bl_ui/space_filebrowser.py
@@ -60,6 +60,10 @@ class FILEBROWSER_HT_header(Header):
             layout.prop(params, "sort_method", expand=True, text="")
 
             layout.prop(params, "show_hidden", text="", icon='FILE_HIDDEN')
+            if params.collapse_seq:
+                layout.prop(params, "collapse_seq", text="", icon='FULLSCREEN_EXIT')
+            else:
+                layout.prop(params, "collapse_seq", text="", icon='FULLSCREEN_ENTER')
             layout.prop(params, "use_filter", text="", icon='FILTER')
 
             row = layout.row(align=True)
diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py
index 508ed1c..e5fce82 100644
--- a/release/scripts/startup/bl_ui/space_sequencer.py
+++ b/release/scripts/startup/bl_ui/space_sequencer.py
@@ -309,6 +309,7 @@ class SEQUENCER_MT_add(Menu):
             layout.operator_menu_enum("sequencer.mask_strip_add", "mask", text="Mask...")
 
         layout.operator("sequencer.movie_strip_add", text="Movie")
+        layout.operator("sequencer.image_sequence_add", text="Image Sequence")
         layout.operator("sequencer.image_strip_add", text="Image")
         layout.operator("sequencer.sound_strip_add", text="Sound")
 
diff --git a/source/blender/blenlib/BLI_fileops_types.h b/source/blender/blenlib/BLI_fileops_types.h
index 0e6eab6..917f6ff 100644
--- a/source/blender/blenlib/BLI_fileops_types.h
+++ b/source/blender/blenlib/BLI_fileops_types.h
@@ -34,6 +34,7 @@
  */
 
 #include <sys/stat.h>
+#include "BLI_listbase.h"
 
 #if defined(WIN32) && !defined(FREE_WINDOWS)
 typedef unsigned int mode_t;
@@ -69,6 +70,11 @@ 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;
 };
 
 struct dirlink {
diff --git a/source/blender/blenlib/intern/BLI_filelist.c b/source/blender/blenlib/intern/BLI_filelist.c
index e9ed785..1dc308c 100644
--- a/source/blender/blenlib/intern/BLI_filelist.c
+++ b/source/blender/blenlib/intern/BLI_filelist.c
@@ -381,6 +381,9 @@ 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 (filelist != NULL) {
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index f8d13bb..dbda561 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -868,6 +868,23 @@ void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath)
 			for (i = 0; i < numfiles; i++) {
 				if (filelist_is_selected(sfile->files, i, CHECK_FILES)) {
 					struct direntry *file = filelist_file(sfile->files, i);
+
+					if (file->selflag & FILE_SEL_COLLAPSED) {
+						LinkData *link_iter = file->list.first;
+
+						while (link_iter) {
+							LinkData *link_tmp = link_iter->next;
+							struct direntry *file_tmp = link_iter->data;
+							RNA_property_collection_add(op->ptr, prop, &itemptr);
+							RNA_string_set(&itemptr, "name", file_tmp->relname);
+							num_files++;
+							MEM_freeN(link_iter);
+							link_iter = link_tmp;
+						}
+
+						BLI_listbase_clear(&file->list);
+					}
+
 					RNA_property_collection_add(op->ptr, prop, &itemptr);
 					RNA_string_set(&itemptr, "name", file->relname);
 					num_files++;
@@ -1673,9 +1690,11 @@ static int file_rename_exec(bContext *C, wmOperator *UNUSED(op))
 		int numfiles = filelist_numfiles(sfile->files);
 		if ( (0 <= idx) && (idx < numfiles) ) {
 			struct direntry *file = filelist_file(sfile->files, idx);
-			filelist_select_file(sfile->files, idx, FILE_SEL_ADD, FILE_SEL_EDITING, CHECK_ALL);
-			BLI_strncpy(sfile->params->renameedit, file->relname, FILE_MAXFILE);
-			sfile->params->renamefile[0] = '\0';
+			if (!(file->selflag & FILE_SEL_COLLAPSED)) {
+				filelist_select_file(sfile->files, idx, FILE_SEL_ADD, FILE_SEL_EDITING, CHECK_ALL);
+				BLI_strncpy(sfile->params->renameedit, file->relname, FILE_MAXFILE);
+				sfile->params->renamefile[0] = '\0';
+			}
 		}
 		ED_area_tag_redraw(sa);
 	}
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 0f1d041..7edfc32 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -35,6 +35,7 @@
 #include <stdlib.h>
 #include <math.h>
 #include <string.h>
+#include <ctype.h>
 
 #ifndef WIN32
 #  include <unistd.h>
@@ -49,6 +50,7 @@
 #include "BLI_fnmatch.h"
 #include "BLI_linklist.h"
 #include "BLI_utildefines.h"
+#include "BLI_ghash.h"
 
 #ifdef WIN32
 #  include "BLI_winstuff.h"
@@ -208,9 +210,11 @@ typedef struct FileImage {
 typedef struct FileListFilter {
 	bool hide_dot;
 	bool hide_parent;
+	bool collapse_ima_seq;
 	unsigned int filter;
 	char filter_glob[64];
-	char filter_search[66];  /* + 2 for heading/trailing implicit '*' wildcards. */
+	char filter_search[66];   /* + 2 for heading/trailing implicit '*' wildcards. */
+	GHash *unique_image_list; /* hash that stores unique filename */
 } FileListFilter;
 
 typedef struct FileList {
@@ -464,6 +468,46 @@ static bool is_filtered_file(struct direntry *file, const char *UNUSED(root), Fi
 		}
 	}
 
+	if (is_filtered && filter->collapse_ima_seq) {
+		const char *filename, *filename_stripped;
+		filename = file->relname;
+
+		filename_stripped = filename;
+
+		if (filename_stripped) {
+#define MAX_FRA_DIGITS 20
+			int numlen = 0;
+
+			/* strip numeric extensions */
+			while (*filename_stripped && isdigit(*filename_stripped)) {
+				filename_stripped++;
+				numlen++;
+			}
+
+			/* was the number really an extension? */
+			if (*filename_stripped == '.')
+				filename_stripped++;
+			else {
+				filename_stripped = filename;
+			}
+
+			if (numlen > 0 && numlen < MAX_FRA_DIGITS) {
+				struct direntry *ofile;
+
+				if ((ofile = BLI_ghash_lookup(filter->unique_image_list, filename_stripped))) {
+					is_filtered = false;
+					ofile->selflag |= FILE_SEL_COLLAPSED;
+					file->selflag |= FILE_SEL_COLLAPSED;
+					BLI_addhead(&ofile->list, BLI_genericNodeN(file));
+				}
+				else {
+					BLI_ghash_insert(filter->unique_image_list, (void *)filename_stripped, file);
+				}
+			}
+#undef MAX_FRA_DIGITS
+		}
+	}
+
 	return is_filtered;
 }
 
@@ -517,6 +561,11 @@ void filelist_filter(FileList *filelist)
 
 	fidx_tmp = MEM_mallocN(sizeof(*fidx_tmp) * (size_t)filelist->numfiles, __func__);
 
+	/* */
+	if (filelist->filter_data.collapse_ima_seq) {
+		filelist->filter_data.unique_image_list = BLI_ghash_str_new("image_seq_hash");
+	}
+
 	/* Filter remap & count how many files are left after filter in a single loop. */
 	for (i = 0; i < filelist->numfiles; ++i) {
 		struct direntry *file = &filelist->filelist[i];
@@ -526,6 +575,11 @@ void filelist_filter(FileList *filelist)
 		}
 	}
 
+	if (filelist->filter_data.unique_image_list) {
+		BLI_ghash_free(filelist->filter_data.unique_image_list, NULL, NULL);
+		filelist->filter_data.unique_image_list = NULL;
+	}
+
 	/* Note: maybe we could even accept filelist->fidx to be filelist->numfiles -len allocated? */
 	filelist->fidx = MEM_mallocN(sizeof(*filelist->fidx) * (size_t)num_filtered, __func__);
 	memcpy(filelist->fidx, fidx_tmp, sizeof(*filelist->fidx) * (size_t)num_filtered);
@@ -535,17 +589,20 @@ void filelist_filter(FileList *filelist)
 }
 
 void filelist_setfilter_options(FileList *filelist, const bool hide_dot, const bool hide_parent,
+                                const bool collapse_ima_seq,
                                 const unsigned int filter,
                                 const char *filter_glob, const char *filter_search)
 {
 	if ((filelist->filter_data.hide_dot != hide_dot) ||
 	    (filelist->filter_data.hide_parent != hide_parent) ||
+	    (filelist->filter_data.collapse_ima_seq != collapse_ima_seq) ||
 	    (filelist->filter_data.filter != filter) ||
 	    !STREQ(filelist->filter_data.filter_glob, filter_glob) ||
 	    (BLI_strcmp_ignore_pad(filelist->filter_data.filter_search, filter_search, '*') != 0))
 	{
 		filelist->filter_data.hide_dot = hide_dot;
 		filelist->filter_data.hide_parent = hide_parent;
+		filelist->filter_data.collapse_ima_seq = collapse_ima_seq;
 
 		filelist->filter_data.filter = filter;
 		BLI_strncpy(filelist->filter_data.filter_glob, filter_glob, sizeof(filelist->filter_data.filter_glob));
diff --git a/source/blender/editors/space_file/filelist.h b/source/blender/editors/space_file/filelist.h
index 44e0a51..c6c9ed8 100644
--- a/source/blender/editors/space_file/filelist.h
+++ b/source/blender/editors/space_file/filelist.h
@@ -69,6 +69,7 @@ bool                filelist_need_sorting(struct FileList *filelist);
 void                filelist_sort(struct FileList *filelist);
 
 void                filelist_setfilter_options(struct FileList *filelist, const bool hide_dot, const bool hide_parent,
+                                               const bool collapse_ima_seq,
                                                const unsigned int filter,
                                                const char *filter_glob, const char *filter_search);
 void                filelist_filter(struct FileList *filelist);
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index 62b4bfa..d56765f 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -230,6 +230,12 @@ short ED_fileselect_set_params(SpaceFile *sfile)
 			}
 		}
 
+		if (params->filter & FILE_TYPE_IMAGE) {
+			if ((prop = RNA_struct_find_property(op->ptr, "collapse_images"))) {
+				params->flag |= FILE_COLLAPSE_IMAGES;
+			}
+		}
+
 		if (is_relative_path) {
 			if ((p

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list