[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53608] trunk/blender: Eyecandy feature: background gradient for 3D viewport.

Antony Riakiotakis kalast at gmail.com
Sun Jan 6 17:45:14 CET 2013


Revision: 53608
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53608
Author:   psy-fi
Date:     2013-01-06 16:45:10 +0000 (Sun, 06 Jan 2013)
Log Message:
-----------
Eyecandy feature: background gradient for 3D viewport. Enable in user preferences under themes->3D view->Theme Gradient Color. This is only used when use render only is not ticked and for now it may interfere with grid lines. Will investigate how to adjust contrast.

Tidying up of options after advisory session on irc: Move all RNA code
in Themes.

Changes after merging trunk's commit that renders sky

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/space_userpref.py
    trunk/blender/source/blender/editors/include/UI_resources.h
    trunk/blender/source/blender/editors/interface/resources.c
    trunk/blender/source/blender/editors/space_view3d/view3d_draw.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	2013-01-06 16:28:44 UTC (rev 53607)
+++ trunk/blender/release/scripts/startup/bl_ui/space_userpref.py	2013-01-06 16:45:10 UTC (rev 53608)
@@ -200,7 +200,7 @@
         col.prop(view, "show_playback_fps", text="Playback FPS")
         col.prop(view, "use_global_scene")
         col.prop(view, "object_origin_size")
-
+ 
         col.separator()
         col.separator()
         col.separator()

Modified: trunk/blender/source/blender/editors/include/UI_resources.h
===================================================================
--- trunk/blender/source/blender/editors/include/UI_resources.h	2013-01-06 16:28:44 UTC (rev 53607)
+++ trunk/blender/source/blender/editors/include/UI_resources.h	2013-01-06 16:45:10 UTC (rev 53608)
@@ -223,7 +223,10 @@
 	
 	TH_AXIS_X,		/* X/Y/Z Axis */
 	TH_AXIS_Y,
-	TH_AXIS_Z
+	TH_AXIS_Z,
+
+	TH_BACK_GRAD,
+	TH_SHOW_BACK_GRAD
 };
 /* 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	2013-01-06 16:28:44 UTC (rev 53607)
+++ trunk/blender/source/blender/editors/interface/resources.c	2013-01-06 16:45:10 UTC (rev 53608)
@@ -170,6 +170,13 @@
 					else
 						cp = ts->button;
 					break;
+				case TH_BACK_GRAD:
+					cp = ts->gradients.gradient;
+					break;
+				case TH_SHOW_BACK_GRAD:
+					cp = &setting;
+					setting = ts->gradients.show_grad;
+					break;
 				case TH_TEXT:
 					if (theme_regionid == RGN_TYPE_WINDOW)
 						cp = ts->text;
@@ -2099,7 +2106,7 @@
 			rgba_char_args_set(btheme->text.syntaxs,    76, 76, 76, 255);   /* Grey (mix between fg/bg) */
 		}
 	}
-	
+
 	if (U.pixelsize == 0.0f)
 		U.pixelsize = 1.0f;
 	

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_draw.c	2013-01-06 16:28:44 UTC (rev 53607)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_draw.c	2013-01-06 16:45:10 UTC (rev 53608)
@@ -3094,8 +3094,37 @@
 		}
 	}
 	else {
-		UI_ThemeClearColor(TH_BACK);
-		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+		if (UI_GetThemeValue(TH_SHOW_BACK_GRAD)) {
+			/* only clear depth buffer here */
+			glClear(GL_DEPTH_BUFFER_BIT);
+
+			glMatrixMode(GL_PROJECTION);
+			glPushMatrix();
+			glLoadIdentity();
+			glMatrixMode(GL_MODELVIEW);
+			glPushMatrix();
+			glLoadIdentity();
+
+			glShadeModel(GL_SMOOTH);
+			glBegin(GL_QUADS);
+			UI_ThemeColor(TH_BACK_GRAD);
+			glVertex2f(-1.0, -1.0);
+			glVertex2f(1.0, -1.0);
+			UI_ThemeColor(TH_BACK);
+			glVertex2f(1.0, 1.0);
+			glVertex2f(-1.0, 1.0);
+			glEnd();
+			glShadeModel(GL_FLAT);
+
+			glMatrixMode(GL_PROJECTION);
+			glPopMatrix();
+
+			glMatrixMode(GL_MODELVIEW);
+			glPopMatrix();
+		} else {
+			UI_ThemeClearColor(TH_BACK);
+			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+		}
 	}
 
 	ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);

