2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-12-21 08:02:24 +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
|
2018-06-01 18:19:39 +02:00
|
|
|
* of the License, or (at your option) any later version.
|
2008-12-21 08:02:24 +00:00
|
|
|
*
|
|
|
|
* 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.
|
2008-12-21 08:02:24 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup edanimation
|
2011-02-27 20:29:51 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2008-12-21 08:02:24 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
2013-05-28 19:35:26 +00:00
|
|
|
#include "BLI_sys_types.h"
|
2010-08-31 11:31:21 +00:00
|
|
|
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2014-01-15 13:00:03 +11:00
|
|
|
#include "BLI_math_base.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
|
2009-10-03 04:21:38 +00:00
|
|
|
#include "DNA_anim_types.h"
|
2008-12-21 08:02:24 +00:00
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
|
|
|
#include "BKE_context.h"
|
2014-11-24 18:18:35 +01:00
|
|
|
#include "BKE_sequencer.h"
|
2011-04-07 15:48:33 +00:00
|
|
|
#include "BKE_global.h"
|
2011-09-05 19:34:27 +00:00
|
|
|
#include "BKE_main.h"
|
2009-10-03 04:21:38 +00:00
|
|
|
#include "BKE_sound.h"
|
2018-07-30 16:16:44 +10:00
|
|
|
#include "BKE_scene.h"
|
2008-12-21 08:02:24 +00:00
|
|
|
|
|
|
|
#include "UI_view2d.h"
|
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
#include "RNA_define.h"
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
2011-02-13 10:52:18 +00:00
|
|
|
#include "ED_anim_api.h"
|
2008-12-21 08:02:24 +00:00
|
|
|
#include "ED_screen.h"
|
2015-01-05 02:12:50 +11:00
|
|
|
#include "ED_sequencer.h"
|
Implement grouped undo option for operators
This option makes an operator to not push a task to the undo stack if the previous stored elemen is the same operator or part of the same undo group.
The main usage is for animation, so you can change frames to inspect the
poses, and revert the previous pose without having to roll back tons of
"change frame" operator, or even see the undo stack full.
This complements rB13ee9b8e
Design with help by Sergey Sharybin.
Reviewers: sergey, mont29
Reviewed By: mont29, sergey
Subscribers: pyc0d3r, hjalti, Severin, lowercase, brecht, monio, aligorith, hadrien, jbakker
Differential Revision: https://developer.blender.org/D2330
2016-11-15 11:50:11 +01:00
|
|
|
#include "ED_util.h"
|
2008-12-21 08:02:24 +00:00
|
|
|
|
2009-10-03 04:21:38 +00:00
|
|
|
#include "anim_intern.h"
|
2009-08-09 21:16:39 +00:00
|
|
|
|
2008-12-21 08:02:24 +00:00
|
|
|
/* ********************** frame change operator ***************************/
|
|
|
|
|
2009-10-20 12:04:56 +00:00
|
|
|
/* Check if the operator can be run from the current context */
|
2018-07-02 11:47:00 +02:00
|
|
|
static bool change_frame_poll(bContext *C)
|
2009-10-20 12:04:56 +00:00
|
|
|
{
|
2013-01-05 11:56:20 +00:00
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2011-04-07 15:48:33 +00:00
|
|
|
/* XXX temp? prevent changes during render */
|
2014-04-01 11:34:00 +11:00
|
|
|
if (G.is_rendering) return false;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-01-05 11:56:20 +00:00
|
|
|
/* although it's only included in keymaps for regions using ED_KEYMAP_ANIMATION,
|
|
|
|
* this shouldn't show up in 3D editor (or others without 2D timeline view) via search
|
2009-10-20 12:04:56 +00:00
|
|
|
*/
|
2013-01-05 11:56:20 +00:00
|
|
|
if (sa) {
|
2018-04-20 17:17:10 +02:00
|
|
|
if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_NLA, SPACE_SEQ, SPACE_CLIP)) {
|
2014-04-01 11:34:00 +11:00
|
|
|
return true;
|
2013-01-05 11:56:20 +00:00
|
|
|
}
|
2019-02-16 16:42:11 +11:00
|
|
|
else if (sa->spacetype == SPACE_GRAPH) {
|
2013-01-05 11:56:20 +00:00
|
|
|
/* NOTE: Graph Editor has special version which does some extra stuff.
|
|
|
|
* No need to show the generic error message for that case though!
|
|
|
|
*/
|
2014-04-01 11:34:00 +11:00
|
|
|
return false;
|
2013-01-05 11:56:20 +00:00
|
|
|
}
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2018-04-20 17:17:10 +02:00
|
|
|
CTX_wm_operator_poll_msg_set(C, "Expected an animation area to be active");
|
2014-04-01 11:34:00 +11:00
|
|
|
return false;
|
2009-10-20 12:04:56 +00:00
|
|
|
}
|
|
|
|
|
2008-12-21 08:02:24 +00:00
|
|
|
/* Set the new frame number */
|
|
|
|
static void change_frame_apply(bContext *C, wmOperator *op)
|
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2017-02-15 16:19:05 +01:00
|
|
|
float frame = RNA_float_get(op->ptr, "frame");
|
2014-11-24 18:18:35 +01:00
|
|
|
bool do_snap = RNA_boolean_get(op->ptr, "snap");
|
|
|
|
|
2018-07-30 16:16:44 +10:00
|
|
|
if (do_snap) {
|
|
|
|
if (CTX_wm_space_seq(C)) {
|
|
|
|
frame = BKE_sequencer_find_next_prev_edit(scene, frame, SEQ_SIDE_BOTH, true, false, false);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
frame = BKE_scene_frame_snap_by_seconds(scene, 1.0, frame);
|
|
|
|
}
|
2014-11-24 18:18:35 +01:00
|
|
|
}
|
|
|
|
|
2009-10-20 12:04:56 +00:00
|
|
|
/* set the new frame number */
|
2017-02-15 16:19:05 +01:00
|
|
|
if (scene->r.flag & SCER_SHOW_SUBFRAME) {
|
2017-03-10 13:38:02 +13:00
|
|
|
CFRA = (int)frame;
|
2017-02-15 16:19:05 +01:00
|
|
|
SUBFRA = frame - (int)frame;
|
|
|
|
}
|
|
|
|
else {
|
2017-09-27 11:13:03 +10:00
|
|
|
CFRA = round_fl_to_int(frame);
|
2017-02-15 16:19:05 +01:00
|
|
|
SUBFRA = 0.0f;
|
|
|
|
}
|
2010-02-18 00:29:08 +00:00
|
|
|
FRAMENUMBER_MIN_CLAMP(CFRA);
|
2017-02-15 16:19:05 +01:00
|
|
|
|
2009-10-20 12:04:56 +00:00
|
|
|
/* do updates */
|
2015-03-26 11:35:41 +01:00
|
|
|
BKE_sound_seek_scene(bmain, scene);
|
2012-05-08 15:30:00 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
|
2008-12-21 08:02:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---- */
|
|
|
|
|
|
|
|
/* Non-modal callback for running operator without user input */
|
|
|
|
static int change_frame_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
change_frame_apply(C, op);
|
2009-08-09 21:16:39 +00:00
|
|
|
|
2008-12-21 08:02:24 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---- */
|
|
|
|
|
|
|
|
/* Get frame from mouse coordinates */
|
2017-02-15 16:19:05 +01:00
|
|
|
static float frame_from_event(bContext *C, const wmEvent *event)
|
2008-12-21 08:02:24 +00:00
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
ARegion *region = CTX_wm_region(C);
|
2013-10-13 20:46:02 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2017-02-15 16:19:05 +01:00
|
|
|
float frame;
|
2011-05-20 07:40:05 +00:00
|
|
|
|
2008-12-21 08:02:24 +00:00
|
|
|
/* convert from region coordinates to View2D 'tot' space */
|
2017-03-10 13:38:02 +13:00
|
|
|
frame = UI_view2d_region_to_view_x(®ion->v2d, event->mval[0]);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2017-03-10 13:38:02 +13:00
|
|
|
/* respect preview range restrictions (if only allowed to move around within that range) */
|
2013-10-13 20:46:02 +00:00
|
|
|
if (scene->r.flag & SCER_LOCK_FRAME_SELECTION) {
|
|
|
|
CLAMP(frame, PSFRA, PEFRA);
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-10-13 20:46:02 +00:00
|
|
|
return frame;
|
2008-12-21 08:02:24 +00:00
|
|
|
}
|
|
|
|
|
2015-01-05 02:12:50 +11:00
|
|
|
static void change_frame_seq_preview_begin(bContext *C, const wmEvent *event)
|
|
|
|
{
|
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
2015-08-07 15:39:32 +02:00
|
|
|
bScreen *screen = CTX_wm_screen(C);
|
2015-01-05 02:12:50 +11:00
|
|
|
if (sa && sa->spacetype == SPACE_SEQ) {
|
|
|
|
SpaceSeq *sseq = sa->spacedata.first;
|
|
|
|
if (ED_space_sequencer_check_show_strip(sseq)) {
|
|
|
|
ED_sequencer_special_preview_set(C, event->mval);
|
|
|
|
}
|
|
|
|
}
|
2015-08-07 15:39:32 +02:00
|
|
|
if (screen)
|
|
|
|
screen->scrubbing = true;
|
2015-01-05 02:12:50 +11:00
|
|
|
}
|
2015-08-01 23:55:33 +02:00
|
|
|
|
2015-01-05 02:12:50 +11:00
|
|
|
static void change_frame_seq_preview_end(bContext *C)
|
|
|
|
{
|
2015-08-01 23:55:33 +02:00
|
|
|
bScreen *screen = CTX_wm_screen(C);
|
|
|
|
bool notify = false;
|
|
|
|
|
|
|
|
if (screen->scrubbing) {
|
|
|
|
screen->scrubbing = false;
|
|
|
|
notify = true;
|
|
|
|
}
|
|
|
|
|
2015-01-05 02:12:50 +11:00
|
|
|
if (ED_sequencer_special_preview_get() != NULL) {
|
|
|
|
ED_sequencer_special_preview_clear();
|
2015-08-01 23:55:33 +02:00
|
|
|
notify = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (notify) {
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2015-01-05 02:12:50 +11:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-21 08:02:24 +00:00
|
|
|
/* Modal Operator init */
|
2013-03-13 09:03:46 +00:00
|
|
|
static int change_frame_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
2008-12-21 08:02:24 +00:00
|
|
|
{
|
|
|
|
/* Change to frame that mouse is over before adding modal handler,
|
|
|
|
* as user could click on a single frame (jump to frame) as well as
|
|
|
|
* click-dragging over a range (modal scrubbing).
|
|
|
|
*/
|
2017-02-15 16:19:05 +01:00
|
|
|
RNA_float_set(op->ptr, "frame", frame_from_event(C, event));
|
2014-11-24 18:18:35 +01:00
|
|
|
|
2015-01-05 02:12:50 +11:00
|
|
|
change_frame_seq_preview_begin(C, event);
|
|
|
|
|
2008-12-21 08:02:24 +00:00
|
|
|
change_frame_apply(C, op);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-21 08:02:24 +00:00
|
|
|
/* add temp handler */
|
2009-09-18 12:43:36 +00:00
|
|
|
WM_event_add_modal_handler(C, op);
|
2008-12-21 08:02:24 +00:00
|
|
|
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
}
|
|
|
|
|
2015-01-05 02:12:50 +11:00
|
|
|
static void change_frame_cancel(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
{
|
|
|
|
change_frame_seq_preview_end(C);
|
|
|
|
}
|
|
|
|
|
2008-12-21 08:02:24 +00:00
|
|
|
/* Modal event handling of frame changing */
|
2013-03-13 09:03:46 +00:00
|
|
|
static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
2008-12-21 08:02:24 +00:00
|
|
|
{
|
2015-01-05 02:12:50 +11:00
|
|
|
int ret = OPERATOR_RUNNING_MODAL;
|
2008-12-21 08:02:24 +00:00
|
|
|
/* execute the events */
|
|
|
|
switch (event->type) {
|
2009-02-09 03:06:52 +00:00
|
|
|
case ESCKEY:
|
2015-01-05 02:12:50 +11:00
|
|
|
ret = OPERATOR_FINISHED;
|
|
|
|
break;
|
|
|
|
|
2008-12-21 08:02:24 +00:00
|
|
|
case MOUSEMOVE:
|
2017-02-15 16:19:05 +01:00
|
|
|
RNA_float_set(op->ptr, "frame", frame_from_event(C, event));
|
2008-12-21 08:02:24 +00:00
|
|
|
change_frame_apply(C, op);
|
|
|
|
break;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
|
|
|
case LEFTMOUSE:
|
2009-02-09 03:06:52 +00:00
|
|
|
case RIGHTMOUSE:
|
2014-08-18 16:37:01 +02:00
|
|
|
case MIDDLEMOUSE:
|
2018-11-16 08:28:58 +11:00
|
|
|
/* We check for either mouse-button to end, to work with all user keymaps. */
|
2012-05-08 15:30:00 +00:00
|
|
|
if (event->val == KM_RELEASE)
|
2015-01-05 02:12:50 +11:00
|
|
|
ret = OPERATOR_FINISHED;
|
2008-12-21 08:02:24 +00:00
|
|
|
break;
|
2014-11-24 18:18:35 +01:00
|
|
|
|
|
|
|
case LEFTCTRLKEY:
|
|
|
|
case RIGHTCTRLKEY:
|
|
|
|
if (event->val == KM_RELEASE) {
|
|
|
|
RNA_boolean_set(op->ptr, "snap", false);
|
|
|
|
}
|
|
|
|
else if (event->val == KM_PRESS) {
|
|
|
|
RNA_boolean_set(op->ptr, "snap", true);
|
|
|
|
}
|
|
|
|
break;
|
2008-12-21 08:02:24 +00:00
|
|
|
}
|
|
|
|
|
2015-01-08 20:14:42 +11:00
|
|
|
if (ret != OPERATOR_RUNNING_MODAL) {
|
2015-01-05 02:12:50 +11:00
|
|
|
change_frame_seq_preview_end(C);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2008-12-21 08:02:24 +00:00
|
|
|
}
|
|
|
|
|
2011-02-13 10:52:18 +00:00
|
|
|
static void ANIM_OT_change_frame(wmOperatorType *ot)
|
2008-12-21 08:02:24 +00:00
|
|
|
{
|
2014-11-24 18:18:35 +01:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2008-12-21 08:02:24 +00:00
|
|
|
/* identifiers */
|
2013-01-05 11:56:20 +00:00
|
|
|
ot->name = "Change Frame";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->idname = "ANIM_OT_change_frame";
|
|
|
|
ot->description = "Interactively change the current frame number";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-21 08:02:24 +00:00
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = change_frame_exec;
|
|
|
|
ot->invoke = change_frame_invoke;
|
2015-01-05 02:12:50 +11:00
|
|
|
ot->cancel = change_frame_cancel;
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->modal = change_frame_modal;
|
|
|
|
ot->poll = change_frame_poll;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-07-11 14:51:13 +00:00
|
|
|
/* flags */
|
Implement grouped undo option for operators
This option makes an operator to not push a task to the undo stack if the previous stored elemen is the same operator or part of the same undo group.
The main usage is for animation, so you can change frames to inspect the
poses, and revert the previous pose without having to roll back tons of
"change frame" operator, or even see the undo stack full.
This complements rB13ee9b8e
Design with help by Sergey Sharybin.
Reviewers: sergey, mont29
Reviewed By: mont29, sergey
Subscribers: pyc0d3r, hjalti, Severin, lowercase, brecht, monio, aligorith, hadrien, jbakker
Differential Revision: https://developer.blender.org/D2330
2016-11-15 11:50:11 +01:00
|
|
|
ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR | OPTYPE_UNDO_GROUPED;
|
2018-06-13 18:38:38 +02:00
|
|
|
ot->undo_group = "Frame Change";
|
2008-12-21 08:02:24 +00:00
|
|
|
|
|
|
|
/* rna */
|
2017-02-15 16:19:05 +01:00
|
|
|
ot->prop = RNA_def_float(ot->srna, "frame", 0, MINAFRAME, MAXFRAME, "Frame", "", MINAFRAME, MAXFRAME);
|
2014-11-24 18:18:35 +01:00
|
|
|
prop = RNA_def_boolean(ot->srna, "snap", false, "Snap", "");
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
2008-12-21 08:02:24 +00:00
|
|
|
}
|
|
|
|
|
2018-04-19 16:51:16 +02:00
|
|
|
|
|
|
|
/* ****************** Start/End Frame Operators *******************************/
|
|
|
|
|
2018-07-02 12:03:56 +02:00
|
|
|
static bool anim_set_end_frames_poll(bContext *C)
|
2018-04-20 17:17:10 +02:00
|
|
|
{
|
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
2018-06-04 09:39:04 +02:00
|
|
|
|
2018-04-20 17:17:10 +02:00
|
|
|
/* XXX temp? prevent changes during render */
|
|
|
|
if (G.is_rendering) return false;
|
2018-06-04 09:39:04 +02:00
|
|
|
|
2018-04-20 17:17:10 +02:00
|
|
|
/* although it's only included in keymaps for regions using ED_KEYMAP_ANIMATION,
|
|
|
|
* this shouldn't show up in 3D editor (or others without 2D timeline view) via search
|
|
|
|
*/
|
|
|
|
if (sa) {
|
2019-02-16 16:42:11 +11:00
|
|
|
if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA, SPACE_SEQ, SPACE_CLIP)) {
|
2018-04-20 17:17:10 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2018-06-04 09:39:04 +02:00
|
|
|
|
2018-04-20 17:17:10 +02:00
|
|
|
CTX_wm_operator_poll_msg_set(C, "Expected an animation area to be active");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-04-19 16:51:16 +02:00
|
|
|
static int anim_set_sfra_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
{
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
int frame;
|
|
|
|
|
|
|
|
if (scene == NULL)
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
frame = CFRA;
|
|
|
|
|
|
|
|
/* if Preview Range is defined, set the 'start' frame for that */
|
|
|
|
if (PRVRANGEON)
|
|
|
|
scene->r.psfra = frame;
|
|
|
|
else
|
|
|
|
scene->r.sfra = frame;
|
2018-06-04 09:39:04 +02:00
|
|
|
|
2018-04-19 16:51:16 +02:00
|
|
|
if (PEFRA < frame) {
|
|
|
|
if (PRVRANGEON)
|
|
|
|
scene->r.pefra = frame;
|
|
|
|
else
|
|
|
|
scene->r.efra = frame;
|
|
|
|
}
|
2018-06-04 09:39:04 +02:00
|
|
|
|
2018-04-19 16:51:16 +02:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
|
2018-06-04 09:39:04 +02:00
|
|
|
|
2018-04-19 16:51:16 +02:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ANIM_OT_start_frame_set(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Set Start Frame";
|
2018-04-21 00:34:19 +02:00
|
|
|
ot->idname = "ANIM_OT_start_frame_set";
|
2018-06-14 12:48:37 +02:00
|
|
|
ot->description = "Set the current frame as the preview or scene start frame";
|
2018-06-04 09:39:04 +02:00
|
|
|
|
2018-04-19 16:51:16 +02:00
|
|
|
/* api callbacks */
|
|
|
|
ot->exec = anim_set_sfra_exec;
|
2018-04-20 17:17:10 +02:00
|
|
|
ot->poll = anim_set_end_frames_poll;
|
2018-06-04 09:39:04 +02:00
|
|
|
|
2018-04-19 16:51:16 +02:00
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2018-06-04 09:39:04 +02:00
|
|
|
}
|
2018-04-19 16:51:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
static int anim_set_efra_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
{
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
int frame;
|
|
|
|
|
|
|
|
if (scene == NULL)
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
frame = CFRA;
|
|
|
|
|
|
|
|
/* if Preview Range is defined, set the 'end' frame for that */
|
|
|
|
if (PRVRANGEON)
|
|
|
|
scene->r.pefra = frame;
|
|
|
|
else
|
|
|
|
scene->r.efra = frame;
|
|
|
|
|
|
|
|
if (PSFRA > frame) {
|
|
|
|
if (PRVRANGEON)
|
|
|
|
scene->r.psfra = frame;
|
|
|
|
else
|
|
|
|
scene->r.sfra = frame;
|
|
|
|
}
|
2018-06-04 09:39:04 +02:00
|
|
|
|
2018-04-19 16:51:16 +02:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
|
2018-06-04 09:39:04 +02:00
|
|
|
|
2018-04-19 16:51:16 +02:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ANIM_OT_end_frame_set(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Set End Frame";
|
2018-04-21 00:34:19 +02:00
|
|
|
ot->idname = "ANIM_OT_end_frame_set";
|
2018-06-14 12:48:37 +02:00
|
|
|
ot->description = "Set the current frame as the preview or scene end frame";
|
2018-06-04 09:39:04 +02:00
|
|
|
|
2018-04-19 16:51:16 +02:00
|
|
|
/* api callbacks */
|
|
|
|
ot->exec = anim_set_efra_exec;
|
2018-04-20 17:17:10 +02:00
|
|
|
ot->poll = anim_set_end_frames_poll;
|
2018-06-04 09:39:04 +02:00
|
|
|
|
2018-04-19 16:51:16 +02:00
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
}
|
|
|
|
|
2008-12-21 08:45:13 +00:00
|
|
|
/* ****************** set preview range operator ****************************/
|
|
|
|
|
|
|
|
static int previewrange_define_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
ARegion *ar = CTX_wm_region(C);
|
2008-12-21 08:45:13 +00:00
|
|
|
float sfra, efra;
|
2012-08-08 20:38:55 +00:00
|
|
|
rcti rect;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2018-10-05 10:27:04 +10:00
|
|
|
/* get min/max values from box select rect (already in region coordinates, not screen) */
|
2012-08-08 20:38:55 +00:00
|
|
|
WM_operator_properties_border_to_rcti(op, &rect);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-21 11:56:42 +00:00
|
|
|
/* convert min/max values to frames (i.e. region to 'tot' rect) */
|
2014-04-21 16:47:16 +10:00
|
|
|
sfra = UI_view2d_region_to_view_x(&ar->v2d, rect.xmin);
|
|
|
|
efra = UI_view2d_region_to_view_x(&ar->v2d, rect.xmax);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
|
|
|
/* set start/end frames for preview-range
|
2018-11-14 12:53:15 +11:00
|
|
|
* - must clamp within allowable limits
|
|
|
|
* - end must not be before start (though this won't occur most of the time)
|
2008-12-21 08:45:13 +00:00
|
|
|
*/
|
2011-06-08 10:57:24 +00:00
|
|
|
FRAMENUMBER_MIN_CLAMP(sfra);
|
|
|
|
FRAMENUMBER_MIN_CLAMP(efra);
|
2012-05-08 15:30:00 +00:00
|
|
|
if (efra < sfra) efra = sfra;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2010-01-19 20:30:04 +00:00
|
|
|
scene->r.flag |= SCER_PRV_RANGE;
|
2017-09-27 11:13:03 +10:00
|
|
|
scene->r.psfra = round_fl_to_int(sfra);
|
|
|
|
scene->r.pefra = round_fl_to_int(efra);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-11-17 10:12:35 +00:00
|
|
|
/* send notifiers */
|
2012-05-08 15:30:00 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-21 08:45:13 +00:00
|
|
|
return OPERATOR_FINISHED;
|
2018-06-04 09:31:30 +02:00
|
|
|
}
|
2008-12-21 08:45:13 +00:00
|
|
|
|
2011-02-13 10:52:18 +00:00
|
|
|
static void ANIM_OT_previewrange_set(wmOperatorType *ot)
|
2008-12-21 08:45:13 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Set Preview Range";
|
|
|
|
ot->idname = "ANIM_OT_previewrange_set";
|
|
|
|
ot->description = "Interactively define frame range used for playback";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-21 08:45:13 +00:00
|
|
|
/* api callbacks */
|
2018-10-05 10:27:04 +10:00
|
|
|
ot->invoke = WM_gesture_box_invoke;
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = previewrange_define_exec;
|
2018-10-05 10:27:04 +10:00
|
|
|
ot->modal = WM_gesture_box_modal;
|
|
|
|
ot->cancel = WM_gesture_box_cancel;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = ED_operator_animview_active;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-01-31 19:40:40 +00:00
|
|
|
/* flags */
|
2012-05-08 15:30:00 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-21 08:45:13 +00:00
|
|
|
/* rna */
|
2012-08-08 20:38:55 +00:00
|
|
|
/* used to define frame range.
|
|
|
|
*
|
|
|
|
* note: border Y values are not used,
|
2018-10-05 10:27:04 +10:00
|
|
|
* but are needed by box_select gesture operator stuff */
|
2012-08-08 20:38:55 +00:00
|
|
|
WM_operator_properties_border(ot);
|
2008-12-21 08:45:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ****************** clear preview range operator ****************************/
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int previewrange_clear_exec(bContext *C, wmOperator *UNUSED(op))
|
2008-12-21 08:45:13 +00:00
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
ScrArea *curarea = CTX_wm_area(C);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-21 08:45:13 +00:00
|
|
|
/* sanity checks */
|
|
|
|
if (ELEM(NULL, scene, curarea))
|
|
|
|
return OPERATOR_CANCELLED;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-21 08:45:13 +00:00
|
|
|
/* simply clear values */
|
2010-01-19 20:30:04 +00:00
|
|
|
scene->r.flag &= ~SCER_PRV_RANGE;
|
2012-05-08 15:30:00 +00:00
|
|
|
scene->r.psfra = 0;
|
|
|
|
scene->r.pefra = 0;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-21 08:45:13 +00:00
|
|
|
ED_area_tag_redraw(curarea);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2014-02-19 13:33:47 +01:00
|
|
|
/* send notifiers */
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-21 08:45:13 +00:00
|
|
|
return OPERATOR_FINISHED;
|
2018-06-04 09:31:30 +02:00
|
|
|
}
|
2008-12-21 08:45:13 +00:00
|
|
|
|
2011-02-13 10:52:18 +00:00
|
|
|
static void ANIM_OT_previewrange_clear(wmOperatorType *ot)
|
2008-12-21 08:45:13 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Clear Preview Range";
|
|
|
|
ot->idname = "ANIM_OT_previewrange_clear";
|
|
|
|
ot->description = "Clear Preview Range";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-21 08:45:13 +00:00
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = previewrange_clear_exec;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = ED_operator_animview_active;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-01-31 19:40:40 +00:00
|
|
|
/* flags */
|
2012-05-08 15:30:00 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2008-12-21 08:45:13 +00:00
|
|
|
}
|
|
|
|
|
2008-12-21 08:02:24 +00:00
|
|
|
/* ************************** registration **********************************/
|
|
|
|
|
|
|
|
void ED_operatortypes_anim(void)
|
|
|
|
{
|
2009-09-04 07:26:32 +00:00
|
|
|
/* Animation Editors only -------------------------- */
|
2008-12-26 11:33:41 +00:00
|
|
|
WM_operatortype_append(ANIM_OT_change_frame);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2018-04-19 16:51:16 +02:00
|
|
|
WM_operatortype_append(ANIM_OT_start_frame_set);
|
|
|
|
WM_operatortype_append(ANIM_OT_end_frame_set);
|
2018-06-04 09:39:04 +02:00
|
|
|
|
2009-03-29 02:15:13 +00:00
|
|
|
WM_operatortype_append(ANIM_OT_previewrange_set);
|
2008-12-26 11:33:41 +00:00
|
|
|
WM_operatortype_append(ANIM_OT_previewrange_clear);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-09-04 07:26:32 +00:00
|
|
|
/* Entire UI --------------------------------------- */
|
2009-11-28 14:37:21 +00:00
|
|
|
WM_operatortype_append(ANIM_OT_keyframe_insert);
|
|
|
|
WM_operatortype_append(ANIM_OT_keyframe_delete);
|
|
|
|
WM_operatortype_append(ANIM_OT_keyframe_insert_menu);
|
|
|
|
WM_operatortype_append(ANIM_OT_keyframe_delete_v3d);
|
2012-10-04 10:58:03 +00:00
|
|
|
WM_operatortype_append(ANIM_OT_keyframe_clear_v3d);
|
2009-11-28 14:37:21 +00:00
|
|
|
WM_operatortype_append(ANIM_OT_keyframe_insert_button);
|
|
|
|
WM_operatortype_append(ANIM_OT_keyframe_delete_button);
|
2012-07-17 15:16:44 +00:00
|
|
|
WM_operatortype_append(ANIM_OT_keyframe_clear_button);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
|
|
|
|
2009-11-28 14:37:21 +00:00
|
|
|
WM_operatortype_append(ANIM_OT_driver_button_add);
|
|
|
|
WM_operatortype_append(ANIM_OT_driver_button_remove);
|
2018-05-24 18:08:32 +02:00
|
|
|
WM_operatortype_append(ANIM_OT_driver_button_edit);
|
2009-09-25 04:51:04 +00:00
|
|
|
WM_operatortype_append(ANIM_OT_copy_driver_button);
|
|
|
|
WM_operatortype_append(ANIM_OT_paste_driver_button);
|
2009-10-07 13:22:56 +00:00
|
|
|
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-11-28 14:37:21 +00:00
|
|
|
WM_operatortype_append(ANIM_OT_keyingset_button_add);
|
|
|
|
WM_operatortype_append(ANIM_OT_keyingset_button_remove);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-10-03 04:21:38 +00:00
|
|
|
WM_operatortype_append(ANIM_OT_keying_set_add);
|
|
|
|
WM_operatortype_append(ANIM_OT_keying_set_remove);
|
|
|
|
WM_operatortype_append(ANIM_OT_keying_set_path_add);
|
|
|
|
WM_operatortype_append(ANIM_OT_keying_set_path_remove);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2010-03-25 11:34:18 +00:00
|
|
|
WM_operatortype_append(ANIM_OT_keying_set_active_set);
|
2008-12-21 08:02:24 +00:00
|
|
|
}
|
|
|
|
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
void ED_keymap_anim(wmKeyConfig *keyconf)
|
2008-12-21 08:02:24 +00:00
|
|
|
{
|
2018-11-08 15:59:51 +11:00
|
|
|
WM_keymap_ensure(keyconf, "Animation", 0, 0);
|
2008-12-21 08:02:24 +00:00
|
|
|
}
|