fix [#34279] Python console: Selected region is not highlighted when using white...
authorCampbell Barton <ideasman42@gmail.com>
Mon, 18 Feb 2013 02:36:36 +0000 (02:36 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 18 Feb 2013 02:36:36 +0000 (02:36 +0000)
14 files changed:
release/scripts/presets/interface_theme/back_to_black.xml
release/scripts/presets/interface_theme/blender_24x.xml
release/scripts/presets/interface_theme/elsyiun.xml
release/scripts/presets/interface_theme/hexagon.xml
release/scripts/presets/interface_theme/ubuntu_ambiance.xml
source/blender/blenlib/intern/math_color_inline.c
source/blender/editors/include/UI_resources.h
source/blender/editors/interface/resources.c
source/blender/editors/space_console/console_draw.c
source/blender/editors/space_info/info_draw.c
source/blender/editors/space_info/textview.c
source/blender/editors/space_info/textview.h
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesrna/intern/rna_userdef.c

index bb625c6..0521684 100644 (file)
                     line_input="#cecece"
                     line_info="#00aa00"
                     line_error="#dc6060"
-                    cursor="#dc6060">
+                    cursor="#dc6060"
+                    select="#ffffff30">
         <space>
           <ThemeSpaceGeneric back="#0f0f0f"
                              title="#5d5d5d"
index 3e84d2a..48a3ee9 100644 (file)
                     line_input="#ffffff"
                     line_info="#00aa00"
                     line_error="#dc6060"
-                    cursor="#dc6060">
+                    cursor="#dc6060"
+                    select="#c6777799">
         <space>
           <ThemeSpaceGeneric back="#b4b4b4"
                              title="#000000"
index 3cb7532..3ea49ed 100644 (file)
                     line_input="#ffffff"
                     line_info="#00aa00"
                     line_error="#dc6060"
-                    cursor="#dc6060">
+                    cursor="#dc6060"
+                    select="#4e4e8f80">
         <space>
           <ThemeSpaceGeneric back="#202020"
                              title="#000000"
index 4072b36..299df38 100644 (file)
                     line_input="#ffffff"
                     line_info="#00aa00"
                     line_error="#dc0606"
-                    cursor="#dc6060">
+                    cursor="#dc6060"
+                    select="#ffffff30">
         <space>
           <ThemeSpaceGeneric back="#7c7e88"
                              title="#000000"
index d51d34f..38ab35d 100644 (file)
                     line_input="#19b6ee"
                     line_info="#f47421"
                     line_error="#ff0000"
-                    cursor="#f47421">
+                    cursor="#f47421"
+                    select="#641f4480">
         <space>
           <ThemeSpaceGeneric back="#131311"
                              title="#000000"
index c24da9f..e9a1c0a 100644 (file)
@@ -174,7 +174,8 @@ MINLINE void srgb_to_linearrgb_uchar4_predivide(float linear[4], const unsigned
 }
 
 /* color macros for themes */
-#define rgba_char_args_set_fl(col, r, g, b, a)  rgba_char_args_set(col, r * 255, g * 255, b * 255, a * 255)
+#define rgba_char_args_set_fl(col, r, g, b, a) \
+       rgba_char_args_set(col, (r) * 255, (g) * 255, (b) * 255, (a) * 255)
 
 MINLINE void rgba_char_args_set(char col[4], const char r, const char g, const char b, const char a)
 {
index f8eae84..b497a97 100644 (file)
@@ -155,6 +155,7 @@ enum {
        TH_CONSOLE_INFO,
        TH_CONSOLE_ERROR,
        TH_CONSOLE_CURSOR,
+       TH_CONSOLE_SELECT,
        
        TH_SEQ_MOVIE,
        TH_SEQ_MOVIECLIP,
index 4e625a7..672e4eb 100644 (file)
@@ -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 */
        
        
index c195cb3..7374723 100644 (file)
@@ -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;
index 54afc9a..a748c30 100644 (file)
@@ -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;
index 14a0aee..66f4904 100644 (file)
@@ -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 */
index d0fab88..653c9b8 100644 (file)
@@ -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 */
index cc53caa..26b3378 100644 (file)
@@ -250,7 +250,7 @@ typedef struct ThemeSpace {
        char ds_channel[4], ds_subchannel[4]; /* dopesheet */
        
        char console_output[4], console_input[4], console_info[4], console_error[4];
-       char console_cursor[4];
+       char console_cursor[4], console_select[4], pad1[4];
        
        char vertex_size, outline_width, facedot_size;
        char noodle_curving;
index 2b2f1a2..9d5a002 100644 (file)
@@ -1689,6 +1689,13 @@ static void rna_def_userdef_theme_space_console(BlenderRNA *brna)
        RNA_def_property_array(prop, 3);
        RNA_def_property_ui_text(prop, "Cursor", "");
        RNA_def_property_update(prop, 0, "rna_userdef_update");
+
+       prop = RNA_def_property(srna, "select", PROP_FLOAT, PROP_COLOR_GAMMA);
+       RNA_def_property_float_sdna(prop, NULL, "console_select");
+       RNA_def_property_array(prop, 4);
+       RNA_def_property_ui_text(prop, "Selection", "");
+       RNA_def_property_update(prop, 0, "rna_userdef_update");
+
 }
 
 static void rna_def_userdef_theme_space_info(BlenderRNA *brna)