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
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')
-rw-r--r--source/blender/editors/space_sequencer/sequencer_add.c160
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c31
-rw-r--r--source/blender/editors/space_sequencer/sequencer_intern.h6
3 files changed, 116 insertions, 81 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")
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 138d9b943fc..39023f5c0a3 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -3694,12 +3694,21 @@ static int sequencer_change_path_exec(bContext *C, wmOperator *op)
Editing *ed = BKE_sequencer_editing_get(scene, false);
Sequence *seq = BKE_sequencer_active_get(scene);
const bool is_relative_path = RNA_boolean_get(op->ptr, "relative_path");
+ const bool use_placeholders = RNA_boolean_get(op->ptr, "use_placeholders");
+ int minframe;
if (seq->type == SEQ_TYPE_IMAGE) {
char directory[FILE_MAX];
- const int len = RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files"));
+ int len;
StripElem *se;
+ /* need to find min/max frame for placeholders */
+ if (use_placeholders) {
+ len = sequencer_image_seq_get_minmax_frame(op, seq->sfra, &minframe);
+ }
+ else {
+ len = RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files"));
+ }
if (len == 0)
return OPERATOR_CANCELLED;
@@ -3717,14 +3726,19 @@ static int sequencer_change_path_exec(bContext *C, wmOperator *op)
}
seq->strip->stripdata = se = MEM_callocN(len * sizeof(StripElem), "stripelem");
- RNA_BEGIN (op->ptr, itemptr, "files")
- {
- char *filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0);
- BLI_strncpy(se->name, filename, sizeof(se->name));
- MEM_freeN(filename);
- se++;
+ if (use_placeholders) {
+ sequencer_image_seq_reserve_frames(op, se, len, minframe);
+ }
+ else {
+ RNA_BEGIN (op->ptr, itemptr, "files")
+ {
+ char *filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0);
+ BLI_strncpy(se->name, filename, sizeof(se->name));
+ MEM_freeN(filename);
+ se++;
+ }
+ RNA_END;
}
- RNA_END;
/* reset these else we wont see all the images */
seq->anim_startofs = seq->anim_endofs = 0;
@@ -3799,4 +3813,5 @@ void SEQUENCER_OT_change_path(struct wmOperatorType *ot)
WM_operator_properties_filesel(ot, FILE_TYPE_FOLDER | FILE_TYPE_IMAGE | FILE_TYPE_MOVIE, FILE_SPECIAL, FILE_OPENFILE,
WM_FILESEL_DIRECTORY | WM_FILESEL_RELPATH | WM_FILESEL_FILEPATH | WM_FILESEL_FILES,
FILE_DEFAULTDISPLAY);
+ RNA_def_boolean(ot->srna, "use_placeholders", false, "Use Placeholders", "Use placeholders for missing frames of the strip");
}
diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h
index 78255507321..0158a2d4872 100644
--- a/source/blender/editors/space_sequencer/sequencer_intern.h
+++ b/source/blender/editors/space_sequencer/sequencer_intern.h
@@ -45,6 +45,8 @@ struct ARegion;
struct ARegionType;
struct Scene;
struct Main;
+struct wmOperator;
+struct StripElem;
/* space_sequencer.c */
struct ARegion *sequencer_has_buttons_region(struct ScrArea *sa);
@@ -202,5 +204,9 @@ void SEQUENCER_OT_sample(struct wmOperatorType *ot);
/* sequencer_preview.c */
void sequencer_preview_add_sound(const struct bContext *C, struct Sequence *seq);
+/* sequencer_add */
+int sequencer_image_seq_get_minmax_frame(struct wmOperator *op, int sfra, int *r_minframe);
+void sequencer_image_seq_reserve_frames(struct wmOperator *op, struct StripElem *se, int len, int minframe);
+
#endif /* __SEQUENCER_INTERN_H__ */