Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / space_action / action_draw.c
index 3e9b742..7c8be94 100644 (file)
@@ -53,7 +53,7 @@
 #include "BKE_pointcache.h"
 
 
-/* Everything from source (BIF, BDR, BSE) ------------------------------ */ 
+/* Everything from source (BIF, BDR, BSE) ------------------------------ */
 
 #include "BIF_gl.h"
 
 /* Channel List */
 
 /* left hand part */
-void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) 
+void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
 {
        ListBase anim_data = {NULL, NULL};
        bAnimListElem *ale;
        int filter;
-       
+
        View2D *v2d = &ar->v2d;
        float y = 0.0f;
        size_t items;
        int height;
-       
+
        /* build list of channels to draw */
        filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
        items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-       
+
        height = ((items * ACHANNEL_STEP(ac)) + (ACHANNEL_HEIGHT(ac)));
        if (height > BLI_rcti_size_y(&v2d->mask)) {
-               /* don't use totrect set, as the width stays the same 
-                * (NOTE: this is ok here, the configuration is pretty straightforward) 
+               /* don't use totrect set, as the width stays the same
+                * (NOTE: this is ok here, the configuration is pretty straightforward)
                 */
                v2d->tot.ymin = (float)(-height);
        }
        /* need to do a view-sync here, so that the keys area doesn't jump around (it must copy this) */
        UI_view2d_sync(NULL, ac->sa, v2d, V2D_LOCK_COPY);
-       
+
        /* loop through channels, and set up drawing depending on their type  */
        {   /* first pass: just the standard GL-drawing for backdrop + text */
                size_t channel_index = 0;
-               
+
                y = (float)ACHANNEL_FIRST(ac);
-               
+
                for (ale = anim_data.first; ale; ale = ale->next) {
                        float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac));
                        float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF(ac));
-                       
+
                        /* check if visible */
                        if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
                            IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) )
@@ -115,7 +115,7 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
                                /* draw all channels using standard channel-drawing API */
                                ANIM_channel_draw(ac, ale, yminc, ymaxc, channel_index);
                        }
-                       
+
                        /* adjust y-position for next one */
                        y -= ACHANNEL_STEP(ac);
                        channel_index++;
@@ -124,13 +124,13 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
        {   /* second pass: widgets */
                uiBlock *block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
                size_t channel_index = 0;
-               
+
                y = (float)ACHANNEL_FIRST(ac);
-               
+
                for (ale = anim_data.first; ale; ale = ale->next) {
                        float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac));
                        float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF(ac));
-                       
+
                        /* check if visible */
                        if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
                            IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) )
@@ -138,16 +138,16 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
                                /* draw all channels using standard channel-drawing API */
                                ANIM_channel_draw_widgets(C, ac, ale, block, yminc, ymaxc, channel_index);
                        }
-                       
+
                        /* adjust y-position for next one */
                        y -= ACHANNEL_STEP(ac);
                        channel_index++;
                }
-               
+
                UI_block_end(C, block);
                UI_block_draw(C, block);
        }
-       
+
        /* free tempolary channels */
        ANIM_animdata_freelist(&anim_data);
 }
@@ -163,50 +163,50 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
 {
        ListBase anim_data = {NULL, NULL};
        bAnimListElem *ale;
-       
+
        View2D *v2d = &ar->v2d;
        bDopeSheet *ads = &saction->ads;
        AnimData *adt = NULL;
-       
+
        float act_start, act_end, y;
-       
+
        unsigned char col1[3], col2[3];
        unsigned char col1a[3], col2a[3];
        unsigned char col1b[3], col2b[3];
-       
+
        const bool show_group_colors = !(saction->flag & SACTION_NODRAWGCOLORS);
-       
-       
+
+
        /* get theme colors */
        UI_GetThemeColor3ubv(TH_BACK, col2);
        UI_GetThemeColor3ubv(TH_HILITE, col1);
-       
+
        UI_GetThemeColor3ubv(TH_GROUP, col2a);
        UI_GetThemeColor3ubv(TH_GROUP_ACTIVE, col1a);
-       
+
        UI_GetThemeColor3ubv(TH_DOPESHEET_CHANNELOB, col1b);
        UI_GetThemeColor3ubv(TH_DOPESHEET_CHANNELSUBOB, col2b);
-       
+
        /* set view-mapping rect (only used for x-axis), for NLA-scaling mapping with less calculation */
 
        /* if in NLA there's a strip active, map the view */
        if (ac->datatype == ANIMCONT_ACTION) {
                /* adt = ANIM_nla_mapping_get(ac, NULL); */ /* UNUSED */
-               
+
                /* start and end of action itself */
                calc_action_range(ac->data, &act_start, &act_end, 0);
        }
-       
+
        /* build list of channels to draw */
        int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
        size_t items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-       
+
        int height = ((items * ACHANNEL_STEP(ac)) + (ACHANNEL_HEIGHT(ac)));
-       /* don't use totrect set, as the width stays the same 
-        * (NOTE: this is ok here, the configuration is pretty straightforward) 
+       /* don't use totrect set, as the width stays the same
+        * (NOTE: this is ok here, the configuration is pretty straightforward)
         */
        v2d->tot.ymin = (float)(-height);
-       
+
        /* first backdrop strips */
        y = (float)(-ACHANNEL_HEIGHT(ac));
 
@@ -216,18 +216,18 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
        immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 
        glEnable(GL_BLEND);
-       
+
        for (ale = anim_data.first; ale; ale = ale->next) {
                const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac));
                const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF(ac));
