Page MenuHome
Paste P1256

Proposed fix for T73784
ActivePublic

Authored by Campbell Barton (campbellbarton) on Fri, Feb 14, 1:57 AM.
diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c
index ac54b1177ba..2d3f6d8bc80 100644
--- a/source/blender/editors/space_console/console_draw.c
+++ b/source/blender/editors/space_console/console_draw.c
@@ -161,7 +161,7 @@ static void console_textview_draw_cursor(struct TextViewContext *tvc)
console_cursor_wrap_offset(sc->prompt, tvc->columns, &offl, &offc, NULL);
console_cursor_wrap_offset(cl->line, tvc->columns, &offl, &offc, cl->line + cl->cursor);
- pen[0] = tvc->cwidth * (offc + tvc->margin_left_chars);
+ pen[0] = tvc->cwidth * offc;
pen[1] = -2 - tvc->lheight * offl;
console_cursor_wrap_offset(cl->line + cl->cursor, tvc->columns, &offl, &offc, NULL);
@@ -187,9 +187,11 @@ static void console_textview_const_colors(TextViewContext *UNUSED(tvc), unsigned
static void console_textview_draw_rect_calc(const ARegion *ar, rcti *draw_rect)
{
- draw_rect->xmin = 0;
- draw_rect->xmax = ar->winx;
- draw_rect->ymin = 0;
+ const int margin = 4 * UI_DPI_FAC;
+ draw_rect->xmin = margin;
+ draw_rect->xmax = ar->winx - (margin + V2D_SCROLL_WIDTH);
+ draw_rect->ymin = margin;
+ /* No margin at the top (allow text to scroll off the window). */
draw_rect->ymax = ar->winy;
}
@@ -223,8 +225,6 @@ static int console_textview_main__internal(struct SpaceConsole *sc,
tvc.sel_start = sc->sel_start;
tvc.sel_end = sc->sel_end;
tvc.lheight = sc->lheight * 1.2f * UI_DPI_FAC;
- tvc.margin_left_chars = 1;
- tvc.margin_right_chars = 2;
tvc.scroll_ymin = v2d->cur.ymin;
tvc.scroll_ymax = v2d->cur.ymax;
diff --git a/source/blender/editors/space_info/info_draw.c b/source/blender/editors/space_info/info_draw.c
index 03ff680a93d..ff03ac8b6fd 100644
--- a/source/blender/editors/space_info/info_draw.c
+++ b/source/blender/editors/space_info/info_draw.c
@@ -208,10 +208,12 @@ static int report_textview_line_get(struct TextViewContext *tvc, const char **li
static void info_textview_draw_rect_calc(const ARegion *ar, rcti *draw_rect)
{
- draw_rect->xmin = 0;
+ const int margin = 4 * UI_DPI_FAC;
+ draw_rect->xmin = margin + UI_UNIT_X + margin;
draw_rect->xmax = ar->winx;
- draw_rect->ymin = 0;
+ draw_rect->ymin = margin;
draw_rect->ymax = ar->winy;
+ /* No margin at the top (allow text to scroll off the window). */
}
static int info_textview_main__internal(struct SpaceInfo *sinfo,
@@ -243,8 +245,6 @@ static int info_textview_main__internal(struct SpaceInfo *sinfo,
tvc.sel_end = 0;
tvc.lheight = 17 * UI_DPI_FAC;
tvc.row_vpadding = 0.4 * tvc.lheight;
- tvc.margin_left_chars = 5;
- tvc.margin_right_chars = 2;
tvc.scroll_ymin = v2d->cur.ymin;
tvc.scroll_ymax = v2d->cur.ymax;
diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c
index c145f5d333f..770922e1726 100644
--- a/source/blender/editors/space_info/textview.c
+++ b/source/blender/editors/space_info/textview.c
@@ -53,8 +53,6 @@ typedef struct TextViewDrawState {
int lheight;
/** Text vertical offset per line. */
int lofs;
- int margin_left_chars;
- int margin_right_chars;
int row_vpadding;
/** Number of characters that fit into the width of the console (fixed width). */
int columns;
@@ -85,9 +83,8 @@ static void console_draw_sel(const char *str,
const int lheight = tds->lheight;
if (sel[0] <= str_len_draw && sel[1] >= 0) {
- const int sta = BLI_str_utf8_offset_to_column(str, max_ii(sel[0], 0)) + tds->margin_left_chars;
- const int end = BLI_str_utf8_offset_to_column(str, min_ii(sel[1], str_len_draw)) +
- tds->margin_left_chars;
+ const int sta = BLI_str_utf8_offset_to_column(str, max_ii(sel[0], 0));
+ const int end = BLI_str_utf8_offset_to_column(str, min_ii(sel[1], str_len_draw));
GPU_blend(true);
GPU_blend_set_func_separate(
@@ -154,11 +151,7 @@ static bool console_draw_string(TextViewDrawState *tds,
int tot_lines; /* Total number of lines for wrapping. */
int *offsets; /* Offsets of line beginnings for wrapping. */
- str_len = console_wrap_offsets(str,
- str_len,
- tds->columns - (tds->margin_left_chars + tds->margin_right_chars),
- &tot_lines,
- &offsets);
+ str_len = console_wrap_offsets(str, str_len, tds->columns, &tot_lines, &offsets);
int line_height = (tot_lines * tds->lheight) + (tds->row_vpadding * 2);
int line_bottom = tds->xy[1];
@@ -229,9 +222,9 @@ static bool console_draw_string(TextViewDrawState *tds,
if (icon_bg) {
float col[4];
- int bg_size = 20 * UI_DPI_FAC;
+ int bg_size = UI_DPI_ICON_SIZE * 1.2;
float vpadding = (tds->lheight + (tds->row_vpadding * 2) - bg_size) / 2;
- float hpadding = ((tds->margin_left_chars * tds->cwidth) - bg_size) / 2;
+ float hpadding = tds->draw_rect->xmin - (bg_size * 1.2f);
rgba_uchar_to_float(col, icon_bg);
UI_draw_roundbox_corner_set(UI_CNR_ALL);
@@ -246,7 +239,7 @@ static bool console_draw_string(TextViewDrawState *tds,
if (icon) {
int vpadding = (tds->lheight + (tds->row_vpadding * 2) - UI_DPI_ICON_SIZE) / 2;
- int hpadding = ((tds->margin_left_chars * tds->cwidth) - UI_DPI_ICON_SIZE) / 2;
+ int hpadding = tds->draw_rect->xmin - (UI_DPI_ICON_SIZE * 1.3f);
GPU_blend(true);
UI_icon_draw_ex(hpadding,
@@ -266,10 +259,7 @@ static bool console_draw_string(TextViewDrawState *tds,
const int final_offset = offsets[tot_lines - 1];
len = str_len - final_offset;
s = str + final_offset;
- BLF_position(tds->font_id,
- tds->xy[0] + (tds->margin_left_chars * tds->cwidth),
- tds->lofs + line_bottom + tds->row_vpadding,
- 0);
+ BLF_position(tds->font_id, tds->xy[0], tds->lofs + line_bottom + tds->row_vpadding, 0);
BLF_color4ubv(tds->font_id, fg);
BLF_draw_mono(tds->font_id, s, len, tds->cwidth);
@@ -287,10 +277,7 @@ static bool console_draw_string(TextViewDrawState *tds,
len = offsets[i] - offsets[i - 1];
s = str + offsets[i - 1];
- BLF_position(tds->font_id,
- tds->xy[0] + (tds->margin_left_chars * tds->cwidth),
- tds->lofs + tds->xy[1],
- 0);
+ BLF_position(tds->font_id, tds->xy[0], tds->lofs + tds->xy[1], 0);
BLF_draw_mono(tds->font_id, s, len, tds->cwidth);
if (tds->sel[0] != tds->sel[1]) {
@@ -364,8 +351,6 @@ int textview_draw(TextViewContext *tvc,
tds.cwidth = (int)BLF_fixed_width(font_id);
BLI_assert(tds.cwidth > 0);
tds.lheight = tvc->lheight;
- tds.margin_left_chars = tvc->margin_left_chars;
- tds.margin_right_chars = tvc->margin_right_chars;
tds.row_vpadding = tvc->row_vpadding;
tds.lofs = -BLF_descender(font_id);
/* Note, scroll bar must be already subtracted. */
diff --git a/source/blender/editors/space_info/textview.h b/source/blender/editors/space_info/textview.h
index 3f7ba9739c4..3c7e57477c7 100644
--- a/source/blender/editors/space_info/textview.h
+++ b/source/blender/editors/space_info/textview.h
@@ -32,8 +32,6 @@ typedef struct TextViewContext {
int columns; /* shouldnt be needed! */
int row_vpadding;
- int margin_left_chars;
- int margin_right_chars;
/** Area to draw: (0, 0, winx, winy) with a margin applied and scroll-bar subtracted. */
rcti draw_rect;