2.5 - Action Editor Transforms now work again

Note: there were some crashes that would occur if context was not reset everytime the modal callback was run. Probably there's something about the context info we need to be more careful about.
This commit is contained in:
Joshua Leung
2008-12-29 07:19:16 +00:00
parent d249110213
commit a91e79ba70
6 changed files with 46 additions and 40 deletions

View File

@@ -224,10 +224,11 @@ short ANIM_animdata_get_context (const bContext *C, bAnimContext *ac)
ac->obact= (scene && scene->basact)? scene->basact->object : NULL; ac->obact= (scene && scene->basact)? scene->basact->object : NULL;
ac->sa= sa; ac->sa= sa;
ac->ar= ar; ac->ar= ar;
ac->spacetype= sa->spacetype; ac->spacetype= (sa) ? sa->spacetype : 0;
ac->regiontype= ar->regiontype; ac->regiontype= (ar) ? ar->regiontype : 0;
/* context depends on editor we are currently in */ /* context depends on editor we are currently in */
if (sa) {
switch (sa->spacetype) { switch (sa->spacetype) {
case SPACE_ACTION: case SPACE_ACTION:
{ {
@@ -243,6 +244,7 @@ short ANIM_animdata_get_context (const bContext *C, bAnimContext *ac)
} }
break; break;
} }
}
/* check if there's any valid data */ /* check if there's any valid data */
if (ok && ac->data) if (ok && ac->data)

View File

@@ -46,6 +46,8 @@
#include "UI_interface.h" #include "UI_interface.h"
#include "UI_view2d.h" #include "UI_view2d.h"
#include "BIF_transform.h"
#include "action_intern.h" #include "action_intern.h"
#include "RNA_access.h" #include "RNA_access.h"
@@ -82,7 +84,7 @@ void action_operatortypes(void)
/* ************************** registration - keymaps **********************************/ /* ************************** registration - keymaps **********************************/
static void action_keymap_keyframes (ListBase *keymap) static void action_keymap_keyframes (wmWindowManager *wm, ListBase *keymap)
{ {
/* action_select.c - selection tools */ /* action_select.c - selection tools */
/* click-select */ /* click-select */
@@ -124,6 +126,9 @@ static void action_keymap_keyframes (ListBase *keymap)
WM_keymap_add_item(keymap, "ACT_OT_keyframes_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ACT_OT_keyframes_delete", XKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "ACT_OT_keyframes_delete", DELKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ACT_OT_keyframes_delete", DELKEY, KM_PRESS, 0, 0);
/* transform system */
transform_keymap_for_space(wm, keymap, SPACE_ACTION);
} }
/* --------------- */ /* --------------- */
@@ -137,6 +142,6 @@ void action_keymap(wmWindowManager *wm)
/* keyframes */ /* keyframes */
keymap= WM_keymap_listbase(wm, "Action_Keys", SPACE_ACTION, 0); keymap= WM_keymap_listbase(wm, "Action_Keys", SPACE_ACTION, 0);
action_keymap_keyframes(keymap); action_keymap_keyframes(wm, keymap);
} }

View File

