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/space_nla
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/space_nla')
-rw-r--r--source/blender/editors/space_nla/nla_channels.c53
-rw-r--r--source/blender/editors/space_nla/nla_edit.c49
-rw-r--r--source/blender/editors/space_nla/nla_select.c7
-rw-r--r--source/blender/editors/space_nla/space_nla.c15
4 files changed, 79 insertions, 45 deletions
diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c
index 5a891a541cb..1ab348eb28e 100644
--- a/source/blender/editors/space_nla/nla_channels.c
+++ b/source/blender/editors/space_nla/nla_channels.c
@@ -89,11 +89,12 @@
* NOTE: eventually, this should probably be phased out when many of these things are replaced with buttons
*/
-static void mouse_nla_channels (bAnimContext *ac, float x, int channel_index, short selectmode)
+static int mouse_nla_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 */
@@ -107,7 +108,7 @@ static void mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sh
printf("Error: animation channel (index = %d) not found in mouse_anim_channels() \n", channel_index);
BLI_freelistN(&anim_data);
- return;
+ return 0;
}
/* action to take depends on what channel we've got */
@@ -119,6 +120,8 @@ static void mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sh
if (x < 16) {
/* toggle expand */
sce->flag ^= SCE_DS_COLLAPSED;
+
+ notifierFlags |= ND_ANIMCHAN_EDIT;
}
else {
/* set selection status */
@@ -129,6 +132,8 @@ static void mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sh
else {
sce->flag |= SCE_DS_SELECTED;
}
+
+ notifierFlags |= ND_ANIMCHAN_SELECT;
}
}
break;
@@ -141,7 +146,8 @@ static void mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sh
if (x < 16) {
/* toggle expand */
- ob->nlaflag ^= OB_ADS_COLLAPSED; // XXX
+ ob->nlaflag ^= OB_ADS_COLLAPSED; // XXX
+ notifierFlags |= ND_ANIMCHAN_EDIT;
}
else if (nlaedit_is_tweakmode_on(ac) == 0) {
/* set selection status */
@@ -166,6 +172,9 @@ static void mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sh
/* xxx should be ED_base_object_activate(), but we need context pointer for that... */
//set_active_base(base);
+
+ /* notifiers - channel was selected */
+ notifierFlags |= ND_ANIMCHAN_SELECT;
}
}
break;
@@ -173,6 +182,7 @@ static void mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sh
{
Object *ob= (Object *)ale->data;
ob->nlaflag ^= OB_ADS_SHOWMATS; // XXX
+ notifierFlags |= ND_ANIMCHAN_EDIT;
}
break;
@@ -180,36 +190,42 @@ static void mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sh
{
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;
@@ -233,14 +249,23 @@ static void mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sh
if (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) {
/* toggle protection (only if there's a toggle there) */
nlt->flag ^= NLATRACK_PROTECTED;
+
+ /* notifier flags - channel was edited */
+ notifierFlags |= ND_ANIMCHAN_EDIT;
}
else if (x >= (NLACHANNEL_NAMEWIDTH-2*NLACHANNEL_BUTTON_WIDTH)) {
/* toggle mute */
nlt->flag ^= NLATRACK_MUTED;
+
+ /* notifier flags - channel was edited */
+ notifierFlags |= ND_ANIMCHAN_EDIT;
}
else if (x <= ((NLACHANNEL_BUTTON_WIDTH*2)+offset)) {
/* toggle 'solo' */
BKE_nlatrack_solo_toggle(adt, nlt);
+
+ /* notifier flags - channel was edited */
+ notifierFlags |= ND_ANIMCHAN_EDIT;
}
else if (nlaedit_is_tweakmode_on(ac) == 0) {
/* set selection */
@@ -257,6 +282,9 @@ static void mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sh
/* if NLA-Track is selected now, make NLA-Track the 'active' one in the visible list */
if (nlt->flag & NLATRACK_SELECTED)
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, nlt, ANIMTYPE_NLATRACK);
+
+ /* notifier flags - channel was selected */
+ notifierFlags |= ND_ANIMCHAN_SELECT;
}
}
break;
@@ -275,6 +303,9 @@ static void mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sh
/* when in tweakmode, this button becomes the toggle for mapped editing */
adt->flag ^= ADT_NLA_EDIT_NOMAP;
}
+
+ /* changes to NLA-Action occurred */
+ notifierFlags |= ND_NLA_ACTCHANGE;
}
}
break;
@@ -285,6 +316,9 @@ static void mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sh
/* free channels */
BLI_freelistN(&anim_data);
+
+ /* return the notifier-flags set */
+ return notifierFlags;
}
/* ------------------- */
@@ -297,6 +331,7 @@ static int nlachannels_mouseclick_invoke(bContext *C, wmOperator *op, wmEvent *e
ARegion *ar;
View2D *v2d;
int mval[2], channel_index;
+ int notifierFlags = 0;
short selectmode;
float x, y;
@@ -328,10 +363,10 @@ static int nlachannels_mouseclick_invoke(bContext *C, wmOperator *op, wmEvent *e
UI_view2d_listview_view_to_cell(v2d, NLACHANNEL_NAMEWIDTH, NLACHANNEL_STEP, 0, (float)NLACHANNEL_HEIGHT_HALF, x, y, NULL, &channel_index);
/* handle mouse-click in the relevant channel then */
- mouse_nla_channels(&ac, x, channel_index, selectmode);
+ notifierFlags= mouse_nla_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;
}
@@ -401,8 +436,7 @@ static int nlaedit_add_tracks_exec (bContext *C, wmOperator *op)
BLI_freelistN(&anim_data);
/* set notifier that things have changed */
- ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_BOTH);
- WM_event_add_notifier(C, NC_SCENE, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_EDIT, NULL);
/* done */
return OPERATOR_FINISHED;
@@ -458,8 +492,7 @@ static int nlaedit_delete_tracks_exec (bContext *C, wmOperator *op)
BLI_freelistN(&anim_data);
/* set notifier that things have changed */
- ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_BOTH);
- WM_event_add_notifier(C, NC_SCENE, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_EDIT, NULL);
/* done */
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c
index 6cbc9cab253..cb151429dd1 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -127,8 +127,7 @@ static int nlaedit_enable_tweakmode_exec (bContext *C, wmOperator *op)
ac.scene->flag |= SCE_NLA_EDIT_ON;
/* set notifier that things have changed */
- ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_BOTH);
- WM_event_add_notifier(C, NC_SCENE, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_ACTCHANGE, NULL);
}
else {
BKE_report(op->reports, RPT_ERROR, "No active strip(s) to enter tweakmode on.");
@@ -197,8 +196,7 @@ static int nlaedit_disable_tweakmode_exec (bContext *C, wmOperator *op)
ac.scene->flag &= ~SCE_NLA_EDIT_ON;
/* set notifier that things have changed */
- ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_BOTH);
- WM_event_add_notifier(C, NC_SCENE, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_ACTCHANGE, NULL);
}
/* done */
@@ -315,8 +313,7 @@ static int nlaedit_add_actionclip_exec (bContext *C, wmOperator *op)
BLI_freelistN(&anim_data);
/* set notifier that things have changed */
- ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_BOTH);
- WM_event_add_notifier(C, NC_SCENE, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_EDIT, NULL);
/* done */
return OPERATOR_FINISHED;
@@ -424,8 +421,7 @@ static int nlaedit_add_transition_exec (bContext *C, wmOperator *op)
/* was anything added? */
if (done) {
/* set notifier that things have changed */
- ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_BOTH);
- WM_event_add_notifier(C, NC_SCENE, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_EDIT, NULL);
/* done */
return OPERATOR_FINISHED;
@@ -483,8 +479,7 @@ static int nlaedit_add_meta_exec (bContext *C, wmOperator *op)
BLI_freelistN(&anim_data);
/* set notifier that things have changed */
- ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_BOTH);
- WM_event_add_notifier(C, NC_SCENE, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_EDIT, NULL);
/* done */
return OPERATOR_FINISHED;
@@ -536,8 +531,7 @@ static int nlaedit_remove_meta_exec (bContext *C, wmOperator *op)
BLI_freelistN(&anim_data);
/* set notifier that things have changed */
- ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_BOTH);
- WM_event_add_notifier(C, NC_SCENE, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_EDIT, NULL);
/* done */
return OPERATOR_FINISHED;
@@ -621,8 +615,7 @@ static int nlaedit_duplicate_exec (bContext *C, wmOperator *op)
if (done) {
/* set notifier that things have changed */
- ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_BOTH);
- WM_event_add_notifier(C, NC_SCENE, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_EDIT, NULL);
/* done */
return OPERATOR_FINISHED;
@@ -707,8 +700,7 @@ static int nlaedit_delete_exec (bContext *C, wmOperator *op)
BLI_freelistN(&anim_data);
/* set notifier that things have changed */
- ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_BOTH);
- WM_event_add_notifier(C, NC_SCENE, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_EDIT, NULL);
/* done */
return OPERATOR_FINISHED;
@@ -831,8 +823,7 @@ static int nlaedit_split_exec (bContext *C, wmOperator *op)
BLI_freelistN(&anim_data);
/* set notifier that things have changed */
- ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_BOTH);
- WM_event_add_notifier(C, NC_SCENE, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_EDIT, NULL);
/* done */
return OPERATOR_FINISHED;
@@ -894,8 +885,7 @@ static int nlaedit_toggle_mute_exec (bContext *C, wmOperator *op)
BLI_freelistN(&anim_data);
/* set notifier that things have changed */
- ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_BOTH);
- WM_event_add_notifier(C, NC_SCENE, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_EDIT, NULL);
/* done */
return OPERATOR_FINISHED;
@@ -966,8 +956,7 @@ static int nlaedit_move_up_exec (bContext *C, wmOperator *op)
BLI_freelistN(&anim_data);
/* set notifier that things have changed */
- ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_BOTH);
- WM_event_add_notifier(C, NC_SCENE, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_EDIT, NULL);
/* done */
return OPERATOR_FINISHED;
@@ -1038,8 +1027,7 @@ static int nlaedit_move_down_exec (bContext *C, wmOperator *op)
BLI_freelistN(&anim_data);
/* set notifier that things have changed */
- ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_BOTH);
- WM_event_add_notifier(C, NC_SCENE, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_EDIT, NULL);
/* done */
return OPERATOR_FINISHED;
@@ -1137,8 +1125,7 @@ static int nlaedit_apply_scale_exec (bContext *C, wmOperator *op)
BLI_freelistN(&anim_data);
/* set notifier that things have changed */
- ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_BOTH);
- WM_event_add_notifier(C, NC_SCENE, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_EDIT, NULL);
/* done */
return OPERATOR_FINISHED;
@@ -1198,8 +1185,7 @@ static int nlaedit_clear_scale_exec (bContext *C, wmOperator *op)
BLI_freelistN(&anim_data);
/* set notifier that things have changed */
- ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_BOTH);
- WM_event_add_notifier(C, NC_SCENE, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_EDIT, NULL);
/* done */
return OPERATOR_FINISHED;
@@ -1337,8 +1323,7 @@ static int nlaedit_snap_exec (bContext *C, wmOperator *op)
BLI_freelistN(&anim_data);
/* set notifier that things have changed */
- ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_BOTH);
- WM_event_add_notifier(C, NC_SCENE, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_EDIT, NULL);
/* done */
return OPERATOR_FINISHED;
@@ -1447,8 +1432,8 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op)
BLI_freelistN(&anim_data);
/* set notifier that things have changed */
- ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_BOTH);
- WM_event_add_notifier(C, NC_SCENE, NULL);
+ // FIXME: this doesn't really do it justice...
+ WM_event_add_notifier(C, NC_ANIMATION, NULL);
/* done */
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c
index 895d0dbf88a..dd9ef2621c5 100644
--- a/source/blender/editors/space_nla/nla_select.c
+++ b/source/blender/editors/space_nla/nla_select.c
@@ -186,7 +186,7 @@ static int nlaedit_deselectall_exec(bContext *C, wmOperator *op)
deselect_nla_strips(&ac, DESELECT_STRIPS_TEST, SELECT_ADD);
/* set notifier that things have changed */
- ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_BOTH);
+ WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_SELECT, NULL);
return OPERATOR_FINISHED;
}
@@ -324,6 +324,9 @@ static int nlaedit_borderselect_exec(bContext *C, wmOperator *op)
/* apply borderselect action */
borderselect_nla_strips(&ac, rect, mode, selectmode);
+ /* set notifier that things have changed */
+ WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_SELECT, NULL);
+
return OPERATOR_FINISHED;
}
@@ -583,7 +586,7 @@ static int nlaedit_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *even
}
/* set notifier that things have changed */
- ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_BOTH);
+ WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_SELECT, NULL);
/* for tweak grab to work */
return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH;
diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c
index a7e9844726d..923208f3b35 100644
--- a/source/blender/editors/space_nla/space_nla.c
+++ b/source/blender/editors/space_nla/space_nla.c
@@ -371,6 +371,9 @@ static void nla_region_listener(ARegion *ar, wmNotifier *wmn)
{
/* context changes */
switch(wmn->category) {
+ case NC_ANIMATION:
+ ED_region_tag_redraw(ar);
+ break;
case NC_SCENE:
switch(wmn->data) {
case ND_OB_ACTIVE:
@@ -392,7 +395,7 @@ static void nla_region_listener(ARegion *ar, wmNotifier *wmn)
default:
if(wmn->data==ND_KEYS)
ED_region_tag_redraw(ar);
-
+ break;
}
}
@@ -401,6 +404,9 @@ static void nla_main_area_listener(ARegion *ar, wmNotifier *wmn)
{
/* context changes */
switch(wmn->category) {
+ case NC_ANIMATION:
+ ED_region_tag_redraw(ar);
+ break;
case NC_SCENE:
switch(wmn->data) {
case ND_OB_ACTIVE:
@@ -430,6 +436,9 @@ static void nla_channel_area_listener(ARegion *ar, wmNotifier *wmn)
{
/* context changes */
switch(wmn->category) {
+ case NC_ANIMATION:
+ ED_region_tag_redraw(ar);
+ break;
case NC_SCENE:
switch(wmn->data) {
case ND_OB_ACTIVE:
@@ -457,6 +466,10 @@ static void nla_listener(ScrArea *sa, wmNotifier *wmn)
{
/* context changes */
switch (wmn->category) {
+ case NC_ANIMATION:
+ // TODO: filter specific types of changes?
+ ED_area_tag_refresh(sa);
+ break;
case NC_SCENE:
/*switch (wmn->data) {
case ND_OB_ACTIVE: