Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / space_action / space_action.c
index 8f8241c..ffcaf53 100644 (file)
 ARegion *action_has_buttons_region(ScrArea *sa)
 {
        ARegion *ar, *arnew;
-       
+
        ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
        if (ar) return ar;
-       
+
        /* add subdiv level; after main */
        ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
-       
+
        /* is error! */
        if (ar == NULL) return NULL;
-       
+
        arnew = MEM_callocN(sizeof(ARegion), "buttons for action");
-       
+
        BLI_insertlinkafter(&sa->regionbase, ar, arnew);
        arnew->regiontype = RGN_TYPE_UI;
        arnew->alignment = RGN_ALIGN_RIGHT;
-       
+
        arnew->flag = RGN_FLAG_HIDDEN;
-       
+
        return arnew;
 }
 
@@ -96,62 +96,62 @@ static SpaceLink *action_new(const ScrArea *sa, const Scene *scene)
 {
        SpaceAction *saction;
        ARegion *ar;
-       
+
        saction = MEM_callocN(sizeof(SpaceAction), "initaction");
        saction->spacetype = SPACE_ACTION;
-       
+
        saction->autosnap = SACTSNAP_FRAME;
        saction->mode = SACTCONT_DOPESHEET;
-       
+
        saction->ads.filterflag |= ADS_FILTER_SUMMARY;
-       
+
        /* enable all cache display */
        saction->cache_display |= TIME_CACHE_DISPLAY;
        saction->cache_display |= (TIME_CACHE_SOFTBODY | TIME_CACHE_PARTICLES);
        saction->cache_display |= (TIME_CACHE_CLOTH | TIME_CACHE_SMOKE | TIME_CACHE_DYNAMICPAINT);
        saction->cache_display |= TIME_CACHE_RIGIDBODY;
-       
+
        /* header */
        ar = MEM_callocN(sizeof(ARegion), "header for action");
-       
+
        BLI_addtail(&saction->regionbase, ar);
        ar->regiontype = RGN_TYPE_HEADER;
        ar->alignment = RGN_ALIGN_BOTTOM;
-       
+
        /* channel list region */
        ar = MEM_callocN(sizeof(ARegion), "channel region for action");
        BLI_addtail(&saction->regionbase, ar);
        ar->regiontype = RGN_TYPE_CHANNELS;
        ar->alignment = RGN_ALIGN_LEFT;
-       
+
        /* only need to set scroll settings, as this will use 'listview' v2d configuration */
        ar->v2d.scroll = V2D_SCROLL_BOTTOM;
        ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
-       
+
        /* ui buttons */
        ar = MEM_callocN(sizeof(ARegion), "buttons region for action");
-       
+
        BLI_addtail(&saction->regionbase, ar);
        ar->regiontype = RGN_TYPE_UI;
        ar->alignment = RGN_ALIGN_RIGHT;
        ar->flag = RGN_FLAG_HIDDEN;
-       
+
        /* main region */
        ar = MEM_callocN(sizeof(ARegion), "main region for action");
-       
+
        BLI_addtail(&saction->regionbase, ar);
        ar->regiontype = RGN_TYPE_WINDOW;
-       
+
        ar->v2d.tot.xmin = (float)(SFRA - 10);
        ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f;
        ar->v2d.tot.xmax = (float)(EFRA + 10);
        ar->v2d.tot.ymax = 0.0f;
-       
+
        ar->v2d.cur = ar->v2d.tot;
-       
+
        ar->v2d.min[0] = 0.0f;
        ar->v2d.min[1] = 0.0f;
-       
+
        ar->v2d.max[0] = MAXFRAMEF;
        ar->v2d.max[1] = FLT_MAX;
 
@@ -163,13 +163,13 @@ static SpaceLink *action_new(const ScrArea *sa, const Scene *scene)
        ar->v2d.keepofs = V2D_KEEPOFS_Y;
        ar->v2d.align = V2D_ALIGN_NO_POS_Y;
        ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
-       
+
        return (SpaceLink *)saction;
 }
 
 /* not spacelink itself */
 static void action_free(SpaceLink *UNUSED(sl))