Modified: trunk/blender/source/blender/makesdna/DNA_userdef_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_userdef_types.h	2013-01-06 16:28:44 UTC (rev 53607)
+++ trunk/blender/source/blender/makesdna/DNA_userdef_types.h	2013-01-06 16:45:10 UTC (rev 53608)
@@ -149,6 +149,13 @@
 	int pad;
 } uiPanelColors;
 
+typedef struct uiGradientColors {
+	char gradient[4];
+	char pad[4];
+	int show_grad;
+	int pad2;
+} uiGradientColors;
+
 typedef struct ThemeUI {
 	/* Interface Elements (buttons, menus, icons) */
 	uiWidgetColors wcol_regular, wcol_tool, wcol_text;
@@ -210,7 +217,9 @@
 	
 	/* note, cannot use name 'panel' because of DNA mapping old files */
 	uiPanelColors panelcolors;
-	
+
+	uiGradientColors gradients;
+
 	char shade1[4];
 	char shade2[4];
 	
@@ -437,6 +446,7 @@
 	int ndof_flag;			/* flags for 3D mouse */
 
 	short ogl_multisamples;	/* amount of samples for OpenGL FSA, if zero no FSA */
+
 	short pad4;
 	
 	float glalphaclip;

Modified: trunk/blender/source/blender/makesrna/intern/rna_userdef.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_userdef.c	2013-01-06 16:28:44 UTC (rev 53607)
+++ trunk/blender/source/blender/makesrna/intern/rna_userdef.c	2013-01-06 16:45:10 UTC (rev 53608)
@@ -758,6 +758,26 @@
 	RNA_def_property_update(prop, 0, "rna_userdef_update");
 }
 
+static void rna_def_userdef_theme_ui_gradient(BlenderRNA *brna)
+{
+	StructRNA *srna;
+	PropertyRNA *prop;
+
+	srna = RNA_def_struct(brna, "ThemeGradientColors", NULL);
+	RNA_def_struct_sdna(srna, "uiGradientColors");
+	RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
+	RNA_def_struct_ui_text(srna, "Theme Gradient Color", "Theme settings for gradient colors");
+
+	prop = RNA_def_property(srna, "gradient", PROP_FLOAT, PROP_COLOR_GAMMA);
+	RNA_def_property_ui_text(prop, "Gradient Color", "");
+	RNA_def_property_update(prop, 0, "rna_userdef_update");
+
+	prop = RNA_def_property(srna, "show_grad", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_ui_text(prop, "Use Gradient",
+	                         "Do a gradient for the background of the viewport working area");
+	RNA_def_property_update(prop, 0, "rna_userdef_update");
+}
+
 static void rna_def_userdef_theme_ui(BlenderRNA *brna)
 {
 	StructRNA *srna;
@@ -766,7 +786,8 @@
 	rna_def_userdef_theme_ui_wcol(brna);
 	rna_def_userdef_theme_ui_wcol_state(brna);
 	rna_def_userdef_theme_ui_panel(brna);
-	
+	rna_def_userdef_theme_ui_gradient(brna);
+
 	srna = RNA_def_struct(brna, "ThemeUserInterface", NULL);
 	RNA_def_struct_sdna(srna, "ThemeUI");
 	RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
@@ -1360,6 +1381,11 @@
 	RNA_def_property_array(prop, 3);
 	RNA_def_property_ui_text(prop, "Skin Root", "");
 	RNA_def_property_update(prop, 0, "rna_userdef_update");
+
+	prop = RNA_def_property(srna, "gradients", PROP_POINTER, PROP_NONE);
+	RNA_def_property_flag(prop, PROP_NEVER_NULL);
+	RNA_def_property_ui_text(prop, "Gradient", "");
+	RNA_def_property_update(prop, 0, "rna_userdef_update");
 }
 
 




More information about the Bf-blender-cvs mailing list