Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2009-04-09 22:11:18 +0400
committerTon Roosendaal <ton@blender.org>2009-04-09 22:11:18 +0400
commit79c30a0752105130f90102915ed8b6471b50146d (patch)
treed1d973a05dc5fa6de48c69fcdfc910592b64f153 /source
parent46d8c1ebc7bd3069f3295de6b4299802a0dee9c9 (diff)
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!
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/include/UI_interface.h9
-rw-r--r--source/blender/editors/interface/interface.c52
-rw-r--r--source/blender/editors/interface/interface_intern.h15
-rw-r--r--source/blender/editors/interface/interface_panel.c449
-rw-r--r--source/blender/editors/interface/interface_style.c202
-rw-r--r--source/blender/editors/interface/interface_widgets.c145
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h85
-rw-r--r--source/blender/windowmanager/intern/wm_files.c5
8 files changed, 454 insertions, 508 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index cb5c2da477f..7c36f89cb41 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -46,6 +46,7 @@ struct Panel;
struct PointerRNA;
struct PropertyRNA;
struct ReportList;
+struct rcti;
typedef struct uiBut uiBut;
typedef struct uiBlock uiBlock;
@@ -128,11 +129,12 @@ typedef struct uiPopupBlockHandle uiPopupBlockHandle;
#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 uiRegionHeaderLayout(const struct bContext *C, struct ARegion *ar);
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 */
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index e548bbd76ca..5a1b8fb6118 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -88,7 +88,7 @@ static void ui_rna_ID_autocomplete(bContext *C, char *str, void *arg_but);
/* ************ GLOBALS ************* */
-static uiFont UIfont[UI_ARRAY]; // no init needed
+static uiFontOld UIfont[UI_ARRAY]; // no init needed
/* ************* translation ************** */
@@ -643,11 +643,34 @@ void uiEndBlock(const bContext *C, uiBlock *block)
/* ************** 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 @@ void uiDrawBlock(const bContext *C, uiBlock *block)
/* 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 @@ void uiDrawBlock(const bContext *C, uiBlock *block)
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(void)
void UI_init_userdef()
{
+ uiStyleInit();
ui_text_init_userdef();
ui_theme_init_userdef();
}
void UI_exit(void)
{
+ uiStyleExit();
ui_resources_free();
}
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index e5f803dec33..2e975c871cf 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -39,6 +39,7 @@ struct IDProperty;
struct uiHandleButtonData;
struct wmEvent;
struct wmWindow;
+struct uiFontStyle;
/* ****************** general defines ************** */
@@ -121,7 +122,7 @@ typedef struct {
typedef struct {
void *xl, *large, *medium, *small;
-} uiFont;
+} uiFontOld;
typedef struct uiLinkLine { /* only for draw/edit */
struct uiLinkLine *next, *prev;
@@ -361,12 +362,10 @@ void autocomplete_end(struct AutoComplete *autocpl, char *autoname);
/* 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,8 +382,12 @@ extern void ui_button_active_cancel(const struct bContext *C, uiBut *but);
/* 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);
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 70c5e1887c2..be14c963136 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -20,9 +20,7 @@
* 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): none yet.
+ * Contributor(s): Blender Foundation, 2003-2009 full recode.
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -451,7 +449,7 @@ uiBlock *uiFindOpenPanelBlockName(ListBase *lb, char *name)
}
/* 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 @@ static void ui_draw_x_icon(float x, float y)
}
-#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)
-{
- 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);
-
- /* draw an inactive tab label */
- UI_ThemeColorShade(TH_TEXT_HI, -40);
- 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++;
- }
- }
-
- // dragger
- /*
- uiSetRoundBox(15);
- UI_ThemeColorShade(TH_HEADER, -70);
- uiRoundBox(panel->sizex-PNL_ICON+5, panel->sizey+5, panel->sizex-5, panel->sizey+PNL_HEADER-5, 5);
- */
-
-}
-
-static void ui_draw_panel_scalewidget(uiBlock *block)
+static void ui_draw_panel_scalewidget(rcti *rect)
{
float xmin, xmax, dx;
float ymin, ymax, dy;
- xmin= block->maxx-PNL_HEADER+2;
- xmax= block->maxx-3;
- ymin= block->miny+3;
- ymax= block->miny+PNL_HEADER-2;
+ xmin= rect->xmax-PNL_HEADER+2;
+ xmax= rect->xmax-3;
+ ymin= rect->ymin+3;
+ ymax= rect->ymin+PNL_HEADER-2;
dx= 0.5f*(xmax-xmin);
dy= 0.5f*(ymax-ymin);
@@ -648,20 +508,20 @@ static void ui_draw_panel_scalewidget(uiBlock *block)
fdrawline(xmin+dx, ymin, xmax, ymax-dy);
glColor4ub(0, 0, 0, 50);
- fdrawline(xmin, ymin+block->aspect, xmax, ymax+block->aspect);
- fdrawline(xmin+dx, ymin+block->aspect, xmax, ymax-dy+block->aspect);
+ fdrawline(xmin, ymin+1, xmax, ymax+1);
+ fdrawline(xmin+dx, ymin+1, xmax, ymax-dy+1);
glDisable(GL_BLEND);
}
-static void ui_draw_panel_dragwidget(uiBlock *block)
+static void ui_draw_panel_dragwidget(rcti *rect)
{
float xmin, xmax, dx;
float ymin, ymax, dy;
- xmin= block->maxx-10-PNL_HEADER+8;
- xmax= block->maxx-10;
- ymin= block->maxy+4;
- ymax= block->maxy+PNL_HEADER-4;
+ xmin= rect->xmax-10-PNL_HEADER+8;
+ xmax= rect->xmax-10;
+ ymin= rect->ymax+4;
+ ymax= rect->ymax+PNL_HEADER-4;
dx= 0.333f*(xmax-xmin);
dy= 0.333f*(ymax-ymin);
@@ -673,203 +533,23 @@ static void ui_draw_panel_dragwidget(uiBlock *block)
fdrawline(xmin+2*dx, ymax, xmax, ymin+2*dy);
glColor4ub(0, 0, 0, 50);
- fdrawline(xmin, ymax+block->aspect, xmax, ymin+block->aspect);
- fdrawline(xmin+dx, ymax+block->aspect, xmax, ymin+dy+block->aspect);
- fdrawline(xmin+2*dx, ymax+block->aspect, xmax, ymin+2*dy+block->aspect);
+ fdrawline(xmin, ymax+1, xmax, ymin+1);
+ fdrawline(xmin+dx, ymax+1, xmax, ymin+dy+1);
+ fdrawline(xmin+2*dx, ymax+1, xmax, ymin+2*dy+1);
glDisable(GL_BLEND);
}
-static void ui_draw_panel_old(ARegion *ar, uiBlock *block)
+static void ui_draw_panel_header_style(ARegion *ar, uiStyle *style, Panel *panel, rcti *rect)
{
- Panel *panel= block->panel;
- int ofsx;
- char *panelname= panel->drawname[0]?panel->drawname:panel->panelname;
-
- if(panel->paneltab) return;
-
- /* if the panel is minimized vertically:
- * (------)
- */
- if(panel->flag & PNL_CLOSEDY) {
- /* draw a little rounded box, the size of the header */
- uiSetRoundBox(15);
- UI_ThemeColorShade(TH_HEADER, -30);
- uiRoundBox(block->minx, block->maxy, block->maxx, block->maxy+PNL_HEADER, 8);
-
- /* title */
- ofsx= PNL_ICON+8;
- if(panel->control & UI_PNL_CLOSE) ofsx+= PNL_ICON;
- UI_ThemeColor(TH_TEXT_HI);
- ui_rasterpos_safe(4+block->minx+ofsx, block->maxy+5, block->aspect);
- UI_DrawString(block->curfont, panelname, ui_translate_buttons());
-
- /* border */
- if(panel->flag & PNL_SELECT) {
- UI_ThemeColorShade(TH_HEADER, -120);
- uiRoundRect(block->minx, block->maxy, block->maxx, block->maxy+PNL_HEADER, 8);
- }
- /* if it's being overlapped by a panel being dragged */
- if(panel->flag & PNL_OVERLAP) {
- UI_ThemeColor(TH_TEXT_HI);
- uiRoundRect(block->minx, block->maxy, block->maxx, block->maxy+PNL_HEADER, 8);
- }
-
- }
- /* if the panel is minimized horizontally:
- * /-\
- * |
- * |
- * |
- * \_/
- */
- else if(panel->flag & PNL_CLOSEDX) {
- char str[4];
- int a, end, ofs;
-
- /* draw a little rounded box, the size of the header, rotated 90 deg */
- uiSetRoundBox(15);
- UI_ThemeColorShade(TH_HEADER, -30);
- uiRoundBox(block->minx, block->miny, block->minx+PNL_HEADER, block->maxy+PNL_HEADER, 8);
-
- /* title, only the initial character for now */
- UI_ThemeColor(TH_TEXT_HI);
- str[1]= 0;
- end= strlen(panelname);
- ofs= 20;
- for(a=0; a<end; a++) {
- str[0]= panelname[a];
- if( isupper(str[0]) ) {
- ui_rasterpos_safe(block->minx+5, block->maxy-ofs, block->aspect);
- UI_DrawString(block->curfont, str, 0);
- ofs+= 15;
- }
- }
-
- /* border */
- if(panel->flag & PNL_SELECT) {
- UI_ThemeColorShade(TH_HEADER, -120);
- uiRoundRect(block->minx, block->miny, block->minx+PNL_HEADER, block->maxy+PNL_HEADER, 8);
- }
- if(panel->flag & PNL_OVERLAP) {
- UI_ThemeColor(TH_TEXT_HI);
- uiRoundRect(block->minx, block->miny, block->minx+PNL_HEADER, block->maxy+PNL_HEADER, 8);
- }
-
- }
- /* an open panel */
- else {
- /* all panels now... */
- if(panel->control & UI_PNL_SOLID) {
- UI_ThemeColorShade(TH_HEADER, -30);
-
- uiSetRoundBox(3);
- uiRoundBox(block->minx, block->maxy, block->maxx, block->maxy+PNL_HEADER, 8);
-
- glEnable(GL_BLEND);
- UI_ThemeColor4(TH_PANEL);
-
- uiSetRoundBox(12);
- /* bad code... but its late :) */
- if(strcmp(block->name, "image_panel_preview")==0)
- uiRoundRect(block->minx, block->miny, block->maxx, block->maxy, 8);
- else
- uiRoundBox(block->minx, block->miny, block->maxx, block->maxy, 8);
-
- // glRectf(block->minx, block->miny, block->maxx, block->maxy);
-
- /* shadow */
- /*
- glColor4ub(0, 0, 0, 40);
-
- fdrawline(block->minx+2, block->miny-1, block->maxx+1, block->miny-1);
- fdrawline(block->maxx+1, block->miny-1, block->maxx+1, block->maxy+7);
-
- glColor4ub(0, 0, 0, 10);
-
- fdrawline(block->minx+3, block->miny-2, block->maxx+2, block->miny-2);
- fdrawline(block->maxx+2, block->miny-2, block->maxx+2, block->maxy+6);
-
- */
-
- glDisable(GL_BLEND);
- }
- /* floating panel */
- else if(panel->control & UI_PNL_TRANSP) {
- UI_ThemeColorShade(TH_HEADER, -30);
- uiSetRoundBox(3);
- uiRoundBox(block->minx, block->maxy, block->maxx, block->maxy+PNL_HEADER, 8);
-
- glEnable(GL_BLEND);
- UI_ThemeColor4(TH_PANEL);
- glRectf(block->minx, block->miny, block->maxx, block->maxy);
-
- glDisable(GL_BLEND);
- }
-
- /* draw the title, tabs, etc in the header */
- ui_draw_panel_header(ar, block);
-
- /* in some occasions, draw a border */
- if(panel->flag & PNL_SELECT) {
- if(panel->control & UI_PNL_SOLID) uiSetRoundBox(15);
- else uiSetRoundBox(3);
-
- UI_ThemeColorShade(TH_HEADER, -120);
- uiRoundRect(block->minx, block->miny, block->maxx, block->maxy+PNL_HEADER, 8);
- }
- if(panel->flag & PNL_OVERLAP) {
- if(panel->control & UI_PNL_SOLID) uiSetRoundBox(15);
- else uiSetRoundBox(3);
-
- UI_ThemeColor(TH_TEXT_HI);
- uiRoundRect(block->minx, block->miny, block->maxx, block->maxy+PNL_HEADER, 8);
- }
-
- if(panel->control & UI_PNL_SCALE)
- ui_draw_panel_scalewidget(block);
-
- /* and a soft shadow-line for now */
- /*
- glEnable( GL_BLEND );
- glColor4ub(0, 0, 0, 50);
- fdrawline(block->maxx, block->miny, block->maxx, block->maxy+PNL_HEADER/2);
- fdrawline(block->minx, block->miny, block->maxx, block->miny);
- glDisable(GL_BLEND);
- */
-
- }
-
- /* draw optional close icon */
-
- ofsx= 6;
- if(panel->control & UI_PNL_CLOSE) {
-
- ui_draw_x_icon(block->minx+2+ofsx, block->maxy+5);
- ofsx= 22;
- }
-
- /* draw collapse icon */
-
- UI_ThemeColor(TH_TEXT_HI);
-
- if(panel->flag & PNL_CLOSEDY)
- ui_draw_tria_icon(block->minx+6+ofsx, block->maxy+5, block->aspect, 'h');
- else if(panel->flag & PNL_CLOSEDX)
- ui_draw_tria_icon(block->minx+7, block->maxy+2, block->aspect, 'h');
- else
- ui_draw_tria_icon(block->minx+6+ofsx, block->maxy+5, block->aspect, 'v');
-}
-
-static void ui_draw_panel_header_style(ARegion *ar, uiBlock *block)
-{
- Panel *pa, *panel= block->panel;
+ Panel *pa;
+ rcti hrect;
float width;
int a, nr= 1, pnl_icons;
char *activename= panel->drawname[0]?panel->drawname:panel->panelname;
- char *panelname, *str;
+ char *panelname;
- ui_draw_panel_dragwidget(block);
+ ui_draw_panel_dragwidget(rect);
/* count */
for(pa= ar->panels.first; pa; pa=pa->next)
@@ -881,11 +561,17 @@ static void ui_draw_panel_header_style(ARegion *ar, uiBlock *block)
if(panel->control & UI_PNL_CLOSE) pnl_icons+= PNL_ICON;
if(nr==1) {
+
/* active tab */
/* draw text label */
UI_ThemeColor(TH_TEXT);
- ui_rasterpos_safe(4.0f+block->minx+pnl_icons, block->maxy+5.0f, block->aspect);
- UI_DrawString(block->curfont, activename, ui_translate_buttons());
+
+ hrect.xmin= rect->xmin+pnl_icons;
+ hrect.ymin= rect->ymax;
+ hrect.xmax= rect->xmax;
+ hrect.ymax= rect->ymax + PNL_HEADER;
+ uiFontStyleDraw(&style->paneltitle, &hrect, activename);
+
return;
}
@@ -893,44 +579,28 @@ static void ui_draw_panel_header_style(ARegion *ar, uiBlock *block)
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) {
+ if(pa->active && (pa==panel || pa->paneltab==panel)) {
/* active tab */
-
- /* 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));
+ if(pa==panel)
+ UI_ThemeColor(TH_TEXT);
else
- str= ui_block_cut_str(block, panelname, (short)(width-10));
- UI_DrawString(block->curfont, str, ui_translate_buttons());
+ UI_ThemeColorBlend(TH_TEXT, TH_BACK, 0.5f);
- a++;
- }
- else if(pa->paneltab==panel) {
-
- /* draw an inactive tab label */
- UI_ThemeColorBlend(TH_TEXT, TH_BACK, 0.5f);
- 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());
+ hrect.xmin= rect->xmin+pnl_icons + a*width;
+ hrect.ymin= rect->ymax;
+ hrect.xmax= hrect.xmin + width;
+ hrect.ymax= hrect.ymin + PNL_HEADER;
+ uiFontStyleDraw(&style->paneltitle, &hrect, panelname);
a++;
}
}
}
-
-/* XXX has follow style definitions still */
-static void ui_draw_panel_style(ARegion *ar, uiBlock *block)
+void ui_draw_panel(ARegion *ar, uiBlock *block, rcti *rect)
{
+ uiStyle *style= U.uistyles.first; // XXX pass on
Panel *panel= block->panel, *prev;
int ofsx;
@@ -944,21 +614,21 @@ static void ui_draw_panel_style(ARegion *ar, uiBlock *block)
}
if(prev) {
- float minx= block->minx+10;
- float maxx= block->maxx-10;
- float y= block->maxy + PNL_HEADER;
+ float minx= rect->xmin+10;
+ float maxx= rect->xmax-10;
+ float y= rect->ymax + PNL_HEADER;
glEnable(GL_BLEND);
glColor4f(0.0f, 0.0f, 0.0f, 0.5f);
fdrawline(minx, y, maxx, y);
glColor4f(1.0f, 1.0f, 1.0f, 0.25f);
- fdrawline(minx, y-block->aspect, maxx, y-block->aspect);
+ fdrawline(minx, y-1, maxx, y-1);
glDisable(GL_BLEND);
}
/* title */
if(!(panel->flag & PNL_CLOSEDX)) {
- ui_draw_panel_header_style(ar, block);
+ ui_draw_panel_header_style(ar, style, panel, rect);
}
/* if the panel is minimized vertically:
@@ -970,7 +640,7 @@ static void ui_draw_panel_style(ARegion *ar, uiBlock *block)
/* if it's being overlapped by a panel being dragged */
if(panel->flag & PNL_OVERLAP) {
UI_ThemeColor(TH_TEXT_HI);
- uiRoundRect(block->minx, block->maxy, block->maxx, block->maxy+PNL_HEADER, 8);
+ uiRoundRect(rect->xmin, rect->ymax, rect->xmax, rect->ymax+PNL_HEADER, 8);
}
}
@@ -986,18 +656,18 @@ static void ui_draw_panel_style(ARegion *ar, uiBlock *block)
else uiSetRoundBox(3);
UI_ThemeColorShade(TH_HEADER, -120);
- uiRoundRect(block->minx, block->miny, block->maxx, block->maxy+PNL_HEADER, 8);
+ uiRoundRect(rect->xmin, rect->ymin, rect->xmax, rect->ymax+PNL_HEADER, 8);
}
if(panel->flag & PNL_OVERLAP) {
if(panel->control & UI_PNL_SOLID) uiSetRoundBox(15);
else uiSetRoundBox(3);
UI_ThemeColor(TH_TEXT_HI);
- uiRoundRect(block->minx, block->miny, block->maxx, block->maxy+PNL_HEADER, 8);
+ uiRoundRect(rect->xmin, rect->ymin, rect->xmax, rect->ymax+PNL_HEADER, 8);
}
if(panel->control & UI_PNL_SCALE)
- ui_draw_panel_scalewidget(block);
+ ui_draw_panel_scalewidget(rect);
}
/* draw optional close icon */
@@ -1005,7 +675,7 @@ static void ui_draw_panel_style(ARegion *ar, uiBlock *block)
ofsx= 6;
if(panel->control & UI_PNL_CLOSE) {
- ui_draw_x_icon(block->minx+2+ofsx, block->maxy+2);
+ ui_draw_x_icon(rect->xmin+2+ofsx, rect->ymax+2);
ofsx= 22;
}
@@ -1013,23 +683,16 @@ static void ui_draw_panel_style(ARegion *ar, uiBlock *block)
UI_ThemeColor(TH_TEXT);
if(panel->flag & PNL_CLOSEDY)
- ui_draw_tria_icon(block->minx+6+ofsx, block->maxy+1, block->aspect, 'h');
+ ui_draw_tria_icon(rect->xmin+6+ofsx, rect->ymax+3, 'h');
else if(panel->flag & PNL_CLOSEDX)
- ui_draw_tria_icon(block->minx+7, block->maxy+1, block->aspect, 'h');
+ ui_draw_tria_icon(rect->xmin+7, rect->ymax+3, 'h');
else
- ui_draw_tria_icon(block->minx+6+ofsx, block->maxy+1, block->aspect, 'v');
+ ui_draw_tria_icon(rect->xmin+6+ofsx, rect->ymax+3, 'v');
}
-void ui_draw_panel(ARegion *ar, uiBlock *block)
-{
- ui_draw_panel_style(ar, block);
-
- if(0) ui_draw_panel_old(ar, block); // XXX
-}
-
/* ------------ panel alignment ---------------- */
@@ -1352,17 +1015,13 @@ void uiEndPanels(const bContext *C, ARegion *ar)
/* draw panels, selected on top */
for(block= ar->uiblocks.first; block; block=block->next) {
if(block->active && block->panel && !(block->panel->flag & PNL_SELECT)) {
- uiPanelPush(block);
uiDrawBlock(C, block);
- uiPanelPop(block);
}
}
for(block= ar->uiblocks.first; block; block=block->next) {
if(block->active && block->panel && (block->panel->flag & PNL_SELECT)) {
- uiPanelPush(block);
uiDrawBlock(C, block);
- uiPanelPop(block);
}
}
}
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c
new file mode 100644
index 00000000000..4d9ebcf05c2
--- /dev/null
+++ b/source/blender/editors/interface/interface_style.c
@@ -0,0 +1,202 @@
+/**
+* ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2009 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <limits.h>
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_ID.h"
+#include "DNA_screen_types.h"
+#include "DNA_userdef_types.h"
+#include "DNA_windowmanager_types.h"
+
+#include "BLI_arithb.h"
+#include "BLI_listbase.h"
+#include "BLI_rect.h"
+#include "BLI_string.h"
+
+#include "BKE_context.h"
+#include "BKE_global.h"
+#include "BKE_utildefines.h"
+
+#include "BIF_gl.h"
+#include "BIF_glutil.h"
+
+#include "BLF_api.h"
+
+#include "UI_interface.h"
+#include "UI_interface_icons.h"
+#include "UI_resources.h"
+#include "UI_text.h"
+#include "UI_view2d.h"
+
+#include "ED_datafiles.h"
+#include "ED_util.h"
+#include "ED_types.h"
+
+#include "interface_intern.h"
+
+
+/* style + theme + layout-engine = UI */
+
+/*
+ This is a complete set of layout rules, the 'state' of the Layout
+ Engine. Multiple styles are possible, defined via C or Python. Styles
+ get a name, and will typically get activated per region type, like
+ "Header", or "Listview" or "Toolbar". Properties of Style definitions
+ are:
+
+ - default collumn properties, internal spacing, aligning, min/max width
+ - button alignment rules (for groups)
+ - label placement rules
+ - internal labeling or external labeling default
+ - default minimum widths for buttons/labels (in amount of characters)
+ - font types, styles and relative sizes for Panel titles, labels, etc.
+
+*/
+
+
+/* ********************************************** */
+
+static uiStyle *ui_style_new(ListBase *styles, const char *name)
+{
+ uiStyle *style= MEM_callocN(sizeof(uiStyle), "new style");
+
+ BLI_addtail(styles, style);
+ BLI_strncpy(style->name, name, MAX_STYLE_NAME);
+
+ style->paneltitle.uifont_id= UIFONT_DEFAULT;
+ style->paneltitle.points= 14;
+ style->paneltitle.shadow= 3;
+ style->paneltitle.shadowalpha= 0.25f;
+
+ style->grouplabel.uifont_id= UIFONT_DEFAULT;
+ style->grouplabel.points= 12;
+ style->paneltitle.shadow= 3;
+ style->grouplabel.shadowalpha= 0.25f;
+
+ style->widgetlabel.uifont_id= UIFONT_DEFAULT;
+ style->widgetlabel.points= 11;
+ style->widgetlabel.shadowalpha= 0.25f;
+
+ style->widget.uifont_id= UIFONT_DEFAULT;
+ style->widget.points= 11;
+ style->widget.shadowalpha= 0.25f;
+
+ return style;
+}
+
+static uiFont *uifont_to_blfont(int id)
+{
+ uiFont *font= U.uifonts.first;
+
+ for(; font; font= font->next) {
+ if(font->uifont_id==id) {
+ return font;
+ }
+ }
+ return NULL;
+}
+
+/* *************** draw ************************ */
+
+void uiFontStyleDraw(uiFontStyle *fs, rcti *rect, char *str)
+{
+ uiFont *font= uifont_to_blfont(fs->uifont_id);
+ float height;
+ int xofs=0, yofs;
+
+ BLF_set(font->blf_id);
+ BLF_size(fs->points, U.dpi);
+
+ height= BLF_height("A");
+ yofs= floor( 0.5f*(rect->ymax - rect->ymin - height));
+
+ if(fs->align==UI_STYLE_TEXT_CENTER)
+ xofs= floor( 0.5f*(rect->xmax - rect->xmin - BLF_width(str)));
+
+ BLF_position(rect->xmin+xofs, rect->ymin+yofs, 0.0f);
+
+ BLF_draw(str);
+}
+
+
+/* ************** init exit ************************ */
+
+/* called on each .B.blend read */
+/* reading without uifont will create one */
+void uiStyleInit(void)
+{
+ uiFont *font= U.uifonts.first;
+ uiStyle *style= U.uistyles.first;
+
+ /* recover from uninitialized dpi */
+ CLAMP(U.dpi, 72, 240);
+
+ /* default builtin */
+ if(font==NULL) {
+ font= MEM_callocN(sizeof(uiFont), "ui font");
+ BLI_addtail(&U.uifonts, font);
+
+ strcpy(font->filename, "default");
+ font->uifont_id= UIFONT_DEFAULT;
+ }
+
+ for(font= U.uifonts.first; font; font= font->next) {
+
+ if(font->uifont_id==UIFONT_DEFAULT) {
+ font->blf_id= BLF_load_mem("default", (unsigned char*)datatoc_bfont_ttf, datatoc_bfont_ttf_size);
+ }
+ else {
+ font->blf_id= BLF_load(font->filename);
+ if(font->blf_id == -1)
+ font->blf_id= BLF_load_mem("default", (unsigned char*)datatoc_bfont_ttf, datatoc_bfont_ttf_size);
+ }
+
+ if (font->blf_id == -1)
+ printf("uiStyleInit error, no fonts available\n");
+ else {
+ BLF_set(font->blf_id);
+ BLF_size(11, U.dpi); /* ? just for speed to initialize? */
+ BLF_size(12, U.dpi);
+ BLF_size(14, U.dpi);
+ }
+ }
+
+ if(style==NULL) {
+ ui_style_new(&U.uistyles, "Default Style");
+ }
+}
+
+
+void uiStyleExit(void)
+{
+ BLI_freelistN(&U.uifonts);
+ BLI_freelistN(&U.uistyles);
+
+}
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index dc409be3058..958cde4efe4 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -32,6 +32,7 @@
#include "DNA_ID.h"
#include "DNA_screen_types.h"
+#include "DNA_userdef_types.h"
#include "DNA_windowmanager_types.h"
#include "BLI_arithb.h"
@@ -131,7 +132,7 @@ typedef struct uiWidgetType {
void (*state)(struct uiWidgetType *, int state);
void (*draw)(uiWidgetColors *, rcti *, int state, int roundboxalign);
void (*custom)(uiBut *, uiWidgetColors *, rcti *, int state, int roundboxalign);
- void (*text)(uiBut *, rcti *, float *col);
+ void (*text)(uiStyle *style, uiBut *, rcti *, float *col);
} uiWidgetType;
@@ -699,42 +700,39 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, int blend, rcti *rect)
-static void widget_draw_text(uiBut *but, float x, float y)
+static void widget_draw_text(uiStyle *style, uiBut *but, rcti *rect)
{
- int transopts;
- int len;
+// int transopts;
char *cpoin;
- ui_rasterpos_safe(x, y, but->aspect);
- if(but->type==IDPOIN) transopts= 0; // no translation, of course!
- else transopts= ui_translate_buttons();
+// ui_rasterpos_safe(x, y, but->aspect);
+// if(but->type==IDPOIN) transopts= 0; // no translation, of course!
+// else transopts= ui_translate_buttons();
/* cut string in 2 parts */
cpoin= strchr(but->drawstr, '|');
if(cpoin) *cpoin= 0;
-#ifdef INTERNATIONAL
- if (but->type == FTPREVIEW)
- FTF_DrawNewFontString (but->drawstr+but->ofs, FTF_INPUT_UTF8);
+ if(but->flag & UI_TEXT_LEFT)
+ style->widget.align= UI_STYLE_TEXT_LEFT;
else
- UI_DrawString(but->font, but->drawstr+but->ofs, transopts);
-#else
- UI_DrawString(but->font, but->drawstr+but->ofs, transopts);
-#endif
+ style->widget.align= UI_STYLE_TEXT_CENTER;
- /* part text right aligned */
+ // XXX finish cutting
+ uiFontStyleDraw(&style->widget, rect, but->drawstr+but->ofs);
+
+ /* part text right aligned */
if(cpoin) {
- len= UI_GetStringWidth(but->font, cpoin+1, ui_translate_buttons());
- ui_rasterpos_safe( but->x2 - len*but->aspect-3, y, but->aspect);
- UI_DrawString(but->font, cpoin+1, ui_translate_buttons());
+// int len= UI_GetStringWidth(but->font, cpoin+1, ui_translate_buttons());
+// ui_rasterpos_safe( but->x2 - len*but->aspect-3, y, but->aspect);
+// UI_DrawString(but->font, cpoin+1, ui_translate_buttons());
*cpoin= '|';
}
}
/* draws text and icons for buttons */
-static void widget_draw_text_icon(uiBut *but, rcti *rect, float *col)
+static void widget_draw_text_icon(uiStyle *style, uiBut *but, rcti *rect, float *col)
{
- float x, y;
short t, pos, ch;
short selsta_tmp, selend_tmp, selsta_draw, selwidth_draw;
@@ -808,28 +806,19 @@ static void widget_draw_text_icon(uiBut *but, rcti *rect, float *col)
/* If there's an icon too (made with uiDefIconTextBut) then draw the icon
and offset the text label to accomodate it */
- if ( (but->flag & UI_HAS_ICON) && (but->flag & UI_ICON_LEFT) )
- {
+ if ( (but->flag & UI_HAS_ICON) && (but->flag & UI_ICON_LEFT) ) {
widget_draw_icon(but, but->icon, 0, rect);
- if(but->editstr || (but->flag & UI_TEXT_LEFT)) x= rect->xmin + but->aspect*UI_icon_get_width(but->icon)+5.0;
- else x= (rect->xmin+rect->xmax-but->strwidth+1)/2.0;
- }
- else
- {
- if(but->editstr || (but->flag & UI_TEXT_LEFT))
- x= rect->xmin+4.0;
- else if ELEM3(but->type, TOG, TOGN, TOG3)
- x= rect->xmin+28.0; /* offset for checkmark */
- else
- x= (rect->xmin+rect->xmax-but->strwidth+1)/2.0;
+ rect->xmin += UI_icon_get_width(but->icon);
+
+ if(but->editstr || (but->flag & UI_TEXT_LEFT))
+ rect->xmin += 5;
}
-
- /* position and draw */
- y = (rect->ymin+rect->ymax- 9.0)/2.0;
+ else if(but->flag & UI_TEXT_LEFT)
+ rect->xmin += 5;
glColor3fv(col);
- widget_draw_text(but, x, y);
+ widget_draw_text(style, but, rect);
}
/* if there's no text label, then check to see if there's an icon only and draw it */
@@ -1312,6 +1301,10 @@ static void widget_numbut(uiWidgetColors *wcol, rcti *rect, int state, int round
widget_num_tria(&wtb.tria2, rect, 0.6f, 'r');
}
widgetbase_draw(&wtb, wcol);
+
+ /* text space */
+ rect->xmin += (rect->ymax-rect->ymin);
+ rect->xmax -= (rect->ymax-rect->ymin);
}
@@ -1401,6 +1394,10 @@ static void widget_menubut(uiWidgetColors *wcol, rcti *rect, int state, int roun
widget_menu_trias(&wtb.tria1, rect);
widgetbase_draw(&wtb, wcol);
+
+ /* text space */
+ rect->xmax -= (rect->ymax-rect->ymin);
+
}
static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
@@ -1458,6 +1455,9 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int ro
}
widgetbase_draw(&wtb, wcol);
+
+ /* text space */
+ rect->xmin += (rect->ymax-rect->ymin) + 8;
}
@@ -1664,43 +1664,37 @@ static int widget_roundbox_set(uiBut *but, rcti *rect)
return 15;
}
-static void ui_but_to_pixelrect(rcti *rect, const ARegion *ar, uiBut *but)
+static void ui_fontscale(short *points, float aspect)
{
- uiBlock *block= but->block;
- float gx, gy;
- float getsizex, getsizey;
-
- getsizex= ar->winx;
- getsizey= ar->winy;
-
- gx= but->x1 + (block->panel?block->panel->ofsx:0.0f);
- gy= but->y1 + (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->x2 + (block->panel?block->panel->ofsx:0.0f);
- gy= but->y2 + (block->panel?block->panel->ofsy:0.0f);
+ if(aspect < 0.9f || aspect > 1.1f) {
+ float pointsf= *points;
- 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])));
+ /* 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);
+ }
}
-
/* conversion from old to new buttons, so still messy */
-void ui_draw_but(ARegion *ar, uiBut *but)
+void ui_draw_but(ARegion *ar, uiBut *but, rcti *rect)
{
+ uiStyle style= *((uiStyle *)U.uistyles.first); // XXX pass on as arg
uiWidgetType *wt= NULL;
- rcti rect;
- /* project */
- ui_but_to_pixelrect(&rect, ar, but);
+ /* scale fonts */
+ ui_fontscale(&style.widgetlabel.points, but->block->aspect);
+ ui_fontscale(&style.widget.points, but->block->aspect);
/* handle menus seperately */
if(but->dt==UI_EMBOSSP) {
switch (but->type) {
case LABEL:
- widget_draw_text_icon(but, &rect, wcol_menu_back.text);
+ widget_draw_text_icon(&style, but, rect, wcol_menu_back.text);
break;
case SEPR:
break;
@@ -1724,9 +1718,9 @@ void ui_draw_but(ARegion *ar, uiBut *but)
switch (but->type) {
case LABEL:
if(but->block->flag & UI_BLOCK_LOOP)
- widget_draw_text_icon(but, &rect, wcol_menu_back.text);
+ widget_draw_text_icon(&style, but, rect, wcol_menu_back.text);
else
- widget_draw_text_icon(but, &rect, wcol_regular.text);
+ widget_draw_text_icon(&style, but, rect, wcol_regular.text);
break;
case SEPR:
break;
@@ -1749,8 +1743,10 @@ void ui_draw_but(ARegion *ar, uiBut *but)
case TOG:
case TOGN:
case TOG3:
- if (!(but->flag & UI_HAS_ICON))
+ if (!(but->flag & UI_HAS_ICON)) {
wt= widget_type(UI_WTYPE_OPTION);
+ but->flag |= UI_TEXT_LEFT;
+ }
else
wt= widget_type(UI_WTYPE_TOGGLE);
break;
@@ -1795,35 +1791,28 @@ void ui_draw_but(ARegion *ar, uiBut *but)
if(wt) {
int roundboxalign, state;
- roundboxalign= widget_roundbox_set(but, &rect);
+ roundboxalign= widget_roundbox_set(but, rect);
state= but->flag;
if(but->editstr) state |= UI_TEXTINPUT;
wt->state(wt, state);
if(wt->custom)
- wt->custom(but, &wt->wcol, &rect, state, roundboxalign);
+ wt->custom(but, &wt->wcol, rect, state, roundboxalign);
else if(wt->draw)
- wt->draw(&wt->wcol, &rect, state, roundboxalign);
- wt->text(but, &rect, wt->wcol.text);
+ wt->draw(&wt->wcol, rect, state, roundboxalign);
+ wt->text(&style, but, rect, wt->wcol.text);
if(state & UI_BUT_DISABLED)
- widget_disabled(&rect);
+ widget_disabled(rect);
}
}
-void ui_draw_menu_back(uiBlock *block)
+void ui_draw_menu_back(uiBlock *block, rcti *rect)
{
uiWidgetType *wt= widget_type(UI_WTYPE_MENU_BACK);
- rcti rect;
-
- /* XXX project later? */
- rect.xmin= block->minx;
- rect.xmax= block->maxx;
- rect.ymin= block->miny;
- rect.ymax= block->maxy;
wt->state(wt, 0);
- wt->draw(&wt->wcol, &rect, block->flag, block->direction);
+ wt->draw(&wt->wcol, rect, block->flag, block->direction);
}
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 7b8c50806ca..e2acfe550f9 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -38,6 +38,67 @@
/* themes; defines in BIF_resource.h */
struct ColorBand;
+/* ************************ style definitions ******************** */
+
+#define MAX_STYLE_NAME 64
+#define MAX_FONT_NAME 256
+
+/* default uifont_id offered by Blender */
+#define UIFONT_DEFAULT 0
+#define UIFONT_BITMAP 1
+/* free slots */
+#define UIFONT_CUSTOM1 2
+#define UIFONT_CUSTOM2 3
+
+/* default fonts to load/initalize */
+/* first font is the default (index 0), others optional */
+typedef struct uiFont {
+ struct uiFont *next, *prev;
+ char filename[256];
+ short blf_id; /* from blfont lib */
+ short uifont_id; /* own id */
+ short r_to_l; /* fonts that read from left to right */
+ short pad;
+
+} uiFont;
+
+/* this state defines appearance of text */
+typedef struct uiFontStyle {
+ short uifont_id; /* saved in file, 0 is default */
+ short points; /* actual size depends on 'global' dpi */
+ short italic, bold; /* style hint */
+ short shadow; /* value is amount of pixels blur */
+ short shadx, shady; /* shadow offset in pixels */
+ short align; /* text align hint */
+ float shadowalpha; /* total alpha */
+ float padf;
+
+} uiFontStyle;
+
+/* uiFontStyle->align */
+#define UI_STYLE_TEXT_LEFT 0
+#define UI_STYLE_TEXT_CENTER 1
+#define UI_STYLE_TEXT_RIGHT 2
+
+
+/* this is fed to the layout engine and widget code */
+typedef struct uiStyle {
+ struct uiStyle *next, *prev;
+
+ char name[64]; /* MAX_STYLE_NAME */
+
+ uiFontStyle paneltitle;
+ uiFontStyle grouplabel;
+ uiFontStyle widgetlabel;
+ uiFontStyle widget;
+
+ short minlabelchars; /* in characters */
+ short minwidgetchars; /* in characters */
+ int pad;
+
+} uiStyle;
+
+
/* global, button colors */
typedef struct ThemeUI {
char outline[4];
@@ -153,7 +214,6 @@ typedef struct bTheme {
ThemeWireColor tarm[20];
/*ThemeWireColor tobj[20];*/
- unsigned char bpad[4], bpad1[4];
} bTheme;
typedef struct SolidLight {
@@ -174,20 +234,26 @@ typedef struct UserDef {
char sounddir[160];
/* yafray: temporary xml export directory */
char yfexportdir[160];
- short versions, vrmlflag; // tmp for export, will be replaced by strubi
+ short versions, pad;
+
int gameflags;
int wheellinescroll;
int uiflag, language;
short userpref, viewzoom;
- short console_buffer; //console vars here for tuhopuu compat, --phase
- short console_out;
+
int mixbufsize;
- int fontsize;
+ int fontsize; // XXX old
+ int dpi; /* range 48-128? */
short encoding;
short transopts;
short menuthreshold1, menuthreshold2;
- char fontname[256]; // FILE_MAXDIR+FILE length
+
+ char fontname[256]; // XXX FILE_MAXDIR+FILE length
+
struct ListBase themes;
+ struct ListBase uifonts;
+ struct ListBase uistyles;
+
short undosteps;
short undomemory;
short gp_manhattendist, gp_euclideandist, gp_eraser;
@@ -209,7 +275,7 @@ typedef struct UserDef {
short glreslimit;
short ndof_pan, ndof_rotate;
short curssize, ipo_new;
-// char pad[8];
+
char versemaster[160];
char verseuser[160];
float glalphaclip;
@@ -321,11 +387,6 @@ extern UserDef U; /* from blenkernel blender.c */
#define USER_DISABLE_SOUND 2
#define USER_DISABLE_MIPMAP 4
-/* vrml flag */
-#define USER_VRML_LAYERS 1
-#define USER_VRML_AUTOSCALE 2
-#define USER_VRML_TWOSIDED 4
-
/* wm draw method */
#define USER_DRAW_TRIPLE 0
#define USER_DRAW_OVERLAP 1
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 1f9c335485d..30a941bb991 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -146,11 +146,6 @@ static void init_userdef_themes(void)
U.dupflag |= USER_DUP_ARM;
}
- /* userdef new option */
- if (G.main->versionfile <= 222) {
- U.vrmlflag= USER_VRML_LAYERS;
- }
-
/* added seam, normal color, undo */
if (G.main->versionfile <= 234) {
bTheme *btheme;