UI: Add theme color for viewport overlay
authorCampbell Barton <ideasman42@gmail.com>
Mon, 17 Mar 2014 18:34:43 +0000 (05:34 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 17 Mar 2014 18:40:18 +0000 (05:40 +1100)
Was using wire or black in many places, this color is used for cursor,
camera guides, transform helper lines. So its possible to have a dark
background with light overlay color.

Patch D331 by Brita, with some edits.

source/blender/editors/include/UI_resources.h
source/blender/editors/interface/resources.c
source/blender/editors/screen/glutil.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/space_view3d/view3d_fly.c
source/blender/editors/space_view3d/view3d_walk.c
source/blender/editors/transform/transform.c
source/blender/editors/util/ed_util.c
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesrna/intern/rna_userdef.c

index 1d4d61afef93bcfb59dfc551fc4b0755090fe7a5..0f11994e2d1afac027df23e6cc1a1dbb83f73cf8 100644 (file)
@@ -275,7 +275,8 @@ enum {
        TH_INFO_INFO,
        TH_INFO_INFO_TEXT,
        TH_INFO_DEBUG,
-       TH_INFO_DEBUG_TEXT
+       TH_INFO_DEBUG_TEXT,
+       TH_VIEW_OVERLAY,
 };
 /* XXX WARNING: previous is saved in file, so do not change order! */
 
index 4b7c25d8f54bb2b31f4f7ccb844828a7ac74d896..a112106620fb6e3a15edc291104d1b2fb87f2a60 100644 (file)
@@ -268,6 +268,8 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
                                
                                case TH_GRID:
                                        cp = ts->grid; break;
+                               case TH_VIEW_OVERLAY:
+                                       cp = ts->view_overlay; break;
                                case TH_WIRE:
                                        cp = ts->wire; break;
                                case TH_WIRE_EDIT:
@@ -819,6 +821,7 @@ void ui_theme_init_default(void)
        rgba_char_args_set(btheme->tv3d.shade2,  0x7f, 0x70, 0x70, 100);
 
        rgba_char_args_set_fl(btheme->tv3d.grid,     0.251, 0.251, 0.251, 1.0);
+       rgba_char_args_set(btheme->tv3d.view_overlay, 0, 0, 0, 255);
        rgba_char_args_set(btheme->tv3d.wire,       0x0, 0x0, 0x0, 255);
        rgba_char_args_set(btheme->tv3d.wire_edit,  0x0, 0x0, 0x0, 255);
        rgba_char_args_set(btheme->tv3d.lamp,       0, 0, 0, 40);
index 73953b8f2284a2ee6d3a22e825510c66bd75e9d2..c75485d93f93acde40367063c711a7b55ac5fde5 100644 (file)
@@ -147,7 +147,8 @@ const GLubyte stipple_checker_8px[128] = {
        0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255,
        0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255};
 
-
+/* UNUSED */
+#if 0
 void fdrawbezier(float vec[4][3])
 {
        float dist;
@@ -177,6 +178,7 @@ void fdrawbezier(float vec[4][3])
        }
        glEnd();
 }
+#endif
 
 void fdrawline(float x1, float y1, float x2, float y2)
 {
index ad54e8a5eff72b875023d550750de407c4b758d2..402f201dc818961b1b1013dd356ad5142e5b2cee 100644 (file)
@@ -565,8 +565,8 @@ static void drawcursor(Scene *scene, ARegion *ar, View3D *v3d)
                cpack(0xFFFFFF);
                circ((float)co[0], (float)co[1], f10);
                setlinestyle(0);
-               cpack(0x0);
-               
+
+               UI_ThemeColor(TH_VIEW_OVERLAY);
                sdrawline(co[0] - f20, co[1], co[0] - f5, co[1]);
                sdrawline(co[0] + f5, co[1], co[0] + f20, co[1]);
                sdrawline(co[0], co[1] - f20, co[0], co[1] - f5);
@@ -1059,7 +1059,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
        float hmargin, vmargin;
        float x1, x2, y1, y2;
        float x1i, x2i, y1i, y2i;
-       float x3, y3, x4, y4;
+
        rctf viewborder;
        Camera *ca = NULL;
        RegionView3D *rv3d = (RegionView3D *)ar->regiondata;
@@ -1135,17 +1135,18 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
                glRectf(x1i - 1, y1i - 1, x2i + 1, y2i + 1);
        }
 
-       UI_ThemeColor(TH_WIRE);
+       UI_ThemeColor(TH_VIEW_OVERLAY);
        glRectf(x1i, y1i, x2i, y2i);
 
        /* border */
        if (scene->r.mode & R_BORDER) {
-               cpack(0);
+               float x3, y3, x4, y4;
+
                x3 = x1 + scene->r.border.xmin * (x2 - x1);
                y3 = y1 + scene->r.border.ymin * (y2 - y1);
                x4 = x1 + scene->r.border.xmax * (x2 - x1);
                y4 = y1 + scene->r.border.ymax * (y2 - y1);
-               
+
                cpack(0x4040FF);
                glRecti(x3,  y3,  x4,  y4);
        }
