From e34e5ce332aaf2fa16426eaa217f5c6bb78d0f63 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 19 May 2016 03:25:00 +1200 Subject: Theme Color Sets - Dynamically generated icons The theme color set selector (for Bone Groups) will now show previews of what each color set looks like. It does so using a 3-color band icon. --- source/blender/editors/include/UI_icons.h | 22 ++++++ source/blender/editors/interface/interface_icons.c | 78 ++++++++++++++++++++++ source/blender/makesrna/intern/rna_pose.c | 42 ++++++------ 3 files changed, 122 insertions(+), 20 deletions(-) diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h index 76ff9e0fbd8..2c80701bf69 100644 --- a/source/blender/editors/include/UI_icons.h +++ b/source/blender/editors/include/UI_icons.h @@ -1020,3 +1020,25 @@ DEF_VICO(KEYTYPE_KEYFRAME_VEC) DEF_VICO(KEYTYPE_BREAKDOWN_VEC) DEF_VICO(KEYTYPE_EXTREME_VEC) DEF_VICO(KEYTYPE_JITTER_VEC) + +DEF_VICO(COLORSET_01_VEC) +DEF_VICO(COLORSET_02_VEC) +DEF_VICO(COLORSET_03_VEC) +DEF_VICO(COLORSET_04_VEC) +DEF_VICO(COLORSET_05_VEC) +DEF_VICO(COLORSET_06_VEC) +DEF_VICO(COLORSET_07_VEC) +DEF_VICO(COLORSET_08_VEC) +DEF_VICO(COLORSET_09_VEC) +DEF_VICO(COLORSET_10_VEC) +DEF_VICO(COLORSET_11_VEC) +DEF_VICO(COLORSET_12_VEC) +DEF_VICO(COLORSET_13_VEC) +DEF_VICO(COLORSET_14_VEC) +DEF_VICO(COLORSET_15_VEC) +DEF_VICO(COLORSET_16_VEC) +DEF_VICO(COLORSET_17_VEC) +DEF_VICO(COLORSET_18_VEC) +DEF_VICO(COLORSET_19_VEC) +DEF_VICO(COLORSET_20_VEC) + diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 9093b965939..0da21fd442f 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -511,6 +511,63 @@ static void vicon_keytype_jitter_draw(int x, int y, int w, int h, float alpha) vicon_keytype_draw_wrapper(x, y, w, h, alpha, BEZT_KEYTYPE_JITTER); } +static void vicon_colorset_draw(int index, int x, int y, int w, int h, float UNUSED(alpha)) +{ + bTheme *btheme = UI_GetTheme(); + ThemeWireColor *cs = &btheme->tarm[index]; + + /* Draw three bands of color: One per color + * x-----a-----b-----c + * | N | S | A | + * x-----a-----b-----c + */ + const int a = x + w / 3; + const int b = x + w / 3 * 2; + const int c = x + w; + + /* XXX: Include alpha into this... */ + /* normal */ + glColor3ubv(cs->solid); + glRecti(x, y, a, y + h); + + /* selected */ + glColor3ubv(cs->select); + glRecti(a, y, b, y + h); + + /* active */ + glColor3ubv(cs->active); + glRecti(b, y, c, y + h); +} + +#define DEF_VICON_COLORSET_DRAW_NTH(prefix, index) \ + static void vicon_colorset_draw_##prefix(int x, int y, int w, int h, float alpha) \ + { \ + vicon_colorset_draw(index, x, y, w, h, alpha); \ + } + +DEF_VICON_COLORSET_DRAW_NTH(01, 0) +DEF_VICON_COLORSET_DRAW_NTH(02, 1) +DEF_VICON_COLORSET_DRAW_NTH(03, 2) +DEF_VICON_COLORSET_DRAW_NTH(04, 3) +DEF_VICON_COLORSET_DRAW_NTH(05, 4) +DEF_VICON_COLORSET_DRAW_NTH(06, 5) +DEF_VICON_COLORSET_DRAW_NTH(07, 6) +DEF_VICON_COLORSET_DRAW_NTH(08, 7) +DEF_VICON_COLORSET_DRAW_NTH(09, 8) +DEF_VICON_COLORSET_DRAW_NTH(10, 9) +DEF_VICON_COLORSET_DRAW_NTH(11, 10) +DEF_VICON_COLORSET_DRAW_NTH(12, 11) +DEF_VICON_COLORSET_DRAW_NTH(13, 12) +DEF_VICON_COLORSET_DRAW_NTH(14, 13) +DEF_VICON_COLORSET_DRAW_NTH(15, 14) +DEF_VICON_COLORSET_DRAW_NTH(16, 15) +DEF_VICON_COLORSET_DRAW_NTH(17, 16) +DEF_VICON_COLORSET_DRAW_NTH(18, 17) +DEF_VICON_COLORSET_DRAW_NTH(19, 18) +DEF_VICON_COLORSET_DRAW_NTH(20, 19) + +#undef DEF_VICON_COLORSET_DRAW_NTH + #ifndef WITH_HEADLESS static void init_brush_icons(void) @@ -741,6 +798,27 @@ static void init_internal_icons(void) def_internal_vicon(VICO_KEYTYPE_BREAKDOWN_VEC, vicon_keytype_breakdown_draw); def_internal_vicon(VICO_KEYTYPE_EXTREME_VEC, vicon_keytype_extreme_draw); def_internal_vicon(VICO_KEYTYPE_JITTER_VEC, vicon_keytype_jitter_draw); + + def_internal_vicon(VICO_COLORSET_01_VEC, vicon_colorset_draw_01); + def_internal_vicon(VICO_COLORSET_02_VEC, vicon_colorset_draw_02); + def_internal_vicon(VICO_COLORSET_03_VEC, vicon_colorset_draw_03); + def_internal_vicon(VICO_COLORSET_04_VEC, vicon_colorset_draw_04); + def_internal_vicon(VICO_COLORSET_05_VEC, vicon_colorset_draw_05); + def_internal_vicon(VICO_COLORSET_06_VEC, vicon_colorset_draw_06); + def_internal_vicon(VICO_COLORSET_07_VEC, vicon_colorset_draw_07); + def_internal_vicon(VICO_COLORSET_08_VEC, vicon_colorset_draw_08); + def_internal_vicon(VICO_COLORSET_09_VEC, vicon_colorset_draw_09); + def_internal_vicon(VICO_COLORSET_10_VEC, vicon_colorset_draw_10); + def_internal_vicon(VICO_COLORSET_11_VEC, vicon_colorset_draw_11); + def_internal_vicon(VICO_COLORSET_12_VEC, vicon_colorset_draw_12); + def_internal_vicon(VICO_COLORSET_13_VEC, vicon_colorset_draw_13); + def_internal_vicon(VICO_COLORSET_14_VEC, vicon_colorset_draw_14); + def_internal_vicon(VICO_COLORSET_15_VEC, vicon_colorset_draw_15); + def_internal_vicon(VICO_COLORSET_16_VEC, vicon_colorset_draw_16); + def_internal_vicon(VICO_COLORSET_17_VEC, vicon_colorset_draw_17); + def_internal_vicon(VICO_COLORSET_18_VEC, vicon_colorset_draw_18); + def_internal_vicon(VICO_COLORSET_19_VEC, vicon_colorset_draw_19); + def_internal_vicon(VICO_COLORSET_20_VEC, vicon_colorset_draw_20); IMB_freeImBuf(b16buf); IMB_freeImBuf(b32buf); diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index fb7d5141a6d..06823a26c77 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -43,6 +43,8 @@ #include "BLT_translation.h" +#include "UI_resources.h" + #include "WM_types.h" @@ -65,26 +67,26 @@ EnumPropertyItem rna_enum_posebone_rotmode_items[] = { /* Bone and Group Color Sets */ EnumPropertyItem rna_enum_color_sets_items[] = { {0, "DEFAULT", 0, "Default Colors", ""}, - {1, "THEME01", 0, "01 - Theme Color Set", ""}, - {2, "THEME02", 0, "02 - Theme Color Set", ""}, - {3, "THEME03", 0, "03 - Theme Color Set", ""}, - {4, "THEME04", 0, "04 - Theme Color Set", ""}, - {5, "THEME05", 0, "05 - Theme Color Set", ""}, - {6, "THEME06", 0, "06 - Theme Color Set", ""}, - {7, "THEME07", 0, "07 - Theme Color Set", ""}, - {8, "THEME08", 0, "08 - Theme Color Set", ""}, - {9, "THEME09", 0, "09 - Theme Color Set", ""}, - {10, "THEME10", 0, "10 - Theme Color Set", ""}, - {11, "THEME11", 0, "11 - Theme Color Set", ""}, - {12, "THEME12", 0, "12 - Theme Color Set", ""}, - {13, "THEME13", 0, "13 - Theme Color Set", ""}, - {14, "THEME14", 0, "14 - Theme Color Set", ""}, - {15, "THEME15", 0, "15 - Theme Color Set", ""}, - {16, "THEME16", 0, "16 - Theme Color Set", ""}, - {17, "THEME17", 0, "17 - Theme Color Set", ""}, - {18, "THEME18", 0, "18 - Theme Color Set", ""}, - {19, "THEME19", 0, "19 - Theme Color Set", ""}, - {20, "THEME20", 0, "20 - Theme Color Set", ""}, + {1, "THEME01", VICO_COLORSET_01_VEC, "01 - Theme Color Set", ""}, + {2, "THEME02", VICO_COLORSET_02_VEC, "02 - Theme Color Set", ""}, + {3, "THEME03", VICO_COLORSET_03_VEC, "03 - Theme Color Set", ""}, + {4, "THEME04", VICO_COLORSET_04_VEC, "04 - Theme Color Set", ""}, + {5, "THEME05", VICO_COLORSET_05_VEC, "05 - Theme Color Set", ""}, + {6, "THEME06", VICO_COLORSET_06_VEC, "06 - Theme Color Set", ""}, + {7, "THEME07", VICO_COLORSET_07_VEC, "07 - Theme Color Set", ""}, + {8, "THEME08", VICO_COLORSET_08_VEC, "08 - Theme Color Set", ""}, + {9, "THEME09", VICO_COLORSET_09_VEC, "09 - Theme Color Set", ""}, + {10, "THEME10", VICO_COLORSET_10_VEC, "10 - Theme Color Set", ""}, + {11, "THEME11", VICO_COLORSET_11_VEC, "11 - Theme Color Set", ""}, + {12, "THEME12", VICO_COLORSET_12_VEC, "12 - Theme Color Set", ""}, + {13, "THEME13", VICO_COLORSET_13_VEC, "13 - Theme Color Set", ""}, + {14, "THEME14", VICO_COLORSET_14_VEC, "14 - Theme Color Set", ""}, + {15, "THEME15", VICO_COLORSET_15_VEC, "15 - Theme Color Set", ""}, + {16, "THEME16", VICO_COLORSET_16_VEC, "16 - Theme Color Set", ""}, + {17, "THEME17", VICO_COLORSET_17_VEC, "17 - Theme Color Set", ""}, + {18, "THEME18", VICO_COLORSET_18_VEC, "18 - Theme Color Set", ""}, + {19, "THEME19", VICO_COLORSET_19_VEC, "19 - Theme Color Set", ""}, + {20, "THEME20", VICO_COLORSET_20_VEC, "20 - Theme Color Set", ""}, {-1, "CUSTOM", 0, "Custom Color Set", ""}, {0, NULL, 0, NULL, NULL} }; -- cgit v1.2.3