From 6c2ce7a3828e92083dfdad85eb683f4d27ed852b Mon Sep 17 00:00:00 2001 From: Jonathan Williamson Date: Mon, 27 Oct 2014 18:11:55 +0100 Subject: Add Theme Option for UI Emboss This adds a theme option for the embossing of UI widgets. By doing this users have much greater flexibility for creating nice themes. Previously many themes (particularly dark ones) looked quite bad due to the very obvious emboss. This made simpler, flat-style themes very challenging. Closes T42228 Reviewed by @campbellbarton --- source/blender/editors/include/UI_resources.h | 2 ++ source/blender/editors/interface/interface_widgets.c | 16 +++++++++++----- source/blender/editors/interface/resources.c | 12 ++++++++++++ source/blender/makesdna/DNA_userdef_types.h | 4 +++- source/blender/makesrna/intern/rna_userdef.c | 6 ++++++ 5 files changed, 34 insertions(+), 6 deletions(-) (limited to 'source/blender') diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index 5b61e76f514..8e37e871501 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -266,6 +266,8 @@ enum { TH_NLA_SOUND, TH_NLA_SOUND_SEL, + TH_EMBOSS, + TH_AXIS_X, /* X/Y/Z Axis */ TH_AXIS_Y, TH_AXIS_Z, diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index b7e61400cfa..46c2da902fe 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -746,6 +746,8 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) glEnableClientState(GL_VERTEX_ARRAY); for (j = 0; j < WIDGET_AA_JITTER; j++) { + unsigned char emboss[4]; + glTranslatef(jit[j][0], jit[j][1], 0.0f); /* outline */ @@ -753,13 +755,17 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) glVertexPointer(2, GL_FLOAT, 0, quad_strip); glDrawArrays(GL_QUAD_STRIP, 0, wtb->totvert * 2 + 2); - + /* emboss bottom shadow */ - if (wtb->emboss) { - glColor4f(1.0f, 1.0f, 1.0f, 0.02f); + UI_GetThemeColor4ubv(TH_EMBOSS, emboss); - glVertexPointer(2, GL_FLOAT, 0, quad_strip_emboss); - glDrawArrays(GL_QUAD_STRIP, 0, wtb->halfwayvert * 2); + if (wtb->emboss) { + UI_GetThemeColor4ubv(TH_EMBOSS, emboss); + if (emboss[3]) { + glColor4ubv(emboss); + glVertexPointer(2, GL_FLOAT, 0, quad_strip_emboss); + glDrawArrays(GL_QUAD_STRIP, 0, wtb->halfwayvert * 2); + } } glTranslatef(-jit[j][0], -jit[j][1], 0.0f); diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index bcd85333709..5dc9ee0264e 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -619,6 +619,9 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo cp = ts->nla_sound_sel; break; + case TH_EMBOSS: + cp = btheme->tui.emboss; break; + case TH_AXIS_X: cp = btheme->tui.xaxis; break; case TH_AXIS_Y: @@ -815,6 +818,8 @@ void ui_theme_init_default(void) btheme->tui.panel.show_header = false; rgba_char_args_set(btheme->tui.panel.header, 0, 0, 0, 25); + rgba_char_args_set_fl(btheme->tui.emboss, 1.0f, 1.0f, 1.0f, 0.02f); + rgba_char_args_set(btheme->tui.xaxis, 220, 0, 0, 255); rgba_char_args_set(btheme->tui.yaxis, 0, 220, 0, 255); rgba_char_args_set(btheme->tui.zaxis, 0, 0, 220, 255); @@ -2491,6 +2496,13 @@ void init_userdef_do_versions(void) } } + if (U.versionfile < 272 || (U.versionfile == 272 && U.subversionfile < 2)) { + bTheme *btheme; + for (btheme = U.themes.first; btheme; btheme = btheme->next) { + rgba_char_args_set_fl(btheme->tui.emboss, 1.0f, 1.0f, 1.0f, 0.02f); + } + } + if (U.pixelsize == 0.0f) U.pixelsize = 1.0f; diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 769e2573aa4..d8653e1f5fe 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -168,11 +168,13 @@ typedef struct ThemeUI { uiPanelColors panel; /* depricated, but we keep it for do_versions (2.66.1) */ + char emboss[4]; + /* fac: 0 - 1 for blend factor, width in pixels */ float menu_shadow_fac; short menu_shadow_width; - short pad; + short pad[3]; char iconfile[256]; // FILE_MAXFILE length float icon_alpha; diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 1bad9570893..a23c3ea8534 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -1018,6 +1018,12 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Icon Alpha", "Transparency of icons in the interface, to reduce contrast"); RNA_def_property_update(prop, 0, "rna_userdef_update"); + prop = RNA_def_property(srna, "emboss", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "emboss"); + RNA_def_property_array(prop, 4); + RNA_def_property_ui_text(prop, "Emboss", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + /* axis */ prop = RNA_def_property(srna, "axis_x", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "xaxis"); -- cgit v1.2.3