@@ -1153,7 +1154,9 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
        /* safety border */
        if (ca) {
                if (ca->dtx & CAM_DTX_CENTER) {
-                       UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0);
+                       float x3, y3;
+
+                       UI_ThemeColorBlendShade(TH_VIEW_OVERLAY, TH_BACK, 0.25, 0);
 
                        x3 = x1 + 0.5f * (x2 - x1);
                        y3 = y1 + 0.5f * (y2 - y1);
@@ -1168,7 +1171,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
                }
 
                if (ca->dtx & CAM_DTX_CENTER_DIAG) {
-                       UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0);
+                       UI_ThemeColorBlendShade(TH_VIEW_OVERLAY, TH_BACK, 0.25, 0);
 
                        glBegin(GL_LINES);
                        glVertex2f(x1, y1);
@@ -1180,37 +1183,37 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
                }
 
                if (ca->dtx & CAM_DTX_THIRDS) {
-                       UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0);
+                       UI_ThemeColorBlendShade(TH_VIEW_OVERLAY, TH_BACK, 0.25, 0);
                        drawviewborder_grid3(x1, x2, y1, y2, 1.0f / 3.0f);
                }
 
                if (ca->dtx & CAM_DTX_GOLDEN) {
-                       UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0);
+                       UI_ThemeColorBlendShade(TH_VIEW_OVERLAY, TH_BACK, 0.25, 0);
                        drawviewborder_grid3(x1, x2, y1, y2, 1.0f - (1.0f / 1.61803399f));
                }
 
                if (ca->dtx & CAM_DTX_GOLDEN_TRI_A) {
-                       UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0);
+                       UI_ThemeColorBlendShade(TH_VIEW_OVERLAY, TH_BACK, 0.25, 0);
                        drawviewborder_triangle(x1, x2, y1, y2, 0, 'A');
                }
 
                if (ca->dtx & CAM_DTX_GOLDEN_TRI_B) {
-                       UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0);
+                       UI_ThemeColorBlendShade(TH_VIEW_OVERLAY, TH_BACK, 0.25, 0);
                        drawviewborder_triangle(x1, x2, y1, y2, 0, 'B');
                }
 
                if (ca->dtx & CAM_DTX_HARMONY_TRI_A) {
-                       UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0);
+                       UI_ThemeColorBlendShade(TH_VIEW_OVERLAY, TH_BACK, 0.25, 0);
                        drawviewborder_triangle(x1, x2, y1, y2, 1, 'A');
                }
 
                if (ca->dtx & CAM_DTX_HARMONY_TRI_B) {
-                       UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0);
+                       UI_ThemeColorBlendShade(TH_VIEW_OVERLAY, TH_BACK, 0.25, 0);
                        drawviewborder_triangle(x1, x2, y1, y2, 1, 'B');
                }
 
                if (ca->flag & CAM_SHOWTITLESAFE) {
-                       UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0);
+                       UI_ThemeColorBlendShade(TH_VIEW_OVERLAY, TH_BACK, 0.25, 0);
 
                        hmargin = 0.1f  * (x2 - x1);
                        vmargin = 0.05f * (y2 - y1);
@@ -1252,7 +1255,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
                        }
 
                        /* draw */
-                       UI_ThemeColorShade(TH_WIRE, 100);
+                       UI_ThemeColorShade(TH_VIEW_OVERLAY, 100);
                        uiDrawBox(GL_LINE_LOOP, rect.xmin, rect.ymin, rect.xmax, rect.ymax, 2.0f);
                }
        }
index a5aecbc1317542044e377f8232d0c5f7a8df63f9..6afe0ef896f539f6010d9cb9d35c635bd4c06644 100644 (file)
@@ -51,6 +51,8 @@
 
 #include "PIL_time.h" /* smoothview */
 
+#include "UI_resources.h"
+
 #include "view3d_intern.h"  /* own include */
 
 /* NOTE: these defines are saved in keymap files, do not change values but just add new ones */
