From d45612aa412798d5529027afd068adc79b8465f1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 18 Feb 2013 02:36:36 +0000 Subject: fix [#34279] Python console: Selected region is not highlighted when using white background color --- source/blender/editors/include/UI_resources.h | 1 + source/blender/editors/interface/resources.c | 10 ++++++++ .../blender/editors/space_console/console_draw.c | 5 ++++ source/blender/editors/space_info/info_draw.c | 4 +++- source/blender/editors/space_info/textview.c | 28 +++++++++++++++------- source/blender/editors/space_info/textview.h | 1 + 6 files changed, 39 insertions(+), 10 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index f8eae840471..b497a97569f 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -155,6 +155,7 @@ enum { TH_CONSOLE_INFO, TH_CONSOLE_ERROR, TH_CONSOLE_CURSOR, + TH_CONSOLE_SELECT, TH_SEQ_MOVIE, TH_SEQ_MOVIECLIP, diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 4e625a75db7..672e4ebbcc4 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -427,6 +427,8 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo cp = ts->console_error; break; case TH_CONSOLE_CURSOR: cp = ts->console_cursor; break; + case TH_CONSOLE_SELECT: + cp = ts->console_select; break; case TH_HANDLE_VERTEX: cp = ts->handle_vertex; @@ -937,6 +939,7 @@ void ui_theme_init_default(void) rgba_char_args_set(btheme->tconsole.console_info, 0, 170, 0, 255); rgba_char_args_set(btheme->tconsole.console_error, 220, 96, 96, 255); rgba_char_args_set(btheme->tconsole.console_cursor, 220, 96, 96, 255); + rgba_char_args_set(btheme->tconsole.console_select, 255, 255, 255, 48); /* space time */ btheme->ttime = btheme->tv3d; @@ -2135,6 +2138,13 @@ void init_userdef_do_versions(void) } } + if (U.versionfile < 265 || (U.versionfile == 265 && U.subversionfile < 11)) { + bTheme *btheme; + for (btheme = U.themes.first; btheme; btheme = btheme->next) { + rgba_char_args_test_set(btheme->tconsole.console_select, 255, 255, 255, 48); + } + } + /* NOTE!! from now on use U.versionfile and U.subversionfile */ diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c index c195cb39157..73747239255 100644 --- a/source/blender/editors/space_console/console_draw.c +++ b/source/blender/editors/space_console/console_draw.c @@ -193,6 +193,10 @@ static int console_textview_line_color(struct TextViewContext *tvc, unsigned cha return TVC_LINE_FG; } +static void console_textview_const_colors(TextViewContext *UNUSED(tvc), unsigned char bg_sel[4]) +{ + UI_GetThemeColor4ubv(TH_CONSOLE_SELECT, bg_sel); +} static int console_textview_main__internal(struct SpaceConsole *sc, ARegion *ar, int draw, int mval[2], void **mouse_pick, int *pos_pick) @@ -210,6 +214,7 @@ static int console_textview_main__internal(struct SpaceConsole *sc, ARegion *ar, tvc.step = console_textview_step; tvc.line_get = console_textview_line_get; tvc.line_color = console_textview_line_color; + tvc.const_colors = console_textview_const_colors; tvc.arg1 = sc; tvc.arg2 = NULL; diff --git a/source/blender/editors/space_info/info_draw.c b/source/blender/editors/space_info/info_draw.c index 54afc9a0849..a748c303b5d 100644 --- a/source/blender/editors/space_info/info_draw.c +++ b/source/blender/editors/space_info/info_draw.c @@ -251,7 +251,8 @@ static int report_textview_line_color(struct TextViewContext *tvc, unsigned char #undef USE_INFO_NEWLINE -static int info_textview_main__internal(struct SpaceInfo *sinfo, ARegion *ar, ReportList *reports, int draw, int mval[2], void **mouse_pick, int *pos_pick) +static int info_textview_main__internal(struct SpaceInfo *sinfo, ARegion *ar, ReportList *reports, + int draw, int mval[2], void **mouse_pick, int *pos_pick) { int ret = 0; @@ -264,6 +265,7 @@ static int info_textview_main__internal(struct SpaceInfo *sinfo, ARegion *ar, Re tvc.step = report_textview_step; tvc.line_get = report_textview_line_get; tvc.line_color = report_textview_line_color; + tvc.const_colors = NULL; tvc.arg1 = sinfo; tvc.arg2 = reports; diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c index 14a0aee09bd..66f4904c340 100644 --- a/source/blender/editors/space_info/textview.c +++ b/source/blender/editors/space_info/textview.c @@ -68,7 +68,8 @@ BLI_INLINE void console_step_sel(ConsoleDrawContext *cdc, const int step) cdc->sel[1] += step; } -static void console_draw_sel(const int sel[2], const int xy[2], const int str_len_draw, int cwidth, int lheight) +static void console_draw_sel(const int sel[2], const int xy[2], const int str_len_draw, int cwidth, int lheight, + const unsigned char bg_sel[4]) { if (sel[0] <= str_len_draw && sel[1] >= 0) { const int sta = max_ii(sel[0], 0); @@ -76,7 +77,7 @@ static void console_draw_sel(const int sel[2], const int xy[2], const int str_le glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glColor4ub(255, 255, 255, 48); + glColor4ubv(bg_sel); glRecti(xy[0] + (cwidth * sta), xy[1] - 2 + lheight, xy[0] + (cwidth * end), xy[1] - 2); @@ -84,12 +85,11 @@ static void console_draw_sel(const int sel[2], const int xy[2], const int str_le } } - /* 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, const char *str, const int str_len, - const unsigned char *fg, const unsigned char *bg) + const unsigned char fg[3], const unsigned char bg[3], const unsigned char bg_sel[4]) { int rct_ofs = cdc->lheight / 4; int tot_lines = (str_len / cdc->console_width) + 1; /* total number of lines for wrapping */ @@ -105,7 +105,8 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, const i /* wrap */ if (str_len > cdc->console_width) - ofs += (cdc->console_width * ((int)((((float)(y_next - cdc->mval[1]) / (float)(y_next - cdc->xy[1])) * tot_lines)))); + ofs += cdc->console_width * ((int)((((float)(y_next - cdc->mval[1]) / + (float)(y_next - cdc->xy[1])) * tot_lines))); CLAMP(ofs, 0, str_len); *cdc->pos_pick += str_len - ofs; @@ -155,7 +156,7 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, const i if (cdc->sel[0] != cdc->sel[1]) { console_step_sel(cdc, -initial_offset); // glColor4ub(255, 0, 0, 96); // debug - console_draw_sel(cdc->sel, cdc->xy, str_len % cdc->console_width, cdc->cwidth, cdc->lheight); + console_draw_sel(cdc->sel, cdc->xy, str_len % cdc->console_width, cdc->cwidth, cdc->lheight, bg_sel); console_step_sel(cdc, cdc->console_width); glColor3ubv(fg); } @@ -170,7 +171,7 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, const i if (cdc->sel[0] != cdc->sel[1]) { // glColor4ub(0, 255, 0, 96); // debug - console_draw_sel(cdc->sel, cdc->xy, cdc->console_width, cdc->cwidth, cdc->lheight); + console_draw_sel(cdc->sel, cdc->xy, cdc->console_width, cdc->cwidth, cdc->lheight, bg_sel); console_step_sel(cdc, cdc->console_width); glColor3ubv(fg); } @@ -204,7 +205,7 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, const i isel[1] = str_len - cdc->sel[0]; // glColor4ub(255, 255, 0, 96); // debug - console_draw_sel(isel, cdc->xy, str_len, cdc->cwidth, cdc->lheight); + console_draw_sel(isel, cdc->xy, str_len, cdc->cwidth, cdc->lheight, bg_sel); console_step_sel(cdc, -(str_len + 1)); } @@ -266,6 +267,11 @@ int textview_draw(TextViewContext *tvc, const int draw, int mval[2], void **mous } if (tvc->begin(tvc)) { + unsigned char bg_sel[4] = {0}; + + if (draw && tvc->const_colors) { + tvc->const_colors(tvc, bg_sel); + } do { const char *ext_line; @@ -279,7 +285,11 @@ int textview_draw(TextViewContext *tvc, const int draw, int mval[2], void **mous tvc->line_get(tvc, &ext_line, &ext_len); - if (!console_draw_string(&cdc, ext_line, ext_len, (color_flag & TVC_LINE_FG) ? fg : NULL, (color_flag & TVC_LINE_BG) ? bg : NULL)) { + if (!console_draw_string(&cdc, ext_line, ext_len, + (color_flag & TVC_LINE_FG) ? fg : NULL, + (color_flag & TVC_LINE_BG) ? bg : NULL, + bg_sel)) + { /* when drawing, if we pass v2d->cur.ymax, then quit */ if (draw) { break; /* past the y limits */ diff --git a/source/blender/editors/space_info/textview.h b/source/blender/editors/space_info/textview.h index d0fab880dc3..653c9b83a50 100644 --- a/source/blender/editors/space_info/textview.h +++ b/source/blender/editors/space_info/textview.h @@ -46,6 +46,7 @@ typedef struct TextViewContext { int (*step)(struct TextViewContext *tvc); int (*line_get)(struct TextViewContext *tvc, const char **, int *); int (*line_color)(struct TextViewContext *tvc, unsigned char fg[3], unsigned char bg[3]); + void (*const_colors)(struct TextViewContext *tvc, unsigned char bg_sel[4]); /* constant theme colors */ void *iter; int iter_index; int iter_char; /* char intex, used for multi-line report display */ -- cgit v1.2.3