2.5 - Animation and View2D

* Added back deselect all (and invert all) tools for Animation Channels (i.e. channel list in Action Editor).

* Resolved all MSVC warnings (I came across) in View2d code. Also, added a new API method to get the coordinates (in 'view' space) of a listview 'cell' given the row + column the cell is in.

* Tidied up a few comments here and there
This commit is contained in:
Joshua Leung 2009-01-02 00:56:48 +00:00
parent c32fbee896
commit e6838f621d
10 changed files with 326 additions and 121 deletions

@ -5264,9 +5264,9 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
case SPACE_ACTION:
{
SpaceAction *saction= (SpaceAction *)sl;
memcpy(&ar->v2d, &saction->v2d, sizeof(View2D));
ar->v2d.tot.xmin= -10.0f;
/* we totally reinit the view for the Action Editor, as some old instances had some weird cruft set */
ar->v2d.tot.xmin= -20.0f;
ar->v2d.tot.ymin= (float)(-sa->winy);
ar->v2d.tot.xmax= (float)(sa->winx);
ar->v2d.tot.ymax= 0.0f;

@ -86,18 +86,177 @@
/* ************************************************************************** */
/* CHANNELS API */
/* -------------------------- Internal Macros ------------------------------- */
/* set/clear/toggle macro
* - channel - channel with a 'flag' member that we're setting
* - smode - 0=clear, 1=set, 2=toggle
* - sflag - bitflag to set
*/
#define ACHANNEL_SET_FLAG(channel, smode, sflag) \
{ \
if (smode == ACHANNEL_SETFLAG_TOGGLE) (channel)->flag ^= (sflag); \
else if (smode == ACHANNEL_SETFLAG_ADD) (channel)->flag |= (sflag); \
else (channel)->flag &= ~(sflag); \
}
/* -------------------------- Internal Tools -------------------------------- */
/* -------------------------- Exposed API ----------------------------------- */
/* Deselect all animation channels
* - data: pointer to datatype, as contained in bAnimContext
* - datatype: the type of data that 'data' represents (eAnim_ChannelType)
* - test: check if deselecting instead of selecting
* - sel: eAnimChannels_SetFlag;
*/
void ANIM_deselect_anim_channels (void *data, short datatype, short test, short sel)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
/* filter data */
filter= ANIMFILTER_VISIBLE;
ANIM_animdata_filter(&anim_data, filter, data, datatype);
/* See if we should be selecting or deselecting */
if (test) {
for (ale= anim_data.first; ale; ale= ale->next) {
if (sel == 0)
break;
switch (ale->type) {
case ANIMTYPE_OBJECT:
if (ale->flag & SELECT)
sel= ACHANNEL_SETFLAG_CLEAR;
break;
case ANIMTYPE_FILLACTD:
if (ale->flag & ACTC_SELECTED)
sel= ACHANNEL_SETFLAG_CLEAR;
break;
case ANIMTYPE_GROUP:
if (ale->flag & AGRP_SELECTED)
sel= ACHANNEL_SETFLAG_CLEAR;
break;
case ANIMTYPE_ACHAN:
if (ale->flag & ACHAN_SELECTED)
sel= ACHANNEL_SETFLAG_CLEAR;
break;
case ANIMTYPE_CONCHAN:
if (ale->flag & CONSTRAINT_CHANNEL_SELECT)
sel= ACHANNEL_SETFLAG_CLEAR;
break;
case ANIMTYPE_ICU:
if (ale->flag & IPO_SELECT)
sel= ACHANNEL_SETFLAG_CLEAR;
break;
}
}
}
/* Now set the flags */
for (ale= anim_data.first; ale; ale= ale->next) {
switch (ale->type) {
case ANIMTYPE_OBJECT:
{
Base *base= (Base *)ale->data;
Object *ob= base->object;
ACHANNEL_SET_FLAG(base, sel, SELECT);
ACHANNEL_SET_FLAG(ob, sel, SELECT);
}
break;
case ANIMTYPE_FILLACTD:
{
bAction *act= (bAction *)ale->data;
ACHANNEL_SET_FLAG(act, sel, ACTC_SELECTED);
}
break;
case ANIMTYPE_GROUP:
{
bActionGroup *agrp= (bActionGroup *)ale->data;
ACHANNEL_SET_FLAG(agrp, sel, AGRP_SELECTED);
agrp->flag &= ~AGRP_ACTIVE;
}
break;
case ANIMTYPE_ACHAN:
{
bActionChannel *achan= (bActionChannel *)ale->data;
ACHANNEL_SET_FLAG(achan, sel, ACHAN_SELECTED);
//select_poseelement_by_name(achan->name, sel); // XXX
achan->flag &= ~ACHAN_HILIGHTED;
}
break;
case ANIMTYPE_CONCHAN:
{
bConstraintChannel *conchan= (bConstraintChannel *)ale->data;
ACHANNEL_SET_FLAG(conchan, sel, CONSTRAINT_CHANNEL_SELECT);
}
break;
case ANIMTYPE_ICU:
{
IpoCurve *icu= (IpoCurve *)ale->data;
ACHANNEL_SET_FLAG(icu, sel, IPO_SELECT);
icu->flag &= ~IPO_ACTIVE;
}
break;
}
}
/* Cleanup */
BLI_freelistN(&anim_data);
}
/* ************************************************************************** */
/* OPERATORS */
/* ********************** Select All Operator *********************** */
static int animchannels_deselectall_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
/* 'standard' behaviour - check if selected, then apply relevant selection */
if (RNA_boolean_get(op->ptr, "invert"))
ANIM_deselect_anim_channels(ac.data, ac.datatype, 0, ACHANNEL_SETFLAG_TOGGLE);
else
ANIM_deselect_anim_channels(ac.data, ac.datatype, 1, ACHANNEL_SETFLAG_ADD);
/* set notifier tha things have changed */
ED_area_tag_redraw(CTX_wm_area(C)); // FIXME... should be updating 'keyframes' data context or so instead!
return OPERATOR_FINISHED;
}
void ANIM_OT_channels_deselectall (wmOperatorType *ot)
{
/* identifiers */
ot->name= "Select All";
ot->idname= "ANIM_OT_channels_deselectall";
/* api callbacks */
ot->exec= animchannels_deselectall_exec;
ot->poll= ED_operator_areaactive;
/* flags */
ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
/* props */
RNA_def_property(ot->srna, "invert", PROP_BOOLEAN, PROP_NONE);
}
/* ******************** Mouse-Click Operator *********************** */
/* Depending on the channel that was clicked on, the mouse click will activate whichever
@ -243,7 +402,7 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s
/* inverse selection status of group */
//select_action_group(act, agrp, SELECT_INVERT);
}
else if (/*G.qual == (LR_CTRLKEY|LR_SHIFTKEY)*/0) {
else if (/*G.qual == (LR_CTRLKEY|LR_SHIFTKEY)*/selectmode == -1) {
// FIXME: need a special case for this!
/* select all in group (and deselect everthing else) */
//select_action_group_channels(act, agrp);
@ -251,7 +410,7 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s
}
else {
/* select group by itself */
//deselect_actionchannels(act, ANIMCONT_ACTION, 0);
ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
//select_action_group(act, agrp, SELECT_ADD);
}
@ -283,7 +442,7 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s
//select_channel(act, achan, SELECT_INVERT);
}
else {
//deselect_actionchannels(act, ACTCONT_ACTION, 0);
ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
//select_channel(act, achan, SELECT_ADD);
}
@ -303,7 +462,7 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s
if ((x > 24) && (achan->flag & ACHAN_SHOWIPO)) {
/* select+make active achan */
//deselect_actionchannels(act, ACTCONT_ACTION, 0);
ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
//select_channel(act, achan, SELECT_ADD);
/* messy... set active bone */
@ -322,7 +481,7 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s
if ((x > 24) && (achan->flag & ACHAN_SHOWCONS)) {
/* select+make active achan */
//deselect_actionchannels(act, ACTCONT_ACTION, 0);
ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
//select_channel(act, achan, SELECT_ADD);
/* messy... set active bone */
@ -460,7 +619,7 @@ static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, wmEvent *
* ACHANNEL_HEIGHT_HALF.
*/
UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y);
UI_view2d_listview_get_cell(v2d, ACHANNEL_NAMEWIDTH, ACHANNEL_STEP, 0, (float)ACHANNEL_HEIGHT_HALF, x, y, NULL, &channel_index);
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);
@ -490,6 +649,7 @@ void ANIM_OT_channels_mouseclick (wmOperatorType *ot)
void ED_operatortypes_animchannels(void)
{
WM_operatortype_append(ANIM_OT_channels_deselectall);
WM_operatortype_append(ANIM_OT_channels_mouseclick);
}
@ -501,6 +661,10 @@ void ED_keymap_animchannels(wmWindowManager *wm)
// XXX for now, only leftmouse....
WM_keymap_add_item(keymap, "ANIM_OT_channels_mouseclick", LEFTMOUSE, KM_PRESS, 0, 0);
RNA_boolean_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_mouseclick", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "extend_select", 1);
/* deselect all */
WM_keymap_add_item(keymap, "ANIM_OT_channels_deselectall", AKEY, KM_PRESS, 0, 0);
RNA_boolean_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_deselectall", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "invert", 1);
}
/* ************************************************************************** */