-               
+
                /* check if visible */
                if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
                    IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) )
                {
                        const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
                        int sel = 0;
-                       
+
                        /* determine if any need to draw channel */
                        if (ale->datatype != ALE_NONE) {
                                /* determine if channel is selected */
@@ -287,10 +287,10 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
                                                        immUniformColor3ubvAlpha(sel ? col1 : col2, 0x22);
                                                }
                                        }
-                                       
+
                                        /* draw region twice: firstly backdrop, then the current range */
                                        immRectf(pos, v2d->cur.xmin,  (float)y - ACHANNEL_HEIGHT_HALF(ac),  v2d->cur.xmax + EXTRA_SCROLL_PAD,  (float)y + ACHANNEL_HEIGHT_HALF(ac));
-                                       
+
                                        if (ac->datatype == ANIMCONT_ACTION)
                                                immRectf(pos, act_start,  (float)y - ACHANNEL_HEIGHT_HALF(ac),  act_end,  (float)y + ACHANNEL_HEIGHT_HALF(ac));
                                }
@@ -298,7 +298,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
                                        /* frames less than one get less saturated background */
                                        immUniformColor3ubvAlpha(sel ? col1 : col2, 0x22);
                                        immRectf(pos, 0.0f, (float)y - ACHANNEL_HEIGHT_HALF(ac), v2d->cur.xmin, (float)y + ACHANNEL_HEIGHT_HALF(ac));
-                                       
+
                                        /* frames one and higher get a saturated background */
                                        immUniformColor3ubvAlpha(sel ? col1 : col2, 0x44);
                                        immRectf(pos, v2d->cur.xmin, (float)y - ACHANNEL_HEIGHT_HALF(ac), v2d->cur.xmax + EXTRA_SCROLL_PAD,  (float)y + ACHANNEL_HEIGHT_HALF(ac));
@@ -315,7 +315,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
                                }
                        }
                }
-               
+
                /*      Increment the step */
                y -= ACHANNEL_STEP(ac);
        }
@@ -335,7 +335,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
        /* Draw keyframes
         *      1) Only channels that are visible in the Action Editor get drawn/evaluated.
         *         This is to try to optimize this for heavier data sets
-        *      2) Keyframes which are out of view horizontally are disregarded 
+        *      2) Keyframes which are out of view horizontally are disregarded
         */
        y = (float)(-ACHANNEL_HEIGHT(ac));
 
@@ -397,7 +397,7 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene)
        ListBase pidlist;
        const float cache_draw_height = (4.0f * UI_DPI_FAC * U.pixelsize);
        float yoffs = 0.f;
-       
+
        if (!(saction->cache_display & TIME_CACHE_DISPLAY) || (!ob))
                return;
 
@@ -438,7 +438,7 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene)
                gpuPushMatrix();
                gpuTranslate2f(0.0, (float)V2D_SCROLL_HEIGHT + yoffs);
                gpuScale2f(1.0, cache_draw_height);
-               
+
                switch (pid->type) {
                        case PTCACHE_TYPE_SOFTBODY:
                                col[0] = 1.0;   col[1] = 0.4;   col[2] = 0.02;