diff options
author | Harley Acheson <harley.acheson@gmail.com> | 2020-01-29 20:24:54 +0300 |
---|---|---|
committer | Harley Acheson <harley.acheson@gmail.com> | 2020-01-29 20:24:54 +0300 |
commit | aa919f3e82020a4d9e953ec826a390bf2837cadc (patch) | |
tree | 97469346d2e7ea1feaa7d5001fc094df6152f31a /source/blender/editors/space_console | |
parent | e3f89237feccf710e34a9bd316e4c0557ad79055 (diff) |
UI: Info Editor Visual Changes
Changes to Info Editor making it easier to read. Only visual changes, no functional changes.
Differential Revision: https://developer.blender.org/D6491
Reviewed by Julian Eisel
Diffstat (limited to 'source/blender/editors/space_console')
-rw-r--r-- | source/blender/editors/space_console/console_draw.c | 107 |
1 files changed, 54 insertions, 53 deletions
diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c index bf6683ffc33..c9dde11cbeb 100644 --- a/source/blender/editors/space_console/console_draw.c +++ b/source/blender/editors/space_console/console_draw.c @@ -42,22 +42,33 @@ #include "../space_info/textview.h" -static void console_line_color(unsigned char fg[3], int type) +static int console_line_data(struct TextViewContext *tvc, + unsigned char fg[4], + unsigned char UNUSED(bg[4]), + int *UNUSED(icon), + unsigned char UNUSED(icon_fg[4]), + unsigned char UNUSED(icon_bg[4])) { - switch (type) { + ConsoleLine *cl_iter = (ConsoleLine *)tvc->iter; + int fg_id = TH_TEXT; + + switch (cl_iter->type) { case CONSOLE_LINE_OUTPUT: - UI_GetThemeColor3ubv(TH_CONSOLE_OUTPUT, fg); + fg_id = TH_CONSOLE_OUTPUT; break; case CONSOLE_LINE_INPUT: - UI_GetThemeColor3ubv(TH_CONSOLE_INPUT, fg); + fg_id = TH_CONSOLE_INPUT; break; case CONSOLE_LINE_INFO: - UI_GetThemeColor3ubv(TH_CONSOLE_INFO, fg); + fg_id = TH_CONSOLE_INFO; break; case CONSOLE_LINE_ERROR: - UI_GetThemeColor3ubv(TH_CONSOLE_ERROR, fg); + fg_id = TH_CONSOLE_ERROR; break; } + + UI_GetThemeColor4ubv(fg_id, fg); + return TVC_LINE_FG; } void console_scrollback_prompt_begin(struct SpaceConsole *sc, ConsoleLine *cl_dummy) @@ -137,47 +148,36 @@ static void console_cursor_wrap_offset( return; } -static int console_textview_line_color(struct TextViewContext *tvc, - unsigned char fg[3], - unsigned char UNUSED(bg[3])) +static void console_textview_draw_cursor(struct TextViewContext *tvc) { - ConsoleLine *cl_iter = (ConsoleLine *)tvc->iter; - - /* annoying hack, to draw the prompt */ - if (tvc->iter_index == 0) { - const SpaceConsole *sc = (SpaceConsole *)tvc->arg1; - const ConsoleLine *cl = (ConsoleLine *)sc->history.last; - int offl = 0, offc = 0; - int xy[2] = {tvc->draw_rect.xmin, tvc->draw_rect.ymin}; - int pen[2]; - GPUVertFormat *format = immVertexFormat(); - uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); - xy[1] += tvc->lheight / 6; - - 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; - pen[1] = -2 - tvc->lheight * offl; - - console_cursor_wrap_offset(cl->line + cl->cursor, tvc->columns, &offl, &offc, NULL); - pen[1] += tvc->lheight * offl; - - /* cursor */ - immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - immUniformThemeColor(TH_CONSOLE_CURSOR); - - immRectf(pos, - (xy[0] + pen[0]) - U.pixelsize, - (xy[1] + pen[1]), - (xy[0] + pen[0]) + U.pixelsize, - (xy[1] + pen[1] + tvc->lheight)); - - immUnbindProgram(); - } - - console_line_color(fg, cl_iter->type); - - return TVC_LINE_FG; + const SpaceConsole *sc = (SpaceConsole *)tvc->arg1; + const ConsoleLine *cl = (ConsoleLine *)sc->history.last; + int offl = 0, offc = 0; + int xy[2] = {tvc->draw_rect.xmin, tvc->draw_rect.ymin}; + int pen[2]; + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + xy[1] += tvc->lheight * 0.35f; + + 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[1] = -2 - tvc->lheight * offl; + + console_cursor_wrap_offset(cl->line + cl->cursor, tvc->columns, &offl, &offc, NULL); + pen[1] += tvc->lheight * offl; + + /* cursor */ + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + immUniformThemeColor(TH_CONSOLE_CURSOR); + + immRectf(pos, + (xy[0] + pen[0]) - U.pixelsize, + (xy[1] + pen[1]), + (xy[0] + pen[0]) + U.pixelsize, + (xy[1] + pen[1] + tvc->lheight)); + + immUnbindProgram(); } static void console_textview_const_colors(TextViewContext *UNUSED(tvc), unsigned char bg_sel[4]) @@ -187,11 +187,9 @@ static void console_textview_const_colors(TextViewContext *UNUSED(tvc), unsigned static void console_textview_draw_rect_calc(const ARegion *ar, rcti *draw_rect) { - 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->xmin = 0; + draw_rect->xmax = ar->winx; + draw_rect->ymin = 0; draw_rect->ymax = ar->winy; } @@ -214,7 +212,8 @@ static int console_textview_main__internal(struct SpaceConsole *sc, tvc.step = console_textview_step; tvc.line_get = console_textview_line_get; - tvc.line_color = console_textview_line_color; + tvc.line_data = console_line_data; + tvc.draw_cursor = console_textview_draw_cursor; tvc.const_colors = console_textview_const_colors; tvc.arg1 = sc; @@ -223,7 +222,9 @@ static int console_textview_main__internal(struct SpaceConsole *sc, /* view */ tvc.sel_start = sc->sel_start; tvc.sel_end = sc->sel_end; - tvc.lheight = sc->lheight * UI_DPI_FAC; + 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; |