diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2015-04-20 18:35:09 +0300 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2015-04-22 15:11:51 +0300 |
commit | e7c2d244c39affb71821f9e81ace9df3c87d2130 (patch) | |
tree | b08766cfde81cb95986f8ecc4401628e27db1d87 /source | |
parent | 62d10cd83324f066a11b4966bd29fc9579e5f76d (diff) |
Placeholder image strips feedback session changes no.1:
Autodetect range of strips.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_add.c | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index ddb9d1196d5..27346ce2bde 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -756,7 +756,7 @@ void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot) static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) { /* cant use the generic function for this */ - + int minframe = INT32_MAX, maxframe = INT32_MIN; Scene *scene = CTX_data_scene(C); /* only for sound */ Editing *ed = BKE_sequencer_editing_get(scene, true); SeqLoadInfo seq_load; @@ -771,7 +771,45 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) /* images are unique in how they handle this - 1 per strip elem */ if (use_placeholders) { - seq_load.len = seq_load.end_frame - seq_load.start_frame; + + RNA_BEGIN (op->ptr, itemptr, "files") + { + char *filename = NULL, *filename_stripped; + int frame; + /* just get the first filename */ + filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0); + + if (filename) { + bool is_numeric; + + filename_stripped = filename; + + /* strip numeric extensions */ + while (*filename_stripped && isdigit(*filename_stripped)) { + filename_stripped++; + } + + is_numeric = (filename_stripped != filename && *filename_stripped == '.'); + + if (is_numeric) { + /* was the number really an extension? */ + *filename_stripped = 0; + frame = atoi(filename); + minframe = min_ii(minframe, frame); + maxframe = max_ii(maxframe, frame); + } + + MEM_freeN(filename); + } + } + RNA_END; + + if (minframe == INT32_MAX) { + minframe = seq_load.start_frame; + maxframe = minframe + 1; + } + + seq_load.len = maxframe - minframe + 1; } else { seq_load.len = RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files")); @@ -815,7 +853,7 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) } for (i = 0; i < seq_load.len; i++, se++) { - BLI_snprintf(se->name, sizeof(se->name), "%04d.%s", seq_load.start_frame + i, filename_stripped); + BLI_snprintf(se->name, sizeof(se->name), "%04d.%s", minframe + i, filename_stripped); } MEM_freeN(filename); |