[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19626] branches/blender2.5/blender/source /blender: 2.5

Ton Roosendaal ton at blender.org
Thu Apr 9 20:11:18 CEST 2009


Revision: 19626
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19626
Author:   ton
Date:     2009-04-09 20:11:18 +0200 (Thu, 09 Apr 2009)

Log Message:
-----------
2.5

WIP commit for UI drawing.

- Hooked up Diego's new Font API
- Added Style definitions for fonts, currently it uses
  a different font for panel titles to show it.
- Styles are in Userdef now too, still not finished 
- Userdef "DPI" will offer global control over font size,
  to match monitor size/resolution. It's meant to scale
  widgets and headers too btw, later.
- Lots of code removed for old fonts, but that's unfinished.

On todo: too much to mention, will continue happily tomorrow!

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/include/UI_interface.h
    branches/blender2.5/blender/source/blender/editors/interface/interface.c
    branches/blender2.5/blender/source/blender/editors/interface/interface_intern.h
    branches/blender2.5/blender/source/blender/editors/interface/interface_panel.c
    branches/blender2.5/blender/source/blender/editors/interface/interface_widgets.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_userdef_types.h
    branches/blender2.5/blender/source/blender/windowmanager/intern/wm_files.c

Added Paths:
-----------
    branches/blender2.5/blender/source/blender/editors/interface/interface_style.c

Modified: branches/blender2.5/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/UI_interface.h	2009-04-09 17:31:23 UTC (rev 19625)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_interface.h	2009-04-09 18:11:18 UTC (rev 19626)
@@ -46,6 +46,7 @@
 struct PointerRNA;
 struct PropertyRNA;
 struct ReportList;
+struct rcti;
 
 typedef struct uiBut uiBut;
 typedef struct uiBlock uiBlock;
@@ -128,11 +129,12 @@
 #define UI_BUT_ALIGN_DOWN	(1<<17)
 
 #define UI_BUT_DISABLED		(1<<18)
-/* dont draw hilite on mouse over */
+	/* dont draw hilite on mouse over */
 #define UI_NO_HILITE		(1<<19)
 #define UI_BUT_ANIMATED		(1<<20)
 #define UI_BUT_ANIMATED_KEY	(1<<21)
 
+
 /* Button types, bits stored in 1 value... and a short even!
 - bits 0-4:  bitnr (0-31)
 - bits 5-7:  pointer type
@@ -631,5 +633,10 @@
 
 void uiAnimContextProperty(const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop, int *index);
 
+/* Styled text draw */
+void uiFontStyleDraw(struct uiFontStyle *fs, struct rcti *rect, char *str);
+
+
+
 #endif /*  UI_INTERFACE_H */
 

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface.c	2009-04-09 17:31:23 UTC (rev 19625)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface.c	2009-04-09 18:11:18 UTC (rev 19626)
@@ -88,7 +88,7 @@
 
 /* ************ GLOBALS ************* */
 
-static uiFont UIfont[UI_ARRAY];  // no init needed
+static uiFontOld UIfont[UI_ARRAY];  // no init needed
 
 /* ************* translation ************** */
 
@@ -643,11 +643,34 @@
 
 /* ************** BLOCK DRAWING FUNCTION ************* */
 
