2009-01-20 14:19:39 +00:00
/**
*
* * * * * * BEGIN GPL LICENSE BLOCK * * * * *
*
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation ; either version 2
* of the License , or ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software Foundation ,
2010-02-12 13:34:04 +00:00
* Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
2009-01-20 14:19:39 +00:00
*
* The Original Code is Copyright ( C ) 2001 - 2002 by NaN Holding BV .
* All rights reserved .
*
* Contributor ( s ) : Blender Foundation , 2003 - 2009 , Campbell Barton
*
* * * * * * END GPL LICENSE BLOCK * * * * *
*/
# include <stdlib.h>
# include <math.h>
# include <string.h>
# ifndef WIN32
# include <unistd.h>
# else
# include <io.h>
# endif
# include <sys/types.h>
# include "MEM_guardedalloc.h"
# include "BLI_blenlib.h"
2009-11-10 20:43:45 +00:00
# include "BLI_math.h"
2009-01-20 14:19:39 +00:00
# include "BLI_storage_types.h"
# include "IMB_imbuf_types.h"
# include "IMB_imbuf.h"
# include "DNA_ipo_types.h"
# include "DNA_curve_types.h"
# include "DNA_scene_types.h"
# include "DNA_screen_types.h"
# include "DNA_space_types.h"
# include "DNA_sequence_types.h"
# include "DNA_view2d_types.h"
# include "DNA_userdef_types.h"
# include "DNA_sound_types.h"
# include "BKE_context.h"
# include "BKE_global.h"
# include "BKE_image.h"
# include "BKE_library.h"
# include "BKE_main.h"
# include "BKE_plugin_types.h"
2009-12-13 14:56:45 +00:00
# include "BKE_sequencer.h"
2009-01-20 14:19:39 +00:00
# include "BKE_scene.h"
# include "BKE_utildefines.h"
# include "BKE_report.h"
# include "BIF_gl.h"
# include "BIF_glutil.h"
# include "WM_api.h"
# include "WM_types.h"
# include "RNA_access.h"
# include "RNA_define.h"
2009-12-13 03:20:29 +00:00
# include "RNA_enum_types.h"
2009-01-20 14:19:39 +00:00
/* for menu/popup icons etc etc*/
# include "UI_interface.h"
# include "UI_resources.h"
# include "ED_anim_api.h"
# include "ED_space_api.h"
# include "ED_types.h"
# include "ED_screen.h"
# include "ED_util.h"
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
# include "ED_fileselect.h"
2009-01-20 14:19:39 +00:00
# include "UI_interface.h"
# include "UI_resources.h"
# include "UI_view2d.h"
2009-08-09 21:16:39 +00:00
# include "BKE_sound.h"
# include "AUD_C-API.h"
2009-01-20 14:19:39 +00:00
/* own include */
# include "sequencer_intern.h"
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
/* Generic functions, reused by add strip operators */
2009-01-26 09:13:15 +00:00
/* avoid passing multiple args and be more verbose */
# define SEQPROP_STARTFRAME 1<<0
# define SEQPROP_ENDFRAME 1<<1
2009-11-14 19:26:58 +00:00
# define SEQPROP_FILES 1<<2
2009-01-26 09:13:15 +00:00
static void sequencer_generic_props__internal ( wmOperatorType * ot , int flag )
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
{
RNA_def_string ( ot - > srna , " name " , " " , MAX_ID_NAME - 2 , " Name " , " Name of the new sequence strip " ) ;
2009-01-26 09:13:15 +00:00
if ( flag & SEQPROP_STARTFRAME )
RNA_def_int ( ot - > srna , " start_frame " , 0 , INT_MIN , INT_MAX , " Start Frame " , " Start frame of the sequence strip " , INT_MIN , INT_MAX ) ;
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
2009-01-26 09:13:15 +00:00
if ( flag & SEQPROP_ENDFRAME )
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
RNA_def_int ( ot - > srna , " end_frame " , 0 , INT_MIN , INT_MAX , " End Frame " , " End frame for the color strip " , INT_MIN , INT_MAX ) ; /* not useual since most strips have a fixed length */
RNA_def_int ( ot - > srna , " channel " , 1 , 1 , MAXSEQ , " Channel " , " Channel to place this strip into " , 1 , MAXSEQ ) ;
RNA_def_boolean ( ot - > srna , " replace_sel " , 1 , " Replace Selection " , " replace the current selection " ) ;
2009-11-14 19:26:58 +00:00
if ( flag & SEQPROP_FILES )
RNA_def_collection_runtime ( ot - > srna , " files " , & RNA_OperatorFileListElement , " Files " , " " ) ;
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
}
2009-01-20 14:19:39 +00:00
2009-01-26 09:13:15 +00:00
static void sequencer_generic_invoke_xy__internal ( bContext * C , wmOperator * op , wmEvent * event , int flag )
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
{
ARegion * ar = CTX_wm_region ( C ) ;
View2D * v2d = UI_view2d_fromcontext ( C ) ;
short mval [ 2 ] ;
float mval_v2d [ 2 ] ;
2009-01-26 09:13:15 +00:00
2009-01-20 14:19:39 +00:00
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
mval [ 0 ] = event - > x - ar - > winrct . xmin ;
mval [ 1 ] = event - > y - ar - > winrct . ymin ;
UI_view2d_region_to_view ( v2d , mval [ 0 ] , mval [ 1 ] , & mval_v2d [ 0 ] , & mval_v2d [ 1 ] ) ;
RNA_int_set ( op - > ptr , " channel " , ( int ) mval_v2d [ 1 ] + 0.5f ) ;
RNA_int_set ( op - > ptr , " start_frame " , ( int ) mval_v2d [ 0 ] ) ;
2009-01-20 14:19:39 +00:00
2009-01-26 09:13:15 +00:00
if ( ( flag & SEQPROP_ENDFRAME ) & & RNA_property_is_set ( op - > ptr , " end_frame " ) = = 0 )
RNA_int_set ( op - > ptr , " end_frame " , ( int ) mval_v2d [ 0 ] + 25 ) ; // XXX arbitary but ok for now.
2009-01-20 14:19:39 +00:00
}
2009-11-14 19:26:58 +00:00
static void seq_load_operator_info ( SeqLoadInfo * seq_load , wmOperator * op )
{
memset ( seq_load , 0 , sizeof ( SeqLoadInfo ) ) ;
seq_load - > start_frame = RNA_int_get ( op - > ptr , " start_frame " ) ;
2010-01-29 17:01:53 +00:00
seq_load - > end_frame = seq_load - > start_frame ; /* un-set */
2009-11-14 19:26:58 +00:00
seq_load - > channel = RNA_int_get ( op - > ptr , " channel " ) ;
2010-01-29 17:01:53 +00:00
seq_load - > len = 1 ; // images only, if endframe isnt set!
2009-11-14 19:26:58 +00:00
2009-12-13 03:20:29 +00:00
RNA_string_get ( op - > ptr , " name " , seq_load - > name + 2 ) ;
2009-11-14 19:26:58 +00:00
RNA_string_get ( op - > ptr , " path " , seq_load - > path ) ; /* full path, file is set by the caller */
2010-01-29 17:01:53 +00:00
if ( RNA_struct_find_property ( op - > ptr , " end_frame " ) ) {
seq_load - > end_frame = RNA_int_get ( op - > ptr , " end_frame " ) ;
}
2009-11-14 19:26:58 +00:00
if ( RNA_struct_find_property ( op - > ptr , " replace_sel " ) & & RNA_boolean_get ( op - > ptr , " replace_sel " ) )
seq_load - > flag | = SEQ_LOAD_REPLACE_SEL ;
if ( RNA_struct_find_property ( op - > ptr , " cache " ) & & RNA_boolean_get ( op - > ptr , " cache " ) )
seq_load - > flag | = SEQ_LOAD_SOUND_CACHE ;
if ( RNA_struct_find_property ( op - > ptr , " sound " ) & & RNA_boolean_get ( op - > ptr , " sound " ) )
seq_load - > flag | = SEQ_LOAD_MOVIE_SOUND ;
/* always use this for ops */
seq_load - > flag | = SEQ_LOAD_FRAME_ADVANCE ;
}
2009-01-20 14:19:39 +00:00
/* add scene operator */
static int sequencer_add_scene_strip_exec ( bContext * C , wmOperator * op )
{
Scene * scene = CTX_data_scene ( C ) ;
2009-01-28 22:36:34 +00:00
Editing * ed = seq_give_editing ( scene , TRUE ) ;
2009-01-20 14:19:39 +00:00
Scene * sce_seq ;
2009-12-13 03:20:29 +00:00
2009-01-20 14:19:39 +00:00
Sequence * seq ; /* generic strip vars */
Strip * strip ;
StripElem * se ;
int start_frame , channel ; /* operator props */
start_frame = RNA_int_get ( op - > ptr , " start_frame " ) ;
channel = RNA_int_get ( op - > ptr , " channel " ) ;
2009-12-13 03:20:29 +00:00
sce_seq = BLI_findlink ( & CTX_data_main ( C ) - > scene , RNA_enum_get ( op - > ptr , " type " ) ) ;
2009-01-20 14:19:39 +00:00
if ( sce_seq = = NULL ) {
2009-12-13 03:20:29 +00:00
BKE_report ( op - > reports , RPT_ERROR , " Scene not found " ) ;
2009-01-20 14:19:39 +00:00
return OPERATOR_CANCELLED ;
}
2009-01-26 09:13:15 +00:00
seq = alloc_sequence ( ed - > seqbasep , start_frame , channel ) ;
2009-01-20 14:19:39 +00:00
seq - > type = SEQ_SCENE ;
seq - > scene = sce_seq ;
/* basic defaults */
seq - > strip = strip = MEM_callocN ( sizeof ( Strip ) , " strip " ) ;
strip - > len = seq - > len = sce_seq - > r . efra - sce_seq - > r . sfra + 1 ;
strip - > us = 1 ;
strip - > stripdata = se = MEM_callocN ( seq - > len * sizeof ( StripElem ) , " stripelem " ) ;
2009-12-13 03:20:29 +00:00
if ( RNA_property_is_set ( op - > ptr , " name " ) )
RNA_string_get ( op - > ptr , " name " , seq - > name + 2 ) ;
else
strcpy ( seq - > name + 2 , sce_seq - > id . name + 2 ) ;
2009-01-20 14:19:39 +00:00
2010-02-07 23:41:17 +00:00
calc_sequence_disp ( scene , seq ) ;
2009-01-20 14:19:39 +00:00
sort_seq ( scene ) ;
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
if ( RNA_boolean_get ( op - > ptr , " replace_sel " ) ) {
deselect_all_seq ( scene ) ;
2009-11-14 19:26:58 +00:00
active_seq_set ( scene , seq ) ;
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
seq - > flag | = SELECT ;
}
2009-12-08 13:57:51 +00:00
WM_event_add_notifier ( C , NC_SCENE | ND_SEQUENCER , scene ) ;
2009-01-20 14:19:39 +00:00
return OPERATOR_FINISHED ;
}
static int sequencer_add_scene_strip_invoke ( bContext * C , wmOperator * op , wmEvent * event )
{
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
sequencer_generic_invoke_xy__internal ( C , op , event , 0 ) ;
2009-01-20 14:19:39 +00:00
return sequencer_add_scene_strip_exec ( C , op ) ;
2009-12-13 03:20:29 +00:00
// needs a menu
// return WM_menu_invoke(C, op, event);
2009-01-20 14:19:39 +00:00
}
2009-04-12 20:32:42 +00:00
void SEQUENCER_OT_scene_strip_add ( struct wmOperatorType * ot )
2009-01-20 14:19:39 +00:00
{
2009-12-13 03:20:29 +00:00
PropertyRNA * prop ;
2009-01-20 14:19:39 +00:00
/* identifiers */
ot - > name = " Add Scene Strip " ;
2009-04-12 20:32:42 +00:00
ot - > idname = " SEQUENCER_OT_scene_strip_add " ;
2009-02-12 03:39:56 +00:00
ot - > description = " Add a strip to the sequencer using a blender scene as a source " ;
2009-01-20 14:19:39 +00:00
/* api callbacks */
ot - > invoke = sequencer_add_scene_strip_invoke ;
ot - > exec = sequencer_add_scene_strip_exec ;
ot - > poll = ED_operator_sequencer_active ;
2009-01-31 19:40:40 +00:00
/* flags */
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2009-01-26 09:13:15 +00:00
sequencer_generic_props__internal ( ot , SEQPROP_STARTFRAME ) ;
2009-12-13 03:20:29 +00:00
prop = RNA_def_enum ( ot - > srna , " type " , DummyRNA_NULL_items , 0 , " Type " , " " ) ;
RNA_def_enum_funcs ( prop , RNA_scene_itemf ) ;
2009-01-20 14:19:39 +00:00
}
2009-11-14 19:26:58 +00:00
static int sequencer_add_generic_strip_exec ( bContext * C , wmOperator * op , SeqLoadFunc seq_load_func )
2009-08-09 21:16:39 +00:00
{
2009-11-14 19:26:58 +00:00
Scene * scene = CTX_data_scene ( C ) ; /* only for sound */
2009-08-09 21:16:39 +00:00
Editing * ed = seq_give_editing ( scene , TRUE ) ;
2009-11-14 19:26:58 +00:00
SeqLoadInfo seq_load ;
Sequence * seq ;
int tot_files ;
2009-08-09 21:16:39 +00:00
2009-11-14 19:26:58 +00:00
seq_load_operator_info ( & seq_load , op ) ;
2009-08-09 21:16:39 +00:00
2009-11-14 19:26:58 +00:00
if ( seq_load . flag & SEQ_LOAD_REPLACE_SEL )
deselect_all_seq ( scene ) ;
2009-08-09 21:16:39 +00:00
2009-11-14 19:26:58 +00:00
tot_files = RNA_property_collection_length ( op - > ptr , RNA_struct_find_property ( op - > ptr , " files " ) ) ;
2009-08-09 21:16:39 +00:00
2009-11-14 19:26:58 +00:00
if ( tot_files ) {
/* multiple files */
char dir_only [ FILE_MAX ] ;
char file_only [ FILE_MAX ] ;
2009-08-09 21:16:39 +00:00
2009-11-14 19:26:58 +00:00
BLI_split_dirfile_basic ( seq_load . path , dir_only , NULL ) ;
2009-08-09 21:16:39 +00:00
2009-11-14 19:26:58 +00:00
RNA_BEGIN ( op - > ptr , itemptr , " files " ) {
RNA_string_get ( & itemptr , " name " , file_only ) ;
BLI_join_dirfile ( seq_load . path , dir_only , file_only ) ;
2009-08-09 21:16:39 +00:00
2009-11-14 19:26:58 +00:00
seq = seq_load_func ( C , ed - > seqbasep , & seq_load ) ;
}
RNA_END ;
}
else {
/* single file */
seq = seq_load_func ( C , ed - > seqbasep , & seq_load ) ;
2009-08-09 21:16:39 +00:00
}
2009-11-14 19:26:58 +00:00
if ( seq_load . tot_success = = 0 ) {
BKE_reportf ( op - > reports , RPT_ERROR , " File \" %s \" could not be loaded " , seq_load . path ) ;
return OPERATOR_CANCELLED ;
}
2009-08-09 21:16:39 +00:00
sort_seq ( scene ) ;
2010-02-07 23:41:17 +00:00
seq_update_muting ( scene , ed ) ;
2009-08-09 21:16:39 +00:00
2009-12-08 13:57:51 +00:00
WM_event_add_notifier ( C , NC_SCENE | ND_SEQUENCER , scene ) ;
2009-08-09 21:16:39 +00:00
2009-11-14 19:26:58 +00:00
return OPERATOR_FINISHED ;
2009-08-09 21:16:39 +00:00
}
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
/* add movie operator */
static int sequencer_add_movie_strip_exec ( bContext * C , wmOperator * op )
{
2009-11-14 19:26:58 +00:00
return sequencer_add_generic_strip_exec ( C , op , sequencer_add_movie_strip ) ;
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
}
static int sequencer_add_movie_strip_invoke ( bContext * C , wmOperator * op , wmEvent * event )
{
sequencer_generic_invoke_xy__internal ( C , op , event , 0 ) ;
2009-01-26 09:13:15 +00:00
return WM_operator_filesel ( C , op , event ) ;
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
//return sequencer_add_movie_strip_exec(C, op);
}
2009-04-12 20:32:42 +00:00
void SEQUENCER_OT_movie_strip_add ( struct wmOperatorType * ot )
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
{
/* identifiers */
ot - > name = " Add Movie Strip " ;
2009-04-12 20:32:42 +00:00
ot - > idname = " SEQUENCER_OT_movie_strip_add " ;
2009-02-12 03:39:56 +00:00
ot - > description = " Add a movie strip to the sequencer " ;
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
/* api callbacks */
ot - > invoke = sequencer_add_movie_strip_invoke ;
ot - > exec = sequencer_add_movie_strip_exec ;
ot - > poll = ED_operator_sequencer_active ;
2009-01-31 19:40:40 +00:00
/* flags */
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
2010-01-31 23:07:32 +00:00
WM_operator_properties_filesel ( ot , FOLDERFILE | MOVIEFILE , FILE_SPECIAL , FILE_OPENFILE ) ;
2009-11-14 19:26:58 +00:00
sequencer_generic_props__internal ( ot , SEQPROP_STARTFRAME | SEQPROP_FILES ) ;
2009-08-09 21:16:39 +00:00
RNA_def_boolean ( ot - > srna , " sound " , TRUE , " Sound " , " Load sound with the movie " ) ;
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
}
/* add sound operator */
2009-11-14 19:26:58 +00:00
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
static int sequencer_add_sound_strip_exec ( bContext * C , wmOperator * op )
{
2009-11-14 19:26:58 +00:00
return sequencer_add_generic_strip_exec ( C , op , sequencer_add_sound_strip ) ;
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
}
static int sequencer_add_sound_strip_invoke ( bContext * C , wmOperator * op , wmEvent * event )
2009-01-26 09:13:15 +00:00
{
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
sequencer_generic_invoke_xy__internal ( C , op , event , 0 ) ;
2009-01-26 09:13:15 +00:00
return WM_operator_filesel ( C , op , event ) ;
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
//return sequencer_add_sound_strip_exec(C, op);
}
2009-04-12 20:32:42 +00:00
void SEQUENCER_OT_sound_strip_add ( struct wmOperatorType * ot )
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
{
/* identifiers */
ot - > name = " Add Sound Strip " ;
2009-04-12 20:32:42 +00:00
ot - > idname = " SEQUENCER_OT_sound_strip_add " ;
2009-02-12 03:39:56 +00:00
ot - > description = " Add a sound strip to the sequencer " ;
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
/* api callbacks */
ot - > invoke = sequencer_add_sound_strip_invoke ;
ot - > exec = sequencer_add_sound_strip_exec ;
ot - > poll = ED_operator_sequencer_active ;
2009-01-31 19:40:40 +00:00
/* flags */
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2010-01-31 23:07:32 +00:00
WM_operator_properties_filesel ( ot , FOLDERFILE | SOUNDFILE , FILE_SPECIAL , FILE_OPENFILE ) ;
2009-11-14 19:26:58 +00:00
sequencer_generic_props__internal ( ot , SEQPROP_STARTFRAME | SEQPROP_FILES ) ;
2009-08-09 21:16:39 +00:00
RNA_def_boolean ( ot - > srna , " cache " , FALSE , " Cache " , " Cache the sound in memory. " ) ;
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
}
/* add image operator */
static int sequencer_add_image_strip_exec ( bContext * C , wmOperator * op )
{
2009-11-14 19:26:58 +00:00
/* cant use the generic function for this */
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
2009-11-14 19:26:58 +00:00
Scene * scene = CTX_data_scene ( C ) ; /* only for sound */
Editing * ed = seq_give_editing ( scene , TRUE ) ;
SeqLoadInfo seq_load ;
Sequence * seq ;
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
Strip * strip ;
StripElem * se ;
2009-11-14 19:26:58 +00:00
seq_load_operator_info ( & seq_load , op ) ;
/* images are unique in how they handle this - 1 per strip elem */
seq_load . len = RNA_property_collection_length ( op - > ptr , RNA_struct_find_property ( op - > ptr , " files " ) ) ;
if ( seq_load . len = = 0 )
seq_load . len = 1 ;
if ( seq_load . flag & SEQ_LOAD_REPLACE_SEL )
deselect_all_seq ( scene ) ;
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
2009-11-14 19:26:58 +00:00
/* main adding function */
seq = sequencer_add_image_strip ( C , ed - > seqbasep , & seq_load ) ;
2009-11-16 14:29:46 +00:00
strip = seq - > strip ;
se = strip - > stripdata ;
2009-11-14 19:26:58 +00:00
if ( seq_load . len > 1 ) {
2009-06-05 16:11:35 +00:00
RNA_BEGIN ( op - > ptr , itemptr , " files " ) {
RNA_string_get ( & itemptr , " name " , se - > name ) ;
se + + ;
}
RNA_END ;
}
else {
2009-11-14 19:26:58 +00:00
BLI_split_dirfile_basic ( seq_load . path , NULL , se - > name ) ;
2010-01-29 17:01:53 +00:00
if ( seq_load . start_frame < seq_load . end_frame ) {
seq - > endstill = seq_load . end_frame - seq_load . start_frame ;
}
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
}
2010-02-07 23:41:17 +00:00
calc_sequence_disp ( scene , seq ) ;
2009-11-14 19:26:58 +00:00
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
sort_seq ( scene ) ;
2009-11-14 19:26:58 +00:00
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
/* last active name */
strncpy ( ed - > act_imagedir , strip - > dir , FILE_MAXDIR - 1 ) ;
2009-12-08 13:57:51 +00:00
WM_event_add_notifier ( C , NC_SCENE | ND_SEQUENCER , scene ) ;
2009-11-14 19:26:58 +00:00
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
return OPERATOR_FINISHED ;
}
static int sequencer_add_image_strip_invoke ( bContext * C , wmOperator * op , wmEvent * event )
{
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
sequencer_generic_invoke_xy__internal ( C , op , event , SEQPROP_ENDFRAME ) ;
2009-01-26 09:13:15 +00:00
return WM_operator_filesel ( C , op , event ) ;
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
//return sequencer_add_image_strip_exec(C, op);
}
2009-04-12 20:32:42 +00:00
void SEQUENCER_OT_image_strip_add ( struct wmOperatorType * ot )
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
{
/* identifiers */
ot - > name = " Add Image Strip " ;
2009-04-12 20:32:42 +00:00
ot - > idname = " SEQUENCER_OT_image_strip_add " ;
2009-02-12 03:39:56 +00:00
ot - > description = " Add an image or image sequence to the sequencer " ;
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
/* api callbacks */
ot - > invoke = sequencer_add_image_strip_invoke ;
ot - > exec = sequencer_add_image_strip_exec ;
ot - > poll = ED_operator_sequencer_active ;
2009-01-31 19:40:40 +00:00
/* flags */
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
2010-01-31 23:07:32 +00:00
WM_operator_properties_filesel ( ot , FOLDERFILE | IMAGEFILE , FILE_SPECIAL , FILE_OPENFILE ) ;
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
sequencer_generic_props__internal ( ot , SEQPROP_STARTFRAME | SEQPROP_ENDFRAME | SEQPROP_FILES ) ;
New Operators, duplicate is shift+d, Add operators are accessible from the header.
SEQUENCER_OT_add_duplicate(mode=1)
SEQUENCER_OT_add_image_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_movie_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
SEQUENCER_OT_add_sound_strip(name='', start_frame=0, channel=1, filename='', replace_sel=True)
Some of these use the file selector, Note that sound isn't working yet because editsound.c functions are not yet in 2.5 and Operators dont have a way to recieve an array of strings so SEQUENCER_OT_add_image_strip only adds 1 image at the moment.
2009-01-22 15:52:04 +00:00
}
2009-01-26 09:13:15 +00:00
/* add_effect_strip operator */
static int sequencer_add_effect_strip_exec ( bContext * C , wmOperator * op )
{
Scene * scene = CTX_data_scene ( C ) ;
2009-01-28 22:36:34 +00:00
Editing * ed = seq_give_editing ( scene , TRUE ) ;
2009-01-26 09:13:15 +00:00
Sequence * seq ; /* generic strip vars */
Strip * strip ;
StripElem * se ;
struct SeqEffectHandle sh ;
int start_frame , end_frame , channel , type ; /* operator props */
Sequence * seq1 , * seq2 , * seq3 ;
char * error_msg ;
start_frame = RNA_int_get ( op - > ptr , " start_frame " ) ;
end_frame = RNA_int_get ( op - > ptr , " end_frame " ) ;
channel = RNA_int_get ( op - > ptr , " channel " ) ;
type = RNA_enum_get ( op - > ptr , " type " ) ;
// XXX We need unique names and move to invoke
if ( ! seq_effect_find_selected ( scene , NULL , type , & seq1 , & seq2 , & seq3 , & error_msg ) ) {
BKE_report ( op - > reports , RPT_ERROR , error_msg ) ;
return OPERATOR_CANCELLED ;
}
/* If seq1 is NULL and no error was rasied it means the seq is standalone
* ( like color strips ) and we need to check its start and end frames are valid */
if ( seq1 = = NULL & & end_frame < = start_frame ) {
BKE_report ( op - > reports , RPT_ERROR , " Start and end frame are not set " ) ;
return OPERATOR_CANCELLED ;
}
seq = alloc_sequence ( ed - > seqbasep , start_frame , channel ) ;
seq - > type = type ;
2009-12-13 03:20:29 +00:00
if ( RNA_property_is_set ( op - > ptr , " name " ) )
RNA_string_get ( op - > ptr , " name " , seq - > name + 2 ) ;
else
strcpy ( seq - > name + 2 , give_seqname ( seq ) ) ;
2010-02-16 17:58:50 +00:00
seqbase_unique_name_recursive ( & ed - > seqbase , seq ) ;
2009-11-22 17:58:33 +00:00
2009-01-26 09:13:15 +00:00
sh = get_sequence_effect ( seq ) ;
seq - > seq1 = seq1 ;
seq - > seq2 = seq2 ;
seq - > seq3 = seq3 ;
sh . init ( seq ) ;
if ( ! seq1 ) { /* effect has no deps */
seq - > len = 1 ;
seq_tx_set_final_right ( seq , end_frame ) ;
}
2009-11-29 18:14:16 +00:00
seq - > flag | = SEQ_USE_EFFECT_DEFAULT_FADE ;
2010-02-07 23:41:17 +00:00
calc_sequence ( scene , seq ) ;
2009-01-26 09:13:15 +00:00
/* basic defaults */
seq - > strip = strip = MEM_callocN ( sizeof ( Strip ) , " strip " ) ;
strip - > len = seq - > len ;
strip - > us = 1 ;
if ( seq - > len > 0 )
strip - > stripdata = se = MEM_callocN ( seq - > len * sizeof ( StripElem ) , " stripelem " ) ;
if ( seq - > type = = SEQ_PLUGIN ) {
2009-09-12 19:54:39 +00:00
char path [ FILE_MAX ] ;
RNA_string_get ( op - > ptr , " path " , path ) ;
2009-01-26 09:13:15 +00:00
2009-09-12 19:54:39 +00:00
sh . init_plugin ( seq , path ) ;
2009-01-26 09:13:15 +00:00
if ( seq - > plugin = = NULL ) {
BLI_remlink ( ed - > seqbasep , seq ) ;
2009-08-09 21:16:39 +00:00
seq_free_sequence ( scene , seq ) ;
2009-09-12 19:54:39 +00:00
BKE_reportf ( op - > reports , RPT_ERROR , " Sequencer plugin \" %s \" could not load. " , path ) ;
2009-01-26 09:13:15 +00:00
return OPERATOR_CANCELLED ;
}
}
else if ( seq - > type = = SEQ_COLOR ) {
SolidColorVars * colvars = ( SolidColorVars * ) seq - > effectdata ;
RNA_float_get_array ( op - > ptr , " color " , colvars - > col ) ;
}
2009-12-21 16:57:39 +00:00
if ( seq_test_overlap ( ed - > seqbasep , seq ) ) shuffle_seq ( ed - > seqbasep , seq , scene ) ;
2009-01-26 09:13:15 +00:00
update_changed_seq_and_deps ( scene , seq , 1 , 1 ) ; /* runs calc_sequence */
/* not sure if this is needed with update_changed_seq_and_deps.
* it was NOT called in blender 2.4 x , but wont hurt */
sort_seq ( scene ) ;
if ( RNA_boolean_get ( op - > ptr , " replace_sel " ) ) {
deselect_all_seq ( scene ) ;
2009-11-14 19:26:58 +00:00
active_seq_set ( scene , seq ) ;
2009-01-26 09:13:15 +00:00
seq - > flag | = SELECT ;
}
2009-12-08 13:57:51 +00:00
WM_event_add_notifier ( C , NC_SCENE | ND_SEQUENCER , scene ) ;
2009-01-26 09:13:15 +00:00
return OPERATOR_FINISHED ;
}
/* add color */
static int sequencer_add_effect_strip_invoke ( bContext * C , wmOperator * op , wmEvent * event )
{
sequencer_generic_invoke_xy__internal ( C , op , event , SEQPROP_ENDFRAME ) ;
if ( RNA_property_is_set ( op - > ptr , " type " ) & & RNA_enum_get ( op - > ptr , " type " ) = = SEQ_PLUGIN ) {
/* only plugins need the file selector */
return WM_operator_filesel ( C , op , event ) ;
}
else {
return sequencer_add_effect_strip_exec ( C , op ) ;
}
}
2009-04-12 20:32:42 +00:00
void SEQUENCER_OT_effect_strip_add ( struct wmOperatorType * ot )
2009-01-26 09:13:15 +00:00
{
/* identifiers */
ot - > name = " Add Effect Strip " ;
2009-04-12 20:32:42 +00:00
ot - > idname = " SEQUENCER_OT_effect_strip_add " ;
2009-09-12 17:16:12 +00:00
ot - > description = " Add an effect to the sequencer, most are applied on top of existing strips " ;
2009-01-26 09:13:15 +00:00
/* api callbacks */
ot - > invoke = sequencer_add_effect_strip_invoke ;
ot - > exec = sequencer_add_effect_strip_exec ;
ot - > poll = ED_operator_sequencer_active ;
2009-01-31 19:40:40 +00:00
/* flags */
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2010-01-31 23:07:32 +00:00
WM_operator_properties_filesel ( ot , 0 , FILE_SPECIAL , FILE_OPENFILE ) ;
2009-07-28 16:46:14 +00:00
sequencer_generic_props__internal ( ot , SEQPROP_STARTFRAME | SEQPROP_ENDFRAME ) ;
2009-01-26 09:13:15 +00:00
RNA_def_enum ( ot - > srna , " type " , sequencer_prop_effect_types , SEQ_CROSS , " Type " , " Sequencer effect type " ) ;
RNA_def_float_vector ( ot - > srna , " color " , 3 , NULL , 0.0f , 1.0f , " Color " , " Initialize the strip with this color (only used when type='COLOR') " , 0.0f , 1.0f ) ;
}