[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18018] branches/blender2.5/blender/source /blender/editors: * bring back some drawing code for node editor (grid, roundbox emboss)

Nathan Letwory jesterking at letwory.net
Mon Dec 22 21:53:38 CET 2008


Revision: 18018
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18018
Author:   jesterking
Date:     2008-12-22 21:53:38 +0100 (Mon, 22 Dec 2008)

Log Message:
-----------
* bring back some drawing code for node editor (grid, roundbox emboss)

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/include/UI_view2d.h
    branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c
    branches/blender2.5/blender/source/blender/editors/interface/view2d.c

Modified: branches/blender2.5/blender/source/blender/editors/include/UI_view2d.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/UI_view2d.h	2008-12-22 20:28:02 UTC (rev 18017)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_view2d.h	2008-12-22 20:53:38 UTC (rev 18018)
@@ -151,6 +151,7 @@
 /* grid drawing */
 View2DGrid *UI_view2d_grid_calc(const struct bContext *C, struct View2D *v2d, short xunits, short xclamp, short yunits, short yclamp, int winx, int winy);
 void UI_view2d_grid_draw(const struct bContext *C, struct View2D *v2d, View2DGrid *grid, int flag);
+void UI_view2d_constant_grid_draw(const struct bContext *C, struct View2D *v2d);
 void UI_view2d_grid_free(View2DGrid *grid);
 
 /* scrollbar drawing */

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c	2008-12-22 20:28:02 UTC (rev 18017)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c	2008-12-22 20:53:38 UTC (rev 18018)
@@ -146,6 +146,54 @@
 	glColor3fv(col);
 }
 
+/* only for headers */
+static void gl_round_box_topshade(float minx, float miny, float maxx, float maxy, float rad)
+{
+	float vec[7][2]= {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293},
+	                  {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
+	char col[7]= {140, 165, 195, 210, 230, 245, 255};
+	int a;
+	char alpha=255;
+	
+	if(roundboxtype & UI_RB_ALPHA) alpha= 128;
+	
+	/* mult */
+	for(a=0; a<7; a++) {
+		vec[a][0]*= rad; vec[a][1]*= rad;
+	}
+
+	/* shades from grey->white->grey */
+	glBegin(GL_LINE_STRIP);
+	
+	if(roundboxtype & 3) {
+		/* corner right-top */
+		glColor4ub(140, 140, 140, alpha);
+		glVertex2f( maxx, maxy-rad);
+		for(a=0; a<7; a++) {
+			glColor4ub(col[a], col[a], col[a], alpha);
+			glVertex2f( maxx-vec[a][1], maxy-rad+vec[a][0]);
+		}
+		glColor4ub(225, 225, 225, alpha);
+		glVertex2f( maxx-rad, maxy);
+	
+		
+		/* corner left-top */
+		glVertex2f( minx+rad, maxy);
+		for(a=0; a<7; a++) {
+			glColor4ub(col[6-a], col[6-a], col[6-a], alpha);
+			glVertex2f( minx+rad-vec[a][0], maxy-vec[a][1]);
+		}
+		glVertex2f( minx, maxy-rad);
+	}
+	else {
+		glColor4ub(225, 225, 225, alpha);
+		glVertex2f( minx, maxy);
+		glVertex2f( maxx, maxy);
+	}
+	
+	glEnd();
+}
+
 /* linear horizontal shade within button or in outline */
 void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown)
 {
@@ -441,7 +489,78 @@
 	glDisable( GL_BLEND );
 }
 
