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>2009-02-15 13:58:24 +0300
committerJoshua Leung <aligorith@gmail.com>2009-02-15 13:58:24 +0300
commit844db375593d2a02f9182f9c195316de01253b67 (patch)
treefb22c05a58c0c00a51a982b4aefadd1e2e509ee5 /source/blender/editors/space_graph/graph_draw.c
parent394b3fcede01356764bb91883a2f32b08b0a6ca3 (diff)
Graph Editor: F-Curve Colouring
Now F-Curve channels in channels region are drawn with the same colour as their respective curve is drawn in the curves area. I've had to make a compromise to store such colour info in F-Curves themselves, which is not terribly ideal if the F-Curve gets reused in some way. However, for now, this will do (special tweaks can be made to make this work better though). I've also added a colour-determination mode per curve which should in future allow more control over this. By default, all curves still use the old 'rainbow' style. The available types area: * Old Rainbow - Colour is determined 'automatically' using a magic method which uses curve position + total curves to generate a colour. * Auto RGB - Color is determined using the 'array index' stored in F-Curve for data-access. An unresolved issue with this is that all the curves with this will end up with exactly the same colour, leading to confusion (i.e. all location.x and scale.x properties could potentially all be the same red colour). * Custom colour - self explanatory Currently, there's a minor bug when loading old files where the colours don't get initialised yet. For now, just clicking in the Graph Editor after file-load will solve any of these problems. Ton: it looks like area->refresh() isn't getting called after file read.
Diffstat (limited to 'source/blender/editors/space_graph/graph_draw.c')
-rw-r--r--source/blender/editors/space_graph/graph_draw.c42
1 files changed, 12 insertions, 30 deletions
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index eea057435ff..a7ef4941b24 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -686,18 +686,15 @@ void graph_draw_curves (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
bAnimListElem *ale;
int filter;
- unsigned int col;
- int items, i;
-
/* build list of curves to draw */
filter= (ANIMFILTER_VISIBLE|ANIMFILTER_CURVESONLY|ANIMFILTER_CURVEVISIBLE);
- items= ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
+ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
/* for each curve:
* draw curve, then handle-lines, and finally vertices in this order so that
* the data will be layered correctly
*/
- for (ale=anim_data.first, i=0; ale; ale=ale->next, i++) {
+ for (ale=anim_data.first; ale; ale=ale->next) {
FCurve *fcu= (FCurve *)ale->key_data;
Object *nob= ANIM_nla_mapping_get(ac, ale);
float fac=0.0f; // dummy var
@@ -719,9 +716,8 @@ void graph_draw_curves (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
UI_ThemeColorShade(TH_HEADER, 50);
}
else {
- // XXX color calculation here really needs to be done in advance instead
- col= ipo_rainbow(i, items);
- cpack(col);
+ /* set whatever color the curve has set */
+ glColor3fv(fcu->color);
}
/* draw F-Curve */
@@ -768,7 +764,7 @@ void graph_draw_channel_names(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
View2D *v2d= &ar->v2d;
float x= 0.0f, y= 0.0f, height;
- int items;
+ int items, i=0;
/* build list of channels to draw */
filter= (ANIMFILTER_VISIBLE|ANIMFILTER_CHANNELS);
@@ -795,7 +791,7 @@ void graph_draw_channel_names(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
/* loop through channels, and set up drawing depending on their type */
y= (float)ACHANNEL_FIRST;
- for (ale= anim_data.first; ale; ale= ale->next) {
+ for (ale= anim_data.first, i=0; ale; ale= ale->next, i++) {
const float yminc= (float)(y - ACHANNEL_HEIGHT_HALF);
const float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF);
@@ -1039,7 +1035,7 @@ void graph_draw_channel_names(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
group= (fcu->grp) ? 1 : 0;
grp= fcu->grp;
-
+
switch (ale->ownertype) {
case ANIMTYPE_NONE: /* no owner */
case ANIMTYPE_FCURVE:
@@ -1141,25 +1137,11 @@ void graph_draw_channel_names(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
gl_round_box(GL_POLYGON, x+offset, yminc, (float)ACHANNEL_NAMEWIDTH, ymaxc, 8);
}
else {
- /* for normal channels
- * - use 3 shades of color group/standard color for 3 indention level
- * - only use group colors if allowed to, and if actually feasible
- */
- if ((grp) && (grp->customCol))
- {
- char cp[3];
-
- if (indent == 2) {
- VECCOPY(cp, grp->cs.solid);
- }
- else if (indent == 1) {
- VECCOPY(cp, grp->cs.select);
- }
- else {
- VECCOPY(cp, grp->cs.active);
- }
-
- glColor3ub(cp[0], cp[1], cp[2]);
+ /* most of the time, only F-Curves are going to be drawn here */
+ if (ale->type == ANIMTYPE_FCURVE) {
+ /* F-Curve channels are colored with whatever color the curve has stored */
+ FCurve *fcu= (FCurve *)ale->data;
+ glColor3fv(fcu->color);
}
else
UI_ThemeColorShade(TH_HEADER, ((indent==0)?20: (indent==1)?-20: -40));