diff options
author | Campbell Barton <ideasman42@gmail.com> | 2008-07-07 08:17:03 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2008-07-07 08:17:03 +0400 |
commit | 17dc66c1d1e9ac276e7e5bc772d23caf83e7a2d2 (patch) | |
tree | e901c3a752c52b41209645ceb4f771eac5fbd4ec | |
parent | 0456a71eddb53a60ffe127c4d6870ce46374264c (diff) |
[#17288] Sequencer API: added a method, a geter/setter, the blend modes dict and corrected a malfunction on audio strips blend mode
from Luca Bonavita (mindrones)
- adds the method "rebuildProxy()" useful to rebuild all the strips at once: the user can do
- adds a BlendModes dictionary under the Blender.Scene.Sequence module: the user can see the blending option with
- adds the getter/setter "blendMode"
- adds a function seq_can_blend in sequence.c as requested by Peter, useful for these purposes but also to solve a bug
after
- the bug is you can apply blend modes to an audio strip that doesn't make sense: changed the test and now you cannot
assign blend mode other than Replace to audio strips
Omitted DNA cleanup part since its only whitespace and Id prefer to have a useful "svn blame" output.
-rw-r--r-- | source/blender/include/BSE_sequence.h | 2 | ||||
-rw-r--r-- | source/blender/python/api2_2x/sceneSequence.c | 74 | ||||
-rw-r--r-- | source/blender/src/buttons_scene.c | 2 | ||||
-rw-r--r-- | source/blender/src/sequence.c | 10 |
4 files changed, 84 insertions, 4 deletions
diff --git a/source/blender/include/BSE_sequence.h b/source/blender/include/BSE_sequence.h index 15a9218b735..0d96de7be60 100644 --- a/source/blender/include/BSE_sequence.h +++ b/source/blender/include/BSE_sequence.h @@ -92,6 +92,8 @@ void update_changed_seq_and_deps(struct Sequence *seq, int len_change, int ibuf_ struct RenderResult; void do_render_seq(struct RenderResult *rr, int cfra); +int seq_can_blend(struct Sequence *seq); + #define SEQ_HAS_PATH(seq) (seq->type==SEQ_MOVIE || seq->type==SEQ_HD_SOUND || seq->type==SEQ_RAM_SOUND || seq->type==SEQ_IMAGE) #endif diff --git a/source/blender/python/api2_2x/sceneSequence.c b/source/blender/python/api2_2x/sceneSequence.c index 56821980cd2..0d3ad3fcb44 100644 --- a/source/blender/python/api2_2x/sceneSequence.c +++ b/source/blender/python/api2_2x/sceneSequence.c @@ -81,6 +81,7 @@ returns None if notfound.\nIf 'name' is not specified, it returns a list of all static PyObject *Sequence_copy( BPy_Sequence * self ); static PyObject *Sequence_new( BPy_Sequence * self, PyObject * args ); static PyObject *Sequence_remove( BPy_Sequence * self, PyObject * args ); +static PyObject *Sequence_rebuildProxy( BPy_Sequence * self ); static PyObject *SceneSeq_new( BPy_SceneSeq * self, PyObject * args ); static PyObject *SceneSeq_remove( BPy_SceneSeq * self, PyObject * args ); @@ -96,6 +97,8 @@ static PyMethodDef BPy_Sequence_methods[] = { "() - Return a copy of the sequence containing the same objects."}, {"copy", ( PyCFunction ) Sequence_copy, METH_NOARGS, "() - Return a copy of the sequence containing the same objects."}, + {"rebuildProxy", ( PyCFunction ) Sequence_rebuildProxy, METH_VARARGS, + "() - Rebuild the active strip's Proxy."}, {NULL, NULL, 0, NULL} }; @@ -309,6 +312,7 @@ static PyObject *Sequence_copy( BPy_Sequence * self ) Py_RETURN_NONE; } + /*****************************************************************************/ /* PythonTypeObject callback function prototypes */ /*****************************************************************************/ @@ -383,8 +387,6 @@ static PyObject *SceneSeq_nextIter( BPy_Sequence * self ) } - - static PyObject *Sequence_getName( BPy_Sequence * self ) { return PyString_FromString( self->seq->name+2 ); @@ -403,11 +405,13 @@ static int Sequence_setName( BPy_Sequence * self, PyObject * value ) return 0; } + static PyObject *Sequence_getProxyDir( BPy_Sequence * self ) { return PyString_FromString( self->seq->strip->proxy ? self->seq->strip->proxy->dir : "" ); } + static int Sequence_setProxyDir( BPy_Sequence * self, PyObject * value ) { char *name = NULL; @@ -430,6 +434,14 @@ static int Sequence_setProxyDir( BPy_Sequence * self, PyObject * value ) } +static PyObject *Sequence_rebuildProxy( BPy_Sequence * self ) +{ + if (self->seq->strip->proxy) + seq_proxy_rebuild(self->seq); + Py_RETURN_NONE; +} + + static PyObject *Sequence_getSound( BPy_Sequence * self ) { if (self->seq->type == SEQ_RAM_SOUND && self->seq->sound) @@ -622,6 +634,54 @@ static int Sequence_setImages( BPy_Sequence * self, PyObject *value ) return 0; } +static PyObject *M_Sequence_BlendModesDict( void ) +{ + PyObject *M = PyConstant_New( ); + + if( M ) { + BPy_constant *d = ( BPy_constant * ) M; + PyConstant_Insert( d, "CROSS", PyInt_FromLong( SEQ_CROSS ) ); + PyConstant_Insert( d, "ADD", PyInt_FromLong( SEQ_ADD ) ); + PyConstant_Insert( d, "SUBTRACT", PyInt_FromLong( SEQ_SUB ) ); + PyConstant_Insert( d, "ALPHAOVER", PyInt_FromLong( SEQ_ALPHAOVER ) ); + PyConstant_Insert( d, "ALPHAUNDER", PyInt_FromLong( SEQ_ALPHAUNDER ) ); + PyConstant_Insert( d, "GAMMACROSS", PyInt_FromLong( SEQ_GAMCROSS ) ); + PyConstant_Insert( d, "MULTIPLY", PyInt_FromLong( SEQ_MUL ) ); + PyConstant_Insert( d, "OVERDROP", PyInt_FromLong( SEQ_OVERDROP ) ); + PyConstant_Insert( d, "PLUGIN", PyInt_FromLong( SEQ_PLUGIN ) ); + PyConstant_Insert( d, "WIPE", PyInt_FromLong( SEQ_WIPE ) ); + PyConstant_Insert( d, "GLOW", PyInt_FromLong( SEQ_GLOW ) ); + PyConstant_Insert( d, "TRANSFORM", PyInt_FromLong( SEQ_TRANSFORM ) ); + PyConstant_Insert( d, "COLOR", PyInt_FromLong( SEQ_COLOR ) ); + PyConstant_Insert( d, "SPEED", PyInt_FromLong( SEQ_SPEED ) ); + } + return M; +} + +static PyObject *Sequence_getBlendMode( BPy_Sequence * self ) +{ + return PyInt_FromLong( self->seq->blend_mode ); +} + +static int Sequence_setBlendMode( BPy_Sequence * self, PyObject * value ) +{ + struct Sequence *seq= self->seq; + int number = PyInt_AsLong( value ); + + if( number==-1 && PyErr_Occurred() ) + return EXPP_ReturnIntError( PyExc_TypeError, "expected an int value" ); + + if ( !seq_can_blend(seq) ) + return EXPP_ReturnIntError( PyExc_AttributeError, "this sequence type dosnt support blending" ); + + if (number<SEQ_EFFECT || number>SEQ_EFFECT_MAX) + return EXPP_ReturnIntError( PyExc_TypeError, "expected an int value" ); + + seq->blend_mode=number; + + return 0; +} + /* * get floating point attributes */ @@ -836,7 +896,11 @@ static PyGetSetDef BPy_Sequence_getseters[] = { (getter)Sequence_getImages, (setter)Sequence_setImages, "Sequence scene", NULL}, - + {"blendMode", + (getter)Sequence_getBlendMode, (setter)Sequence_setBlendMode, + "Sequence Blend Mode", + NULL}, + {"type", (getter)getIntAttr, (setter)NULL, "", @@ -1131,6 +1195,7 @@ PyObject *M_Sequence_Get( PyObject * self, PyObject * args ) /*****************************************************************************/ PyObject *Sequence_Init( void ) { + PyObject *BlendModesDict = M_Sequence_BlendModesDict( ); PyObject *submodule; if( PyType_Ready( &Sequence_Type ) < 0 ) return NULL; @@ -1142,6 +1207,9 @@ PyObject *Sequence_Init( void ) "The Blender Sequence module\n\n\ This module provides access to **Sequence Data** in Blender.\n" ); + if( BlendModesDict ) + PyModule_AddObject( submodule, "BlendModes", BlendModesDict ); + /*Add SUBMODULES to the module*/ /*PyDict_SetItemString(dict, "Constraint", Constraint_Init()); //creates a *new* module*/ return submodule; diff --git a/source/blender/src/buttons_scene.c b/source/blender/src/buttons_scene.c index 1c98950080a..af90d01fb59 100644 --- a/source/blender/src/buttons_scene.c +++ b/source/blender/src/buttons_scene.c @@ -499,7 +499,7 @@ static char* seq_panel_blend_modes() so that would collide also. */ - if (!(last_seq->type & SEQ_EFFECT)) { + if ( seq_can_blend(last_seq) ) { int i; for (i = SEQ_EFFECT; i <= SEQ_EFFECT_MAX; i++) { diff --git a/source/blender/src/sequence.c b/source/blender/src/sequence.c index 6851929bbc2..9426548dc38 100644 --- a/source/blender/src/sequence.c +++ b/source/blender/src/sequence.c @@ -2380,6 +2380,16 @@ ImBuf *give_ibuf_seq(int rectx, int recty, int cfra, int chanshown) return i; } +/* check used when we need to change seq->blend_mode but not to effect or audio strips */ +int seq_can_blend(Sequence *seq) +{ + if (ELEM4(seq->type, SEQ_IMAGE, SEQ_META, SEQ_SCENE, SEQ_MOVIE)) { + return 1; + } else { + return 0; + } +} + /* threading api */ static ListBase running_threads; |