diff options
Diffstat (limited to 'source/blender/editors/animation/keyframes_draw.c')
-rw-r--r-- | source/blender/editors/animation/keyframes_draw.c | 133 |
1 files changed, 98 insertions, 35 deletions
diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index 02e141a7a69..c1958064431 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -39,6 +39,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_dlrbTree.h" +#include "BLI_utildefines.h" #include "DNA_anim_types.h" #include "DNA_armature_types.h" @@ -47,6 +48,7 @@ #include "DNA_scene_types.h" #include "DNA_key_types.h" #include "DNA_lamp_types.h" +#include "DNA_lattice_types.h" #include "DNA_mesh_types.h" #include "DNA_material_types.h" #include "DNA_meta_types.h" @@ -58,7 +60,7 @@ #include "BKE_key.h" #include "BKE_material.h" #include "BKE_global.h" // XXX remove me! -#include "BKE_utildefines.h" + #include "BIF_gl.h" @@ -135,6 +137,49 @@ static void nupdate_ak_bezt (void *node, void *data) ak->key_type= BEZT_KEYTYPE_KEYFRAME; } +/* ......... */ + +/* Comparator callback used for ActKeyColumns and GPencil frame */ +static short compare_ak_gpframe (void *node, void *data) +{ + ActKeyColumn *ak= (ActKeyColumn *)node; + bGPDframe *gpf= (bGPDframe *)data; + + if (gpf->framenum < ak->cfra) + return -1; + else if (gpf->framenum > ak->cfra) + return 1; + else + return 0; +} + +/* New node callback used for building ActKeyColumns from GPencil frames */ +static DLRBT_Node *nalloc_ak_gpframe (void *data) +{ + ActKeyColumn *ak= MEM_callocN(sizeof(ActKeyColumn), "ActKeyColumnGPF"); + bGPDframe *gpf= (bGPDframe *)data; + + /* store settings based on state of BezTriple */ + ak->cfra= gpf->framenum; + ak->sel= (gpf->flag & GP_FRAME_SELECT) ? SELECT : 0; + + /* set 'modified', since this is used to identify long keyframes */ + ak->modified = 1; + + return (DLRBT_Node *)ak; +} + +/* Node updater callback used for building ActKeyColumns from GPencil frames */ +static void nupdate_ak_gpframe (void *node, void *data) +{ + ActKeyColumn *ak= (ActKeyColumn *)node; + bGPDframe *gpf= (bGPDframe *)data; + + /* set selection status and 'touched' status */ + if (gpf->flag & GP_FRAME_SELECT) ak->sel = SELECT; + ak->modified += 1; +} + /* --------------- */ /* Add the given BezTriple to the given 'list' of Keyframes */ @@ -146,6 +191,15 @@ static void add_bezt_to_keycolumns_list(DLRBT_Tree *keys, BezTriple *bezt) BLI_dlrbTree_add(keys, compare_ak_bezt, nalloc_ak_bezt, nupdate_ak_bezt, bezt); } +/* Add the given GPencil Frame to the given 'list' of Keyframes */ +static void add_gpframe_to_keycolumns_list(DLRBT_Tree *keys, bGPDframe *gpf) +{ + if ELEM(NULL, keys, gpf) + return; + else + BLI_dlrbTree_add(keys, compare_ak_gpframe, nalloc_ak_gpframe, nupdate_ak_gpframe, gpf); +} + /* ActBeztColumns (Helpers for Long Keyframes) ------------------------------ */ /* maximum size of default buffer for BezTriple columns */ @@ -392,7 +446,7 @@ static const float _unit_diamond_shape[4][2] = { }; /* draw a simple diamond shape with OpenGL */ -void draw_keyframe_shape (float x, float y, float xscale, float hsize, short sel, short key_type, short mode) +void draw_keyframe_shape (float x, float y, float xscale, float hsize, short sel, short key_type, short mode, float alpha) { static GLuint displist1=0; static GLuint displist2=0; @@ -441,23 +495,30 @@ void draw_keyframe_shape (float x, float y, float xscale, float hsize, short sel switch (key_type) { case BEZT_KEYTYPE_BREAKDOWN: /* bluish frames for now */ { - if (sel) glColor3f(0.33f, 0.75f, 0.93f); - else glColor3f(0.70f, 0.86f, 0.91f); + if (sel) glColor4f(0.33f, 0.75f, 0.93f, alpha); + else glColor4f(0.70f, 0.86f, 0.91f, alpha); } break; case BEZT_KEYTYPE_EXTREME: /* redish frames for now */ { - if (sel) glColor3f(95.0f, 0.5f, 0.5f); - else glColor3f(0.91f, 0.70f, 0.80f); + if (sel) glColor4f(0.95f, 0.5f, 0.5f, alpha); + else glColor4f(0.91f, 0.70f, 0.80f, alpha); + } + break; + + case BEZT_KEYTYPE_JITTER: /* greenish frames for now? */ + { + if (sel) glColor4f(0.38f, 0.75f, 0.26f, alpha); + else glColor4f(0.58f, 0.90f, 0.46f, alpha); } break; case BEZT_KEYTYPE_KEYFRAME: /* traditional yellowish frames for now */ default: { - if (sel) UI_ThemeColorShade(TH_STRIP_SELECT, 50); - else glColor3f(0.91f, 0.91f, 0.91f); + if (sel) UI_ThemeColorShadeAlpha(TH_STRIP_SELECT, 50, -255*(1.0f-alpha)); + else glColor4f(0.91f, 0.91f, 0.91f, alpha); } break; } @@ -467,7 +528,7 @@ void draw_keyframe_shape (float x, float y, float xscale, float hsize, short sel if ELEM(mode, KEYFRAME_SHAPE_FRAME, KEYFRAME_SHAPE_BOTH) { /* exterior - black frame */ - glColor3ub(0, 0, 0); + glColor4f(0.0f, 0.0f, 0.0f, alpha); glCallList(displist1); } @@ -479,7 +540,7 @@ void draw_keyframe_shape (float x, float y, float xscale, float hsize, short sel glTranslatef(-x, -y, 0.0f); } -static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, float ypos) +static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, float ypos, short channelLocked) { ActKeyColumn *ak; ActKeyBlock *ab; @@ -522,6 +583,10 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa /* draw keys */ if (keys) { + /* locked channels are less strongly shown, as feedback for locked channels in DopeSheet */ + // TODO: allow this opacity factor to be themed? + float kalpha = (channelLocked)? 0.35f : 1.0f; + for (ak= keys->first; ak; ak= ak->next) { /* optimisation: if keyframe doesn't appear within 5 units (screenspace) in visible area, don't draw * - this might give some improvements, since we current have to flip between view/region matrices @@ -532,7 +597,7 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa /* draw using OpenGL - uglier but faster */ // NOTE1: a previous version of this didn't work nice for some intel cards // NOTE2: if we wanted to go back to icons, these are icon = (ak->sel & SELECT) ? ICON_SPACE2 : ICON_SPACE3; - draw_keyframe_shape(ak->cfra, ypos, xscale, 5.0f, (ak->sel & SELECT), ak->key_type, KEYFRAME_SHAPE_BOTH); + draw_keyframe_shape(ak->cfra, ypos, xscale, 5.0f, (ak->sel & SELECT), ak->key_type, KEYFRAME_SHAPE_BOTH, kalpha); } } @@ -553,7 +618,7 @@ void draw_summary_channel(View2D *v2d, bAnimContext *ac, float ypos) BLI_dlrbTree_linkedlist_sync(&keys); BLI_dlrbTree_linkedlist_sync(&blocks); - draw_keylist(v2d, &keys, &blocks, ypos); + draw_keylist(v2d, &keys, &blocks, ypos, 0); BLI_dlrbTree_free(&keys); BLI_dlrbTree_free(&blocks); @@ -571,7 +636,7 @@ void draw_scene_channel(View2D *v2d, bDopeSheet *ads, Scene *sce, float ypos) BLI_dlrbTree_linkedlist_sync(&keys); BLI_dlrbTree_linkedlist_sync(&blocks); - draw_keylist(v2d, &keys, &blocks, ypos); + draw_keylist(v2d, &keys, &blocks, ypos, 0); BLI_dlrbTree_free(&keys); BLI_dlrbTree_free(&blocks); @@ -589,7 +654,7 @@ void draw_object_channel(View2D *v2d, bDopeSheet *ads, Object *ob, float ypos) BLI_dlrbTree_linkedlist_sync(&keys); BLI_dlrbTree_linkedlist_sync(&blocks); - draw_keylist(v2d, &keys, &blocks, ypos); + draw_keylist(v2d, &keys, &blocks, ypos, 0); BLI_dlrbTree_free(&keys); BLI_dlrbTree_free(&blocks); @@ -607,7 +672,7 @@ void draw_fcurve_channel(View2D *v2d, AnimData *adt, FCurve *fcu, float ypos) BLI_dlrbTree_linkedlist_sync(&keys); BLI_dlrbTree_linkedlist_sync(&blocks); - draw_keylist(v2d, &keys, &blocks, ypos); + draw_keylist(v2d, &keys, &blocks, ypos, (fcu->flag & FCURVE_PROTECTED)); BLI_dlrbTree_free(&keys); BLI_dlrbTree_free(&blocks); @@ -625,7 +690,7 @@ void draw_agroup_channel(View2D *v2d, AnimData *adt, bActionGroup *agrp, float y BLI_dlrbTree_linkedlist_sync(&keys); BLI_dlrbTree_linkedlist_sync(&blocks); - draw_keylist(v2d, &keys, &blocks, ypos); + draw_keylist(v2d, &keys, &blocks, ypos, (agrp->flag & AGRP_PROTECTED)); BLI_dlrbTree_free(&keys); BLI_dlrbTree_free(&blocks); @@ -643,7 +708,7 @@ void draw_action_channel(View2D *v2d, AnimData *adt, bAction *act, float ypos) BLI_dlrbTree_linkedlist_sync(&keys); BLI_dlrbTree_linkedlist_sync(&blocks); - draw_keylist(v2d, &keys, &blocks, ypos); + draw_keylist(v2d, &keys, &blocks, ypos, 0); BLI_dlrbTree_free(&keys); BLI_dlrbTree_free(&blocks); @@ -655,11 +720,11 @@ void draw_gpl_channel(View2D *v2d, bDopeSheet *ads, bGPDlayer *gpl, float ypos) BLI_dlrbTree_init(&keys); - gpl_to_keylist(ads, gpl, &keys, NULL); + gpl_to_keylist(ads, gpl, &keys); BLI_dlrbTree_linkedlist_sync(&keys); - draw_keylist(v2d, &keys, NULL, ypos); + draw_keylist(v2d, &keys, NULL, ypos, (gpl->flag & GP_LAYER_LOCKED)); BLI_dlrbTree_free(&keys); } @@ -753,6 +818,8 @@ void ob_to_keylist(bDopeSheet *ads, Object *ob, DLRBT_Tree *keys, DLRBT_Tree *bl /* add material's data */ action_to_keylist(ma->adt, ma->adt->action, keys, blocks); + + // TODO: textures... } } @@ -808,6 +875,14 @@ void ob_to_keylist(bDopeSheet *ads, Object *ob, DLRBT_Tree *keys, DLRBT_Tree *bl action_to_keylist(me->adt, me->adt->action, keys, blocks); } break; + case OB_LATTICE: /* ------- Lattice ---------- */ + { + Lattice *lt= (Lattice *)ob->data; + + if ((lt->adt) && !(filterflag & ADS_FILTER_NOLAT)) + action_to_keylist(lt->adt, lt->adt->action, keys, blocks); + } + break; } /* Add Particle System Keyframes */ @@ -898,26 +973,14 @@ void action_to_keylist(AnimData *adt, bAction *act, DLRBT_Tree *keys, DLRBT_Tree } -void gpl_to_keylist(bDopeSheet *ads, bGPDlayer *gpl, DLRBT_Tree *keys, DLRBT_Tree *blocks) +void gpl_to_keylist(bDopeSheet *UNUSED(ads), bGPDlayer *gpl, DLRBT_Tree *keys) { bGPDframe *gpf; - ActKeyColumn *ak; if (gpl && keys) { - /* loop over frames, converting directly to 'keyframes' (should be in order too) */ - for (gpf= gpl->frames.first; gpf; gpf= gpf->next) { - ak= MEM_callocN(sizeof(ActKeyColumn), "ActKeyColumn"); - BLI_addtail((ListBase *)keys, ak); - - ak->cfra= (float)gpf->framenum; - ak->modified = 1; - ak->key_type= 0; - - if (gpf->flag & GP_FRAME_SELECT) - ak->sel = SELECT; - else - ak->sel = 0; - } + /* although the frames should already be in an ordered list, they are not suitable for displaying yet */ + for (gpf= gpl->frames.first; gpf; gpf= gpf->next) + add_gpframe_to_keycolumns_list(keys, gpf); } } |