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,24 +224,26 @@ short ANIM_animdata_get_context (const bContext *C, bAnimContext *ac)
ac->obact= (scene && scene->basact)? scene->basact->object : NULL;
ac->sa= sa;
ac->ar= ar;
ac->spacetype= sa->spacetype;
ac->regiontype= ar->regiontype;
ac->spacetype= (sa) ? sa->spacetype : 0;
ac->regiontype= (ar) ? ar->regiontype : 0;
/* context depends on editor we are currently in */
switch (sa->spacetype) {
case SPACE_ACTION:
{
SpaceAction *saction= (SpaceAction *)CTX_wm_space_data(C);
ok= actedit_get_context(C, ac, saction);
if (sa) {
switch (sa->spacetype) {
case SPACE_ACTION:
{
SpaceAction *saction= (SpaceAction *)CTX_wm_space_data(C);
ok= actedit_get_context(C, ac, saction);
}
break;
case SPACE_IPO:
{
SpaceIpo *sipo= (SpaceIpo *)CTX_wm_space_data(C);
ok= ipoedit_get_context(C, ac, sipo);
}
break;
}
break;
case SPACE_IPO:
{
SpaceIpo *sipo= (SpaceIpo *)CTX_wm_space_data(C);
ok= ipoedit_get_context(C, ac, sipo);
}
break;
}
/* check if there's any valid data */

View File

@@ -46,6 +46,8 @@
#include "UI_interface.h"
#include "UI_view2d.h"
#include "BIF_transform.h"
#include "action_intern.h"
#include "RNA_access.h"
@@ -82,7 +84,7 @@ void action_operatortypes(void)
/* ************************** registration - keymaps **********************************/
static void action_keymap_keyframes (ListBase *keymap)
static void action_keymap_keyframes (wmWindowManager *wm, ListBase *keymap)
{
/* action_select.c - selection tools */
/* 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", 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 */
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);
}
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
if (saction->lock) {
@@ -4263,7 +4263,7 @@ static short getAnimEdit_SnapMode(TransInfo *t)
/* currently, some of these are only for the action editor */
if (t->spacetype == SPACE_ACTION) {
SpaceAction *saction= (SpaceAction *)CTX_wm_space_data(t->context);
SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
if (saction) {
switch (saction->autosnap) {
@@ -4290,7 +4290,7 @@ static short getAnimEdit_SnapMode(TransInfo *t)
}
}
else if (t->spacetype == SPACE_NLA) {
SpaceNla *snla= (SpaceNla *)CTX_wm_space_data(t->context);
SpaceNla *snla= (SpaceNla *)t->sa->spacedata.first;
if (snla) {
switch (snla->autosnap) {
@@ -4340,12 +4340,12 @@ static short getAnimEdit_DrawTime(TransInfo *t)
/* currently, some of these are only for the action editor */
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;
}
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;
}
@@ -4548,7 +4548,7 @@ void initTimeSlide(TransInfo *t)
{
/* this tool is only really available in the Action Editor... */
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 */
saction->flag |= SACTION_MOVING;
@@ -4576,9 +4576,9 @@ static void headerTimeSlide(TransInfo *t, float sval, char *str)
outputNumInput(&(t->num), tvec);
}
else {
const float minx= *((float *)(t->customData));
const float maxx= *((float *)(t->customData) + 1);
const float cval= t->fac;
float minx= *((float *)(t->customData));
float maxx= *((float *)(t->customData) + 1);
float cval= t->fac;
float val;
val= 2.0f*(cval-sval) / (maxx-minx);
@@ -4598,17 +4598,11 @@ static void applyTimeSlide(TransInfo *t, float sval)
float minx= *((float *)(t->customData));
float maxx= *((float *)(t->customData) + 1);
/* set value for drawing black line */
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;
#if 0 // TRANSFORM_FIX_ME
if (NLA_ACTION_SCALED)
cvalf= get_action_frame(OBACT, cvalf);
#endif
saction->timeslide= cvalf;
}
@@ -4658,7 +4652,7 @@ int TimeSlide(TransInfo *t, short mval[2])
t->fac= cval[0];
/* 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]);
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) {
SpaceAction *saction= (SpaceAction *)CTX_wm_space_data(t->context);
SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
Scene *scene= NULL;
bAnimContext ac;
@@ -3984,8 +3984,8 @@ void special_aftertrans_update(TransInfo *t)
}
/* get pointers to useful data */
ob = OBACT;
scene= ac.scene;
ob = OBACT;
if (ac.datatype == ANIMCONT_DOPESHEET) {
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)
{
View2D *v2d = sa->spacedata.first;
View2D *v2d = sa->spacedata.first; // XXX no!
t->view = v2d;
@@ -738,7 +738,8 @@ void initTransInfo (bContext *C, TransInfo *t, wmEvent *event)
}
else
{
t->view = NULL;
// XXX for now, get View2D from the active region
t->view = &ar->v2d;
t->around = V3D_CENTER;
}

View File

@@ -62,7 +62,11 @@ static void transformops_data(bContext *C, wmOperator *op, wmEvent *event)
static int transform_modal(bContext *C, wmOperator *op, wmEvent *event)
{
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);
transformApply(t);