+/* project button or block (but==NULL) to pixels in regionspace */
+static void ui_but_to_pixelrect(rcti *rect, const ARegion *ar, uiBlock *block, uiBut *but)
+{
+	float gx, gy;
+	float getsizex, getsizey;
+	
+	getsizex= ar->winx;
+	getsizey= ar->winy;
+	
+	gx= (but?but->x1:block->minx) + (block->panel?block->panel->ofsx:0.0f);
+	gy= (but?but->y1:block->miny) + (block->panel?block->panel->ofsy:0.0f);
+	
+	rect->xmin= floor(getsizex*(0.5+ 0.5*(gx*block->winmat[0][0]+ gy*block->winmat[1][0]+ block->winmat[3][0])));
+	rect->ymin= floor(getsizey*(0.5+ 0.5*(gx*block->winmat[0][1]+ gy*block->winmat[1][1]+ block->winmat[3][1])));
+	
+	gx= (but?but->x2:block->maxx) + (block->panel?block->panel->ofsx:0.0f);
+	gy= (but?but->y2:block->maxy) + (block->panel?block->panel->ofsy:0.0f);
+	
+	rect->xmax= floor(getsizex*(0.5+ 0.5*(gx*block->winmat[0][0]+ gy*block->winmat[1][0]+ block->winmat[3][0])));
+	rect->ymax= floor(getsizey*(0.5+ 0.5*(gx*block->winmat[0][1]+ gy*block->winmat[1][1]+ block->winmat[3][1])));
+}
+
 void uiDrawBlock(const bContext *C, uiBlock *block)
 {
 	ARegion *ar;
 	uiBut *but;
-
+	rcti rect;
+	
 	/* get menu region or area region */
 	ar= CTX_wm_menu(C);
 	if(!ar)
@@ -659,13 +682,6 @@
 	/* we set this only once */
 	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 	
-	if(block->flag & UI_BLOCK_LOOP)
-		ui_draw_menu_back(block);
-	else if(block->panel)
-		ui_draw_panel(ar, block);
-
-	if(block->drawextra) block->drawextra(C, block);
-
 	/* pixel space for AA widgets */
 	glMatrixMode(GL_PROJECTION);
 	glPushMatrix();
@@ -675,9 +691,21 @@
 	
 	wmOrtho2(0.0f, ar->winx, 0.0f, ar->winy);
 	
-	for(but= block->buttons.first; but; but= but->next)
-		ui_draw_but(ar, but);
+	/* back */
+	ui_but_to_pixelrect(&rect, ar, block, NULL);
+	if(block->flag & UI_BLOCK_LOOP)
+		ui_draw_menu_back(block, &rect);
+	else if(block->panel)
+		ui_draw_panel(ar, block, &rect);
 
+	if(block->drawextra) block->drawextra(C, block);
+
+	/* widgets */
+	for(but= block->buttons.first; but; but= but->next) {
+		ui_but_to_pixelrect(&rect, ar, block, but);
+		ui_draw_but(ar, but, &rect);
+	}
+	
 	/* restore matrix */
 	glMatrixMode(GL_PROJECTION);
 	glPopMatrix();
@@ -3287,12 +3315,14 @@
 
 void UI_init_userdef()
 {
+	uiStyleInit();
 	ui_text_init_userdef();
 	ui_theme_init_userdef();
 }
 
 void UI_exit(void)
 {
+	uiStyleExit();
 	ui_resources_free();
 }
 

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_intern.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_intern.h	2009-04-09 17:31:23 UTC (rev 19625)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_intern.h	2009-04-09 18:11:18 UTC (rev 19626)
@@ -39,6 +39,7 @@
 struct uiHandleButtonData;
 struct wmEvent;
 struct wmWindow;
+struct uiFontStyle;
 
 /* ****************** general defines ************** */
 
@@ -121,7 +122,7 @@
 
 typedef struct {
 	void *xl, *large, *medium, *small;
-} uiFont;
+} uiFontOld;
 
 typedef struct uiLinkLine {				/* only for draw/edit */
 	struct uiLinkLine *next, *prev;
@@ -361,12 +362,10 @@
 
 /* interface_panel.c */
 extern int ui_handler_panel_region(struct bContext *C, struct wmEvent *event);
-extern void ui_draw_panel(struct ARegion *ar, uiBlock *block);
+extern void ui_draw_panel(struct ARegion *ar, uiBlock *block, rcti *rect);
 
 /* interface_draw.c */
 extern void ui_rasterpos_safe(float x, float y, float aspect);
-extern void ui_draw_tria_icon(float x, float y, float aspect, char dir);
-extern void ui_draw_anti_x(float x1, float y1, float x2, float y2);
 extern void ui_dropshadow(rctf *rct, float radius, float aspect, int select);
 
 extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad);
@@ -383,9 +382,13 @@
 
 /* interface_widgets.c */
 void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3);
-void ui_draw_menu_back(uiBlock *block);
-extern void ui_draw_but(ARegion *ar, uiBut *but);
+void ui_draw_menu_back(uiBlock *block, rcti *rect);
+extern void ui_draw_but(ARegion *ar, uiBut *but, rcti *rect);
 
+/* interface_style.c */
+void uiStyleInit(void);
+void uiStyleExit(void);
+
 /* interface_anim.c */
 void ui_but_anim_flag(uiBut *but, float cfra);
 void ui_but_anim_insert_keyframe(struct bContext *C);

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_panel.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_panel.c	2009-04-09 17:31:23 UTC (rev 19625)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_panel.c	2009-04-09 18:11:18 UTC (rev 19626)
@@ -20,10 +20,8 @@
  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
  * All rights reserved.
  *
- * The Original Code is: all of this file.
+ * Contributor(s): Blender Foundation, 2003-2009 full recode.
  *
- * Contributor(s): none yet.
- *
  * ***** END GPL LICENSE BLOCK *****
  */
 
@@ -451,7 +449,7 @@
 }
 
 /* triangle 'icon' for panel header */
