2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2009-01-20 14:19:39 +00:00
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup spseq
|
2011-02-27 20:29:51 +00:00
|
|
|
*/
|
|
|
|
|
|
2020-03-19 09:33:03 +01:00
|
|
|
#include <ctype.h>
|
2009-01-20 14:19:39 +00:00
|
|
|
#include <math.h>
|
2020-03-19 09:33:03 +01:00
|
|
|
#include <stdlib.h>
|
2009-01-20 14:19:39 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
2021-03-16 18:47:23 +01:00
|
|
|
#include "BLI_ghash.h"
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2009-01-20 14:19:39 +00:00
|
|
|
|
2017-03-24 20:01:32 +01:00
|
|
|
#include "BLT_translation.h"
|
|
|
|
|
|
2012-06-07 18:24:36 +00:00
|
|
|
#include "DNA_mask_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_scene_types.h"
|
2021-03-02 12:08:16 +01:00
|
|
|
#include "DNA_sound_types.h"
|
2021-03-16 18:47:23 +01:00
|
|
|
#include "DNA_space_types.h"
|
2009-01-20 14:19:39 +00:00
|
|
|
|
|
|
|
|
#include "BKE_context.h"
|
2021-03-16 18:47:23 +01:00
|
|
|
#include "BKE_global.h"
|
2020-02-10 12:58:59 +01:00
|
|
|
#include "BKE_lib_id.h"
|
2009-01-20 14:19:39 +00:00
|
|
|
#include "BKE_main.h"
|
2012-06-07 18:24:36 +00:00
|
|
|
#include "BKE_mask.h"
|
2018-11-07 18:00:24 +01:00
|
|
|
#include "BKE_movieclip.h"
|
2009-01-20 14:19:39 +00:00
|
|
|
#include "BKE_report.h"
|
|
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
#include "IMB_imbuf.h"
|
|
|
|
|
|
2009-01-20 14:19:39 +00:00
|
|
|
#include "WM_api.h"
|
|
|
|
|
#include "WM_types.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
|
|
|
|
2020-12-19 06:44:57 +01:00
|
|
|
#include "SEQ_add.h"
|
|
|
|
|
#include "SEQ_effects.h"
|
2021-03-16 18:47:23 +01:00
|
|
|
#include "SEQ_proxy.h"
|
2020-12-19 06:44:57 +01:00
|
|
|
#include "SEQ_relations.h"
|
|
|
|
|
#include "SEQ_render.h"
|
|
|
|
|
#include "SEQ_select.h"
|
2020-11-01 21:03:31 +01:00
|
|
|
#include "SEQ_sequencer.h"
|
2020-12-19 06:44:57 +01:00
|
|
|
#include "SEQ_time.h"
|
|
|
|
|
#include "SEQ_transform.h"
|
|
|
|
|
#include "SEQ_utils.h"
|
2020-11-01 21:03:31 +01:00
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* For menu, popup, icons, etc. */
|
2009-01-20 14:19:39 +00:00
|
|
|
#include "ED_screen.h"
|
2012-05-29 05:45:06 +00:00
|
|
|
#include "ED_sequencer.h"
|
2009-01-20 14:19:39 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
#include "UI_interface.h"
|
2009-01-20 14:19:39 +00:00
|
|
|
|
2011-06-23 09:27:56 +00:00
|
|
|
#ifdef WITH_AUDASPACE
|
2017-08-18 08:24:12 +02:00
|
|
|
# include <AUD_Sequence.h>
|
2011-06-23 09:27:56 +00:00
|
|
|
#endif
|
2009-08-09 21:16:39 +00:00
|
|
|
|
2019-06-04 16:52:48 +02:00
|
|
|
#include "DEG_depsgraph.h"
|
2019-06-07 11:27:34 +02:00
|
|
|
#include "DEG_depsgraph_build.h"
|
2019-06-04 16:52:48 +02:00
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Own include. */
|
2009-01-20 14:19:39 +00:00
|
|
|
#include "sequencer_intern.h"
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
typedef struct SequencerAddData {
|
|
|
|
|
ImageFormatData im_format;
|
|
|
|
|
} SequencerAddData;
|
|
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Generic functions, reused by add strip operators. */
|
2009-01-26 09:13:15 +00:00
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Avoid passing multiple args and be more verbose. */
|
2012-03-29 22:26:11 +00:00
|
|
|
#define SEQPROP_STARTFRAME (1 << 0)
|
|
|
|
|
#define SEQPROP_ENDFRAME (1 << 1)
|
|
|
|
|
#define SEQPROP_NOPATHS (1 << 2)
|
|
|
|
|
#define SEQPROP_NOCHAN (1 << 3)
|
2020-12-16 20:34:26 +01:00
|
|
|
#define SEQPROP_FIT_METHOD (1 << 4)
|
2009-01-26 09:13:15 +00:00
|
|
|
|
2020-12-16 20:34:26 +01:00
|
|
|
static const EnumPropertyItem scale_fit_methods[] = {
|
|
|
|
|
{SEQ_SCALE_TO_FIT, "FIT", 0, "Scale to Fit", "Scale image to fit within the canvas"},
|
|
|
|
|
{SEQ_SCALE_TO_FILL, "FILL", 0, "Scale to Fill", "Scale image to completely fill the canvas"},
|
|
|
|
|
{SEQ_STRETCH_TO_FILL, "STRETCH", 0, "Stretch to Fill", "Stretch image to fill the canvas"},
|
|
|
|
|
{SEQ_USE_ORIGINAL_SIZE, "ORIGINAL", 0, "Use Original Size", "Keep image at its original size"},
|
|
|
|
|
{0, NULL, 0, NULL, NULL},
|
|
|
|
|
};
|
|
|
|
|
|
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
|
|
|
{
|
2012-05-21 16:52:04 +00:00
|
|
|
PropertyRNA *prop;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-15 23:24:20 +11:00
|
|
|
if (flag & SEQPROP_STARTFRAME) {
|
|
|
|
|
RNA_def_int(ot->srna,
|
|
|
|
|
"frame_start",
|
|
|
|
|
0,
|
|
|
|
|
INT_MIN,
|
|
|
|
|
INT_MAX,
|
|
|
|
|
"Start Frame",
|
|
|
|
|
"Start frame of the sequence strip",
|
2020-01-22 02:07:54 +01:00
|
|
|
-MAXFRAME,
|
|
|
|
|
MAXFRAME);
|
2019-01-15 23:24:20 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-15 23:24:20 +11:00
|
|
|
if (flag & SEQPROP_ENDFRAME) {
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Not usual since most strips have a fixed length. */
|
2019-01-15 23:24:20 +11:00
|
|
|
RNA_def_int(ot->srna,
|
|
|
|
|
"frame_end",
|
|
|
|
|
0,
|
|
|
|
|
INT_MIN,
|
|
|
|
|
INT_MAX,
|
|
|
|
|
"End Frame",
|
|
|
|
|
"End frame for the color strip",
|
2020-01-22 02:07:54 +01:00
|
|
|
-MAXFRAME,
|
|
|
|
|
MAXFRAME);
|
2019-01-15 23:24:20 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-15 23:24:20 +11:00
|
|
|
RNA_def_int(
|
|
|
|
|
ot->srna, "channel", 1, 1, MAXSEQ, "Channel", "Channel to place this strip into", 1, MAXSEQ);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-15 23:24:20 +11:00
|
|
|
RNA_def_boolean(
|
|
|
|
|
ot->srna, "replace_sel", 1, "Replace Selection", "Replace the current selection");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Only for python scripts which import strips and place them after. */
|
2019-01-15 23:24:20 +11:00
|
|
|
prop = RNA_def_boolean(
|
|
|
|
|
ot->srna, "overlap", 0, "Allow Overlap", "Don't correct overlap on new sequence strips");
|
2012-05-21 16:52:04 +00:00
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN);
|
2020-12-16 20:34:26 +01:00
|
|
|
|
|
|
|
|
if (flag & SEQPROP_FIT_METHOD) {
|
|
|
|
|
ot->prop = RNA_def_enum(ot->srna,
|
|
|
|
|
"fit_method",
|
|
|
|
|
scale_fit_methods,
|
|
|
|
|
SEQ_SCALE_TO_FIT,
|
|
|
|
|
"Fit Method",
|
|
|
|
|
"Scale fit method");
|
|
|
|
|
}
|
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
|
|
|
|
2010-07-02 20:09:42 +00:00
|
|
|
static void sequencer_generic_invoke_path__internal(bContext *C,
|
|
|
|
|
wmOperator *op,
|
|
|
|
|
const char *identifier)
|
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (RNA_struct_find_property(op->ptr, identifier)) {
|
2012-03-29 22:26:11 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2020-12-19 05:57:27 +01:00
|
|
|
Sequence *last_seq = SEQ_select_active_get(scene);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (last_seq && last_seq->strip && SEQ_HAS_PATH(last_seq)) {
|
2018-06-01 17:08:38 +02:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2013-07-15 05:11:14 +00:00
|
|
|
char path[FILE_MAX];
|
2010-07-02 20:09:42 +00:00
|
|
|
BLI_strncpy(path, last_seq->strip->dir, sizeof(path));
|
2018-06-05 15:10:33 +02:00
|
|
|
BLI_path_abs(path, BKE_main_blendfile_path(bmain));
|
2010-07-02 20:09:42 +00:00
|
|
|
RNA_string_set(op->ptr, identifier, path);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-27 01:43:48 +00:00
|
|
|
static int sequencer_generic_invoke_xy_guess_channel(bContext *C, int type)
|
2013-02-27 00:04:07 +00:00
|
|
|
{
|
|
|
|
|
Sequence *tgt = NULL;
|
|
|
|
|
Sequence *seq;
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2020-12-19 05:57:27 +01:00
|
|
|
Editing *ed = SEQ_editing_get(scene, true);
|
2020-11-06 14:10:59 +01:00
|
|
|
int timeline_frame = (int)CFRA;
|
2013-02-27 00:04:07 +00:00
|
|
|
int proximity = INT_MAX;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-02-27 00:04:07 +00:00
|
|
|
if (!ed || !ed->seqbasep) {
|
2020-08-02 20:54:37 +02:00
|
|
|
return 1;
|
2013-02-27 00:04:07 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-02-27 00:04:07 +00:00
|
|
|
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
|
2020-11-06 14:10:59 +01:00
|
|
|
if ((type == -1 || seq->type == type) && (seq->enddisp < timeline_frame) &&
|
|
|
|
|
(timeline_frame - seq->enddisp < proximity)) {
|
2013-02-27 00:04:07 +00:00
|
|
|
tgt = seq;
|
2020-11-06 14:10:59 +01:00
|
|
|
proximity = timeline_frame - seq->enddisp;
|
2013-02-27 00:04:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-02-27 00:04:07 +00:00
|
|
|
if (tgt) {
|
2019-05-19 11:21:37 -07:00
|
|
|
return tgt->machine + 1;
|
2013-02-27 00:04:07 +00:00
|
|
|
}
|
2020-08-02 20:54:37 +02:00
|
|
|
return 1;
|
2013-02-27 00:04:07 +00:00
|
|
|
}
|
|
|
|
|
|
2013-02-27 01:40:36 +00:00
|
|
|
static void sequencer_generic_invoke_xy__internal(bContext *C, wmOperator *op, int flag, int type)
|
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
|
|
|
{
|
2013-02-27 00:04:07 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2020-11-06 14:10:59 +01:00
|
|
|
int timeline_frame = (int)CFRA;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Effect strips don't need a channel initialized from the mouse. */
|
2019-05-19 11:21:37 -07:00
|
|
|
if (!(flag & SEQPROP_NOCHAN) && RNA_struct_property_is_set(op->ptr, "channel") == 0) {
|
2013-02-27 01:43:48 +00:00
|
|
|
RNA_int_set(op->ptr, "channel", sequencer_generic_invoke_xy_guess_channel(C, type));
|
2011-06-20 04:09:33 +00:00
|
|
|
}
|
|
|
|
|
|
2020-11-06 14:10:59 +01:00
|
|
|
RNA_int_set(op->ptr, "frame_start", timeline_frame);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if ((flag & SEQPROP_ENDFRAME) && RNA_struct_property_is_set(op->ptr, "frame_end") == 0) {
|
2020-11-06 14:10:59 +01:00
|
|
|
RNA_int_set(op->ptr, "frame_end", timeline_frame + 25); /* XXX arbitrary but ok for now. */
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2010-07-01 14:08:41 +00:00
|
|
|
|
2010-12-11 20:01:34 +00:00
|
|
|
if (!(flag & SEQPROP_NOPATHS)) {
|
|
|
|
|
sequencer_generic_invoke_path__internal(C, op, "filepath");
|
|
|
|
|
sequencer_generic_invoke_path__internal(C, op, "directory");
|
|
|
|
|
}
|
2009-01-20 14:19:39 +00:00
|
|
|
}
|
|
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
static void load_data_init_from_operator(SeqLoadData *load_data, bContext *C, wmOperator *op)
|
2009-11-14 19:26:58 +00:00
|
|
|
{
|
2018-06-01 17:08:38 +02:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-02-03 18:55:59 +11:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
const bool relative = (prop = RNA_struct_find_property(op->ptr, "relative_path")) &&
|
|
|
|
|
RNA_property_boolean_get(op->ptr, prop);
|
2012-03-29 22:26:11 +00:00
|
|
|
int is_file = -1;
|
2021-03-02 12:08:16 +01:00
|
|
|
memset(load_data, 0, sizeof(SeqLoadData));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
load_data->start_frame = RNA_int_get(op->ptr, "frame_start");
|
|
|
|
|
load_data->channel = RNA_int_get(op->ptr, "channel");
|
|
|
|
|
load_data->image.end_frame = load_data->start_frame;
|
|
|
|
|
load_data->image.len = 1;
|
|
|
|
|
load_data->fit_method = RNA_enum_get(op->ptr, "fit_method");
|
|
|
|
|
SEQ_tool_settings_fit_method_set(CTX_data_scene(C), load_data->fit_method);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-02-03 18:55:59 +11:00
|
|
|
if ((prop = RNA_struct_find_property(op->ptr, "filepath"))) {
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Full path, file is set by the caller. */
|
2021-03-02 12:08:16 +01:00
|
|
|
RNA_property_string_get(op->ptr, prop, load_data->path);
|
2012-03-29 22:26:11 +00:00
|
|
|
is_file = 1;
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
2014-02-03 18:55:59 +11:00
|
|
|
else if ((prop = RNA_struct_find_property(op->ptr, "directory"))) {
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Full path, file is set by the caller. */
|
2021-03-02 12:08:16 +01:00
|
|
|
RNA_property_string_get(op->ptr, prop, load_data->path);
|
2012-03-29 22:26:11 +00:00
|
|
|
is_file = 0;
|
2010-07-02 20:09:42 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if ((is_file != -1) && relative) {
|
2021-03-02 12:08:16 +01:00
|
|
|
BLI_path_rel(load_data->path, BKE_main_blendfile_path(bmain));
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-02-03 18:55:59 +11:00
|
|
|
if ((prop = RNA_struct_find_property(op->ptr, "frame_end"))) {
|
2021-03-02 12:08:16 +01:00
|
|
|
load_data->image.end_frame = RNA_property_int_get(op->ptr, prop);
|
2021-03-20 01:34:12 +01:00
|
|
|
load_data->effect.end_frame = load_data->image.end_frame;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if ((prop = RNA_struct_find_property(op->ptr, "cache")) &&
|
|
|
|
|
RNA_property_boolean_get(op->ptr, prop)) {
|
2021-03-02 12:08:16 +01:00
|
|
|
load_data->flags |= SEQ_LOAD_SOUND_CACHE;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if ((prop = RNA_struct_find_property(op->ptr, "mono")) &&
|
|
|
|
|
RNA_property_boolean_get(op->ptr, prop)) {
|
2021-03-02 12:08:16 +01:00
|
|
|
load_data->flags |= SEQ_LOAD_SOUND_MONO;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if ((prop = RNA_struct_find_property(op->ptr, "use_framerate")) &&
|
|
|
|
|
RNA_property_boolean_get(op->ptr, prop)) {
|
2021-03-02 12:08:16 +01:00
|
|
|
load_data->flags |= SEQ_LOAD_MOVIE_SYNC_FPS;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-29 22:26:11 +00:00
|
|
|
if (is_file == 1) {
|
2021-03-02 12:08:16 +01:00
|
|
|
BLI_strncpy(load_data->name, BLI_path_basename(load_data->path), sizeof(load_data->name));
|
2010-07-02 20:09:42 +00:00
|
|
|
}
|
2014-02-03 18:55:59 +11:00
|
|
|
else if ((prop = RNA_struct_find_property(op->ptr, "files"))) {
|
|
|
|
|
RNA_PROP_BEGIN (op->ptr, itemptr, prop) {
|
2012-03-29 22:26:11 +00:00
|
|
|
char *name = RNA_string_get_alloc(&itemptr, "name", NULL, 0);
|
2021-03-02 12:08:16 +01:00
|
|
|
BLI_strncpy(load_data->name, name, sizeof(load_data->name));
|
2010-07-28 07:00:40 +00:00
|
|
|
MEM_freeN(name);
|
2010-07-02 20:09:42 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2014-02-03 18:55:59 +11:00
|
|
|
RNA_PROP_END;
|
2010-07-02 20:09:42 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
if ((prop = RNA_struct_find_property(op->ptr, "use_multiview")) &&
|
|
|
|
|
RNA_property_boolean_get(op->ptr, prop)) {
|
|
|
|
|
if (op->customdata) {
|
|
|
|
|
SequencerAddData *sad = op->customdata;
|
|
|
|
|
ImageFormatData *imf = &sad->im_format;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
load_data->use_multiview = true;
|
|
|
|
|
load_data->views_format = imf->views_format;
|
|
|
|
|
load_data->stereo3d_format = &imf->stereo3d_format;
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
}
|
2009-11-14 19:26:58 +00:00
|
|
|
}
|
|
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
static void seq_load_apply_generic_options(bContext *C, wmOperator *op, Sequence *seq)
|
2014-05-27 15:18:31 +10:00
|
|
|
{
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2020-12-19 05:57:27 +01:00
|
|
|
Editing *ed = SEQ_editing_get(scene, false);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
if (seq == NULL) {
|
|
|
|
|
return;
|
2014-05-27 15:18:31 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (RNA_boolean_get(op->ptr, "replace_sel")) {
|
|
|
|
|
seq->flag |= SELECT;
|
2021-03-02 12:08:16 +01:00
|
|
|
SEQ_select_active_set(scene, seq);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (RNA_boolean_get(op->ptr, "overlap") == false) {
|
|
|
|
|
if (SEQ_transform_test_overlap(ed->seqbasep, seq)) {
|
|
|
|
|
SEQ_transform_seqbase_shuffle(ed->seqbasep, seq, scene);
|
|
|
|
|
}
|
2014-05-27 15:18:31 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-22 02:07:54 +01:00
|
|
|
static bool seq_effect_add_properties_poll(const bContext *UNUSED(C),
|
|
|
|
|
wmOperator *op,
|
|
|
|
|
const PropertyRNA *prop)
|
|
|
|
|
{
|
|
|
|
|
const char *prop_id = RNA_property_identifier(prop);
|
|
|
|
|
int type = RNA_enum_get(op->ptr, "type");
|
|
|
|
|
|
|
|
|
|
/* Hide start/end frames for effect strips that are locked to their parents' location. */
|
2020-12-19 05:57:27 +01:00
|
|
|
if (SEQ_effect_get_num_inputs(type) != 0) {
|
2020-11-06 15:29:25 +11:00
|
|
|
if (STR_ELEM(prop_id, "frame_start", "frame_end")) {
|
2020-01-22 02:07:54 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ((type != SEQ_TYPE_COLOR) && (STREQ(prop_id, "color"))) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-20 14:19:39 +00:00
|
|
|
static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
2019-06-07 11:27:34 +02:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2012-03-29 22:26:11 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2021-03-02 12:08:16 +01:00
|
|
|
const Editing *ed = SEQ_editing_get(scene, true);
|
|
|
|
|
Scene *sce_seq = BLI_findlink(&bmain->scenes, RNA_enum_get(op->ptr, "scene"));
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-03-29 22:26:11 +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;
|
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
if (RNA_boolean_get(op->ptr, "replace_sel")) {
|
|
|
|
|
ED_sequencer_deselect_all(scene);
|
|
|
|
|
}
|
2010-07-02 20:09:42 +00:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
SeqLoadData load_data;
|
|
|
|
|
load_data_init_from_operator(&load_data, C, op);
|
|
|
|
|
load_data.scene = sce_seq;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
Sequence *seq = SEQ_add_scene_strip(scene, ed->seqbasep, &load_data);
|
|
|
|
|
seq_load_apply_generic_options(C, op, seq);
|
2011-07-28 03:44:17 +00:00
|
|
|
|
2019-06-04 16:52:48 +02:00
|
|
|
DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
|
2019-06-07 11:27:34 +02:00
|
|
|
DEG_relations_tag_update(bmain);
|
2012-03-29 22:26:11 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-01-20 14:19:39 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int sequencer_add_scene_strip_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
2009-01-20 14:19:39 +00:00
|
|
|
{
|
2019-03-26 21:16:47 +11:00
|
|
|
if (!RNA_struct_property_is_set(op->ptr, "scene")) {
|
2010-12-02 22:58:23 +00:00
|
|
|
return WM_enum_search_invoke(C, op, event);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-02-27 01:40:36 +00:00
|
|
|
sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_SCENE);
|
2009-01-20 14:19:39 +00:00
|
|
|
return sequencer_add_scene_strip_exec(C, op);
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Identifiers. */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Add Scene Strip";
|
|
|
|
|
ot->idname = "SEQUENCER_OT_scene_strip_add";
|
|
|
|
|
ot->description = "Add a strip to the sequencer using a blender scene as a source";
|
2009-01-20 14:19:39 +00:00
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Api callbacks. */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = sequencer_add_scene_strip_invoke;
|
|
|
|
|
ot->exec = sequencer_add_scene_strip_exec;
|
2014-02-26 13:21:48 +11:00
|
|
|
ot->poll = ED_operator_sequencer_active_editable;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Flags. */
|
2012-03-29 22:26:11 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-01-26 09:13:15 +00:00
|
|
|
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
|
2012-03-29 22:26:11 +00:00
|
|
|
prop = RNA_def_enum(ot->srna, "scene", DummyRNA_NULL_items, 0, "Scene", "");
|
2017-11-21 16:33:36 +11:00
|
|
|
RNA_def_enum_funcs(prop, RNA_scene_without_active_itemf);
|
2014-05-05 15:09:29 +10:00
|
|
|
RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->prop = prop;
|
2009-01-20 14:19:39 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-21 18:02:29 +00:00
|
|
|
static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
2020-02-19 15:06:14 +11:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2012-03-29 22:26:11 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2021-03-02 12:08:16 +01:00
|
|
|
const Editing *ed = SEQ_editing_get(scene, true);
|
|
|
|
|
MovieClip *clip = BLI_findlink(&bmain->movieclips, RNA_enum_get(op->ptr, "clip"));
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-03-21 18:02:29 +00:00
|
|
|
if (clip == NULL) {
|
2012-10-26 17:32:50 +00:00
|
|
|
BKE_report(op->reports, RPT_ERROR, "Movie clip not found");
|
2012-03-21 18:02:29 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
if (RNA_boolean_get(op->ptr, "replace_sel")) {
|
|
|
|
|
ED_sequencer_deselect_all(scene);
|
|
|
|
|
}
|
2012-03-21 18:02:29 +00:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
SeqLoadData load_data;
|
|
|
|
|
load_data_init_from_operator(&load_data, C, op);
|
|
|
|
|
load_data.clip = clip;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
Sequence *seq = SEQ_add_movieclip_strip(scene, ed->seqbasep, &load_data);
|
|
|
|
|
seq_load_apply_generic_options(C, op, seq);
|
2012-03-21 18:02:29 +00:00
|
|
|
|
2019-06-04 16:52:48 +02:00
|
|
|
DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
|
2012-03-29 22:26:11 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-03-21 18:02:29 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int sequencer_add_movieclip_strip_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
2012-03-21 18:02:29 +00:00
|
|
|
{
|
2019-03-26 21:16:47 +11:00
|
|
|
if (!RNA_struct_property_is_set(op->ptr, "clip")) {
|
2012-03-21 18:02:29 +00:00
|
|
|
return WM_enum_search_invoke(C, op, event);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-02-27 01:40:36 +00:00
|
|
|
sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_MOVIECLIP);
|
2012-03-21 18:02:29 +00:00
|
|
|
return sequencer_add_movieclip_strip_exec(C, op);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SEQUENCER_OT_movieclip_strip_add(struct wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
PropertyRNA *prop;
|
2012-06-07 18:24:36 +00:00
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Identifiers. */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Add MovieClip Strip";
|
|
|
|
|
ot->idname = "SEQUENCER_OT_movieclip_strip_add";
|
|
|
|
|
ot->description = "Add a movieclip strip to the sequencer";
|
2012-03-21 18:02:29 +00:00
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Api callbacks. */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = sequencer_add_movieclip_strip_invoke;
|
|
|
|
|
ot->exec = sequencer_add_movieclip_strip_exec;
|
2014-02-26 13:21:48 +11:00
|
|
|
ot->poll = ED_operator_sequencer_active_editable;
|
2012-06-07 18:24:36 +00:00
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Flags. */
|
2012-03-29 22:26:11 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2012-06-07 18:24:36 +00:00
|
|
|
|
2012-03-21 18:02:29 +00:00
|
|
|
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
|
2012-03-29 22:26:11 +00:00
|
|
|
prop = RNA_def_enum(ot->srna, "clip", DummyRNA_NULL_items, 0, "Clip", "");
|
2012-03-21 18:02:29 +00:00
|
|
|
RNA_def_enum_funcs(prop, RNA_movieclip_itemf);
|
2017-03-24 20:01:32 +01:00
|
|
|
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_MOVIECLIP);
|
2014-05-05 15:09:29 +10:00
|
|
|
RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->prop = prop;
|
2012-03-21 18:02:29 +00:00
|
|
|
}
|
|
|
|
|
|
2012-06-07 18:24:36 +00:00
|
|
|
static int sequencer_add_mask_strip_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
2020-02-19 15:06:14 +11:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2012-06-07 18:24:36 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2021-03-02 12:08:16 +01:00
|
|
|
const Editing *ed = SEQ_editing_get(scene, true);
|
|
|
|
|
Mask *mask = BLI_findlink(&bmain->masks, RNA_enum_get(op->ptr, "mask"));
|
2012-06-07 18:24:36 +00:00
|
|
|
|
|
|
|
|
if (mask == NULL) {
|
|
|
|
|
BKE_report(op->reports, RPT_ERROR, "Mask not found");
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
if (RNA_boolean_get(op->ptr, "replace_sel")) {
|
|
|
|
|
ED_sequencer_deselect_all(scene);
|
|
|
|
|
}
|
2012-06-07 18:24:36 +00:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
SeqLoadData load_data;
|
|
|
|
|
load_data_init_from_operator(&load_data, C, op);
|
|
|
|
|
load_data.mask = mask;
|
2012-06-07 18:24:36 +00:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
Sequence *seq = SEQ_add_mask_strip(scene, ed->seqbasep, &load_data);
|
|
|
|
|
seq_load_apply_generic_options(C, op, seq);
|
2012-06-07 18:24:36 +00:00
|
|
|
|
2019-06-04 16:52:48 +02:00
|
|
|
DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
|
2012-06-07 18:24:36 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int sequencer_add_mask_strip_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
2012-06-07 18:24:36 +00:00
|
|
|
{
|
2019-03-26 21:16:47 +11:00
|
|
|
if (!RNA_struct_property_is_set(op->ptr, "mask")) {
|
2012-06-07 18:24:36 +00:00
|
|
|
return WM_enum_search_invoke(C, op, event);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-02-27 01:40:36 +00:00
|
|
|
sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_MASK);
|
2012-06-07 18:24:36 +00:00
|
|
|
return sequencer_add_mask_strip_exec(C, op);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SEQUENCER_OT_mask_strip_add(struct wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Identifiers. */
|
2012-06-07 18:24:36 +00:00
|
|
|
ot->name = "Add Mask Strip";
|
|
|
|
|
ot->idname = "SEQUENCER_OT_mask_strip_add";
|
|
|
|
|
ot->description = "Add a mask strip to the sequencer";
|
|
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Api callbacks. */
|
2012-06-07 18:24:36 +00:00
|
|
|
ot->invoke = sequencer_add_mask_strip_invoke;
|
|
|
|
|
ot->exec = sequencer_add_mask_strip_exec;
|
2014-02-26 13:21:48 +11:00
|
|
|
ot->poll = ED_operator_sequencer_active_editable;
|
2012-06-07 18:24:36 +00:00
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Flags. */
|
2012-06-07 18:24:36 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
|
|
|
|
|
|
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
|
|
|
|
|
prop = RNA_def_enum(ot->srna, "mask", DummyRNA_NULL_items, 0, "Mask", "");
|
|
|
|
|
RNA_def_enum_funcs(prop, RNA_mask_itemf);
|
2014-05-05 15:09:29 +10:00
|
|
|
RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
|
2012-06-07 18:24:36 +00:00
|
|
|
ot->prop = prop;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
static void sequencer_add_init(bContext *UNUSED(C), wmOperator *op)
|
2009-08-09 21:16:39 +00:00
|
|
|
{
|
2021-03-02 12:08:16 +01:00
|
|
|
op->customdata = MEM_callocN(sizeof(SequencerAddData), __func__);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
static void sequencer_add_cancel(bContext *UNUSED(C), wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
if (op->customdata) {
|
|
|
|
|
MEM_freeN(op->customdata);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2021-03-02 12:08:16 +01:00
|
|
|
op->customdata = NULL;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
static bool sequencer_add_draw_check_fn(PointerRNA *UNUSED(ptr),
|
|
|
|
|
PropertyRNA *prop,
|
|
|
|
|
void *UNUSED(user_data))
|
|
|
|
|
{
|
|
|
|
|
const char *prop_id = RNA_property_identifier(prop);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
return !(STR_ELEM(prop_id, "filepath", "directory", "filename"));
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-16 18:47:23 +01:00
|
|
|
/* Strips are added in context of timeline which has different preview size than actual preview. We
|
|
|
|
|
* must search for preview area. In most cases there will be only one preview area, but there can
|
|
|
|
|
* be more with different preview sizes. */
|
|
|
|
|
static IMB_Proxy_Size seq_get_proxy_size_flags(bContext *C)
|
|
|
|
|
{
|
|
|
|
|
bScreen *screen = CTX_wm_screen(C);
|
|
|
|
|
IMB_Proxy_Size proxy_sizes = 0;
|
|
|
|
|
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
|
|
|
|
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
|
|
|
|
|
switch (sl->spacetype) {
|
|
|
|
|
case SPACE_SEQ: {
|
|
|
|
|
SpaceSeq *sseq = (SpaceSeq *)sl;
|
|
|
|
|
if (!ELEM(sseq->view, SEQ_VIEW_PREVIEW, SEQ_VIEW_SEQUENCE_PREVIEW)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
proxy_sizes |= SEQ_rendersize_to_proxysize(sseq->render_size);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return proxy_sizes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void seq_build_proxy(bContext *C, Sequence *seq)
|
|
|
|
|
{
|
2021-03-16 23:15:11 +01:00
|
|
|
if (U.sequencer_proxy_setup != USER_SEQ_PROXY_SETUP_AUTOMATIC) {
|
2021-03-16 18:47:23 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Enable and set proxy size. */
|
|
|
|
|
SEQ_proxy_set(seq, true);
|
|
|
|
|
seq->strip->proxy->build_size_flags = seq_get_proxy_size_flags(C);
|
|
|
|
|
seq->strip->proxy->build_flags |= SEQ_PROXY_SKIP_EXISTING;
|
|
|
|
|
|
|
|
|
|
/* Build proxy. */
|
|
|
|
|
GSet *file_list = BLI_gset_new(BLI_ghashutil_strhash_p, BLI_ghashutil_strcmp, "file list");
|
|
|
|
|
wmJob *wm_job = ED_seq_proxy_wm_job_get(C);
|
|
|
|
|
ProxyJob *pj = ED_seq_proxy_job_get(C, wm_job);
|
|
|
|
|
SEQ_proxy_rebuild_context(pj->main, pj->depsgraph, pj->scene, seq, file_list, &pj->queue);
|
|
|
|
|
BLI_gset_free(file_list, MEM_freeN);
|
|
|
|
|
|
|
|
|
|
if (!WM_jobs_is_running(wm_job)) {
|
|
|
|
|
G.is_break = false;
|
|
|
|
|
WM_jobs_start(CTX_wm_manager(C), wm_job);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ED_area_tag_redraw(CTX_wm_area(C));
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
static void sequencer_add_movie_multiple_strips(bContext *C,
|
|
|
|
|
wmOperator *op,
|
|
|
|
|
SeqLoadData *load_data)
|
|
|
|
|
{
|
|
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
const Editing *ed = SEQ_editing_get(scene, true);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
RNA_BEGIN (op->ptr, itemptr, "files") {
|
|
|
|
|
char dir_only[FILE_MAX];
|
|
|
|
|
char file_only[FILE_MAX];
|
|
|
|
|
RNA_string_get(op->ptr, "directory", dir_only);
|
|
|
|
|
RNA_string_get(&itemptr, "name", file_only);
|
|
|
|
|
BLI_join_dirfile(load_data->path, sizeof(load_data->path), dir_only, file_only);
|
|
|
|
|
BLI_strncpy(load_data->name, file_only, sizeof(load_data->name));
|
|
|
|
|
Sequence *seq_movie = NULL;
|
|
|
|
|
Sequence *seq_sound = NULL;
|
|
|
|
|
load_data->channel++;
|
|
|
|
|
seq_movie = SEQ_add_movie_strip(bmain, scene, ed->seqbasep, load_data);
|
|
|
|
|
load_data->channel--;
|
|
|
|
|
if (seq_movie == NULL) {
|
|
|
|
|
BKE_reportf(op->reports, RPT_ERROR, "File '%s' could not be loaded", load_data->path);
|
2009-11-14 19:26:58 +00:00
|
|
|
}
|
2021-03-02 12:08:16 +01:00
|
|
|
else {
|
|
|
|
|
if (RNA_boolean_get(op->ptr, "sound")) {
|
|
|
|
|
seq_sound = SEQ_add_sound_strip(bmain, scene, ed->seqbasep, load_data);
|
2012-02-11 13:19:25 +00:00
|
|
|
}
|
2021-03-02 12:08:16 +01:00
|
|
|
load_data->start_frame += seq_movie->enddisp - seq_movie->startdisp;
|
|
|
|
|
seq_load_apply_generic_options(C, op, seq_sound);
|
|
|
|
|
seq_load_apply_generic_options(C, op, seq_movie);
|
2021-03-16 18:47:23 +01:00
|
|
|
seq_build_proxy(C, seq_movie);
|
2011-07-28 03:44:17 +00:00
|
|
|
}
|
2009-08-09 21:16:39 +00:00
|
|
|
}
|
2021-03-02 12:08:16 +01:00
|
|
|
RNA_END;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
static bool sequencer_add_movie_single_strip(bContext *C, wmOperator *op, SeqLoadData *load_data)
|
|
|
|
|
{
|
|
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
const Editing *ed = SEQ_editing_get(scene, true);
|
2019-06-20 16:06:01 -07:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
Sequence *seq_movie = NULL;
|
|
|
|
|
Sequence *seq_sound = NULL;
|
|
|
|
|
load_data->channel++;
|
|
|
|
|
seq_movie = SEQ_add_movie_strip(bmain, scene, ed->seqbasep, load_data);
|
|
|
|
|
load_data->channel--;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
if (seq_movie == NULL) {
|
|
|
|
|
BKE_reportf(op->reports, RPT_ERROR, "File '%s' could not be loaded", load_data->path);
|
|
|
|
|
return false;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2021-03-02 12:08:16 +01:00
|
|
|
if (RNA_boolean_get(op->ptr, "sound")) {
|
|
|
|
|
seq_sound = SEQ_add_sound_strip(bmain, scene, ed->seqbasep, load_data);
|
|
|
|
|
}
|
|
|
|
|
seq_load_apply_generic_options(C, op, seq_sound);
|
|
|
|
|
seq_load_apply_generic_options(C, op, seq_movie);
|
2021-03-16 18:47:23 +01:00
|
|
|
seq_build_proxy(C, seq_movie);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
return true;
|
2009-08-09 21:16:39 +00:00
|
|
|
}
|
|
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
static int sequencer_add_movie_strip_exec(bContext *C, wmOperator *op)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
2021-03-02 12:08:16 +01:00
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
SeqLoadData load_data;
|
|
|
|
|
|
|
|
|
|
load_data_init_from_operator(&load_data, C, op);
|
|
|
|
|
|
|
|
|
|
if (RNA_boolean_get(op->ptr, "replace_sel")) {
|
|
|
|
|
ED_sequencer_deselect_all(scene);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const int tot_files = RNA_property_collection_length(op->ptr,
|
|
|
|
|
RNA_struct_find_property(op->ptr, "files"));
|
|
|
|
|
if (tot_files > 1) {
|
|
|
|
|
sequencer_add_movie_multiple_strips(C, op, &load_data);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (!sequencer_add_movie_single_strip(C, op, &load_data)) {
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (op->customdata) {
|
2015-04-06 10:40:12 -03:00
|
|
|
MEM_freeN(op->customdata);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
DEG_relations_tag_update(bmain);
|
|
|
|
|
DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
|
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
return OPERATOR_FINISHED;
|
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
|
|
|
}
|
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int sequencer_add_movie_strip_invoke(bContext *C,
|
|
|
|
|
wmOperator *op,
|
|
|
|
|
const wmEvent *UNUSED(event))
|
2010-03-16 17:23:20 +00:00
|
|
|
{
|
2015-04-06 10:40:12 -03:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2020-12-19 05:57:27 +01:00
|
|
|
Editing *ed = SEQ_editing_get(scene, false);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
/* Only enable "use_framerate" if there aren't any existing strips, unless overridden by user.
|
|
|
|
|
*/
|
2016-01-09 00:12:33 +13:00
|
|
|
if (ed && ed->seqbasep && ed->seqbasep->first) {
|
|
|
|
|
RNA_boolean_set(op->ptr, "use_framerate", false);
|
|
|
|
|
}
|
2020-12-16 20:34:26 +01:00
|
|
|
RNA_enum_set(op->ptr, "fit_method", SEQ_tool_settings_fit_method_get(scene));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* This is for drag and drop. */
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((RNA_struct_property_is_set(op->ptr, "files") && RNA_collection_length(op->ptr, "files")) ||
|
2012-03-22 14:33:51 +00:00
|
|
|
RNA_struct_property_is_set(op->ptr, "filepath")) {
|
2013-02-27 01:40:36 +00:00
|
|
|
sequencer_generic_invoke_xy__internal(C, op, SEQPROP_NOPATHS, SEQ_TYPE_MOVIE);
|
2010-07-21 19:49:43 +00:00
|
|
|
return sequencer_add_movie_strip_exec(C, op);
|
2010-12-11 20:01:34 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-02-27 01:40:36 +00:00
|
|
|
sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_MOVIE);
|
2015-04-06 10:40:12 -03:00
|
|
|
sequencer_add_init(C, op);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Show multiview save options only if scene use multiview. */
|
2015-04-06 10:40:12 -03:00
|
|
|
prop = RNA_struct_find_property(op->ptr, "show_multiview");
|
|
|
|
|
RNA_property_boolean_set(op->ptr, prop, (scene->r.scemode & R_MULTIVIEW) != 0);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-07-01 14:08:41 +00:00
|
|
|
WM_event_add_fileselect(C, op);
|
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
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
|
|
|
}
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
static void sequencer_add_draw(bContext *UNUSED(C), wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
uiLayout *layout = op->layout;
|
|
|
|
|
SequencerAddData *sad = op->customdata;
|
|
|
|
|
ImageFormatData *imf = &sad->im_format;
|
|
|
|
|
PointerRNA imf_ptr, ptr;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Main draw call. */
|
2015-04-06 10:40:12 -03:00
|
|
|
RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
|
2019-03-22 00:30:17 +11:00
|
|
|
uiDefAutoButsRNA(
|
2020-04-05 23:39:20 +02:00
|
|
|
layout, &ptr, sequencer_add_draw_check_fn, NULL, NULL, UI_BUT_LABEL_ALIGN_NONE, false);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Image template. */
|
2015-04-06 10:40:12 -03:00
|
|
|
RNA_pointer_create(NULL, &RNA_ImageFormatSettings, imf, &imf_ptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Multiview template. */
|
2019-03-26 21:16:47 +11:00
|
|
|
if (RNA_boolean_get(op->ptr, "show_multiview")) {
|
2015-04-06 10:40:12 -03:00
|
|
|
uiTemplateImageFormatViews(layout, &imf_ptr, op->ptr);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2015-04-06 10:40:12 -03: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
|
|
|
|
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
|
|
|
{
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Identifiers. */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Add Movie Strip";
|
|
|
|
|
ot->idname = "SEQUENCER_OT_movie_strip_add";
|
|
|
|
|
ot->description = "Add a movie strip to the sequencer";
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Api callbacks. */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = sequencer_add_movie_strip_invoke;
|
|
|
|
|
ot->exec = sequencer_add_movie_strip_exec;
|
2015-04-06 10:40:12 -03:00
|
|
|
ot->cancel = sequencer_add_cancel;
|
|
|
|
|
ot->ui = sequencer_add_draw;
|
2014-02-26 13:21:48 +11:00
|
|
|
ot->poll = ED_operator_sequencer_active_editable;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Flags. */
|
2012-03-29 22:26:11 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-02-07 22:56:20 +11:00
|
|
|
WM_operator_properties_filesel(ot,
|
|
|
|
|
FILE_TYPE_FOLDER | FILE_TYPE_MOVIE,
|
|
|
|
|
FILE_SPECIAL,
|
|
|
|
|
FILE_OPENFILE,
|
2019-11-11 13:34:40 +01:00
|
|
|
WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH | WM_FILESEL_FILES |
|
2020-03-02 09:23:55 +01:00
|
|
|
WM_FILESEL_SHOW_PROPS | WM_FILESEL_DIRECTORY,
|
2016-02-07 22:56:20 +11:00
|
|
|
FILE_DEFAULTDISPLAY,
|
2020-11-02 23:55:59 +01:00
|
|
|
FILE_SORT_DEFAULT);
|
2020-12-16 20:34:26 +01:00
|
|
|
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME | SEQPROP_FIT_METHOD);
|
2014-04-01 11:34:00 +11:00
|
|
|
RNA_def_boolean(ot->srna, "sound", true, "Sound", "Load sound with the movie");
|
2016-01-08 18:30:26 +13:00
|
|
|
RNA_def_boolean(ot->srna,
|
|
|
|
|
"use_framerate",
|
|
|
|
|
true,
|
|
|
|
|
"Use Movie Framerate",
|
|
|
|
|
"Use framerate from the movie to keep sound and video in sync");
|
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
|
|
|
}
|
|
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
static void sequencer_add_sound_multiple_strips(bContext *C,
|
|
|
|
|
wmOperator *op,
|
|
|
|
|
SeqLoadData *load_data)
|
|
|
|
|
{
|
|
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
Editing *ed = SEQ_editing_get(scene, true);
|
|
|
|
|
|
|
|
|
|
RNA_BEGIN (op->ptr, itemptr, "files") {
|
|
|
|
|
char dir_only[FILE_MAX];
|
|
|
|
|
char file_only[FILE_MAX];
|
|
|
|
|
RNA_string_get(op->ptr, "directory", dir_only);
|
|
|
|
|
RNA_string_get(&itemptr, "name", file_only);
|
|
|
|
|
BLI_join_dirfile(load_data->path, sizeof(load_data->path), dir_only, file_only);
|
|
|
|
|
BLI_strncpy(load_data->name, file_only, sizeof(load_data->name));
|
|
|
|
|
Sequence *seq = SEQ_add_sound_strip(bmain, scene, ed->seqbasep, load_data);
|
|
|
|
|
if (seq == NULL) {
|
|
|
|
|
BKE_reportf(op->reports, RPT_ERROR, "File '%s' could not be loaded", load_data->path);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
seq_load_apply_generic_options(C, op, seq);
|
|
|
|
|
load_data->start_frame += seq->enddisp - seq->startdisp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
RNA_END;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool sequencer_add_sound_single_strip(bContext *C, wmOperator *op, SeqLoadData *load_data)
|
|
|
|
|
{
|
|
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
Editing *ed = SEQ_editing_get(scene, true);
|
|
|
|
|
|
|
|
|
|
Sequence *seq = SEQ_add_sound_strip(bmain, scene, ed->seqbasep, load_data);
|
|
|
|
|
if (seq == NULL) {
|
|
|
|
|
BKE_reportf(op->reports, RPT_ERROR, "File '%s' could not be loaded", load_data->path);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
seq_load_apply_generic_options(C, op, seq);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2021-03-02 12:08:16 +01:00
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
SeqLoadData load_data;
|
|
|
|
|
load_data_init_from_operator(&load_data, C, op);
|
|
|
|
|
|
|
|
|
|
if (RNA_boolean_get(op->ptr, "replace_sel")) {
|
|
|
|
|
ED_sequencer_deselect_all(scene);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const int tot_files = RNA_property_collection_length(op->ptr,
|
|
|
|
|
RNA_struct_find_property(op->ptr, "files"));
|
|
|
|
|
if (tot_files > 1) {
|
|
|
|
|
sequencer_add_sound_multiple_strips(C, op, &load_data);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (!sequencer_add_sound_single_strip(C, op, &load_data)) {
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (op->customdata) {
|
|
|
|
|
MEM_freeN(op->customdata);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DEG_relations_tag_update(bmain);
|
|
|
|
|
DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
|
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
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
|
|
|
}
|
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int sequencer_add_sound_strip_invoke(bContext *C,
|
|
|
|
|
wmOperator *op,
|
|
|
|
|
const wmEvent *UNUSED(event))
|
2010-03-16 17:23:20 +00:00
|
|
|
{
|
2020-04-05 23:55:51 +02:00
|
|
|
/* This is for drag and drop. */
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((RNA_struct_property_is_set(op->ptr, "files") && RNA_collection_length(op->ptr, "files")) ||
|
2012-03-29 22:26:11 +00:00
|
|
|
RNA_struct_property_is_set(op->ptr, "filepath")) {
|
2013-02-27 01:40:36 +00:00
|
|
|
sequencer_generic_invoke_xy__internal(C, op, SEQPROP_NOPATHS, SEQ_TYPE_SOUND_RAM);
|
2010-07-21 19:49:43 +00:00
|
|
|
return sequencer_add_sound_strip_exec(C, op);
|
2010-12-11 20:01:34 +00:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-02-27 01:40:36 +00:00
|
|
|
sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_SOUND_RAM);
|
2011-10-12 00:15:19 +00:00
|
|
|
|
2010-07-01 14:08:41 +00:00
|
|
|
WM_event_add_fileselect(C, op);
|
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
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-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
|
|
|
{
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Identifiers. */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Add Sound Strip";
|
|
|
|
|
ot->idname = "SEQUENCER_OT_sound_strip_add";
|
|
|
|
|
ot->description = "Add a sound strip to the sequencer";
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Api callbacks. */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = sequencer_add_sound_strip_invoke;
|
|
|
|
|
ot->exec = sequencer_add_sound_strip_exec;
|
2014-02-26 13:21:48 +11:00
|
|
|
ot->poll = ED_operator_sequencer_active_editable;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Flags. */
|
2012-03-29 22:26:11 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-02-07 22:56:20 +11:00
|
|
|
WM_operator_properties_filesel(ot,
|
|
|
|
|
FILE_TYPE_FOLDER | FILE_TYPE_SOUND,
|
|
|
|
|
FILE_SPECIAL,
|
|
|
|
|
FILE_OPENFILE,
|
2019-11-11 13:34:40 +01:00
|
|
|
WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH | WM_FILESEL_FILES |
|
2020-03-02 09:23:55 +01:00
|
|
|
WM_FILESEL_SHOW_PROPS | WM_FILESEL_DIRECTORY,
|
2016-02-07 22:56:20 +11:00
|
|
|
FILE_DEFAULTDISPLAY,
|
2020-11-02 23:55:59 +01:00
|
|
|
FILE_SORT_DEFAULT);
|
2011-08-12 03:53:26 +00:00
|
|
|
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
|
2014-04-01 11:34:00 +11:00
|
|
|
RNA_def_boolean(ot->srna, "cache", false, "Cache", "Cache the sound in memory");
|
2016-01-09 02:35:30 +01:00
|
|
|
RNA_def_boolean(ot->srna, "mono", false, "Mono", "Merge all the sound's channels into one");
|
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
|
|
|
}
|
|
|
|
|
|
2015-06-04 20:40:11 +02:00
|
|
|
int sequencer_image_seq_get_minmax_frame(wmOperator *op,
|
|
|
|
|
int sfra,
|
|
|
|
|
int *r_minframe,
|
|
|
|
|
int *r_numdigits)
|
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
|
|
|
{
|
2015-04-20 17:35:09 +02:00
|
|
|
int minframe = INT32_MAX, maxframe = INT32_MIN;
|
2015-06-04 20:40:11 +02:00
|
|
|
int numdigits = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-20 18:07:34 +02:00
|
|
|
RNA_BEGIN (op->ptr, itemptr, "files") {
|
2015-06-04 20:40:11 +02:00
|
|
|
char *filename;
|
2015-04-20 18:07:34 +02:00
|
|
|
int frame;
|
|
|
|
|
filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-20 18:07:34 +02:00
|
|
|
if (filename) {
|
2015-06-04 20:40:11 +02:00
|
|
|
if (BLI_path_frame_get(filename, &frame, &numdigits)) {
|
2015-04-20 18:07:34 +02:00
|
|
|
minframe = min_ii(minframe, frame);
|
|
|
|
|
maxframe = max_ii(maxframe, frame);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-20 18:07:34 +02:00
|
|
|
MEM_freeN(filename);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
RNA_END;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-20 18:07:34 +02:00
|
|
|
if (minframe == INT32_MAX) {
|
|
|
|
|
minframe = sfra;
|
|
|
|
|
maxframe = minframe + 1;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-20 18:07:34 +02:00
|
|
|
*r_minframe = minframe;
|
2015-06-04 20:40:11 +02:00
|
|
|
*r_numdigits = numdigits;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-20 18:07:34 +02:00
|
|
|
return maxframe - minframe + 1;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-04 20:40:11 +02:00
|
|
|
void sequencer_image_seq_reserve_frames(
|
|
|
|
|
wmOperator *op, StripElem *se, int len, int minframe, int numdigits)
|
2015-04-20 18:07:34 +02:00
|
|
|
{
|
2015-06-04 20:40:11 +02:00
|
|
|
char *filename = NULL;
|
2015-04-20 18:07:34 +02:00
|
|
|
RNA_BEGIN (op->ptr, itemptr, "files") {
|
|
|
|
|
filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
RNA_END;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-06-04 20:40:11 +02:00
|
|
|
if (filename) {
|
|
|
|
|
char ext[PATH_MAX];
|
|
|
|
|
char filename_stripped[PATH_MAX];
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Strip the frame from filename and substitute with `#`. */
|
Fix BLI_path_frame_strip
The `BLI_path_frame_strip` function was completely broken, unless the
number of digits in the sequence number was the same as the length of
the extension. In other words, it would work fine for `file.0001.abc` (4
digit `0001` and 4 char `.abc`), but other combinations would truncate
to the shortest (`file.001.abc` would become `file.###.ab` and
`file.00001.a` would become `file.##.a`). The dependency between the
sequence number and the file extension is now removed.
The behaviour has changed a little bit in the case where there are no
numbers in the filename. Previously, `path="filename.abc"` would result
in `path="filename.abc"` and `ext=""`, but now it results in
`path="filename"` and `ext=".abc"`. This way `ext` always contains the
extension, and the behaviour is consistent regardless of whether there
were any numbers found.
Furthermore, I've removed the `bool set_frame_char` parameter, because
it was unclear, probably also buggy, and most importantly, never used.
I've also added a unit test for the `BLI_path_frame_strip` function.
2019-03-20 12:59:11 +01:00
|
|
|
BLI_path_frame_strip(filename, ext);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-09 18:41:07 +02:00
|
|
|
for (int i = 0; i < len; i++, se++) {
|
2015-06-04 20:40:11 +02:00
|
|
|
BLI_strncpy(filename_stripped, filename, sizeof(filename_stripped));
|
|
|
|
|
BLI_path_frame(filename_stripped, minframe + i, numdigits);
|
|
|
|
|
BLI_snprintf(se->name, sizeof(se->name), "%s%s", filename_stripped, ext);
|
2015-04-20 17:35:09 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-20 18:07:34 +02:00
|
|
|
MEM_freeN(filename);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
static int sequencer_add_image_strip_calculate_length(wmOperator *op,
|
|
|
|
|
const int start_frame,
|
|
|
|
|
int *minframe,
|
|
|
|
|
int *numdigits)
|
2015-04-20 18:07:34 +02:00
|
|
|
{
|
|
|
|
|
const bool use_placeholders = RNA_boolean_get(op->ptr, "use_placeholders");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-20 18:07:34 +02:00
|
|
|
if (use_placeholders) {
|
2021-03-02 12:08:16 +01:00
|
|
|
return sequencer_image_seq_get_minmax_frame(op, start_frame, minframe, numdigits);
|
2015-04-20 16:33:10 +02:00
|
|
|
}
|
2021-03-03 12:17:16 +01:00
|
|
|
return RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files"));
|
2021-03-02 12:08:16 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-02 14:21:10 +01:00
|
|
|
static void sequencer_add_image_strip_load_files(
|
|
|
|
|
wmOperator *op, Sequence *seq, SeqLoadData *load_data, const int minframe, const int numdigits)
|
2021-03-02 12:08:16 +01:00
|
|
|
{
|
|
|
|
|
const bool use_placeholders = RNA_boolean_get(op->ptr, "use_placeholders");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
SEQ_add_image_set_directory(seq, load_data->path);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-20 16:33:10 +02:00
|
|
|
if (use_placeholders) {
|
2021-03-02 12:08:16 +01:00
|
|
|
sequencer_image_seq_reserve_frames(
|
|
|
|
|
op, seq->strip->stripdata, load_data->image.len, minframe, numdigits);
|
2015-04-20 16:33:10 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2021-03-02 12:08:16 +01:00
|
|
|
size_t strip_frame = 0;
|
2015-04-20 16:33:10 +02:00
|
|
|
RNA_BEGIN (op->ptr, itemptr, "files") {
|
|
|
|
|
char *filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0);
|
2021-03-02 12:08:16 +01:00
|
|
|
SEQ_add_image_load_file(seq, strip_frame, filename);
|
2015-04-20 16:33:10 +02:00
|
|
|
MEM_freeN(filename);
|
2021-03-02 12:08:16 +01:00
|
|
|
strip_frame++;
|
2015-04-20 16:33:10 +02:00
|
|
|
}
|
|
|
|
|
RNA_END;
|
2009-06-05 16:11:35 +00:00
|
|
|
}
|
2021-03-02 12:08:16 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
Editing *ed = SEQ_editing_get(scene, true);
|
|
|
|
|
|
|
|
|
|
SeqLoadData load_data;
|
|
|
|
|
load_data_init_from_operator(&load_data, C, op);
|
|
|
|
|
|
|
|
|
|
int minframe, numdigits;
|
|
|
|
|
load_data.image.len = sequencer_add_image_strip_calculate_length(
|
|
|
|
|
op, load_data.start_frame, &minframe, &numdigits);
|
|
|
|
|
if (load_data.image.len == 0) {
|
|
|
|
|
return OPERATOR_CANCELLED;
|
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
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
if (RNA_boolean_get(op->ptr, "replace_sel")) {
|
|
|
|
|
ED_sequencer_deselect_all(scene);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
Sequence *seq = SEQ_add_image_strip(CTX_data_main(C), scene, ed->seqbasep, &load_data);
|
2021-03-02 14:21:10 +01:00
|
|
|
sequencer_add_image_strip_load_files(op, seq, &load_data, minframe, numdigits);
|
2021-03-02 12:08:16 +01:00
|
|
|
SEQ_add_image_init_alpha_mode(seq);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
/* Adjust length. */
|
|
|
|
|
if (load_data.image.len == 1) {
|
|
|
|
|
SEQ_transform_set_right_handle_frame(seq, load_data.image.end_frame);
|
|
|
|
|
SEQ_time_update_sequence(scene, seq);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
seq_load_apply_generic_options(C, op, seq);
|
|
|
|
|
|
2019-06-04 16:52:48 +02:00
|
|
|
DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
|
2012-03-29 22:26:11 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
if (op->customdata) {
|
|
|
|
|
MEM_freeN(op->customdata);
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int sequencer_add_image_strip_invoke(bContext *C,
|
|
|
|
|
wmOperator *op,
|
|
|
|
|
const wmEvent *UNUSED(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
|
|
|
{
|
2015-04-06 10:40:12 -03:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
|
2020-12-16 20:34:26 +01:00
|
|
|
const SequencerToolSettings *tool_settings = scene->toolsettings->sequencer_tool_settings;
|
|
|
|
|
RNA_enum_set(op->ptr, "fit_method", tool_settings->fit_method);
|
|
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Name set already by drag and drop. */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (RNA_struct_property_is_set(op->ptr, "files") && RNA_collection_length(op->ptr, "files")) {
|
2013-02-27 01:40:36 +00:00
|
|
|
sequencer_generic_invoke_xy__internal(
|
|
|
|
|
C, op, SEQPROP_ENDFRAME | SEQPROP_NOPATHS, SEQ_TYPE_IMAGE);
|
2010-12-11 20:01:34 +00:00
|
|
|
return sequencer_add_image_strip_exec(C, op);
|
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-02-27 01:40:36 +00:00
|
|
|
sequencer_generic_invoke_xy__internal(C, op, SEQPROP_ENDFRAME, SEQ_TYPE_IMAGE);
|
2015-04-06 10:40:12 -03:00
|
|
|
sequencer_add_init(C, op);
|
|
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Show multiview save options only if scene use multiview. */
|
2015-04-06 10:40:12 -03:00
|
|
|
prop = RNA_struct_find_property(op->ptr, "show_multiview");
|
|
|
|
|
RNA_property_boolean_set(op->ptr, prop, (scene->r.scemode & R_MULTIVIEW) != 0);
|
|
|
|
|
|
2010-07-01 14:08:41 +00:00
|
|
|
WM_event_add_fileselect(C, op);
|
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
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-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
|
|
|
{
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Identifiers. */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Add Image Strip";
|
|
|
|
|
ot->idname = "SEQUENCER_OT_image_strip_add";
|
|
|
|
|
ot->description = "Add an image or image sequence to the sequencer";
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Api callbacks. */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = sequencer_add_image_strip_invoke;
|
|
|
|
|
ot->exec = sequencer_add_image_strip_exec;
|
2015-04-06 10:40:12 -03:00
|
|
|
ot->cancel = sequencer_add_cancel;
|
|
|
|
|
ot->ui = sequencer_add_draw;
|
2014-02-26 13:21:48 +11:00
|
|
|
ot->poll = ED_operator_sequencer_active_editable;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Flags. */
|
2012-03-29 22:26:11 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-02-07 22:56:20 +11:00
|
|
|
WM_operator_properties_filesel(ot,
|
|
|
|
|
FILE_TYPE_FOLDER | FILE_TYPE_IMAGE,
|
|
|
|
|
FILE_SPECIAL,
|
|
|
|
|
FILE_OPENFILE,
|
2019-11-11 13:34:40 +01:00
|
|
|
WM_FILESEL_DIRECTORY | WM_FILESEL_RELPATH | WM_FILESEL_FILES |
|
2020-03-02 09:23:55 +01:00
|
|
|
WM_FILESEL_SHOW_PROPS | WM_FILESEL_DIRECTORY,
|
2016-02-07 22:56:20 +11:00
|
|
|
FILE_DEFAULTDISPLAY,
|
2020-11-02 23:55:59 +01:00
|
|
|
FILE_SORT_DEFAULT);
|
2020-12-16 20:34:26 +01:00
|
|
|
sequencer_generic_props__internal(ot,
|
|
|
|
|
SEQPROP_STARTFRAME | SEQPROP_ENDFRAME | SEQPROP_FIT_METHOD);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-20 16:33:10 +02:00
|
|
|
RNA_def_boolean(ot->srna,
|
|
|
|
|
"use_placeholders",
|
|
|
|
|
false,
|
|
|
|
|
"Use Placeholders",
|
|
|
|
|
"Use placeholders for missing frames of the 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
|
|
|
}
|
|
|
|
|
|
2009-01-26 09:13:15 +00:00
|
|
|
static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
2012-03-29 22:26:11 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2020-12-19 05:57:27 +01:00
|
|
|
Editing *ed = SEQ_editing_get(scene, true);
|
2012-03-29 22:26:11 +00:00
|
|
|
const char *error_msg;
|
2009-01-26 09:13:15 +00:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
SeqLoadData load_data;
|
|
|
|
|
load_data_init_from_operator(&load_data, C, op);
|
|
|
|
|
load_data.effect.type = RNA_enum_get(op->ptr, "type");
|
2009-01-26 09:13:15 +00:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
Sequence *seq1, *seq2, *seq3;
|
|
|
|
|
if (!seq_effect_find_selected(
|
|
|
|
|
scene, NULL, load_data.effect.type, &seq1, &seq2, &seq3, &error_msg)) {
|
2009-01-26 09:13:15 +00:00
|
|
|
BKE_report(op->reports, RPT_ERROR, error_msg);
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
if (RNA_boolean_get(op->ptr, "replace_sel")) {
|
|
|
|
|
ED_sequencer_deselect_all(scene);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2009-11-29 18:14:16 +00:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
load_data.effect.seq1 = seq1;
|
|
|
|
|
load_data.effect.seq2 = seq2;
|
|
|
|
|
load_data.effect.seq3 = seq3;
|
2010-07-04 08:49:54 +00:00
|
|
|
|
2020-04-06 09:57:56 +02:00
|
|
|
/* Set channel. If unset, use lowest free one above strips. */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!RNA_struct_property_is_set(op->ptr, "channel")) {
|
2021-03-02 12:08:16 +01:00
|
|
|
if (seq1 != NULL) {
|
|
|
|
|
int chan = max_iii(
|
|
|
|
|
seq1 ? seq1->machine : 0, seq2 ? seq2->machine : 0, seq3 ? seq3->machine : 0);
|
2019-03-26 21:16:47 +11:00
|
|
|
if (chan < MAXSEQ) {
|
2021-03-02 12:08:16 +01:00
|
|
|
load_data.channel = chan;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2011-06-20 04:09:33 +00:00
|
|
|
}
|
2009-01-26 09:13:15 +00:00
|
|
|
}
|
|
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
Sequence *seq = SEQ_add_effect_strip(scene, ed->seqbasep, &load_data);
|
|
|
|
|
seq_load_apply_generic_options(C, op, seq);
|
2009-01-26 09:13:15 +00:00
|
|
|
|
2021-03-02 12:08:16 +01:00
|
|
|
if (seq->type == SEQ_TYPE_COLOR) {
|
|
|
|
|
SolidColorVars *colvars = (SolidColorVars *)seq->effectdata;
|
|
|
|
|
RNA_float_get_array(op->ptr, "color", colvars->col);
|
|
|
|
|
}
|
2009-01-26 09:13:15 +00:00
|
|
|
|
2019-06-04 16:52:48 +02:00
|
|
|
DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
|
2018-06-04 09:31:30 +02:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
|
2009-01-26 09:13:15 +00:00
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int sequencer_add_effect_strip_invoke(bContext *C,
|
|
|
|
|
wmOperator *op,
|
|
|
|
|
const wmEvent *UNUSED(event))
|
2009-01-26 09:13:15 +00:00
|
|
|
{
|
2014-04-11 11:25:41 +10:00
|
|
|
bool is_type_set = RNA_struct_property_is_set(op->ptr, "type");
|
2012-03-29 22:26:11 +00:00
|
|
|
int type = -1;
|
2016-07-15 15:45:45 +10:00
|
|
|
int prop_flag = SEQPROP_ENDFRAME | SEQPROP_NOPATHS;
|
2011-06-20 04:09:33 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (is_type_set) {
|
2012-03-29 22:26:11 +00:00
|
|
|
type = RNA_enum_get(op->ptr, "type");
|
2011-06-20 04:09:33 +00:00
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* When invoking an effect strip which uses inputs, skip initializing the channel from the
|
|
|
|
|
* mouse. */
|
2020-12-19 05:57:27 +01:00
|
|
|
if (SEQ_effect_get_num_inputs(type) != 0) {
|
2011-06-20 04:09:33 +00:00
|
|
|
prop_flag |= SEQPROP_NOCHAN;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-27 01:40:36 +00:00
|
|
|
sequencer_generic_invoke_xy__internal(C, op, prop_flag, type);
|
2009-01-26 09:13:15 +00:00
|
|
|
|
2012-05-29 10:21:07 +00:00
|
|
|
return sequencer_add_effect_strip_exec(C, op);
|
2009-01-26 09:13:15 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
{
|
2020-01-22 02:07:54 +01:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Identifiers. */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Add Effect Strip";
|
|
|
|
|
ot->idname = "SEQUENCER_OT_effect_strip_add";
|
|
|
|
|
ot->description = "Add an effect to the sequencer, most are applied on top of existing strips";
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Api callbacks. */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = sequencer_add_effect_strip_invoke;
|
|
|
|
|
ot->exec = sequencer_add_effect_strip_exec;
|
2014-02-26 13:21:48 +11:00
|
|
|
ot->poll = ED_operator_sequencer_active_editable;
|
2020-01-22 02:07:54 +01:00
|
|
|
ot->poll_property = seq_effect_add_properties_poll;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-05 23:55:51 +02:00
|
|
|
/* Flags. */
|
2012-03-29 22:26:11 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-07 15:49:02 +00:00
|
|
|
RNA_def_enum(ot->srna,
|
|
|
|
|
"type",
|
|
|
|
|
sequencer_prop_effect_types,
|
2019-09-29 16:17:48 -07:00
|
|
|
SEQ_TYPE_CROSS,
|
2012-06-07 15:49:02 +00:00
|
|
|
"Type",
|
|
|
|
|
"Sequencer effect type");
|
2020-01-22 02:07:54 +01:00
|
|
|
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME | SEQPROP_ENDFRAME);
|
2021-02-24 13:25:44 -06:00
|
|
|
/* Only used when strip is of the Color type. */
|
2020-01-22 02:07:54 +01:00
|
|
|
prop = RNA_def_float_color(ot->srna,
|
|
|
|
|
"color",
|
|
|
|
|
3,
|
|
|
|
|
NULL,
|
|
|
|
|
0.0f,
|
|
|
|
|
1.0f,
|
|
|
|
|
"Color",
|
2021-02-24 13:25:44 -06:00
|
|
|
"Initialize the strip with this color",
|
2020-01-22 02:07:54 +01:00
|
|
|
0.0f,
|
|
|
|
|
1.0f);
|
|
|
|
|
RNA_def_property_subtype(prop, PROP_COLOR_GAMMA);
|
2009-01-26 09:13:15 +00:00
|
|
|
}
|