diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-04-30 00:04:12 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-04-30 00:04:12 +0400 |
commit | ebe4ffa8de3c0a2d471e6f859e96921fe95b475b (patch) | |
tree | 4faba21ba91585bb906c86655d1eacbdfda970b2 /source/blender/editors/space_clip | |
parent | ebbc038e4f044be9f2c5f495bce685fb267d99cf (diff) |
Tomato: refactoring of dopesheet to allow different sort orders in list of channels
Store list of channels displaying in dopesheet separately from list of tracks.
This allows to re-sort channels in dopesheet independently from list of all
tracks (currently only alphabetic sorting is implemented).
This also allows to cache assorted information (like tracked segments of track)
but currently such a things are not bottlenecks and could be done after merge
dopesheet view into trunk.
TODO:
- Still have some deadlocks when drawing selected channels.
Skipping channel background or keyframe drawing helps here but
this need to be resolved.
- Bump sub-version and wrote code needed to convert pre-dopesheet interface
with opened curve view displaying properly.
- Probably it'll worth caching tracked segments.
Diffstat (limited to 'source/blender/editors/space_clip')
5 files changed, 47 insertions, 46 deletions
diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c index 758a2ac3d99..d1733cf322b 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_draw.c +++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c @@ -154,8 +154,8 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene) if (clip) { MovieTracking *tracking = &clip->tracking; - MovieTrackingTrack *track; - ListBase *tracksbase = BKE_tracking_get_tracks(tracking); + MovieTrackingDopesheet *dopesheet = &tracking->dopesheet; + MovieTrackingDopesheetChannel *channel; float y, xscale, yscale; float strip[4], selected_strip[4]; @@ -172,17 +172,15 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene) glEnable(GL_BLEND); - for (track = tracksbase->first; track; track = track->next) { + for (channel = dopesheet->channels.first; channel; channel = channel->next) { float yminc = (float) (y - CHANNEL_HEIGHT_HALF); float ymaxc = (float) (y + CHANNEL_HEIGHT_HALF); - if (!TRACK_VIEW_SELECTED(sc, track)) - continue; - /* check if visible */ if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) { + MovieTrackingTrack *track = channel->track; float alpha; int i, sel = track->flag & TRACK_DOPE_SEL; @@ -272,21 +270,20 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar) View2D *v2d = &ar->v2d; MovieClip *clip = ED_space_clip(sc); MovieTracking *tracking; - MovieTrackingTrack *track; - ListBase *tracksbase; + MovieTrackingDopesheet *dopesheet; + MovieTrackingDopesheetChannel *channel; uiStyle *style = UI_GetStyle(); uiBlock *block; int fontid = style->widget.uifont_id; - int items, height; + int height; float y; if (!clip) return; tracking = &clip->tracking; - tracksbase = BKE_tracking_get_tracks(tracking); - items = BLI_countlist(tracksbase); - height = (items * CHANNEL_STEP) + (CHANNEL_HEIGHT * 2); + dopesheet = &tracking->dopesheet; + height = (dopesheet->tot_channel * CHANNEL_STEP) + (CHANNEL_HEIGHT * 2); if (height > (v2d->mask.ymax - v2d->mask.ymin)) { /* don't use totrect set, as the width stays the same @@ -305,17 +302,15 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar) BLF_size(fontid, 11.0f, U.dpi); - for (track = tracksbase->first; track; track = track->next) { + for (channel = dopesheet->channels.first; channel; channel = channel->next) { float yminc = (float) (y - CHANNEL_HEIGHT_HALF); float ymaxc = (float) (y + CHANNEL_HEIGHT_HALF); - if (!TRACK_VIEW_SELECTED(sc, track)) - continue; - /* check if visible */ if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) { + MovieTrackingTrack *track = channel->track; float font_height, color[3]; int sel = track->flag & TRACK_DOPE_SEL; @@ -345,17 +340,15 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar) y = (float) CHANNEL_FIRST; glEnable(GL_BLEND); - for (track = tracksbase->first; track; track = track->next) { + for (channel = dopesheet->channels.first; channel; channel = channel->next) { float yminc = (float)(y - CHANNEL_HEIGHT_HALF); float ymaxc = (float)(y + CHANNEL_HEIGHT_HALF); - if (!TRACK_VIEW_SELECTED(sc, track)) - continue; - /* check if visible */ if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) { + MovieTrackingTrack *track = channel->track; uiBut *but; PointerRNA ptr; int icon; diff --git a/source/blender/editors/space_clip/clip_dopesheet_ops.c b/source/blender/editors/space_clip/clip_dopesheet_ops.c index 2225f01afe3..bec030f5e21 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_ops.c +++ b/source/blender/editors/space_clip/clip_dopesheet_ops.c @@ -91,40 +91,28 @@ static int dopesheet_select_channel_exec(bContext *C, wmOperator *op) SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip(sc); MovieTracking *tracking = &clip->tracking; - ListBase *tracksbase = BKE_tracking_get_tracks(tracking); - MovieTrackingTrack *track; + MovieTrackingDopesheet *dopesheet = &tracking->dopesheet; + MovieTrackingDopesheetChannel *channel; float location[2]; - int extend = RNA_boolean_get(op->ptr, "extend"), channel, channel_index; + int extend = RNA_boolean_get(op->ptr, "extend"); + int current_channel_index = 0, channel_index; RNA_float_get_array(op->ptr, "location", location); - channel = -(location[1] - (CHANNEL_FIRST + CHANNEL_HEIGHT_HALF)) / CHANNEL_STEP; + channel_index = -(location[1] - (CHANNEL_FIRST + CHANNEL_HEIGHT_HALF)) / CHANNEL_STEP; - for (track = tracksbase->first, channel_index = 0; track; track = track->next) { - if (!TRACK_VIEW_SELECTED(sc, track)) - continue; + for (channel = dopesheet->channels.first; channel; channel = channel->next) { + MovieTrackingTrack *track = channel->track; - if (channel_index == channel) { + if (current_channel_index == channel_index) { if (extend) track->flag ^= TRACK_DOPE_SEL; else track->flag |= TRACK_DOPE_SEL; - - if (track->flag & TRACK_DOPE_SEL) { - MovieTrackingMarker *marker; - - /* make last selected in dopesheet track active in clip editor */ - tracking->act_track = track; - - /* make active track be centered to screen */ - /* XXX: doesn't work in other opened spaces */ - marker = BKE_tracking_get_marker(track, sc->user.framenr); - clip_view_center_to_point(sc, marker->pos[0], marker->pos[1]); - } } else if (!extend) track->flag &= ~TRACK_DOPE_SEL; - channel_index++; + current_channel_index++; } WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 69a8b0f4c92..e61580295fc 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -565,3 +565,11 @@ int ED_space_clip_show_trackedit(SpaceClip *sc) return FALSE; } + +void ED_space_clip_update_dopesheet(SpaceClip *sc) +{ + MovieClip *clip = sc->clip; + MovieTracking *tracking = &clip->tracking; + + BKE_tracking_update_dopesheet(tracking); +} diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c index 7ab41078e16..0414c969705 100644 --- a/source/blender/editors/space_clip/clip_graph_ops.c +++ b/source/blender/editors/space_clip/clip_graph_ops.c @@ -234,11 +234,6 @@ static int mouse_select_curve(bContext *C, float co[2], int extend) tracking->act_track = userdata.track; - /* make active track be centered to screen */ - /* XXX: doesn't work in other opened spaces */ - marker = BKE_tracking_get_marker(userdata.track, sc->user.framenr); - clip_view_center_to_point(sc, marker->pos[0], marker->pos[1]); - /* deselect all knots on newly selected curve */ clip_graph_tracking_iterate(sc, &selectdata, toggle_selection_cb); } diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index b3bb7464761..2c9b61ed1ef 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -95,6 +95,8 @@ static void add_marker(SpaceClip *sc, float x, float y) BKE_tracking_select_track(tracksbase, track, TRACK_AREA_ALL, 0); clip->tracking.act_track = track; + + ED_space_clip_update_dopesheet(sc); } static int add_marker_exec(bContext *C, wmOperator *op) @@ -174,6 +176,8 @@ static int delete_track_exec(bContext *C, wmOperator *UNUSED(op)) /* nothing selected now, unlock view so it can be scrolled nice again */ sc->flag &= ~SC_LOCK_SELECTION; + ED_space_clip_update_dopesheet(sc); + return OPERATOR_FINISHED; } @@ -225,6 +229,8 @@ static int delete_marker_exec(bContext *C, wmOperator *UNUSED(op)) sc->flag &= ~SC_LOCK_SELECTION; } + ED_space_clip_update_dopesheet(sc); + return OPERATOR_FINISHED; } @@ -790,6 +796,7 @@ static int mouse_select(bContext *C, float co[2], int extend) } WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); + ED_space_clip_update_dopesheet(sc); return OPERATOR_FINISHED; } @@ -901,6 +908,8 @@ static int border_select_exec(bContext *C, wmOperator *op) } if (change) { + ED_space_clip_update_dopesheet(sc); + WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); return OPERATOR_FINISHED; @@ -985,6 +994,8 @@ static int circle_select_exec(bContext *C, wmOperator *op) } if (change) { + ED_space_clip_update_dopesheet(sc); + WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); return OPERATOR_FINISHED; @@ -1081,6 +1092,8 @@ static int select_all_exec(bContext *C, wmOperator *op) if (!has_selection) sc->flag &= ~SC_LOCK_SELECTION; + ED_space_clip_update_dopesheet(sc); + WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); return OPERATOR_FINISHED; @@ -1161,6 +1174,8 @@ static int select_groped_exec(bContext *C, wmOperator *op) track = track->next; } + ED_space_clip_update_dopesheet(sc); + WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip); return OPERATOR_FINISHED; @@ -2730,6 +2745,8 @@ static int hide_tracks_exec(bContext *C, wmOperator *op) sc->flag &= ~SC_LOCK_SELECTION; } + BKE_tracking_update_dopesheet(tracking); + WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, NULL); return OPERATOR_FINISHED; |