Tab theme colors
authorCampbell Barton <ideasman42@gmail.com>
Thu, 23 Jan 2014 00:44:35 +0000 (11:44 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 23 Jan 2014 00:48:36 +0000 (11:48 +1100)
patch D234 from Jonathan Williamson with edits

- de-duplicate rna_def_userdef_theme_space_gradient and rna_def_userdef_theme_space_generic
- ui_theme_init_new_do now always sets theme settings (no need to test),
  used by bpy.ops.ui.reset_default_theme()

source/blender/blenkernel/BKE_blender.h
source/blender/editors/include/UI_resources.h
source/blender/editors/interface/interface_panel.c
source/blender/editors/interface/resources.c
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesrna/intern/rna_userdef.c

index 99595b36f6f24656e968854f32363714d2dba9d1..960ca1b1d2023b0b1dc94c8015170dd51f6bcd0d 100644 (file)
@@ -42,7 +42,7 @@ extern "C" {
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION         269
-#define BLENDER_SUBVERSION      9
+#define BLENDER_SUBVERSION      10
 /* 262 was the last editmesh release but it has compatibility code for bmesh data */
 #define BLENDER_MINVERSION      262
 #define BLENDER_MINSUBVERSION   0
index 23498dcf4aaf3bff28cab4e0074eda416a682a10..4e353b18be87e5d3db1f02fc3b9497f6e3603bcf 100644 (file)
@@ -58,6 +58,10 @@ enum {
        TH_TEXT,
        TH_TEXT_HI,
        TH_TITLE,
+       TH_TAB_ACTIVE,
+       TH_TAB_INACTIVE,
+       TH_TAB_BACK,
+       TH_TAB_OUTLINE,
        
        TH_HEADER,
        TH_HEADERDESEL,
index 696496518378b5b1ecf7abbb4e7d8822714438c4..14523efaf188b01d9e8e213a05eac613f252f9a1 100644 (file)
@@ -1418,9 +1418,12 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active)
        unsigned char theme_col_text[4];
        unsigned char theme_col_text_hi[4];
 
-       /* Secondary theme colors */
+       /* Tab colors */
        unsigned char theme_col_tab_bg[4];
+       unsigned char theme_col_tab_active[4];
        unsigned char theme_col_tab_inactive[4];
+
+       /* Secondary theme colors */
        unsigned char theme_col_tab_outline[4];
        unsigned char theme_col_tab_divider[4];  /* line that divides tabs from the main area */
        unsigned char theme_col_tab_highlight[4];
@@ -1432,11 +1435,12 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active)
        UI_GetThemeColor4ubv(TH_TEXT, theme_col_text);
        UI_GetThemeColor4ubv(TH_TEXT_HI, theme_col_text_hi);
 
-       blend_color_interpolate_byte(theme_col_tab_bg, theme_col_back, theme_col_text, 0.2f);
-       blend_color_interpolate_byte(theme_col_tab_inactive, theme_col_back, theme_col_text, 0.10f);
-       blend_color_interpolate_byte(theme_col_tab_outline, theme_col_back, theme_col_text, 0.3f);
-       blend_color_interpolate_byte(theme_col_tab_divider, theme_col_back, theme_col_text, 0.3f);
+       UI_GetThemeColor4ubv(TH_TAB_BACK, theme_col_tab_bg);
+       UI_GetThemeColor4ubv(TH_TAB_ACTIVE, theme_col_tab_active);
+       UI_GetThemeColor4ubv(TH_TAB_INACTIVE, theme_col_tab_inactive);
+       UI_GetThemeColor4ubv(TH_TAB_OUTLINE, theme_col_tab_outline);
 
+       blend_color_interpolate_byte(theme_col_tab_divider, theme_col_back, theme_col_text, 0.3f);
        blend_color_interpolate_byte(theme_col_tab_highlight, theme_col_back, theme_col_text_hi, 0.2f);
        blend_color_interpolate_byte(theme_col_tab_highlight_inactive, theme_col_tab_inactive, theme_col_text_hi, 0.12f);
 
@@ -1509,7 +1513,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active)
                if (is_active)
 #endif
                {
-                       glColor3ubv(is_active ? theme_col_back : theme_col_tab_inactive);
+                       glColor3ubv(is_active ? theme_col_tab_active : theme_col_tab_inactive);
                        ui_panel_category_draw_tab(GL_POLYGON, rct->xmin, rct->ymin, rct->xmax, rct->ymax,
                                                   tab_curve_radius - px, roundboxtype, true, true, NULL);
 
index 2150da8893a6f40d06ef38fdb3016d984bf95d33..63f4681c77909132d2acc9dc4445ad70f82e6f16 100644 (file)
@@ -246,6 +246,15 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
                                case TH_BUTBACK_TEXT_HI:
                                        cp = ts->button_text_hi; break;
 
+                               case TH_TAB_ACTIVE:
+                                       cp = ts->tab_active; break;
+                               case TH_TAB_INACTIVE:
+                                       cp = ts->tab_inactive; break;
+                               case TH_TAB_BACK:
+                                       cp = ts->tab_back; break;
+                               case TH_TAB_OUTLINE:
+                                       cp = ts->tab_outline; break;
+
                                case TH_SHADE1:
                                        cp = ts->shade1; break;
                                case TH_SHADE2:
@@ -713,23 +722,30 @@ static void ui_theme_init_boneColorSets(bTheme *btheme)
 /* use this call to init new variables in themespace, if they're same for all */
 static void ui_theme_init_new_do(ThemeSpace *ts)
 {
-       rgba_char_args_test_set(ts->header_text,        0, 0, 0, 255);
-       rgba_char_args_test_set(ts->header_title,   0, 0, 0, 255);
-       rgba_char_args_test_set(ts->header_text_hi, 255, 255, 255, 255);
-
-//     rgba_char_args_test_set(ts->panel_text,     0, 0, 0, 255);
-//     rgba_char_args_test_set(ts->panel_title,        0, 0, 0, 255);
-//     rgba_char_args_test_set(ts->panel_text_hi,  255, 255, 255, 255);
-
-       rgba_char_args_test_set(ts->button,         145, 145, 145, 245);
-       rgba_char_args_test_set(ts->button_title,   0, 0, 0, 255);
-       rgba_char_args_test_set(ts->button_text,        0, 0, 0, 255);
-       rgba_char_args_test_set(ts->button_text_hi, 255, 255, 255, 255);
-
-       rgba_char_args_test_set(ts->list,           165, 165, 165, 255);
-       rgba_char_args_test_set(ts->list_title,     0, 0, 0, 255);
-       rgba_char_args_test_set(ts->list_text,      0, 0, 0, 255);
-       rgba_char_args_test_set(ts->list_text_hi,   255, 255, 255, 255);
+       rgba_char_args_set(ts->header_text,    0, 0, 0, 255);
+       rgba_char_args_set(ts->header_title,   0, 0, 0, 255);
+       rgba_char_args_set(ts->header_text_hi, 255, 255, 255, 255);
+
+#if 0
+       rgba_char_args_set(ts->panel_text,     0, 0, 0, 255);
+       rgba_char_args_set(ts->panel_title,        0, 0, 0, 255);
+       rgba_char_args_set(ts->panel_text_hi,  255, 255, 255, 255);
+#endif
+
+       rgba_char_args_set(ts->button,         145, 145, 145, 245);
+       rgba_char_args_set(ts->button_title,   0, 0, 0, 255);
+       rgba_char_args_set(ts->button_text,        0, 0, 0, 255);
+       rgba_char_args_set(ts->button_text_hi, 255, 255, 255, 255);
+
+       rgba_char_args_set(ts->list,           165, 165, 165, 255);
+       rgba_char_args_set(ts->list_title,     0, 0, 0, 255);
+       rgba_char_args_set(ts->list_text,      0, 0, 0, 255);
+       rgba_char_args_set(ts->list_text_hi,   255, 255, 255, 255);
+
+       rgba_char_args_set(ts->tab_active,     114, 114, 114, 255);
+       rgba_char_args_set(ts->tab_inactive,   100, 100, 100, 255);
+       rgba_char_args_set(ts->tab_back,       70, 70, 70, 255);
+       rgba_char_args_set(ts->tab_outline,    60, 60, 60, 255);
 }
 
 static void ui_theme_init_new(bTheme *btheme)
@@ -2386,6 +2402,20 @@ void init_userdef_do_versions(void)
                        U.gpencil_new_layer_col[3] = 0.9f;
                }
        }
