Tab theme colors

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()
This commit is contained in:
Campbell Barton 2014-01-23 11:44:35 +11:00
parent 4b820fb673
commit 80af3d6857
6 changed files with 105 additions and 91 deletions

@ -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

@ -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,

@ -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);

@ -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_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);
// 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);
#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_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_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_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->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;

@ -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 */

@ -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,6 +1078,28 @@ 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");
/* 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, "Tab Active", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop = RNA_def_property(srna, "tab_inactive", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Tab Inactive", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop = RNA_def_property(srna, "tab_back", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Tab Background", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop = RNA_def_property(srna, "tab_outline", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Tab Outline", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
/* } */
}
@ -1101,72 +1112,30 @@ static void rna_def_userdef_theme_space_gradient(BlenderRNA *brna)
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);
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Title", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop = RNA_def_property(srna, "text", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Text", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop = RNA_def_property(srna, "text_hi", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Text Highlight", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
/* header */
prop = RNA_def_property(srna, "header", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Header", "");
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");
/* 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");
/* gradient/background settings */
prop = RNA_def_property(srna, "gradients", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
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_userdef_theme_space_common(srna);
}
static void rna_def_userdef_theme_space_generic(BlenderRNA *brna)
{
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", "");
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, "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");
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");
prop = RNA_def_property(srna, "button_text_hi", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Region Text Highlight", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
/* } */
rna_def_userdef_theme_space_common(srna);
}
/* list / channels */