uiStyleFontSet(fs);
- height= BLF_height("A");
+ height= BLF_height("2"); /* correct offset is on baseline, the j is below that */
yofs= floor( 0.5f*(rect->ymax - rect->ymin - height));
if(fs->align==UI_STYLE_TEXT_CENTER)
xofs= rect->xmax - rect->xmin - BLF_width(str);
/* clip is very strict, so we give it some space */
- BLF_clipping(rect->xmin-4, rect->ymin-4, rect->xmax+4, rect->ymax+4);
+ BLF_clipping(rect->xmin-1, rect->ymin-4, rect->xmax+1, rect->ymax+4);
BLF_enable(BLF_CLIPPING);
if(fs->shadow)
float col[4];
char str[128];
short mval[2];
+ rcti rect;
} View2DString;
UI_view2d_view_to_region(v2d, x, y, mval, mval+1);
if(mval[0]!=V2D_IS_CLIPPED && mval[1]!=V2D_IS_CLIPPED) {
+ /* use calloc, rect has to be zeroe'd */
View2DString *v2s= MEM_callocN(sizeof(View2DString), "View2DString");
BLI_addtail(&strings, v2s);
}
}
+/* no clip (yet) */
+void UI_view2d_text_cache_rectf(View2D *v2d, rctf *rect, char *str)
+{
+ View2DString *v2s= MEM_callocN(sizeof(View2DString), "View2DString");
+
+ UI_view2d_to_region_no_clip(v2d, rect->xmin, rect->ymin, &v2s->rect.xmin, &v2s->rect.ymin);
+ UI_view2d_to_region_no_clip(v2d, rect->xmax, rect->ymax, &v2s->rect.xmax, &v2s->rect.ymax);
+
+ BLI_addtail(&strings, v2s);
+ BLI_strncpy(v2s->str, str, 128);
+ glGetFloatv(GL_CURRENT_COLOR, v2s->col);
+}
+
+
void UI_view2d_text_cache_draw(ARegion *ar)
{
View2DString *v2s;
for(v2s= strings.first; v2s; v2s= v2s->next) {
glColor3fv(v2s->col);
- BLF_draw_default((float)v2s->mval[0], (float)v2s->mval[1], 0.0, v2s->str);
+ if(v2s->rect.xmin==v2s->rect.xmax)
+ BLF_draw_default((float)v2s->mval[0], (float)v2s->mval[1], 0.0, v2s->str);
+ else {
+ int xofs=0, yofs;
+
+ yofs= ceil( 0.5f*(v2s->rect.ymax - v2s->rect.ymin - BLF_height_default("28")));
+ if(yofs<1) yofs= 1;
+
+ BLF_clipping(v2s->rect.xmin-4, v2s->rect.ymin-4, v2s->rect.xmax+4, v2s->rect.ymax+4);
+ BLF_enable(BLF_CLIPPING);
+
+ BLF_draw_default(v2s->rect.xmin+xofs, v2s->rect.ymin+yofs, 0.0f, v2s->str);
+
+ BLF_disable(BLF_CLIPPING);
+ }
}
// wmPopMatrix();
/* draw info text on a sequence strip */
static void draw_seq_text(View2D *v2d, Sequence *seq, float x1, float x2, float y1, float y2, char *background_col)
{
+ rctf rect;
char str[32 + FILE_MAXDIR+FILE_MAXFILE];
if(seq->name[2]) {
cpack(0);
}
- UI_view2d_text_cache_add(v2d, x1, y1+SEQ_STRIP_OFSBOTTOM, str);
+ rect.xmin= x1;
+ rect.ymin= y1;
+ rect.xmax= x2;
+ rect.ymax= y2;
+ UI_view2d_text_cache_rectf(v2d, &rect, str);
}
/* draws a shaded strip, made from gradient + flat color + gradient */