[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19637] branches/blender2.5/blender/source /blender: 2.5
Ton Roosendaal
ton at blender.org
Fri Apr 10 16:06:24 CEST 2009
Revision: 19637
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19637
Author: ton
Date: 2009-04-10 16:06:24 +0200 (Fri, 10 Apr 2009)
Log Message:
-----------
2.5
More font style work;
- hooked up almost all ui buttons code to new font
system, including text clipping
- panel headers scale now too to smaller fonts
- added further style hints, for shadow/emboss. Is all going to
be in UI designer control!
- for fun; changed layout engine to spread vertical buttons in
window width
Next: removal of all usage of old font system, using 'styles'.
Will also move font blurring to blenfont module.
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/blenfont/intern/blf_font.c
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_layout.c
branches/blender2.5/blender/source/blender/editors/interface/interface_panel.c
branches/blender2.5/blender/source/blender/editors/interface/interface_regions.c
branches/blender2.5/blender/source/blender/editors/interface/interface_style.c
branches/blender2.5/blender/source/blender/editors/interface/interface_widgets.c
branches/blender2.5/blender/source/blender/makesdna/DNA_userdef_types.h
Modified: branches/blender2.5/blender/source/blender/blenfont/intern/blf_font.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenfont/intern/blf_font.c 2009-04-10 13:16:50 UTC (rev 19636)
+++ branches/blender2.5/blender/source/blender/blenfont/intern/blf_font.c 2009-04-10 14:06:24 UTC (rev 19637)
@@ -154,9 +154,8 @@
pen_x += delta.x >> 6;
}
- /* This only return zero if the clipping is enable and the glyph is out of the clip rctf. */
- if (blf_glyph_render(font, g, (float)pen_x, (float)pen_y) == 0)
- break;
+ /* do not return this loop if clipped, we want every character tested */
+ blf_glyph_render(font, g, (float)pen_x, (float)pen_y);
pen_x += g->advance;
g_prev= g;
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-10 13:16:50 UTC (rev 19636)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_interface.h 2009-04-10 14:06:24 UTC (rev 19637)
@@ -635,7 +635,8 @@
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);
+void uiStyleFontSet(struct uiFontStyle *fs);
+void uiStyleFontDraw(struct uiFontStyle *fs, struct rcti *rect, char *str);
Modified: branches/blender2.5/blender/source/blender/editors/interface/interface.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface.c 2009-04-10 13:16:50 UTC (rev 19636)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface.c 2009-04-10 14:06:24 UTC (rev 19637)
@@ -52,6 +52,8 @@
#include "BIF_gl.h"
#include "BIF_glutil.h"
+#include "BLF_api.h"
+
#include "UI_interface.h"
#include "UI_text.h"
@@ -228,19 +230,21 @@
static void ui_text_bounds_block(uiBlock *block, float offset)
{
+ uiStyle *style= U.uistyles.first; // XXX pass on as arg
uiBut *bt;
int i = 0, j, x1addval= offset, nextcol;
- bt= block->buttons.first;
- while(bt) {
+ uiStyleFontSet(&style->widget);
+
+ for(bt= block->buttons.first; bt; bt= bt->next) {
if(bt->type!=SEPR) {
- int transopts= ui_translate_buttons();
- if(bt->type==TEX || bt->type==IDPOIN) transopts= 0;
- j= UI_GetStringWidth(bt->font, bt->drawstr, transopts);
+ //int transopts= ui_translate_buttons();
+ //if(bt->type==TEX || bt->type==IDPOIN) transopts= 0;
+
+ j= BLF_width(bt->drawstr);
if(j > i) i = j;
}
- bt= bt->next;
}
/* cope with multi collumns */
@@ -643,6 +647,22 @@
/* ************** BLOCK DRAWING FUNCTION ************* */
+static void ui_fontscale(short *points, float aspect)
+{
+ if(aspect < 0.9f || aspect > 1.1f) {
+ float pointsf= *points;
+
+ /* for some reason scaling fonts goes too fast compared to widget size */
+ aspect= sqrt(aspect);
+ pointsf /= aspect;
+
+ if(aspect > 1.0)
+ *points= ceil(pointsf);
+ else
+ *points= floor(pointsf);
+ }
+}
+
/* 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)
{
@@ -665,8 +685,10 @@
rect->ymax= floor(getsizey*(0.5+ 0.5*(gx*block->winmat[0][1]+ gy*block->winmat[1][1]+ block->winmat[3][1])));
}
+/* uses local copy of style, to scale things down, and allow widgets to change stuff */
void uiDrawBlock(const bContext *C, uiBlock *block)
{
+ uiStyle style= *((uiStyle *)U.uistyles.first); // XXX pass on as arg
ARegion *ar;
uiBut *but;
rcti rect;
@@ -682,6 +704,15 @@
/* we set this only once */
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ /* scale fonts */
+ ui_fontscale(&style.paneltitle.points, block->aspect);
+ ui_fontscale(&style.grouplabel.points, block->aspect);
+ ui_fontscale(&style.widgetlabel.points, block->aspect);
+ ui_fontscale(&style.widget.points, block->aspect);
+
+ /* scale block min/max to rect */
+ ui_but_to_pixelrect(&rect, ar, block, NULL);
+
/* pixel space for AA widgets */
glMatrixMode(GL_PROJECTION);
glPushMatrix();
@@ -692,18 +723,17 @@
wmOrtho2(0.0f, ar->winx, 0.0f, ar->winy);
/* back */
- ui_but_to_pixelrect(&rect, ar, block, NULL);
if(block->flag & UI_BLOCK_LOOP)
- ui_draw_menu_back(block, &rect);
+ ui_draw_menu_back(&style, block, &rect);
else if(block->panel)
- ui_draw_panel(ar, block, &rect);
+ ui_draw_panel(ar, &style, 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);
+ ui_draw_but(ar, &style, but, &rect);
}
/* restore matrix */
@@ -1876,14 +1906,6 @@
BLI_strncpy(block->name, name, sizeof(block->name));
-#if 0
- /* draw win */
- block->win= win;
- /* window where queue event should be added, pretty weak this way!
- this is because the 'mainwin' pup menu's */
- block->winq= mywinget();
-#endif
-
block->dt= dt;
block->themecol= TH_AUTO;
@@ -1908,8 +1930,6 @@
block->flag |= UI_BLOCK_LOOP; /* tag as menu */
}
- uiSetCurFont(block, font);
-
return block;
}
@@ -1931,7 +1951,6 @@
double value;
float okwidth;
int transopts= ui_translate_buttons();
- short pos;
ui_is_but_sel(but);
@@ -2076,55 +2095,8 @@
strcpy(but->drawstr, but->str);
strcat(but->drawstr, but->editstr);
}
-
- if(but->drawstr[0]) {
- but->strwidth= but->aspect*UI_GetStringWidth(but->font, but->drawstr, transopts);
- // here should be check for less space for icon offsets...
- if(but->type==MENU) okwidth -= 15;
- }
- else
- but->strwidth= 0;
-
- /* automatic width */
- if(but->x2==0.0f && but->x1 > 0.0f) {
- but->x2= (but->x1+but->strwidth+6);
- }
-
- if(but->strwidth==0) but->drawstr[0]= 0;
- else if(but->block->flag & UI_BLOCK_LOOP); // no clip string, uiTextBoundsBlock is used (hack!)
- else {
-
- /* calc but->ofs, to draw the string shorter if too long */
- but->ofs= 0;
-
- while(but->strwidth > (int)okwidth ) {
- if ELEM3(but->type, NUM, NUMABS, TEX) { // only these cut off left
- but->ofs++;
- but->strwidth= but->aspect*UI_GetStringWidth(but->font, but->drawstr+but->ofs, transopts);
-
- /* textbut exception */
- if(but->editstr && but->pos != -1) {
- pos= but->pos+strlen(but->str);
- if(pos-1 < but->ofs) {
- pos= but->ofs-pos+1;
- but->ofs -= pos;
- if(but->ofs<0) {
- but->ofs= 0;
- pos--;
- }
- but->drawstr[ strlen(but->drawstr)-pos ]= 0;
- }
- }
- }
- else {
- but->drawstr[ strlen(but->drawstr)-1 ]= 0;
- but->strwidth= but->aspect*UI_GetStringWidth(but->font, but->drawstr, transopts);
- }
-
- if(but->strwidth < 10) break;
- }
- }
+ /* text clipping moved to widget drawing code itself */
}
static int ui_auto_themecol(uiBut *but)
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-10 13:16:50 UTC (rev 19636)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_intern.h 2009-04-10 14:06:24 UTC (rev 19637)
@@ -40,6 +40,7 @@
struct wmEvent;
struct wmWindow;
struct uiFontStyle;
+struct uiStyle;
/* ****************** general defines ************** */
@@ -362,7 +363,7 @@
/* 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, rcti *rect);
+extern void ui_draw_panel(struct ARegion *ar, struct uiStyle *style, uiBlock *block, rcti *rect);
/* interface_draw.c */
extern void ui_rasterpos_safe(float x, float y, float aspect);
@@ -382,13 +383,14 @@
/* 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, rcti *rect);
-extern void ui_draw_but(ARegion *ar, uiBut *but, rcti *rect);
+void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect);
+extern void ui_draw_but(ARegion *ar, struct uiStyle *style, 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_layout.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c 2009-04-10 13:16:50 UTC (rev 19636)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c 2009-04-10 14:06:24 UTC (rev 19637)
@@ -940,7 +940,10 @@
if(pt->draw && (!pt->poll || pt->poll(C))) {
block= uiBeginBlock(C, ar, pt->idname, UI_EMBOSS, UI_HELV);
- w= (ar->type->minsizex)? ar->type->minsizex-22: UI_PANEL_WIDTH-22;
+ if(vertical)
+ w= (ar->type->minsizex)? ar->type->minsizex-12: ar->winx-12;
+ else
+ w= (ar->type->minsizex)? ar->type->minsizex-12: UI_PANEL_WIDTH-12;
if(uiNewPanel(C, ar, block, pt->name, pt->name, x, y, w, 0)) {
panel= uiPanelFromBlock(block);
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-10 13:16:50 UTC (rev 19636)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_panel.c 2009-04-10 14:06:24 UTC (rev 19637)
@@ -570,7 +570,7 @@
hrect.ymin= rect->ymax;
hrect.xmax= rect->xmax;
hrect.ymax= rect->ymax + PNL_HEADER;
- uiFontStyleDraw(&style->paneltitle, &hrect, activename);
+ uiStyleFontDraw(&style->paneltitle, &hrect, activename);
return;
}
@@ -591,16 +591,15 @@
hrect.ymin= rect->ymax;
hrect.xmax= hrect.xmin + width;
hrect.ymax= hrect.ymin + PNL_HEADER;
- uiFontStyleDraw(&style->paneltitle, &hrect, panelname);
+ uiStyleFontDraw(&style->paneltitle, &hrect, panelname);
a++;
}
}
}
-void ui_draw_panel(ARegion *ar, uiBlock *block, rcti *rect)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list