2.5 - Animation Editors - common drawing stuff
* Fixed current frame number drawing in Animation Editors, so that the little frame number indicator box gets shown (animsys2 feature). * Made all Animation Editors draw markers and preview range
This commit is contained in:
@@ -5078,7 +5078,7 @@ static void area_add_header_region(ScrArea *sa, ListBase *lb)
|
||||
ar->v2d.keepofs = V2D_LOCKOFS_Y;
|
||||
ar->v2d.keeptot = V2D_KEEPTOT_STRICT;
|
||||
ar->v2d.align = V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y;
|
||||
|
||||
ar->v2d.flag = (V2D_PIXELOFS_X|V2D_PIXELOFS_Y);
|
||||
}
|
||||
|
||||
/* 2.50 patch */
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_object.h"
|
||||
#include "BKE_screen.h"
|
||||
#include "BKE_utildefines.h"
|
||||
|
||||
@@ -58,17 +59,21 @@
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
#include "UI_text.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
/* XXX */
|
||||
extern void ui_rasterpos_safe(float x, float y, float aspect);
|
||||
|
||||
/* *************************************************** */
|
||||
/* CURRENT FRAME DRAWING */
|
||||
|
||||
/* Draw current frame number in a little green box beside the current frame indicator */
|
||||
static void draw_cfra_number (View2D *v2d, float cfra, short time)
|
||||
{
|
||||
float xscale, yscale, yspace, ypixels, x;
|
||||
short slen;
|
||||
float xscale, yscale, x, y;
|
||||
char str[32];
|
||||
short slen;
|
||||
|
||||
/* because the frame number text is subject to the same scaling as the contents of the view */
|
||||
UI_view2d_getscale(v2d, &xscale, &yscale);
|
||||
@@ -78,23 +83,23 @@ static void draw_cfra_number (View2D *v2d, float cfra, short time)
|
||||
sprintf(str, " %.2f", FRA2TIME(CFRA));
|
||||
else
|
||||
sprintf(str, " %d", CFRA);
|
||||
slen= UI_GetStringWidth(G.font, str, 0);
|
||||
slen= UI_GetStringWidth(G.font, str, 0) - 1;
|
||||
|
||||
/* get starting coordinates for drawing */
|
||||
x= cfra * xscale;
|
||||
y= 18;
|
||||
|
||||
/* draw green box around/behind text */
|
||||
UI_ThemeColor(TH_CFRAME);
|
||||
UI_ThemeColorShadeAlpha(TH_CFRAME, 0, -100);
|
||||
glRectf(x, 0, x+slen, 15);
|
||||
glRectf(x, y, x+slen, y+15);
|
||||
|
||||
/* draw current frame number - black text */
|
||||
UI_ThemeColor(TH_TEXT);
|
||||
ui_rasterpos_safe(x-5, 17, 1.0);
|
||||
UI_DrawString(G.fonts, str, 0);
|
||||
ui_rasterpos_safe(x-5, y+3, 1.0);
|
||||
UI_DrawString(G.fonts, str, 0); // XXX may need to be updated for font stuff
|
||||
|
||||
/* restore view transform */
|
||||
glScalef(xscale, yscale, 1.0);
|
||||
glScalef(xscale, 1.0, 1.0);
|
||||
}
|
||||
|
||||
/* General call for drawing current frame indicator in a */
|
||||
|
||||
@@ -170,10 +170,17 @@ static void *actedit_get_context (const bContext *C, SpaceAction *saction, short
|
||||
|
||||
/* ----------- Private Stuff - IPO Editor ------------- */
|
||||
|
||||
/* Get data being edited in IPO Editor (depending on current 'mode') */
|
||||
static void *ipoedit_get_context (const bContext *C, SpaceIpo *sipo, short *datatype)
|
||||
{
|
||||
// XXX FIXME...
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* ----------- Public API --------------- */
|
||||
|
||||
/* Obtain current anim-data context from Blender Context info */
|
||||
void *animdata_get_context (const bContext *C, short *datatype)
|
||||
void *ANIM_animdata_get_context (const bContext *C, short *datatype)
|
||||
{
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
|
||||
@@ -194,7 +201,7 @@ void *animdata_get_context (const bContext *C, short *datatype)
|
||||
case SPACE_IPO:
|
||||
{
|
||||
SpaceIpo *sipo= (SpaceIpo *)CTX_wm_space_data(C);
|
||||
// ...
|
||||
return ipoedit_get_context(C, sipo, datatype);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -204,5 +211,57 @@ void *animdata_get_context (const bContext *C, short *datatype)
|
||||
}
|
||||
|
||||
/* ************************************************************ */
|
||||
/* Blender Data <-- Filter --> Channels to be operated on */
|
||||
|
||||
/* ----------- 'Private' Stuff --------------- */
|
||||
|
||||
|
||||
/* ----------- Public API --------------- */
|
||||
|
||||
/* This function filters the active data source to leave only the desired
|
||||
* data types. 'Public' api call.
|
||||
* *act_data: is a pointer to a ListBase, to which the filtered animation channels
|
||||
* will be placed for use.
|
||||
* filter_mode: how should the data be filtered - bitmapping accessed flags
|
||||
*/
|
||||
void ANIM_animdata_filter (ListBase *anim_data, int filter_mode, void *data, short datatype)
|
||||
{
|
||||
/* only filter data if there's somewhere to put it */
|
||||
if (data && anim_data) {
|
||||
bAnimListElem *ale, *next;
|
||||
|
||||
/* firstly filter the data */
|
||||
switch (datatype) {
|
||||
case ANIMCONT_ACTION:
|
||||
//animdata_filter_action(anim_data, data, filter_mode, NULL, ANIMTYPE_NONE);
|
||||
break;
|
||||
case ANIMCONT_SHAPEKEY:
|
||||
//animdata_filter_shapekey(anim_data, data, filter_mode, NULL, ANIMTYPE_NONE);
|
||||
break;
|
||||
case ANIMCONT_GPENCIL:
|
||||
//animdata_filter_gpencil(anim_data, data, filter_mode);
|
||||
break;
|
||||
case ANIMCONT_DOPESHEET:
|
||||
//animdata_filter_dopesheet(anim_data, data, filter_mode);
|
||||
break;
|
||||
}
|
||||
|
||||
/* remove any weedy entries */
|
||||
// XXX this is weedy code!
|
||||
for (ale= anim_data->first; ale; ale= next) {
|
||||
next= ale->next;
|
||||
|
||||
if (ale->type == ANIMTYPE_NONE)
|
||||
BLI_freelinkN(anim_data, ale);
|
||||
|
||||
if (filter_mode & ALEFILTER_IPOKEYS) {
|
||||
if (ale->datatype != ALE_IPO)
|
||||
BLI_freelinkN(anim_data, ale);
|
||||
else if (ale->key_data == NULL)
|
||||
BLI_freelinkN(anim_data, ale);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ************************************************************ */
|
||||
|
||||
@@ -95,8 +95,8 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag)
|
||||
int icon_id= 0;
|
||||
|
||||
xpos = marker->frame;
|
||||
/* no time correction for framelen! space is drawn with old values */
|
||||
|
||||
/* no time correction for framelen! space is drawn with old values */
|
||||
ypixels= v2d->mask.ymax-v2d->mask.ymin;
|
||||
UI_view2d_getscale(v2d, &xscale, &yscale);
|
||||
|
||||
@@ -105,18 +105,20 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag)
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
/* vertical line */
|
||||
/* vertical line - dotted */
|
||||
if (flag & DRAW_MARKERS_LINES) {
|
||||
setlinestyle(3);
|
||||
if(marker->flag & SELECT)
|
||||
glColor4ub(255,255,255, 96);
|
||||
|
||||
if (marker->flag & SELECT)
|
||||
glColor4ub(255, 255, 255, 96);
|
||||
else
|
||||
glColor4ub(0,0,0, 96);
|
||||
glColor4ub(0, 0, 0, 96);
|
||||
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f((xpos*xscale)+0.5, 12);
|
||||
glVertex2f((xpos*xscale)+0.5, 34*yscale); /* a bit lazy but we know it cant be greater then 34 strips high*/
|
||||
glVertex2f((xpos*xscale)+0.5, 12);
|
||||
glVertex2f((xpos*xscale)+0.5, 34*yscale); /* a bit lazy but we know it cant be greater then 34 strips high*/
|
||||
glEnd();
|
||||
|
||||
setlinestyle(0);
|
||||
}
|
||||
|
||||
@@ -137,7 +139,7 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag)
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
/* and the marker name too, shifted slightly to the top-right */
|
||||
if(marker->name && marker->name[0]) {
|
||||
if (marker->name && marker->name[0]) {
|
||||
if(marker->flag & SELECT) {
|
||||
UI_ThemeColor(TH_TEXT_HI);
|
||||
ui_rasterpos_safe(xpos*xscale+4.0, (ypixels<=39.0)?(ypixels-10.0):29.0, 1.0);
|
||||
|
||||
@@ -63,6 +63,7 @@ typedef struct bAnimListElem {
|
||||
|
||||
|
||||
/* Some types for easier type-testing */
|
||||
// XXX was ACTTYPE_*
|
||||
typedef enum eAnim_ChannelType {
|
||||
ANIMTYPE_NONE= 0,
|
||||
ANIMTYPE_SPECIALDATA,
|
||||
@@ -109,6 +110,7 @@ typedef enum eAnim_KeyType {
|
||||
} eAnim_KeyType;
|
||||
|
||||
/* Main Data container types */
|
||||
// XXX was ACTCONT_*
|
||||
typedef enum eAnimCont_Types {
|
||||
ANIMCONT_NONE = 0, /* invalid or no data */
|
||||
ANIMCONT_ACTION, /* action (bAction) */
|
||||
@@ -118,6 +120,7 @@ typedef enum eAnimCont_Types {
|
||||
} eAnimCont_Types;
|
||||
|
||||
/* filtering flags - under what circumstances should a channel be added */
|
||||
// XXX was ACTFILTER_*
|
||||
typedef enum eAnimFilter_Flags {
|
||||
ALEFILTER_VISIBLE = (1<<0), /* should channels be visible */
|
||||
ALEFILTER_SEL = (1<<1), /* should channels be selected */
|
||||
@@ -133,10 +136,10 @@ typedef enum eAnimFilter_Flags {
|
||||
/* ---------------- API -------------------- */
|
||||
|
||||
/* Obtain list of filtered Animation channels to operate on */
|
||||
void animdata_filter(struct ListBase *act_data, int filter_mode, void *data, short datatype);
|
||||
void ANIM_animdata_filter(struct ListBase *anim_data, int filter_mode, void *data, short datatype);
|
||||
|
||||
/* Obtain current anim-data context from Blender Context info */
|
||||
void *animdata_get_context(const struct bContext *C, short *datatype);
|
||||
void *ANIM_animdata_get_context(const struct bContext *C, short *datatype);
|
||||
|
||||
/* ************************************************ */
|
||||
/* DRAWING API */
|
||||
|
||||
@@ -97,9 +97,9 @@ static SpaceLink *action_new(void)
|
||||
BLI_addtail(&saction->regionbase, ar);
|
||||
ar->regiontype= RGN_TYPE_WINDOW;
|
||||
|
||||
ar->v2d.tot.xmin= -5.0f;
|
||||
ar->v2d.tot.xmin= -2.0f;
|
||||
ar->v2d.tot.ymin= -2000.0f;
|
||||
ar->v2d.tot.xmax= 1000.0f; // xxx - use end frame instead?
|
||||
ar->v2d.tot.xmax= 100.0f;
|
||||
ar->v2d.tot.ymax= 0.0f;
|
||||
|
||||
ar->v2d.cur.xmin= -2.0f;
|
||||
@@ -190,7 +190,12 @@ static void action_main_area_draw(const bContext *C, ARegion *ar)
|
||||
if ((saction->flag & SACTION_NODRAWCFRANUM)==0) flag |= DRAWCFRA_SHOW_NUMBOX;
|
||||
ANIM_draw_cfra(C, v2d, flag);
|
||||
|
||||
/* markers */
|
||||
UI_view2d_view_orthoSpecial(C, v2d, 1);
|
||||
draw_markers_time(C, 0);
|
||||
|
||||
/* preview range */
|
||||
UI_view2d_view_ortho(C, v2d);
|
||||
ANIM_draw_previewrange(C, v2d);
|
||||
|
||||
/* reset view matrix */
|
||||
|
||||
@@ -46,6 +46,8 @@
|
||||
|
||||
#include "ED_space_api.h"
|
||||
#include "ED_screen.h"
|
||||
#include "ED_anim_api.h"
|
||||
#include "ED_markers.h"
|
||||
|
||||
#include "BIF_gl.h"
|
||||
|
||||
@@ -56,8 +58,6 @@
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "ED_markers.h"
|
||||
|
||||
#include "ipo_intern.h" // own include
|
||||
|
||||
/* ******************** default callbacks for ipo space ***************** */
|
||||
@@ -147,50 +147,6 @@ static SpaceLink *ipo_duplicate(SpaceLink *sl)
|
||||
return (SpaceLink *)sipon;
|
||||
}
|
||||
|
||||
|
||||
// XXX this should be defined in some general lib for anim editors...
|
||||
static void draw_cfra(const bContext *C, SpaceIpo *sipo, View2D *v2d)
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
float vec[2];
|
||||
|
||||
//vec[0] = get_ipo_cfra_from_cfra(sipo, scene->r.cfra);
|
||||
vec[0] = scene->r.cfra;
|
||||
vec[0]*= scene->r.framelen;
|
||||
|
||||
vec[1]= v2d->cur.ymin;
|
||||
UI_ThemeColor(TH_CFRAME);
|
||||
glLineWidth(2.0);
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex2fv(vec);
|
||||
vec[1]= v2d->cur.ymax;
|
||||
glVertex2fv(vec);
|
||||
glEnd();
|
||||
|
||||
#if 0
|
||||
if(sipo->blocktype==ID_OB) {
|
||||
ob= (scene->basact) ? (scene->basact->object) : 0;
|
||||
if (ob && (ob->ipoflag & OB_OFFS_OB) && (give_timeoffset(ob)!=0.0)) {
|
||||
vec[0]-= give_timeoffset(ob);
|
||||
|
||||
UI_ThemeColorShade(TH_HILITE, -30);
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex2fv(vec);
|
||||
vec[1]= G.v2d->cur.ymin;
|
||||
glVertex2fv(vec);
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
glLineWidth(1.0);
|
||||
|
||||
/* Draw current frame number in a little box */
|
||||
//draw_cfra_number(vec[0]);
|
||||
}
|
||||
|
||||
/* add handlers, stuff you only do once or on area/region changes */
|
||||
static void ipo_main_area_init(wmWindowManager *wm, ARegion *ar)
|
||||
{
|
||||
@@ -211,7 +167,7 @@ static void ipo_main_area_draw(const bContext *C, ARegion *ar)
|
||||
View2DGrid *grid;
|
||||
View2DScrollers *scrollers;
|
||||
float col[3];
|
||||
int unit;
|
||||
short unit=0, flag=0;
|
||||
|
||||
/* clear and setup matrix */
|
||||
UI_GetThemeColor3fv(TH_BACK, col);
|
||||
@@ -229,12 +185,18 @@ static void ipo_main_area_draw(const bContext *C, ARegion *ar)
|
||||
/* data... */
|
||||
|
||||
/* current frame */
|
||||
draw_cfra(C, sipo, v2d);
|
||||
if (sipo->flag & SIPO_DRAWTIME) flag |= DRAWCFRA_UNIT_SECONDS;
|
||||
if ((sipo->flag & SIPO_NODRAWCFRANUM)==0) flag |= DRAWCFRA_SHOW_NUMBOX;
|
||||
ANIM_draw_cfra(C, v2d, flag);
|
||||
|
||||
/* markers */
|
||||
UI_view2d_view_orthoSpecial(C, v2d, 1);
|
||||
draw_markers_time(C, 0);
|
||||
|
||||
/* preview range */
|
||||
UI_view2d_view_ortho(C, v2d);
|
||||
ANIM_draw_previewrange(C, v2d);
|
||||
|
||||
/* reset view matrix */
|
||||
UI_view2d_view_restore(C);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user