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
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-09-22 01:26:04 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-09-22 01:26:04 +0400
commit3448f675cb20ad38691a4d40ed90f44722243ae9 (patch)
treedb38a231c678e039b57add6f524ea794961689cc
parentd601a51e03ca0dc8d714b36ad7ae7a5005119bc3 (diff)
Fix #19427, problem in blenfont not computing the width of text correct,
particularly text including spaces. This gave some problems with placing the cursor and selection, and clipping text inside buttons.
-rw-r--r--source/blender/blenfont/intern/blf_font.c4
-rw-r--r--source/blender/editors/interface/interface_widgets.c11
2 files changed, 5 insertions, 10 deletions
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c
index 0a3dd259f6c..8721e49f06b 100644
--- a/source/blender/blenfont/intern/blf_font.c
+++ b/source/blender/blenfont/intern/blf_font.c
@@ -353,8 +353,8 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box)
pen_x += delta.x >> 6;
}
- gbox.xmin= g->box.xmin + pen_x;
- gbox.xmax= g->box.xmax + pen_x;
+ gbox.xmin= pen_x;
+ gbox.xmax= pen_x + g->advance;
gbox.ymin= g->box.ymin + pen_y;
gbox.ymax= g->box.ymax + pen_y;
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 90b2c920613..ac8750f84e6 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -773,7 +773,8 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, int blend, rcti *rect)
/* sets but->ofs to make sure text is correctly visible */
static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
{
- int okwidth= rect->xmax-rect->xmin;
+ int border= (but->flag & UI_BUT_ALIGN_RIGHT)? 8: 10;
+ int okwidth= rect->xmax-rect->xmin - border;
/* need to set this first */
uiStyleFontSet(fstyle);
@@ -842,11 +843,8 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
but->drawstr[selend_tmp]= ch;
- /* if at pos 0, leave a bit more to the left */
- t= (pos == 0)? 0: 1;
-
glColor3ubv((unsigned char*)wcol->item);
- glRects(rect->xmin+selsta_draw+1, rect->ymin+2, rect->xmin+selwidth_draw+1, rect->ymax-2);
+ glRects(rect->xmin+selsta_draw, rect->ymin+2, rect->xmin+selwidth_draw, rect->ymax-2);
}
} else {
/* text cursor */
@@ -861,9 +859,6 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
but->drawstr[pos]= ch;
}
- /* if at pos 0, leave a bit more to the left */
- t += (pos == 0)? 0: 1;
-
glColor3ub(255,0,0);
glRects(rect->xmin+t, rect->ymin+2, rect->xmin+t+2, rect->ymax-2);
}