Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2015-04-20 19:07:34 +0300
committerAntony Riakiotakis <kalast@gmail.com>2015-04-22 15:11:51 +0300
commitd354eeab7460ba76f92f3dcce3eea069010635b3 (patch)
treebddd9d355b15f9918b8d8921d9a21b53010e85b1 /source/blender/editors/space_sequencer/sequencer_add.c
parente7c2d244c39affb71821f9e81ace9df3c87d2130 (diff)
Placeholder image strips feedback session changes no.2:
Change paths operator can also have the same placeholder logic now
Diffstat (limited to 'source/blender/editors/space_sequencer/sequencer_add.c')
-rw-r--r--source/blender/editors/space_sequencer/sequencer_add.c160
1 files changed, 87 insertions, 73 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c
index 27346ce2bde..f4b1afba6c4 100644
--- a/source/blender/editors/space_sequencer/sequencer_add.c
+++ b/source/blender/editors/space_sequencer/sequencer_add.c
@@ -752,64 +752,108 @@ void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot)
RNA_def_boolean(ot->srna, "cache", false, "Cache", "Cache the sound in memory");
}
-/* add image operator */
-static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op)
+int sequencer_image_seq_get_minmax_frame(wmOperator *op, int sfra, int *r_minframe)
{
- /* 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;
- Sequence *seq;
- Strip *strip;
- StripElem *se;
- int i;
- bool use_placeholders = RNA_boolean_get(op->ptr, "use_placeholders");
+ 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);
- seq_load_operator_info(&seq_load, op);
+ if (filename) {
+ bool is_numeric;
- /* images are unique in how they handle this - 1 per strip elem */
- if (use_placeholders) {
+ filename_stripped = filename;
- 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);
+ /* strip numeric extensions */
+ while (*filename_stripped && isdigit(*filename_stripped)) {
+ filename_stripped++;
+ }
- if (filename) {
- bool is_numeric;
+ is_numeric = (filename_stripped != filename && *filename_stripped == '.');
- filename_stripped = filename;
+ 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);
+ }
- /* strip numeric extensions */
- while (*filename_stripped && isdigit(*filename_stripped)) {
- filename_stripped++;
- }
+ MEM_freeN(filename);
+ }
+ }
+ RNA_END;
- is_numeric = (filename_stripped != filename && *filename_stripped == '.');
+ if (minframe == INT32_MAX) {
+ minframe = sfra;
+ maxframe = minframe + 1;
+ }
- 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);
- }
+ *r_minframe = minframe;
- MEM_freeN(filename);
- }
+ return maxframe - minframe + 1;
+}
+
+void sequencer_image_seq_reserve_frames(wmOperator *op, StripElem *se, int len, int minframe)
+{
+ int i;
+ char *filename = NULL, *filename_stripped;
+ RNA_BEGIN (op->ptr, itemptr, "files")
+ {
+ /* just get the first filename */
+ filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0);
+ break;
+ }
+ RNA_END;
+
+ filename_stripped = filename;
+
+ if (filename_stripped) {
+
+ /* strip numeric extensions */
+ while (*filename_stripped && isdigit(*filename_stripped)) {
+ filename_stripped++;
+ }
+
+ /* was the number really an extension? */
+ if (*filename_stripped == '.')
+ filename_stripped++;
+ else {
+ filename_stripped = filename;
}
- RNA_END;
- if (minframe == INT32_MAX) {
- minframe = seq_load.start_frame;
- maxframe = minframe + 1;
+ for (i = 0; i < len; i++, se++) {
+ BLI_snprintf(se->name, sizeof(se->name), "%04d.%s", minframe + i, filename_stripped);
}
- seq_load.len = maxframe - minframe + 1;
+ MEM_freeN(filename);
+ }
+}
+
+
+/* add image operator */
+static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op)
+{
+ int minframe;
+ /* cant use the generic function for this */
+ Scene *scene = CTX_data_scene(C); /* only for sound */
+ Editing *ed = BKE_sequencer_editing_get(scene, true);
+ SeqLoadInfo seq_load;
+ Sequence *seq;
+
+ Strip *strip;
+ StripElem *se;
+ const bool use_placeholders = RNA_boolean_get(op->ptr, "use_placeholders");
+
+ seq_load_operator_info(&seq_load, op);
+
+ /* images are unique in how they handle this - 1 per strip elem */
+ if (use_placeholders) {
+ seq_load.len = sequencer_image_seq_get_minmax_frame(op, seq_load.start_frame, &minframe);
}
else {
seq_load.len = RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files"));
@@ -827,37 +871,7 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op)
se = strip->stripdata;
if (use_placeholders) {
- char *filename = NULL, *filename_stripped;
- RNA_BEGIN (op->ptr, itemptr, "files")
- {
- /* just get the first filename */
- filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0);
- break;
- }
- RNA_END;
-
- filename_stripped = filename;
-
- if (filename_stripped) {
-
- /* strip numeric extensions */
- while (*filename_stripped && isdigit(*filename_stripped)) {
- filename_stripped++;
- }
-
- /* was the number really an extension? */
- if (*filename_stripped == '.')
- filename_stripped++;
- else {
- filename_stripped = filename;
- }
-
- for (i = 0; i < seq_load.len; i++, se++) {
- BLI_snprintf(se->name, sizeof(se->name), "%04d.%s", minframe + i, filename_stripped);
- }
-
- MEM_freeN(filename);
- }
+ sequencer_image_seq_reserve_frames(op, se, seq_load.len, minframe);
}
else {
RNA_BEGIN (op->ptr, itemptr, "files")