diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-11-11 09:35:45 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-11-11 09:35:45 +0300 |
commit | 80a650dfb1e73363ae6924dc5738b732bb89ded4 (patch) | |
tree | 7d8af50bde3e4c32474d899a7fd00558afe9befc /source/blender/editors | |
parent | 59cfe81085b06243220cdb075a28a1352edebf7b (diff) |
BLF_draw functions take an extra length argument, so the console drawing doenst need to swap in NULL chars to draw word wrapping.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/interface/interface_draw.c | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_style.c | 6 | ||||
-rw-r--r-- | source/blender/editors/interface/view2d.c | 6 | ||||
-rw-r--r-- | source/blender/editors/screen/area.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_console/console_draw.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_info/textview.c | 20 | ||||
-rw-r--r-- | source/blender/editors/space_info/textview.h | 2 | ||||
-rw-r--r-- | source/blender/editors/space_text/text_draw.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 33 |
10 files changed, 36 insertions, 51 deletions
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 29278edf451..1e818289d1e 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -856,7 +856,7 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), sprintf(str,"%-3d",i*20); str[3]='\0'; fdrawline(rect.xmin+22, yofs+(i/5.f)*h, rect.xmax+1, yofs+(i/5.f)*h); - BLF_draw_default(rect.xmin+1, yofs-5+(i/5.f)*h, 0, str); + BLF_draw_default(rect.xmin+1, yofs-5+(i/5.f)*h, 0, str, sizeof(str)-1); /* in the loop because blf_draw reset it */ glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index fda52e927af..719be6c3463 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -165,7 +165,7 @@ void uiStyleFontDraw(uiFontStyle *fs, rcti *rect, char *str) if (fs->kerning == 1) BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT); - BLF_draw(fs->uifont_id, str); + BLF_draw(fs->uifont_id, str, 65535); /* XXX, use real length */ BLF_disable(fs->uifont_id, BLF_CLIPPING); if (fs->shadow) BLF_disable(fs->uifont_id, BLF_SHADOW); @@ -218,7 +218,7 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, char *str) if (fs->kerning == 1) BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT); - BLF_draw(fs->uifont_id, str); + BLF_draw(fs->uifont_id, str, 65535); /* XXX, use real length */ BLF_disable(fs->uifont_id, BLF_ROTATION); BLF_disable(fs->uifont_id, BLF_CLIPPING); if (fs->shadow) @@ -258,7 +258,7 @@ void UI_DrawString(float x, float y, char *str) uiStyleFontSet(&style->widget); BLF_position(style->widget.uifont_id, x, y, 0.0f); - BLF_draw(style->widget.uifont_id, str); + BLF_draw(style->widget.uifont_id, str, 65535); /* XXX, use real length */ if (style->widget.kerning == 1) BLF_disable(style->widget.uifont_id, BLF_KERNING_DEFAULT); diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index c1c10bf33c6..43d4e20b8bb 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -1525,7 +1525,7 @@ static void scroll_printstr(Scene *scene, float x, float y, float val, int power } /* draw it */ - BLF_draw_default(x, y, 0.0f, str); + BLF_draw_default(x, y, 0.0f, str, sizeof(str)-1); } /* Draw scrollbars in the given 2d-region */ @@ -2054,7 +2054,7 @@ void UI_view2d_text_cache_draw(ARegion *ar) for(v2s= strings.first; v2s; v2s= v2s->next) { glColor3fv(v2s->col); if(v2s->rect.xmin==v2s->rect.xmax) - BLF_draw_default((float)v2s->mval[0], (float)v2s->mval[1], 0.0, v2s->str); + BLF_draw_default((float)v2s->mval[0], (float)v2s->mval[1], 0.0, v2s->str, sizeof(v2s->str)-1); else { int xofs=0, yofs; @@ -2063,7 +2063,7 @@ void UI_view2d_text_cache_draw(ARegion *ar) BLF_clipping_default(v2s->rect.xmin-4, v2s->rect.ymin-4, v2s->rect.xmax+4, v2s->rect.ymax+4); BLF_enable_default(BLF_CLIPPING); - BLF_draw_default(v2s->rect.xmin+xofs, v2s->rect.ymin+yofs, 0.0f, v2s->str); + BLF_draw_default(v2s->rect.xmin+xofs, v2s->rect.ymin+yofs, 0.0f, v2s->str, sizeof(v2s->str)-1); BLF_disable_default(BLF_CLIPPING); } } diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 7838fbdd5f4..e7c6441c077 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -338,7 +338,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar) glClear(GL_COLOR_BUFFER_BIT); UI_ThemeColor(TH_TEXT); - BLF_draw_default(20, 8, 0.0f, ar->headerstr); + BLF_draw_default(20, 8, 0.0f, ar->headerstr, 65535); /* XXX, use real length */ } else if(at->draw) { at->draw(C, ar); diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c index 38222f097ce..5c2ba2cf838 100644 --- a/source/blender/editors/space_console/console_draw.c +++ b/source/blender/editors/space_console/console_draw.c @@ -168,7 +168,7 @@ static int console_textview_step(TextViewContext *tvc) return ((tvc->iter= (void *)((Link *)tvc->iter)->prev) != NULL); } -static int console_textview_line_get(struct TextViewContext *tvc, char **line, int *len) +static int console_textview_line_get(struct TextViewContext *tvc, const char **line, int *len) { ConsoleLine *cl= (ConsoleLine *)tvc->iter; *line= cl->line; @@ -231,7 +231,7 @@ static int report_textview_step(TextViewContext *tvc) return ((tvc->iter= (void *)((Link *)tvc->iter)->prev) != NULL); } -static int report_textview_line_get(struct TextViewContext *tvc, char **line, int *len) +static int report_textview_line_get(struct TextViewContext *tvc, const char **line, int *len) { Report *report= (Report *)tvc->iter; *line= report->message; diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c index e7b9826568a..5f2ed46789e 100644 --- a/source/blender/editors/space_info/textview.c +++ b/source/blender/editors/space_info/textview.c @@ -89,7 +89,7 @@ static void console_draw_sel(int sel[2], int xy[2], int str_len_draw, int cwidth /* return 0 if the last line is off the screen * should be able to use this for any string type */ -static int console_draw_string(ConsoleDrawContext *cdc, char *str, int str_len, unsigned char *fg, unsigned char *bg) +static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str_len, unsigned char *fg, unsigned char *bg) { #define STEP_SEL(value) cdc->sel[0] += (value); cdc->sel[1] += (value) int rct_ofs= cdc->lheight/4; @@ -131,8 +131,7 @@ static int console_draw_string(ConsoleDrawContext *cdc, char *str, int str_len, if(str_len > cdc->console_width) { /* wrap? */ const int initial_offset= ((tot_lines-1) * cdc->console_width); - char *line_stride= str + initial_offset; /* advance to the last line and draw it first */ - char eol; /* baclup the end of wrapping */ + const char *line_stride= str + initial_offset; /* advance to the last line and draw it first */ int sel_orig[2]; VECCOPY2D(sel_orig, cdc->sel); @@ -150,7 +149,7 @@ static int console_draw_string(ConsoleDrawContext *cdc, char *str, int str_len, /* last part needs no clipping */ BLF_position(mono, cdc->xy[0], cdc->xy[1], 0); - BLF_draw(mono, line_stride); + BLF_draw(mono, line_stride, str_len - initial_offset); if(cdc->sel[0] != cdc->sel[1]) { STEP_SEL(-initial_offset); @@ -165,11 +164,8 @@ static int console_draw_string(ConsoleDrawContext *cdc, char *str, int str_len, line_stride -= cdc->console_width; for(; line_stride >= str; line_stride -= cdc->console_width) { - eol = line_stride[cdc->console_width]; - line_stride[cdc->console_width]= '\0'; - BLF_position(mono, cdc->xy[0], cdc->xy[1], 0); - BLF_draw(mono, line_stride); + BLF_draw(mono, line_stride, cdc->console_width); if(cdc->sel[0] != cdc->sel[1]) { // glColor4ub(0, 255, 0, 96); // debug @@ -179,8 +175,6 @@ static int console_draw_string(ConsoleDrawContext *cdc, char *str, int str_len, } cdc->xy[1] += cdc->lheight; - - line_stride[cdc->console_width] = eol; /* restore */ /* check if were out of view bounds */ if(cdc->xy[1] > cdc->ymax) @@ -200,7 +194,7 @@ static int console_draw_string(ConsoleDrawContext *cdc, char *str, int str_len, glColor3ubv(fg); BLF_position(mono, cdc->xy[0], cdc->xy[1], 0); - BLF_draw(mono, str); + BLF_draw(mono, str, str_len); if(cdc->sel[0] != cdc->sel[1]) { int isel[2]; @@ -269,9 +263,9 @@ int textview_draw(TextViewContext *tvc, int draw, int mval[2], void **mouse_pick } if(tvc->begin(tvc)) { - + do { - char *ext_line; + const char *ext_line; int ext_len; int color_flag= 0; diff --git a/source/blender/editors/space_info/textview.h b/source/blender/editors/space_info/textview.h index b664ca1a155..35c44d36f27 100644 --- a/source/blender/editors/space_info/textview.h +++ b/source/blender/editors/space_info/textview.h @@ -39,7 +39,7 @@ typedef struct TextViewContext { /* iterator */ int (*step)(struct TextViewContext *tvc); - int (*line_get)(struct TextViewContext *tvc, char **, int *); + int (*line_get)(struct TextViewContext *tvc, const char **, int *); int (*line_color)(struct TextViewContext *tvc, unsigned char fg[3], unsigned char bg[3]); void *iter; int iter_index; diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 024eef9092a..ee00ffa9f87 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -74,20 +74,18 @@ static void text_font_end(SpaceText *UNUSED(st)) static int text_font_draw(SpaceText *UNUSED(st), int x, int y, char *str) { BLF_position(mono, x, y, 0); - BLF_draw(mono, str); + BLF_draw(mono, str, 65535); /* XXX, use real length */ return BLF_width(mono, str); } static int text_font_draw_character(SpaceText *st, int x, int y, char c) { - char str[2]; - + char str[1]; str[0]= c; - str[1]= '\0'; BLF_position(mono, x, y, 0); - BLF_draw(mono, str); + BLF_draw(mono, str, 1); return st->cwidth; } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index ba33b19cad7..662acb82b3e 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -643,10 +643,10 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa const char *str= (char *)(vos+1); glColor3fv(vos->col); if(vos->flag & V3D_CACHE_TEXT_ASCII) { - BLF_draw_default_ascii((float)vos->mval[0]+vos->xoffs, (float)vos->mval[1], (depth_write)? 0.0f: 2.0f, str); + BLF_draw_default_ascii((float)vos->mval[0]+vos->xoffs, (float)vos->mval[1], (depth_write)? 0.0f: 2.0f, str, 65535); /* XXX, use real length */ } else { - BLF_draw_default((float)vos->mval[0]+vos->xoffs, (float)vos->mval[1], (depth_write)? 0.0f: 2.0f, str); + BLF_draw_default((float)vos->mval[0]+vos->xoffs, (float)vos->mval[1], (depth_write)? 0.0f: 2.0f, str, 65535); /* XXX, use real length */ } } } diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 27afe07c4b2..c890c884f64 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -604,7 +604,7 @@ static void draw_view_axis(RegionView3D *rv3d) glEnd(); if (fabs(dx) > toll || fabs(dy) > toll) { - BLF_draw_default(start + dx + 2, start + dy + ydisp + 2, 0.0f, "x"); + BLF_draw_default(start + dx + 2, start + dy + ydisp + 2, 0.0f, "x", 1); } /* BLF_draw_default disables blending */ @@ -624,7 +624,7 @@ static void draw_view_axis(RegionView3D *rv3d) glEnd(); if (fabs(dx) > toll || fabs(dy) > toll) { - BLF_draw_default(start + dx + 2, start + dy + ydisp + 2, 0.0f, "y"); + BLF_draw_default(start + dx + 2, start + dy + ydisp + 2, 0.0f, "y", 1); } glEnable(GL_BLEND); @@ -643,7 +643,7 @@ static void draw_view_axis(RegionView3D *rv3d) glEnd(); if (fabs(dx) > toll || fabs(dy) > toll) { - BLF_draw_default(start + dx + 2, start + dy + ydisp + 2, 0.0f, "z"); + BLF_draw_default(start + dx + 2, start + dy + ydisp + 2, 0.0f, "z", 1); } /* restore line-width */ @@ -724,24 +724,17 @@ static char *view3d_get_name(View3D *v3d, RegionView3D *rv3d) static void draw_viewport_name(ARegion *ar, View3D *v3d) { RegionView3D *rv3d= ar->regiondata; - char *name = view3d_get_name(v3d, rv3d); - char *printable = NULL; + char *name= view3d_get_name(v3d, rv3d); + char tmpstr[24]; if (v3d->localvd) { - printable = MEM_mallocN(strlen(name) + strlen(" (Local)_"), "viewport_name"); /* '_' gives space for '\0' */ - strcpy(printable, name); - strcat(printable, " (Local)"); - } else { - printable = name; + snprintf(tmpstr, sizeof(tmpstr), "%s (Local)", name); + name= tmpstr; } - if (printable) { + if (name) { UI_ThemeColor(TH_TEXT_HI); - BLF_draw_default(22, ar->winy-17, 0.0f, printable); - } - - if (v3d->localvd) { - MEM_freeN(printable); + BLF_draw_default(22, ar->winy-17, 0.0f, name, sizeof(tmpstr)); } } @@ -836,7 +829,7 @@ static void draw_selected_name(Scene *scene, Object *ob, View3D *v3d) if (U.uiflag & USER_SHOW_ROTVIEWICON) offset = 14 + (U.rvisize * 2); - BLF_draw_default(offset, 10, 0.0f, info); + BLF_draw_default(offset, 10, 0.0f, info, sizeof(info)-1); } static void view3d_get_viewborder_size(Scene *scene, ARegion *ar, float size_r[2]) @@ -1015,7 +1008,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) /* camera name - draw in highlighted text color */ if (ca && (ca->flag & CAM_SHOWNAME)) { UI_ThemeColor(TH_TEXT_HI); - BLF_draw_default(x1i, y1i-15, 0.0f, v3d->camera->id.name+2); + BLF_draw_default(x1i, y1i-15, 0.0f, v3d->camera->id.name+2, sizeof(v3d->camera->id.name)-2); UI_ThemeColor(TH_WIRE); } } @@ -2274,7 +2267,7 @@ static void draw_viewport_fps(Scene *scene, ARegion *ar) BLI_snprintf(printable, sizeof(printable), "fps: %i", (int)(fps+0.5)); } - BLF_draw_default(22, ar->winy-17, 0.0f, printable); + BLF_draw_default(22, ar->winy-17, 0.0f, printable, sizeof(printable)-1); } void view3d_main_area_draw(const bContext *C, ARegion *ar) @@ -2507,7 +2500,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) } if (grid_unit) { /* draw below the viewport name */ UI_ThemeColor(TH_TEXT_HI); - BLF_draw_default(22, ar->winy-(USER_SHOW_VIEWPORTNAME?40:20), 0.0f, grid_unit); + BLF_draw_default(22, ar->winy-(USER_SHOW_VIEWPORTNAME?40:20), 0.0f, grid_unit, 65535); /* XXX, use real length */ } ob= OBACT; |