+
+       if (U.versionfile < 269 || (U.versionfile == 269 && U.subversionfile < 10)) {
+               bTheme *btheme;
+               for (btheme = U.themes.first; btheme; btheme = btheme->next) {
+                       ThemeSpace *ts;
+
+                       for (ts = UI_THEMESPACE_START(btheme); ts != UI_THEMESPACE_END(btheme); ts++) {
+                               rgba_char_args_set(ts->tab_active, 114, 114, 114, 255);
+                               rgba_char_args_set(ts->tab_inactive, 100, 100, 100, 255);
+                               rgba_char_args_set(ts->tab_back, 70, 70, 70, 255);
+                               rgba_char_args_set(ts->tab_outline, 60, 60, 60, 255);
+                       }
+               }
+       }
        
        if (U.pixelsize == 0.0f)
                U.pixelsize = 1.0f;
index 864cc8170d69e244325b7d86892791e07b334d36..dca007f83ec99ba588fb123e75bf5cbfce55be80 100644 (file)
@@ -154,6 +154,7 @@ typedef struct uiGradientColors {
        char high_gradient[4];
        int show_grad;
        int pad2;
+
 } uiGradientColors;
 
 typedef struct ThemeUI {
@@ -197,6 +198,12 @@ typedef struct ThemeSpace {
        char header_text[4];
        char header_text_hi[4];
 
+       /* region tabs */
+       char tab_active[4];
+       char tab_inactive[4];
+       char tab_back[4];
+       char tab_outline[4];
+
        /* button/tool regions */
        char button[4];                 /* region background */
        char button_title[4];   /* panel title */
index e2063b82670cc4a5957a45e26f1ab3bd1db53ea5..c851acd64d97005458547fedf9f023eb6a088cd5 100644 (file)
@@ -1016,21 +1016,10 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna)
        RNA_def_property_update(prop, 0, "rna_userdef_update");
 }
 
