Revision: 15464
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15464
Author:   campbellbarton
Date:     2008-07-07 06:17:03 +0200 (Mon, 07 Jul 2008)

Log Message:
-----------
[#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.

Modified Paths:
--------------
    trunk/blender/source/blender/include/BSE_sequence.h
    trunk/blender/source/blender/python/api2_2x/sceneSequence.c
    trunk/blender/source/blender/src/buttons_scene.c
    trunk/blender/source/blender/src/sequence.c

Modified: trunk/blender/source/blender/include/BSE_sequence.h
===================================================================
--- trunk/blender/source/blender/include/BSE_sequence.h 2008-07-07 02:02:10 UTC 
(rev 15463)
+++ trunk/blender/source/blender/include/BSE_sequence.h 2008-07-07 04:17:03 UTC 
(rev 15464)
@@ -92,6 +92,8 @@
 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

Modified: trunk/blender/source/blender/python/api2_2x/sceneSequence.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/sceneSequence.c 2008-07-07 
02:02:10 UTC (rev 15463)
+++ trunk/blender/source/blender/python/api2_2x/sceneSequence.c 2008-07-07 
04:17:03 UTC (rev 15464)
@@ -81,6 +81,7 @@
 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 @@
         "() - 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 @@
        Py_RETURN_NONE;
 }
 
+
 /*****************************************************************************/
 /* PythonTypeObject callback function prototypes                        */
 /*****************************************************************************/
@@ -383,8 +387,6 @@
 }
 
 
-
-
 static PyObject *Sequence_getName( BPy_Sequence * self )
 {
        return PyString_FromString( self->seq->name+2 );
@@ -403,11 +405,13 @@
        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 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 @@
        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 @@
         (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 *Sequence_Init( void )
 {
+       PyObject *BlendModesDict = M_Sequence_BlendModesDict( );
        PyObject *submodule;
        if( PyType_Ready( &Sequence_Type ) < 0 )
                return NULL;
@@ -1142,6 +1207,9 @@
 "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;

Modified: trunk/blender/source/blender/src/buttons_scene.c
===================================================================
--- trunk/blender/source/blender/src/buttons_scene.c    2008-07-07 02:02:10 UTC 
(rev 15463)
+++ trunk/blender/source/blender/src/buttons_scene.c    2008-07-07 04:17:03 UTC 
(rev 15464)
@@ -499,7 +499,7 @@
          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++) {

Modified: trunk/blender/source/blender/src/sequence.c
===================================================================
--- trunk/blender/source/blender/src/sequence.c 2008-07-07 02:02:10 UTC (rev 
15463)
+++ trunk/blender/source/blender/src/sequence.c 2008-07-07 04:17:03 UTC (rev 
15464)
@@ -2380,6 +2380,16 @@
        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;


_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to