Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-05-03 23:28:41 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-05-03 23:28:41 +0400
commitb1006fb949d5b437f7ab0514ee779ba24fcfc1f8 (patch)
tree9e30e514bdba81d5955691bd4722235beea2d58b /source/blender/blenkernel
parent5821c2973ec6a7cc6abc25ac75e85e84dc176411 (diff)
Clip editor: sort order for dopesheet channels
Supported sorting by name, longest tracked segment and total tracked frames. Internally tracks are stored in Tracking datablock, but sort order is a clip editor space property and sorting happens on clip editor draw. If there's no dopesheet opened with different sort orders it's not a problem due to re-sorting wouldn't happen. Also fixed draw issue of tracked segments introduced in previous commit.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_tracking.h6
-rw-r--r--source/blender/blenkernel/intern/tracking.c83
2 files changed, 88 insertions, 1 deletions
diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h
index 3b1a5dbfc8a..1432dc151d0 100644
--- a/source/blender/blenkernel/BKE_tracking.h
+++ b/source/blender/blenkernel/BKE_tracking.h
@@ -166,6 +166,7 @@ void BKE_tracking_deselect_track(struct MovieTrackingTrack *track, int area);
/* Dopesheet */
void BKE_tracking_update_dopesheet(struct MovieTracking *tracking);
+void BKE_tracking_dopesheet_sort(struct MovieTracking *tracking, int sort_order, int inverse);
#define TRACK_SELECTED(track) ((track)->flag&SELECT || (track)->pat_flag&SELECT || (track)->search_flag&SELECT)
@@ -197,4 +198,9 @@ void BKE_tracking_update_dopesheet(struct MovieTracking *tracking);
#define TRACK_AREA_ALL (TRACK_AREA_POINT|TRACK_AREA_PAT|TRACK_AREA_SEARCH)
+#define TRACK_SORT_NONE -1
+#define TRACK_SORT_NAME 0
+#define TRACK_SORT_LONGEST 1
+#define TRACK_SORT_TOTAL 2
+
#endif
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index 216e3b19672..bb4a7783c82 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -3072,6 +3072,52 @@ static int channels_alpha_sort(void *a, void *b)
return 0;
}
+static int channels_total_track_sort(void *a, void *b)
+{
+ MovieTrackingDopesheetChannel *channel_a = a;
+ MovieTrackingDopesheetChannel *channel_b = b;
+
+ if (channel_a->total_frames > channel_b->total_frames)
+ return 1;
+ else
+ return 0;
+}
+
+static int channels_longest_segment_sort(void *a, void *b)
+{
+ MovieTrackingDopesheetChannel *channel_a = a;
+ MovieTrackingDopesheetChannel *channel_b = b;
+
+ if (channel_a->max_segment > channel_b->max_segment)
+ return 1;
+ else
+ return 0;
+}
+
+static int channels_alpha_inverse_sort(void *a, void *b)
+{
+ if (channels_alpha_sort(a, b))
+ return 0;
+ else
+ return 1;
+}
+
+static int channels_total_track_inverse_sort(void *a, void *b)
+{
+ if (channels_total_track_sort(a, b))
+ return 0;
+ else
+ return 1;
+}
+
+static int channels_longest_segment_inverse_sort(void *a, void *b)
+{
+ if (channels_longest_segment_sort(a, b))
+ return 0;
+ else
+ return 1;
+}
+
static void channels_segments_calc(MovieTrackingDopesheetChannel *channel)
{
MovieTrackingTrack *track = channel->track;
@@ -3173,5 +3219,40 @@ void BKE_tracking_update_dopesheet(MovieTracking *tracking)
}
}
- BLI_sortlist(&dopesheet->channels, channels_alpha_sort);
+ dopesheet->sort_order = TRACK_SORT_NONE;
+ dopesheet->sort_inverse = -1;
+}
+
+void BKE_tracking_dopesheet_sort(MovieTracking *tracking, int sort_order, int inverse)
+{
+ MovieTrackingDopesheet *dopesheet = &tracking->dopesheet;
+
+ if (dopesheet->sort_order == sort_order && dopesheet->sort_inverse == inverse)
+ return;
+
+ if (inverse) {
+ if (sort_order == TRACK_SORT_NAME) {
+ BLI_sortlist(&dopesheet->channels, channels_alpha_inverse_sort);
+ }
+ else if (sort_order == TRACK_SORT_LONGEST) {
+ BLI_sortlist(&dopesheet->channels, channels_longest_segment_inverse_sort);
+ }
+ else if (sort_order == TRACK_SORT_TOTAL) {
+ BLI_sortlist(&dopesheet->channels, channels_total_track_inverse_sort);
+ }
+ }
+ else {
+ if (sort_order == TRACK_SORT_NAME) {
+ BLI_sortlist(&dopesheet->channels, channels_alpha_sort);
+ }
+ else if (sort_order == TRACK_SORT_LONGEST) {
+ BLI_sortlist(&dopesheet->channels, channels_longest_segment_sort);
+ }
+ else if (sort_order == TRACK_SORT_TOTAL) {
+ BLI_sortlist(&dopesheet->channels, channels_total_track_sort);
+ }
+ }
+
+ dopesheet->sort_order = sort_order;
+ dopesheet->sort_inverse = inverse;
}