Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2009-07-10 14:48:25 +0400
committerJoshua Leung <aligorith@gmail.com>2009-07-10 14:48:25 +0400
commit6f0de59c551235d5e26281eca6e172d08ff5eb73 (patch)
tree6a119fd0740cf21854a8d34919d5780a677c86aa /source/blender/editors/animation
parentb1a9281ed801ae8b2483cd4246880b1009efe955 (diff)
NLA SoC: Notifier Fixes for Animation Editors
I've gone through all the Animation Editor operators, making sure they send appropriate notifiers, and that these notifiers are handled. * Added a separate category for animation-related notifiers, since the old-style ones attached to specific datatypes only was turning out to be not too feasible. * For now, the focus has been on making sure that all Animation Editors update when there have been any potentially suitable changes at all. Later on, we can filter these more carefully to only take the ones we really need (for optimisation purposes)
Diffstat (limited to 'source/blender/editors/animation')
-rw-r--r--source/blender/editors/animation/anim_channels.c77
-rw-r--r--source/blender/editors/animation/anim_deps.c70
-rw-r--r--source/blender/editors/animation/keyframes_general.c2
-rw-r--r--source/blender/editors/animation/keyingsets.c6
4 files changed, 70 insertions, 85 deletions
diff --git a/source/blender/editors/animation/anim_channels.c b/source/blender/editors/animation/anim_channels.c
index 5e9abd42aeb..1cf553f6f26 100644
--- a/source/blender/editors/animation/anim_channels.c
+++ b/source/blender/editors/animation/anim_channels.c
@@ -614,8 +614,8 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op)
mode= RNA_enum_get(op->ptr, "direction");
rearrange_action_channels(&ac, mode);
- /* set notifier tha things have changed */
- ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_CHANNELS);
+ /* send notifier that things have changed */
+ WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
return OPERATOR_FINISHED;
}
@@ -728,8 +728,8 @@ static int animchannels_visibility_toggle_exec(bContext *C, wmOperator *op)
/* cleanup */
BLI_freelistN(&anim_data);
- /* set notifier tha things have changed */
- ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_CHANNELS);
+ /* send notifier that things have changed */
+ WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
return OPERATOR_FINISHED;
}
@@ -992,8 +992,8 @@ static int animchannels_setflag_exec(bContext *C, wmOperator *op)
/* modify setting */
setflag_anim_channels(&ac, setting, mode, 1);
- /* set notifier tha things have changed */
- ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_CHANNELS);
+ /* send notifier that things have changed */
+ WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
return OPERATOR_FINISHED;
}
@@ -1101,8 +1101,8 @@ static int animchannels_expand_exec (bContext *C, wmOperator *op)
/* modify setting */
setflag_anim_channels(&ac, ACHANNEL_SETTING_EXPAND, ACHANNEL_SETFLAG_ADD, onlysel);
- /* set notifier that things have changed */
- ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_CHANNELS);
+ /* send notifier that things have changed */
+ WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
return OPERATOR_FINISHED;
}
@@ -1142,8 +1142,8 @@ static int animchannels_collapse_exec (bContext *C, wmOperator *op)
/* modify setting */
setflag_anim_channels(&ac, ACHANNEL_SETTING_EXPAND, ACHANNEL_SETFLAG_CLEAR, onlysel);
- /* set notifier that things have changed */
- ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_CHANNELS);
+ /* send notifier that things have changed */
+ WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
return OPERATOR_FINISHED;
}
@@ -1181,8 +1181,8 @@ static int animchannels_deselectall_exec(bContext *C, wmOperator *op)
else
ANIM_deselect_anim_channels(ac.data, ac.datatype, 1, ACHANNEL_SETFLAG_ADD);
- /* set notifier tha things have changed */
- ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_CHANNELS);
+ /* send notifier that things have changed */
+ WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN_SELECT, NULL);
return OPERATOR_FINISHED;
}
@@ -1310,6 +1310,9 @@ static int animchannels_borderselect_exec(bContext *C, wmOperator *op)
/* apply borderselect animation channels */
borderselect_anim_channels(&ac, &rect, selectmode);
+ /* send notifier that things have changed */
+ WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN_SELECT, NULL);
+
return OPERATOR_FINISHED;
}
@@ -1344,11 +1347,12 @@ void ANIM_OT_channels_select_border(wmOperatorType *ot)
* NOTE: eventually, this should probably be phased out when many of these things are replaced with buttons
*/
-static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, short selectmode)
+static int mouse_anim_channels (bAnimContext *ac, float x, int channel_index, short selectmode)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
+ int notifierFlags = 0;
/* get the channel that was clicked on */
/* filter channels */
@@ -1362,7 +1366,7 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s
printf("Error: animation channel (index = %d) not found in mouse_anim_channels() \n", channel_index);
BLI_freelistN(&anim_data);
- return;
+ return 0;
}
/* selectmode -1 is a special case for ActionGroups only, which selects all of the channels underneath it only... */
@@ -1370,7 +1374,7 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s
if ((selectmode == -1) && (ale->type != ANIMTYPE_GROUP)) {
/* normal channels should not behave normally in this case */
BLI_freelistN(&anim_data);
- return;
+ return 0;
}
/* action to take depends on what channel we've got */
@@ -1382,6 +1386,8 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s
if (x < 16) {
/* toggle expand */
sce->flag ^= SCE_DS_COLLAPSED;
+
+ notifierFlags |= ND_ANIMCHAN_EDIT;
}
else {
/* set selection status */
@@ -1392,6 +1398,8 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s
else {
sce->flag |= SCE_DS_SELECTED;
}
+
+ notifierFlags |= ND_ANIMCHAN_SELECT;
}
}
break;
@@ -1405,6 +1413,8 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s
if (x < 16) {
/* toggle expand */
ob->nlaflag ^= OB_ADS_COLLAPSED; // XXX
+
+ notifierFlags |= ND_ANIMCHAN_EDIT;
}
else {
/* set selection status */
@@ -1429,6 +1439,8 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s
/* xxx should be ED_base_object_activate(), but we need context pointer for that... */
//set_active_base(base);
+
+ notifierFlags |= ND_ANIMCHAN_SELECT;
}
}
break;
@@ -1436,18 +1448,21 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s
{
bAction *act= (bAction *)ale->data;
act->flag ^= ACT_COLLAPSED;
+ notifierFlags |= ND_ANIMCHAN_EDIT;
}
break;
case ANIMTYPE_FILLDRIVERS:
{
AnimData *adt= (AnimData* )ale->data;
adt->flag ^= ADT_DRIVERS_COLLAPSED;
+ notifierFlags |= ND_ANIMCHAN_EDIT;
}
break;
case ANIMTYPE_FILLMATD:
{
Object *ob= (Object *)ale->data;
ob->nlaflag ^= OB_ADS_SHOWMATS; // XXX
+ notifierFlags |= ND_ANIMCHAN_EDIT;
}
break;
@@ -1455,36 +1470,42 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s
{
Material *ma= (Material *)ale->data;
ma->flag ^= MA_DS_EXPAND;
+ notifierFlags |= ND_ANIMCHAN_EDIT;
}
break;
case ANIMTYPE_DSLAM:
{
Lamp *la= (Lamp *)ale->data;
la->flag ^= LA_DS_EXPAND;
+ notifierFlags |= ND_ANIMCHAN_EDIT;
}
break;
case ANIMTYPE_DSCAM:
{
Camera *ca= (Camera *)ale->data;
ca->flag ^= CAM_DS_EXPAND;
+ notifierFlags |= ND_ANIMCHAN_EDIT;
}
break;
case ANIMTYPE_DSCUR:
{
Curve *cu= (Curve *)ale->data;
cu->flag ^= CU_DS_EXPAND;
+ notifierFlags |= ND_ANIMCHAN_EDIT;
}
break;
case ANIMTYPE_DSSKEY:
{
Key *key= (Key *)ale->data;
key->flag ^= KEYBLOCK_DS_EXPAND;
+ notifierFlags |= ND_ANIMCHAN_EDIT;
}
break;
case ANIMTYPE_DSWOR:
{
World *wo= (World *)ale->data;
wo->flag ^= WO_DS_EXPAND;
+ notifierFlags |= ND_ANIMCHAN_EDIT;
}
break;
@@ -1496,18 +1517,22 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s
if ((x < (offset+17)) && (agrp->channels.first)) {
/* toggle expand */
agrp->flag ^= AGRP_EXPANDED;
+ notifierFlags |= ND_ANIMCHAN_EDIT;
}
else if ((x < (offset+32)) && (ac->spacetype==SPACE_IPO)) {
/* toggle visibility (of grouped F-Curves in Graph editor) */
agrp->flag ^= AGRP_NOTVISIBLE;
+ notifierFlags |= ND_ANIMCHAN_EDIT;
}
else if (x >= (ACHANNEL_NAMEWIDTH-ACHANNEL_BUTTON_WIDTH)) {
/* toggle protection/locking */
agrp->flag ^= AGRP_PROTECTED;
+ notifierFlags |= ND_ANIMCHAN_EDIT;
}
else if (x >= (ACHANNEL_NAMEWIDTH-2*ACHANNEL_BUTTON_WIDTH)) {
/* toggle mute */
agrp->flag ^= AGRP_MUTED;
+ notifierFlags |= ND_ANIMCHAN_EDIT;
}
else {
/* select/deselect group */
@@ -1536,6 +1561,8 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s
/* 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);
+
+ notifierFlags |= ND_ANIMCHAN_SELECT;
}
}
break;
@@ -1556,16 +1583,20 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s
if (x >= (ACHANNEL_NAMEWIDTH-ACHANNEL_BUTTON_WIDTH)) {
/* toggle protection (only if there's a toggle there) */
- if (fcu->bezt)
+ if (fcu->bezt) {
fcu->flag ^= FCURVE_PROTECTED;
+ notifierFlags |= ND_ANIMCHAN_EDIT;
+ }
}
else if (x >= (ACHANNEL_NAMEWIDTH-2*ACHANNEL_BUTTON_WIDTH)) {
/* toggle mute */
fcu->flag ^= FCURVE_MUTED;
+ notifierFlags |= ND_ANIMCHAN_EDIT;
}
else if ((x < (offset+17)) && (ac->spacetype==SPACE_IPO)) {
/* toggle visibility */
fcu->flag ^= FCURVE_VISIBLE;
+ notifierFlags |= ND_ANIMCHAN_EDIT;
}
else {
/* select/deselect */
@@ -1582,6 +1613,8 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s
/* 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);
+
+ notifierFlags |= ND_ANIMCHAN_SELECT;
}
}
break;
@@ -1591,6 +1624,8 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s
/* toggle expand */
gpd->flag ^= GP_DATA_EXPAND;
+
+ notifierFlags |= ND_ANIMCHAN_EDIT;
}
break;
case ANIMTYPE_GPLAYER:
@@ -1629,6 +1664,9 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s
/* free channels */
BLI_freelistN(&anim_data);
+
+ /* return notifier flags */
+ return notifierFlags;
}
/* ------------------- */
@@ -1641,6 +1679,7 @@ static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, wmEvent *
ARegion *ar;
View2D *v2d;
int mval[2], channel_index;
+ int notifierFlags = 0;
short selectmode;
float x, y;
@@ -1675,10 +1714,10 @@ static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, wmEvent *
UI_view2d_listview_view_to_cell(v2d, ACHANNEL_NAMEWIDTH, ACHANNEL_STEP, 0, (float)ACHANNEL_HEIGHT_HALF, x, y, NULL, &channel_index);
/* handle mouse-click in the relevant channel then */
- mouse_anim_channels(&ac, x, channel_index, selectmode);
+ notifierFlags= mouse_anim_channels(&ac, x, channel_index, selectmode);
- /* set notifier tha things have changed */
- ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_CHANNELS);
+ /* set notifier that things have changed */
+ WM_event_add_notifier(C, NC_ANIMATION|notifierFlags, NULL);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c
index 1ff2169bf61..13667159fe0 100644
--- a/source/blender/editors/animation/anim_deps.c
+++ b/source/blender/editors/animation/anim_deps.c
@@ -77,72 +77,6 @@ void ED_anim_object_flush_update(const bContext *C, Object *ob)
}
-/* **************************** animation tool notifiers ******************************** */
-
-/* Send notifiers on behalf of animation editing tools, based on various context info
- * - data_changed: eAnimData_Changed
- */
-void ANIM_animdata_send_notifiers (bContext *C, bAnimContext *ac, short data_changed)
-{
- /* types of notifiers to send, depends on the editor context */
- switch (ac->datatype) {
- case ANIMCONT_DOPESHEET: /* dopesheet */
- case ANIMCONT_FCURVES: /* fcurve editor */
- case ANIMCONT_DRIVERS: /* drivers editor */ // XXX probably this will need separate handling, since these are part of dependency system
- {
- /* what action was taken */
- switch (data_changed) {
- case ANIM_CHANGED_KEYFRAMES_VALUES:
- /* keyframe values changed, so transform may have changed */
- // XXX what about other cases? maybe we need general ND_KEYFRAMES or ND_ANIMATION?
- WM_event_add_notifier(C, NC_OBJECT|ND_KEYS|ND_TRANSFORM, NULL);
- break;
- case ANIM_CHANGED_KEYFRAMES_SELECT:
- WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, NULL);
- break;
- case ANIM_CHANGED_CHANNELS:
- // XXX err... check available datatypes in dopesheet first?
- // FIXME: this currently doesn't work (to update own view)
- WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE|ND_OB_SELECT, ac->scene);
- WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE|ND_BONE_SELECT, NULL);
- break;
- }
-
- // XXX for now, at least update own editor!
- ED_area_tag_redraw(CTX_wm_area(C));
- }
- break;
-
- case ANIMCONT_ACTION: /* action editor */
- {
- Object *obact= CTX_data_active_object(C);
-
- switch (data_changed) {
- case ANIM_CHANGED_KEYFRAMES_VALUES:
- /* keyframe values changed, so transform may have changed */
- // XXX what about other cases? maybe we need general ND_KEYFRAMES or ND_ANIMATION?
- WM_event_add_notifier(C, NC_OBJECT|ND_KEYS|ND_TRANSFORM, obact);
- break;
- case ANIM_CHANGED_KEYFRAMES_SELECT:
- WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obact);
- break;
- case ANIM_CHANGED_CHANNELS:
- // XXX err... check available datatypes in dopesheet first?
- // FIXME: this currently doesn't work (to update own view)
- WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE|ND_BONE_SELECT, obact);
- break;
- }
-
- // XXX for now, at least update own editor!
- ED_area_tag_redraw(CTX_wm_area(C));
- }
- break;
-
- default: /* some other data... just update area for now */
- ED_area_tag_redraw(CTX_wm_area(C));
- }
-}
-
/* **************************** pose <-> action syncing ******************************** */
/* Summary of what needs to be synced between poses and actions:
* 1) Flags
@@ -152,6 +86,10 @@ void ANIM_animdata_send_notifiers (bContext *C, bAnimContext *ac, short data_cha
* 3) Grouping (only for pose to action for now)
*/
+/* XXX OBSOLETE CODE WARNING:
+ * With the Animato system, the code below is somewhat obsolete now...
+ */
+
/* Notifier from Action/Dopesheet (this may be extended to include other things such as Python...)
* Channels in action changed, so update pose channels/groups to reflect changes.
*
diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c
index 48ca06fb73d..6e62b163ca9 100644
--- a/source/blender/editors/animation/keyframes_general.c
+++ b/source/blender/editors/animation/keyframes_general.c
@@ -52,6 +52,8 @@
#include "ED_keyframing.h"
#include "ED_keyframes_edit.h"
+#include "RNA_access.h"
+
/* This file contains code for various keyframe-editing tools which are 'destructive'
* (i.e. they will modify the order of the keyframes, and change the size of the array).
* While some of these tools may eventually be moved out into blenkernel, for now, it is
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c
index 240089d26a6..0f8de7f607d 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -1085,6 +1085,9 @@ int modify_keyframes (bContext *C, ListBase *dsources, bAction *act, KeyingSet *
case ID_MA: /* Material Keyframes */
WM_event_add_notifier(C, NC_MATERIAL|ND_KEYS, ksp->id);
break;
+ default: /* Any keyframes */
+ WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL);
+ break;
}
}
}
@@ -1191,6 +1194,9 @@ int modify_keyframes (bContext *C, ListBase *dsources, bAction *act, KeyingSet *
case ID_MA: /* Material Keyframes */
WM_event_add_notifier(C, NC_MATERIAL|ND_KEYS, cks->id);
break;
+ default: /* Any keyframes */
+ WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL);
+ break;
}
}
}