diff options
Diffstat (limited to 'source/blender/editors/interface/resources.c')
-rw-r--r-- | source/blender/editors/interface/resources.c | 332 |
1 files changed, 283 insertions, 49 deletions
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index ce25817c147..c78342a0713 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -54,6 +54,8 @@ #include "BIF_gl.h" +#include "BLF_api.h" + #include "UI_interface.h" #include "UI_interface_icons.h" @@ -154,18 +156,15 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo case SPACE_CONSOLE: ts = &btheme->tconsole; break; - case SPACE_TIME: - ts = &btheme->ttime; - break; case SPACE_NODE: ts = &btheme->tnode; break; - case SPACE_LOGIC: - ts = &btheme->tlogic; - break; case SPACE_CLIP: ts = &btheme->tclip; break; + case SPACE_TOPBAR: + ts = &btheme->ttopbar; + break; default: ts = &btheme->tv3d; break; @@ -231,6 +230,7 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo headerdesel[0] = cp[0] > 10 ? cp[0] - 10 : 0; headerdesel[1] = cp[1] > 10 ? cp[1] - 10 : 0; headerdesel[2] = cp[2] > 10 ? cp[2] - 10 : 0; + headerdesel[3] = cp[3]; cp = headerdesel; break; case TH_HEADER_TEXT: @@ -659,6 +659,9 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo case TH_WIDGET_EMBOSS: cp = btheme->tui.widget_emboss; break; + case TH_EDITOR_OUTLINE: + cp = btheme->tui.editor_outline; + break; case TH_AXIS_X: cp = btheme->tui.xaxis; break; case TH_AXIS_Y: @@ -666,6 +669,17 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo case TH_AXIS_Z: cp = btheme->tui.zaxis; break; + case TH_MANIPULATOR_HI: + cp = btheme->tui.manipulator_hi; break; + case TH_MANIPULATOR_PRIMARY: + cp = btheme->tui.manipulator_primary; break; + case TH_MANIPULATOR_SECONDARY: + cp = btheme->tui.manipulator_secondary; break; + case TH_MANIPULATOR_A: + cp = btheme->tui.manipulator_a; break; + case TH_MANIPULATOR_B: + cp = btheme->tui.manipulator_b; break; + case TH_INFO_SELECTED: cp = ts->info_selected; break; @@ -836,6 +850,15 @@ static void ui_theme_space_init_handles_color(ThemeSpace *theme_space) rgba_char_args_set(theme_space->act_spline, 0xdb, 0x25, 0x12, 255); } +static void ui_theme_space_init_manipulator_colors(bTheme *btheme) +{ + rgba_char_args_set(btheme->tui.manipulator_hi, 255, 255, 255, 255); + rgba_char_args_set(btheme->tui.manipulator_primary, 222, 255, 13, 255); + rgba_char_args_set(btheme->tui.manipulator_secondary, 0, 255, 255, 255); + rgba_char_args_set(btheme->tui.manipulator_a, 23, 127, 23, 255); + rgba_char_args_set(btheme->tui.manipulator_b, 127, 23, 23, 255); +} + /** * initialize default theme * \note: when you add new colors, created & saved themes need initialized @@ -862,6 +885,7 @@ void ui_theme_init_default(void) btheme->tui.iconfile[0] = 0; rgba_char_args_set(btheme->tui.wcol_tooltip.text, 255, 255, 255, 255); rgba_char_args_set_fl(btheme->tui.widget_emboss, 1.0f, 1.0f, 1.0f, 0.02f); + rgba_char_args_set_fl(btheme->tui.editor_outline, 0.25f, 0.25f, 0.25f, 1.0f); rgba_char_args_set(btheme->tui.xaxis, 220, 0, 0, 255); rgba_char_args_set(btheme->tui.yaxis, 0, 220, 0, 255); @@ -876,6 +900,9 @@ void ui_theme_init_default(void) /* common (new) variables */ ui_theme_init_new(btheme); + /* Manipulator. */ + ui_theme_space_init_manipulator_colors(btheme); + /* space view3d */ rgba_char_args_set_fl(btheme->tv3d.back, 0.225, 0.225, 0.225, 1.0); rgba_char_args_set(btheme->tv3d.text, 0, 0, 0, 255); @@ -1185,10 +1212,6 @@ void ui_theme_init_default(void) rgba_char_args_set(btheme->tnode.console_output, 223, 202, 53, 255); /* interface nodes */ btheme->tnode.noodle_curving = 5; - /* space logic */ - btheme->tlogic = btheme->tv3d; - rgba_char_args_set(btheme->tlogic.back, 100, 100, 100, 255); - /* space clip */ btheme->tclip = btheme->tv3d; @@ -1207,6 +1230,14 @@ void ui_theme_init_default(void) rgba_char_args_set(btheme->tclip.strip_select, 0xff, 0x8c, 0x00, 0xff); btheme->tclip.handle_vertex_size = 5; ui_theme_space_init_handles_color(&btheme->tclip); + + /* space topbar */ + char tmp[4]; + btheme->ttopbar = btheme->tv3d; + /* swap colors */ + copy_v4_v4_char(tmp, btheme->ttopbar.header); + copy_v4_v4_char(btheme->ttopbar.header, btheme->ttopbar.tab_inactive); + copy_v4_v4_char(btheme->ttopbar.back, tmp); } void ui_style_init_default(void) @@ -1273,25 +1304,35 @@ void UI_ThemeColor4(int colorid) cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid); glColor4ubv(cp); - } /* set the color with offset for shades */ void UI_ThemeColorShade(int colorid, int offset) { - int r, g, b; + unsigned char col[4]; + UI_GetThemeColorShade4ubv(colorid, offset, col); + glColor4ubv(col); +} + +void UI_ThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset) +{ + int r, g, b, a; const unsigned char *cp; cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid); - r = offset + (int) cp[0]; + r = coloffset + (int) cp[0]; CLAMP(r, 0, 255); - g = offset + (int) cp[1]; + g = coloffset + (int) cp[1]; CLAMP(g, 0, 255); - b = offset + (int) cp[2]; + b = coloffset + (int) cp[2]; CLAMP(b, 0, 255); - glColor4ub(r, g, b, cp[3]); + a = alphaoffset + (int) cp[3]; + CLAMP(a, 0, 255); + + glColor4ub(r, g, b, a); } -void UI_ThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset) + +void UI_GetThemeColorShadeAlpha4ubv(int colorid, int coloffset, int alphaoffset, unsigned char col[4]) { int r, g, b, a; const unsigned char *cp; @@ -1305,7 +1346,11 @@ void UI_ThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset) CLAMP(b, 0, 255); a = alphaoffset + (int) cp[3]; CLAMP(a, 0, 255); - glColor4ub(r, g, b, a); + + col[0] = r; + col[1] = g; + col[2] = b; + col[3] = a; } void UI_GetThemeColorBlend3ubv(int colorid1, int colorid2, float fac, unsigned char col[3]) @@ -1321,6 +1366,19 @@ void UI_GetThemeColorBlend3ubv(int colorid1, int colorid2, float fac, unsigned c col[2] = floorf((1.0f - fac) * cp1[2] + fac * cp2[2]); } +void UI_GetThemeColorBlend3f(int colorid1, int colorid2, float fac, float r_col[3]) +{ + const unsigned char *cp1, *cp2; + + cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1); + cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2); + + CLAMP(fac, 0.0f, 1.0f); + r_col[0] = ((1.0f - fac) * cp1[0] + fac * cp2[0]) / 255.0f; + r_col[1] = ((1.0f - fac) * cp1[1] + fac * cp2[1]) / 255.0f; + r_col[2] = ((1.0f - fac) * cp1[2] + fac * cp2[2]) / 255.0f; +} + /* blend between to theme colors, and set it */ void UI_ThemeColorBlend(int colorid1, int colorid2, float fac) { @@ -1373,6 +1431,12 @@ void UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, int off glColor4ub(r, g, b, a); } +void UI_FontThemeColor(int fontid, int colorid) +{ + unsigned char color[4]; + UI_GetThemeColor4ubv(colorid, color); + BLF_color4ubv(fontid, color); +} /* get individual values, not scaled */ float UI_GetThemeValuef(int colorid) @@ -1471,6 +1535,111 @@ void UI_GetThemeColorShade3ubv(int colorid, int offset, unsigned char col[3]) col[2] = b; } +void UI_GetThemeColorBlendShade3ubv(int colorid1, int colorid2, float fac, int offset, unsigned char col[3]) +{ + const unsigned char *cp1, *cp2; + + cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1); + cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2); + + CLAMP(fac, 0.0f, 1.0f); + + float blend[3]; + blend[0] = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]); + blend[1] = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]); + blend[2] = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]); + + unit_float_to_uchar_clamp_v3(col, blend); +} + +void UI_GetThemeColorShade4ubv(int colorid, int offset, unsigned char col[4]) +{ + int r, g, b; + const unsigned char *cp; + + cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid); + r = offset + (int) cp[0]; + CLAMP(r, 0, 255); + g = offset + (int) cp[1]; + CLAMP(g, 0, 255); + b = offset + (int) cp[2]; + CLAMP(b, 0, 255); + + col[0] = r; + col[1] = g; + col[2] = b; + col[3] = cp[3]; +} + +void UI_GetThemeColorShadeAlpha4fv(int colorid, int coloffset, int alphaoffset, float col[4]) +{ + int r, g, b, a; + const unsigned char *cp; + + cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid); + + r = coloffset + (int) cp[0]; + CLAMP(r, 0, 255); + g = coloffset + (int) cp[1]; + CLAMP(g, 0, 255); + b = coloffset + (int) cp[2]; + CLAMP(b, 0, 255); + a = alphaoffset + (int) cp[3]; + CLAMP(b, 0, 255); + + col[0] = ((float)r) / 255.0f; + col[1] = ((float)g) / 255.0f; + col[2] = ((float)b) / 255.0f; + col[3] = ((float)a) / 255.0f; +} + +void UI_GetThemeColorBlendShade3fv(int colorid1, int colorid2, float fac, int offset, float col[3]) +{ + int r, g, b; + const unsigned char *cp1, *cp2; + + cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1); + cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2); + + CLAMP(fac, 0.0f, 1.0f); + + r = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]); + CLAMP(r, 0, 255); + g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]); + CLAMP(g, 0, 255); + b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]); + CLAMP(b, 0, 255); + + col[0] = ((float)r) / 255.0f; + col[1] = ((float)g) / 255.0f; + col[2] = ((float)b) / 255.0f; +} + +void UI_GetThemeColorBlendShade4fv(int colorid1, int colorid2, float fac, int offset, float col[4]) +{ + int r, g, b, a; + const unsigned char *cp1, *cp2; + + cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1); + cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2); + + CLAMP(fac, 0.0f, 1.0f); + + r = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]); + CLAMP(r, 0, 255); + g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]); + CLAMP(g, 0, 255); + b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]); + CLAMP(b, 0, 255); + a = offset + floorf((1.0f - fac) * cp1[3] + fac * cp2[3]); + CLAMP(a, 0, 255); + + col[0] = ((float)r) / 255.0f; + col[1] = ((float)g) / 255.0f; + col[2] = ((float)b) / 255.0f; + col[3] = ((float)a) / 255.0f; +} + /* get the color, in char pointer */ void UI_GetThemeColor3ubv(int colorid, unsigned char col[3]) { @@ -1659,11 +1828,9 @@ void init_userdef_do_versions(void) U.savetime = 1; // XXX error(STRINGIFY(BLENDER_STARTUP_FILE)" is buggy, please consider removing it.\n"); } - /* transform widget settings */ - if (U.tw_hotspot == 0) { - U.tw_hotspot = 14; - U.tw_size = 25; /* percentage of window size */ - U.tw_handlesize = 16; /* percentage of widget radius */ + if (U.manipulator_size == 0) { + U.manipulator_size = 75; + U.manipulator_flag |= USER_MANIPULATOR_DRAW; } if (U.pad_rot_angle == 0.0f) U.pad_rot_angle = 15.0f; @@ -1943,13 +2110,6 @@ void init_userdef_do_versions(void) if (btheme->tui.wcol_num.outline[3] == 0) ui_widget_color_init(&btheme->tui); - - /* Logic editor theme, check for alpha==0 is safe, then color was never set */ - if (btheme->tlogic.syntaxn[3] == 0) { - /* re-uses syntax color storage */ - btheme->tlogic = btheme->tv3d; - rgba_char_args_set(btheme->tlogic.back, 100, 100, 100, 255); - } rgba_char_args_set_fl(btheme->tinfo.back, 0.45, 0.45, 0.45, 1.0); rgba_char_args_set_fl(btheme->tuserpref.back, 0.45, 0.45, 0.45, 1.0); @@ -1986,8 +2146,6 @@ void init_userdef_do_versions(void) strcpy(km->idname, "3D View Generic"); else if (STREQ(km->idname, "EditMesh")) strcpy(km->idname, "Mesh"); - else if (STREQ(km->idname, "TimeLine")) - strcpy(km->idname, "Timeline"); else if (STREQ(km->idname, "UVEdit")) strcpy(km->idname, "UV Editor"); else if (STREQ(km->idname, "Animation_Channels")) @@ -2014,10 +2172,6 @@ void init_userdef_do_versions(void) strcpy(km->idname, "Property Editor"); } } - if (!USER_VERSION_ATLEAST(250, 16)) { - if (U.wmdrawmethod == USER_DRAW_TRIPLE) - U.wmdrawmethod = USER_DRAW_AUTOMATIC; - } if (!USER_VERSION_ATLEAST(252, 3)) { if (U.flag & USER_LMOUSESELECT) @@ -2497,9 +2651,6 @@ void init_userdef_do_versions(void) if (!USER_VERSION_ATLEAST(269, 9)) { bTheme *btheme; - - U.tw_size = U.tw_size * 5.0f; - /* Action Editor (and NLA Editor) - Keyframe Colors */ /* Graph Editor - larger vertex size defaults */ for (btheme = U.themes.first; btheme; btheme = btheme->next) { @@ -2633,10 +2784,6 @@ void init_userdef_do_versions(void) rgba_char_args_set(btheme->tnode.gp_vertex, 0, 0, 0, 255); rgba_char_args_set(btheme->tnode.gp_vertex_select, 255, 133, 0, 255); btheme->tnode.gp_vertex_size = 3; - - /* Timeline Keyframe Indicators */ - rgba_char_args_set(btheme->ttime.time_keyframe, 0xDD, 0xD7, 0x00, 0xFF); - rgba_char_args_set(btheme->ttime.time_gp_keyframe, 0xB5, 0xE6, 0x1D, 0xFF); } } @@ -2766,13 +2913,97 @@ void init_userdef_do_versions(void) U.transopts &= ~( USER_TR_DEPRECATED_2 | USER_TR_DEPRECATED_3 | USER_TR_DEPRECATED_4 | USER_TR_DEPRECATED_6 | USER_TR_DEPRECATED_7); - U.gameflags &= ~( - USER_GL_RENDER_DEPRECATED_0 | USER_GL_RENDER_DEPRECATED_1 | - USER_GL_RENDER_DEPRECATED_3 | USER_GL_RENDER_DEPRECATED_4); U.uiflag |= USER_LOCK_CURSOR_ADJUST; } + if (!USER_VERSION_ATLEAST(280, 9)) { + /* interface_widgets.c */ + struct uiWidgetColors wcol_tab = { + {60, 60, 60, 255}, + {83, 83, 83, 255}, + {114, 114, 114, 255}, + {90, 90, 90, 255}, + + {0, 0, 0, 255}, + {0, 0, 0, 255}, + + 0, + 0, 0 + }; + + for (bTheme *btheme = U.themes.first; btheme; btheme = btheme->next) { + char tmp[4]; + + btheme->tui.wcol_tab = wcol_tab; + btheme->ttopbar = btheme->tv3d; + /* swap colors */ + copy_v4_v4_char(tmp, btheme->ttopbar.header); + copy_v4_v4_char(btheme->ttopbar.header, btheme->ttopbar.tab_inactive); + copy_v4_v4_char(btheme->ttopbar.back, tmp); + } + } + + if (!USER_VERSION_ATLEAST(280, 9)) { + /* Timeline removal */ + for (bTheme *btheme = U.themes.first; btheme; btheme = btheme->next) { + if (btheme->tipo.anim_active[3] == 0) { + rgba_char_args_set(btheme->tipo.anim_active, 204, 112, 26, 102); + } + if (btheme->tseq.anim_active[3] == 0) { + rgba_char_args_set(btheme->tseq.anim_active, 204, 112, 26, 102); + } + } + } + + if (!USER_VERSION_ATLEAST(280, 10)) { + /* Roundness */ + for (bTheme *btheme = U.themes.first; btheme; btheme = btheme->next) { + btheme->tui.wcol_regular.roundness = 0.25f; + btheme->tui.wcol_tool.roundness = 0.2f; + btheme->tui.wcol_text.roundness = 0.2f; + btheme->tui.wcol_radio.roundness = 0.2f; + btheme->tui.wcol_option.roundness = 0.333333f; + btheme->tui.wcol_toggle.roundness = 0.25f; + btheme->tui.wcol_num.roundness = 0.5f; + btheme->tui.wcol_numslider.roundness = 0.5f; + btheme->tui.wcol_tab.roundness = 0.25f; + btheme->tui.wcol_menu.roundness = 0.2f; + btheme->tui.wcol_pulldown.roundness = 0.2f; + btheme->tui.wcol_menu_back.roundness = 0.25f; + btheme->tui.wcol_menu_item.roundness = 0.25f; + btheme->tui.wcol_tooltip.roundness = 0.25f; + btheme->tui.wcol_box.roundness = 0.2f; + btheme->tui.wcol_scroll.roundness = 0.5f; + btheme->tui.wcol_progress.roundness = 0.25f; + btheme->tui.wcol_list_item.roundness = 0.2f; + btheme->tui.wcol_pie_menu.roundness = 0.5f; + rgba_char_args_set_fl(btheme->tui.editor_outline, 0.25f, 0.25f, 0.25f, 1.0f); + } + } + + if (((bTheme *)U.themes.first)->tui.wcol_toolbar_item.text[3] == 0) { + struct uiWidgetColors wcol_toolbar_item = { + .outline = {0x19, 0x19, 0x19, 0xff}, + .inner = {0x46, 0x46, 0x46, 0xff}, + .inner_sel = {0xb4, 0xb4, 0xb4, 0xff}, + .item = {0x19, 0x19, 0x19, 0xff}, + + .text = {0xff, 0xff, 0xff, 0xff}, + .text_sel = {0x33, 0x33, 0x33, 0xff}, + + .shaded = 0, + .shadetop = 0, + .shadedown = 0, + .alpha_check = 0, + .roundness = 0.3f, + }; + for (bTheme *btheme = U.themes.first; btheme; btheme = btheme->next) { + btheme->tui.wcol_toolbar_item = wcol_toolbar_item; + btheme->tui.icon_saturation = 0.4f; + } + } + /** * Include next version bump. */ @@ -2780,17 +3011,20 @@ void init_userdef_do_versions(void) /* (keep this block even if it becomes empty). */ } + if (((bTheme *)U.themes.first)->tui.manipulator_hi[3] == 0) { + for (bTheme *btheme = U.themes.first; btheme; btheme = btheme->next) { + ui_theme_space_init_manipulator_colors(btheme); + } + } + if (U.pixelsize == 0.0f) U.pixelsize = 1.0f; if (U.image_draw_method == 0) U.image_draw_method = IMAGE_DRAW_METHOD_2DTEXTURE; - // keep the following until the new audaspace is default to be built with -#ifdef WITH_SYSTEM_AUDASPACE // we default to the first audio device U.audiodevice = 0; -#endif /* Not versioning, just avoid errors. */ #ifndef WITH_CYCLES |