-static void rna_def_userdef_theme_space_generic(BlenderRNA *brna)
+static void rna_def_userdef_theme_space_common(StructRNA *srna)
 {
-       StructRNA *srna;
        PropertyRNA *prop;
 
-       srna = RNA_def_struct(brna, "ThemeSpaceGeneric", NULL);
-       RNA_def_struct_sdna(srna, "ThemeSpace");
-       RNA_def_struct_ui_text(srna, "Theme Space Settings", "");
-
-       /* window */
-       prop = RNA_def_property(srna, "back", PROP_FLOAT, PROP_COLOR_GAMMA);
-       RNA_def_property_array(prop, 3);
-       RNA_def_property_ui_text(prop, "Window Background", "");
-       RNA_def_property_update(prop, 0, "rna_userdef_update");
-
        prop = RNA_def_property(srna, "title", PROP_FLOAT, PROP_COLOR_GAMMA);
        RNA_def_property_array(prop, 3);
        RNA_def_property_ui_text(prop, "Title", "");
@@ -1089,55 +1078,39 @@ static void rna_def_userdef_theme_space_generic(BlenderRNA *brna)
        RNA_def_property_array(prop, 3);
        RNA_def_property_ui_text(prop, "Region Text Highlight", "");
        RNA_def_property_update(prop, 0, "rna_userdef_update");
-/*     } */
-}
-
-static void rna_def_userdef_theme_space_gradient(BlenderRNA *brna)
-{
-       StructRNA *srna;
-       PropertyRNA *prop;
 
-       srna = RNA_def_struct(brna, "ThemeSpaceGradient", NULL);
-       RNA_def_struct_sdna(srna, "ThemeSpace");
-       RNA_def_struct_ui_text(srna, "Theme Space Settings", "");
-
-       /* window */
-       prop = RNA_def_property(srna, "title", PROP_FLOAT, PROP_COLOR_GAMMA);
+       /* tabs */
+       prop = RNA_def_property(srna, "tab_active", PROP_FLOAT, PROP_COLOR_GAMMA);
        RNA_def_property_array(prop, 3);
-       RNA_def_property_ui_text(prop, "Title", "");
+       RNA_def_property_ui_text(prop, "Tab Active", "");
        RNA_def_property_update(prop, 0, "rna_userdef_update");
 
-       prop = RNA_def_property(srna, "text", PROP_FLOAT, PROP_COLOR_GAMMA);
+       prop = RNA_def_property(srna, "tab_inactive", PROP_FLOAT, PROP_COLOR_GAMMA);
        RNA_def_property_array(prop, 3);
-       RNA_def_property_ui_text(prop, "Text", "");
+       RNA_def_property_ui_text(prop, "Tab Inactive", "");
        RNA_def_property_update(prop, 0, "rna_userdef_update");
 
-       prop = RNA_def_property(srna, "text_hi", PROP_FLOAT, PROP_COLOR_GAMMA);
+       prop = RNA_def_property(srna, "tab_back", PROP_FLOAT, PROP_COLOR_GAMMA);
        RNA_def_property_array(prop, 3);
-       RNA_def_property_ui_text(prop, "Text Highlight", "");
+       RNA_def_property_ui_text(prop, "Tab Background", "");
        RNA_def_property_update(prop, 0, "rna_userdef_update");
 
-       /* header */
-       prop = RNA_def_property(srna, "header", PROP_FLOAT, PROP_COLOR_GAMMA);
+       prop = RNA_def_property(srna, "tab_outline", PROP_FLOAT, PROP_COLOR_GAMMA);
        RNA_def_property_array(prop, 3);
-       RNA_def_property_ui_text(prop, "Header", "");
+       RNA_def_property_ui_text(prop, "Tab Outline", "");
        RNA_def_property_update(prop, 0, "rna_userdef_update");
 
-       prop = RNA_def_property(srna, "header_text", PROP_FLOAT, PROP_COLOR_GAMMA);
-       RNA_def_property_array(prop, 3);
-       RNA_def_property_ui_text(prop, "Header Text", "");
-       RNA_def_property_update(prop, 0, "rna_userdef_update");
+/*     } */
+}
 
