From fd90e17130e01cb6f71830e325d11c18f74c52a0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 31 Aug 2013 05:00:40 +0000 Subject: [PATCH] text drawing glitche - highlight line was offset slightly from selection. --- source/blender/editors/space_text/text_draw.c | 22 +++++++++---------- .../blender/editors/space_text/text_intern.h | 2 +- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 95fd7fce878..e92cab72042 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -1133,23 +1133,23 @@ static void draw_cursor(SpaceText *st, ARegion *ar) wrap_offset_in_line(st, ar, text->sell, text->selc, &offl, &offc); - y1 = ar->winy - 2 - (vsell - offl) * lheight; - y2 = y1 - (lheight * visible_lines + TXT_LINE_SPACING); + y1 = ar->winy - (vsell - offl) * lheight; + y2 = y1 - (lheight * visible_lines); } else { - y1 = ar->winy - 2 - vsell * lheight; - y2 = y1 - (lheight + TXT_LINE_SPACING); + y1 = ar->winy - vsell * lheight; + y2 = y1 - (lheight); } if (!(y1 < 0 || y2 > ar->winy)) { /* check we need to draw */ - x1 = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET; + x1 = 0; // st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET; x2 = x1 + ar->winx; glColor4ub(255, 255, 255, 32); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); - glRecti(x1 - 4, y1, x2, y2 + TXT_LINE_SPACING); + glRecti(x1 - 4, y1, x2, y2); glDisable(GL_BLEND); } } @@ -1317,15 +1317,13 @@ void draw_text_main(SpaceText *st, ARegion *ar) int wraplinecount = 0, wrap_skip = 0; int margin_column_x; - /* dpi controlled line height and font size */ - st->lheight_dpi = (U.widget_unit * st->lheight) / 20; - - if (st->lheight_dpi) st->viewlines = (int)ar->winy / (st->lheight_dpi + TXT_LINE_SPACING); - else st->viewlines = 0; - /* if no text, nothing to do */ if (!text) return; + + /* dpi controlled line height and font size */ + st->lheight_dpi = (U.widget_unit * st->lheight) / 20; + st->viewlines = (st->lheight_dpi) ? (int)ar->winy / (st->lheight_dpi + TXT_LINE_SPACING) : 0; text_update_drawcache(st, ar); diff --git a/source/blender/editors/space_text/text_intern.h b/source/blender/editors/space_text/text_intern.h index 371ccfd9bd9..a1187b2da0d 100644 --- a/source/blender/editors/space_text/text_intern.h +++ b/source/blender/editors/space_text/text_intern.h @@ -54,7 +54,7 @@ void text_scroll_to_cursor(struct SpaceText *st, struct ScrArea *sa); void text_update_cursor_moved(struct bContext *C); /* TXT_OFFSET used to be 35 when the scrollbar was on the left... */ -#define TXT_OFFSET ((int)(0.75f * U.widget_unit)) +#define TXT_OFFSET ((int)(0.2f * U.widget_unit)) #define TXT_SCROLL_WIDTH U.widget_unit #define TXT_SCROLL_SPACE ((int)(0.1f * U.widget_unit)) #define TXT_LINE_SPACING ((int)(0.2f * U.widget_unit)) /* space between lines */