[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25832] trunk/blender/source/blender: Animation Channels Drawing Tweak:
Joshua Leung
aligorith at gmail.com
Fri Jan 8 12:14:30 CET 2010
Revision: 25832
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25832
Author: aligorith
Date: 2010-01-08 12:14:30 +0100 (Fri, 08 Jan 2010)
Log Message:
-----------
Animation Channels Drawing Tweak:
A solid color backdrop is now drawn behind the mute/protect toggles and sliders, reducing the visual clutter with long names still appearing behind the UI widgets.
Modified Paths:
--------------
trunk/blender/source/blender/blenlib/BLI_math_color.h
trunk/blender/source/blender/blenlib/intern/math_color.c
trunk/blender/source/blender/editors/animation/anim_channels_defines.c
trunk/blender/source/blender/editors/include/ED_anim_api.h
trunk/blender/source/blender/editors/include/UI_resources.h
trunk/blender/source/blender/editors/interface/resources.c
Modified: trunk/blender/source/blender/blenlib/BLI_math_color.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_color.h 2010-01-08 10:11:04 UTC (rev 25831)
+++ trunk/blender/source/blender/blenlib/BLI_math_color.h 2010-01-08 11:14:30 UTC (rev 25832)
@@ -74,6 +74,9 @@
int constrain_rgb(float *r, float *g, float *b);
void minmax_rgb(short c[3]);
+void rgb_byte_to_float(char *in, float *out);
+void rgb_float_to_byte(float *in, char *out);
+
#ifdef __cplusplus
}
#endif
Modified: trunk/blender/source/blender/blenlib/intern/math_color.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_color.c 2010-01-08 10:11:04 UTC (rev 25831)
+++ trunk/blender/source/blender/blenlib/intern/math_color.c 2010-01-08 11:14:30 UTC (rev 25832)
@@ -274,6 +274,26 @@
*b /= 255.0f;
}
+void rgb_byte_to_float(char *in, float *out)
+{
+ out[0]= ((float)in[0]) / 255.0f;
+ out[1]= ((float)in[1]) / 255.0f;
+ out[2]= ((float)in[2]) / 255.0f;
+}
+
+void rgb_float_to_byte(float *in, char *out)
+{
+ int r, g, b;
+
+ r= (int)(in[0] * 255.0);
+ g= (int)(in[1] * 255.0);
+ b= (int)(in[2] * 255.0);
+
+ out[0]= (char)((r <= 0)? 0 : (r >= 255)? 255 : r);
+ out[1]= (char)((g <= 0)? 0 : (g >= 255)? 255 : g);
+ out[2]= (char)((b <= 0)? 0 : (b >= 255)? 255 : b);
+}
+
/* ********************************* color transforms ********************************* */
Modified: trunk/blender/source/blender/editors/animation/anim_channels_defines.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_channels_defines.c 2010-01-08 10:11:04 UTC (rev 25831)
+++ trunk/blender/source/blender/editors/animation/anim_channels_defines.c 2010-01-08 11:14:30 UTC (rev 25832)
@@ -120,6 +120,13 @@
/* Draw Backdrop ---------------------------------- */
+/* get backdrop color for top-level widgets (Scene and Object only) */
+static void acf_generic_root_color(bAnimContext *ac, bAnimListElem *ale, float *color)
+{
+ /* darker blue for top-level widgets */
+ UI_GetThemeColor3fv(TH_DOPESHEET_CHANNELOB, color);
+}
+
/* backdrop for top-level widgets (Scene and Object only) */
static void acf_generic_root_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc)
{
@@ -127,38 +134,48 @@
View2D *v2d= &ac->ar->v2d;
short expanded= ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_EXPAND) != 0;
short offset= (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
+ float color[3];
- /* darker blue for top-level widgets */
- UI_ThemeColor(TH_DOPESHEET_CHANNELOB);
+ /* set backdrop drawing color */
+ acf->get_backdrop_color(ac, ale, color);
+ glColor3fv(color);
/* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */
uiSetRoundBox((expanded)? (1):(1|8));
gl_round_box(GL_POLYGON, offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc, 8);
}
+
+/* get backdrop color for data expanders under top-level Scene/Object */
+static void acf_generic_dataexpand_color(bAnimContext *ac, bAnimListElem *ale, float *color)
+{
+ /* lighter color than top-level widget */
+ UI_GetThemeColor3fv(TH_DOPESHEET_CHANNELSUBOB, color);
+}
+
/* backdrop for data expanders under top-level Scene/Object */
static void acf_generic_dataexpand_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc)
{
bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale);
View2D *v2d= &ac->ar->v2d;
short offset= (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
+ float color[3];
- /* lighter color than top-level widget */
- UI_ThemeColor(TH_DOPESHEET_CHANNELSUBOB);
+ /* set backdrop drawing color */
+ acf->get_backdrop_color(ac, ale, color);
+ glColor3fv(color);
/* no rounded corner - just rectangular box */
glRectf(offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc);
}
-/* backdrop for generic channels */
-static void acf_generic_channel_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc)
+/* get backdrop color for generic channels */
+static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, float *color)
{
bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale);
- View2D *v2d= &ac->ar->v2d;
SpaceAction *saction = NULL;
bActionGroup *grp = NULL;
short indent= (acf->get_indent_level) ? acf->get_indent_level(ac, ale) : 0;
- short offset= (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
/* get context info needed... */
if ((ac->sa) && (ac->sa->spacetype == SPACE_ACTION))
@@ -188,11 +205,28 @@
VECCOPY(cp, grp->cs.active);
}
- glColor3ub(cp[0], cp[1], cp[2]);
+ /* copy the colors over, transforming from bytes to floats */
+ rgb_byte_to_float(cp, color);
}
- else // FIXME: what happens when the indention is 1 greater than what it should be (due to grouping)?
- UI_ThemeColorShade(TH_HEADER, ((indent==0)?20: (indent==1)?-20: -40));
+ else {
+ // FIXME: what happens when the indention is 1 greater than what it should be (due to grouping)?
+ int colOfs= 20 - 20*indent;
+ UI_GetThemeColorShade3fv(TH_HEADER, colOfs, color);
+ }
+}
+
+/* backdrop for generic channels */
+static void acf_generic_channel_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc)
+{
+ bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale);
+ View2D *v2d= &ac->ar->v2d;
+ short offset= (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
+ float color[3];
+ /* set backdrop drawing color */
+ acf->get_backdrop_color(ac, ale, color);
+ glColor3fv(color);
+
/* no rounded corners - just rectangular box */
glRectf(offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc);
}
@@ -348,13 +382,23 @@
/* Animation Summary ----------------------------------- */
+/* get backdrop color for summary widget */
+static void acf_summary_color(bAnimContext *ac, bAnimListElem *ale, float *color)
+{
+ // FIXME: hardcoded color - same as the 'action' line in NLA
+ glColor3f(0.8f, 0.2f, 0.0f); // reddish color
+}
+
/* backdrop for summary widget */
static void acf_summary_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc)
{
+ bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale);
View2D *v2d= &ac->ar->v2d;
+ float color[3];
- // FIXME: hardcoded color - same as the 'action' line in NLA
- glColor3f(0.8f, 0.2f, 0.0f); // reddish color
+ /* set backdrop drawing color */
+ acf->get_backdrop_color(ac, ale, color);
+ glColor3fv(color);
/* rounded corners on LHS only
* - top and bottom
@@ -424,6 +468,7 @@
/* all animation summary (DopeSheet only) type define */
static bAnimChannelType ACF_SUMMARY =
{
+ acf_summary_color, /* backdrop color */
acf_summary_backdrop, /* backdrop */
acf_generic_indention_0, /* indent level */
NULL, /* offset */
@@ -522,6 +567,7 @@
/* scene type define */
static bAnimChannelType ACF_SCENE =
{
+ acf_generic_root_color, /* backdrop color */
acf_generic_root_backdrop, /* backdrop */
acf_generic_indention_0, /* indent level */
NULL, /* offset */
@@ -641,6 +687,7 @@
/* object type define */
static bAnimChannelType ACF_OBJECT =
{
+ acf_generic_root_color, /* backdrop color */
acf_generic_root_backdrop, /* backdrop */
acf_generic_indention_0, /* indent level */
NULL, /* offset */
@@ -655,6 +702,16 @@
/* Group ------------------------------------------- */
+/* get backdrop color for group widget */
+static void acf_group_color(bAnimContext *ac, bAnimListElem *ale, float *color)
+{
+ /* highlight only for action group channels */
+ if (ale->flag & AGRP_ACTIVE)
+ UI_GetThemeColorShade3fv(TH_GROUP_ACTIVE, 10, color);
+ else
+ UI_GetThemeColorShade3fv(TH_GROUP, 20, color);
+}
+
/* backdrop for group widget */
static void acf_group_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc)
{
@@ -662,12 +719,11 @@
View2D *v2d= &ac->ar->v2d;
short expanded= ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_EXPAND) != 0;
short offset= (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
+ float color[3];
- /* only for action group channels */
- if (ale->flag & AGRP_ACTIVE)
- UI_ThemeColorShade(TH_GROUP_ACTIVE, 10);
- else
- UI_ThemeColorShade(TH_GROUP, 20);
+ /* set backdrop drawing color */
+ acf->get_backdrop_color(ac, ale, color);
+ glColor3fv(color);
/* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */
uiSetRoundBox((expanded)? (1):(1|8));
@@ -738,6 +794,7 @@
/* group type define */
static bAnimChannelType ACF_GROUP =
{
+ acf_group_color, /* backdrop color */
acf_group_backdrop, /* backdrop */
acf_generic_indention_0, /* indent level */
acf_generic_group_offset, /* offset */
@@ -821,6 +878,7 @@
/* fcurve type define */
static bAnimChannelType ACF_FCURVE =
{
+ acf_generic_channel_color, /* backdrop color */
acf_generic_channel_backdrop, /* backdrop */
acf_generic_indention_flexible, /* indent level */ // xxx rename this to f-curves only?
acf_generic_group_offset, /* offset */
@@ -902,6 +960,7 @@
/* object action expander type define */
static bAnimChannelType ACF_FILLACTD =
{
+ acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop,/* backdrop */
acf_generic_indention_1, /* indent level */
acf_generic_basic_offset, /* offset */
@@ -977,6 +1036,7 @@
/* drivers expander type define */
static bAnimChannelType ACF_FILLDRIVERS =
{
+ acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop,/* backdrop */
acf_generic_indention_1, /* indent level */
acf_generic_basic_offset, /* offset */
@@ -1020,6 +1080,7 @@
/* materials expander type define */
static bAnimChannelType ACF_FILLMATD=
{
+ acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop,/* backdrop */
acf_generic_indention_1, /* indent level */
acf_generic_basic_offset, /* offset */
@@ -1063,6 +1124,7 @@
/* particles expander type define */
static bAnimChannelType ACF_FILLPARTD=
{
+ acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop,/* backdrop */
acf_generic_indention_1, /* indent level */
acf_generic_basic_offset, /* offset */
@@ -1142,6 +1204,7 @@
/* material expander type define */
static bAnimChannelType ACF_DSMAT=
{
+ acf_generic_channel_color, /* backdrop color */
acf_generic_channel_backdrop, /* backdrop */
acf_generic_indention_0, /* indent level */
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list