@@ -469,7 +469,7 @@ static void viewRedrawForce(TransInfo *t)
ED_area_tag_redraw(t->sa); ED_area_tag_redraw(t->sa);
} }
else if (t->spacetype == SPACE_ACTION) { else if (t->spacetype == SPACE_ACTION) {
SpaceAction *saction= (SpaceAction *)CTX_wm_space_data(t->context); SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
// TRANSFORM_FIX_ME // TRANSFORM_FIX_ME
if (saction->lock) { if (saction->lock) {
@@ -4263,7 +4263,7 @@ static short getAnimEdit_SnapMode(TransInfo *t)
/* currently, some of these are only for the action editor */ /* currently, some of these are only for the action editor */
if (t->spacetype == SPACE_ACTION) { if (t->spacetype == SPACE_ACTION) {
SpaceAction *saction= (SpaceAction *)CTX_wm_space_data(t->context); SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
if (saction) { if (saction) {
switch (saction->autosnap) { switch (saction->autosnap) {
@@ -4290,7 +4290,7 @@ static short getAnimEdit_SnapMode(TransInfo *t)
} }
} }
else if (t->spacetype == SPACE_NLA) { else if (t->spacetype == SPACE_NLA) {
SpaceNla *snla= (SpaceNla *)CTX_wm_space_data(t->context); SpaceNla *snla= (SpaceNla *)t->sa->spacedata.first;
if (snla) { if (snla) {
switch (snla->autosnap) { switch (snla->autosnap) {
@@ -4340,12 +4340,12 @@ static short getAnimEdit_DrawTime(TransInfo *t)
/* currently, some of these are only for the action editor */ /* currently, some of these are only for the action editor */
if (t->spacetype == SPACE_ACTION) { if (t->spacetype == SPACE_ACTION) {
SpaceAction *saction= (SpaceAction *)CTX_wm_space_data(t->context); SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
drawtime = (saction->flag & SACTION_DRAWTIME)? 1 : 0; drawtime = (saction->flag & SACTION_DRAWTIME)? 1 : 0;
} }
else if (t->spacetype == SPACE_NLA) { else if (t->spacetype == SPACE_NLA) {
SpaceNla *snla= (SpaceNla *)CTX_wm_space_data(t->context); SpaceNla *snla= (SpaceNla *)t->sa->spacedata.first;
drawtime = (snla->flag & SNLA_DRAWTIME)? 1 : 0; drawtime = (snla->flag & SNLA_DRAWTIME)? 1 : 0;
} }
@@ -4548,7 +4548,7 @@ void initTimeSlide(TransInfo *t)
{ {
/* this tool is only really available in the Action Editor... */ /* this tool is only really available in the Action Editor... */
if (t->spacetype == SPACE_ACTION) { if (t->spacetype == SPACE_ACTION) {
SpaceAction *saction= (SpaceAction *)CTX_wm_space_data(t->context); SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
/* set flag for drawing stuff */ /* set flag for drawing stuff */
saction->flag |= SACTION_MOVING; saction->flag |= SACTION_MOVING;
@@ -4576,9 +4576,9 @@ static void headerTimeSlide(TransInfo *t, float sval, char *str)
outputNumInput(&(t->num), tvec); outputNumInput(&(t->num), tvec);
} }
else { else {
const float minx= *((float *)(t->customData)); float minx= *((float *)(t->customData));
const float maxx= *((float *)(t->customData) + 1); float maxx= *((float *)(t->customData) + 1);
const float cval= t->fac; float cval= t->fac;
float val; float val;
val= 2.0f*(cval-sval) / (maxx-minx); val= 2.0f*(cval-sval) / (maxx-minx);
@@ -4598,17 +4598,11 @@ static void applyTimeSlide(TransInfo *t, float sval)
float minx= *((float *)(t->customData)); float minx= *((float *)(t->customData));
float maxx= *((float *)(t->customData) + 1); float maxx= *((float *)(t->customData) + 1);
/* set value for drawing black line */ /* set value for drawing black line */
if (t->spacetype == SPACE_ACTION) { if (t->spacetype == SPACE_ACTION) {
SpaceAction *saction= (SpaceAction *)CTX_wm_space_data(t->context); SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
float cvalf = t->fac; float cvalf = t->fac;
#if 0 // TRANSFORM_FIX_ME
if (NLA_ACTION_SCALED)
cvalf= get_action_frame(OBACT, cvalf);
#endif
saction->timeslide= cvalf; saction->timeslide= cvalf;
} }
@@ -4658,7 +4652,7 @@ int TimeSlide(TransInfo *t, short mval[2])
t->fac= cval[0]; t->fac= cval[0];
/* handle numeric-input stuff */ /* handle numeric-input stuff */
t->vec[0] = 2.0*(cval[0]-sval[0]) / (maxx-minx); t->vec[0] = 2.0f*(cval[0]-sval[0]) / (maxx-minx);
applyNumInput(&t->num, &t->vec[0]); applyNumInput(&t->num, &t->vec[0]);
t->fac = (maxx-minx) * t->vec[0] / 2.0 + sval[0]; t->fac = (maxx-minx) * t->vec[0] / 2.0 + sval[0];

View File

@@ -3973,7 +3973,7 @@ void special_aftertrans_update(TransInfo *t)
} }
if (t->spacetype == SPACE_ACTION) { if (t->spacetype == SPACE_ACTION) {
SpaceAction *saction= (SpaceAction *)CTX_wm_space_data(t->context); SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
Scene *scene= NULL; Scene *scene= NULL;
bAnimContext ac; bAnimContext ac;
@@ -3984,8 +3984,8 @@ void special_aftertrans_update(TransInfo *t)
} }
/* get pointers to useful data */ /* get pointers to useful data */
ob = OBACT;
scene= ac.scene; scene= ac.scene;
ob = OBACT;
if (ac.datatype == ANIMCONT_DOPESHEET) { if (ac.datatype == ANIMCONT_DOPESHEET) {
ListBase anim_data = {NULL, NULL}; ListBase anim_data = {NULL, NULL};

View File

@@ -730,7 +730,7 @@ void initTransInfo (bContext *C, TransInfo *t, wmEvent *event)
} }
else if(t->spacetype==SPACE_IMAGE) else if(t->spacetype==SPACE_IMAGE)
{ {
View2D *v2d = sa->spacedata.first; View2D *v2d = sa->spacedata.first; // XXX no!
t->view = v2d; t->view = v2d;
@@ -738,7 +738,8 @@ void initTransInfo (bContext *C, TransInfo *t, wmEvent *event)
} }
else else
{ {
t->view = NULL; // XXX for now, get View2D from the active region
t->view = &ar->v2d;
t->around = V3D_CENTER; t->around = V3D_CENTER;
} }

View File

@@ -63,6 +63,10 @@ static int transform_modal(bContext *C, wmOperator *op, wmEvent *event)
{ {
TransInfo *t = op->customdata; TransInfo *t = op->customdata;
/* need to set context here, otherwise we get crashes with things that use context */
// XXX this seems quite hackish - Aligorith
t->context= C;
transformEvent(t, event); transformEvent(t, event);
transformApply(t); transformApply(t);