2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2009-01-01 00:18:23 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-01-01 00:18:23 +00:00
|
|
|
*
|
2009-08-11 11:52:23 +00:00
|
|
|
* The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung
|
2009-01-01 00:18:23 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): Joshua Leung
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/animation/anim_channels_edit.c
|
|
|
|
* \ingroup edanimation
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2010-11-07 12:09:15 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2009-01-01 00:18:23 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2011-06-03 23:12:34 +00:00
|
|
|
#include "BKE_library.h"
|
2009-01-01 00:18:23 +00:00
|
|
|
|
2009-01-20 11:07:42 +00:00
|
|
|
#include "DNA_anim_types.h"
|
2009-01-01 00:18:23 +00:00
|
|
|
#include "DNA_object_types.h"
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
#include "DNA_key_types.h"
|
2010-08-04 04:01:27 +00:00
|
|
|
#include "DNA_gpencil_types.h"
|
2012-06-08 14:31:38 +00:00
|
|
|
#include "DNA_mask_types.h"
|
2009-01-01 00:18:23 +00:00
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
#include "RNA_define.h"
|
|
|
|
|
|
|
|
#include "BKE_action.h"
|
2009-07-10 12:11:00 +00:00
|
|
|
#include "BKE_fcurve.h"
|
2011-07-09 01:11:09 +00:00
|
|
|
#include "BKE_gpencil.h"
|
2009-01-01 00:18:23 +00:00
|
|
|
#include "BKE_context.h"
|
2012-06-08 14:31:38 +00:00
|
|
|
#include "BKE_mask.h"
|
2010-02-08 02:51:02 +00:00
|
|
|
#include "BKE_global.h"
|
2009-01-01 00:18:23 +00:00
|
|
|
|
|
|
|
#include "UI_view2d.h"
|
|
|
|
|
|
|
|
#include "ED_anim_api.h"
|
|
|
|
#include "ED_keyframes_edit.h" // XXX move the select modes out of there!
|
|
|
|
#include "ED_screen.h"
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
/* ************************************************************************** */
|
2009-12-04 03:51:52 +00:00
|
|
|
/* CHANNELS API - Exposed API */
|
2009-01-01 00:18:23 +00:00
|
|
|
|
2009-12-04 03:51:52 +00:00
|
|
|
/* -------------------------- Selection ------------------------------------- */
|
2009-01-01 08:08:55 +00:00
|
|
|
|
2009-02-22 04:13:29 +00:00
|
|
|
/* Set the given animation-channel as the active one for the active context */
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
// TODO: extend for animdata types...
|
2012-04-29 17:11:40 +00:00
|
|
|
void ANIM_set_active_channel(bAnimContext *ac, void *data, short datatype, int filter, void *channel_data, short channel_type)
|
2009-01-05 00:38:17 +00:00
|
|
|
{
|
2009-02-22 04:13:29 +00:00
|
|
|
ListBase anim_data = {NULL, NULL};
|
|
|
|
bAnimListElem *ale;
|
2009-01-05 00:38:17 +00:00
|
|
|
|
2009-02-22 04:13:29 +00:00
|
|
|
/* try to build list of filtered items */
|
NLA SoC: Operators for 'tweaking' strip actions (TAB-Key for both)
In this commit, I've introduced the mechanism by which actions already referenced by strips used in the NLA can be edited (or 'tweaked'). To use, simply select a strip you wish to edit, and hit that TAB key to start tweaking that strip's action, and hit TAB again once you're done.
What happens when you enter 'tweak mode':
1) The action of the active strip temporarily becomes the 'active action' of the AnimData block. You are now able to edit this in one of the Animation Editors (DopeSheet/Action, Graph Editors) as per normal (i.e. sliding keyframes around, inserting keyframes, etc.). The 'action-line' will therefore get drawn immediately above the active track containing the active strip, so that it's clear that that's what we're editing.
2) All the NLA-tracks (and all the strips within them) that occur after the track that the active strip lived in get disabled while you're in tweakmode. This is equivalent to travelling back to an earlier state in a construction history stack.
3) The active NLA track also gets disabled while in tweakmode, since it would otherwise interfere with the correct functioning of the tweaking for the action of interest.
4) The 'real' active action (i.e. the one displaced by the active strip's action) gets put into temp storage, and will be restored after you exit tweakmode.
5) Any strips which also reference the action being tweaked will get highlighted in red shading to indicate that you may be making some changes to the action which you don't really want to make for the other users too.
Please note though, that this is only a rough prototype of this functionality, with some niceties still to come. i.e.:
* NLA-tracks after the active track should still get drawn above the 'tweaking action line', but perhaps with different appearance?
* Various tools will still need awareness of this to prevent corrupting operations from taking place. How to proceed is still undecided...
* When exiting tweak-mode, the strip the action came from still needs some form of syncing with the modified action... there are a few tricky issues here that will need to be solved
* Evaluation code doesn't totally take this into account yet...
---
Also, fixed a number of bugs with various code (notably selection, and also a few drawing bugs)
2009-06-05 05:18:07 +00:00
|
|
|
ANIM_animdata_filter(ac, &anim_data, filter, data, datatype);
|
2009-02-22 04:13:29 +00:00
|
|
|
if (anim_data.first == NULL)
|
2009-01-05 00:38:17 +00:00
|
|
|
return;
|
|
|
|
|
2009-02-22 04:13:29 +00:00
|
|
|
/* only clear the 'active' flag for the channels of the same type */
|
2012-05-08 15:30:00 +00:00
|
|
|
for (ale = anim_data.first; ale; ale = ale->next) {
|
2009-02-22 04:13:29 +00:00
|
|
|
/* skip if types don't match */
|
|
|
|
if (channel_type != ale->type)
|
2009-04-11 00:29:21 +00:00
|
|
|
continue;
|
2009-01-05 00:38:17 +00:00
|
|
|
|
2009-02-22 04:13:29 +00:00
|
|
|
/* flag to set depends on type */
|
|
|
|
switch (ale->type) {
|
|
|
|
case ANIMTYPE_GROUP:
|
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
bActionGroup *agrp = (bActionGroup *)ale->data;
|
2009-02-22 04:13:29 +00:00
|
|
|
|
2009-04-11 00:29:21 +00:00
|
|
|
ACHANNEL_SET_FLAG(agrp, ACHANNEL_SETFLAG_CLEAR, AGRP_ACTIVE);
|
2009-02-22 04:13:29 +00:00
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
break;
|
2009-02-22 04:13:29 +00:00
|
|
|
case ANIMTYPE_FCURVE:
|
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
FCurve *fcu = (FCurve *)ale->data;
|
2009-02-22 04:13:29 +00:00
|
|
|
|
2009-04-11 00:29:21 +00:00
|
|
|
ACHANNEL_SET_FLAG(fcu, ACHANNEL_SETFLAG_CLEAR, FCURVE_ACTIVE);
|
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
break;
|
2009-05-31 04:52:20 +00:00
|
|
|
case ANIMTYPE_NLATRACK:
|
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
NlaTrack *nlt = (NlaTrack *)ale->data;
|
2009-05-31 04:52:20 +00:00
|
|
|
|
|
|
|
ACHANNEL_SET_FLAG(nlt, ACHANNEL_SETFLAG_CLEAR, NLATRACK_ACTIVE);
|
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
break;
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
|
|
|
|
case ANIMTYPE_FILLACTD: /* Action Expander */
|
2012-05-08 15:30:00 +00:00
|
|
|
case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
case ANIMTYPE_DSLAM:
|
|
|
|
case ANIMTYPE_DSCAM:
|
|
|
|
case ANIMTYPE_DSCUR:
|
|
|
|
case ANIMTYPE_DSSKEY:
|
|
|
|
case ANIMTYPE_DSWOR:
|
|
|
|
case ANIMTYPE_DSPART:
|
|
|
|
case ANIMTYPE_DSMBALL:
|
|
|
|
case ANIMTYPE_DSARM:
|
2009-12-28 00:52:31 +00:00
|
|
|
case ANIMTYPE_DSMESH:
|
2011-01-05 00:37:21 +00:00
|
|
|
case ANIMTYPE_DSTEX:
|
|
|
|
case ANIMTYPE_DSLAT:
|
2011-09-03 20:48:43 +00:00
|
|
|
case ANIMTYPE_DSLINESTYLE:
|
2011-08-01 11:44:20 +00:00
|
|
|
case ANIMTYPE_DSSPK:
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
{
|
|
|
|
/* need to verify that this data is valid for now */
|
|
|
|
if (ale->adt) {
|
|
|
|
ACHANNEL_SET_FLAG(ale->adt, ACHANNEL_SETFLAG_CLEAR, ADT_UI_ACTIVE);
|
|
|
|
}
|
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
break;
|
2009-04-11 00:29:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set active flag */
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
if (channel_data) {
|
2009-04-11 00:29:21 +00:00
|
|
|
switch (channel_type) {
|
|
|
|
case ANIMTYPE_GROUP:
|
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
bActionGroup *agrp = (bActionGroup *)channel_data;
|
2009-04-11 00:29:21 +00:00
|
|
|
agrp->flag |= AGRP_ACTIVE;
|
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
break;
|
2009-04-11 00:29:21 +00:00
|
|
|
case ANIMTYPE_FCURVE:
|
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
FCurve *fcu = (FCurve *)channel_data;
|
2009-04-11 00:29:21 +00:00
|
|
|
fcu->flag |= FCURVE_ACTIVE;
|
2009-02-22 04:13:29 +00:00
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
break;
|
2009-05-31 04:52:20 +00:00
|
|
|
case ANIMTYPE_NLATRACK:
|
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
NlaTrack *nlt = (NlaTrack *)channel_data;
|
NLA SoC: Operators for 'tweaking' strip actions (TAB-Key for both)
In this commit, I've introduced the mechanism by which actions already referenced by strips used in the NLA can be edited (or 'tweaked'). To use, simply select a strip you wish to edit, and hit that TAB key to start tweaking that strip's action, and hit TAB again once you're done.
What happens when you enter 'tweak mode':
1) The action of the active strip temporarily becomes the 'active action' of the AnimData block. You are now able to edit this in one of the Animation Editors (DopeSheet/Action, Graph Editors) as per normal (i.e. sliding keyframes around, inserting keyframes, etc.). The 'action-line' will therefore get drawn immediately above the active track containing the active strip, so that it's clear that that's what we're editing.
2) All the NLA-tracks (and all the strips within them) that occur after the track that the active strip lived in get disabled while you're in tweakmode. This is equivalent to travelling back to an earlier state in a construction history stack.
3) The active NLA track also gets disabled while in tweakmode, since it would otherwise interfere with the correct functioning of the tweaking for the action of interest.
4) The 'real' active action (i.e. the one displaced by the active strip's action) gets put into temp storage, and will be restored after you exit tweakmode.
5) Any strips which also reference the action being tweaked will get highlighted in red shading to indicate that you may be making some changes to the action which you don't really want to make for the other users too.
Please note though, that this is only a rough prototype of this functionality, with some niceties still to come. i.e.:
* NLA-tracks after the active track should still get drawn above the 'tweaking action line', but perhaps with different appearance?
* Various tools will still need awareness of this to prevent corrupting operations from taking place. How to proceed is still undecided...
* When exiting tweak-mode, the strip the action came from still needs some form of syncing with the modified action... there are a few tricky issues here that will need to be solved
* Evaluation code doesn't totally take this into account yet...
---
Also, fixed a number of bugs with various code (notably selection, and also a few drawing bugs)
2009-06-05 05:18:07 +00:00
|
|
|
nlt->flag |= NLATRACK_ACTIVE;
|
2009-05-31 04:52:20 +00:00
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
break;
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
|
|
|
|
case ANIMTYPE_FILLACTD: /* Action Expander */
|
2012-05-08 15:30:00 +00:00
|
|
|
case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
case ANIMTYPE_DSLAM:
|
|
|
|
case ANIMTYPE_DSCAM:
|
|
|
|
case ANIMTYPE_DSCUR:
|
|
|
|
case ANIMTYPE_DSSKEY:
|
|
|
|
case ANIMTYPE_DSWOR:
|
|
|
|
case ANIMTYPE_DSPART:
|
|
|
|
case ANIMTYPE_DSMBALL:
|
|
|
|
case ANIMTYPE_DSARM:
|
2009-12-28 00:52:31 +00:00
|
|
|
case ANIMTYPE_DSMESH:
|
2011-01-05 00:37:21 +00:00
|
|
|
case ANIMTYPE_DSLAT:
|
2011-09-03 20:48:43 +00:00
|
|
|
case ANIMTYPE_DSLINESTYLE:
|
2011-08-01 11:44:20 +00:00
|
|
|
case ANIMTYPE_DSSPK:
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
{
|
|
|
|
/* need to verify that this data is valid for now */
|
2011-04-24 10:51:45 +00:00
|
|
|
if (ale && ale->adt) {
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
ale->adt->flag |= ADT_UI_ACTIVE;
|
2011-04-24 10:51:45 +00:00
|
|
|
}
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
break;
|
2009-02-22 04:13:29 +00:00
|
|
|
}
|
2009-01-05 00:38:17 +00:00
|
|
|
}
|
2009-02-22 04:13:29 +00:00
|
|
|
|
|
|
|
/* clean up */
|
|
|
|
BLI_freelistN(&anim_data);
|
2009-01-05 00:38:17 +00:00
|
|
|
}
|
|
|
|
|
2009-01-02 00:56:48 +00:00
|
|
|
/* Deselect all animation channels
|
|
|
|
* - data: pointer to datatype, as contained in bAnimContext
|
2009-01-05 00:38:17 +00:00
|
|
|
* - datatype: the type of data that 'data' represents (eAnimCont_Types)
|
2009-01-02 00:56:48 +00:00
|
|
|
* - test: check if deselecting instead of selecting
|
|
|
|
* - sel: eAnimChannels_SetFlag;
|
|
|
|
*/
|
2012-04-29 17:11:40 +00:00
|
|
|
void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, short datatype, short test, short sel)
|
2009-01-02 00:56:48 +00:00
|
|
|
{
|
|
|
|
ListBase anim_data = {NULL, NULL};
|
|
|
|
bAnimListElem *ale;
|
|
|
|
int filter;
|
|
|
|
|
|
|
|
/* filter data */
|
Animation Channel Filtering Refactor - Part 3 (Visibility Flag Split)
* This (big) commit is aimed at cleaning up the filtering flags used
by the animation channel filtering code. The list of filtering flags
has been growing a bit "organically" since it's humble origins for use
in the Action Editor some 3 years (IIRC) ago now during a weekend
hackathon. Obviously, some things have ended up tacked on, while
others have been the product of other flag options. Nevertheless, it
was time for a bit of a spring clean!
* Most notably, one area where the system outgrown its original design
for the Action Editor was in terms of the "visibility" filtering flag
it was using. While in the Action Editor the concept of what channels
to include was strictly dictated by whether the channel hierarchy
showed it, in the Graph Editor this is not always the case. In other
words, there was a difference between the data the channels
represented being visible and the channels for that data being visible
in the hierarchy.
Long story short: this lead to bug report [#27076] (and many like it),
where if you selected an F-Curve, then collapsed the Group it was in,
then even after selecting another F-Curve in another Group, the
original F-Curve's properties would still be shown in the Properties
Region. The good news is that this commit fixes this issue right away!
* More good news will follow, as I start checking on the flag usage of
other tools, but I'm committing this first so that we have a stable
reference (of code similar to the old buggy stuff) on which we can
fall back to later to find bugs (should they pop up).
Anyways, back to the trenches!
2011-06-22 11:41:26 +00:00
|
|
|
/* NOTE: no list visible, otherwise, we get dangling */
|
2012-05-08 15:30:00 +00:00
|
|
|
filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS;
|
2010-01-23 03:04:37 +00:00
|
|
|
ANIM_animdata_filter(ac, &anim_data, filter, data, datatype);
|
2009-01-02 00:56:48 +00:00
|
|
|
|
|
|
|
/* See if we should be selecting or deselecting */
|
|
|
|
if (test) {
|
2012-05-08 15:30:00 +00:00
|
|
|
for (ale = anim_data.first; ale; ale = ale->next) {
|
2009-01-02 00:56:48 +00:00
|
|
|
if (sel == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
switch (ale->type) {
|
2009-02-13 06:33:07 +00:00
|
|
|
case ANIMTYPE_SCENE:
|
|
|
|
if (ale->flag & SCE_DS_SELECTED)
|
2012-05-08 15:30:00 +00:00
|
|
|
sel = ACHANNEL_SETFLAG_CLEAR;
|
2009-02-13 06:33:07 +00:00
|
|
|
break;
|
2009-01-02 00:56:48 +00:00
|
|
|
case ANIMTYPE_OBJECT:
|
2012-05-08 15:30:00 +00:00
|
|
|
#if 0 /* for now, do not take object selection into account, since it gets too annoying */
|
2009-01-02 00:56:48 +00:00
|
|
|
if (ale->flag & SELECT)
|
2012-05-08 15:30:00 +00:00
|
|
|
sel = ACHANNEL_SETFLAG_CLEAR;
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
#endif
|
2009-01-02 00:56:48 +00:00
|
|
|
break;
|
|
|
|
case ANIMTYPE_GROUP:
|
|
|
|
if (ale->flag & AGRP_SELECTED)
|
2012-05-08 15:30:00 +00:00
|
|
|
sel = ACHANNEL_SETFLAG_CLEAR;
|
2009-01-02 00:56:48 +00:00
|
|
|
break;
|
2009-01-20 11:07:42 +00:00
|
|
|
case ANIMTYPE_FCURVE:
|
|
|
|
if (ale->flag & FCURVE_SELECTED)
|
2012-05-08 15:30:00 +00:00
|
|
|
sel = ACHANNEL_SETFLAG_CLEAR;
|
2009-01-02 00:56:48 +00:00
|
|
|
break;
|
2009-10-16 12:08:47 +00:00
|
|
|
case ANIMTYPE_SHAPEKEY:
|
|
|
|
if (ale->flag & KEYBLOCK_SEL)
|
2012-05-08 15:30:00 +00:00
|
|
|
sel = ACHANNEL_SETFLAG_CLEAR;
|
2009-10-16 12:08:47 +00:00
|
|
|
break;
|
2009-05-30 10:41:41 +00:00
|
|
|
case ANIMTYPE_NLATRACK:
|
|
|
|
if (ale->flag & NLATRACK_SELECTED)
|
2012-05-08 15:30:00 +00:00
|
|
|
sel = ACHANNEL_SETFLAG_CLEAR;
|
2009-05-30 10:41:41 +00:00
|
|
|
break;
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
|
|
|
|
case ANIMTYPE_FILLACTD: /* Action Expander */
|
2012-05-08 15:30:00 +00:00
|
|
|
case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
case ANIMTYPE_DSLAM:
|
|
|
|
case ANIMTYPE_DSCAM:
|
|
|
|
case ANIMTYPE_DSCUR:
|
|
|
|
case ANIMTYPE_DSSKEY:
|
|
|
|
case ANIMTYPE_DSWOR:
|
|
|
|
case ANIMTYPE_DSPART:
|
|
|
|
case ANIMTYPE_DSMBALL:
|
|
|
|
case ANIMTYPE_DSARM:
|
2009-12-28 00:52:31 +00:00
|
|
|
case ANIMTYPE_DSMESH:
|
2010-02-18 00:29:08 +00:00
|
|
|
case ANIMTYPE_DSNTREE:
|
|
|
|
case ANIMTYPE_DSTEX:
|
2011-01-05 00:37:21 +00:00
|
|
|
case ANIMTYPE_DSLAT:
|
2010-09-21 22:23:10 +00:00
|
|
|
case ANIMTYPE_DSLINESTYLE:
|
2011-08-01 11:44:20 +00:00
|
|
|
case ANIMTYPE_DSSPK:
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
{
|
|
|
|
if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED))
|
2012-05-08 15:30:00 +00:00
|
|
|
sel = ACHANNEL_SETFLAG_CLEAR;
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
break;
|
2011-01-10 22:10:28 +00:00
|
|
|
|
|
|
|
case ANIMTYPE_GPLAYER:
|
|
|
|
if (ale->flag & GP_LAYER_SELECT)
|
2012-05-08 15:30:00 +00:00
|
|
|
sel = ACHANNEL_SETFLAG_CLEAR;
|
2011-01-10 22:10:28 +00:00
|
|
|
break;
|
2012-06-08 14:31:38 +00:00
|
|
|
case ANIMTYPE_MASKLAYER:
|
|
|
|
if (ale->flag & MASK_LAYERFLAG_SELECT)
|
|
|
|
sel = ACHANNEL_SETFLAG_CLEAR;
|
|
|
|
break;
|
2009-01-02 00:56:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now set the flags */
|
2012-05-08 15:30:00 +00:00
|
|
|
for (ale = anim_data.first; ale; ale = ale->next) {
|
2009-01-02 00:56:48 +00:00
|
|
|
switch (ale->type) {
|
2009-02-13 06:33:07 +00:00
|
|
|
case ANIMTYPE_SCENE:
|
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
Scene *scene = (Scene *)ale->data;
|
2009-02-13 06:33:07 +00:00
|
|
|
|
|
|
|
ACHANNEL_SET_FLAG(scene, sel, SCE_DS_SELECTED);
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
|
|
|
|
if (scene->adt) {
|
|
|
|
ACHANNEL_SET_FLAG(scene, sel, ADT_UI_SELECTED);
|
|
|
|
}
|
2009-02-13 06:33:07 +00:00
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
break;
|
2009-01-02 00:56:48 +00:00
|
|
|
case ANIMTYPE_OBJECT:
|
2012-05-08 15:30:00 +00:00
|
|
|
#if 0 /* for now, do not take object selection into account, since it gets too annoying */
|
|
|
|
{
|
|
|
|
Base *base = (Base *)ale->data;
|
|
|
|
Object *ob = base->object;
|
2012-08-08 13:55:30 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
ACHANNEL_SET_FLAG(base, sel, SELECT);
|
|
|
|
ACHANNEL_SET_FLAG(ob, sel, SELECT);
|
2012-08-08 13:55:30 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
if (ob->adt) {
|
|
|
|
ACHANNEL_SET_FLAG(ob, sel, ADT_UI_SELECTED);
|
|
|
|
}
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
}
|
|
|
|
#endif
|
2009-01-02 00:56:48 +00:00
|
|
|
break;
|
|
|
|
case ANIMTYPE_GROUP:
|
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
bActionGroup *agrp = (bActionGroup *)ale->data;
|
2009-01-02 00:56:48 +00:00
|
|
|
|
|
|
|
ACHANNEL_SET_FLAG(agrp, sel, AGRP_SELECTED);
|
|
|
|
agrp->flag &= ~AGRP_ACTIVE;
|
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
break;
|
2009-01-20 11:07:42 +00:00
|
|
|
case ANIMTYPE_FCURVE:
|
2009-01-02 00:56:48 +00:00
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
FCurve *fcu = (FCurve *)ale->data;
|
2009-01-02 00:56:48 +00:00
|
|
|
|
2009-01-20 11:07:42 +00:00
|
|
|
ACHANNEL_SET_FLAG(fcu, sel, FCURVE_SELECTED);
|
|
|
|
fcu->flag &= ~FCURVE_ACTIVE;
|
2009-01-02 00:56:48 +00:00
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
break;
|
2009-10-16 12:08:47 +00:00
|
|
|
case ANIMTYPE_SHAPEKEY:
|
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
KeyBlock *kb = (KeyBlock *)ale->data;
|
2009-10-16 12:08:47 +00:00
|
|
|
|
|
|
|
ACHANNEL_SET_FLAG(kb, sel, KEYBLOCK_SEL);
|
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
break;
|
2009-05-30 10:41:41 +00:00
|
|
|
case ANIMTYPE_NLATRACK:
|
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
NlaTrack *nlt = (NlaTrack *)ale->data;
|
2009-05-30 10:41:41 +00:00
|
|
|
|
|
|
|
ACHANNEL_SET_FLAG(nlt, sel, NLATRACK_SELECTED);
|
|
|
|
nlt->flag &= ~NLATRACK_ACTIVE;
|
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
break;
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
|
|
|
|
case ANIMTYPE_FILLACTD: /* Action Expander */
|
2012-05-08 15:30:00 +00:00
|
|
|
case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
case ANIMTYPE_DSLAM:
|
|
|
|
case ANIMTYPE_DSCAM:
|
|
|
|
case ANIMTYPE_DSCUR:
|
|
|
|
case ANIMTYPE_DSSKEY:
|
|
|
|
case ANIMTYPE_DSWOR:
|
|
|
|
case ANIMTYPE_DSPART:
|
|
|
|
case ANIMTYPE_DSMBALL:
|
|
|
|
case ANIMTYPE_DSARM:
|
2009-12-28 00:52:31 +00:00
|
|
|
case ANIMTYPE_DSMESH:
|
2010-02-18 00:29:08 +00:00
|
|
|
case ANIMTYPE_DSNTREE:
|
|
|
|
case ANIMTYPE_DSTEX:
|
2011-01-05 00:37:21 +00:00
|
|
|
case ANIMTYPE_DSLAT:
|
2010-09-21 22:23:10 +00:00
|
|
|
case ANIMTYPE_DSLINESTYLE:
|
2011-08-01 11:44:20 +00:00
|
|
|
case ANIMTYPE_DSSPK:
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
{
|
|
|
|
/* need to verify that this data is valid for now */
|
|
|
|
if (ale->adt) {
|
|
|
|
ACHANNEL_SET_FLAG(ale->adt, sel, ADT_UI_SELECTED);
|
|
|
|
ale->adt->flag &= ~ADT_UI_ACTIVE;
|
|
|
|
}
|
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
break;
|
2011-01-10 22:10:28 +00:00
|
|
|
|
|
|
|
case ANIMTYPE_GPLAYER:
|
|
|
|
{
|
|
|
|
bGPDlayer *gpl = (bGPDlayer *)ale->data;
|
|
|
|
|
|
|
|
ACHANNEL_SET_FLAG(gpl, sel, GP_LAYER_SELECT);
|
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
break;
|
2012-08-08 13:55:30 +00:00
|
|
|
|
2012-06-08 14:31:38 +00:00
|
|
|
case ANIMTYPE_MASKLAYER:
|
|
|
|
{
|
|
|
|
MaskLayer *masklay = (MaskLayer *)ale->data;
|
2012-08-08 13:55:30 +00:00
|
|
|
|
2012-06-08 14:31:38 +00:00
|
|
|
ACHANNEL_SET_FLAG(masklay, sel, MASK_LAYERFLAG_SELECT);
|
|
|
|
}
|
|
|
|
break;
|
2009-01-02 00:56:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Cleanup */
|
|
|
|
BLI_freelistN(&anim_data);
|
|
|
|
}
|
|
|
|
|
2009-12-04 03:51:52 +00:00
|
|
|
/* ---------------------------- Graph Editor ------------------------------------- */
|
|
|
|
|
2009-11-30 11:10:03 +00:00
|
|
|
/* Flush visibility (for Graph Editor) changes up/down hierarchy for changes in the given setting
|
|
|
|
* - anim_data: list of the all the anim channels that can be chosen
|
|
|
|
* -> filtered using ANIMFILTER_CHANNELS only, since if we took VISIBLE too,
|
2011-09-25 12:31:21 +00:00
|
|
|
* then the channels under closed expanders get ignored...
|
2012-03-02 16:05:54 +00:00
|
|
|
* - ale_setting: the anim channel (not in the anim_data list directly, though occurring there)
|
2009-11-30 11:10:03 +00:00
|
|
|
* with the new state of the setting that we want flushed up/down the hierarchy
|
2010-01-10 11:09:30 +00:00
|
|
|
* - setting: type of setting to set
|
|
|
|
* - on: whether the visibility setting has been enabled or disabled
|
2009-11-30 11:10:03 +00:00
|
|
|
*/
|
2012-04-29 17:11:40 +00:00
|
|
|
void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAnimListElem *ale_setting, int setting, short on)
|
2009-11-30 11:10:03 +00:00
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
bAnimListElem *ale, *match = NULL;
|
|
|
|
int prevLevel = 0, matchLevel = 0;
|
2009-11-30 11:10:03 +00:00
|
|
|
|
2010-01-24 10:18:16 +00:00
|
|
|
/* sanity check */
|
|
|
|
if (ELEM(NULL, anim_data, anim_data->first))
|
|
|
|
return;
|
|
|
|
|
2009-11-30 11:10:03 +00:00
|
|
|
/* find the channel that got changed */
|
2012-05-08 15:30:00 +00:00
|
|
|
for (ale = anim_data->first; ale; ale = ale->next) {
|
2009-11-30 11:10:03 +00:00
|
|
|
/* compare data, and type as main way of identifying the channel */
|
|
|
|
if ((ale->data == ale_setting->data) && (ale->type == ale_setting->type)) {
|
|
|
|
/* we also have to check the ID, this is assigned to, since a block may have multiple users */
|
2012-07-06 23:56:59 +00:00
|
|
|
/* TODO: is the owner-data more revealing? */
|
2009-11-30 11:10:03 +00:00
|
|
|
if (ale->id == ale_setting->id) {
|
2012-05-08 15:30:00 +00:00
|
|
|
match = ale;
|
2009-11-30 11:10:03 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (match == NULL) {
|
2012-03-31 00:59:17 +00:00
|
|
|
printf("ERROR: no channel matching the one changed was found\n");
|
2009-11-30 11:10:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
2012-05-08 15:30:00 +00:00
|
|
|
bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale_setting);
|
2009-11-30 11:10:03 +00:00
|
|
|
|
2010-01-24 10:18:16 +00:00
|
|
|
if (acf == NULL) {
|
2012-03-31 00:59:17 +00:00
|
|
|
printf("ERROR: no channel info for the changed channel\n");
|
2010-01-24 10:18:16 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-11-30 11:10:03 +00:00
|
|
|
/* get the level of the channel that was affected
|
2012-05-08 15:30:00 +00:00
|
|
|
* - we define the level as simply being the offset for the start of the channel
|
2009-11-30 11:10:03 +00:00
|
|
|
*/
|
2012-05-08 15:30:00 +00:00
|
|
|
matchLevel = (acf->get_offset) ? acf->get_offset(ac, ale_setting) : 0;
|
|
|
|
prevLevel = matchLevel;
|
2009-11-30 11:10:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* flush up?
|
2010-01-10 11:09:30 +00:00
|
|
|
*
|
|
|
|
* For Visibility:
|
|
|
|
* - only flush up if the current state is now enabled (positive 'on' state is default)
|
2009-11-30 11:10:03 +00:00
|
|
|
* (otherwise, it's too much work to force the parents to be inactive too)
|
2010-01-10 11:09:30 +00:00
|
|
|
*
|
|
|
|
* For everything else:
|
|
|
|
* - only flush up if the current state is now disabled (negative 'off' state is default)
|
|
|
|
* (otherwise, it's too much work to force the parents to be active too)
|
2009-11-30 11:10:03 +00:00
|
|
|
*/
|
2010-01-10 11:09:30 +00:00
|
|
|
if ( ((setting == ACHANNEL_SETTING_VISIBLE) && on) ||
|
2012-05-08 15:30:00 +00:00
|
|
|
((setting != ACHANNEL_SETTING_VISIBLE) && on == 0) )
|
2010-01-10 11:09:30 +00:00
|
|
|
{
|
2009-11-30 11:10:03 +00:00
|
|
|
/* go backwards in the list, until the highest-ranking element (by indention has been covered) */
|
2012-05-08 15:30:00 +00:00
|
|
|
for (ale = match->prev; ale; ale = ale->prev) {
|
|
|
|
bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
|
2009-11-30 11:10:03 +00:00
|
|
|
int level;
|
|
|
|
|
2010-01-24 10:18:16 +00:00
|
|
|
/* if no channel info was found, skip, since this type might not have any useful info */
|
|
|
|
if (acf == NULL)
|
|
|
|
continue;
|
|
|
|
|
2009-11-30 11:10:03 +00:00
|
|
|
/* get the level of the current channel traversed
|
2012-05-08 15:30:00 +00:00
|
|
|
* - we define the level as simply being the offset for the start of the channel
|
2009-11-30 11:10:03 +00:00
|
|
|
*/
|
2012-05-08 15:30:00 +00:00
|
|
|
level = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
|
2009-11-30 11:10:03 +00:00
|
|
|
|
|
|
|
/* if the level is 'less than' (i.e. more important) the level we're matching
|
|
|
|
* but also 'less than' the level just tried (i.e. only the 1st group above grouped F-Curves,
|
2010-02-08 10:47:34 +00:00
|
|
|
* when toggling visibility of F-Curves, gets flushed, which should happen if we don't let prevLevel
|
|
|
|
* get updated below once the first 1st group is found)...
|
2009-11-30 11:10:03 +00:00
|
|
|
*/
|
2010-02-08 10:47:34 +00:00
|
|
|
if (level < prevLevel) {
|
|
|
|
/* flush the new status... */
|
2010-01-10 11:09:30 +00:00
|
|
|
ANIM_channel_setting_set(ac, ale, setting, on);
|
2010-02-08 10:47:34 +00:00
|
|
|
|
|
|
|
/* store this level as the 'old' level now */
|
2012-05-08 15:30:00 +00:00
|
|
|
prevLevel = level;
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2010-02-08 10:47:34 +00:00
|
|
|
/* if the level is 'greater than' (i.e. less important) than the previous level... */
|
|
|
|
else if (level > prevLevel) {
|
|
|
|
/* if previous level was a base-level (i.e. 0 offset / root of one hierarchy),
|
|
|
|
* stop here
|
|
|
|
*/
|
|
|
|
if (prevLevel == 0)
|
|
|
|
break;
|
|
|
|
/* otherwise, this level weaves into another sibling hierarchy to the previous one just
|
|
|
|
* finished, so skip until we get to the parent of this level
|
|
|
|
*/
|
|
|
|
else
|
|
|
|
continue;
|
|
|
|
}
|
2009-11-30 11:10:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* flush down (always) */
|
|
|
|
{
|
|
|
|
/* go forwards in the list, until the lowest-ranking element (by indention has been covered) */
|
2012-05-08 15:30:00 +00:00
|
|
|
for (ale = match->next; ale; ale = ale->next) {
|
|
|
|
bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
|
2009-11-30 11:10:03 +00:00
|
|
|
int level;
|
|
|
|
|
2010-01-24 10:18:16 +00:00
|
|
|
/* if no channel info was found, skip, since this type might not have any useful info */
|
|
|
|
if (acf == NULL)
|
|
|
|
continue;
|
|
|
|
|
2009-11-30 11:10:03 +00:00
|
|
|
/* get the level of the current channel traversed
|
2012-05-08 15:30:00 +00:00
|
|
|
* - we define the level as simply being the offset for the start of the channel
|
2009-11-30 11:10:03 +00:00
|
|
|
*/
|
2012-05-08 15:30:00 +00:00
|
|
|
level = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
|
2009-11-30 11:10:03 +00:00
|
|
|
|
|
|
|
/* if the level is 'greater than' (i.e. less important) the channel that was changed,
|
|
|
|
* flush the new status...
|
|
|
|
*/
|
|
|
|
if (level > matchLevel)
|
2010-01-10 11:09:30 +00:00
|
|
|
ANIM_channel_setting_set(ac, ale, setting, on);
|
2009-11-30 11:10:03 +00:00
|
|
|
/* however, if the level is 'less than or equal to' the channel that was changed,
|
|
|
|
* (i.e. the current channel is as important if not more important than the changed channel)
|
|
|
|
* then we should stop, since we've found the last one of the children we should flush
|
|
|
|
*/
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* store this level as the 'old' level now */
|
2012-05-27 19:40:36 +00:00
|
|
|
// prevLevel = level; // XXX: prevLevel is unused
|
2009-11-30 11:10:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-04 03:51:52 +00:00
|
|
|
/* -------------------------- F-Curves ------------------------------------- */
|
|
|
|
|
|
|
|
/* Delete the given F-Curve from its AnimData block */
|
2012-04-29 17:11:40 +00:00
|
|
|
void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *fcu)
|
2009-12-04 03:51:52 +00:00
|
|
|
{
|
|
|
|
/* - if no AnimData, we've got nowhere to remove the F-Curve from
|
|
|
|
* (this doesn't guarantee that the F-Curve is in there, but at least we tried
|
|
|
|
* - if no F-Curve, there is nothing to remove
|
|
|
|
*/
|
|
|
|
if (ELEM(NULL, adt, fcu))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* remove from whatever list it came from
|
|
|
|
* - Action Group
|
|
|
|
* - Action
|
|
|
|
* - Drivers
|
|
|
|
* - TODO... some others?
|
|
|
|
*/
|
2011-06-02 12:21:55 +00:00
|
|
|
if ((ac) && (ac->datatype == ANIMCONT_DRIVERS)) {
|
|
|
|
/* driver F-Curve */
|
2009-12-04 03:51:52 +00:00
|
|
|
BLI_remlink(&adt->drivers, fcu);
|
2011-06-02 12:21:55 +00:00
|
|
|
}
|
|
|
|
else if (adt->action) {
|
2012-12-16 06:30:17 +00:00
|
|
|
bAction *act = adt->action;
|
|
|
|
|
2011-06-02 12:21:55 +00:00
|
|
|
/* remove from group or action, whichever one "owns" the F-Curve */
|
2012-12-16 06:30:17 +00:00
|
|
|
if (fcu->grp) {
|
|
|
|
bActionGroup *agrp = fcu->grp;
|
|
|
|
|
|
|
|
/* remove F-Curve from group+action */
|
|
|
|
action_groups_remove_channel(act, fcu);
|
2011-06-02 12:21:55 +00:00
|
|
|
|
2012-12-16 06:30:17 +00:00
|
|
|
/* if group has no more channels, remove it too,
|
|
|
|
* otherwise can have many dangling groups [#33541]
|
|
|
|
*/
|
|
|
|
if (agrp->channels.first == NULL) {
|
|
|
|
BLI_freelinkN(&act->groups, agrp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
BLI_remlink(&act->curves, fcu);
|
|
|
|
}
|
|
|
|
|
2011-06-02 12:21:55 +00:00
|
|
|
/* if action has no more F-Curves as a result of this, unlink it from
|
|
|
|
* AnimData if it did not come from a NLA Strip being tweaked.
|
|
|
|
*
|
|
|
|
* This is done so that we don't have dangling Object+Action entries in
|
|
|
|
* channel list that are empty, and linger around long after the data they
|
|
|
|
* are for has disappeared (and probably won't come back).
|
|
|
|
*/
|
2012-12-16 06:30:17 +00:00
|
|
|
if ((act->curves.first == NULL) && (adt->flag & ADT_NLA_EDIT_ON) == 0) {
|
|
|
|
id_us_min(&act->id);
|
2011-06-02 12:21:55 +00:00
|
|
|
adt->action = NULL;
|
|
|
|
}
|
|
|
|
}
|
2009-12-04 03:51:52 +00:00
|
|
|
|
|
|
|
/* free the F-Curve itself */
|
|
|
|
free_fcurve(fcu);
|
|
|
|
}
|
|
|
|
|
2009-01-01 00:18:23 +00:00
|
|
|
/* ************************************************************************** */
|
2009-01-01 08:08:55 +00:00
|
|
|
/* OPERATORS */
|
|
|
|
|
2009-06-21 03:02:40 +00:00
|
|
|
/* ****************** Operator Utilities ********************************** */
|
|
|
|
|
|
|
|
/* poll callback for being in an Animation Editor channels list region */
|
2012-05-08 15:30:00 +00:00
|
|
|
static int animedit_poll_channels_active(bContext *C)
|
2009-06-21 03:02:40 +00:00
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
2009-06-21 03:02:40 +00:00
|
|
|
|
|
|
|
/* channels region test */
|
2012-07-06 23:56:59 +00:00
|
|
|
/* TODO: could enhance with actually testing if channels region? */
|
2009-06-21 03:02:40 +00:00
|
|
|
if (ELEM(NULL, sa, CTX_wm_region(C)))
|
|
|
|
return 0;
|
|
|
|
/* animation editor test */
|
|
|
|
if (ELEM3(sa->spacetype, SPACE_ACTION, SPACE_IPO, SPACE_NLA) == 0)
|
|
|
|
return 0;
|
2012-07-06 23:56:59 +00:00
|
|
|
|
2009-06-21 03:02:40 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* poll callback for Animation Editor channels list region + not in NLA-tweakmode for NLA */
|
2012-05-08 15:30:00 +00:00
|
|
|
static int animedit_poll_channels_nla_tweakmode_off(bContext *C)
|
2009-06-21 03:02:40 +00:00
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
2009-06-21 03:02:40 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2012-07-06 23:56:59 +00:00
|
|
|
|
2009-06-21 03:02:40 +00:00
|
|
|
/* channels region test */
|
2012-07-06 23:56:59 +00:00
|
|
|
/* TODO: could enhance with actually testing if channels region? */
|
2009-06-21 03:02:40 +00:00
|
|
|
if (ELEM(NULL, sa, CTX_wm_region(C)))
|
|
|
|
return 0;
|
|
|
|
/* animation editor test */
|
|
|
|
if (ELEM3(sa->spacetype, SPACE_ACTION, SPACE_IPO, SPACE_NLA) == 0)
|
|
|
|
return 0;
|
|
|
|
|
2012-10-21 05:46:41 +00:00
|
|
|
/* NLA TweakMode test */
|
2009-06-21 03:02:40 +00:00
|
|
|
if (sa->spacetype == SPACE_NLA) {
|
|
|
|
if ((scene == NULL) || (scene->flag & SCE_NLA_EDIT_ON))
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-01-05 00:38:17 +00:00
|
|
|
/* ****************** Rearrange Channels Operator ******************* */
|
2009-01-20 11:07:42 +00:00
|
|
|
|
2009-01-05 09:54:39 +00:00
|
|
|
/* constants for channel rearranging */
|
|
|
|
/* WARNING: don't change exising ones without modifying rearrange func accordingly */
|
|
|
|
enum {
|
2012-05-08 15:30:00 +00:00
|
|
|
REARRANGE_ANIMCHAN_TOP = -2,
|
|
|
|
REARRANGE_ANIMCHAN_UP = -1,
|
|
|
|
REARRANGE_ANIMCHAN_DOWN = 1,
|
|
|
|
REARRANGE_ANIMCHAN_BOTTOM = 2
|
2009-01-05 09:54:39 +00:00
|
|
|
};
|
|
|
|
|
2010-11-07 12:09:15 +00:00
|
|
|
/* defines for rearranging channels */
|
2011-02-13 14:16:36 +00:00
|
|
|
static EnumPropertyItem prop_animchannel_rearrange_types[] = {
|
2010-11-07 12:09:15 +00:00
|
|
|
{REARRANGE_ANIMCHAN_TOP, "TOP", 0, "To Top", ""},
|
|
|
|
{REARRANGE_ANIMCHAN_UP, "UP", 0, "Up", ""},
|
|
|
|
{REARRANGE_ANIMCHAN_DOWN, "DOWN", 0, "Down", ""},
|
|
|
|
{REARRANGE_ANIMCHAN_BOTTOM, "BOTTOM", 0, "To Bottom", ""},
|
|
|
|
{0, NULL, 0, NULL, NULL}
|
|
|
|
};
|
2009-01-05 09:54:39 +00:00
|
|
|
|
2011-02-10 05:15:05 +00:00
|
|
|
/* Reordering "Islands" Defines ----------------------------------- */
|
2009-01-05 09:54:39 +00:00
|
|
|
|
2011-02-10 05:15:05 +00:00
|
|
|
/* Island definition - just a listbase container */
|
|
|
|
typedef struct tReorderChannelIsland {
|
|
|
|
struct tReorderChannelIsland *next, *prev;
|
2009-01-05 09:54:39 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
ListBase channels; /* channels within this region with the same state */
|
|
|
|
int flag; /* eReorderIslandFlag */
|
2011-02-10 05:15:05 +00:00
|
|
|
} tReorderChannelIsland;
|
|
|
|
|
|
|
|
/* flags for channel reordering islands */
|
|
|
|
typedef enum eReorderIslandFlag {
|
2012-05-08 15:30:00 +00:00
|
|
|
REORDER_ISLAND_SELECTED = (1 << 0), /* island is selected */
|
|
|
|
REORDER_ISLAND_UNTOUCHABLE = (1 << 1), /* island should be ignored */
|
|
|
|
REORDER_ISLAND_MOVED = (1 << 2) /* island has already been moved */
|
2011-02-10 05:15:05 +00:00
|
|
|
} eReorderIslandFlag;
|
2009-01-05 09:54:39 +00:00
|
|
|
|
|
|
|
|
2011-02-10 05:15:05 +00:00
|
|
|
/* Rearrange Methods --------------------------------------------- */
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
static short rearrange_island_ok(tReorderChannelIsland *island)
|
2009-01-05 09:54:39 +00:00
|
|
|
{
|
2011-02-10 05:15:05 +00:00
|
|
|
/* island must not be untouchable */
|
|
|
|
if (island->flag & REORDER_ISLAND_UNTOUCHABLE)
|
|
|
|
return 0;
|
2009-01-05 09:54:39 +00:00
|
|
|
|
2011-02-10 05:15:05 +00:00
|
|
|
/* island should be selected to be moved */
|
|
|
|
return (island->flag & REORDER_ISLAND_SELECTED) && !(island->flag & REORDER_ISLAND_MOVED);
|
2009-01-05 09:54:39 +00:00
|
|
|
}
|
|
|
|
|
2011-02-10 05:15:05 +00:00
|
|
|
/* ............................. */
|
2009-01-05 09:54:39 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
static short rearrange_island_top(ListBase *list, tReorderChannelIsland *island)
|
2009-01-05 09:54:39 +00:00
|
|
|
{
|
2011-02-10 05:15:05 +00:00
|
|
|
if (rearrange_island_ok(island)) {
|
|
|
|
/* remove from current position */
|
|
|
|
BLI_remlink(list, island);
|
2009-01-05 09:54:39 +00:00
|
|
|
|
|
|
|
/* make it first element */
|
2011-02-10 05:15:05 +00:00
|
|
|
BLI_insertlinkbefore(list, list->first, island);
|
2009-01-05 09:54:39 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
static short rearrange_island_up(ListBase *list, tReorderChannelIsland *island)
|
2009-01-05 09:54:39 +00:00
|
|
|
{
|
2011-02-10 05:15:05 +00:00
|
|
|
if (rearrange_island_ok(island)) {
|
|
|
|
/* moving up = moving before the previous island, otherwise we're in the same place */
|
2012-05-08 15:30:00 +00:00
|
|
|
tReorderChannelIsland *prev = island->prev;
|
2009-01-05 09:54:39 +00:00
|
|
|
|
|
|
|
if (prev) {
|
2011-02-10 05:15:05 +00:00
|
|
|
/* remove from current position */
|
|
|
|
BLI_remlink(list, island);
|
2009-01-05 09:54:39 +00:00
|
|
|
|
|
|
|
/* push it up */
|
2011-02-10 05:15:05 +00:00
|
|
|
BLI_insertlinkbefore(list, prev, island);
|
2009-01-05 09:54:39 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
static short rearrange_island_down(ListBase *list, tReorderChannelIsland *island)
|
2009-01-05 09:54:39 +00:00
|
|
|
{
|
2011-02-10 05:15:05 +00:00
|
|
|
if (rearrange_island_ok(island)) {
|
|
|
|
/* moving down = moving after the next island, otherwise we're in the same place */
|
|
|
|
tReorderChannelIsland *next = island->next;
|
2009-01-05 09:54:39 +00:00
|
|
|
|
|
|
|
if (next) {
|
2011-02-10 05:15:05 +00:00
|
|
|
/* can only move past if next is not untouchable (i.e. nothing can go after it) */
|
2012-05-08 15:30:00 +00:00
|
|
|
if ((next->flag & REORDER_ISLAND_UNTOUCHABLE) == 0) {
|
2011-02-10 05:15:05 +00:00
|
|
|
/* remove from current position */
|
|
|
|
BLI_remlink(list, island);
|
|
|
|
|
|
|
|
/* push it down */
|
|
|
|
BLI_insertlinkafter(list, next, island);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2009-01-05 09:54:39 +00:00
|
|
|
}
|
2011-02-10 05:15:05 +00:00
|
|
|
/* else: no next channel, so we're at the bottom already, so can't move */
|
2009-01-05 09:54:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
static short rearrange_island_bottom(ListBase *list, tReorderChannelIsland *island)
|
2009-01-05 09:54:39 +00:00
|
|
|
{
|
2011-02-10 05:15:05 +00:00
|
|
|
if (rearrange_island_ok(island)) {
|
|
|
|
tReorderChannelIsland *last = list->last;
|
|
|
|
|
|
|
|
/* remove island from current position */
|
|
|
|
BLI_remlink(list, island);
|
|
|
|
|
|
|
|
/* add before or after the last channel? */
|
2012-05-08 15:30:00 +00:00
|
|
|
if ((last->flag & REORDER_ISLAND_UNTOUCHABLE) == 0) {
|
2011-02-10 05:15:05 +00:00
|
|
|
/* can add after it */
|
|
|
|
BLI_addtail(list, island);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* can at most go just before it, since last cannot be moved */
|
|
|
|
BLI_insertlinkbefore(list, last, island);
|
2009-01-05 09:54:39 +00:00
|
|
|
|
|
|
|
}
|
2011-02-10 05:15:05 +00:00
|
|
|
|
|
|
|
return 1;
|
2009-01-05 09:54:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-02-10 05:15:05 +00:00
|
|
|
/* ............................. */
|
2009-01-05 09:54:39 +00:00
|
|
|
|
2010-11-07 12:09:15 +00:00
|
|
|
/* typedef for channel rearranging function
|
|
|
|
* < list: list that channels belong to
|
2011-02-10 05:15:05 +00:00
|
|
|
* < island: island to be moved
|
2010-11-07 12:09:15 +00:00
|
|
|
* > return[0]: whether operation was a success
|
2009-01-05 09:54:39 +00:00
|
|
|
*/
|
2011-02-10 05:15:05 +00:00
|
|
|
typedef short (*AnimChanRearrangeFp)(ListBase *list, tReorderChannelIsland *island);
|
2010-11-07 12:09:15 +00:00
|
|
|
|
|
|
|
/* get rearranging function, given 'rearrange' mode */
|
2012-05-08 15:30:00 +00:00
|
|
|
static AnimChanRearrangeFp rearrange_get_mode_func(short mode)
|
2009-01-05 09:54:39 +00:00
|
|
|
{
|
2010-11-07 12:09:15 +00:00
|
|
|
switch (mode) {
|
|
|
|
case REARRANGE_ANIMCHAN_TOP:
|
2011-02-10 05:15:05 +00:00
|
|
|
return rearrange_island_top;
|
2010-11-07 12:09:15 +00:00
|
|
|
case REARRANGE_ANIMCHAN_UP:
|
2011-02-10 05:15:05 +00:00
|
|
|
return rearrange_island_up;
|
2010-11-07 12:09:15 +00:00
|
|
|
case REARRANGE_ANIMCHAN_DOWN:
|
2011-02-10 05:15:05 +00:00
|
|
|
return rearrange_island_down;
|
2010-11-07 12:09:15 +00:00
|
|
|
case REARRANGE_ANIMCHAN_BOTTOM:
|
2011-02-10 05:15:05 +00:00
|
|
|
return rearrange_island_bottom;
|
2010-11-07 12:09:15 +00:00
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-10 05:15:05 +00:00
|
|
|
/* Rearrange Islands Generics ------------------------------------- */
|
2010-11-07 12:09:15 +00:00
|
|
|
|
2011-02-10 05:15:05 +00:00
|
|
|
/* add channel into list of islands */
|
2012-05-08 15:30:00 +00:00
|
|
|
static void rearrange_animchannel_add_to_islands(ListBase *islands, ListBase *srcList, Link *channel, short type)
|
2010-11-07 12:09:15 +00:00
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
tReorderChannelIsland *island = islands->last; /* always try to add to last island if possible */
|
|
|
|
short is_sel = 0, is_untouchable = 0;
|
2011-02-10 05:15:05 +00:00
|
|
|
|
|
|
|
/* get flags - selected and untouchable from the channel */
|
|
|
|
switch (type) {
|
|
|
|
case ANIMTYPE_GROUP:
|
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
bActionGroup *agrp = (bActionGroup *)channel;
|
2011-02-10 05:15:05 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
is_sel = SEL_AGRP(agrp);
|
|
|
|
is_untouchable = (agrp->flag & AGRP_TEMP) != 0;
|
2011-02-10 05:15:05 +00:00
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
break;
|
2011-02-10 05:15:05 +00:00
|
|
|
case ANIMTYPE_FCURVE:
|
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
FCurve *fcu = (FCurve *)channel;
|
2011-02-10 05:15:05 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
is_sel = SEL_FCU(fcu);
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
break;
|
2011-02-10 05:15:05 +00:00
|
|
|
case ANIMTYPE_NLATRACK:
|
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
NlaTrack *nlt = (NlaTrack *)channel;
|
2011-02-10 05:15:05 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
is_sel = SEL_NLT(nlt);
|
2011-02-10 05:15:05 +00:00
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
break;
|
2011-02-10 05:15:05 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
printf("rearrange_animchannel_add_to_islands(): don't know how to handle channels of type %d\n", type);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* do we need to add to a new island? */
|
|
|
|
if ((island == NULL) || /* 1) no islands yet */
|
2012-05-08 15:30:00 +00:00
|
|
|
((island->flag & REORDER_ISLAND_SELECTED) == 0) || /* 2) unselected islands have single channels only - to allow up/down movement */
|
|
|
|
(is_sel == 0)) /* 3) if channel is unselected, stop existing island (it was either wrong sel status, or full already) */
|
2011-02-10 05:15:05 +00:00
|
|
|
{
|
|
|
|
/* create a new island now */
|
|
|
|
island = MEM_callocN(sizeof(tReorderChannelIsland), "tReorderChannelIsland");
|
|
|
|
BLI_addtail(islands, island);
|
|
|
|
|
|
|
|
if (is_sel)
|
|
|
|
island->flag |= REORDER_ISLAND_SELECTED;
|
|
|
|
if (is_untouchable)
|
|
|
|
island->flag |= REORDER_ISLAND_UNTOUCHABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add channel to island - need to remove it from its existing list first though */
|
|
|
|
BLI_remlink(srcList, channel);
|
|
|
|
BLI_addtail(&island->channels, channel);
|
2010-11-07 12:09:15 +00:00
|
|
|
}
|
|
|
|
|
2011-02-10 05:15:05 +00:00
|
|
|
/* flatten islands out into a single list again */
|
2012-05-08 15:30:00 +00:00
|
|
|
static void rearrange_animchannel_flatten_islands(ListBase *islands, ListBase *srcList)
|
2010-11-07 12:09:15 +00:00
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
tReorderChannelIsland *island, *isn = NULL;
|
2011-02-10 05:15:05 +00:00
|
|
|
|
|
|
|
/* make sure srcList is empty now */
|
|
|
|
BLI_assert(srcList->first == NULL);
|
|
|
|
|
|
|
|
/* go through merging islands */
|
|
|
|
for (island = islands->first; island; island = isn) {
|
|
|
|
isn = island->next;
|
|
|
|
|
|
|
|
/* merge island channels back to main list, then delete the island */
|
|
|
|
BLI_movelisttolist(srcList, &island->channels);
|
|
|
|
BLI_freelinkN(islands, island);
|
|
|
|
}
|
2010-11-07 12:09:15 +00:00
|
|
|
}
|
|
|
|
|
2011-02-10 05:15:05 +00:00
|
|
|
/* ............................. */
|
2010-11-07 12:09:15 +00:00
|
|
|
|
2011-02-10 05:15:05 +00:00
|
|
|
/* performing rearranging of channels using islands */
|
2012-05-08 15:30:00 +00:00
|
|
|
static short rearrange_animchannel_islands(ListBase *list, AnimChanRearrangeFp rearrange_func, short mode, short type)
|
2010-11-07 12:09:15 +00:00
|
|
|
{
|
2011-02-10 05:15:05 +00:00
|
|
|
ListBase islands = {NULL, NULL};
|
2012-05-08 15:30:00 +00:00
|
|
|
Link *channel, *chanNext = NULL;
|
2012-05-19 13:28:19 +00:00
|
|
|
short done = FALSE;
|
2009-01-05 09:54:39 +00:00
|
|
|
|
2011-02-10 05:15:05 +00:00
|
|
|
/* don't waste effort on an empty list */
|
|
|
|
if (list->first == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* group channels into islands */
|
|
|
|
for (channel = list->first; channel; channel = chanNext) {
|
|
|
|
chanNext = channel->next;
|
|
|
|
rearrange_animchannel_add_to_islands(&islands, list, channel, type);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* perform moving of selected islands now, but only if there is more than one of 'em so that something will happen
|
|
|
|
* - scanning of the list is performed in the opposite direction to the direction we're moving things, so that we
|
|
|
|
* shouldn't need to encounter items we've moved already
|
|
|
|
*/
|
|
|
|
if (islands.first != islands.last) {
|
|
|
|
tReorderChannelIsland *first = (mode > 0) ? islands.last : islands.first;
|
2012-05-08 15:30:00 +00:00
|
|
|
tReorderChannelIsland *island, *isn = NULL;
|
2011-02-10 05:15:05 +00:00
|
|
|
|
|
|
|
for (island = first; island; island = isn) {
|
|
|
|
isn = (mode > 0) ? island->prev : island->next;
|
|
|
|
|
|
|
|
/* perform rearranging */
|
|
|
|
if (rearrange_func(&islands, island)) {
|
|
|
|
island->flag |= REORDER_ISLAND_MOVED;
|
2012-05-19 13:28:19 +00:00
|
|
|
done = TRUE;
|
2011-02-10 05:15:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-01-05 09:54:39 +00:00
|
|
|
|
2011-02-10 05:15:05 +00:00
|
|
|
/* ungroup islands */
|
|
|
|
rearrange_animchannel_flatten_islands(&islands, list);
|
|
|
|
|
|
|
|
/* did we do anything? */
|
|
|
|
return done;
|
2010-11-07 12:09:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* NLA Specific Stuff ----------------------------------------------------- */
|
|
|
|
|
|
|
|
/* Change the order NLA Tracks within NLA Stack
|
|
|
|
* ! NLA tracks are displayed in opposite order, so directions need care
|
|
|
|
* mode: REARRANGE_ANIMCHAN_*
|
|
|
|
*/
|
2012-05-08 15:30:00 +00:00
|
|
|
static void rearrange_nla_channels(bAnimContext *UNUSED(ac), AnimData *adt, short mode)
|
2010-11-07 12:09:15 +00:00
|
|
|
{
|
|
|
|
AnimChanRearrangeFp rearrange_func;
|
2009-01-05 09:54:39 +00:00
|
|
|
|
2010-11-07 12:09:15 +00:00
|
|
|
/* hack: invert mode so that functions will work in right order */
|
|
|
|
mode *= -1;
|
|
|
|
|
|
|
|
/* get rearranging function */
|
|
|
|
rearrange_func = rearrange_get_mode_func(mode);
|
|
|
|
if (rearrange_func == NULL)
|
|
|
|
return;
|
|
|
|
|
2012-10-21 05:46:41 +00:00
|
|
|
/* only consider NLA data if it's accessible */
|
2010-11-07 12:09:15 +00:00
|
|
|
//if (EXPANDED_DRVD(adt) == 0)
|
|
|
|
// return;
|
|
|
|
|
2011-02-10 05:15:05 +00:00
|
|
|
/* perform rearranging on tracks list */
|
|
|
|
rearrange_animchannel_islands(&adt->nla_tracks, rearrange_func, mode, ANIMTYPE_NLATRACK);
|
2010-11-07 12:09:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Drivers Specific Stuff ------------------------------------------------- */
|
|
|
|
|
|
|
|
/* Change the order drivers within AnimData block
|
|
|
|
* mode: REARRANGE_ANIMCHAN_*
|
|
|
|
*/
|
2012-05-08 15:30:00 +00:00
|
|
|
static void rearrange_driver_channels(bAnimContext *UNUSED(ac), AnimData *adt, short mode)
|
2010-11-07 12:09:15 +00:00
|
|
|
{
|
|
|
|
/* get rearranging function */
|
|
|
|
AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode);
|
|
|
|
|
|
|
|
if (rearrange_func == NULL)
|
|
|
|
return;
|
|
|
|
|
2012-10-21 05:46:41 +00:00
|
|
|
/* only consider drivers if they're accessible */
|
2010-11-07 12:09:15 +00:00
|
|
|
if (EXPANDED_DRVD(adt) == 0)
|
|
|
|
return;
|
|
|
|
|
2011-02-10 05:15:05 +00:00
|
|
|
/* perform rearranging on drivers list (drivers are really just F-Curves) */
|
|
|
|
rearrange_animchannel_islands(&adt->drivers, rearrange_func, mode, ANIMTYPE_FCURVE);
|
2010-11-07 12:09:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Action Specific Stuff ------------------------------------------------- */
|
|
|
|
|
|
|
|
/* make sure all action-channels belong to a group (and clear action's list) */
|
2012-05-08 15:30:00 +00:00
|
|
|
static void split_groups_action_temp(bAction *act, bActionGroup *tgrp)
|
2010-11-07 12:09:15 +00:00
|
|
|
{
|
|
|
|
bActionGroup *agrp;
|
|
|
|
FCurve *fcu;
|
|
|
|
|
|
|
|
if (act == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Separate F-Curves into lists per group */
|
2012-05-08 15:30:00 +00:00
|
|
|
for (agrp = act->groups.first; agrp; agrp = agrp->next) {
|
2010-11-07 12:09:15 +00:00
|
|
|
if (agrp->channels.first) {
|
2012-05-08 15:30:00 +00:00
|
|
|
fcu = agrp->channels.last;
|
|
|
|
act->curves.first = fcu->next;
|
2010-11-07 12:09:15 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
fcu = agrp->channels.first;
|
|
|
|
fcu->prev = NULL;
|
2010-11-07 12:09:15 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
fcu = agrp->channels.last;
|
|
|
|
fcu->next = NULL;
|
2010-11-07 12:09:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-01 12:20:18 +00:00
|
|
|
/* Initialize memory for temp-group */
|
2010-11-07 12:09:15 +00:00
|
|
|
memset(tgrp, 0, sizeof(bActionGroup));
|
2012-05-08 15:30:00 +00:00
|
|
|
tgrp->flag |= (AGRP_EXPANDED | AGRP_TEMP);
|
2010-11-07 12:09:15 +00:00
|
|
|
BLI_strncpy(tgrp->name, "#TempGroup", sizeof(tgrp->name));
|
|
|
|
|
|
|
|
/* Move any action-channels not already moved, to the temp group */
|
|
|
|
if (act->curves.first) {
|
|
|
|
/* start of list */
|
2012-05-08 15:30:00 +00:00
|
|
|
fcu = act->curves.first;
|
|
|
|
fcu->prev = NULL;
|
|
|
|
tgrp->channels.first = fcu;
|
|
|
|
act->curves.first = NULL;
|
2010-11-07 12:09:15 +00:00
|
|
|
|
|
|
|
/* end of list */
|
2012-05-08 15:30:00 +00:00
|
|
|
fcu = act->curves.last;
|
|
|
|
fcu->next = NULL;
|
|
|
|
tgrp->channels.last = fcu;
|
|
|
|
act->curves.last = NULL;
|
2010-11-07 12:09:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Add temp-group to list */
|
|
|
|
BLI_addtail(&act->groups, tgrp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* link lists of channels that groups have */
|
2012-05-08 15:30:00 +00:00
|
|
|
static void join_groups_action_temp(bAction *act)
|
2010-11-07 12:09:15 +00:00
|
|
|
{
|
|
|
|
bActionGroup *agrp;
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
for (agrp = act->groups.first; agrp; agrp = agrp->next) {
|
2010-11-07 12:09:15 +00:00
|
|
|
ListBase tempGroup;
|
|
|
|
|
|
|
|
/* add list of channels to action's channels */
|
2012-05-08 15:30:00 +00:00
|
|
|
tempGroup = agrp->channels;
|
2010-12-21 14:49:34 +00:00
|
|
|
BLI_movelisttolist(&act->curves, &agrp->channels);
|
2012-05-08 15:30:00 +00:00
|
|
|
agrp->channels = tempGroup;
|
2010-11-07 12:09:15 +00:00
|
|
|
|
|
|
|
/* clear moved flag */
|
|
|
|
agrp->flag &= ~AGRP_MOVED;
|
|
|
|
|
|
|
|
/* if temp-group... remove from list (but don't free as it's on the stack!) */
|
|
|
|
if (agrp->flag & AGRP_TEMP) {
|
|
|
|
BLI_remlink(&act->groups, agrp);
|
2009-01-05 09:54:39 +00:00
|
|
|
break;
|
2010-11-07 12:09:15 +00:00
|
|
|
}
|
2009-01-05 09:54:39 +00:00
|
|
|
}
|
2010-11-07 12:09:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Change the order of anim-channels within action
|
|
|
|
* mode: REARRANGE_ANIMCHAN_*
|
|
|
|
*/
|
2012-05-08 15:30:00 +00:00
|
|
|
static void rearrange_action_channels(bAnimContext *ac, bAction *act, short mode)
|
2010-11-07 12:09:15 +00:00
|
|
|
{
|
|
|
|
bActionGroup tgrp;
|
2011-02-10 05:15:05 +00:00
|
|
|
short do_channels;
|
2010-11-07 12:09:15 +00:00
|
|
|
|
|
|
|
/* get rearranging function */
|
|
|
|
AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode);
|
|
|
|
|
|
|
|
if (rearrange_func == NULL)
|
|
|
|
return;
|
|
|
|
|
2011-02-10 05:15:05 +00:00
|
|
|
/* make sure we're only operating with groups (vs a mixture of groups+curves) */
|
2009-01-05 09:54:39 +00:00
|
|
|
split_groups_action_temp(act, &tgrp);
|
|
|
|
|
2011-02-10 05:15:05 +00:00
|
|
|
/* rearrange groups first
|
|
|
|
* - the group's channels will only get considered if nothing happened when rearranging the groups
|
|
|
|
* i.e. the rearrange function returned 0
|
|
|
|
*/
|
|
|
|
do_channels = rearrange_animchannel_islands(&act->groups, rearrange_func, mode, ANIMTYPE_GROUP) == 0;
|
2009-01-05 09:54:39 +00:00
|
|
|
|
|
|
|
if (do_channels) {
|
2011-02-10 05:15:05 +00:00
|
|
|
bActionGroup *agrp;
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
for (agrp = act->groups.first; agrp; agrp = agrp->next) {
|
2010-11-07 12:09:15 +00:00
|
|
|
/* only consider F-Curves if they're visible (group expanded) */
|
2011-04-24 10:51:45 +00:00
|
|
|
if (EXPANDED_AGRP(ac, agrp)) {
|
2011-02-10 05:15:05 +00:00
|
|
|
rearrange_animchannel_islands(&agrp->channels, rearrange_func, mode, ANIMTYPE_FCURVE);
|
2009-01-05 09:54:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* assemble lists into one list (and clear moved tags) */
|
|
|
|
join_groups_action_temp(act);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------- */
|
|
|
|
|
|
|
|
static int animchannels_rearrange_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
bAnimContext ac;
|
|
|
|
short mode;
|
|
|
|
|
2010-11-07 12:09:15 +00:00
|
|
|
/* get editor data */
|
2009-01-05 09:54:39 +00:00
|
|
|
if (ANIM_animdata_get_context(C, &ac) == 0)
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
2010-11-07 12:09:15 +00:00
|
|
|
/* get mode */
|
2012-05-08 15:30:00 +00:00
|
|
|
mode = RNA_enum_get(op->ptr, "direction");
|
2009-01-05 09:54:39 +00:00
|
|
|
|
2011-08-21 07:08:15 +00:00
|
|
|
/* method to move channels depends on the editor */
|
|
|
|
if (ac.datatype == ANIMCONT_GPENCIL) {
|
|
|
|
/* Grease Pencil channels */
|
|
|
|
printf("Grease Pencil not supported for moving yet\n");
|
|
|
|
}
|
2012-06-08 14:31:38 +00:00
|
|
|
else if (ac.datatype == ANIMCONT_MASK) {
|
|
|
|
/* Grease Pencil channels */
|
|
|
|
printf("Mask does not supported for moving yet\n");
|
|
|
|
}
|
2011-08-21 07:08:15 +00:00
|
|
|
else if (ac.datatype == ANIMCONT_ACTION) {
|
|
|
|
/* Directly rearrange action's channels */
|
|
|
|
rearrange_action_channels(&ac, ac.data, mode);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ListBase anim_data = {NULL, NULL};
|
|
|
|
bAnimListElem *ale;
|
|
|
|
int filter;
|
2010-11-07 12:09:15 +00:00
|
|
|
|
2011-08-21 07:08:15 +00:00
|
|
|
/* get animdata blocks */
|
2012-05-08 15:30:00 +00:00
|
|
|
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA);
|
2011-08-21 07:08:15 +00:00
|
|
|
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
|
|
|
|
|
|
|
|
for (ale = anim_data.first; ale; ale = ale->next) {
|
2012-05-08 15:30:00 +00:00
|
|
|
AnimData *adt = ale->data;
|
2010-11-07 12:09:15 +00:00
|
|
|
|
2011-08-21 07:08:15 +00:00
|
|
|
switch (ac.datatype) {
|
|
|
|
case ANIMCONT_NLA: /* NLA-tracks only */
|
|
|
|
rearrange_nla_channels(&ac, adt, mode);
|
|
|
|
break;
|
2010-11-07 12:09:15 +00:00
|
|
|
|
2011-08-21 07:08:15 +00:00
|
|
|
case ANIMCONT_DRIVERS: /* Drivers list only */
|
|
|
|
rearrange_driver_channels(&ac, adt, mode);
|
|
|
|
break;
|
2010-11-07 12:09:15 +00:00
|
|
|
|
2011-08-21 07:08:15 +00:00
|
|
|
case ANIMCONT_SHAPEKEY: // DOUBLE CHECK ME...
|
|
|
|
|
|
|
|
default: /* some collection of actions */
|
|
|
|
if (adt->action)
|
|
|
|
rearrange_action_channels(&ac, adt->action, mode);
|
2012-03-31 00:59:17 +00:00
|
|
|
else if (G.debug & G_DEBUG)
|
2011-08-21 07:08:15 +00:00
|
|
|
printf("Animdata has no action\n");
|
|
|
|
break;
|
|
|
|
}
|
2010-11-07 12:09:15 +00:00
|
|
|
}
|
2011-08-21 07:08:15 +00:00
|
|
|
|
|
|
|
/* free temp data */
|
|
|
|
BLI_freelistN(&anim_data);
|
2010-11-07 12:09:15 +00:00
|
|
|
}
|
2009-01-05 09:54:39 +00:00
|
|
|
|
2010-11-07 12:09:15 +00:00
|
|
|
/* send notifier that things have changed */
|
2012-05-08 15:30:00 +00:00
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
|
2009-01-05 09:54:39 +00:00
|
|
|
|
2010-11-07 12:09:15 +00:00
|
|
|
return OPERATOR_FINISHED;
|
2009-01-05 09:54:39 +00:00
|
|
|
}
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
static void ANIM_OT_channels_move(wmOperatorType *ot)
|
2009-01-05 09:54:39 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Move Channels";
|
|
|
|
ot->idname = "ANIM_OT_channels_move";
|
2010-12-02 02:03:30 +00:00
|
|
|
ot->description = "Rearrange selected animation channels";
|
2009-01-05 09:54:39 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = animchannels_rearrange_exec;
|
|
|
|
ot->poll = animedit_poll_channels_nla_tweakmode_off;
|
2009-01-05 09:54:39 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-05-08 15:30:00 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-01-05 09:54:39 +00:00
|
|
|
|
|
|
|
/* props */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->prop = RNA_def_enum(ot->srna, "direction", prop_animchannel_rearrange_types, REARRANGE_ANIMCHAN_DOWN, "Direction", "");
|
2009-01-05 09:54:39 +00:00
|
|
|
}
|
2009-01-05 00:38:17 +00:00
|
|
|
|
2013-02-22 01:49:51 +00:00
|
|
|
/* ******************** Group Channel Operator ************************ */
|
|
|
|
|
|
|
|
static int animchannels_grouping_poll(bContext *C)
|
|
|
|
{
|
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
|
|
|
SpaceLink *sl;
|
|
|
|
|
|
|
|
/* channels region test */
|
|
|
|
/* TODO: could enhance with actually testing if channels region? */
|
|
|
|
if (ELEM(NULL, sa, CTX_wm_region(C)))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* animation editor test - must be suitable modes only */
|
|
|
|
sl = CTX_wm_space_data(C);
|
|
|
|
|
|
|
|
switch (sa->spacetype) {
|
|
|
|
/* supported... */
|
|
|
|
case SPACE_ACTION:
|
|
|
|
{
|
|
|
|
SpaceAction *saction = (SpaceAction *)sl;
|
|
|
|
|
|
|
|
/* dopesheet and action only - all others are for other datatypes or have no groups */
|
|
|
|
if (ELEM(saction->mode, SACTCONT_ACTION, SACTCONT_DOPESHEET) == 0)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SPACE_IPO:
|
|
|
|
{
|
|
|
|
SpaceIpo *sipo = (SpaceIpo *)sl;
|
|
|
|
|
|
|
|
/* drivers can't have groups... */
|
|
|
|
if (sipo->mode != SIPO_MODE_ANIMATION)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* unsupported... */
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------- */
|
|
|
|
|
|
|
|
static void animchannels_group_channels(bAnimContext *ac, bAnimListElem *adt_ref, const char name[])
|
|
|
|
{
|
|
|
|
AnimData *adt = adt_ref->adt;
|
|
|
|
bAction *act = adt->action;
|
|
|
|
|
|
|
|
if (act) {
|
|
|
|
ListBase anim_data = {NULL, NULL};
|
|
|
|
int filter;
|
|
|
|
|
|
|
|
/* find selected F-Curves to re-group */
|
|
|
|
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL);
|
|
|
|
ANIM_animdata_filter(ac, &anim_data, filter, adt_ref, ANIMCONT_CHANNEL);
|
|
|
|
|
|
|
|
if (anim_data.first) {
|
|
|
|
bActionGroup *agrp;
|
|
|
|
bAnimListElem *ale;
|
|
|
|
|
|
|
|
/* create new group, which should now be part of the action */
|
|
|
|
agrp = action_groups_add_new(act, name);
|
|
|
|
BLI_assert(agrp != NULL);
|
|
|
|
|
|
|
|
/* transfer selected F-Curves across to new group */
|
|
|
|
for (ale = anim_data.first; ale; ale = ale->next) {
|
|
|
|
FCurve *fcu = (FCurve *)ale->data;
|
|
|
|
bActionGroup *grp = fcu->grp;
|
|
|
|
|
|
|
|
/* remove F-Curve from group, then group too if it is now empty */
|
|
|
|
action_groups_remove_channel(act, fcu);
|
|
|
|
|
|
|
|
if ((grp) && (grp->channels.first == NULL)) {
|
|
|
|
BLI_freelinkN(&act->groups, grp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add F-Curve to group */
|
|
|
|
action_groups_add_channel(act, agrp, fcu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
BLI_freelistN(&anim_data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int animchannels_group_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
bAnimContext ac;
|
|
|
|
char name[MAX_NAME];
|
|
|
|
|
|
|
|
/* get editor data */
|
|
|
|
if (ANIM_animdata_get_context(C, &ac) == 0)
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
/* get name for new group */
|
|
|
|
RNA_string_get(op->ptr, "name", name);
|
|
|
|
|
|
|
|
/* XXX: name for group should never be empty... */
|
|
|
|
if (name[0]) {
|
|
|
|
ListBase anim_data = {NULL, NULL};
|
|
|
|
bAnimListElem *ale;
|
|
|
|
int filter;
|
|
|
|
|
|
|
|
/* handle each animdata block separately, so that the regrouping doesn't flow into blocks */
|
|
|
|
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_NODUPLIS);
|
|
|
|
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
|
|
|
|
|
|
|
|
for (ale = anim_data.first; ale; ale = ale->next) {
|
|
|
|
animchannels_group_channels(&ac, ale, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free temp data */
|
|
|
|
BLI_freelistN(&anim_data);
|
|
|
|
|
|
|
|
/* updatss */
|
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ANIM_OT_channels_group(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Group Channels";
|
|
|
|
ot->idname = "ANIM_OT_channels_group";
|
|
|
|
ot->description = "Add selected F-Curves to a new group";
|
|
|
|
|
|
|
|
/* callbacks */
|
|
|
|
ot->invoke = WM_operator_props_popup;
|
|
|
|
ot->exec = animchannels_group_exec;
|
|
|
|
ot->poll = animchannels_grouping_poll;
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
|
|
|
|
/* props */
|
|
|
|
ot->prop = RNA_def_string(ot->srna, "name", "New Group",
|
|
|
|
sizeof(((bActionGroup *)NULL)->name),
|
|
|
|
"Name", "Name of newly created group");
|
|
|
|
/* RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE); */ /* XXX: still not too sure about this - keeping same text is confusing... */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------- */
|
|
|
|
|
|
|
|
static int animchannels_ungroup_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
{
|
|
|
|
bAnimContext ac;
|
|
|
|
|
|
|
|
ListBase anim_data = {NULL, NULL};
|
|
|
|
bAnimListElem *ale;
|
|
|
|
int filter;
|
|
|
|
|
|
|
|
/* get editor data */
|
|
|
|
if (ANIM_animdata_get_context(C, &ac) == 0)
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
/* just selected F-Curves... */
|
|
|
|
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS);
|
|
|
|
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
|
|
|
|
|
|
|
|
for (ale = anim_data.first; ale; ale = ale->next) {
|
|
|
|
/* find action for this F-Curve... */
|
|
|
|
if (ale->adt && ale->adt->action) {
|
|
|
|
FCurve *fcu = (FCurve *)ale->data;
|
|
|
|
bAction *act = ale->adt->action;
|
|
|
|
|
|
|
|
/* only proceed to remove if F-Curve is in a group... */
|
|
|
|
if (fcu->grp) {
|
|
|
|
bActionGroup *agrp = fcu->grp;
|
|
|
|
|
|
|
|
/* remove F-Curve from group and add at tail (ungrouped) */
|
|
|
|
action_groups_remove_channel(act, fcu);
|
|
|
|
BLI_addtail(&act->curves, fcu);
|
|
|
|
|
|
|
|
/* delete group if it is now empty */
|
|
|
|
if (agrp->channels.first == NULL) {
|
|
|
|
BLI_freelinkN(&act->groups, agrp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
BLI_freelistN(&anim_data);
|
|
|
|
|
|
|
|
/* updates */
|
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ANIM_OT_channels_ungroup(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Ungroup Channels";
|
|
|
|
ot->idname = "ANIM_OT_channels_ungroup";
|
|
|
|
ot->description = "Remove selected F-Curves from their current groups";
|
|
|
|
|
|
|
|
/* callbacks */
|
|
|
|
ot->exec = animchannels_ungroup_exec;
|
|
|
|
ot->poll = animchannels_grouping_poll;
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
}
|
|
|
|
|
2009-07-10 12:11:00 +00:00
|
|
|
/* ******************** Delete Channel Operator *********************** */
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-07-10 12:11:00 +00:00
|
|
|
{
|
|
|
|
bAnimContext ac;
|
|
|
|
ListBase anim_data = {NULL, NULL};
|
|
|
|
bAnimListElem *ale;
|
|
|
|
int filter;
|
|
|
|
|
|
|
|
/* get editor data */
|
|
|
|
if (ANIM_animdata_get_context(C, &ac) == 0)
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
/* cannot delete in shapekey */
|
|
|
|
if (ac.datatype == ANIMCONT_SHAPEKEY)
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
|
|
|
|
/* do groups only first (unless in Drivers mode, where there are none) */
|
|
|
|
if (ac.datatype != ANIMCONT_DRIVERS) {
|
|
|
|
/* filter data */
|
2012-05-08 15:30:00 +00:00
|
|
|
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
2009-07-10 12:11:00 +00:00
|
|
|
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
|
|
|
|
|
|
|
|
/* delete selected groups and their associated channels */
|
2012-05-08 15:30:00 +00:00
|
|
|
for (ale = anim_data.first; ale; ale = ale->next) {
|
2009-07-10 12:11:00 +00:00
|
|
|
/* only groups - don't check other types yet, since they may no-longer exist */
|
|
|
|
if (ale->type == ANIMTYPE_GROUP) {
|
2012-05-08 15:30:00 +00:00
|
|
|
bActionGroup *agrp = (bActionGroup *)ale->data;
|
|
|
|
AnimData *adt = ale->adt;
|
2009-07-10 12:11:00 +00:00
|
|
|
FCurve *fcu, *fcn;
|
|
|
|
|
|
|
|
/* skip this group if no AnimData available, as we can't safely remove the F-Curves */
|
|
|
|
if (adt == NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* delete all of the Group's F-Curves, but no others */
|
2012-05-08 15:30:00 +00:00
|
|
|
for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcn) {
|
|
|
|
fcn = fcu->next;
|
2009-07-10 12:11:00 +00:00
|
|
|
|
|
|
|
/* remove from group and action, then free */
|
|
|
|
action_groups_remove_channel(adt->action, fcu);
|
|
|
|
free_fcurve(fcu);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free the group itself */
|
|
|
|
if (adt->action)
|
|
|
|
BLI_freelinkN(&adt->action->groups, agrp);
|
|
|
|
else
|
|
|
|
MEM_freeN(agrp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
BLI_freelistN(&anim_data);
|
|
|
|
}
|
|
|
|
|
2011-07-08 11:57:25 +00:00
|
|
|
/* filter data */
|
2012-05-08 15:30:00 +00:00
|
|
|
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
2011-07-08 11:57:25 +00:00
|
|
|
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
|
|
|
|
|
|
|
|
/* delete selected data channels */
|
2012-05-08 15:30:00 +00:00
|
|
|
for (ale = anim_data.first; ale; ale = ale->next) {
|
2011-07-08 11:57:25 +00:00
|
|
|
switch (ale->type) {
|
|
|
|
case ANIMTYPE_FCURVE:
|
|
|
|
{
|
|
|
|
/* F-Curves if we can identify its parent */
|
2012-05-08 15:30:00 +00:00
|
|
|
AnimData *adt = ale->adt;
|
|
|
|
FCurve *fcu = (FCurve *)ale->data;
|
2009-07-10 12:11:00 +00:00
|
|
|
|
2009-12-04 03:51:52 +00:00
|
|
|
/* try to free F-Curve */
|
|
|
|
ANIM_fcurve_delete_from_animdata(&ac, adt, fcu);
|
2009-07-10 12:11:00 +00:00
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
break;
|
2011-07-08 11:57:25 +00:00
|
|
|
|
|
|
|
case ANIMTYPE_GPLAYER:
|
|
|
|
{
|
|
|
|
/* Grease Pencil layer */
|
2012-05-08 15:30:00 +00:00
|
|
|
bGPdata *gpd = (bGPdata *)ale->id;
|
|
|
|
bGPDlayer *gpl = (bGPDlayer *)ale->data;
|
2011-07-08 11:57:25 +00:00
|
|
|
|
|
|
|
/* try to delete the layer's data and the layer itself */
|
|
|
|
free_gpencil_frames(gpl);
|
|
|
|
BLI_freelinkN(&gpd->layers, gpl);
|
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
break;
|
2013-02-22 01:49:51 +00:00
|
|
|
|
2012-06-08 14:31:38 +00:00
|
|
|
case ANIMTYPE_MASKLAYER:
|
|
|
|
{
|
2012-12-18 08:41:38 +00:00
|
|
|
/* Mask layer */
|
2012-06-08 14:31:38 +00:00
|
|
|
Mask *mask = (Mask *)ale->id;
|
|
|
|
MaskLayer *masklay = (MaskLayer *)ale->data;
|
2013-02-22 01:49:51 +00:00
|
|
|
|
2012-06-08 14:31:38 +00:00
|
|
|
/* try to delete the layer's data and the layer itself */
|
|
|
|
BKE_mask_layer_remove(mask, masklay);
|
|
|
|
}
|
|
|
|
break;
|
2009-07-10 12:11:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-08 11:57:25 +00:00
|
|
|
/* cleanup */
|
|
|
|
BLI_freelistN(&anim_data);
|
|
|
|
|
2009-07-10 12:11:00 +00:00
|
|
|
/* send notifier that things have changed */
|
2012-05-08 15:30:00 +00:00
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
|
2009-07-10 12:11:00 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
static void ANIM_OT_channels_delete(wmOperatorType *ot)
|
2009-07-10 12:11:00 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Delete Channels";
|
|
|
|
ot->idname = "ANIM_OT_channels_delete";
|
|
|
|
ot->description = "Delete all selected animation channels";
|
2009-07-10 12:11:00 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = animchannels_delete_exec;
|
|
|
|
ot->poll = animedit_poll_channels_active;
|
2009-07-10 12:11:00 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-05-08 15:30:00 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-07-10 12:11:00 +00:00
|
|
|
}
|
2009-02-10 11:37:14 +00:00
|
|
|
|
2009-11-30 11:10:03 +00:00
|
|
|
/* ******************** Set Channel Visibility Operator *********************** */
|
|
|
|
/* NOTE: this operator is only valid in the Graph Editor channels region */
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int animchannels_visibility_set_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-11-30 11:10:03 +00:00
|
|
|
{
|
|
|
|
bAnimContext ac;
|
|
|
|
ListBase anim_data = {NULL, NULL};
|
|
|
|
ListBase all_data = {NULL, NULL};
|
|
|
|
bAnimListElem *ale;
|
|
|
|
int filter;
|
|
|
|
|
|
|
|
/* get editor data */
|
|
|
|
if (ANIM_animdata_get_context(C, &ac) == 0)
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
Animation Channel Filtering Refactor - Part 3 (Visibility Flag Split)
* This (big) commit is aimed at cleaning up the filtering flags used
by the animation channel filtering code. The list of filtering flags
has been growing a bit "organically" since it's humble origins for use
in the Action Editor some 3 years (IIRC) ago now during a weekend
hackathon. Obviously, some things have ended up tacked on, while
others have been the product of other flag options. Nevertheless, it
was time for a bit of a spring clean!
* Most notably, one area where the system outgrown its original design
for the Action Editor was in terms of the "visibility" filtering flag
it was using. While in the Action Editor the concept of what channels
to include was strictly dictated by whether the channel hierarchy
showed it, in the Graph Editor this is not always the case. In other
words, there was a difference between the data the channels
represented being visible and the channels for that data being visible
in the hierarchy.
Long story short: this lead to bug report [#27076] (and many like it),
where if you selected an F-Curve, then collapsed the Group it was in,
then even after selecting another F-Curve in another Group, the
original F-Curve's properties would still be shown in the Properties
Region. The good news is that this commit fixes this issue right away!
* More good news will follow, as I start checking on the flag usage of
other tools, but I'm committing this first so that we have a stable
reference (of code similar to the old buggy stuff) on which we can
fall back to later to find bugs (should they pop up).
Anyways, back to the trenches!
2011-06-22 11:41:26 +00:00
|
|
|
/* get list of all channels that selection may need to be flushed to
|
|
|
|
* - hierarchy mustn't affect what we have access to here...
|
|
|
|
*/
|
2012-05-08 15:30:00 +00:00
|
|
|
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS);
|
2010-02-09 08:38:45 +00:00
|
|
|
ANIM_animdata_filter(&ac, &all_data, filter, ac.data, ac.datatype);
|
Animation Channel Filtering Refactor - Part 3 (Visibility Flag Split)
* This (big) commit is aimed at cleaning up the filtering flags used
by the animation channel filtering code. The list of filtering flags
has been growing a bit "organically" since it's humble origins for use
in the Action Editor some 3 years (IIRC) ago now during a weekend
hackathon. Obviously, some things have ended up tacked on, while
others have been the product of other flag options. Nevertheless, it
was time for a bit of a spring clean!
* Most notably, one area where the system outgrown its original design
for the Action Editor was in terms of the "visibility" filtering flag
it was using. While in the Action Editor the concept of what channels
to include was strictly dictated by whether the channel hierarchy
showed it, in the Graph Editor this is not always the case. In other
words, there was a difference between the data the channels
represented being visible and the channels for that data being visible
in the hierarchy.
Long story short: this lead to bug report [#27076] (and many like it),
where if you selected an F-Curve, then collapsed the Group it was in,
then even after selecting another F-Curve in another Group, the
original F-Curve's properties would still be shown in the Properties
Region. The good news is that this commit fixes this issue right away!
* More good news will follow, as I start checking on the flag usage of
other tools, but I'm committing this first so that we have a stable
reference (of code similar to the old buggy stuff) on which we can
fall back to later to find bugs (should they pop up).
Anyways, back to the trenches!
2011-06-22 11:41:26 +00:00
|
|
|
|
|
|
|
/* hide all channels not selected
|
2011-06-22 13:30:59 +00:00
|
|
|
* - hierarchy matters if we're doing this from the channels region
|
|
|
|
* since we only want to apply this to channels we can "see",
|
|
|
|
* and have these affect their relatives
|
|
|
|
* - but for Graph Editor, this gets used also from main region
|
|
|
|
* where hierarchy doesn't apply, as for [#21276]
|
Animation Channel Filtering Refactor - Part 3 (Visibility Flag Split)
* This (big) commit is aimed at cleaning up the filtering flags used
by the animation channel filtering code. The list of filtering flags
has been growing a bit "organically" since it's humble origins for use
in the Action Editor some 3 years (IIRC) ago now during a weekend
hackathon. Obviously, some things have ended up tacked on, while
others have been the product of other flag options. Nevertheless, it
was time for a bit of a spring clean!
* Most notably, one area where the system outgrown its original design
for the Action Editor was in terms of the "visibility" filtering flag
it was using. While in the Action Editor the concept of what channels
to include was strictly dictated by whether the channel hierarchy
showed it, in the Graph Editor this is not always the case. In other
words, there was a difference between the data the channels
represented being visible and the channels for that data being visible
in the hierarchy.
Long story short: this lead to bug report [#27076] (and many like it),
where if you selected an F-Curve, then collapsed the Group it was in,
then even after selecting another F-Curve in another Group, the
original F-Curve's properties would still be shown in the Properties
Region. The good news is that this commit fixes this issue right away!
* More good news will follow, as I start checking on the flag usage of
other tools, but I'm committing this first so that we have a stable
reference (of code similar to the old buggy stuff) on which we can
fall back to later to find bugs (should they pop up).
Anyways, back to the trenches!
2011-06-22 11:41:26 +00:00
|
|
|
*/
|
2011-06-22 13:30:59 +00:00
|
|
|
if ((ac.spacetype == SPACE_IPO) && (ac.regiontype != RGN_TYPE_CHANNELS)) {
|
|
|
|
/* graph editor (case 2) */
|
2012-05-08 15:30:00 +00:00
|
|
|
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_UNSEL | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
|
2011-06-22 13:30:59 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* standard case */
|
2012-05-08 15:30:00 +00:00
|
|
|
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_UNSEL | ANIMFILTER_NODUPLIS);
|
2011-06-22 13:30:59 +00:00
|
|
|
}
|
2009-11-30 11:10:03 +00:00
|
|
|
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
for (ale = anim_data.first; ale; ale = ale->next) {
|
2010-02-09 08:38:45 +00:00
|
|
|
/* clear setting first */
|
2009-11-30 11:10:03 +00:00
|
|
|
ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_VISIBLE, ACHANNEL_SETFLAG_CLEAR);
|
2010-02-09 08:38:45 +00:00
|
|
|
|
|
|
|
/* now also flush selection status as appropriate
|
|
|
|
* NOTE: in some cases, this may result in repeat flushing being performed
|
|
|
|
*/
|
|
|
|
ANIM_flush_setting_anim_channels(&ac, &all_data, ale, ACHANNEL_SETTING_VISIBLE, 0);
|
|
|
|
}
|
2009-11-30 11:10:03 +00:00
|
|
|
|
|
|
|
BLI_freelistN(&anim_data);
|
|
|
|
|
|
|
|
/* make all the selected channels visible */
|
2012-05-08 15:30:00 +00:00
|
|
|
filter = (ANIMFILTER_SEL | ANIMFILTER_NODUPLIS);
|
2009-11-30 11:10:03 +00:00
|
|
|
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
|
2012-07-06 23:56:59 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
for (ale = anim_data.first; ale; ale = ale->next) {
|
2009-11-30 11:10:03 +00:00
|
|
|
/* hack: skip object channels for now, since flushing those will always flush everything, but they are always included */
|
2012-07-06 23:56:59 +00:00
|
|
|
/* TODO: find out why this is the case, and fix that */
|
2009-11-30 11:10:03 +00:00
|
|
|
if (ale->type == ANIMTYPE_OBJECT)
|
|
|
|
continue;
|
2013-02-22 01:49:51 +00:00
|
|
|
|
2009-11-30 11:10:03 +00:00
|
|
|
/* enable the setting */
|
|
|
|
ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_VISIBLE, ACHANNEL_SETFLAG_ADD);
|
2013-02-22 01:49:51 +00:00
|
|
|
|
2009-11-30 11:10:03 +00:00
|
|
|
/* now, also flush selection status up/down as appropriate */
|
2010-01-10 11:09:30 +00:00
|
|
|
ANIM_flush_setting_anim_channels(&ac, &all_data, ale, ACHANNEL_SETTING_VISIBLE, 1);
|
2009-11-30 11:10:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BLI_freelistN(&anim_data);
|
|
|
|
BLI_freelistN(&all_data);
|
|
|
|
|
|
|
|
|
|
|
|
/* send notifier that things have changed */
|
2012-05-08 15:30:00 +00:00
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
|
2009-11-30 11:10:03 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
static void ANIM_OT_channels_visibility_set(wmOperatorType *ot)
|
2009-11-30 11:10:03 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Set Visibility";
|
|
|
|
ot->idname = "ANIM_OT_channels_visibility_set";
|
|
|
|
ot->description = "Make only the selected animation channels visible in the Graph Editor";
|
2009-11-30 11:10:03 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = animchannels_visibility_set_exec;
|
|
|
|
ot->poll = ED_operator_graphedit_active;
|
2009-11-30 11:10:03 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-05-08 15:30:00 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-11-30 11:10:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-02-10 11:37:14 +00:00
|
|
|
/* ******************** Toggle Channel Visibility Operator *********************** */
|
2009-11-30 11:10:03 +00:00
|
|
|
/* NOTE: this operator is only valid in the Graph Editor channels region */
|
2009-02-10 11:37:14 +00:00
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int animchannels_visibility_toggle_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-02-10 11:37:14 +00:00
|
|
|
{
|
|
|
|
bAnimContext ac;
|
|
|
|
ListBase anim_data = {NULL, NULL};
|
2009-11-30 11:10:03 +00:00
|
|
|
ListBase all_data = {NULL, NULL};
|
2009-02-10 11:37:14 +00:00
|
|
|
bAnimListElem *ale;
|
|
|
|
int filter;
|
2012-05-08 15:30:00 +00:00
|
|
|
short vis = ACHANNEL_SETFLAG_ADD;
|
2009-02-10 11:37:14 +00:00
|
|
|
|
|
|
|
/* get editor data */
|
|
|
|
if (ANIM_animdata_get_context(C, &ac) == 0)
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
Animation Channel Filtering Refactor - Part 3 (Visibility Flag Split)
* This (big) commit is aimed at cleaning up the filtering flags used
by the animation channel filtering code. The list of filtering flags
has been growing a bit "organically" since it's humble origins for use
in the Action Editor some 3 years (IIRC) ago now during a weekend
hackathon. Obviously, some things have ended up tacked on, while
others have been the product of other flag options. Nevertheless, it
was time for a bit of a spring clean!
* Most notably, one area where the system outgrown its original design
for the Action Editor was in terms of the "visibility" filtering flag
it was using. While in the Action Editor the concept of what channels
to include was strictly dictated by whether the channel hierarchy
showed it, in the Graph Editor this is not always the case. In other
words, there was a difference between the data the channels
represented being visible and the channels for that data being visible
in the hierarchy.
Long story short: this lead to bug report [#27076] (and many like it),
where if you selected an F-Curve, then collapsed the Group it was in,
then even after selecting another F-Curve in another Group, the
original F-Curve's properties would still be shown in the Properties
Region. The good news is that this commit fixes this issue right away!
* More good news will follow, as I start checking on the flag usage of
other tools, but I'm committing this first so that we have a stable
reference (of code similar to the old buggy stuff) on which we can
fall back to later to find bugs (should they pop up).
Anyways, back to the trenches!
2011-06-22 11:41:26 +00:00
|
|
|
/* get list of all channels that selection may need to be flushed to
|
|
|
|
* - hierarchy mustn't affect what we have access to here...
|
|
|
|
*/
|
2012-05-08 15:30:00 +00:00
|
|
|
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS);
|
2009-11-30 11:10:03 +00:00
|
|
|
ANIM_animdata_filter(&ac, &all_data, filter, ac.data, ac.datatype);
|
|
|
|
|
Animation Channel Filtering Refactor - Part 3 (Visibility Flag Split)
* This (big) commit is aimed at cleaning up the filtering flags used
by the animation channel filtering code. The list of filtering flags
has been growing a bit "organically" since it's humble origins for use
in the Action Editor some 3 years (IIRC) ago now during a weekend
hackathon. Obviously, some things have ended up tacked on, while
others have been the product of other flag options. Nevertheless, it
was time for a bit of a spring clean!
* Most notably, one area where the system outgrown its original design
for the Action Editor was in terms of the "visibility" filtering flag
it was using. While in the Action Editor the concept of what channels
to include was strictly dictated by whether the channel hierarchy
showed it, in the Graph Editor this is not always the case. In other
words, there was a difference between the data the channels
represented being visible and the channels for that data being visible
in the hierarchy.
Long story short: this lead to bug report [#27076] (and many like it),
where if you selected an F-Curve, then collapsed the Group it was in,
then even after selecting another F-Curve in another Group, the
original F-Curve's properties would still be shown in the Properties
Region. The good news is that this commit fixes this issue right away!
* More good news will follow, as I start checking on the flag usage of
other tools, but I'm committing this first so that we have a stable
reference (of code similar to the old buggy stuff) on which we can
fall back to later to find bugs (should they pop up).
Anyways, back to the trenches!
2011-06-22 11:41:26 +00:00
|
|
|
/* filter data
|
|
|
|
* - restrict this to only applying on settings we can get to in the list
|
|
|
|
*/
|
2012-05-08 15:30:00 +00:00
|
|
|
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS);
|
2009-02-10 11:37:14 +00:00
|
|
|
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
|
|
|
|
|
|
|
|
/* See if we should be making showing all selected or hiding */
|
2012-05-08 15:30:00 +00:00
|
|
|
for (ale = anim_data.first; ale; ale = ale->next) {
|
2009-10-16 10:44:10 +00:00
|
|
|
/* set the setting in the appropriate way (if available) */
|
2010-02-09 21:22:24 +00:00
|
|
|
if (ANIM_channel_setting_get(&ac, ale, ACHANNEL_SETTING_VISIBLE)) {
|
2012-05-08 15:30:00 +00:00
|
|
|
vis = ACHANNEL_SETFLAG_CLEAR;
|
2010-02-09 21:22:24 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-02-10 11:37:14 +00:00
|
|
|
}
|
2009-11-30 11:10:03 +00:00
|
|
|
|
2009-02-10 11:37:14 +00:00
|
|
|
/* Now set the flags */
|
2012-05-08 15:30:00 +00:00
|
|
|
for (ale = anim_data.first; ale; ale = ale->next) {
|
2009-12-03 10:27:22 +00:00
|
|
|
/* hack: skip object channels for now, since flushing those will always flush everything, but they are always included */
|
2012-07-06 23:56:59 +00:00
|
|
|
/* TODO: find out why this is the case, and fix that */
|
2009-12-03 10:27:22 +00:00
|
|
|
if (ale->type == ANIMTYPE_OBJECT)
|
|
|
|
continue;
|
2013-02-22 01:49:51 +00:00
|
|
|
|
2009-11-30 11:10:03 +00:00
|
|
|
/* change the setting */
|
2009-10-16 10:44:10 +00:00
|
|
|
ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_VISIBLE, vis);
|
2013-02-22 01:49:51 +00:00
|
|
|
|
2009-11-30 11:10:03 +00:00
|
|
|
/* now, also flush selection status up/down as appropriate */
|
2010-01-10 11:09:30 +00:00
|
|
|
ANIM_flush_setting_anim_channels(&ac, &all_data, ale, ACHANNEL_SETTING_VISIBLE, (vis == ACHANNEL_SETFLAG_ADD));
|
2009-02-10 11:37:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
BLI_freelistN(&anim_data);
|
2009-11-30 11:10:03 +00:00
|
|
|
BLI_freelistN(&all_data);
|
2009-02-10 11:37:14 +00:00
|
|
|
|
2009-07-10 10:48:25 +00:00
|
|
|
/* send notifier that things have changed */
|
2012-05-08 15:30:00 +00:00
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
|
2009-02-10 11:37:14 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
2010-02-09 21:22:24 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
static void ANIM_OT_channels_visibility_toggle(wmOperatorType *ot)
|
2009-02-10 11:37:14 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Toggle Visibility";
|
|
|
|
ot->idname = "ANIM_OT_channels_visibility_toggle";
|
|
|
|
ot->description = "Toggle visibility in Graph Editor of all selected animation channels";
|
2009-02-10 11:37:14 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = animchannels_visibility_toggle_exec;
|
|
|
|
ot->poll = ED_operator_graphedit_active;
|
2009-02-10 11:37:14 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-05-08 15:30:00 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-02-10 11:37:14 +00:00
|
|
|
}
|
|
|
|
|
2009-01-02 11:06:27 +00:00
|
|
|
/* ********************** Set Flags Operator *********************** */
|
|
|
|
|
|
|
|
/* defines for setting animation-channel flags */
|
2011-02-13 14:16:36 +00:00
|
|
|
static EnumPropertyItem prop_animchannel_setflag_types[] = {
|
2010-02-09 21:22:24 +00:00
|
|
|
{ACHANNEL_SETFLAG_TOGGLE, "TOGGLE", 0, "Toggle", ""},
|
2009-06-16 00:52:21 +00:00
|
|
|
{ACHANNEL_SETFLAG_CLEAR, "DISABLE", 0, "Disable", ""},
|
|
|
|
{ACHANNEL_SETFLAG_ADD, "ENABLE", 0, "Enable", ""},
|
2010-02-09 21:22:24 +00:00
|
|
|
{ACHANNEL_SETFLAG_INVERT, "INVERT", 0, "Invert", ""},
|
2009-06-16 00:52:21 +00:00
|
|
|
{0, NULL, 0, NULL, NULL}
|
2009-01-02 11:06:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* defines for set animation-channel settings */
|
2009-08-11 11:52:23 +00:00
|
|
|
// TODO: could add some more types, but those are really quite dependent on the mode...
|
2011-02-13 14:16:36 +00:00
|
|
|
static EnumPropertyItem prop_animchannel_settings_types[] = {
|
2009-06-16 00:52:21 +00:00
|
|
|
{ACHANNEL_SETTING_PROTECT, "PROTECT", 0, "Protect", ""},
|
|
|
|
{ACHANNEL_SETTING_MUTE, "MUTE", 0, "Mute", ""},
|
|
|
|
{0, NULL, 0, NULL, NULL}
|
2009-01-02 11:06:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* ------------------- */
|
|
|
|
|
|
|
|
/* Set/clear a particular flag (setting) for all selected + visible channels
|
|
|
|
* setting: the setting to modify
|
|
|
|
* mode: eAnimChannels_SetFlag
|
2009-04-08 12:35:38 +00:00
|
|
|
* onlysel: only selected channels get the flag set
|
2009-01-02 11:06:27 +00:00
|
|
|
*/
|
2010-02-09 21:22:24 +00:00
|
|
|
// TODO: enable a setting which turns flushing on/off?
|
2012-05-08 15:30:00 +00:00
|
|
|
static void setflag_anim_channels(bAnimContext *ac, short setting, short mode, short onlysel, short flush)
|
2009-01-02 11:06:27 +00:00
|
|
|
{
|
|
|
|
ListBase anim_data = {NULL, NULL};
|
2010-02-09 21:22:24 +00:00
|
|
|
ListBase all_data = {NULL, NULL};
|
2009-01-02 11:06:27 +00:00
|
|
|
bAnimListElem *ale;
|
|
|
|
int filter;
|
|
|
|
|
2010-02-09 21:22:24 +00:00
|
|
|
/* filter data that we need if flush is on */
|
|
|
|
if (flush) {
|
Animation Channel Filtering Refactor - Part 3 (Visibility Flag Split)
* This (big) commit is aimed at cleaning up the filtering flags used
by the animation channel filtering code. The list of filtering flags
has been growing a bit "organically" since it's humble origins for use
in the Action Editor some 3 years (IIRC) ago now during a weekend
hackathon. Obviously, some things have ended up tacked on, while
others have been the product of other flag options. Nevertheless, it
was time for a bit of a spring clean!
* Most notably, one area where the system outgrown its original design
for the Action Editor was in terms of the "visibility" filtering flag
it was using. While in the Action Editor the concept of what channels
to include was strictly dictated by whether the channel hierarchy
showed it, in the Graph Editor this is not always the case. In other
words, there was a difference between the data the channels
represented being visible and the channels for that data being visible
in the hierarchy.
Long story short: this lead to bug report [#27076] (and many like it),
where if you selected an F-Curve, then collapsed the Group it was in,
then even after selecting another F-Curve in another Group, the
original F-Curve's properties would still be shown in the Properties
Region. The good news is that this commit fixes this issue right away!
* More good news will follow, as I start checking on the flag usage of
other tools, but I'm committing this first so that we have a stable
reference (of code similar to the old buggy stuff) on which we can
fall back to later to find bugs (should they pop up).
Anyways, back to the trenches!
2011-06-22 11:41:26 +00:00
|
|
|
/* get list of all channels that selection may need to be flushed to
|
|
|
|
* - hierarchy visibility needs to be ignored so that settings can get flushed
|
|
|
|
* "down" inside closed containers
|
|
|
|
*/
|
2012-05-08 15:30:00 +00:00
|
|
|
filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS;
|
2010-02-09 21:22:24 +00:00
|
|
|
ANIM_animdata_filter(ac, &all_data, filter, ac->data, ac->datatype);
|
|
|
|
}
|
|
|
|
|
Animation Channel Filtering Refactor - Part 3 (Visibility Flag Split)
* This (big) commit is aimed at cleaning up the filtering flags used
by the animation channel filtering code. The list of filtering flags
has been growing a bit "organically" since it's humble origins for use
in the Action Editor some 3 years (IIRC) ago now during a weekend
hackathon. Obviously, some things have ended up tacked on, while
others have been the product of other flag options. Nevertheless, it
was time for a bit of a spring clean!
* Most notably, one area where the system outgrown its original design
for the Action Editor was in terms of the "visibility" filtering flag
it was using. While in the Action Editor the concept of what channels
to include was strictly dictated by whether the channel hierarchy
showed it, in the Graph Editor this is not always the case. In other
words, there was a difference between the data the channels
represented being visible and the channels for that data being visible
in the hierarchy.
Long story short: this lead to bug report [#27076] (and many like it),
where if you selected an F-Curve, then collapsed the Group it was in,
then even after selecting another F-Curve in another Group, the
original F-Curve's properties would still be shown in the Properties
Region. The good news is that this commit fixes this issue right away!
* More good news will follow, as I start checking on the flag usage of
other tools, but I'm committing this first so that we have a stable
reference (of code similar to the old buggy stuff) on which we can
fall back to later to find bugs (should they pop up).
Anyways, back to the trenches!
2011-06-22 11:41:26 +00:00
|
|
|
/* filter data that we're working on
|
|
|
|
* - hierarchy matters if we're doing this from the channels region
|
|
|
|
* since we only want to apply this to channels we can "see",
|
|
|
|
* and have these affect their relatives
|
|
|
|
* - but for Graph Editor, this gets used also from main region
|
|
|
|
* where hierarchy doesn't apply [#21276]
|
|
|
|
*/
|
2011-06-22 12:54:26 +00:00
|
|
|
if ((ac->spacetype == SPACE_IPO) && (ac->regiontype != RGN_TYPE_CHANNELS)) {
|
|
|
|
/* graph editor (case 2) */
|
2012-05-08 15:30:00 +00:00
|
|
|
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
|
2011-06-22 12:54:26 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* standard case */
|
2012-05-08 15:30:00 +00:00
|
|
|
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS);
|
2011-06-22 12:54:26 +00:00
|
|
|
}
|
2009-04-08 12:35:38 +00:00
|
|
|
if (onlysel) filter |= ANIMFILTER_SEL;
|
2009-01-26 04:13:38 +00:00
|
|
|
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
2009-01-02 11:06:27 +00:00
|
|
|
|
2010-02-09 21:22:24 +00:00
|
|
|
/* if toggling, check if disable or enable */
|
|
|
|
if (mode == ACHANNEL_SETFLAG_TOGGLE) {
|
|
|
|
/* default to turn all on, unless we encounter one that's on... */
|
2012-05-08 15:30:00 +00:00
|
|
|
mode = ACHANNEL_SETFLAG_ADD;
|
2010-02-09 21:22:24 +00:00
|
|
|
|
|
|
|
/* see if we should turn off instead... */
|
2012-05-08 15:30:00 +00:00
|
|
|
for (ale = anim_data.first; ale; ale = ale->next) {
|
2010-02-09 21:22:24 +00:00
|
|
|
/* set the setting in the appropriate way (if available) */
|
|
|
|
if (ANIM_channel_setting_get(ac, ale, setting) > 0) {
|
2012-05-08 15:30:00 +00:00
|
|
|
mode = ACHANNEL_SETFLAG_CLEAR;
|
2010-02-09 21:22:24 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* apply the setting */
|
2012-05-08 15:30:00 +00:00
|
|
|
for (ale = anim_data.first; ale; ale = ale->next) {
|
2010-02-09 21:22:24 +00:00
|
|
|
/* skip channel if setting is not available */
|
|
|
|
if (ANIM_channel_setting_get(ac, ale, setting) == -1)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* set the setting in the appropriate way */
|
2009-08-11 11:52:23 +00:00
|
|
|
ANIM_channel_setting_set(ac, ale, setting, mode);
|
2010-02-09 21:22:24 +00:00
|
|
|
|
|
|
|
/* if flush status... */
|
|
|
|
if (flush)
|
|
|
|
ANIM_flush_setting_anim_channels(ac, &all_data, ale, setting, mode);
|
2009-01-02 11:06:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BLI_freelistN(&anim_data);
|
2010-02-09 21:22:24 +00:00
|
|
|
BLI_freelistN(&all_data);
|
2009-01-02 11:06:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------- */
|
|
|
|
|
|
|
|
static int animchannels_setflag_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
bAnimContext ac;
|
|
|
|
short mode, setting;
|
2012-05-08 15:30:00 +00:00
|
|
|
short flush = 1;
|
2009-01-02 11:06:27 +00:00
|
|
|
|
|
|
|
/* get editor data */
|
|
|
|
if (ANIM_animdata_get_context(C, &ac) == 0)
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
/* mode (eAnimChannels_SetFlag), setting (eAnimChannel_Settings) */
|
2012-05-08 15:30:00 +00:00
|
|
|
mode = RNA_enum_get(op->ptr, "mode");
|
|
|
|
setting = RNA_enum_get(op->ptr, "type");
|
2009-01-02 11:06:27 +00:00
|
|
|
|
2010-02-09 21:22:24 +00:00
|
|
|
/* check if setting is flushable */
|
|
|
|
if (setting == ACHANNEL_SETTING_EXPAND)
|
2012-05-08 15:30:00 +00:00
|
|
|
flush = 0;
|
2010-02-09 21:22:24 +00:00
|
|
|
|
|
|
|
/* modify setting
|
|
|
|
* - only selected channels are affected
|
|
|
|
*/
|
|
|
|
setflag_anim_channels(&ac, setting, mode, 1, flush);
|
2009-01-02 11:06:27 +00:00
|
|
|
|
2009-07-10 10:48:25 +00:00
|
|
|
/* send notifier that things have changed */
|
2012-05-08 15:30:00 +00:00
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
|
2009-01-02 11:06:27 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2012-02-02 04:59:30 +00:00
|
|
|
/* duplicate of 'ANIM_OT_channels_setting_toggle' for menu title only, weak! */
|
2012-05-08 15:30:00 +00:00
|
|
|
static void ANIM_OT_channels_setting_enable(wmOperatorType *ot)
|
2009-01-02 11:06:27 +00:00
|
|
|
{
|
2012-11-20 02:03:20 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2009-01-02 11:06:27 +00:00
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Enable Channel Setting";
|
|
|
|
ot->idname = "ANIM_OT_channels_setting_enable";
|
|
|
|
ot->description = "Enable specified setting on all selected animation channels";
|
2009-01-02 11:06:27 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = WM_menu_invoke;
|
|
|
|
ot->exec = animchannels_setflag_exec;
|
|
|
|
ot->poll = animedit_poll_channels_active;
|
2009-01-02 11:06:27 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-05-08 15:30:00 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-01-02 11:06:27 +00:00
|
|
|
|
|
|
|
/* props */
|
2012-05-08 15:30:00 +00:00
|
|
|
/* flag-setting mode */
|
2012-11-20 02:03:20 +00:00
|
|
|
prop = RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_ADD, "Mode", "");
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN);
|
2012-05-08 15:30:00 +00:00
|
|
|
/* setting to set */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->prop = RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, 0, "Type", "");
|
2009-01-02 11:06:27 +00:00
|
|
|
}
|
2012-02-02 04:59:30 +00:00
|
|
|
/* duplicate of 'ANIM_OT_channels_setting_toggle' for menu title only, weak! */
|
2012-05-08 15:30:00 +00:00
|
|
|
static void ANIM_OT_channels_setting_disable(wmOperatorType *ot)
|
2009-01-02 11:06:27 +00:00
|
|
|
{
|
2012-11-20 02:03:20 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2009-01-02 11:06:27 +00:00
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Disable Channel Setting";
|
|
|
|
ot->idname = "ANIM_OT_channels_setting_disable";
|
|
|
|
ot->description = "Disable specified setting on all selected animation channels";
|
2009-01-02 11:06:27 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = WM_menu_invoke;
|
|
|
|
ot->exec = animchannels_setflag_exec;
|
|
|
|
ot->poll = animedit_poll_channels_active;
|
2009-01-02 11:06:27 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-05-08 15:30:00 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-01-02 11:06:27 +00:00
|
|
|
|
|
|
|
/* props */
|
2012-05-08 15:30:00 +00:00
|
|
|
/* flag-setting mode */
|
2012-11-20 02:03:20 +00:00
|
|
|
prop = RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_CLEAR, "Mode", "");
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN); /* internal hack - don't expose */
|
2012-05-08 15:30:00 +00:00
|
|
|
/* setting to set */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->prop = RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, 0, "Type", "");
|
2009-01-02 11:06:27 +00:00
|
|
|
}
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
static void ANIM_OT_channels_setting_toggle(wmOperatorType *ot)
|
2009-01-02 11:06:27 +00:00
|
|
|
{
|
2012-11-20 02:03:20 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2009-01-02 11:06:27 +00:00
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Toggle Channel Setting";
|
|
|
|
ot->idname = "ANIM_OT_channels_setting_toggle";
|
|
|
|
ot->description = "Toggle specified setting on all selected animation channels";
|
2009-01-02 11:06:27 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = WM_menu_invoke;
|
|
|
|
ot->exec = animchannels_setflag_exec;
|
|
|
|
ot->poll = animedit_poll_channels_active;
|
2009-01-02 11:06:27 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-05-08 15:30:00 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-01-02 11:06:27 +00:00
|
|
|
|
|
|
|
/* props */
|
2012-05-08 15:30:00 +00:00
|
|
|
/* flag-setting mode */
|
2012-11-20 02:03:20 +00:00
|
|
|
prop = RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_TOGGLE, "Mode", "");
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN); /* internal hack - don't expose */
|
2012-05-08 15:30:00 +00:00
|
|
|
/* setting to set */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->prop = RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, 0, "Type", "");
|
2009-01-02 11:06:27 +00:00
|
|
|
}
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
static void ANIM_OT_channels_editable_toggle(wmOperatorType *ot)
|
2009-02-22 05:55:37 +00:00
|
|
|
{
|
2012-11-20 02:03:20 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2009-02-22 05:55:37 +00:00
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Toggle Channel Editability";
|
|
|
|
ot->idname = "ANIM_OT_channels_editable_toggle";
|
|
|
|
ot->description = "Toggle editability of selected channels";
|
2009-02-22 05:55:37 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = animchannels_setflag_exec;
|
|
|
|
ot->poll = animedit_poll_channels_active;
|
2009-02-22 05:55:37 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-05-08 15:30:00 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-02-22 05:55:37 +00:00
|
|
|
|
|
|
|
/* props */
|
2012-05-08 15:30:00 +00:00
|
|
|
/* flag-setting mode */
|
2009-02-22 05:55:37 +00:00
|
|
|
RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_TOGGLE, "Mode", "");
|
2012-05-08 15:30:00 +00:00
|
|
|
/* setting to set */
|
2012-11-20 02:03:20 +00:00
|
|
|
prop = RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, ACHANNEL_SETTING_PROTECT, "Type", "");
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN); /* internal hack - don't expose */
|
2009-02-22 05:55:37 +00:00
|
|
|
}
|
|
|
|
|
2009-04-08 12:35:38 +00:00
|
|
|
/* ********************** Expand Channels Operator *********************** */
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
static int animchannels_expand_exec(bContext *C, wmOperator *op)
|
2009-04-08 12:35:38 +00:00
|
|
|
{
|
|
|
|
bAnimContext ac;
|
2012-05-08 15:30:00 +00:00
|
|
|
short onlysel = 1;
|
2009-04-08 12:35:38 +00:00
|
|
|
|
|
|
|
/* get editor data */
|
|
|
|
if (ANIM_animdata_get_context(C, &ac) == 0)
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
/* only affect selected channels? */
|
|
|
|
if (RNA_boolean_get(op->ptr, "all"))
|
2012-05-08 15:30:00 +00:00
|
|
|
onlysel = 0;
|
2009-04-08 12:35:38 +00:00
|
|
|
|
|
|
|
/* modify setting */
|
2010-02-09 21:22:24 +00:00
|
|
|
setflag_anim_channels(&ac, ACHANNEL_SETTING_EXPAND, ACHANNEL_SETFLAG_ADD, onlysel, 0);
|
2009-04-08 12:35:38 +00:00
|
|
|
|
2009-07-10 10:48:25 +00:00
|
|
|
/* send notifier that things have changed */
|
2012-05-08 15:30:00 +00:00
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
|
2009-04-08 12:35:38 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
static void ANIM_OT_channels_expand(wmOperatorType *ot)
|
2009-04-08 12:35:38 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Expand Channels";
|
|
|
|
ot->idname = "ANIM_OT_channels_expand";
|
|
|
|
ot->description = "Expand (i.e. open) all selected expandable animation channels";
|
2009-04-08 12:35:38 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = animchannels_expand_exec;
|
|
|
|
ot->poll = animedit_poll_channels_active;
|
2009-04-08 12:35:38 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-05-08 15:30:00 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-04-08 12:35:38 +00:00
|
|
|
|
|
|
|
/* props */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->prop = RNA_def_boolean(ot->srna, "all", 1, "All", "Expand all channels (not just selected ones)");
|
2009-04-08 12:35:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ********************** Collapse Channels Operator *********************** */
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
static int animchannels_collapse_exec(bContext *C, wmOperator *op)
|
2009-04-08 12:35:38 +00:00
|
|
|
{
|
|
|
|
bAnimContext ac;
|
2012-05-08 15:30:00 +00:00
|
|
|
short onlysel = 1;
|
2009-04-08 12:35:38 +00:00
|
|
|
|
|
|
|
/* get editor data */
|
|
|
|
if (ANIM_animdata_get_context(C, &ac) == 0)
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
/* only affect selected channels? */
|
|
|
|
if (RNA_boolean_get(op->ptr, "all"))
|
2012-05-08 15:30:00 +00:00
|
|
|
onlysel = 0;
|
2009-04-08 12:35:38 +00:00
|
|
|
|
|
|
|
/* modify setting */
|
2010-02-09 21:22:24 +00:00
|
|
|
setflag_anim_channels(&ac, ACHANNEL_SETTING_EXPAND, ACHANNEL_SETFLAG_CLEAR, onlysel, 0);
|
2009-04-08 12:35:38 +00:00
|
|
|
|
2009-07-10 10:48:25 +00:00
|
|
|
/* send notifier that things have changed */
|
2012-05-08 15:30:00 +00:00
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
|
2009-04-08 12:35:38 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
static void ANIM_OT_channels_collapse(wmOperatorType *ot)
|
2009-04-08 12:35:38 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Collapse Channels";
|
|
|
|
ot->idname = "ANIM_OT_channels_collapse";
|
|
|
|
ot->description = "Collapse (i.e. close) all selected expandable animation channels";
|
2009-04-08 12:35:38 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = animchannels_collapse_exec;
|
|
|
|
ot->poll = animedit_poll_channels_active;
|
2009-04-08 12:35:38 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-05-08 15:30:00 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-04-08 12:35:38 +00:00
|
|
|
|
|
|
|
/* props */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->prop = RNA_def_boolean(ot->srna, "all", 1, "All", "Collapse all channels (not just selected ones)");
|
2009-04-08 12:35:38 +00:00
|
|
|
}
|
|
|
|
|
2010-11-11 11:56:50 +00:00
|
|
|
/* ******************* Reenable Disabled Operator ******************* */
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
static int animchannels_enable_poll(bContext *C)
|
2010-11-11 11:56:50 +00:00
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
2012-07-06 23:56:59 +00:00
|
|
|
|
2010-11-11 11:56:50 +00:00
|
|
|
/* channels region test */
|
2012-07-06 23:56:59 +00:00
|
|
|
/* TODO: could enhance with actually testing if channels region? */
|
2010-11-11 11:56:50 +00:00
|
|
|
if (ELEM(NULL, sa, CTX_wm_region(C)))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* animation editor test - Action/Dopesheet/etc. and Graph only */
|
|
|
|
if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_IPO) == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
static int animchannels_enable_exec(bContext *C, wmOperator *UNUSED(op))
|
2010-11-11 11:56:50 +00:00
|
|
|
{
|
|
|
|
bAnimContext ac;
|
|
|
|
|
|
|
|
ListBase anim_data = {NULL, NULL};
|
|
|
|
bAnimListElem *ale;
|
|
|
|
int filter;
|
|
|
|
|
|
|
|
/* get editor data */
|
|
|
|
if (ANIM_animdata_get_context(C, &ac) == 0)
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
/* filter data */
|
2012-05-08 15:30:00 +00:00
|
|
|
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS);
|
2010-11-11 11:56:50 +00:00
|
|
|
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
|
|
|
|
|
|
|
|
/* loop through filtered data and clean curves */
|
2012-05-08 15:30:00 +00:00
|
|
|
for (ale = anim_data.first; ale; ale = ale->next) {
|
2010-11-11 11:56:50 +00:00
|
|
|
FCurve *fcu = (FCurve *)ale->data;
|
2011-03-27 23:11:22 +00:00
|
|
|
|
|
|
|
/* remove disabled flags from F-Curves */
|
2010-11-11 11:56:50 +00:00
|
|
|
fcu->flag &= ~FCURVE_DISABLED;
|
2011-03-27 23:11:22 +00:00
|
|
|
|
|
|
|
/* for drivers, let's do the same too */
|
|
|
|
if (fcu->driver)
|
|
|
|
fcu->driver->flag &= ~DRIVER_FLAG_INVALID;
|
|
|
|
|
|
|
|
/* tag everything for updates - in particular, this is needed to get drivers working again */
|
|
|
|
ANIM_list_elem_update(ac.scene, ale);
|
2010-11-11 11:56:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* free temp data */
|
|
|
|
BLI_freelistN(&anim_data);
|
|
|
|
|
|
|
|
/* send notifier that things have changed */
|
2012-05-08 15:30:00 +00:00
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
|
2010-11-11 11:56:50 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
static void ANIM_OT_channels_fcurves_enable(wmOperatorType *ot)
|
2010-11-11 11:56:50 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Revive Disabled F-Curves";
|
|
|
|
ot->idname = "ANIM_OT_channels_fcurves_enable";
|
|
|
|
ot->description = "Clears 'disabled' tag from all F-Curves to get broken F-Curves working again";
|
2010-11-11 11:56:50 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = animchannels_enable_exec;
|
|
|
|
ot->poll = animchannels_enable_poll;
|
2010-11-11 11:56:50 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-05-08 15:30:00 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2010-11-11 11:56:50 +00:00
|
|
|
}
|
|
|
|
|
2009-01-01 08:08:55 +00:00
|
|
|
/* ********************** Select All Operator *********************** */
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
static int animchannels_deselectall_exec(bContext *C, wmOperator *op)
|
2009-01-02 00:56:48 +00:00
|
|
|
{
|
|
|
|
bAnimContext ac;
|
|
|
|
|
|
|
|
/* get editor data */
|
|
|
|
if (ANIM_animdata_get_context(C, &ac) == 0)
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
2012-03-01 12:20:18 +00:00
|
|
|
/* 'standard' behavior - check if selected, then apply relevant selection */
|
2009-01-02 00:56:48 +00:00
|
|
|
if (RNA_boolean_get(op->ptr, "invert"))
|
2010-01-23 03:04:37 +00:00
|
|
|
ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, 0, ACHANNEL_SETFLAG_TOGGLE);
|
2009-01-02 00:56:48 +00:00
|
|
|
else
|
2010-01-23 03:04:37 +00:00
|
|
|
ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, 1, ACHANNEL_SETFLAG_ADD);
|
2009-01-02 00:56:48 +00:00
|
|
|
|
2009-07-10 10:48:25 +00:00
|
|
|
/* send notifier that things have changed */
|
2012-05-08 15:30:00 +00:00
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
|
2009-01-02 00:56:48 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
static void ANIM_OT_channels_select_all_toggle(wmOperatorType *ot)
|
2009-01-02 00:56:48 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Select All";
|
|
|
|
ot->idname = "ANIM_OT_channels_select_all_toggle";
|
|
|
|
ot->description = "Toggle selection of all animation channels";
|
2009-01-02 00:56:48 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = animchannels_deselectall_exec;
|
|
|
|
ot->poll = animedit_poll_channels_nla_tweakmode_off;
|
2009-01-02 00:56:48 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-05-08 15:30:00 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-01-02 00:56:48 +00:00
|
|
|
|
|
|
|
/* props */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->prop = RNA_def_boolean(ot->srna, "invert", 0, "Invert", "");
|
2009-01-02 00:56:48 +00:00
|
|
|
}
|
2009-01-01 00:18:23 +00:00
|
|
|
|
2009-01-02 01:28:05 +00:00
|
|
|
/* ******************** Borderselect Operator *********************** */
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
static void borderselect_anim_channels(bAnimContext *ac, rcti *rect, short selectmode)
|
2009-01-02 01:28:05 +00:00
|
|
|
{
|
|
|
|
ListBase anim_data = {NULL, NULL};
|
|
|
|
bAnimListElem *ale;
|
|
|
|
int filter;
|
|
|
|
|
2011-07-06 01:34:10 +00:00
|
|
|
SpaceNla *snla = (SpaceNla *)ac->sl;
|
2012-05-08 15:30:00 +00:00
|
|
|
View2D *v2d = &ac->ar->v2d;
|
2009-01-02 01:28:05 +00:00
|
|
|
rctf rectf;
|
2010-11-07 12:09:15 +00:00
|
|
|
float ymin, ymax;
|
|
|
|
|
|
|
|
/* set initial y extents */
|
2010-11-07 12:15:21 +00:00
|
|
|
if (ac->datatype == ANIMCONT_NLA) {
|
2011-07-06 01:34:10 +00:00
|
|
|
ymin = (float)(-NLACHANNEL_HEIGHT(snla));
|
2010-11-07 12:15:21 +00:00
|
|
|
ymax = 0.0f;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ymin = 0.0f;
|
2010-11-07 12:09:15 +00:00
|
|
|
ymax = (float)(-ACHANNEL_HEIGHT);
|
2010-11-07 12:15:21 +00:00
|
|
|
}
|
2009-01-02 01:28:05 +00:00
|
|
|
|
|
|
|
/* convert border-region to view coordinates */
|
2012-05-08 15:30:00 +00:00
|
|
|
UI_view2d_region_to_view(v2d, rect->xmin, rect->ymin + 2, &rectf.xmin, &rectf.ymin);
|
|
|
|
UI_view2d_region_to_view(v2d, rect->xmax, rect->ymax - 2, &rectf.xmax, &rectf.ymax);
|
2009-01-02 01:28:05 +00:00
|
|
|
|
|
|
|
/* filter data */
|
2012-05-08 15:30:00 +00:00
|
|
|
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
|
2009-01-26 04:13:38 +00:00
|
|
|
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
2009-01-02 01:28:05 +00:00
|
|
|
|
|
|
|
/* loop over data, doing border select */
|
2012-05-08 15:30:00 +00:00
|
|
|
for (ale = anim_data.first; ale; ale = ale->next) {
|
2010-11-07 12:09:15 +00:00
|
|
|
if (ac->datatype == ANIMCONT_NLA)
|
2012-05-08 15:30:00 +00:00
|
|
|
ymin = ymax - NLACHANNEL_STEP(snla);
|
2010-11-07 12:09:15 +00:00
|
|
|
else
|
2012-05-08 15:30:00 +00:00
|
|
|
ymin = ymax - ACHANNEL_STEP;
|
2009-01-02 01:28:05 +00:00
|
|
|
|
|
|
|
/* if channel is within border-select region, alter it */
|
|
|
|
if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))) {
|
2009-08-13 07:28:51 +00:00
|
|
|
/* set selection flags only */
|
|
|
|
ANIM_channel_setting_set(ac, ale, ACHANNEL_SETTING_SELECT, selectmode);
|
|
|
|
|
|
|
|
/* type specific actions */
|
2009-01-02 01:28:05 +00:00
|
|
|
switch (ale->type) {
|
2009-08-13 07:28:51 +00:00
|
|
|
case ANIMTYPE_GROUP:
|
2009-01-02 01:28:05 +00:00
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
bActionGroup *agrp = (bActionGroup *)ale->data;
|
2009-01-02 01:28:05 +00:00
|
|
|
|
2009-08-13 07:28:51 +00:00
|
|
|
/* always clear active flag after doing this */
|
2009-01-05 00:38:17 +00:00
|
|
|
agrp->flag &= ~AGRP_ACTIVE;
|
2009-01-02 01:28:05 +00:00
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
break;
|
2010-11-08 00:09:31 +00:00
|
|
|
case ANIMTYPE_NLATRACK:
|
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
NlaTrack *nlt = (NlaTrack *)ale->data;
|
2010-11-08 00:09:31 +00:00
|
|
|
|
|
|
|
/* for now, it's easier just to do this here manually, as defining a new type
|
|
|
|
* currently adds complications when doing other stuff
|
|
|
|
*/
|
|
|
|
ACHANNEL_SET_FLAG(nlt, selectmode, NLATRACK_SELECTED);
|
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
break;
|
2009-01-02 01:28:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set minimum extent to be the maximum of the next channel */
|
2012-05-08 15:30:00 +00:00
|
|
|
ymax = ymin;
|
2009-01-02 01:28:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
BLI_freelistN(&anim_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------- */
|
|
|
|
|
|
|
|
static int animchannels_borderselect_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
bAnimContext ac;
|
|
|
|
rcti rect;
|
2012-05-08 15:30:00 +00:00
|
|
|
short selectmode = 0;
|
2011-11-16 19:22:14 +00:00
|
|
|
int gesture_mode, extend;
|
2009-01-02 01:28:05 +00:00
|
|
|
|
|
|
|
/* get editor data */
|
|
|
|
if (ANIM_animdata_get_context(C, &ac) == 0)
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
/* get settings from operator */
|
2012-08-08 20:38:55 +00:00
|
|
|
WM_operator_properties_border_to_rcti(op, &rect);
|
2011-11-16 19:22:14 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
gesture_mode = RNA_int_get(op->ptr, "gesture_mode");
|
|
|
|
extend = RNA_boolean_get(op->ptr, "extend");
|
2011-11-16 19:22:14 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!extend)
|
2011-11-16 19:22:14 +00:00
|
|
|
ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, 1, ACHANNEL_SETFLAG_CLEAR);
|
|
|
|
|
2009-11-06 22:51:08 +00:00
|
|
|
if (gesture_mode == GESTURE_MODAL_SELECT)
|
2009-01-02 01:28:05 +00:00
|
|
|
selectmode = ACHANNEL_SETFLAG_ADD;
|
|
|
|
else
|
|
|
|
selectmode = ACHANNEL_SETFLAG_CLEAR;
|
|
|
|
|
|
|
|
/* apply borderselect animation channels */
|
|
|
|
borderselect_anim_channels(&ac, &rect, selectmode);
|
|
|
|
|
2009-07-10 10:48:25 +00:00
|
|
|
/* send notifier that things have changed */
|
2012-05-08 15:30:00 +00:00
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
|
2009-07-10 10:48:25 +00:00
|
|
|
|
2009-01-02 01:28:05 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2011-02-13 10:52:18 +00:00
|
|
|
static void ANIM_OT_channels_select_border(wmOperatorType *ot)
|
2009-01-02 01:28:05 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Border Select";
|
|
|
|
ot->idname = "ANIM_OT_channels_select_border";
|
|
|
|
ot->description = "Select all animation channels within the specified region";
|
2009-01-02 01:28:05 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = WM_border_select_invoke;
|
|
|
|
ot->exec = animchannels_borderselect_exec;
|
|
|
|
ot->modal = WM_border_select_modal;
|
|
|
|
ot->cancel = WM_border_select_cancel;
|
2009-01-02 01:28:05 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = animedit_poll_channels_nla_tweakmode_off;
|
2009-01-02 01:28:05 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-05-08 15:30:00 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-01-02 01:28:05 +00:00
|
|
|
|
|
|
|
/* rna */
|
2011-11-16 19:22:14 +00:00
|
|
|
WM_operator_properties_gesture_border(ot, TRUE);
|
2009-01-02 01:28:05 +00:00
|
|
|
}
|
|
|
|
|
Animation channels can now be renamed by Ctrl-Clicking on them, as in
the Outliner
Channels which can be renamed include:
- Scenes, Objects, World, Material, Texture, etc. (i.e. "ID-blocks",
or the dark and light blue channels)
- Action Groups (green channels)
- Action expanders (i.e. "CubeAction", "WorldAction", etc.)
- Grease Pencil stuff
Channels which CANNOT be renamed, as they mostly use hardcoded values
or otherwise include:
- Drivers expander
- FCurves (they don't technically have a "name"; what is shown is just
a user-friendly representation of their rna_paths)
2011-08-03 01:22:31 +00:00
|
|
|
/* ******************* Rename Operator ***************************** */
|
|
|
|
/* Allow renaming some channels by clicking on them */
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
static void rename_anim_channels(bAnimContext *ac, int channel_index)
|
Animation channels can now be renamed by Ctrl-Clicking on them, as in
the Outliner
Channels which can be renamed include:
- Scenes, Objects, World, Material, Texture, etc. (i.e. "ID-blocks",
or the dark and light blue channels)
- Action Groups (green channels)
- Action expanders (i.e. "CubeAction", "WorldAction", etc.)
- Grease Pencil stuff
Channels which CANNOT be renamed, as they mostly use hardcoded values
or otherwise include:
- Drivers expander
- FCurves (they don't technically have a "name"; what is shown is just
a user-friendly representation of their rna_paths)
2011-08-03 01:22:31 +00:00
|
|
|
{
|
|
|
|
ListBase anim_data = {NULL, NULL};
|
|
|
|
bAnimChannelType *acf;
|
|
|
|
bAnimListElem *ale;
|
|
|
|
int filter;
|
|
|
|
|
|
|
|
/* get the channel that was clicked on */
|
2012-05-08 15:30:00 +00:00
|
|
|
/* filter channels */
|
|
|
|
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
|
Animation channels can now be renamed by Ctrl-Clicking on them, as in
the Outliner
Channels which can be renamed include:
- Scenes, Objects, World, Material, Texture, etc. (i.e. "ID-blocks",
or the dark and light blue channels)
- Action Groups (green channels)
- Action expanders (i.e. "CubeAction", "WorldAction", etc.)
- Grease Pencil stuff
Channels which CANNOT be renamed, as they mostly use hardcoded values
or otherwise include:
- Drivers expander
- FCurves (they don't technically have a "name"; what is shown is just
a user-friendly representation of their rna_paths)
2011-08-03 01:22:31 +00:00
|
|
|
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
/* get channel from index */
|
|
|
|
ale = BLI_findlink(&anim_data, channel_index);
|
Animation channels can now be renamed by Ctrl-Clicking on them, as in
the Outliner
Channels which can be renamed include:
- Scenes, Objects, World, Material, Texture, etc. (i.e. "ID-blocks",
or the dark and light blue channels)
- Action Groups (green channels)
- Action expanders (i.e. "CubeAction", "WorldAction", etc.)
- Grease Pencil stuff
Channels which CANNOT be renamed, as they mostly use hardcoded values
or otherwise include:
- Drivers expander
- FCurves (they don't technically have a "name"; what is shown is just
a user-friendly representation of their rna_paths)
2011-08-03 01:22:31 +00:00
|
|
|
if (ale == NULL) {
|
|
|
|
/* channel not found */
|
2012-03-31 00:59:17 +00:00
|
|
|
if (G.debug & G_DEBUG)
|
|
|
|
printf("Error: animation channel (index = %d) not found in rename_anim_channels()\n", channel_index);
|
Animation channels can now be renamed by Ctrl-Clicking on them, as in
the Outliner
Channels which can be renamed include:
- Scenes, Objects, World, Material, Texture, etc. (i.e. "ID-blocks",
or the dark and light blue channels)
- Action Groups (green channels)
- Action expanders (i.e. "CubeAction", "WorldAction", etc.)
- Grease Pencil stuff
Channels which CANNOT be renamed, as they mostly use hardcoded values
or otherwise include:
- Drivers expander
- FCurves (they don't technically have a "name"; what is shown is just
a user-friendly representation of their rna_paths)
2011-08-03 01:22:31 +00:00
|
|
|
|
|
|
|
BLI_freelistN(&anim_data);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check that channel can be renamed */
|
|
|
|
acf = ANIM_channel_get_typeinfo(ale);
|
|
|
|
if (acf && acf->name_prop) {
|
|
|
|
PointerRNA ptr;
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
|
|
/* ok if we can get name property to edit from this channel */
|
|
|
|
if (acf->name_prop(ale, &ptr, &prop)) {
|
|
|
|
/* actually showing the rename textfield is done on redraw,
|
|
|
|
* so here we just store the index of this channel in the
|
2012-03-04 04:35:12 +00:00
|
|
|
* dopesheet data, which will get utilized when drawing the
|
Animation channels can now be renamed by Ctrl-Clicking on them, as in
the Outliner
Channels which can be renamed include:
- Scenes, Objects, World, Material, Texture, etc. (i.e. "ID-blocks",
or the dark and light blue channels)
- Action Groups (green channels)
- Action expanders (i.e. "CubeAction", "WorldAction", etc.)
- Grease Pencil stuff
Channels which CANNOT be renamed, as they mostly use hardcoded values
or otherwise include:
- Drivers expander
- FCurves (they don't technically have a "name"; what is shown is just
a user-friendly representation of their rna_paths)
2011-08-03 01:22:31 +00:00
|
|
|
* channel...
|
|
|
|
*
|
|
|
|
* +1 factor is for backwards compat issues
|
|
|
|
*/
|
|
|
|
if (ac->ads) {
|
|
|
|
ac->ads->renameIndex = channel_index + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free temp data and tag for refresh */
|
|
|
|
BLI_freelistN(&anim_data);
|
|
|
|
ED_region_tag_redraw(ac->ar);
|
|
|
|
}
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int animchannels_rename_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
|
Animation channels can now be renamed by Ctrl-Clicking on them, as in
the Outliner
Channels which can be renamed include:
- Scenes, Objects, World, Material, Texture, etc. (i.e. "ID-blocks",
or the dark and light blue channels)
- Action Groups (green channels)
- Action expanders (i.e. "CubeAction", "WorldAction", etc.)
- Grease Pencil stuff
Channels which CANNOT be renamed, as they mostly use hardcoded values
or otherwise include:
- Drivers expander
- FCurves (they don't technically have a "name"; what is shown is just
a user-friendly representation of their rna_paths)
2011-08-03 01:22:31 +00:00
|
|
|
{
|
|
|
|
bAnimContext ac;
|
|
|
|
ARegion *ar;
|
|
|
|
View2D *v2d;
|
|
|
|
int channel_index;
|
|
|
|
float x, y;
|
|
|
|
|
|
|
|
/* get editor data */
|
|
|
|
if (ANIM_animdata_get_context(C, &ac) == 0)
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
/* get useful pointers from animation context data */
|
2012-05-08 15:30:00 +00:00
|
|
|
ar = ac.ar;
|
|
|
|
v2d = &ar->v2d;
|
Animation channels can now be renamed by Ctrl-Clicking on them, as in
the Outliner
Channels which can be renamed include:
- Scenes, Objects, World, Material, Texture, etc. (i.e. "ID-blocks",
or the dark and light blue channels)
- Action Groups (green channels)
- Action expanders (i.e. "CubeAction", "WorldAction", etc.)
- Grease Pencil stuff
Channels which CANNOT be renamed, as they mostly use hardcoded values
or otherwise include:
- Drivers expander
- FCurves (they don't technically have a "name"; what is shown is just
a user-friendly representation of their rna_paths)
2011-08-03 01:22:31 +00:00
|
|
|
|
|
|
|
/* figure out which channel user clicked in
|
2012-05-27 19:40:36 +00:00
|
|
|
* Note: although channels technically start at (y = ACHANNEL_FIRST), we need to adjust by half a channel's height
|
Animation channels can now be renamed by Ctrl-Clicking on them, as in
the Outliner
Channels which can be renamed include:
- Scenes, Objects, World, Material, Texture, etc. (i.e. "ID-blocks",
or the dark and light blue channels)
- Action Groups (green channels)
- Action expanders (i.e. "CubeAction", "WorldAction", etc.)
- Grease Pencil stuff
Channels which CANNOT be renamed, as they mostly use hardcoded values
or otherwise include:
- Drivers expander
- FCurves (they don't technically have a "name"; what is shown is just
a user-friendly representation of their rna_paths)
2011-08-03 01:22:31 +00:00
|
|
|
* so that the tops of channels get caught ok. Since ACHANNEL_FIRST is really ACHANNEL_HEIGHT, we simply use
|
|
|
|
* ACHANNEL_HEIGHT_HALF.
|
|
|
|
*/
|
2013-03-13 09:03:46 +00:00
|
|
|
UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, &y);
|
Animation channels can now be renamed by Ctrl-Clicking on them, as in
the Outliner
Channels which can be renamed include:
- Scenes, Objects, World, Material, Texture, etc. (i.e. "ID-blocks",
or the dark and light blue channels)
- Action Groups (green channels)
- Action expanders (i.e. "CubeAction", "WorldAction", etc.)
- Grease Pencil stuff
Channels which CANNOT be renamed, as they mostly use hardcoded values
or otherwise include:
- Drivers expander
- FCurves (they don't technically have a "name"; what is shown is just
a user-friendly representation of their rna_paths)
2011-08-03 01:22:31 +00:00
|
|
|
|
|
|
|
if (ac.datatype == ANIMCONT_NLA) {
|
|
|
|
SpaceNla *snla = (SpaceNla *)ac.sl;
|
|
|
|
UI_view2d_listview_view_to_cell(v2d, NLACHANNEL_NAMEWIDTH, NLACHANNEL_STEP(snla), 0, (float)NLACHANNEL_HEIGHT_HALF(snla), x, y, NULL, &channel_index);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
UI_view2d_listview_view_to_cell(v2d, ACHANNEL_NAMEWIDTH, ACHANNEL_STEP, 0, (float)ACHANNEL_HEIGHT_HALF, x, y, NULL, &channel_index);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* handle click */
|
|
|
|
rename_anim_channels(&ac, channel_index);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
static void ANIM_OT_channels_rename(wmOperatorType *ot)
|
Animation channels can now be renamed by Ctrl-Clicking on them, as in
the Outliner
Channels which can be renamed include:
- Scenes, Objects, World, Material, Texture, etc. (i.e. "ID-blocks",
or the dark and light blue channels)
- Action Groups (green channels)
- Action expanders (i.e. "CubeAction", "WorldAction", etc.)
- Grease Pencil stuff
Channels which CANNOT be renamed, as they mostly use hardcoded values
or otherwise include:
- Drivers expander
- FCurves (they don't technically have a "name"; what is shown is just
a user-friendly representation of their rna_paths)
2011-08-03 01:22:31 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Rename Channels";
|
|
|
|
ot->idname = "ANIM_OT_channels_rename";
|
|
|
|
ot->description = "Rename animation channel under mouse";
|
Animation channels can now be renamed by Ctrl-Clicking on them, as in
the Outliner
Channels which can be renamed include:
- Scenes, Objects, World, Material, Texture, etc. (i.e. "ID-blocks",
or the dark and light blue channels)
- Action Groups (green channels)
- Action expanders (i.e. "CubeAction", "WorldAction", etc.)
- Grease Pencil stuff
Channels which CANNOT be renamed, as they mostly use hardcoded values
or otherwise include:
- Drivers expander
- FCurves (they don't technically have a "name"; what is shown is just
a user-friendly representation of their rna_paths)
2011-08-03 01:22:31 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = animchannels_rename_invoke;
|
|
|
|
ot->poll = animedit_poll_channels_active;
|
Animation channels can now be renamed by Ctrl-Clicking on them, as in
the Outliner
Channels which can be renamed include:
- Scenes, Objects, World, Material, Texture, etc. (i.e. "ID-blocks",
or the dark and light blue channels)
- Action Groups (green channels)
- Action expanders (i.e. "CubeAction", "WorldAction", etc.)
- Grease Pencil stuff
Channels which CANNOT be renamed, as they mostly use hardcoded values
or otherwise include:
- Drivers expander
- FCurves (they don't technically have a "name"; what is shown is just
a user-friendly representation of their rna_paths)
2011-08-03 01:22:31 +00:00
|
|
|
}
|
|
|
|
|
2009-01-01 00:18:23 +00:00
|
|
|
/* ******************** Mouse-Click Operator *********************** */
|
2009-08-16 02:21:43 +00:00
|
|
|
/* Handle selection changes due to clicking on channels. Settings will get caught by UI code... */
|
2009-01-01 00:18:23 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
static int mouse_anim_channels(bAnimContext *ac, float UNUSED(x), int channel_index, short selectmode)
|
2009-01-01 00:18:23 +00:00
|
|
|
{
|
|
|
|
ListBase anim_data = {NULL, NULL};
|
|
|
|
bAnimListElem *ale;
|
|
|
|
int filter;
|
2009-07-10 10:48:25 +00:00
|
|
|
int notifierFlags = 0;
|
2009-01-01 00:18:23 +00:00
|
|
|
|
|
|
|
/* get the channel that was clicked on */
|
2012-05-08 15:30:00 +00:00
|
|
|
/* filter channels */
|
|
|
|
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
|
Graph Editor: Visibility toggles improved (Durian Request)
Toggling one of the visibility toggles in the Graph Editor now flushes the new value up/down the hierarchy.
- when enabling a visibility toggle, all the 'higher' up and lower down channels get their visibility turned on
- when disabling a visibility toggle, only the ones lower down get their visibility turned off (since there might still be other channels at the same level which are still enabled.
This makes showing/hiding groups of F-Curves much easier, since previously you'd have to use multiple clicks to isolate particular F-Curves. For example, to isolate only X Location curves, previously, the workflow would have been to select all AKEY, hide all VKEY, then toggle the individual X Location curves in group, then make sure the groups and objects, etc. were also visible. Now, the steps of making sure that the parents were visible too has been eliminated.
---
Also, fixed a few minor bugs with the animation-backend code for Graph Editor.
2009-10-19 02:17:57 +00:00
|
|
|
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
2009-01-01 00:18:23 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
/* get channel from index */
|
|
|
|
ale = BLI_findlink(&anim_data, channel_index);
|
2009-01-01 00:18:23 +00:00
|
|
|
if (ale == NULL) {
|
|
|
|
/* channel not found */
|
2012-03-31 00:59:17 +00:00
|
|
|
if (G.debug & G_DEBUG)
|
|
|
|
printf("Error: animation channel (index = %d) not found in mouse_anim_channels()\n", channel_index);
|
2009-01-01 00:18:23 +00:00
|
|
|
|
|
|
|
BLI_freelistN(&anim_data);
|
2009-07-10 10:48:25 +00:00
|
|
|
return 0;
|
2009-01-01 00:18:23 +00:00
|
|
|
}
|
2012-07-06 23:56:59 +00:00
|
|
|
|
2009-01-05 00:38:17 +00:00
|
|
|
/* selectmode -1 is a special case for ActionGroups only, which selects all of the channels underneath it only... */
|
2012-07-06 23:56:59 +00:00
|
|
|
/* TODO: should this feature be extended to work with other channel types too? */
|
2009-01-05 00:38:17 +00:00
|
|
|
if ((selectmode == -1) && (ale->type != ANIMTYPE_GROUP)) {
|
|
|
|
/* normal channels should not behave normally in this case */
|
|
|
|
BLI_freelistN(&anim_data);
|
2009-07-10 10:48:25 +00:00
|
|
|
return 0;
|
2009-01-05 00:38:17 +00:00
|
|
|
}
|
2012-07-06 23:56:59 +00:00
|
|
|
|
2009-01-01 00:18:23 +00:00
|
|
|
/* action to take depends on what channel we've got */
|
2012-07-06 23:56:59 +00:00
|
|
|
/* WARNING: must keep this in sync with the equivalent function in nla_channels.c */
|
2009-01-01 00:18:23 +00:00
|
|
|
switch (ale->type) {
|
2009-02-13 06:33:07 +00:00
|
|
|
case ANIMTYPE_SCENE:
|
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
Scene *sce = (Scene *)ale->data;
|
|
|
|
AnimData *adt = sce->adt;
|
2009-02-13 06:33:07 +00:00
|
|
|
|
2009-08-16 02:21:43 +00:00
|
|
|
/* set selection status */
|
|
|
|
if (selectmode == SELECT_INVERT) {
|
|
|
|
/* swap select */
|
|
|
|
sce->flag ^= SCE_DS_SELECTED;
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
if (adt) adt->flag ^= ADT_UI_SELECTED;
|
2009-02-13 06:33:07 +00:00
|
|
|
}
|
|
|
|
else {
|
2009-08-16 02:21:43 +00:00
|
|
|
sce->flag |= SCE_DS_SELECTED;
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
if (adt) adt->flag |= ADT_UI_SELECTED;
|
2009-02-13 06:33:07 +00:00
|
|
|
}
|
2009-08-16 02:21:43 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
|
2009-02-13 06:33:07 +00:00
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
break;
|
2009-01-01 00:18:23 +00:00
|
|
|
case ANIMTYPE_OBJECT:
|
2009-01-05 00:38:17 +00:00
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
bDopeSheet *ads = (bDopeSheet *)ac->data;
|
|
|
|
Scene *sce = (Scene *)ads->source;
|
|
|
|
Base *base = (Base *)ale->data;
|
|
|
|
Object *ob = base->object;
|
|
|
|
AnimData *adt = ob->adt;
|
2009-01-05 00:38:17 +00:00
|
|
|
|
2009-08-16 02:21:43 +00:00
|
|
|
/* set selection status */
|
|
|
|
if (selectmode == SELECT_INVERT) {
|
|
|
|
/* swap select */
|
|
|
|
base->flag ^= SELECT;
|
2012-05-08 15:30:00 +00:00
|
|
|
ob->flag = base->flag;
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
|
|
|
|
if (adt) adt->flag ^= ADT_UI_SELECTED;
|
2009-01-05 00:38:17 +00:00
|
|
|
}
|
|
|
|
else {
|
2009-08-16 02:21:43 +00:00
|
|
|
Base *b;
|
2012-08-08 13:55:30 +00:00
|
|
|
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
/* deselect all */
|
2012-07-06 23:56:59 +00:00
|
|
|
/* TODO: should this deselect all other types of channels too? */
|
2012-05-08 15:30:00 +00:00
|
|
|
for (b = sce->base.first; b; b = b->next) {
|
2009-08-16 02:21:43 +00:00
|
|
|
b->flag &= ~SELECT;
|
2012-05-08 15:30:00 +00:00
|
|
|
b->object->flag = b->flag;
|
|
|
|
if (b->object->adt) b->object->adt->flag &= ~(ADT_UI_SELECTED | ADT_UI_ACTIVE);
|
2009-08-16 02:21:43 +00:00
|
|
|
}
|
2009-07-10 10:48:25 +00:00
|
|
|
|
2009-08-16 02:21:43 +00:00
|
|
|
/* select object now */
|
|
|
|
base->flag |= SELECT;
|
|
|
|
ob->flag |= SELECT;
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
if (adt) adt->flag |= ADT_UI_SELECTED;
|
2009-01-01 00:18:23 +00:00
|
|
|
}
|
2009-08-16 02:21:43 +00:00
|
|
|
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
if ((adt) && (adt->flag & ADT_UI_SELECTED))
|
|
|
|
adt->flag |= ADT_UI_ACTIVE;
|
2009-08-16 02:21:43 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
|
2009-08-03 13:09:23 +00:00
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
break;
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
|
|
|
|
case ANIMTYPE_FILLACTD: /* Action Expander */
|
2012-05-08 15:30:00 +00:00
|
|
|
case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
case ANIMTYPE_DSLAM:
|
|
|
|
case ANIMTYPE_DSCAM:
|
|
|
|
case ANIMTYPE_DSCUR:
|
|
|
|
case ANIMTYPE_DSSKEY:
|
|
|
|
case ANIMTYPE_DSWOR:
|
|
|
|
case ANIMTYPE_DSPART:
|
|
|
|
case ANIMTYPE_DSMBALL:
|
|
|
|
case ANIMTYPE_DSARM:
|
2009-12-28 00:52:31 +00:00
|
|
|
case ANIMTYPE_DSMESH:
|
2010-02-18 00:29:08 +00:00
|
|
|
case ANIMTYPE_DSNTREE:
|
|
|
|
case ANIMTYPE_DSTEX:
|
2011-01-05 00:37:21 +00:00
|
|
|
case ANIMTYPE_DSLAT:
|
2010-09-21 22:23:10 +00:00
|
|
|
case ANIMTYPE_DSLINESTYLE:
|
2011-08-01 11:44:20 +00:00
|
|
|
case ANIMTYPE_DSSPK:
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
{
|
|
|
|
/* sanity checking... */
|
|
|
|
if (ale->adt) {
|
|
|
|
/* select/deselect */
|
|
|
|
if (selectmode == SELECT_INVERT) {
|
|
|
|
/* inverse selection status of this AnimData block only */
|
|
|
|
ale->adt->flag ^= ADT_UI_SELECTED;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* select AnimData block by itself */
|
2010-01-23 03:04:37 +00:00
|
|
|
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
ale->adt->flag |= ADT_UI_SELECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set active? */
|
|
|
|
if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED))
|
|
|
|
ale->adt->flag |= ADT_UI_ACTIVE;
|
|
|
|
}
|
2009-01-01 00:18:23 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
|
2013-02-22 02:09:54 +00:00
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
break;
|
2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)
* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying.
* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...
Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
|
|
|
|
2009-01-01 00:18:23 +00:00
|
|
|
case ANIMTYPE_GROUP:
|
2009-01-05 00:38:17 +00:00
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
bActionGroup *agrp = (bActionGroup *)ale->data;
|
2009-01-05 00:38:17 +00:00
|
|
|
|
2009-08-16 02:21:43 +00:00
|
|
|
/* select/deselect group */
|
|
|
|
if (selectmode == SELECT_INVERT) {
|
|
|
|
/* inverse selection status of this group only */
|
|
|
|
agrp->flag ^= AGRP_SELECTED;
|
2009-07-03 10:28:10 +00:00
|
|
|
}
|
2009-08-16 02:21:43 +00:00
|
|
|
else if (selectmode == -1) {
|
2012-10-21 05:46:41 +00:00
|
|
|
/* select all in group (and deselect everthing else) */
|
2009-08-16 02:21:43 +00:00
|
|
|
FCurve *fcu;
|
|
|
|
|
|
|
|
/* deselect all other channels */
|
2010-01-23 03:04:37 +00:00
|
|
|
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
|
2009-08-16 02:21:43 +00:00
|
|
|
|
|
|
|
/* only select channels in group and group itself */
|
2012-05-08 15:30:00 +00:00
|
|
|
for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next)
|
2009-08-16 02:21:43 +00:00
|
|
|
fcu->flag |= FCURVE_SELECTED;
|
2012-10-21 05:46:41 +00:00
|
|
|
agrp->flag |= AGRP_SELECTED;
|
2009-07-03 10:28:10 +00:00
|
|
|
}
|
2009-01-05 00:38:17 +00:00
|
|
|
else {
|
2009-08-16 02:21:43 +00:00
|
|
|
/* select group by itself */
|
2010-01-23 03:04:37 +00:00
|
|
|
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
|
2009-08-16 02:21:43 +00:00
|
|
|
agrp->flag |= AGRP_SELECTED;
|
2009-01-01 00:18:23 +00:00
|
|
|
}
|
2009-08-16 02:21:43 +00:00
|
|
|
|
|
|
|
/* if group is selected now, make group the 'active' one in the visible list */
|
|
|
|
if (agrp->flag & AGRP_SELECTED)
|
|
|
|
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP);
|
2012-08-08 13:55:30 +00:00
|
|
|
else
|
|
|
|
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, NULL, ANIMTYPE_GROUP);
|
2009-08-16 02:21:43 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
|
2009-01-05 00:38:17 +00:00
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
break;
|
2009-01-20 11:07:42 +00:00
|
|
|
case ANIMTYPE_FCURVE:
|
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
FCurve *fcu = (FCurve *)ale->data;
|
2009-02-22 09:30:18 +00:00
|
|
|
|
2009-08-16 02:21:43 +00:00
|
|
|
/* select/deselect */
|
|
|
|
if (selectmode == SELECT_INVERT) {
|
|
|
|
/* inverse selection status of this F-Curve only */
|
|
|
|
fcu->flag ^= FCURVE_SELECTED;
|
2009-02-10 11:37:14 +00:00
|
|
|
}
|
2009-01-20 11:07:42 +00:00
|
|
|
else {
|
2009-08-16 02:21:43 +00:00
|
|
|
/* select F-Curve by itself */
|
2010-01-23 03:04:37 +00:00
|
|
|
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
|
2009-08-16 02:21:43 +00:00
|
|
|
fcu->flag |= FCURVE_SELECTED;
|
2009-01-01 00:18:23 +00:00
|
|
|
}
|
2009-08-16 02:21:43 +00:00
|
|
|
|
|
|
|
/* if F-Curve is selected now, make F-Curve the 'active' one in the visible list */
|
|
|
|
if (fcu->flag & FCURVE_SELECTED)
|
|
|
|
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, fcu, ANIMTYPE_FCURVE);
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
|
2009-10-16 12:08:47 +00:00
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
break;
|
2009-10-16 12:08:47 +00:00
|
|
|
case ANIMTYPE_SHAPEKEY:
|
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
KeyBlock *kb = (KeyBlock *)ale->data;
|
2009-10-16 12:08:47 +00:00
|
|
|
|
|
|
|
/* select/deselect */
|
|
|
|
if (selectmode == SELECT_INVERT) {
|
|
|
|
/* inverse selection status of this ShapeKey only */
|
|
|
|
kb->flag ^= KEYBLOCK_SEL;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* select ShapeKey by itself */
|
2010-01-23 03:04:37 +00:00
|
|
|
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
|
2009-10-16 12:08:47 +00:00
|
|
|
kb->flag |= KEYBLOCK_SEL;
|
|
|
|
}
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
|
2009-01-20 11:07:42 +00:00
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
break;
|
2009-01-01 00:18:23 +00:00
|
|
|
case ANIMTYPE_GPDATABLOCK:
|
2009-01-20 11:07:42 +00:00
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
bGPdata *gpd = (bGPdata *)ale->data;
|
2009-01-20 11:07:42 +00:00
|
|
|
|
2011-01-10 22:10:28 +00:00
|
|
|
/* toggle expand
|
|
|
|
* - although the triangle widget already allows this, the whole channel can also be used for this purpose
|
|
|
|
*/
|
2009-01-20 11:07:42 +00:00
|
|
|
gpd->flag ^= GP_DATA_EXPAND;
|
2009-07-10 10:48:25 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
notifierFlags |= (ND_ANIMCHAN | NA_EDITED);
|
2009-01-20 11:07:42 +00:00
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
break;
|
2009-01-01 00:18:23 +00:00
|
|
|
case ANIMTYPE_GPLAYER:
|
2009-01-20 11:07:42 +00:00
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
bGPDlayer *gpl = (bGPDlayer *)ale->data;
|
2009-01-20 11:07:42 +00:00
|
|
|
|
2011-01-10 22:10:28 +00:00
|
|
|
/* select/deselect */
|
|
|
|
if (selectmode == SELECT_INVERT) {
|
|
|
|
/* invert selection status of this layer only */
|
|
|
|
gpl->flag ^= GP_LAYER_SELECT;
|
2009-01-20 11:07:42 +00:00
|
|
|
}
|
2012-10-21 05:46:41 +00:00
|
|
|
else {
|
2011-01-10 22:10:28 +00:00
|
|
|
/* select layer by itself */
|
|
|
|
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
|
|
|
|
gpl->flag |= GP_LAYER_SELECT;
|
2009-01-20 11:07:42 +00:00
|
|
|
}
|
2011-01-10 22:10:28 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
notifierFlags |= (ND_ANIMCHAN | NA_EDITED);
|
2009-01-20 11:07:42 +00:00
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
break;
|
2012-06-08 14:31:38 +00:00
|
|
|
case ANIMTYPE_MASKDATABLOCK:
|
|
|
|
{
|
|
|
|
Mask *mask = (Mask *)ale->data;
|
2012-08-08 13:55:30 +00:00
|
|
|
|
2012-06-08 14:31:38 +00:00
|
|
|
/* toggle expand
|
|
|
|
* - although the triangle widget already allows this, the whole channel can also be used for this purpose
|
|
|
|
*/
|
|
|
|
mask->flag ^= MASK_ANIMF_EXPAND;
|
2012-08-08 13:55:30 +00:00
|
|
|
|
2012-06-08 14:31:38 +00:00
|
|
|
notifierFlags |= (ND_ANIMCHAN | NA_EDITED);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ANIMTYPE_MASKLAYER:
|
|
|
|
{
|
|
|
|
MaskLayer *masklay = (MaskLayer *)ale->data;
|
2012-08-08 13:55:30 +00:00
|
|
|
|
2012-06-08 14:31:38 +00:00
|
|
|
/* select/deselect */
|
|
|
|
if (selectmode == SELECT_INVERT) {
|
|
|
|
/* invert selection status of this layer only */
|
|
|
|
masklay->flag ^= MASK_LAYERFLAG_SELECT;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* select layer by itself */
|
|
|
|
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
|
|
|
|
masklay->flag |= MASK_LAYERFLAG_SELECT;
|
|
|
|
}
|
2012-08-08 13:55:30 +00:00
|
|
|
|
2012-06-08 14:31:38 +00:00
|
|
|
notifierFlags |= (ND_ANIMCHAN | NA_EDITED);
|
|
|
|
}
|
|
|
|
break;
|
2009-01-01 00:18:23 +00:00
|
|
|
default:
|
2012-03-31 00:59:17 +00:00
|
|
|
if (G.debug & G_DEBUG)
|
|
|
|
printf("Error: Invalid channel type in mouse_anim_channels()\n");
|
2009-01-01 00:18:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* free channels */
|
|
|
|
BLI_freelistN(&anim_data);
|
2009-07-10 10:48:25 +00:00
|
|
|
|
|
|
|
/* return notifier flags */
|
|
|
|
return notifierFlags;
|
2009-01-01 00:18:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------- */
|
|
|
|
|
|
|
|
/* handle clicking */
|
2013-03-13 09:03:46 +00:00
|
|
|
static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
2009-01-01 00:18:23 +00:00
|
|
|
{
|
|
|
|
bAnimContext ac;
|
|
|
|
ARegion *ar;
|
|
|
|
View2D *v2d;
|
2011-05-20 07:40:05 +00:00
|
|
|
int channel_index;
|
2009-07-10 10:48:25 +00:00
|
|
|
int notifierFlags = 0;
|
2009-01-01 00:18:23 +00:00
|
|
|
short selectmode;
|
|
|
|
float x, y;
|
|
|
|
|
|
|
|
|
|
|
|
/* get editor data */
|
|
|
|
if (ANIM_animdata_get_context(C, &ac) == 0)
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
/* get useful pointers from animation context data */
|
2012-05-08 15:30:00 +00:00
|
|
|
ar = ac.ar;
|
|
|
|
v2d = &ar->v2d;
|
2009-01-01 00:18:23 +00:00
|
|
|
|
|
|
|
/* select mode is either replace (deselect all, then add) or add/extend */
|
2009-03-29 02:15:13 +00:00
|
|
|
if (RNA_boolean_get(op->ptr, "extend"))
|
2012-05-08 15:30:00 +00:00
|
|
|
selectmode = SELECT_INVERT;
|
2009-03-29 02:15:13 +00:00
|
|
|
else if (RNA_boolean_get(op->ptr, "children_only"))
|
2012-05-08 15:30:00 +00:00
|
|
|
selectmode = -1; /* this is a bit of a special case for ActionGroups only... should it be removed or extended to all instead? */
|
2009-01-01 00:18:23 +00:00
|
|
|
else
|
2012-05-08 15:30:00 +00:00
|
|
|
selectmode = SELECT_REPLACE;
|
2009-01-01 00:18:23 +00:00
|
|
|
|
|
|
|
/* figure out which channel user clicked in
|
2012-05-27 19:40:36 +00:00
|
|
|
* Note: although channels technically start at (y = ACHANNEL_FIRST), we need to adjust by half a channel's height
|
2009-01-01 00:18:23 +00:00
|
|
|
* so that the tops of channels get caught ok. Since ACHANNEL_FIRST is really ACHANNEL_HEIGHT, we simply use
|
|
|
|
* ACHANNEL_HEIGHT_HALF.
|
|
|
|
*/
|
2011-05-20 07:40:05 +00:00
|
|
|
UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, &y);
|
2009-01-02 00:56:48 +00:00
|
|
|
UI_view2d_listview_view_to_cell(v2d, ACHANNEL_NAMEWIDTH, ACHANNEL_STEP, 0, (float)ACHANNEL_HEIGHT_HALF, x, y, NULL, &channel_index);
|
2009-01-01 00:18:23 +00:00
|
|
|
|
|
|
|
/* handle mouse-click in the relevant channel then */
|
2012-05-08 15:30:00 +00:00
|
|
|
notifierFlags = mouse_anim_channels(&ac, x, channel_index, selectmode);
|
2009-01-01 00:18:23 +00:00
|
|
|
|
2009-07-10 10:48:25 +00:00
|
|
|
/* set notifier that things have changed */
|
2012-05-08 15:30:00 +00:00
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | notifierFlags, NULL);
|
2009-01-01 00:18:23 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
static void ANIM_OT_channels_click(wmOperatorType *ot)
|
2009-01-01 00:18:23 +00:00
|
|
|
{
|
2012-08-08 13:55:30 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2009-01-01 00:18:23 +00:00
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Mouse Click on Channels";
|
|
|
|
ot->idname = "ANIM_OT_channels_click";
|
|
|
|
ot->description = "Handle mouse-clicks over animation channels";
|
2009-01-01 00:18:23 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = animchannels_mouseclick_invoke;
|
|
|
|
ot->poll = animedit_poll_channels_active;
|
2009-01-01 00:18:23 +00:00
|
|
|
|
2009-01-31 19:40:40 +00:00
|
|
|
/* flags */
|
2013-03-14 05:58:13 +00:00
|
|
|
ot->flag = OPTYPE_UNDO;
|
2009-01-31 19:40:40 +00:00
|
|
|
|
2012-08-08 13:55:30 +00:00
|
|
|
/* properties */
|
|
|
|
/* NOTE: don't save settings, otherwise, can end up with some weird behaviour (sticky extend) */
|
|
|
|
prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); // SHIFTKEY
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
|
|
|
|
|
|
|
prop = RNA_def_boolean(ot->srna, "children_only", 0, "Select Children Only", ""); // CTRLKEY|SHIFTKEY
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
2009-01-01 00:18:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ************************************************************************** */
|
|
|
|
/* Operator Registration */
|
|
|
|
|
|
|
|
void ED_operatortypes_animchannels(void)
|
|
|
|
{
|
2009-03-29 02:15:13 +00:00
|
|
|
WM_operatortype_append(ANIM_OT_channels_select_all_toggle);
|
|
|
|
WM_operatortype_append(ANIM_OT_channels_select_border);
|
Animation channels can now be renamed by Ctrl-Clicking on them, as in
the Outliner
Channels which can be renamed include:
- Scenes, Objects, World, Material, Texture, etc. (i.e. "ID-blocks",
or the dark and light blue channels)
- Action Groups (green channels)
- Action expanders (i.e. "CubeAction", "WorldAction", etc.)
- Grease Pencil stuff
Channels which CANNOT be renamed, as they mostly use hardcoded values
or otherwise include:
- Drivers expander
- FCurves (they don't technically have a "name"; what is shown is just
a user-friendly representation of their rna_paths)
2011-08-03 01:22:31 +00:00
|
|
|
|
2009-04-08 12:35:38 +00:00
|
|
|
WM_operatortype_append(ANIM_OT_channels_click);
|
Animation channels can now be renamed by Ctrl-Clicking on them, as in
the Outliner
Channels which can be renamed include:
- Scenes, Objects, World, Material, Texture, etc. (i.e. "ID-blocks",
or the dark and light blue channels)
- Action Groups (green channels)
- Action expanders (i.e. "CubeAction", "WorldAction", etc.)
- Grease Pencil stuff
Channels which CANNOT be renamed, as they mostly use hardcoded values
or otherwise include:
- Drivers expander
- FCurves (they don't technically have a "name"; what is shown is just
a user-friendly representation of their rna_paths)
2011-08-03 01:22:31 +00:00
|
|
|
WM_operatortype_append(ANIM_OT_channels_rename);
|
2009-01-02 11:06:27 +00:00
|
|
|
|
2009-03-29 02:15:13 +00:00
|
|
|
WM_operatortype_append(ANIM_OT_channels_setting_enable);
|
|
|
|
WM_operatortype_append(ANIM_OT_channels_setting_disable);
|
|
|
|
WM_operatortype_append(ANIM_OT_channels_setting_toggle);
|
2012-07-06 23:56:59 +00:00
|
|
|
|
2009-07-10 12:11:00 +00:00
|
|
|
WM_operatortype_append(ANIM_OT_channels_delete);
|
2012-07-06 23:56:59 +00:00
|
|
|
|
|
|
|
/* XXX does this need to be a separate operator? */
|
2009-03-29 02:15:13 +00:00
|
|
|
WM_operatortype_append(ANIM_OT_channels_editable_toggle);
|
2009-02-22 05:55:37 +00:00
|
|
|
|
2010-11-07 12:09:15 +00:00
|
|
|
WM_operatortype_append(ANIM_OT_channels_move);
|
2009-02-10 11:37:14 +00:00
|
|
|
|
2009-04-08 12:35:38 +00:00
|
|
|
WM_operatortype_append(ANIM_OT_channels_expand);
|
|
|
|
WM_operatortype_append(ANIM_OT_channels_collapse);
|
|
|
|
|
2009-02-10 11:37:14 +00:00
|
|
|
WM_operatortype_append(ANIM_OT_channels_visibility_toggle);
|
2009-11-30 11:10:03 +00:00
|
|
|
WM_operatortype_append(ANIM_OT_channels_visibility_set);
|
2010-11-11 11:56:50 +00:00
|
|
|
|
2010-11-11 21:49:40 +00:00
|
|
|
WM_operatortype_append(ANIM_OT_channels_fcurves_enable);
|
2013-02-22 01:49:51 +00:00
|
|
|
|
|
|
|
WM_operatortype_append(ANIM_OT_channels_group);
|
|
|
|
WM_operatortype_append(ANIM_OT_channels_ungroup);
|
2009-01-01 00:18:23 +00:00
|
|
|
}
|
|
|
|
|
2010-01-23 03:04:37 +00:00
|
|
|
// TODO: check on a poll callback for this, to get hotkeys into menus
|
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_animchannels(wmKeyConfig *keyconf)
|
2009-01-01 00:18:23 +00:00
|
|
|
{
|
2009-12-24 09:26:06 +00:00
|
|
|
wmKeyMap *keymap = WM_keymap_find(keyconf, "Animation Channels", 0, 0);
|
2012-01-16 16:12:03 +00:00
|
|
|
wmKeyMapItem *kmi;
|
|
|
|
|
2009-01-02 01:28:05 +00:00
|
|
|
/* selection */
|
2012-05-08 15:30:00 +00:00
|
|
|
/* click-select */
|
2012-07-06 23:56:59 +00:00
|
|
|
/* XXX for now, only leftmouse.... */
|
2009-04-08 12:35:38 +00:00
|
|
|
WM_keymap_add_item(keymap, "ANIM_OT_channels_click", LEFTMOUSE, KM_PRESS, 0, 0);
|
2012-01-16 16:12:03 +00:00
|
|
|
RNA_boolean_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_click", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "extend", TRUE);
|
2012-05-08 15:30:00 +00:00
|
|
|
RNA_boolean_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_click", LEFTMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "children_only", TRUE);
|
2012-07-06 23:56:59 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
/* rename */
|
Animation channels can now be renamed by Ctrl-Clicking on them, as in
the Outliner
Channels which can be renamed include:
- Scenes, Objects, World, Material, Texture, etc. (i.e. "ID-blocks",
or the dark and light blue channels)
- Action Groups (green channels)
- Action expanders (i.e. "CubeAction", "WorldAction", etc.)
- Grease Pencil stuff
Channels which CANNOT be renamed, as they mostly use hardcoded values
or otherwise include:
- Drivers expander
- FCurves (they don't technically have a "name"; what is shown is just
a user-friendly representation of their rna_paths)
2011-08-03 01:22:31 +00:00
|
|
|
WM_keymap_add_item(keymap, "ANIM_OT_channels_rename", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
/* deselect all */
|
2009-03-29 02:15:13 +00:00
|
|
|
WM_keymap_add_item(keymap, "ANIM_OT_channels_select_all_toggle", AKEY, KM_PRESS, 0, 0);
|
2012-01-16 16:12:03 +00:00
|
|
|
RNA_boolean_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "invert", TRUE);
|
2009-01-02 01:28:05 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
/* borderselect */
|
2009-03-29 02:15:13 +00:00
|
|
|
WM_keymap_add_item(keymap, "ANIM_OT_channels_select_border", BKEY, KM_PRESS, 0, 0);
|
2009-12-15 10:46:19 +00:00
|
|
|
WM_keymap_add_item(keymap, "ANIM_OT_channels_select_border", EVT_TWEAK_L, KM_ANY, 0, 0);
|
2009-01-02 11:06:27 +00:00
|
|
|
|
2009-07-10 12:11:00 +00:00
|
|
|
/* delete */
|
|
|
|
WM_keymap_add_item(keymap, "ANIM_OT_channels_delete", XKEY, KM_PRESS, 0, 0);
|
|
|
|
WM_keymap_add_item(keymap, "ANIM_OT_channels_delete", DELKEY, KM_PRESS, 0, 0);
|
|
|
|
|
2009-01-02 11:06:27 +00:00
|
|
|
/* settings */
|
2009-03-29 02:15:13 +00:00
|
|
|
WM_keymap_add_item(keymap, "ANIM_OT_channels_setting_toggle", WKEY, KM_PRESS, KM_SHIFT, 0);
|
2012-05-08 15:30:00 +00:00
|
|
|
WM_keymap_add_item(keymap, "ANIM_OT_channels_setting_enable", WKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
|
2009-03-29 02:15:13 +00:00
|
|
|
WM_keymap_add_item(keymap, "ANIM_OT_channels_setting_disable", WKEY, KM_PRESS, KM_ALT, 0);
|
2009-01-05 09:54:39 +00:00
|
|
|
|
2011-10-17 06:39:13 +00:00
|
|
|
/* settings - specialized hotkeys */
|
2009-03-29 02:15:13 +00:00
|
|
|
WM_keymap_add_item(keymap, "ANIM_OT_channels_editable_toggle", TABKEY, KM_PRESS, 0, 0);
|
2009-02-22 05:55:37 +00:00
|
|
|
|
2009-04-08 12:35:38 +00:00
|
|
|
/* expand/collapse */
|
|
|
|
WM_keymap_add_item(keymap, "ANIM_OT_channels_expand", PADPLUSKEY, KM_PRESS, 0, 0);
|
|
|
|
WM_keymap_add_item(keymap, "ANIM_OT_channels_collapse", PADMINUS, KM_PRESS, 0, 0);
|
|
|
|
|
2012-01-16 16:12:03 +00:00
|
|
|
kmi = WM_keymap_add_item(keymap, "ANIM_OT_channels_expand", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
|
|
|
|
RNA_boolean_set(kmi->ptr, "all", FALSE);
|
|
|
|
kmi = WM_keymap_add_item(keymap, "ANIM_OT_channels_collapse", PADMINUS, KM_PRESS, KM_CTRL, 0);
|
|
|
|
RNA_boolean_set(kmi->ptr, "all", FALSE);
|
|
|
|
|
2010-11-07 12:09:15 +00:00
|
|
|
/* rearranging */
|
2011-08-22 02:01:22 +00:00
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_move", PAGEUPKEY, KM_PRESS, 0, 0)->ptr, "direction", REARRANGE_ANIMCHAN_UP);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_move", PAGEDOWNKEY, KM_PRESS, 0, 0)->ptr, "direction", REARRANGE_ANIMCHAN_DOWN);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_move", PAGEUPKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "direction", REARRANGE_ANIMCHAN_TOP);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_move", PAGEDOWNKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "direction", REARRANGE_ANIMCHAN_BOTTOM);
|
2009-02-10 11:37:14 +00:00
|
|
|
|
2013-02-22 01:49:51 +00:00
|
|
|
/* grouping */
|
|
|
|
WM_keymap_add_item(keymap, "ANIM_OT_channels_group", GKEY, KM_PRESS, KM_CTRL, 0);
|
|
|
|
WM_keymap_add_item(keymap, "ANIM_OT_channels_ungroup", GKEY, KM_PRESS, KM_ALT, 0);
|
|
|
|
|
2009-02-10 11:37:14 +00:00
|
|
|
/* Graph Editor only */
|
2009-11-30 11:10:03 +00:00
|
|
|
WM_keymap_add_item(keymap, "ANIM_OT_channels_visibility_set", VKEY, KM_PRESS, 0, 0);
|
|
|
|
WM_keymap_add_item(keymap, "ANIM_OT_channels_visibility_toggle", VKEY, KM_PRESS, KM_SHIFT, 0);
|
2009-01-01 00:18:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ************************************************************************** */
|