-{      
+{
 //     SpaceAction *saction = (SpaceAction *) sl;
 }
 
@@ -178,16 +178,16 @@ static void action_free(SpaceLink *UNUSED(sl))
 static void action_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa)
 {
        SpaceAction *saction = sa->spacedata.first;
-       
+
        saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
 }
 
 static SpaceLink *action_duplicate(SpaceLink *sl)
 {
        SpaceAction *sactionn = MEM_dupallocN(sl);
-       
+
        /* clear or remove stuff from old */
-       
+
        return (SpaceLink *)sactionn;
 }
 
@@ -197,9 +197,9 @@ static SpaceLink *action_duplicate(SpaceLink *sl)
 static void action_main_region_init(wmWindowManager *wm, ARegion *ar)
 {
        wmKeyMap *keymap;
-       
+
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
-       
+
        /* own keymap */
        keymap = WM_keymap_find(wm->defaultconf, "Dopesheet", SPACE_ACTION, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
@@ -220,44 +220,44 @@ static void action_main_region_draw(const bContext *C, ARegion *ar)
        short marker_flag = 0;
        short cfra_flag = 0;
        short unit = 0;
-       
+
        /* clear and setup matrix */
        UI_ThemeClearColor(TH_BACK);
        glClear(GL_COLOR_BUFFER_BIT);
-       
+
        UI_view2d_view_ortho(v2d);
-       
+
        /* time grid */
        unit = (saction->flag & SACTION_DRAWTIME) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES;
        grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy);
        UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL);
        UI_view2d_grid_free(grid);
-       
+
        ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
-       
+
        /* start and end frame */
        ANIM_draw_framerange(scene, v2d);
-       
+
        /* data */
        if (ANIM_animdata_get_context(C, &ac)) {
                draw_channel_strips(&ac, saction, ar);
        }
-       
+
        /* current frame */
        if (saction->flag & SACTION_DRAWTIME) cfra_flag |= DRAWCFRA_UNIT_SECONDS;
        ANIM_draw_cfra(C, v2d, cfra_flag);
-       
+
        /* markers */
        UI_view2d_view_orthoSpecial(ar, v2d, 1);
-       
+
        marker_flag = ((ac.markers && (ac.markers != &ac.scene->markers)) ? DRAW_MARKERS_LOCAL : 0) | DRAW_MARKERS_MARGIN;
        ED_markers_draw(C, marker_flag);
-       
+
        /* caches */
        if (saction->mode == SACTCONT_TIMELINE) {
                timeline_draw_cache(saction, obact, scene);
        }
-       
+
        /* preview range */
        UI_view2d_view_ortho(v2d);
        ANIM_draw_previewrange(C, v2d, 0);
@@ -265,15 +265,15 @@ static void action_main_region_draw(const bContext *C, ARegion *ar)
        /* callback */
        UI_view2d_view_ortho(v2d);
        ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
-       
+
        /* reset view matrix */
        UI_view2d_view_restore(C);
-       
+
        /* scrollers */
        scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
        UI_view2d_scrollers_draw(C, v2d, scrollers);
        UI_view2d_scrollers_free(scrollers);