@ -79,7 +79,7 @@ static void draw_cfra_number (Scene *scene, View2D *v2d, float cfra, short time)
/* because the frame number text is subject to the same scaling as the contents of the view */
UI_view2d_getscale(v2d, &xscale, &yscale);
glScalef(1.0/xscale, 1.0, 1.0);
glScalef(1.0f/xscale, 1.0f, 1.0f);
if (time)
sprintf(str, " %.2f", FRA2TIME(CFRA));
@ -97,7 +97,7 @@ static void draw_cfra_number (Scene *scene, View2D *v2d, float cfra, short time)
/* draw current frame number - black text */
UI_ThemeColor(TH_TEXT);
ui_rasterpos_safe(x-5, y+3, 1.0);
ui_rasterpos_safe(x-5, y+3, 1.0f);
UI_DrawString(G.fonts, str, 0); // XXX may need to be updated for font stuff
/* restore view transform */
@ -168,8 +168,8 @@ void ANIM_draw_previewrange (const bContext *C, View2D *v2d)
/* only draw two separate 'curtains' if there's no overlap between them */
if (PSFRA < PEFRA) {
glRectf(v2d->cur.xmin, v2d->cur.ymin, PSFRA, v2d->cur.ymax);
glRectf(PEFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax);
glRectf((float)PEFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
}
else {
glRectf(v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);

@ -44,6 +44,7 @@ struct IpoCurve;
/* ************************************************ */
/* ANIMATION CHANNEL FILTERING */
/* anim_filter.c */
/* --------------- Context --------------------- */
@ -243,11 +244,25 @@ short ANIM_animdata_context_getdata(bAnimContext *ac);
/* ************************************************ */
/* ANIMATION CHANNELS LIST */
/* anim_channels.c */
/* ------------------------ API -------------------------- */
/* Deselect all animation channels */
void ANIM_deselect_anim_channels(void *data, short datatype, short test, short sel);
/* --------------- Settings and/or Defines -------------- */
/* flag-setting behaviour */
enum {
ACHANNEL_SETFLAG_CLEAR = 0,
ACHANNEL_SETFLAG_ADD,
ACHANNEL_SETFLAG_TOGGLE
} eAnimChannels_SetFlag;
/* ************************************************ */
/* DRAWING API */
/* anim_draw.c */
/* ---------- Current Frame Drawing ---------------- */
@ -275,7 +290,7 @@ void ANIM_draw_previewrange(const struct bContext *C, struct View2D *v2d);
/* ASSORTED TOOLS */
/* ------------ IPO Adrcode <-> Icons/Names Mapping ------------ */
/* anim_ipo_utils.c */
int geticon_ipo_blocktype(short blocktype);
char *getname_ipocurve(struct IpoCurve *icu, struct Object *ob);
@ -284,6 +299,7 @@ unsigned int ipo_rainbow(int cur, int tot);
/* ------------- NLA-Mapping ----------------------- */
/* anim_draw.c */
/* Obtain the Object providing NLA-scaling for the given channel if applicable */
struct Object *ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale);
@ -295,6 +311,7 @@ void ANIM_nla_mapping_draw(struct gla2DDrawInfo *di, struct Object *ob, short re
void ANIM_nla_mapping_apply(struct Object *ob, struct Ipo *ipo, short restore, short only_keys);
/* ------------- xxx macros ----------------------- */
#define BEZSELECTED(bezt) ((bezt->f2 & SELECT) || (bezt->f1 & SELECT) || (bezt->f3 & SELECT))

@ -127,6 +127,7 @@ struct wmWindowManager;
struct bScreen;
struct ScrArea;
struct bContext;
struct rctf;
typedef struct View2DGrid View2DGrid;
typedef struct View2DScrollers View2DScrollers;
@ -160,7 +161,8 @@ void UI_view2d_scrollers_draw(const struct bContext *C, struct View2D *v2d, View
void UI_view2d_scrollers_free(View2DScrollers *scrollers);
/* list view tools */
void UI_view2d_listview_get_cell(struct View2D *v2d, short columnwidth, short rowheight, float startx, float starty, float viewx, float viewy, int *column, int *row);
void UI_view2d_listview_cell_to_view(struct View2D *v2d, short columnwidth, short rowheight, float startx, float starty, int column, int row, struct rctf *rect);
void UI_view2d_listview_view_to_cell(struct View2D *v2d, short columnwidth, short rowheight, float startx, float starty, float viewx, float viewy, int *column, int *row);
void UI_view2d_listview_visible_cells(struct View2D *v2d, short columnwidth, short rowheight, float startx, float starty, int *column_min, int *column_max, int *row_min, int *row_max);
/* coordinate conversion */

@ -126,8 +126,8 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
/* zoom + aspect ratio are locked */
v2d->keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPZOOM|V2D_KEEPASPECT);
v2d->minzoom= v2d->maxzoom= 1.0f;
v2d->min[0]= v2d->max[0]= winx-1;
v2d->min[1]= v2d->max[1]= winy-1;
v2d->min[0]= v2d->max[0]= (float)(winx-1);
v2d->min[1]= v2d->max[1]= (float)(winy-1);
/* tot rect has strictly regulated placement, and must only occur in +/+ quadrant */
v2d->align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y);
@ -350,8 +350,8 @@ void UI_view2d_curRect_validate(View2D *v2d)
}
/* store region size for next time */
v2d->oldwinx= winx;
v2d->oldwiny= winy;
v2d->oldwinx= (short)winx;
v2d->oldwiny= (short)winy;
}
/* Step 2: apply new sizes to cur rect, but need to take into account alignment settings here... */
@ -816,40 +816,40 @@ struct View2DGrid {
/* try to write step as a power of 10 */
static void step_to_grid(float *step, int *power, int unit)
{
const float loga= log10(*step);
const float loga= (float)log10(*step);
float rem;
*power= (int)(loga);
rem= loga - (*power);
rem= pow(10.0, rem);
rem= (float)pow(10.0, rem);
if (loga < 0.0) {
if (rem < 0.2) rem= 0.2;
else if(rem < 0.5) rem= 0.5;
else rem= 1.0;
if (loga < 0.0f) {
if (rem < 0.2f) rem= 0.2f;
else if(rem < 0.5f) rem= 0.5f;
else rem= 1.0f;
*step= rem * pow(10.0, (float)(*power));
*step= rem * (float)pow(10.0, (*power));
/* for frames, we want 1.0 frame intervals only */
if (unit == V2D_UNIT_FRAMES) {
rem = 1.0;
*step = 1.0;
rem = 1.0f;
*step = 1.0f;
}
/* prevents printing 1.0 2.0 3.0 etc */
if (rem == 1.0) (*power)++;
if (rem == 1.0f) (*power)++;
}
else {
if (rem < 2.0) rem= 2.0;
else if(rem < 5.0) rem= 5.0;
else rem= 10.0;
if (rem < 2.0f) rem= 2.0f;
else if(rem < 5.0f) rem= 5.0f;
else rem= 10.0f;
*step= rem * pow(10.0, (float)(*power));
*step= rem * (float)pow(10.0, (*power));
(*power)++;
/* prevents printing 1.0, 2.0, 3.0, etc. */
if (rem == 10.0) (*power)++;
if (rem == 10.0f) (*power)++;
}
}
@ -882,7 +882,7 @@ View2DGrid *UI_view2d_grid_calc(const bContext *C, View2D *v2d, short xunits, sh
/* rule: gridstep is minimal GRIDSTEP pixels */
if (xunits == V2D_UNIT_SECONDS) {
secondgrid= 1;
seconddiv= 0.01f * FPS;
seconddiv= (float)(0.01 * FPS);
}
else {
secondgrid= 0;
@ -892,7 +892,7 @@ View2DGrid *UI_view2d_grid_calc(const bContext *C, View2D *v2d, short xunits, sh
/* calculate x-axis grid scale (only if both args are valid) */
if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) == 0) {
space= v2d->cur.xmax - v2d->cur.xmin;
pixels= v2d->mask.xmax - v2d->mask.xmin;
pixels= (float)(v2d->mask.xmax - v2d->mask.xmin);
grid->dx= (MINGRIDSTEP * space) / (seconddiv * pixels);
step_to_grid(&grid->dx, &grid->powerx, xunits);
@ -908,7 +908,7 @@ View2DGrid *UI_view2d_grid_calc(const bContext *C, View2D *v2d, short xunits, sh
/* calculate y-axis grid scale (only if both args are valid) */
if (ELEM(V2D_ARG_DUMMY, yunits, yclamp) == 0) {
space= v2d->cur.ymax - v2d->cur.ymin;
pixels= winy;
pixels= (float)winy;
grid->dy= MINGRIDSTEP * space / pixels;
step_to_grid(&grid->dy, &grid->powery, yunits);
@ -921,14 +921,14 @@ View2DGrid *UI_view2d_grid_calc(const bContext *C, View2D *v2d, short xunits, sh
/* calculate start position */
if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) == 0) {
grid->startx= seconddiv*(v2d->cur.xmin/seconddiv - fmod(v2d->cur.xmin/seconddiv, grid->dx/seconddiv));
grid->startx= seconddiv*(v2d->cur.xmin/seconddiv - (float)fmod(v2d->cur.xmin/seconddiv, grid->dx/seconddiv));
if (v2d->cur.xmin < 0.0f) grid->startx-= grid->dx;
}
else
grid->startx= v2d->cur.xmin;
if (ELEM(V2D_ARG_DUMMY, yunits, yclamp) == 0) {
grid->starty= (v2d->cur.ymin - fmod(v2d->cur.ymin, grid->dy));
grid->starty= (v2d->cur.ymin - (float)fmod(v2d->cur.ymin, grid->dy));
if (v2d->cur.ymin < 0.0f) grid->starty-= grid->dy;
}
else
@ -1053,7 +1053,7 @@ void UI_view2d_constant_grid_draw(const bContext *C, View2D *v2d)
UI_ThemeColorShade(TH_BACK, -10);
start= v2d->cur.xmin -fmod(v2d->cur.xmin, step);
start= v2d->cur.xmin - (float)fmod(v2d->cur.xmin, step);
glBegin(GL_LINES);
for(; start<v2d->cur.xmax; start+=step) {
@ -1061,7 +1061,7 @@ void UI_view2d_constant_grid_draw(const bContext *C, View2D *v2d)
glVertex2f(start, v2d->cur.ymax);
}
start= v2d->cur.ymin -fmod(v2d->cur.ymin, step);
start= v2d->cur.ymin - (float)fmod(v2d->cur.ymin, step);
for(; start<v2d->cur.ymax; start+=step) {
glVertex2f(v2d->cur.xmin, start);
glVertex2f(v2d->cur.xmax, start);
@ -1125,13 +1125,13 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
if (v2d->scroll & V2D_SCROLL_HORIZONTAL) {
/* scroller 'button' extents */
totsize= v2d->tot.xmax - v2d->tot.xmin;
scrollsize= hor.xmax - hor.xmin;
scrollsize= (float)(hor.xmax - hor.xmin);
fac= (v2d->cur.xmin- v2d->tot.xmin) / totsize;
scrollers->hor_min= hor.xmin + (fac * scrollsize);
fac= (v2d->cur.xmin - v2d->tot.xmin) / totsize;
scrollers->hor_min= (int)(hor.xmin + (fac * scrollsize));
fac= (v2d->cur.xmax - v2d->tot.xmin) / totsize;
scrollers->hor_max= hor.xmin + (fac * scrollsize);
scrollers->hor_max= (int)(hor.xmin + (fac * scrollsize));
if (scrollers->hor_min > scrollers->hor_max)
scrollers->hor_min= scrollers->hor_max;
@ -1141,13 +1141,13 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
if (v2d->scroll & V2D_SCROLL_VERTICAL) {
/* scroller 'button' extents */
totsize= v2d->tot.ymax - v2d->tot.ymin;
scrollsize= vert.ymax - vert.ymin;
scrollsize= (float)(vert.ymax - vert.ymin);
fac= (v2d->cur.ymin- v2d->tot.ymin) / totsize;
scrollers->vert_min= vert.ymin + (fac * scrollsize);
scrollers->vert_min= (int)(vert.ymin + (fac * scrollsize));
fac= (v2d->cur.ymax - v2d->tot.ymin) / totsize;
scrollers->vert_max= vert.ymin + (fac * scrollsize);
scrollers->vert_max= (int)(vert.ymin + (fac * scrollsize));
if (scrollers->vert_min > scrollers->vert_max)
scrollers->vert_min= scrollers->vert_max;
@ -1211,12 +1211,12 @@ static void scroll_printstr(View2DScrollers *scrollers, Scene *scene, float x, f
* go against conventions...
*/
hours= (int)val / 3600;
val= fmod(val, 3600);
val= (float)fmod(val, 3600);
}
if (val >= 60) {
/* minutes */
minutes= (int)val / 60;
val= fmod(val, 60);
val= (float)fmod(val, 60);
}
if (power <= 0) {
/* seconds + frames
@ -1313,15 +1313,15 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
float mid= 0.5f * (vs->hor_max + vs->hor_min);
gl_round_box_shade(GL_POLYGON,
mid-V2D_SCROLLCAP_RAD, hor.ymin+2,
mid+V2D_SCROLLCAP_RAD, hor.ymax-2,
mid-V2D_SCROLLCAP_RAD, (float)hor.ymin+2,
mid+V2D_SCROLLCAP_RAD, (float)hor.ymax-2,
V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE);
}
else {
/* draw rounded box as per normal */
gl_round_box_shade(GL_POLYGON,
vs->hor_min, hor.ymin+2,
vs->hor_max, hor.ymax-2,
(float)vs->hor_min, (float)hor.ymin+2,
(float)vs->hor_max, (float)hor.ymax-2,
V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE);
}
}
@ -1330,8 +1330,8 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
UI_ThemeColorShade(TH_SHADE1, dark);
uiSetRoundBox(0);
gl_round_box_shade(GL_POLYGON,
vs->hor_min, hor.ymin+2,
vs->hor_max, hor.ymax-2,
(float)vs->hor_min, (float)hor.ymin+2,
(float)vs->hor_max, (float)hor.ymax-2,
V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE);
/* 'minimum' handle */
@ -1339,8 +1339,8 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
UI_ThemeColorShade(TH_SHADE1, darker);
gl_round_box_shade(GL_POLYGON,
vs->hor_min-V2D_SCROLLER_HANDLE_SIZE, hor.ymin+2,
vs->hor_min+V2D_SCROLLER_HANDLE_SIZE, hor.ymax-2,
(float)vs->hor_min-V2D_SCROLLER_HANDLE_SIZE, (float)hor.ymin+2,
(float)vs->hor_min+V2D_SCROLLER_HANDLE_SIZE, (float)hor.ymax-2,
V2D_SCROLLCAP_RAD, V2D_SCROLLCAP_SHADE, -V2D_SCROLLCAP_SHADE);
/* maximum handle */
@ -1348,8 +1348,8 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
UI_ThemeColorShade(TH_SHADE1, darker);
gl_round_box_shade(GL_POLYGON,
vs->hor_max-V2D_SCROLLER_HANDLE_SIZE, hor.ymin+2,
vs->hor_max+V2D_SCROLLER_HANDLE_SIZE, hor.ymax-2,
(float)vs->hor_max-V2D_SCROLLER_HANDLE_SIZE, (float)hor.ymin+2,
(float)vs->hor_max+V2D_SCROLLER_HANDLE_SIZE, (float)hor.ymax-2,
V2D_SCROLLCAP_RAD, V2D_SCROLLCAP_SHADE, -V2D_SCROLLCAP_SHADE);
}
@ -1364,7 +1364,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
* - dfac is gap between scale markings
*/
fac= (grid->startx - v2d->cur.xmin) / (v2d->cur.xmax - v2d->cur.xmin);
fac= hor.xmin + fac*(hor.xmax - hor.xmin);
fac= (float)hor.xmin + fac*(hor.xmax - hor.xmin);
dfac= (grid->dx) / (v2d->cur.xmax - v2d->cur.xmin);
dfac= dfac * (hor.xmax - hor.xmin);
@ -1388,29 +1388,29 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
for (; fac < hor.xmax; fac+=dfac, val+=grid->dx) {
switch (vs->xunits) {
case V2D_UNIT_FRAMES: /* frames (as whole numbers)*/
scroll_printstr(vs, scene, fac, 3.0+(float)(hor.ymin), val, grid->powerx, V2D_UNIT_FRAMES, 'h');
scroll_printstr(vs, scene, fac, 3.0f+(float)(hor.ymin), val, grid->powerx, V2D_UNIT_FRAMES, 'h');
break;
case V2D_UNIT_SECONDS: /* seconds */
fac2= val/FPS;
scroll_printstr(vs, scene, fac, 3.0+(float)(hor.ymin), fac2, grid->powerx, V2D_UNIT_SECONDS, 'h');
fac2= val/(float)FPS;
scroll_printstr(vs, scene, fac, 3.0f+(float)(hor.ymin), fac2, grid->powerx, V2D_UNIT_SECONDS, 'h');
break;
case V2D_UNIT_SECONDSSEQ: /* seconds with special calculations (only used for sequencer only) */
{
float time;
fac2= val/FPS;
time= floor(fac2);
fac2= val/(float)FPS;
time= (float)floor(fac2);
fac2= fac2-time;
scroll_printstr(vs, scene, fac, 3.0+(float)(hor.ymin), time+FPS*fac2/100.0, grid->powerx, V2D_UNIT_SECONDSSEQ, 'h');
scroll_printstr(vs, scene, fac, 3.0f+(float)(hor.ymin), time+(float)FPS*fac2/100.0f, grid->powerx, V2D_UNIT_SECONDSSEQ, 'h');
}
break;
case V2D_UNIT_DEGREES: /* IPO-Editor for rotation IPO-Drivers */
/* HACK: although we're drawing horizontal, we make this draw as 'vertical', just to get degree signs */
scroll_printstr(vs, scene, fac, 3.0+(float)(hor.ymin), val, grid->powerx, V2D_UNIT_DEGREES, 'v');
scroll_printstr(vs, scene, fac, 3.0f+(float)(hor.ymin), val, grid->powerx, V2D_UNIT_DEGREES, 'v');
break;
}
}
@ -1448,15 +1448,15 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
float mid= 0.5f * (vs->vert_max + vs->vert_min);
gl_round_box_vertical_shade(GL_POLYGON,
vert.xmin+2, mid-V2D_SCROLLCAP_RAD,
vert.xmax-2, mid+V2D_SCROLLCAP_RAD,
(float)vert.xmin+2, mid-V2D_SCROLLCAP_RAD,
(float)vert.xmax-2, mid+V2D_SCROLLCAP_RAD,
V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE);
}
else {
/* draw rounded box as per normal */
gl_round_box_vertical_shade(GL_POLYGON,
vert.xmin+2, vs->vert_min,
vert.xmax-2, vs->vert_max,
(float)vert.xmin+2, (float)vs->vert_min,
(float)vert.xmax-2, (float)vs->vert_max,
V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE);
}
}
@ -1465,8 +1465,8 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
UI_ThemeColorShade(TH_SHADE1, dark);
uiSetRoundBox(0);
gl_round_box_vertical_shade(GL_POLYGON,
vert.xmin+2, vs->vert_min,
vert.xmax-2, vs->vert_max,
(float)vert.xmin+2, (float)vs->vert_min,
(float)vert.xmax-2, (float)vs->vert_max,
V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE);
/* 'minimum' handle */
@ -1474,8 +1474,8 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
uiSetRoundBox(12);
gl_round_box_vertical_shade(GL_POLYGON,
vert.xmin+2, vs->vert_min-V2D_SCROLLER_HANDLE_SIZE,
vert.xmax-2, vs->vert_min+V2D_SCROLLER_HANDLE_SIZE,
(float)vert.xmin+2, (float)vs->vert_min-V2D_SCROLLER_HANDLE_SIZE,
(float)vert.xmax-2, (float)vs->vert_min+V2D_SCROLLER_HANDLE_SIZE,
V2D_SCROLLCAP_RAD, V2D_SCROLLCAP_SHADE, -V2D_SCROLLCAP_SHADE);
/* maximum handle */
@ -1483,8 +1483,8 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
uiSetRoundBox(3);
gl_round_box_vertical_shade(GL_POLYGON,
vert.xmin+2, vs->vert_max-V2D_SCROLLER_HANDLE_SIZE,
vert.xmax-2, vs->vert_max+V2D_SCROLLER_HANDLE_SIZE,
(float)vert.xmin+2, (float)vs->vert_max-V2D_SCROLLER_HANDLE_SIZE,
(float)vert.xmax-2, (float)vs->vert_max+V2D_SCROLLER_HANDLE_SIZE,
V2D_SCROLLCAP_RAD, V2D_SCROLLCAP_SHADE, -V2D_SCROLLCAP_SHADE);
}
@ -1517,7 +1517,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
/* draw vertical steps */
for (; fac < vert.ymax; fac+= dfac, val += grid->dy) {
scroll_printstr(vs, scene, (float)(vert.xmax)-14.0, fac, val, grid->powery, vs->yunits, 'v');
scroll_printstr(vs, scene, (float)(vert.xmax)-14.0f, fac, val, grid->powery, vs->yunits, 'v');
}
}
@ -1564,6 +1564,47 @@ void UI_view2d_scrollers_free(View2DScrollers *scrollers)
/* *********************************************************************** */
/* List View Utilities */
/* Get the view-coordinates of the nominated cell
* - columnwidth, rowheight = size of each 'cell'
* - startx, starty = coordinates (in 'tot' rect space) that the list starts from
* This should be (0,0) for most views. However, for those where the starting row was offsetted
* (like for Animation Editor channel lists, to make the first entry more visible), these will be
* the min-coordinates of the first item.
* - column, row = the 2d-corodinates (in 2D-view / 'tot' rect space) the cell exists at
* - rect = coordinates of the cell (passed as single var instead of 4 separate, as it's more useful this way)
*/
void UI_view2d_listview_cell_to_view(View2D *v2d, short columnwidth, short rowheight, float startx, float starty, int column, int row, rctf *rect)
{
/* sanity checks */
if ELEM(NULL, v2d, rect)
return;
if ((columnwidth <= 0) && (rowheight <= 0)) {
rect->xmin= rect->xmax= 0.0f;
rect->ymin= rect->ymax= 0.0f;
return;
}
/* x-coordinates */
rect->xmin= startx + (float)(columnwidth * column);
rect->xmax= startx + (float)(columnwidth * (column + 1));
if ((v2d->align & V2D_ALIGN_NO_POS_X) && !(v2d->align & V2D_ALIGN_NO_NEG_X)) {
/* simply negate the values for the coordinates if in negative half */
rect->xmin = -rect->xmin;
rect->xmax = -rect->xmax;
}
/* y-coordinates */
rect->ymin= starty + (float)(rowheight * row);
rect->ymax= starty + (float)(rowheight * (row + 1));
if ((v2d->align & V2D_ALIGN_NO_POS_Y) && !(v2d->align & V2D_ALIGN_NO_NEG_Y)) {
/* simply negate the values for the coordinates if in negative half */
rect->ymin = -rect->ymin;
rect->ymax = -rect->ymax;
}
}
/* Get the 'cell' (row, column) that the given 2D-view coordinates (i.e. in 'tot' rect space) lie in.
* - columnwidth, rowheight = size of each 'cell'
* - startx, starty = coordinates (in 'tot' rect space) that the list starts from
@ -1573,7 +1614,7 @@ void UI_view2d_scrollers_free(View2DScrollers *scrollers)
* - viewx, viewy = 2D-coordinates (in 2D-view / 'tot' rect space) to get the cell for
* - column, row = the 'coordinates' of the relevant 'cell'
*/
void UI_view2d_listview_get_cell(View2D *v2d, short columnwidth, short rowheight, float startx, float starty,
void UI_view2d_listview_view_to_cell(View2D *v2d, short columnwidth, short rowheight, float startx, float starty,
float viewx, float viewy, int *column, int *row)
{
/* adjust view coordinates to be all positive ints, corrected for the start offset */
@ -1589,28 +1630,16 @@ void UI_view2d_listview_get_cell(View2D *v2d, short columnwidth, short rowheight
}
/* get column */
if ((column) && (columnwidth > 0)) {
if (x > 0)
*column= x / columnwidth;
else
*column= 0;
}
else if (column) {
/* we want the column, but column width is undefined */
if ((column) && (columnwidth > 0))
*column= x / columnwidth;
else if (column)
*column= 0;
}
/* get row */
if ((row) && (rowheight > 0)) {
if (y > 0)
*row= y / rowheight;
else
*row= 0;
}
else if (row) {
/* we want the row, but row height is undefined */
if ((row) && (rowheight > 0))
*row= y / rowheight;
else if (row)
*row= 0;
}
}
/* Get the 'extreme' (min/max) column and row indices which are visible within the 'cur' rect
@ -1624,11 +1653,11 @@ void UI_view2d_listview_visible_cells(View2D *v2d, short columnwidth, short rowh
/* using 'cur' rect coordinates, call the cell-getting function to get the cells for this */
if (v2d) {
/* min */
UI_view2d_listview_get_cell(v2d, columnwidth, rowheight, startx, starty,
UI_view2d_listview_view_to_cell(v2d, columnwidth, rowheight, startx, starty,
v2d->cur.xmin, v2d->cur.ymin, column_min, row_min);
/* max*/
UI_view2d_listview_get_cell(v2d, columnwidth, rowheight, startx, starty,
UI_view2d_listview_view_to_cell(v2d, columnwidth, rowheight, startx, starty,
v2d->cur.xmax, v2d->cur.ymax, column_max, row_max);
}
}
@ -1646,15 +1675,15 @@ void UI_view2d_region_to_view(View2D *v2d, int x, int y, float *viewx, float *vi
float div, ofs;
if (viewx) {
div= v2d->mask.xmax - v2d->mask.xmin;
ofs= v2d->mask.xmin;
div= (float)(v2d->mask.xmax - v2d->mask.xmin);
ofs= (float)v2d->mask.xmin;
*viewx= v2d->cur.xmin + (v2d->cur.xmax-v2d->cur.xmin) * ((float)x - ofs) / div;
}
if (viewy) {
div= v2d->mask.ymax - v2d->mask.ymin;
ofs= v2d->mask.ymin;
div= (float)(v2d->mask.ymax - v2d->mask.ymin);
ofs= (float)v2d->mask.ymin;
*viewy= v2d->cur.ymin + (v2d->cur.ymax - v2d->cur.ymin) * ((float)y - ofs) / div;
}
@ -1681,9 +1710,9 @@ void UI_view2d_view_to_region(View2D *v2d, float x, float y, short *regionx, sho
/* check if values are within bounds */
if ((x>=0.0f) && (x<=1.0f) && (y>=0.0f) && (y<=1.0f)) {
if (regionx)
*regionx= v2d->mask.xmin + x*(v2d->mask.xmax-v2d->mask.xmin);
*regionx= (short)(v2d->mask.xmin + x*(v2d->mask.xmax-v2d->mask.xmin));
if (regiony)
*regiony= v2d->mask.ymin + y*(v2d->mask.ymax-v2d->mask.ymin);
*regiony= (short)(v2d->mask.ymin + y*(v2d->mask.ymax-v2d->mask.ymin));
}
}
@ -1707,12 +1736,12 @@ void UI_view2d_to_region_no_clip(View2D *v2d, float x, float y, short *regionx,
if (regionx) {
if (x < -32760) *regionx= -32760;
else if(x > 32760) *regionx= 32760;
else *regionx= x;
else *regionx= (short)x;
}
if (regiony) {
if (y < -32760) *regiony= -32760;
else if(y > 32760) *regiony= 32760;
else *regiony= y;
else *regiony= (short)y;
}
}

@ -723,12 +723,12 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event)
/* x-axis transform */
dist = (v2d->mask.xmax - v2d->mask.xmin) / 2.0f;
dx= 1.0f - (fabs(vzd->lastx - dist) + 2.0f) / (fabs(event->x - dist) + 2.0f);
dx= 1.0f - ((float)fabs(vzd->lastx - dist) + 2.0f) / ((float)fabs(event->x - dist) + 2.0f);
dx*= 0.5f * (v2d->cur.xmax - v2d->cur.xmin);
/* y-axis transform */
dist = (v2d->mask.ymax - v2d->mask.ymin) / 2.0f;
dy= 1.0f - (fabs(vzd->lasty - dist) + 2.0) / (fabs(event->y - dist) + 2.0f);
dy= 1.0f - ((float)fabs(vzd->lasty - dist) + 2.0) / ((float)fabs(event->y - dist) + 2.0f);
dy*= 0.5f * (v2d->cur.ymax - v2d->cur.ymin);
}
else {

@ -131,7 +131,6 @@ static void action_keymap_keyframes (wmWindowManager *wm, ListBase *keymap)
WM_keymap_add_item(keymap, "ACT_OT_keyframes_delete", DELKEY, KM_PRESS, 0, 0);
/* copy/paste */
// XXX - should we keep these?
WM_keymap_add_item(keymap, "ACT_OT_keyframes_copy", CKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "ACT_OT_keyframes_paste", VKEY, KM_PRESS, KM_CTRL, 0);

@ -17,10 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* The Original Code is: all of this file.
* The Original Code is Copyright (C) 2008 Blender Foundation
*
* Contributor(s): Joshua Leung
*
@ -241,9 +238,6 @@ static void *get_nearest_action_key (bAnimContext *ac, int mval[2], float *selx,
return NULL;
}
/* ************************************************************************** */
/* CHANNEL STUFF */
/* ************************************************************************** */
/* KEYFRAMES STUFF */

@ -373,7 +373,7 @@ void ED_spacetype_action(void)
art->init= action_channel_area_init;
art->draw= action_channel_area_draw;
art->listener= action_main_area_listener;
art->listener= action_channel_area_listener;
BLI_addhead(&st->regiontypes, art);