[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [52026] trunk/blender: Axis Colours are now Themeable

Joshua Leung aligorith at gmail.com
Fri Nov 9 07:36:14 CET 2012


Revision: 52026
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=52026
Author:   aligorith
Date:     2012-11-09 06:36:11 +0000 (Fri, 09 Nov 2012)
Log Message:
-----------
Axis Colours are now Themeable

This commit allows you to set the RGB <-> XYZ axis colours used for things like
the mini axis indicator, grid axis indicators, manipulators, transform
constraint indicators, F-Curves (when using XYZ to RGB colouring option), and
perhaps something else I've missed. Previously, these places all used hardcoded
defines (220 * i/j/k), but the readability of these colours was often quite
poor, especially when used with certain themes.

The settings for these colours can be found under the "User Interface" section
of the themes (i.e. same set of colours is used across editors). I could have
made these per editor, but since it's unlikely that these will need to be too
different across editors in practice (+ being easier to version patch), they are
stored under the UI section.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/space_userpref.py
    trunk/blender/source/blender/editors/animation/anim_draw.c
    trunk/blender/source/blender/editors/include/UI_resources.h
    trunk/blender/source/blender/editors/interface/resources.c
    trunk/blender/source/blender/editors/space_graph/space_graph.c
    trunk/blender/source/blender/editors/space_view3d/view3d_draw.c
    trunk/blender/source/blender/editors/transform/transform_manipulator.c
    trunk/blender/source/blender/makesdna/DNA_userdef_types.h
    trunk/blender/source/blender/makesrna/intern/rna_userdef.c

Modified: trunk/blender/release/scripts/startup/bl_ui/space_userpref.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_userpref.py	2012-11-09 06:06:50 UTC (rev 52025)
+++ trunk/blender/release/scripts/startup/bl_ui/space_userpref.py	2012-11-09 06:36:11 UTC (rev 52026)
@@ -728,6 +728,29 @@
             colsub = padding.column()
             colsub.row().prop(ui, "header")
 
+            col.separator()
+            col.separator()
+
+            ui = theme.user_interface
+            col.label("Axis Colors:")
+
+            row = col.row()
+
+            subsplit = row.split(percentage=0.95)
+
+            padding = subsplit.split(percentage=0.15)
+            colsub = padding.column()
+            colsub = padding.column()
+            colsub.row().prop(ui, "axis_x")
+            colsub.row().prop(ui, "axis_y")
+            colsub.row().prop(ui, "axis_z")
+            
+            subsplit = row.split(percentage=0.85)
+
+            padding = subsplit.split(percentage=0.15)
+            colsub = padding.column()
+            colsub = padding.column()
+            
             layout.separator()
             layout.separator()
         elif theme.theme_area == 'BONE_COLOR_SETS':

Modified: trunk/blender/source/blender/editors/animation/anim_draw.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_draw.c	2012-11-09 06:06:50 UTC (rev 52025)
+++ trunk/blender/source/blender/editors/animation/anim_draw.c	2012-11-09 06:36:11 UTC (rev 52026)
@@ -381,7 +381,7 @@
 						return RAD2DEGF(1.0f);  /* radians to degrees */
 				}
 			}
-
+			
 			/* TODO: other rotation types here as necessary */
 		}
 	}

Modified: trunk/blender/source/blender/editors/include/UI_resources.h
===================================================================
--- trunk/blender/source/blender/editors/include/UI_resources.h	2012-11-09 06:06:50 UTC (rev 52025)
+++ trunk/blender/source/blender/editors/include/UI_resources.h	2012-11-09 06:36:11 UTC (rev 52026)
@@ -215,7 +215,11 @@
 	TH_NLA_META,
 	TH_NLA_META_SEL,
 	TH_NLA_SOUND,
-	TH_NLA_SOUND_SEL
+	TH_NLA_SOUND_SEL,
+	
+	TH_AXIS_X,		/* X/Y/Z Axis */
+	TH_AXIS_Y,
+	TH_AXIS_Z
 };
 /* XXX WARNING: previous is saved in file, so do not change order! */
 

Modified: trunk/blender/source/blender/editors/interface/resources.c
===================================================================
--- trunk/blender/source/blender/editors/interface/resources.c	2012-11-09 06:06:50 UTC (rev 52025)
+++ trunk/blender/source/blender/editors/interface/resources.c	2012-11-09 06:36:11 UTC (rev 52026)
@@ -236,7 +236,7 @@
 					cp = ts->shade2; break;
 				case TH_HILITE:
 					cp = ts->hilite; break;
-
+				
 				case TH_GRID:
 					cp = ts->grid; break;
 				case TH_WIRE:
@@ -510,6 +510,13 @@
 				case TH_NLA_SOUND_SEL:
 					cp = ts->nla_sound_sel;
 					break;