-void ui_draw_tria_icon(float x, float y, float aspect, char dir)
+void ui_draw_tria_icon(float x, float y, char dir)
 {
 	if(dir=='h') {
 		ui_draw_anti_tria( x-1, y, x-1, y+11.0, x+9, y+6.25);
@@ -489,155 +487,17 @@
 
 }
 
-#if 0
-static void ui_set_panel_pattern(char dir)
-{
-	static int firsttime= 1;
-	static GLubyte path[4*32], patv[4*32];
-	int a,b,i=0;
-
-	if(firsttime) {
-		firsttime= 0;
-		for(a=0; a<128; a++) patv[a]= 0x33;
-		for(a=0; a<8; a++) {
-			for(b=0; b<4; b++) path[i++]= 0xff;	/* 1 scanlines */
-			for(b=0; b<12; b++) path[i++]= 0x0;	/* 3 lines */
-		}
-	}
-	glEnable(GL_POLYGON_STIPPLE);
-	if(dir=='h') glPolygonStipple(path);	
-	else glPolygonStipple(patv);	
-}
-#endif
-
-static char *ui_block_cut_str(uiBlock *block, char *str, short okwidth)
-{
-	short width, ofs=strlen(str);
-	static char str1[128];
-	
-	if(ofs>127) return str;
-	
-	width= block->aspect*UI_GetStringWidth(block->curfont, str, ui_translate_buttons());
-
-	if(width <= okwidth) return str;
-	strcpy(str1, str);
-	
-	while(width > okwidth && ofs>0) {
-		ofs--;
-		str1[ofs]= 0;
-		
-		width= block->aspect*UI_GetStringWidth(block->curfont, str1, 0);
-		
-		if(width < 10) break;
-	}
-	return str1;
-}
-
-
 #define PNL_ICON 	20
-#define PNL_DRAGGER	20
 
-
-static void ui_draw_panel_header(ARegion *ar, uiBlock *block)
+static void ui_draw_panel_scalewidget(rcti *rect)
 {
-	Panel *pa, *panel= block->panel;
-	float width;
-	int a, nr= 1, pnl_icons;
-	char *activename= panel->drawname[0]?panel->drawname:panel->panelname;
-	char *panelname, *str;
-	
-	/* count */
-	for(pa= ar->panels.first; pa; pa=pa->next)
-		if(pa->active)
-			if(pa->paneltab==panel)
-				nr++;
-
-	pnl_icons= PNL_ICON+8;
-	if(panel->control & UI_PNL_CLOSE) pnl_icons+= PNL_ICON;
-
-	if(nr==1) {
-		// full header
-		UI_ThemeColorShade(TH_HEADER, -30);
-		uiSetRoundBox(3);
-		uiRoundBox(block->minx, block->maxy, block->maxx, block->maxy+PNL_HEADER, 8);
-
-		/* active tab */
-		/* draw text label */
-		UI_ThemeColor(TH_TEXT_HI);
-		ui_rasterpos_safe(4.0f+block->minx+pnl_icons, block->maxy+5.0f, block->aspect);
-		UI_DrawString(block->curfont, activename, ui_translate_buttons());
-		return;
-	}
-	
-	// tabbed, full header brighter
-	//UI_ThemeColorShade(TH_HEADER, 0);
-	//uiSetRoundBox(3);
-	//uiRoundBox(block->minx, block->maxy, block->maxx, block->maxy+PNL_HEADER, 8);
-
-	a= 0;
-	width= (panel->sizex - 3 - pnl_icons - PNL_ICON)/nr;
-	for(pa= ar->panels.first; pa; pa=pa->next) {
-		panelname= pa->drawname[0]?pa->drawname:pa->panelname;
-		if(a == 0)
-			activename= panelname;
-		
-		if(pa->active==0);
-		else if(pa==panel) {
-			/* active tab */
-		
-			/* draw the active tab */
-			uiSetRoundBox(3);
-			UI_ThemeColorShade(TH_HEADER, -3);
-			uiRoundBox(2+pnl_icons+a*width, panel->sizey-1, pnl_icons+(a+1)*width, panel->sizey+PNL_HEADER-3, 8);
-
-			/* draw the active text label */
-			UI_ThemeColor(TH_TEXT);
-			ui_rasterpos_safe(16+pnl_icons+a*width, panel->sizey+4, block->aspect);
-			if(panelname != activename && strstr(panelname, activename) == panelname)
-				str= ui_block_cut_str(block, panelname+strlen(activename), (short)(width-10));
-			else
-				str= ui_block_cut_str(block, panelname, (short)(width-10));
-			UI_DrawString(block->curfont, str, ui_translate_buttons());
-
-			a++;
-		}
-		else if(pa->paneltab==panel) {
-			/* draw an inactive tab */
-			uiSetRoundBox(3);
-			UI_ThemeColorShade(TH_HEADER, -60);
-			uiRoundBox(2+pnl_icons+a*width, panel->sizey, pnl_icons+(a+1)*width, panel->sizey+PNL_HEADER-3, 8);
-			

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list