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:
authorJoshua Leung <aligorith@gmail.com>2011-03-24 06:19:30 +0300
committerJoshua Leung <aligorith@gmail.com>2011-03-24 06:19:30 +0300
commit3b0a42f898bc862cbb4e6ad04200b64dcf83e611 (patch)
treefac34f93ef54827d5e40951a05dbef8c331d8af6 /source/blender/editors/animation/keyframes_draw.c
parenteef811a0954ad67a4667592c85cd95822d15e17c (diff)
Reshuffled utility function to keyframe drawing API, removing some
duplicate code
Diffstat (limited to 'source/blender/editors/animation/keyframes_draw.c')
-rw-r--r--source/blender/editors/animation/keyframes_draw.c44
1 files changed, 28 insertions, 16 deletions
diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c
index 3f8f8dc1e84..662f038fd6e 100644
--- a/source/blender/editors/animation/keyframes_draw.c
+++ b/source/blender/editors/animation/keyframes_draw.c
@@ -457,6 +457,33 @@ static void set_touched_actkeyblock (ActKeyBlock *ab)
set_touched_actkeyblock(ab->right);
}
+/* --------- */
+
+/* Checks if ActKeyBlock should exist... */
+short actkeyblock_is_valid (ActKeyBlock *ab, DLRBT_Tree *keys)
+{
+ ActKeyColumn *ak;
+ short startCurves, endCurves, totCurves;
+
+ /* check that block is valid */
+ if (ab == NULL)
+ return 0;
+
+ /* find out how many curves occur at each keyframe */
+ ak= (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->start);
+ startCurves = (ak)? ak->totcurve: 0;
+
+ ak= (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->end);
+ endCurves = (ak)? ak->totcurve: 0;
+
+ /* only draw keyblock if it appears in at all of the keyframes at lowest end */
+ if (!startCurves && !endCurves)
+ return 0;
+
+ totCurves = (startCurves>endCurves)? endCurves: startCurves;
+ return (ab->totcurve >= totCurves);
+}
+
/* *************************** Keyframe Drawing *************************** */
/* coordinates for diamond shape */
@@ -576,22 +603,7 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa
/* draw keyblocks */
if (blocks) {
for (ab= blocks->first; ab; ab= ab->next) {
- short startCurves, endCurves, totCurves;
-
- /* find out how many curves occur at each keyframe */
- ak= (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->start);
- startCurves = (ak)? ak->totcurve: 0;
-
- ak= (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->end);
- endCurves = (ak)? ak->totcurve: 0;
-
- /* only draw keyblock if it appears in at all of the keyframes at lowest end */
- if (!startCurves && !endCurves)
- continue;
- else
- totCurves = (startCurves>endCurves)? endCurves: startCurves;
-
- if (ab->totcurve >= totCurves) {
+ if (actkeyblock_is_valid(ab, keys)) {
/* draw block */
if (ab->sel)
UI_ThemeColor4(TH_STRIP_SELECT);