+					
+				case TH_AXIS_X:
+					cp = btheme->tui.xaxis; break;
+				case TH_AXIS_Y:
+					cp = btheme->tui.yaxis; break;
+				case TH_AXIS_Z:
+					cp = btheme->tui.zaxis; break;
 			}
 		}
 	}
@@ -655,9 +662,14 @@
 
 	/* UI buttons */
 	ui_widget_color_init(&btheme->tui);
+	
 	btheme->tui.iconfile[0] = 0;
 	btheme->tui.panel.show_header = FALSE;
 	rgba_char_args_set(btheme->tui.panel.header, 0, 0, 0, 25);
+	
+	rgba_char_args_set(btheme->tui.xaxis, 220,   0,   0, 255);
+	rgba_char_args_set(btheme->tui.yaxis,   0, 220,   0, 255);
+	rgba_char_args_set(btheme->tui.zaxis,   0,   0, 220, 255);
 
 	/* Bone Color Sets */
 	ui_theme_init_boneColorSets(btheme);
@@ -1072,7 +1084,6 @@
 	
 	cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
 	return ((float)cp[0]);
-
 }
 
 /* get individual values, not scaled */
@@ -1082,7 +1093,6 @@
 	
 	cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
 	return ((int) cp[0]);
-
 }
 
 
@@ -1244,21 +1254,20 @@
 
 void UI_make_axis_color(const unsigned char src_col[3], unsigned char dst_col[3], const char axis)
 {
+	unsigned char col[3];
+	
 	switch (axis) {
 		case 'X':
-			dst_col[0] = src_col[0] > 219 ? 255 : src_col[0] + 36;
-			dst_col[1] = src_col[1] < 26 ? 0 : src_col[1] - 26;
-			dst_col[2] = src_col[2] < 26 ? 0 : src_col[2] - 26;
+			UI_GetThemeColor3ubv(TH_AXIS_X, col);
+			UI_GetColorPtrBlendShade3ubv(src_col, col, dst_col, 0.5f, -10);
 			break;
 		case 'Y':
-			dst_col[0] = src_col[0] < 46 ? 0 : src_col[0] - 36;
-			dst_col[1] = src_col[1] > 189 ? 255 : src_col[1] + 66;
-			dst_col[2] = src_col[2] < 46 ? 0 : src_col[2] - 36;
+			UI_GetThemeColor3ubv(TH_AXIS_Y, col);
+			UI_GetColorPtrBlendShade3ubv(src_col, col, dst_col, 0.5f, -10);
 			break;
 		case 'Z':
-			dst_col[0] = src_col[0] < 26 ? 0 : src_col[0] - 26;
-			dst_col[1] = src_col[1] < 26 ? 0 : src_col[1] - 26;
-			dst_col[2] = src_col[2] > 209 ? 255 : src_col[2] + 46;
+			UI_GetThemeColor3ubv(TH_AXIS_Z, col);
+			UI_GetColorPtrBlendShade3ubv(src_col, col, dst_col, 0.5f, -10);
 			break;
 		default:
 			BLI_assert(!"invalid axis arg");
@@ -1946,6 +1955,16 @@
 				rgba_char_args_set(btheme->tv3d.skin_root, 180, 77, 77, 255);
 		}
 	}
+	
+	if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 9)) {
+		bTheme *btheme;
+		
+		for (btheme = U.themes.first; btheme; btheme = btheme->next) {
+			rgba_char_args_set(btheme->tui.xaxis, 220,   0,   0, 255);
+			rgba_char_args_set(btheme->tui.yaxis,   0, 220,   0, 255);
+			rgba_char_args_set(btheme->tui.zaxis,   0,   0, 220, 255);
+		}
+	}
 
 	/* GL Texture Garbage Collection (variable abused above!) */
 	if (U.textimeout == 0) {

Modified: trunk/blender/source/blender/editors/space_graph/space_graph.c
===================================================================
--- trunk/blender/source/blender/editors/space_graph/space_graph.c	2012-11-09 06:06:50 UTC (rev 52025)
+++ trunk/blender/source/blender/editors/space_graph/space_graph.c	2012-11-09 06:36:11 UTC (rev 52026)
@@ -563,13 +563,13 @@
 					
 					switch (fcu->array_index) {
 						case 0:
-							col[0] = 1.0f; col[1] = 0.0f; col[2] = 0.0f;
+							UI_GetThemeColor3fv(TH_AXIS_X, col);
 							break;
 						case 1:
-							col[0] = 0.0f; col[1] = 1.0f; col[2] = 0.0f;
+							UI_GetThemeColor3fv(TH_AXIS_Y, col);
 							break;
 						case 2:
-							col[0] = 0.0f; col[1] = 0.0f; col[2] = 1.0f;
+							UI_GetThemeColor3fv(TH_AXIS_Z, col);
 							break;
 						default:
 							/* 'unknown' color - bluish so as to not conflict with handles */

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_draw.c	2012-11-09 06:06:50 UTC (rev 52025)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_draw.c	2012-11-09 06:36:11 UTC (rev 52026)
@@ -545,12 +545,8 @@
 			}
 		}
 	}
