UI Experiment: Image Sequence Collapse #119193

Open
Harley Acheson wants to merge 1 commits from Harley/blender:SequenceCollapse into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
1 changed files with 135 additions and 65 deletions

View File

@ -101,6 +101,9 @@ struct FileListInternEntry {
const char *name;
bool free_name;
int sequence_start;
int sequence_end;
/**
* This is data from the current main, represented by this file. It's crucial that this is
* updated correctly on undo, redo and file reading (without UI). The space is responsible to
@ -686,6 +689,11 @@ static bool is_filtered_hidden(const char *filename,
return true;
}
/* Let's just reuse this filter setting for image sequences for now. */
if ((filter->flags & FLF_HIDE_DOT) && file->sequence_start && !file->sequence_end) {
return true;
}
return false;
}
@ -2103,7 +2111,27 @@ static FileDirEntry *filelist_file_create_entry(FileList *filelist, const int in
ret->relpath = BLI_strdup(entry->relpath);
if (entry->free_name) {
if ((filelist->filter_data.flags & FLF_HIDE_DOT) && entry->typeflag & FILE_TYPE_IMAGE &&
entry->sequence_start && entry->sequence_end &&
(entry->sequence_start != entry->sequence_end))
{
char head[FILE_MAX], tail[FILE_MAX];
ushort digits;
int num = BLI_path_sequence_decode(
entry->relpath, head, sizeof(head), tail, sizeof(tail), &digits);
ret->name = BLI_sprintfN("%s%.*s%s (%0*i-%0*i)",
head,
digits,
"####################",
tail,
digits,
entry->sequence_start,
digits,
entry->sequence_end);
}
else {
ret->name = BLI_strdup(entry->name);
}
ret->flags |= FILE_ENTRY_NAME_FREE;
}
else {
@ -3060,11 +3088,20 @@ static int filelist_readjob_list_dir(FileListReadJob *job_params,
/* Full path of the item. */
char full_path[FILE_MAX];
FileListInternEntry *entry = nullptr;
/* Used to find image sequences. */
FileListInternEntry *image_sequence_start = nullptr;
char seq_head[FILE_MAX] = {0};
char seq_tail[FILE_MAX] = {0};
ushort seq_digits;
const int files_num = BLI_filelist_dir_contents(root, &files);
if (files) {
int i = files_num;
while (i--) {
FileListInternEntry *entry;
for (int i = 0; i < files_num; i++) {
if (skip_currpar && FILENAME_IS_CURRPAR(files[i].relname)) {
continue;
}
if (skip_currpar && FILENAME_IS_CURRPAR(files[i].relname)) {
continue;
@ -3126,6 +3163,37 @@ static int filelist_readjob_list_dir(FileListReadJob *job_params,
if (filter_glob[0] && BLI_path_extension_check_glob(target, filter_glob)) {
entry->typeflag |= FILE_TYPE_OPERATOR;
}
if (entry->typeflag & FILE_TYPE_IMAGE) {
char head[FILE_MAX], tail[FILE_MAX];
ushort digits;
int num = BLI_path_sequence_decode(
entry->relpath, head, sizeof(head), tail, sizeof(tail), &digits);
if (num) {
entry->sequence_start = num;
if (image_sequence_start && (num == image_sequence_start->sequence_end + 1) &&
(digits == seq_digits) && (STREQLEN(head, seq_head, sizeof(head))) &&
(STREQLEN(tail, seq_tail, sizeof(tail))))
{
/* This is a child member of an image sequence. */
entry->sequence_end = 0;
/* Mark the parent as valid. */
image_sequence_start->sequence_end++;
}
else {
/* This one might be the start if valid children follow. */
image_sequence_start = entry;
image_sequence_start->sequence_end = num;
seq_digits = digits;
STRNCPY(seq_head, head);
STRNCPY(seq_tail, tail);
}
}
else {
image_sequence_start = nullptr;
}
}
}
}
@ -3139,6 +3207,8 @@ static int filelist_readjob_list_dir(FileListReadJob *job_params,
BLI_addtail(entries, entry);
entries_num++;
}
if (files) {
BLI_filelist_free(files, files_num);
}
return entries_num;