@@ -248,8 +250,8 @@ static void drawFlyPixel(const struct bContext *UNUSED(C), ARegion *UNUSED(ar),
        y1 = yoff + 0.45f * fly->height;
        x2 = xoff + 0.55f * fly->width;
        y2 = yoff + 0.55f * fly->height;
-       cpack(0);
 
+       UI_ThemeColor(TH_VIEW_OVERLAY);
        glBegin(GL_LINES);
        /* bottom left */
        glVertex2f(x1, y1);
index 5fa21640d1e4e60d8e60ee1c9613b9eb2d576cf4..6c981fe86d0cff2beb2a2f722a6d15e2d2e96bd4 100644 (file)
@@ -57,6 +57,8 @@
 
 #include "PIL_time.h" /* smoothview */
 
+#include "UI_resources.h"
+
 #include "view3d_intern.h"  /* own include */
 
 #define EARTH_GRAVITY 9.80668f /* m/s2 */
@@ -315,8 +317,7 @@ static void drawWalkPixel(const struct bContext *UNUSED(C), ARegion *ar, void *a
                yoff = walk->ar->winy / 2;
        }
 
-       cpack(0);
-
+       UI_ThemeColor(TH_VIEW_OVERLAY);
        glBegin(GL_LINES);
        /* North */
        glVertex2i(xoff, yoff + inner_length);
index d52b494131b995e0432538375f859c13a15e3ac5..d3af2d0d1d977da7433eea6cb22def9307bb5a85 100644 (file)
@@ -1690,7 +1690,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
 
                switch (t->helpline) {
                        case HLP_SPRING:
-                               UI_ThemeColor(TH_WIRE);
+                               UI_ThemeColor(TH_VIEW_OVERLAY);
 
                                setlinestyle(3);
                                glBegin(GL_LINE_STRIP);
@@ -1708,7 +1708,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
                                glLineWidth(1.0);
                                break;
                        case HLP_HARROW:
-                               UI_ThemeColor(TH_WIRE);
+                               UI_ThemeColor(TH_VIEW_OVERLAY);
 
                                glTranslatef(mval[0], mval[1], 0);
 
@@ -1718,7 +1718,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
                                glLineWidth(1.0);
                                break;
                        case HLP_VARROW:
-                               UI_ThemeColor(TH_WIRE);
+                               UI_ThemeColor(TH_VIEW_OVERLAY);
 
                                glTranslatef(mval[0], mval[1], 0);
 
@@ -1734,7 +1734,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
                                float dist = sqrtf(dx * dx + dy * dy);
                                float delta_angle = min_ff(15.0f / dist, (float)M_PI / 4.0f);
                                float spacing_angle = min_ff(5.0f / dist, (float)M_PI / 12.0f);
-                               UI_ThemeColor(TH_WIRE);
+                               UI_ThemeColor(TH_VIEW_OVERLAY);
 
                                setlinestyle(3);
                                glBegin(GL_LINE_STRIP);
index b490d81761c0ed12cc8c2c605197a1dfdff0bc69..246094a337a9cea725394a3de84569474df5190d 100644 (file)
@@ -290,7 +290,7 @@ void ED_region_draw_mouse_line_cb(const bContext *C, ARegion *ar, void *arg_info
        const int mval_dst[2] = {win->eventstate->x - ar->winrct.xmin,
                                 win->eventstate->y - ar->winrct.ymin};
 
-       UI_ThemeColor(TH_WIRE);
+       UI_ThemeColor(TH_VIEW_OVERLAY);
        setlinestyle(3);
        glBegin(GL_LINE_STRIP);
        glVertex2iv(mval_dst);
index b9f1d604007bba78a96d83dab5884be8d20620a6..d584fd5adb0baa012cb6ef92e5baf73cd6f91e97 100644 (file)
@@ -233,8 +233,10 @@ typedef struct ThemeSpace {
        char hilite[4];
        char grid[4]; 
        
+       char view_overlay[4];
+
        char wire[4], wire_edit[4], select[4];
-       char lamp[4], speaker[4], empty[4], camera[4], pad[4];
+       char lamp[4], speaker[4], empty[4], camera[4];
        char active[4], group[4], group_active[4], transform[4];
        char vertex[4], vertex_select[4], vertex_unreferenced[4];
        char edge[4], edge_select[4];
index ba42dd1370bb040ec98ec99807219e8b919554a1..41953fb02394ee440c1ce55d71aba80908204e95 100644 (file)
@@ -1442,6 +1442,11 @@ static void rna_def_userdef_theme_space_view3d(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Camera", "");
        RNA_def_property_update(prop, 0, "rna_userdef_update");
 
+       prop = RNA_def_property(srna, "view_overlay", PROP_FLOAT, PROP_COLOR_GAMMA);
+       RNA_def_property_array(prop, 3);
+       RNA_def_property_ui_text(prop, "View Overlay", "");
+       RNA_def_property_update(prop, 0, "rna_userdef_update");
+
        prop = RNA_def_property(srna, "empty", PROP_FLOAT, PROP_COLOR_GAMMA);
        RNA_def_property_array(prop, 3);
        RNA_def_property_ui_text(prop, "Empty", "");