+/* for headers and floating panels */
+void uiRoundBoxEmboss(float minx, float miny, float maxx, float maxy, float rad, int active)
+{
+	float color[4];
+	
+	if(roundboxtype & UI_RB_ALPHA) {
+		glGetFloatv(GL_CURRENT_COLOR, color);
+		color[3]= 0.5;
+		glColor4fv(color);
+		glEnable( GL_BLEND );
+	}
+	
+	/* solid part */
+	//if(active)
+	//	gl_round_box_shade(GL_POLYGON, minx, miny, maxx, maxy, rad, 0.10, -0.05);
+	// else
+	/* shading doesnt work for certain buttons yet (pulldown) need smarter buffer caching (ton) */
+	gl_round_box(GL_POLYGON, minx, miny, maxx, maxy, rad);
+	
+	/* set antialias line */
+	if (UI_GetThemeValue(TH_BUT_DRAWTYPE) != TH_MINIMAL) {
+		glEnable( GL_LINE_SMOOTH );
+		glEnable( GL_BLEND );
+	}
 
+	/* top shade */
+	gl_round_box_topshade(minx+1, miny+1, maxx-1, maxy-1, rad);
+
+	/* total outline */
+	if(roundboxtype & UI_RB_ALPHA) glColor4ub(0,0,0, 128); else glColor4ub(0,0,0, 200);
+	gl_round_box(GL_LINE_LOOP, minx, miny, maxx, maxy, rad);
+   
+	glDisable( GL_LINE_SMOOTH );
+
+	/* bottom shade for header down */
+	if((roundboxtype & 12)==12) {
+		glColor4ub(0,0,0, 80);
+		fdrawline(minx+rad-1.0, miny+1.0, maxx-rad+1.0, miny+1.0);
+	}
+	glDisable( GL_BLEND );
+}
+
+/* plain antialiased filled box */
+#if 0
+void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad)
+{
+	float color[4];
+	
+	if(roundboxtype & UI_RB_ALPHA) {
+		glGetFloatv(GL_CURRENT_COLOR, color);
+		color[3]= 0.5;
+		glColor4fv(color);
+		glEnable( GL_BLEND );
+	}
+	
+	/* solid part */
+	gl_round_box(GL_POLYGON, minx, miny, maxx, maxy, rad);
+	
+	/* set antialias line */
+	if (UI_GetThemeValue(TH_BUT_DRAWTYPE) != TH_MINIMAL) {
+		glEnable( GL_LINE_SMOOTH );
+		glEnable( GL_BLEND );
+	}
+		
+	gl_round_box(GL_LINE_LOOP, minx, miny, maxx, maxy, rad);
+   
+	glDisable( GL_BLEND );
+	glDisable( GL_LINE_SMOOTH );
+}
+#endif
+
+
 /* ************** safe rasterpos for pixmap alignment with pixels ************* */
 
 void ui_rasterpos_safe(float x, float y, float aspect)

Modified: branches/blender2.5/blender/source/blender/editors/interface/view2d.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/view2d.c	2008-12-22 20:28:02 UTC (rev 18017)
+++ branches/blender2.5/blender/source/blender/editors/interface/view2d.c	2008-12-22 20:53:38 UTC (rev 18018)
@@ -1046,6 +1046,37 @@
 	}
 }
 
+/* Draw a constant grid in given 2d-region */
+void UI_view2d_constant_grid_draw(const bContext *C, View2D *v2d)
+{
+	float start, step= 25.0f;
+
+	UI_ThemeColorShade(TH_BACK, -10);
+	
+	start= v2d->cur.xmin -fmod(v2d->cur.xmin, step);
+	
+	glBegin(GL_LINES);
+	for(; start<v2d->cur.xmax; start+=step) {
+		glVertex2f(start, v2d->cur.ymin);
+		glVertex2f(start, v2d->cur.ymax);
+	}
+
+	start= v2d->cur.ymin -fmod(v2d->cur.ymin, step);
+	for(; start<v2d->cur.ymax; start+=step) {
+		glVertex2f(v2d->cur.xmin, start);
+		glVertex2f(v2d->cur.xmax, start);
+	}
+	
+	/* X and Y axis */
+	UI_ThemeColorShade(TH_BACK, -18);
+	glVertex2f(0.0f, v2d->cur.ymin);
+	glVertex2f(0.0f, v2d->cur.ymax);
+	glVertex2f(v2d->cur.xmin, 0.0f);
+	glVertex2f(v2d->cur.xmax, 0.0f);
+	
+	glEnd();
+}
+
 /* free temporary memory used for drawing grid */
 void UI_view2d_grid_free(View2DGrid *grid)
 {





More information about the Bf-blender-cvs mailing list