-       
+
        /* draw current frame number-indicator on top of scrollers */
        if ((saction->flag & SACTION_NODRAWCFRANUM) == 0) {
                UI_view2d_view_orthoSpecial(ar, v2d, 1);
@@ -285,16 +285,16 @@ static void action_main_region_draw(const bContext *C, ARegion *ar)
 static void action_channel_region_init(wmWindowManager *wm, ARegion *ar)
 {
        wmKeyMap *keymap;
-       
+
        /* ensure the 2d view sync works - main region has bottom scroller */
        ar->v2d.scroll = V2D_SCROLL_BOTTOM;
-       
+
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
-       
+
        /* own keymap */
        keymap = WM_keymap_find(wm->defaultconf, "Animation Channels", 0, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
-       
+
        keymap = WM_keymap_find(wm->defaultconf, "Dopesheet Generic", SPACE_ACTION, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 }
@@ -304,21 +304,21 @@ static void action_channel_region_draw(const bContext *C, ARegion *ar)
        /* draw entirely, view changes should be handled here */
        bAnimContext ac;
        View2D *v2d = &ar->v2d;
-       
+
        /* clear and setup matrix */
        UI_ThemeClearColor(TH_BACK);
        glClear(GL_COLOR_BUFFER_BIT);
-       
+
        UI_view2d_view_ortho(v2d);
-       
+
        /* data */
        if (ANIM_animdata_get_context(C, &ac)) {
                draw_channel_names((bContext *)C, &ac, ar);
        }
-       
+
        /* reset view matrix */
        UI_view2d_view_restore(C);
-       
+
        /* no scrollers here */
 }
 
@@ -393,7 +393,7 @@ static void saction_channel_region_message_subscribe(
                .user_data = ar,
                .notify = ED_region_do_msg_notify_tag_redraw,
        };
-       
+
        /* All dopesheet filter settings, etc. affect the drawing of this editor,
         * also same applies for all animation-related datatypes that may appear here,
         * so just whitelist the entire structs for updates
@@ -402,13 +402,13 @@ static void saction_channel_region_message_subscribe(
                wmMsgParams_RNA msg_key_params = {{{0}}};
                StructRNA *type_array[] = {
                        &RNA_DopeSheet,    /* dopesheet filters */
-                       
+
                        &RNA_ActionGroup,  /* channel groups */
-                       
+
                        &RNA_FCurve,       /* F-Curve */
                        &RNA_Keyframe,
                        &RNA_FCurveSample,
-                       
+
                        &RNA_GreasePencil, /* Grease Pencil */
                        &RNA_GPencilLayer,
                        &RNA_GPencilFrame,
@@ -518,7 +518,7 @@ static void saction_main_region_message_subscribe(
                        WM_msg_subscribe_rna(mbus, &idptr, props[i], &msg_sub_value_region_tag_redraw, __func__);
                }
        }
-       
+
        /* Now run the general "channels region" one - since channels and main should be in sync */
        saction_channel_region_message_subscribe(C, workspace, scene, screen, sa, ar, mbus);
 }
