diff options
author | Joshua Leung <aligorith@gmail.com> | 2008-02-14 08:00:23 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2008-02-14 08:00:23 +0300 |
commit | 5beaeb9f4bb1582071cf6bd72a7276a54cc4e95a (patch) | |
tree | 70813d66b5825de2ab484c9ce81b2a8b61e08ee4 | |
parent | b4f975b91a4294a4a7a32bab58eac2158bc7debe (diff) |
== Custom Bone Colours - Per Group Colour-Sets ==
Now it is possible to define a custom colour set per bone group. This allows rigs to look consistent across different computers with different themes. As such, the bone-groups buttons have been reshuffled to present the settings in a better way.
Colour sets are now selected from a menu with descriptive names, instead of using a slider. Choose the 'Custom Set' entry to use a custom set of colours for the active group. The sets of theme colours have been retained, and can be used directly, or as the basis for a new custom colour set (when any one of the colour controls is touched).
For bone-groups that haven't had any custom colour set used yet, a default 'test' set is used. This uses bright versions of the RGB colours.
-rw-r--r-- | source/blender/include/butspace.h | 1 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_action_types.h | 16 | ||||
-rw-r--r-- | source/blender/src/buttons_editing.c | 106 | ||||
-rw-r--r-- | source/blender/src/drawarmature.c | 9 | ||||
-rw-r--r-- | source/blender/src/poseobject.c | 2 |
5 files changed, 105 insertions, 29 deletions
diff --git a/source/blender/include/butspace.h b/source/blender/include/butspace.h index 7d047610a3a..5a276665240 100644 --- a/source/blender/include/butspace.h +++ b/source/blender/include/butspace.h @@ -535,6 +535,7 @@ void curvemap_buttons(struct uiBlock *block, struct CurveMapping *cumap, char la #define B_POSEGRP_RECALC 2330 #define B_POSEGRP_ADD 2331 #define B_POSEGRP_REMOVE 2332 +#define B_POSEGRP_MCUSTOM 2333 /* *********************** */ #define B_CAMBUTS 2500 diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h index 03b546f42f1..64476d10475 100644 --- a/source/blender/makesdna/DNA_action_types.h +++ b/source/blender/makesdna/DNA_action_types.h @@ -33,6 +33,7 @@ #include "DNA_listBase.h" #include "DNA_ID.h" #include "DNA_view2d_types.h" +#include "DNA_userdef_types.h" struct SpaceLink; struct Object; @@ -115,15 +116,22 @@ typedef struct bPose { * Even though all Action-Channels live in a big list per Action, each group they are in also * holds references to the achans within that list which belong to it. Care must be taken to * ensure that action-groups never end up being the sole 'owner' of a channel. + * + * + * This is also exploited for bone-groups. Bone-Groups are stored per bPose, and are used + * primarily to colour bones in the 3d-view. There are other benefits too, but those are mostly related + * to Action-Groups. */ typedef struct bActionGroup { struct bActionGroup *next, *prev; - int flag; /* settings for this action-group */ - int customCol; /* index of custom color set to use when used for bones (0=default - used for all old files) */ - char name[32]; /* name of the group */ + ListBase channels; /* Note: this must not be touched by standard listbase functions */ + + int flag; /* settings for this action-group */ + int customCol; /* index of custom color set to use when used for bones (0=default - used for all old files, -1=custom set) */ + char name[32]; /* name of the group */ - ListBase channels; /* Note: this must not be touched by standard listbase functions */ + ThemeWireColor cs; /* color set to use when customCol == -1 */ } bActionGroup; /* Action Channels belong to Actions. They are linked with an IPO block, and can also own diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index b3cdf29e336..c86c5f9c4d9 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -3889,6 +3889,17 @@ void do_armbuts(unsigned short event) if (ob && ob->pose) pose_remove_posegroup(); break; + case B_POSEGRP_MCUSTOM: + if (ob && ob->pose) { + if (ob->pose->active_group) { + bActionGroup *grp= (bActionGroup *)BLI_findlink(&ob->pose->agroups, ob->pose->active_group-1); + grp->customCol= -1; + } + + allqueue(REDRAWVIEW3D, 0); + allqueue(REDRAWBUTSEDIT, 0); + } + break; } } @@ -5039,6 +5050,32 @@ static void verify_posegroup_groupname(void *arg1, void *arg2) BLI_uniquename(&pose->agroups, grp, "Group", offsetof(bActionGroup, name), 32); } +static char *build_colorsets_menustr () +{ + DynStr *pupds= BLI_dynstr_new(); + char *str; + char buf[48]; + int i; + + /* add title first (and the "default" entry) */ + BLI_dynstr_append(pupds, "Bone Color Set%t|Default Colors%x0|"); + + /* loop through set indices, adding them */ + for (i=1; i<21; i++) { + sprintf(buf, "%d - Theme Color Set%%x%d|", i, i); + BLI_dynstr_append(pupds, buf); + } + + /* add the 'custom' entry */ + BLI_dynstr_append(pupds, "Custom Set %x-1"); + + /* convert to normal MEM_malloc'd string */ + str= BLI_dynstr_get_cstring(pupds); + BLI_dynstr_free(pupds); + + return str; +} + static void editing_panel_links(Object *ob) { uiBlock *block; @@ -5126,6 +5163,7 @@ static void editing_panel_links(Object *ob) if ((ob->pose) && (ob->flag & OB_POSEMODE) && (G.obedit != ob)) { bAction *act= ob->poselib; bPose *pose= ob->pose; + bActionGroup *grp= NULL; int count; char *menustr; @@ -5167,45 +5205,69 @@ static void editing_panel_links(Object *ob) } - /* Action Groups settings for armature reside on the right */ + /* Bone Groups settings for armature reside on the right */ xco= 315; uiDefBut(block, LABEL,0, "Bone Groups:", xco, 154, 140, 20, 0, 0, 0, 0, 0, ""); - /* add new group */ - uiDefBut(block, BUT, B_POSEGRP_ADD, "Add Group", xco,130,140,20, 0, 0, 0, 0, 0, "Add a new Pose Group for the Pose"); - - if (pose->agroups.first) { - uiBlockBeginAlign(block); + uiBlockBeginAlign(block); + if (pose->agroups.first) { /* currently 'active' group - browse groups */ count= BLI_countlist(&pose->agroups); menustr= build_posegroups_menustr(pose, 0); - uiDefButI(block, MENU, B_POSEGRP_RECALC, menustr, xco, 85,18,20, &pose->active_group, 1, count, 0, 0, "Browses Pose Groups available for Armature. Click to change."); + uiDefButI(block, MENU, B_POSEGRP_RECALC, menustr, xco, 130,18,20, &pose->active_group, 1, count, 0, 0, "Browses Bone Groups available for Armature. Click to change."); MEM_freeN(menustr); - + /* currently 'active' group - change name */ if (pose->active_group) { - bActionGroup *grp= (bActionGroup *)BLI_findlink(&pose->agroups, pose->active_group-1); + grp= (bActionGroup *)BLI_findlink(&pose->agroups, pose->active_group-1); /* active group */ - but= uiDefBut(block, TEX, REDRAWBUTSEDIT,"", xco+18,85,140-18-20,20, grp->name, 0, 31, 0, 0, "Displays current Pose Group name. Click to change."); + but= uiDefBut(block, TEX, REDRAWBUTSEDIT,"", xco+18,130,140-18-20,20, grp->name, 0, 31, 0, 0, "Displays current Bone Group name. Click to change."); uiButSetFunc(but, verify_posegroup_groupname, pose, grp); - uiDefIconBut(block, BUT, B_POSEGRP_REMOVE, VICON_X, xco+140-20, 85, 20, 20, NULL, 0.0, 0.0, 0.0, 0.0, "Remove this Pose Group"); - - /* set custom color set */ - uiDefButI(block, NUM,B_POSEGRP_RECALC, "GroupColor: ", xco,65,110,19, &grp->customCol, 0, 20, 0.0, 0.0, "Index of set of Custom Colors to shade Group's bones with. 0 = Use Default Color Scheme"); - if (grp->customCol) { + uiDefIconBut(block, BUT, B_POSEGRP_REMOVE, VICON_X, xco+140-20, 130, 20, 20, NULL, 0.0, 0.0, 0.0, 0.0, "Remove this Bone Group"); + } + } + + uiDefBut(block, BUT, B_POSEGRP_ADD, "Add Group", xco,110,140,20, 0, 21, 0, 0, 0, "Add a new Bone Group for the Pose"); + uiBlockEndAlign(block); + + /* colour set for 'active' group */ + if (pose->active_group && grp) { + uiBlockBeginAlign(block); + menustr= build_colorsets_menustr(); + uiDefButI(block, MENU,B_POSEGRP_RECALC, menustr, xco,85,140,19, &grp->customCol, -1, 20, 0.0, 0.0, "Index of set of Custom Colors to shade Group's bones with. 0 = Use Default Color Scheme, -1 = Use Custom Color Scheme"); + MEM_freeN(menustr); + + /* show color-selection/preview */ + if (grp->customCol) { + if (grp->customCol > 0) { + /* copy theme colors on-to group's custom color in case user tries to edit color */ bTheme *btheme= U.themes.first; ThemeWireColor *col_set= &btheme->tarm[(grp->customCol - 1)]; - uiSetButLock(1, "To change these colors, see Themes -> Bone Color Sets"); - - uiDefButC(block, COL, B_POSEGRP_RECALC, "", xco+110, 65, 10, 19, col_set->solid, 0, 0, 0, 0, "Color to use for surface of bones. See current theme in Info Window."); - uiDefButC(block, COL, B_POSEGRP_RECALC, "", xco+120, 65, 10, 19, col_set->select, 0, 0, 0, 0, "Color to use for 'selected' bones. See current theme in Info Window."); - uiDefButC(block, COL, B_POSEGRP_RECALC, "", xco+130, 65, 10, 19, col_set->active, 0, 0, 0, 0, "Color to use for 'active' bones. See current theme in Info Window."); - - uiClearButLock(); + memcpy(&grp->cs, col_set, sizeof(ThemeWireColor)); } + else { + /* init custom colours with a generic multi-colour rgb set, if not initialised already */ + if (grp->cs.solid[0] == 0) { + /* define for setting colors in theme below */ + #define SETCOL(col, r, g, b, a) col[0]=r; col[1]=g; col[2]= b; col[3]= a; + + SETCOL(grp->cs.solid, 0xff, 0x00, 0x00, 255); + SETCOL(grp->cs.select, 0x81, 0xe6, 0x14, 255); + SETCOL(grp->cs.active, 0x18, 0xb6, 0xe0, 255); + + #undef SETCOL + } + } + + /* color changing */ + uiDefButC(block, COL, B_POSEGRP_MCUSTOM, "", xco, 65, 30, 19, grp->cs.solid, 0, 0, 0, 0, "Color to use for surface of bones"); + uiDefButC(block, COL, B_POSEGRP_MCUSTOM, "", xco+30, 65, 30, 19, grp->cs.select, 0, 0, 0, 0, "Color to use for 'selected' bones"); + uiDefButC(block, COL, B_POSEGRP_MCUSTOM, "", xco+60, 65, 30, 19, grp->cs.active, 0, 0, 0, 0, "Color to use for 'active' bones"); + + uiDefButBitS(block, TOG, TH_WIRECOLOR_CONSTCOLS, B_POSEGRP_MCUSTOM, "ConstCols", xco+90,65,50,20, &grp->cs.flag, 0, 0, 0, 0, "Allow the use of colors indicating constraints/keyed status"); } uiBlockEndAlign(block); } diff --git a/source/blender/src/drawarmature.c b/source/blender/src/drawarmature.c index 66cd9a7a716..9b8905b782b 100644 --- a/source/blender/src/drawarmature.c +++ b/source/blender/src/drawarmature.c @@ -109,6 +109,7 @@ static void set_pchan_colorset (Object *ob, bPoseChannel *pchan) { bPose *pose= (ob) ? ob->pose : NULL; bArmature *arm= (ob) ? ob->data : NULL; + bActionGroup *grp= NULL; short color_index= 0; /* sanity check */ @@ -123,7 +124,7 @@ static void set_pchan_colorset (Object *ob, bPoseChannel *pchan) * has been set to use one */ if (pchan->agrp_index) { - bActionGroup *grp= (bActionGroup *)BLI_findlink(&pose->agroups, (pchan->agrp_index - 1)); + grp= (bActionGroup *)BLI_findlink(&pose->agroups, (pchan->agrp_index - 1)); if (grp) color_index= grp->customCol; } @@ -132,10 +133,14 @@ static void set_pchan_colorset (Object *ob, bPoseChannel *pchan) /* bcolor is a pointer to the color set to use. If NULL, then the default * color set (based on the theme colors for 3d-view) is used. */ - if (color_index) { + if (color_index > 0) { bTheme *btheme= U.themes.first; bcolor= &btheme->tarm[(color_index - 1)]; } + else if (color_index == -1) { + /* use the group's own custom color set */ + bcolor= (grp)? &grp->cs : NULL; + } else bcolor= NULL; } diff --git a/source/blender/src/poseobject.c b/source/blender/src/poseobject.c index 5f519f428a9..714f105127b 100644 --- a/source/blender/src/poseobject.c +++ b/source/blender/src/poseobject.c @@ -986,7 +986,7 @@ char *build_posegroups_menustr (bPose *pose, short for_pupmenu) else BLI_dynstr_append(pupds, "BG: [None]%x0|"); - /* loop through markers, adding them */ + /* loop through groups, adding them */ for (grp= pose->agroups.first, i=1; grp; grp=grp->next, i++) { if (for_pupmenu == 0) BLI_dynstr_append(pupds, "BG: "); |