Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-02-18 06:36:36 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-02-18 06:36:36 +0400
commitd45612aa412798d5529027afd068adc79b8465f1 (patch)
tree9e4b8ceaaf479a61f5170fb2c4a8d657ebf74d98 /source/blender/editors/space_info
parent42a81550f9b1ab4af7945580922c897425becf7f (diff)
fix [#34279] Python console: Selected region is not highlighted when using white background color
Diffstat (limited to 'source/blender/editors/space_info')
-rw-r--r--source/blender/editors/space_info/info_draw.c4
-rw-r--r--source/blender/editors/space_info/textview.c28
-rw-r--r--source/blender/editors/space_info/textview.h1
3 files changed, 23 insertions, 10 deletions
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 */