From 1fdea43c29a7a0ffb65ec8049da574d4198d22af Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Dec 2019 19:37:51 +1100 Subject: Fix minor errors with text view margins for console/info editor - Margins used duplicate define between files. - Cursor selection ignored margins. - Cursor wasn't scaling with DPI. Add a 'draw_rect' member which is the region rect with margins applied to make these checks clearer. This resolves issue pointed out in D6300, which complicated further refactoring. --- source/blender/editors/space_info/info_draw.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'source/blender/editors/space_info/info_draw.c') diff --git a/source/blender/editors/space_info/info_draw.c b/source/blender/editors/space_info/info_draw.c index 734515e1f79..a22983c15a8 100644 --- a/source/blender/editors/space_info/info_draw.c +++ b/source/blender/editors/space_info/info_draw.c @@ -228,6 +228,16 @@ static int report_textview_line_color(struct TextViewContext *tvc, #undef USE_INFO_NEWLINE +static void info_textview_draw_rect_calc(ARegion *ar, rcti *draw_rect) +{ + const int margin = 4 * UI_DPI_FAC; + draw_rect->xmin = margin; + draw_rect->xmax = ar->winx - (V2D_SCROLL_WIDTH + margin); + draw_rect->ymin = margin; + /* No margin at the top (allow text to scroll off the window). */ + draw_rect->ymax = ar->winy; +} + static int info_textview_main__internal(struct SpaceInfo *sinfo, ARegion *ar, ReportList *reports, @@ -258,7 +268,8 @@ static int info_textview_main__internal(struct SpaceInfo *sinfo, tvc.lheight = 14 * UI_DPI_FAC; // sc->lheight; tvc.ymin = v2d->cur.ymin; tvc.ymax = v2d->cur.ymax; - tvc.winx = ar->winx - V2D_SCROLL_WIDTH; + + info_textview_draw_rect_calc(ar, &tvc.draw_rect); ret = textview_draw(&tvc, draw, mval, mouse_pick, pos_pick); -- cgit v1.2.3