@@ -529,7 +529,7 @@ static void action_listener(
         WorkSpace *UNUSED(workspace))
 {
        SpaceAction *saction = (SpaceAction *)sa->spacedata.first;
-       
+
        /* context changes */
        switch (wmn->category) {
                case NC_GPENCIL:
@@ -550,7 +550,7 @@ static void action_listener(
                                saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
                                ED_area_tag_refresh(sa);
                        }
-                       /* autocolor only really needs to change when channels are added/removed, or previously hidden stuff appears 
+                       /* autocolor only really needs to change when channels are added/removed, or previously hidden stuff appears
                         * (assume for now that if just adding these works, that will be fine)
                         */
                        else if (((wmn->data == ND_KEYFRAME) && ELEM(wmn->action, NA_ADDED, NA_REMOVED)) ||
@@ -558,7 +558,7 @@ static void action_listener(
                        {
                                ED_area_tag_refresh(sa);
                        }
-                       /* for simple edits to the curve data though (or just plain selections), a simple redraw should work 
+                       /* for simple edits to the curve data though (or just plain selections), a simple redraw should work
                         * (see T39851 for an example of how this can go wrong)
                         */
                        else {
@@ -598,7 +598,7 @@ static void action_listener(
                                                saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
                                                ED_area_tag_refresh(sa);
                                                break;
-                                               
+
                                        default: /* just redrawing the view will do */
                                                ED_area_tag_redraw(sa);
                                                break;
@@ -721,12 +721,12 @@ static void action_header_region_listener(
                case NC_ANIMATION:
                        switch (wmn->data) {
                                case ND_ANIMCHAN: /* set of visible animchannels changed */
-                                       /* NOTE: for now, this should usually just mean that the filters changed 
+                                       /* NOTE: for now, this should usually just mean that the filters changed
                                         *       It may be better if we had a dedicated flag for that though
                                         */
                                        ED_region_tag_redraw(ar);
                                        break;
-                                       
+
                                case ND_KEYFRAME: /* new keyframed added -> active action may have changed */
                                        //saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
                                        ED_region_tag_redraw(ar);
@@ -741,9 +741,9 @@ static void action_header_region_listener(
 static void action_buttons_area_init(wmWindowManager *wm, ARegion *ar)
 {
        wmKeyMap *keymap;
-       
+
        ED_region_panels_init(wm, ar);
-       
+
        keymap = WM_keymap_find(wm->defaultconf, "Dopesheet Generic", SPACE_ACTION, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 }
@@ -790,19 +790,19 @@ static void action_region_listener(
 static void action_refresh(const bContext *C, ScrArea *sa)
 {
        SpaceAction *saction = (SpaceAction *)sa->spacedata.first;
-       
-       /* update the state of the animchannels in response to changes from the data they represent 
+
+       /* update the state of the animchannels in response to changes from the data they represent
         * NOTE: the temp flag is used to indicate when this needs to be done, and will be cleared once handled
         */
        if (saction->flag & SACTION_TEMP_NEEDCHANSYNC) {
                ARegion *ar;
-               
+
                /* Perform syncing of channel state incl. selection
                 * Active action setting also occurs here (as part of anim channel filtering in anim_filter.c)
                 */
                ANIM_sync_animchannels_to_data(C);
                saction->flag &= ~SACTION_TEMP_NEEDCHANSYNC;
-               
+
                /* Tag everything for redraw
                 * - Regions (such as header) need to be manually tagged for redraw too
                 *   or else they don't update [#28962]
@@ -811,7 +811,7 @@ static void action_refresh(const bContext *C, ScrArea *sa)
                for (ar = sa->regionbase.first; ar; ar = ar->next)
                        ED_region_tag_redraw(ar);
        }
-       
+
        /* region updates? */
        // XXX re-sizing y-extents of tot should go here?
 }
@@ -838,10 +838,10 @@ void ED_spacetype_action(void)
 {
        SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype action");
        ARegionType *art;
-       
+
        st->spaceid = SPACE_ACTION;
        strncpy(st->name, "Action", BKE_ST_MAXNAME);
-       
+
        st->new = action_new;
        st->free = action_free;
        st->init = action_init;
@@ -862,32 +862,32 @@ void ED_spacetype_action(void)
        art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES;
 
        BLI_addhead(&st->regiontypes, art);
-       
+
        /* regions: header */
        art = MEM_callocN(sizeof(ARegionType), "spacetype action region");
        art->regionid = RGN_TYPE_HEADER;
        art->prefsizey = HEADERY;
        art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
-       
+
        art->init = action_header_region_init;
        art->draw = action_header_region_draw;
        art->listener = action_header_region_listener;
-       
+
        BLI_addhead(&st->regiontypes, art);
-       
+
        /* regions: channels */
        art = MEM_callocN(sizeof(ARegionType), "spacetype action region");
        art->regionid = RGN_TYPE_CHANNELS;
        art->prefsizex = 200;
        art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES;
-       
+
        art->init = action_channel_region_init;
        art->draw = action_channel_region_draw;
        art->listener = action_channel_region_listener;
        art->message_subscribe = saction_channel_region_message_subscribe;
-       
+
        BLI_addhead(&st->regiontypes, art);
-       
+
        /* regions: UI buttons */
        art = MEM_callocN(sizeof(ARegionType), "spacetype action region");
        art->regionid = RGN_TYPE_UI;
@@ -896,11 +896,11 @@ void ED_spacetype_action(void)
        art->listener = action_region_listener;
        art->init = action_buttons_area_init;
        art->draw = action_buttons_area_draw;
-       
+
        BLI_addhead(&st->regiontypes, art);
-       
+
        action_buttons_register(art);
-       
+
        BKE_spacetype_register(st);
 }