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:
authorCampbell Barton <ideasman42@gmail.com>2012-06-06 10:01:51 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-06-06 10:01:51 +0400
commit2be904b62687bb8ae9316f1bae678c4d66f10c15 (patch)
tree06c309bc2f7462c455dece56379abd0672460c2e /source/blender/makesrna/intern/rna_sequencer_api.c
parenteedaaee072f7b21f9a1e2d4ed463000b2aacb620 (diff)
support negative indexing with SequenceElements.pop() - like python does, -1 is default.
Diffstat (limited to 'source/blender/makesrna/intern/rna_sequencer_api.c')
-rw-r--r--source/blender/makesrna/intern/rna_sequencer_api.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/rna_sequencer_api.c b/source/blender/makesrna/intern/rna_sequencer_api.c
index bdbd153b1e2..2fb882d96a1 100644
--- a/source/blender/makesrna/intern/rna_sequencer_api.c
+++ b/source/blender/makesrna/intern/rna_sequencer_api.c
@@ -327,7 +327,12 @@ static void rna_SequenceElements_pop(ID *id, Sequence *seq, ReportList *reports,
return;
}
- if (seq->len <= index) {
+ /* python style negative indexing */
+ if (index < 0) {
+ index += seq->len;
+ }
+
+ if (seq->len <= index || index < 0) {
BKE_report(reports, RPT_ERROR, "SequenceElements.pop: index out of range");
return;
}
@@ -335,6 +340,7 @@ static void rna_SequenceElements_pop(ID *id, Sequence *seq, ReportList *reports,
new_seq = MEM_callocN(sizeof(StripElem) * (seq->len - 1), "SequenceElements_pop");
seq->len--;
+ /* TODO - simply use 2 memcpy calls */
for (i = 0, se = seq->strip->stripdata; i < seq->len; i++, se++) {
if (i == index)
se++;
@@ -394,7 +400,7 @@ void RNA_api_sequence_elements(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "pop", "rna_SequenceElements_pop");
RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
RNA_def_function_ui_description(func, "Pop an image off the collection");
- parm = RNA_def_int(func, "index", 0, 0, INT_MAX, "", "Index of image to remove", 0, INT_MAX);
+ parm = RNA_def_int(func, "index", -1, INT_MIN, INT_MAX, "", "Index of image to remove", INT_MIN, INT_MAX);
RNA_def_property_flag(parm, PROP_REQUIRED);
}