-       prop = RNA_def_property(srna, "header_text_hi", PROP_FLOAT, PROP_COLOR_GAMMA);
-       RNA_def_property_array(prop, 3);
-       RNA_def_property_ui_text(prop, "Header Text Highlight", "");
-       RNA_def_property_update(prop, 0, "rna_userdef_update");
+static void rna_def_userdef_theme_space_gradient(BlenderRNA *brna)
+{
+       StructRNA *srna;
+       PropertyRNA *prop;
 
-       /* panel settings */
-       prop = RNA_def_property(srna, "panelcolors", PROP_POINTER, PROP_NONE);
-       RNA_def_property_flag(prop, PROP_NEVER_NULL);
-       RNA_def_property_ui_text(prop, "Panel Colors", "");
-       RNA_def_property_update(prop, 0, "rna_userdef_update");
+       srna = RNA_def_struct(brna, "ThemeSpaceGradient", NULL);
+       RNA_def_struct_sdna(srna, "ThemeSpace");
+       RNA_def_struct_ui_text(srna, "Theme Space Settings", "");
 
        /* gradient/background settings */
        prop = RNA_def_property(srna, "gradients", PROP_POINTER, PROP_NONE);
@@ -1145,28 +1118,24 @@ static void rna_def_userdef_theme_space_gradient(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Gradient Colors", "");
        RNA_def_property_update(prop, 0, "rna_userdef_update");
 
-       /* buttons */
-/*     if (! ELEM(spacetype, SPACE_BUTS, SPACE_OUTLINER)) { */
-       prop = RNA_def_property(srna, "button", PROP_FLOAT, PROP_COLOR_GAMMA);
-       RNA_def_property_array(prop, 4);
-       RNA_def_property_ui_text(prop, "Region Background", "");
-       RNA_def_property_update(prop, 0, "rna_userdef_update");
+       rna_def_userdef_theme_space_common(srna);
+}
 
-       prop = RNA_def_property(srna, "button_title", PROP_FLOAT, PROP_COLOR_GAMMA);
-       RNA_def_property_array(prop, 3);
-       RNA_def_property_ui_text(prop, "Region Text Titles", "");
-       RNA_def_property_update(prop, 0, "rna_userdef_update");
+static void rna_def_userdef_theme_space_generic(BlenderRNA *brna)
+{
+       StructRNA *srna;
+       PropertyRNA *prop;
 
-       prop = RNA_def_property(srna, "button_text", PROP_FLOAT, PROP_COLOR_GAMMA);
-       RNA_def_property_array(prop, 3);
-       RNA_def_property_ui_text(prop, "Region Text", "");
-       RNA_def_property_update(prop, 0, "rna_userdef_update");
+       srna = RNA_def_struct(brna, "ThemeSpaceGeneric", NULL);
+       RNA_def_struct_sdna(srna, "ThemeSpace");
+       RNA_def_struct_ui_text(srna, "Theme Space Settings", "");
 
-       prop = RNA_def_property(srna, "button_text_hi", PROP_FLOAT, PROP_COLOR_GAMMA);
+       prop = RNA_def_property(srna, "back", PROP_FLOAT, PROP_COLOR_GAMMA);
        RNA_def_property_array(prop, 3);
-       RNA_def_property_ui_text(prop, "Region Text Highlight", "");
+       RNA_def_property_ui_text(prop, "Window Background", "");
        RNA_def_property_update(prop, 0, "rna_userdef_update");
-/*     } */
+
+       rna_def_userdef_theme_space_common(srna);
 }
 
 /* list / channels */