-
-
-
-
-	if (v3d->zbuf && scene->obedit) glDepthMask(1);
 	
+	if (v3d->zbuf && scene->obedit) glDepthMask(1);
 }
 
 static void drawcursor(Scene *scene, ARegion *ar, View3D *v3d)
@@ -600,8 +596,8 @@
 	mul_qt_v3(rv3d->viewquat, vec);
 	dx = vec[0] * k;
 	dy = vec[1] * k;
-
-	glColor4ub(220, 0, 0, bright);
+	
+	UI_ThemeColorShadeAlpha(TH_AXIS_X, 0, bright);
 	glBegin(GL_LINES);
 	glVertex2f(start, start + ydisp);
 	glVertex2f(start + dx, start + dy + ydisp);
@@ -620,8 +616,8 @@
 	mul_qt_v3(rv3d->viewquat, vec);
 	dx = vec[0] * k;
 	dy = vec[1] * k;
-
-	glColor4ub(0, 220, 0, bright);
+	
+	UI_ThemeColorShadeAlpha(TH_AXIS_Y, 0, bright);
 	glBegin(GL_LINES);
 	glVertex2f(start, start + ydisp);
 	glVertex2f(start + dx, start + dy + ydisp);
@@ -640,7 +636,7 @@
 	dx = vec[0] * k;
 	dy = vec[1] * k;
 
-	glColor4ub(30, 30, 220, bright);
+	UI_ThemeColorShadeAlpha(TH_AXIS_Z, 0, bright);
 	glBegin(GL_LINES);
 	glVertex2f(start, start + ydisp);
 	glVertex2f(start + dx, start + dy + ydisp);

Modified: trunk/blender/source/blender/editors/transform/transform_manipulator.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_manipulator.c	2012-11-09 06:06:50 UTC (rev 52025)
+++ trunk/blender/source/blender/editors/transform/transform_manipulator.c	2012-11-09 06:36:11 UTC (rev 52026)
@@ -744,7 +744,7 @@
 	return (char)(255.0f * (angle - 5) / 15.0f);
 }
 
-/* three colors can be set;
+/* three colors can be set:
  * gray for ghosting
  * moving: in transform theme color
  * else the red/green/blue
@@ -776,15 +776,13 @@
 				}
 				break;
 			case 'X':
-				col[0] = 220;
+				UI_GetThemeColor3ubv(TH_AXIS_X, col);
 				break;
 			case 'Y':
-				col[1] = 220;
+				UI_GetThemeColor3ubv(TH_AXIS_Y, col);
 				break;
 			case 'Z':
-				col[0] = 30;
-				col[1] = 30;
-				col[2] = 220;
+				UI_GetThemeColor3ubv(TH_AXIS_Z, col);
 				break;
 			default:
 				BLI_assert(!"invalid axis arg");

Modified: trunk/blender/source/blender/makesdna/DNA_userdef_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_userdef_types.h	2012-11-09 06:06:50 UTC (rev 52025)
+++ trunk/blender/source/blender/makesdna/DNA_userdef_types.h	2012-11-09 06:36:11 UTC (rev 52026)
@@ -162,7 +162,8 @@
 	char iconfile[256];	// FILE_MAXFILE length
 	float icon_alpha;
 
-	float pad;
+	/* Axis Colors */
+	char xaxis[4], yaxis[4], zaxis[4];
 } ThemeUI;
 
 /* try to put them all in one, if needed a special struct can be created as well

Modified: trunk/blender/source/blender/makesrna/intern/rna_userdef.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_userdef.c	2012-11-09 06:06:50 UTC (rev 52025)
+++ trunk/blender/source/blender/makesrna/intern/rna_userdef.c	2012-11-09 06:36:11 UTC (rev 52026)
@@ -770,6 +770,25 @@
 	prop = RNA_def_property(srna, "icon_alpha", PROP_FLOAT, PROP_FACTOR);
 	RNA_def_property_ui_text(prop, "Icon Alpha", "Transparency of icons in the interface, to reduce contrast");
 	RNA_def_property_update(prop, 0, "rna_userdef_update");
+	
+	/* axis */
+	prop = RNA_def_property(srna, "axis_x", PROP_FLOAT, PROP_COLOR_GAMMA);
+	RNA_def_property_float_sdna(prop, NULL, "xaxis");
+	RNA_def_property_array(prop, 3);
+	RNA_def_property_ui_text(prop, "X Axis", "");
+	RNA_def_property_update(prop, 0, "rna_userdef_update");
+	
+	prop = RNA_def_property(srna, "axis_y", PROP_FLOAT, PROP_COLOR_GAMMA);
+	RNA_def_property_float_sdna(prop, NULL, "yaxis");
+	RNA_def_property_array(prop, 3);
+	RNA_def_property_ui_text(prop, "Y Axis", "");

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list